@arcgis/core 4.32.0-next.20250101 → 4.32.0-next.20250103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Color.js +1 -1
- package/PopupTemplate.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/geometry/extendedUnitData.js +5 -0
- package/arcade/geometry/functions.js +5 -0
- package/arcade/geometry/operators.js +5 -0
- package/arcade/geometry/unitConversion.js +5 -0
- package/arcade/geometry/wkt.js +5 -0
- package/arcade/languageUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{e371f4f0eb3c22f222df.js → 005727711cca0614c2ab.js} +2 -2
- package/assets/esri/core/workers/chunks/{e371f4f0eb3c22f222df.js.LICENSE.txt → 005727711cca0614c2ab.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{2d908c115ea18e813b95.js → 00c0fbe19c12691cf2c3.js} +1 -1
- package/assets/esri/core/workers/chunks/08e28328385066c519c2.js +1 -0
- package/assets/esri/core/workers/chunks/{0e735d01296d340b393e.js → 0b95ec12218f3c04df18.js} +1 -1
- package/assets/esri/core/workers/chunks/{59bf879b4802a5ba431e.js → 0ee669947c23f469e357.js} +1 -1
- package/assets/esri/core/workers/chunks/116103ecec27cce47a2f.js +1 -0
- package/assets/esri/core/workers/chunks/11f00218905f0db447ff.js +1 -0
- package/assets/esri/core/workers/chunks/14b87f3dd9942e6b19d0.js +1 -0
- package/assets/esri/core/workers/chunks/16d7c07e1c11b88dae84.js +1 -0
- package/assets/esri/core/workers/chunks/1d04fe800cb98e4d6bc4.js +1 -0
- package/assets/esri/core/workers/chunks/{71f6e5742cf0c482066b.js → 1dc6b5b177022b80c473.js} +1 -1
- package/assets/esri/core/workers/chunks/{59455e2dd44b4c01cc76.js → 2586741c359057b3f626.js} +1 -1
- package/assets/esri/core/workers/chunks/{250a810dd4e1ff293564.js → 318a39b56851e707edad.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1e4813f0c73fc2a483c.js → 370b230fd2d7703d0698.js} +2 -2
- package/assets/esri/core/workers/chunks/{b1e4813f0c73fc2a483c.js.LICENSE.txt → 370b230fd2d7703d0698.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/38d03fe352057fb375b5.js +1 -0
- package/assets/esri/core/workers/chunks/{ebf9caf2dc8af89afec2.js → 42aa697b4718b75b8cb2.js} +2 -2
- package/assets/esri/core/workers/chunks/{ebf9caf2dc8af89afec2.js.LICENSE.txt → 42aa697b4718b75b8cb2.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{801dbea20966806db1c9.js → 53cd990b2c988518de6d.js} +1 -1
- package/assets/esri/core/workers/chunks/5a1eb0d1e25ff5574c43.js +1 -0
- package/assets/esri/core/workers/chunks/6157c49e7431f5868c77.js +1 -0
- package/assets/esri/core/workers/chunks/{eef2d94a73064f9bc085.js → 61d64f163840563017d5.js} +1 -1
- package/assets/esri/core/workers/chunks/6d218fb5e0f0a04d72c5.js +2 -0
- package/assets/esri/core/workers/chunks/{d82b3e2905cab511ff3a.js.LICENSE.txt → 6d218fb5e0f0a04d72c5.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/6ed57d01be6bc054c7cd.js +1 -0
- package/assets/esri/core/workers/chunks/7254956381e823219db0.js +1 -0
- package/assets/esri/core/workers/chunks/740e6bdb3b76f2ea6d61.js +1 -0
- package/assets/esri/core/workers/chunks/756c2f7c8659deab6c96.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{56fc353421252f2d0a99.js → 75e8ba7e02647b7216ae.js} +1 -1
- package/assets/esri/core/workers/chunks/89d7eec47e5b29935d92.js +1 -0
- package/assets/esri/core/workers/chunks/8cd2c9ec1e541836b81c.js +1 -0
- package/assets/esri/core/workers/chunks/{0b3e1e903120da297641.js → 932375de79e3d33bc4d7.js} +1 -1
- package/assets/esri/core/workers/chunks/{263adfd1c2641ef5c0f5.js → 95f23bd17ce9e07fc8ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{7de9c01849c4aa1940e7.js → 986889cea53c4a470347.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc6160e8ab3cea4040c2.js → 9e9b2fd958e816b1b5f6.js} +1 -1
- package/assets/esri/core/workers/chunks/a57cead317eb2fc9afd8.js +1 -0
- package/assets/esri/core/workers/chunks/acec58a7f23b2cc938ee.js +1 -0
- package/assets/esri/core/workers/chunks/b0f4254d8a32dd713009.js +1 -0
- package/assets/esri/core/workers/chunks/b277b8c2f556918e4f9a.js +1 -0
- package/assets/esri/core/workers/chunks/{deffd56e39ce725ce377.js → b30046a40bcfbec8abe4.js} +1 -1
- package/assets/esri/core/workers/chunks/{5c11e2e65b97565e5003.js → b7db64b07edb0b37ece1.js} +1 -1
- package/assets/esri/core/workers/chunks/bd1fb82e8bac439d05ea.js +1 -0
- package/assets/esri/core/workers/chunks/bf0a0ca7fdac98f06a89.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/c44ce0302dc82fb66ada.js +1 -0
- package/assets/esri/core/workers/chunks/c52872a50a5989121388.js +1 -0
- package/assets/esri/core/workers/chunks/c8cd6ba5600d8ff8db0b.js +2 -0
- package/assets/esri/core/workers/chunks/{a100fb789d72410f8d4f.js.LICENSE.txt → c8cd6ba5600d8ff8db0b.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{57c1370b310768c0790a.js → ca1e186f136abb23ae4b.js} +1 -1
- package/assets/esri/core/workers/chunks/{d14e4fc82ad772899336.js → ca4a37bdc0f7fb705146.js} +1 -1
- package/assets/esri/core/workers/chunks/cb94fc9b0f613ad50b3f.js +1 -0
- package/assets/esri/core/workers/chunks/d20764cc99fcabcb7cbf.js +1 -0
- package/assets/esri/core/workers/chunks/df18a72e3625cbe31935.js +1 -0
- package/assets/esri/core/workers/chunks/eff8fcb6393cd1193cbc.js +1 -0
- package/assets/esri/core/workers/chunks/f19d3c855f6e93544918.js +1 -0
- package/assets/esri/core/workers/chunks/{60b40b2319d1651dd150.js → f7e50a8284d12da21355.js} +1 -1
- package/assets/esri/core/workers/chunks/f9c0d571f62e611ffe2b.js +1 -0
- package/assets/esri/core/workers/chunks/fdfe8e0d942b78f08191.js +1 -0
- package/assets/esri/core/workers/chunks/ff21207f46a354786eed.js +1 -0
- package/chunks/Bufferer-BiY2mtjI.js +1 -1
- package/chunks/Centroid-DZi-eb9F.js +1 -1
- package/chunks/Clipper-a9xfvRaw.js +1 -1
- package/chunks/CrackAndCluster-CfzXpEle.js +1 -1
- package/chunks/Distance2DCalculator-eS0piaux.js +1 -1
- package/chunks/GeodeticDistanceCalculator-bNilDneE.js +1 -1
- package/chunks/Geometry.js +1 -1
- package/chunks/GeometryCleaner-DVgW95-D.js +1 -1
- package/chunks/Intersector-K1VmdfQW.js +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/OperatorClip.js +1 -1
- package/chunks/OperatorCrosses.js +1 -1
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorDensify.js +1 -1
- package/chunks/OperatorDifference.js +1 -1
- package/chunks/OperatorGeneralize.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticDistance.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntersection.js +1 -1
- package/chunks/OperatorIntersects.js +1 -1
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorOverlaps.js +1 -1
- package/chunks/OperatorProject.js +1 -1
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingDensify.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorSimplify.js +1 -1
- package/chunks/OperatorTouches.js +1 -1
- package/chunks/OperatorUnion.js +1 -1
- package/chunks/OperatorWithin.js +1 -1
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/SideCalculator2D-Bf4QCxCR.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/Tick.js +1 -1
- package/chunks/Transformation2D.js +1 -1
- package/chunks/arcade.js +1 -1
- package/chunks/areaOperator.js +5 -0
- package/chunks/array.js +1 -1
- package/chunks/bufferOperator.js +5 -0
- package/chunks/centroidOperator.js +5 -0
- package/chunks/chartUtilsAm5.js +1 -1
- package/chunks/clipOperator.js +5 -0
- package/chunks/containsOperator.js +5 -0
- package/chunks/convexHullOperator.js +5 -0
- package/chunks/crossesOperator.js +5 -0
- package/chunks/cutOperator.js +5 -0
- package/chunks/densifyOperator.js +5 -0
- package/chunks/differenceOperator.js +5 -0
- package/chunks/disjointOperator.js +5 -0
- package/chunks/distanceOperator.js +5 -0
- package/chunks/equalsOperator.js +5 -0
- package/chunks/generalizeOperator.js +5 -0
- package/chunks/geodesicBufferOperator.js +5 -0
- package/chunks/geodeticAreaOperator.js +5 -0
- package/chunks/geodeticDensifyOperator.js +5 -0
- package/chunks/geodeticLengthOperator.js +5 -0
- package/chunks/i3s.js +1 -1
- package/chunks/intersectionOperator.js +5 -0
- package/chunks/intersectsOperator.js +5 -0
- package/chunks/languageUtils.js +1 -1
- package/chunks/lclayout.js +1 -1
- package/chunks/lengthOperator.js +5 -0
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/offsetOperator.js +5 -0
- package/chunks/overlapsOperator.js +5 -0
- package/chunks/pe-wasm.js +1 -1
- package/chunks/proximityOperator.js +5 -0
- package/chunks/relateOperator.js +5 -0
- package/chunks/simplifyOperator.js +5 -0
- package/chunks/symmetricDifferenceOperator.js +5 -0
- package/chunks/touchesOperator.js +5 -0
- package/chunks/unionOperator.js +5 -0
- package/chunks/vxlLayer.js +1 -1
- package/chunks/withinOperator.js +5 -0
- package/copyright.txt +2 -2
- package/core/Evented.js +1 -1
- package/geometry/operators/areaOperator.js +1 -1
- package/geometry/operators/bufferOperator.js +1 -1
- package/geometry/operators/centroidOperator.js +1 -1
- package/geometry/operators/clipOperator.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/convexHullOperator.js +1 -1
- package/geometry/operators/crossesOperator.js +1 -1
- package/geometry/operators/cutOperator.js +1 -1
- package/geometry/operators/densifyOperator.js +1 -1
- package/geometry/operators/differenceOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/distanceOperator.js +1 -1
- package/geometry/operators/equalsOperator.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/generalizeOperator.js +1 -1
- package/geometry/operators/geodesicBufferOperator.js +1 -1
- package/geometry/operators/geodeticAreaOperator.js +1 -1
- package/geometry/operators/geodeticDensifyOperator.js +1 -1
- package/geometry/operators/geodeticLengthOperator.js +1 -1
- package/geometry/operators/gx/operatorAffineTransform.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBoundary.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorConvexHull.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorLocateBetween.js +1 -1
- package/geometry/operators/gx/operatorMinimumBoundingCircle.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/gx/operatorSinglePartToMultiPart.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/intersectionOperator.js +1 -1
- package/geometry/operators/intersectsOperator.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/json/disjointOperator.js +1 -1
- package/geometry/operators/lengthOperator.js +1 -1
- package/geometry/operators/offsetOperator.js +1 -1
- package/geometry/operators/overlapsOperator.js +1 -1
- package/geometry/operators/proximityOperator.js +1 -1
- package/geometry/operators/relateOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/simplifyOperator.js +1 -1
- package/geometry/operators/support/apiConverter.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/operators/symmetricDifferenceOperator.js +1 -1
- package/geometry/operators/touchesOperator.js +1 -1
- package/geometry/operators/unionOperator.js +1 -1
- package/geometry/operators/withinOperator.js +1 -1
- package/geometry/support/contains.js +1 -1
- package/kernel.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/wmtsUtils.js +1 -1
- package/package.json +3 -3
- package/smartMapping/renderers/support/utils.js +1 -1
- package/smartMapping/symbology/support/Theme.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/interfaces.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/Legend/support/heatmapRampUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/assets/esri/core/workers/chunks/015285436ca965f94e17.js +0 -1
- package/assets/esri/core/workers/chunks/048d296efa26ccd79056.js +0 -1
- package/assets/esri/core/workers/chunks/0e0b978459d70b15acb5.js +0 -1
- package/assets/esri/core/workers/chunks/10fa211987b16fd71a1a.js +0 -1
- package/assets/esri/core/workers/chunks/200a5f1864c2c2f7536c.js +0 -1
- package/assets/esri/core/workers/chunks/23a697d48f6e45cc033e.js +0 -1
- package/assets/esri/core/workers/chunks/29b610ff44708e044cbd.js +0 -1
- package/assets/esri/core/workers/chunks/3600125c58d5d04c515a.js +0 -1
- package/assets/esri/core/workers/chunks/457d4abc938d14f28e31.js +0 -1
- package/assets/esri/core/workers/chunks/4b5dbdcad438cb2dd4bf.js +0 -1
- package/assets/esri/core/workers/chunks/69efc716991a407c3d23.js +0 -1
- package/assets/esri/core/workers/chunks/6e254e846e284223ef63.js +0 -1
- package/assets/esri/core/workers/chunks/785610aa615198fd3815.js +0 -1
- package/assets/esri/core/workers/chunks/7bf7aace72f81f5de4e4.js +0 -1
- package/assets/esri/core/workers/chunks/7ea3d652536e1d79dfc6.js +0 -1
- package/assets/esri/core/workers/chunks/816c9c81352cd0ca8ce8.js +0 -1
- package/assets/esri/core/workers/chunks/9291508232b23f030178.js +0 -1
- package/assets/esri/core/workers/chunks/9fc49968dea8e2b64f3e.js +0 -1
- package/assets/esri/core/workers/chunks/a0b3d70a1b0360084593.js +0 -1
- package/assets/esri/core/workers/chunks/a100fb789d72410f8d4f.js +0 -2
- package/assets/esri/core/workers/chunks/b4d76d46661aba356ea3.js +0 -1
- package/assets/esri/core/workers/chunks/cb3af81e1fe6405c4885.js +0 -1
- package/assets/esri/core/workers/chunks/cbf57abb537e86c1dd7f.js +0 -1
- package/assets/esri/core/workers/chunks/cebdf2f88c4d2ad8baab.js +0 -1
- package/assets/esri/core/workers/chunks/d56d77125798beb7e493.js +0 -1
- package/assets/esri/core/workers/chunks/d82b3e2905cab511ff3a.js +0 -2
- package/assets/esri/core/workers/chunks/e2f91098793b8742fae6.js +0 -1
- package/assets/esri/core/workers/chunks/f25c04cf1a4bc1d2636a.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{k as t,t as e,g as s,w as i,G as n,y as r,u as o,a,i as h,d as m,z as u,f as l,A as c,e as d,o as g,r as _,p}from"./Geometry.js";import{P as f,m as x,l as y,O as P,Q as v,e as C,R as b,x as E,E as D,b as S,o as w,D as A,U as T,V as I,j as N,a as q,W as M,X as Y,K as X,Y as F,Z as R,_ as L,$ as z,H as V,a0 as B,T as k,a1 as G,a2 as H,a3 as W,v as j,M as Z,F as U,a4 as O,B as Q,a5 as K,a6 as $,a7 as J,a8 as tt,a9 as et,aa as st,ab as it,ac as nt,q as rt,ad as ot,ae as at,af as ht,ag as mt,ah as ut,n as lt,s as ct,ai as dt,C as gt,aj as _t,ak as pt,al as ft,d as xt,am as yt,an as Pt,r as vt,ao as Ct,ap as bt,aq as Et,u as Dt,ar as St,as as wt,at as At,au as Tt,av as It}from"./Transformation2D.js";import{G as Nt}from"./SimpleGeometryCursor.js";class qt{static construct(t,e,s,i){return new qt(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new qt(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new qt(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return f.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(e){void 0!==e.xmin?(this.xmin=e.xmin,this.xmax=e.xmax,this.ymin=e.ymin,this.ymax=e.ymax):void 0!==e.x?(this.xmin=e.x,this.xmax=e.x,this.ymin=e.y,this.ymax=e.y):void 0!==e.pt1?(this.xmin=e.pt1.x,this.ymin=e.pt1.y,this.xmax=e.pt2.x,this.ymax=e.pt2.y,this.normalize()):void 0!==e.env2D?(this.xmin=e.env2D.xmin,this.xmax=e.env2D.xmax,this.ymin=e.env2D.ymin,this.ymax=e.env2D.ymax,this.normalize()):void 0!==e.pt?(this.xmin=e.pt.x,this.xmax=e.pt.x,this.ymin=e.pt.y,this.ymax=e.pt.y):void 0!==e.center?(this.xmin=e.center.x-.5*e.width,this.xmax=this.xmin+e.width,this.ymin=e.center.y-.5*e.height,this.ymax=this.ymin+e.height,this.normalize()):t("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let i=1,n=2*e;i<n;i+=2){if(!this.isEmpty()){for(let t=i,n=2*e;t<n;t+=2)this.mergeNeCoords(s[t],s[t+1]);return}this.setCoords({x:s[i],y:s[i+1]}),i+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new f(this.xmin,this.ymin)}getLowerRight(){return new f(this.xmax,this.ymin)}getUpperLeft(){return new f(this.xmin,this.ymax)}getUpperRight(){return new f(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new f(this.xmin,this.ymin);case 1:return new f(this.xmin,this.ymax);case 2:return new f(this.xmax,this.ymax);default:return new f(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,r=e.y-t.y;if(Math.abs(n)>Math.abs(r)?s&qt.XMASK?(s&qt.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&qt.XMASK?(i&qt.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&qt.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):(i&qt.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s&qt.YMASK?(s&qt.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):i&qt.YMASK?(i&qt.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s?(s&qt.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&qt.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),n=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),n=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),n=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),r=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),n=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),r=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=x(f,4);this.queryCorners(s);const i=x(f,4);t.queryCorners(i);for(let n=0;n<4;n++)for(let t=0;t<4;t++){const r=f.sqrDistance(s[n],i[t]);r>e&&(e=r)}return e}sqrMaxMinDistance(t){const e=f.sqrDistance(t,this.getLowerLeft()),s=f.sqrDistance(t,this.getUpperLeft()),i=f.sqrDistance(t,this.getLowerRight()),n=f.sqrDistance(t,this.getUpperRight());let r,o=Math.max(e,s);return r=Math.max(e,i),o>r&&(o=r),r=Math.max(s,n),o>r&&(o=r),r=Math.max(i,n),o>r&&(o=r),o}sqrMinDistance(t){if(this.contains(t))return 0;return this.sqrDistance(t)}sqrMaxDistance(t){let e=f.sqrDistance(t,this.getLowerLeft());return e=Math.max(f.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(f.sqrDistance(t,this.getUpperRight()),e),e=Math.max(f.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=y(t.x,this.xmin,this.xmax),s=y(t.y,this.ymin,this.ymax);return f.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new f;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}querySide(t,s){switch(t){case 0:s.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:s.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:s.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:s.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:e("query_side")}return s}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){if(this.isEmpty())return P();return(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*P()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}qt.XLESSXMIN=1,qt.YLESSYMIN=4,qt.XMASK=3,qt.YMASK=12;const Mt=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],Yt=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],Xt=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],Ft=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],Rt=[4,8,4,8,1],Lt=25;function zt(){return new Array(Lt)}let Vt=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return Xt[t]}static getPersistence(t){return Ft[t]}static getPersistenceSize(t){return Rt[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return Yt[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return Mt[t]}static isDefaultValue(t,e){return v(Mt[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=new Array(Lt),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=14;for(;s<n;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let r=0;for(s=0,n=this.getAttributeCount();s<n;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=r;for(let t=0;t<i;t++)this.m_defaultPointAttributes[r]=n,r++}}};class Bt{static construct(t,e,s){return new Bt(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new Bt(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new Bt;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return s(0),0}static sqrDistance(t,e){return C(t.x-e.x)+C(t.y-e.y)+C(t.z-e.z)}static sqrDistanceCoords(t,e,s,i,n,r){return C(t-i)+C(e-n)+C(s-r)}static distance(t,e){return Math.sqrt(Bt.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&b(this.z,t.z,e)}static compareByLength(t,e,i,n){return s(0),0}isEqualCoords(t,e,i,n){return s(0),this.x===t&&this.y===e&&this.z===i}isEqualsTols(t,e,i){return s(0),!1}isEqualCoordsTols(t,e,i,n,r){return s(0),!1}static st_isEqual(t,e,i,n){return s(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,i){return s(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return Bt.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return Bt.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new Bt(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return s(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return Bt.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return s(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return s(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return s(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,i,n=!1){return s(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return s(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return s(0),{}}static average(t,e){return s(0),{}}static size(){return Bt.dimensions}static lerp(t,e,s){const i=new Bt;return E(t,e,s,i),i}static slerp(t,e,i){return s(0),{}}static compareVectors(t,e){return s(0),0}static selectRightHandedBasisFromNormal(t,e,s){const i=t.getUnitVector(),n=i.createAPerpendicular(),r=new Bt;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new Bt(0,0,1)),this.crossProductVector(new Bt(1,0,0)),this.crossProductVector(new Bt(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce(((t,s,i)=>e[t]>e[i]?t:i),0)];return s.normalizeThis(),s}calculateAngle(t){return s(0),0}static crossDotSign(t,e,i){return s(0),0}static isBisectorRobust(t,e,i){return s(0),0}static compareZOrder(t,e){return s(0),!1}}Bt.dimensions=3;class kt{static constructEmpty(){return new kt(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,i){s(0)}getEnvelope2D(){return new qt(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new D(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=S(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=S(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=S(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,i,n=1){return s(0),0}sqrMaxDistance(t,e=1){return s(0),0}}const Gt=-559038737;var Ht=Vt;function Wt(t,s,i){switch(t){case 0:return new te(s,i);case 1:return new ee(s,i);case 2:return new Jt(s,i);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new $t(s,i);default:e("")}}function jt(t,e){const s=Ht.getComponentCount(t);return Wt(Ht.getPersistence(t),e*s,Ht.getDefaultValue(t))}function Zt(t,e){const s=Ht.getComponentCount(t);return Wt(Ht.getPersistence(t),e*s)}function Ut(t,e){return new Jt(t,e)}function Ot(t,e){return new $t(t,e)}function Qt(t,e){return new ee(t,e)}class Kt{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>Kt.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,s,i){(s<0||i<0||i+s>this.size())&&e(),this.m_a.fill(t,s,s+i)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,i){if(this.getPersistence()!==t.getPersistence())return!1;return se(this,t,e,s,i)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,i,n,r,o,a){s(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;n&&this.checkResize(Math.max(0,a)+n),this.m_a.copyWithin(t+n,t,a>=0?a:m),this.m_a.set(h.readRange(i,n),t),r||this.reverseRange(t,n,o)}writeRange(t,i,n,r,o,a){s(this.getPersistence()===n.getPersistence());const h=n;if((t<0||i<0||r<0)&&e(),h.size()<r+i&&e(),0===i)return;this.size()<i+t&&this.resize(i+t);const m=h.m_a.subarray(r,r+i);ie(this.m_a,t,i,m)}insertAttributes(t,e,s,i){const n=Ht.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let r=0;r<n;r++)this.m_a[t+r]=e.getAttributeAsDbl(s,r)}insertAttributesFromPoints(t,e,i,n,r){s(Ht.getPersistence(n)===this.getPersistence());const o=Ht.getComponentCount(n),a=this.m_size;if(this.checkResize(Math.max(0,r)+o*i),this.m_a.copyWithin(t+o*i,t,r>=0?r:a),0===n){const s=new f;for(let n=t,r=0;r<i;r++,n+=2)e[r].queryXY(s),this.m_a[n]=s.x,this.m_a[n+1]=s.y}else if(1===o)for(let s=t,h=0;h<i;h++,s++)this.m_a[s]=e[h].getAttributeAsDbl(n,0);else for(let s=t,h=0;h<i;h++,s+=o)for(let t=0;t<o;t++)this.m_a[s+t]=e[h].getAttributeAsDbl(n,t)}eraseRange(t,s,i){this.m_size<t+s&&e(),this.m_a.copyWithin(t,t+s),this.m_size-=s}reverseRange(t,s,i){if((i<1||s%i!=0)&&e(),this.m_a.subarray(t,t+s).reverse(),i>1)for(let e=t,n=t+s;e<n;e+=i){let t=e,s=e+i-1;for(;t<s;){const e=this.m_a[t];this.m_a[t]=this.m_a[s],this.m_a[s]=e,t++,s--}}}rotate(t,e,s){(e<t||e>s||t>s)&&i("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,Kt.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}Kt.s_constructMin=2,Kt.s_resizeMin=30;class $t extends Kt{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new $t({ctor:Int8Array,copy:this})}restrictedClone(t){return new $t({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class Jt extends Kt{getPersistence(){return 2}clone(){return new Jt({ctor:Int32Array,copy:this})}restrictedClone(t){return new Jt({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){s(e<=w()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class te extends Kt{getPersistence(){return 0}clone(){return new te({ctor:Float32Array,copy:this})}restrictedClone(t){return new te({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class ee extends Kt{getPersistence(){return 1}getArray(){return this.m_a}applyTransformation(t,s,i){(1&s||s+2*i>this.size())&&e();const n=0===s?this.m_a:this.m_a.subarray(s);t.transformInterleavedPoints(n,i,n)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new f(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let a=s,h=t,m=0;m<i;++m,++a){const t=e[a];this.m_a[h++]=t.x,this.m_a[h++]=t.y}else for(let a=s+i-1,h=t,m=0;m<i;++m,--a){const t=e[a];this.m_a[h++]=t.x,this.m_a[h++]=t.y}}queryRange(t,s,i,n,r){if((t<0||s<0)&&e(),!n&&(r<=0||s%r!=0)&&e(),0===s)return;if(1===s)return void(i[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+s);i.set(o)}writeRangeFromArray(t,s,i,n,r){if((t<0||s<0)&&e(),0===s)return;if(1===s)return void(this.m_a[t]=i[0]);let o=i;s<i.length&&(o=i.subarray(0,s)),this.m_a.set(o,t)}clone(){return new ee({ctor:Float64Array,copy:this})}restrictedClone(t){return new ee({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}function se(t,e,s,i,n){if(t.getPersistence()!==e.getPersistence())return!1;const r=t.getPersistence()<=1,o=t.size(),a=e.size();if(i>o||i>a)return!1;if(n)if(r){for(let h=s;h<i;h++)if(!b(t.read(h),e.read(h),n))return!1}else for(let h=s;h<i;h++){let s=t.read(h)-e.read(h);if(s<0&&(s=-s),s>n)return!1}else for(let h=s;h<i;h++){const s=t.read(h),i=e.read(h);if(s!==i){if(r&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}function ie(t,s,i,n,r,o){if((s<0||i<0)&&e(),0===i)return;if(1===i)return void(t[s]=n[0]);let a=n;i<n.length&&(a=n.subarray(0,i)),t.set(a,s)}var ne=Vt;function re(){return new Array(14)}class oe{static getInstance(){return oe.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new ne(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new ne(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new ne(t);return this.m_map.set(t,s),s}}function ae(t){return oe.getInstance().FindOrAdd(t)}function he(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:ae(s)}function me(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:ae(s)}function ue(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:ae(s)}function le(){return oe.getInstance().GetVD2D()}function ce(){return oe.getInstance().GetVD3D()}function de(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}oe.s_thisInstance=new oe;class ge{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new Jt(0),this.m_bucketedIndices=new Jt(0)}static sortEx(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);(new ge).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let m=e;m<s;m++){const e=i.getValue(t.read(m));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let r=e;r<s;r++){const s=t.read(r),n=i.getValue(s),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let r=e;r<s;r++){const s=this.m_bucketedIndices.read(r-e),n=i.getValue(s),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let m=0,u=this.m_buckets.size();m<u;m++){const s=h;h=this.m_buckets.read(m),h>s&&i.userSort(e+s,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(ge.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}ge.c_maxBuckets=65536;class _e{constructor(t){this.m_buffer=null,this.m_firstFree=-1,this.m_last=0,this.m_size=0,this.m_capacity=0,this.m_bufferSize=0,this.m_stride=0,this.m_stride=t,this.m_realStride=t,this.m_blockSize=Math.trunc(_e.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>_e.st_blockPower][1+(t&_e.st_blockMask)]=_e.st_deadVertex,!0}deleteElement(t){(t>>_e.st_blockPower)*this.m_blockSize*this.m_realStride+(t&_e.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>_e.st_blockPower][t&_e.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>_e.st_blockPower][(t&_e.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>_e.st_blockPower][(t&_e.st_blockMask)+e]=s}getStride(){return this.m_stride}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.m_capacity){const t=0!==this.m_capacity?Math.trunc(2*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<_e.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>_e.st_blockPower][t&_e.st_blockMask];this.m_size++;const e=this.m_buffer[t>>_e.st_blockPower],s=t&_e.st_blockMask;for(let i=0;i<this.m_stride;i++)e[s+i]=-1;return t}elementToIndex(t){return(t>>_e.st_blockPower)*this.m_blockSize+(t&_e.st_blockMask)/this.m_realStride}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.m_size=0,t&&(this.m_buffer=null,this.m_capacity=0)}size(){return this.m_size}setCapacity(t){t>this.m_capacity&&this.grow(t)}capacity(){return this.m_capacity}swap(t,e){const s=this.m_buffer[t>>_e.st_blockPower],i=this.m_buffer[e>>_e.st_blockPower],n=t&_e.st_blockMask,r=e&_e.st_blockMask;for(let o=0;o<this.m_stride;o++){const t=s[n+o];s[n+o]=i[r+o],i[r+o]=t}}swapField(t,e,s){const i=this.m_buffer[t>>_e.st_blockPower],n=this.m_buffer[e>>_e.st_blockPower],r=(t&_e.st_blockMask)+s,o=(e&_e.st_blockMask)+s,a=i[r];i[r]=n[o],n[o]=a}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}ensureBufferBlocksCapacity(t){if(this.m_buffer.length<t){const e=new Array(t);for(let t=0;t<this.m_buffer.length;t++)e[t]=this.m_buffer[t];this.m_buffer=e}}grow(t){null===this.m_buffer&&(this.m_bufferSize=0,this.m_buffer=new Array(8));const e=Math.trunc((t+this.m_blockSize-1)/this.m_blockSize);if(this.ensureBufferBlocksCapacity(e),1===e){let e=0;const s=t*this.m_realStride;for(;s>_e.st_sizes[e];)e++;const i=new Int32Array(_e.st_sizes[e]);1===this.m_bufferSize?(i.set(this.m_buffer[0]),this.m_buffer[0]=i):(this.m_buffer[this.m_bufferSize]=i,this.m_bufferSize++),this.m_capacity=Math.trunc(i.length/this.m_realStride)}else{if(1===this.m_bufferSize&&this.m_buffer[0].length<_e.st_realBlockSize){const t=new Int32Array(_e.st_realBlockSize);t.set(this.m_buffer[0]),this.m_buffer[0]=t,this.m_capacity=this.m_blockSize}for(;this.m_bufferSize<e;)this.m_buffer[this.m_bufferSize++]=new Int32Array(_e.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}function pe(t,e){return{element:t,box:e.clone()}}_e.st_realBlockSize=16384,_e.st_blockMask=16383,_e.st_blockPower=14,_e.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],_e.st_deadVertex=-2125315821;class fe{constructor(t,e,s){this.m_extent=new qt,this.m_dataExtent=new qt,this.m_childExtents=[new qt,new qt,new qt,new qt],this.m_elementNodes=new _e(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new _e(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){s(0)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){s(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return s(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return s(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return s(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>fe.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new qt;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const n=s.length;for(let r=0;r<n;r++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const i=new qt;i.setCoords({env2D:t}),i.inflateCoords(e,e);const n=[],r=[];n.push(this.m_root),r.push(this.m_extent.clone());const o=x(qt,4);let a=0;for(;n.length>0;){let t=!1;const e=n.at(-1),h=r.at(-1);if(n.pop(),r.pop(),i.containsEnvelope(h)){if(a+=this.getSubTreeElementCount(e),s>0&&a>=s)return s}else if(i.isIntersecting(h)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(i)&&(a++,s>0&&a>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){fe.setChildExtents_(h,o);for(let t=0;t<4;t++){const s=this.getChild_(e,t);if(-1!==s&&this.getSubTreeElementCount_(s)>0){i.isIntersecting(o[t])&&(n.push(s),r.push(o[t].clone()))}}}}return a}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new xe(this,t,e)}getIteratorForQT(){return new xe(this)}getSortedIterator(t,e){return new ye(this.getIterator(t,e))}getSortedIteratorForQT(){return new ye(this.getIteratorForQT())}visitLeavesNearest(t,e,i,n){s(0)}reset_(t,s){(s<0||s>127)&&e("invalid height"),this.m_height=s,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,n,r,o){if(!i.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,r,o);if(!r)for(let u=n;-1!==u;u=this.getParent_(u))this.setSubTreeElementCount_(u,this.getSubTreeElementCount_(u)+1);const a=new qt;a.setCoords({env2D:i});let h,m=n;for(h=s;h<this.m_height&&this.canPushDown_(m);h++){fe.setChildExtents_(a,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(m,s);-1===e&&(e=this.createChild_(m,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),m=e,a.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,h,a,m,r,n,o,-1)}insertDuplicates_(t,e,s,i,n,r,o){if(!r){if(!i.containsEnvelope(e))return-1;this.setSubTreeElementCount_(n,this.getSubTreeElementCount_(n)+1),this.setContainedSubTreeElementCount_(n,this.getContainedSubTreeElementCount_(n)+1)}const a=Math.max(e.width(),e.height());let h=-1;const m=[],u=[],l=[];m.push(n),u.push(i.clone()),l.push(s);const c=x(qt,4);for(;m.length>0;){let s=!1;const i=m.at(-1),d=u.at(-1),g=l.at(-1);if(m.pop(),u.pop(),l.pop(),g+1<this.m_height&&this.canPushDown_(i)){a<=Math.max(d.width(),d.height())/2&&(s=!0)}if(s){fe.setChildExtents_(d,c);let t=!1;for(let s=0;s<4;s++)if(t=c[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),m.push(t),u.push(c[s].clone()),l.push(g+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let s=0;s<4;s++){if(c[s].isIntersecting(e)){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),m.push(t),u.push(c[s].clone()),l.push(g+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1)}}}else h=this.insertAtQuad_(t,e,g,d,i,r,n,o,h),r=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let u=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),u=a}else-1===h?(u=this.createElement_(),this.setDataValues_(this.getData_(u),t,e)):u=this.createElementFromDuplicate_(h);return this.setQuad_(u,n),-1!==m?(this.setPrevElement_(u,m),this.setNextElement_(m,u)):this.setFirstElement_(n,u),this.setLastElement_(n,u),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),u}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===fe.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const n=new qt;let r=this.getFirstElement_(s),o=-1,a=-1;do{a=this.getData_(r),i=this.getElementValue_(a),n.setCoords({env2D:this.getBoundingBoxValue_(a)}),o=this.getNextElement_(r),this.m_bStoreDuplicates?this.insertDuplicates_(i,n,t,e,s,!0,r):this.insert_(i,n,t,e,s,!0,r),r=o}while(-1!==r)}canPushDown_(t){return this.getLocalElementCount_(t)>=fe.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){s(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&fe.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>fe.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const i=e<<fe.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=pe(e,s)}}fe.m_quadrantMask=3,fe.m_heightBitShift=2,fe.m_flushingCount=5;class xe{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new f,this.m_queryEnd=new f,this.m_queryBox=new qt,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new qt,new qt,new qt,new qt],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof qt)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===n.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new f,e=new f,s=new qt;let i=!1;for(;!i;){for(;-1!==this.m_currentElementHandle;){const n=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(n)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){i=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){i=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),i=this.m_extentsStack.at(-1);fe.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let n=0;n<4;n++){const i=this.m_quadTree.getChild_(s,n);if(-1!==i&&this.m_quadTree.getSubTreeElementCount(i)>0&&this.m_childExtents[n].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new qt;s.setCoords({env2D:this.m_childExtents[n]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(i),this.m_extentsStack.push(this.m_childExtents[n].clone()))}else this.m_quadsStack.push(i),this.m_extentsStack.push(this.m_childExtents[n].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return s(0),{}}}class ye{constructor(t){this.m_bucketSort=new ge,this.m_sortedHandles=new Jt(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,((t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s)))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return s(0),{}}}class Pe{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class ve{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new _e(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||(s(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,i,n,r=-1){if(-1===r&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.getRoot_(r)===ve.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,r),this.addToList_(-1,t,r),t}let o,a,h,m,u;if(n?(o=e!==ve.st_nullNode()?this.m_comparator.compare(this,s,e):-1,a=t!==ve.st_nullNode()?this.m_comparator.compare(this,s,t):1):(o=-1,a=1),i&&(0===o||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===o?e:t;return this.setDuplicateElement_(i,r),-1}u=e!==ve.st_nullNode()&&t!==ve.st_nullNode()?this.m_random>I(this.m_random)>>1:e!==ve.st_nullNode(),u?(m=o,h=e):(m=a,h=t);let l=-1,c=-1,d=!0;for(;;){if(m<0){const t=this.getLeft(h);if(t===ve.st_nullNode()){c=h,l=this.newNode_(s),this.setLeft_(h,l),this.setParent_(l,h);break}h=t}else{const t=this.getRight(h);if(t===ve.st_nullNode()){c=this.getNext(h),l=this.newNode_(s),this.setRight_(h,l),this.setParent_(l,h);break}h=t}d&&(m*=-1,d=!1)}return this.bubbleUp_(l),this.getParent(l)===ve.st_nullNode()&&this.setRoot_(l,r),this.addToList_(c,l,r),l}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==ve.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==ve.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===ve.st_nullNode()&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==ve.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),ve.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==ve.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==ve.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=ve.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return _e.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const i=this.getPriority_(t);for(;e!==ve.st_nullNode()||s!==ve.st_nullNode();){const n=e!==ve.st_nullNode()?this.getPriority_(e):N(),r=s!==ve.st_nullNode()?this.getPriority_(s):N();if(i<=Math.min(n,r))return;n<=r?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==ve.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==ve.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==ve.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==ve.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==ve.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==ve.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=I(this.m_random),this.m_random&N()>>1}maxPriority(){return s(0),0}getMaxDepthHelper_(t){return t===ve.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===ve.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===ve.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===ve.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===ve.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),i=this.getRight(t),n=this.getParent(t),r=t;if(-1!==s&&-1!==i){let o;this.m_random=I(this.m_random),o=this.m_random>N()>>1?this.getNext(t):this.getPrev(t);const a=this.getParent(o)===t;this.m_treapData.swapField(t,o,0),this.m_treapData.swapField(t,o,1),this.m_treapData.swapField(t,o,2),-1!==n?this.getLeft(n)===t?this.setLeft_(n,o):this.setRight_(n,o):this.setRoot_(o,e),a?(s===o?(this.setLeft_(o,t),this.setParent_(i,o)):i===o&&(this.setRight_(o,t),this.setParent_(s,o)),this.setParent_(t,o),n=o):(this.setParent_(s,o),this.setParent_(i,o),n=this.getParent(t),r=o),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const o=-1!==s?s:i;-1===n?this.setRoot_(o,e):this.getLeft(n)===r?this.setLeft_(n,o):this.setRight_(n,o),-1!==o&&this.setParent_(o,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,N());let s=ve.st_nullNode(),i=ve.st_nullNode();const n=this.getRoot_(e),r=n===t;if(r&&(s=this.getLeft(n),i=this.getRight(n),s===ve.st_nullNode()&&i===ve.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(ve.st_nullNode(),e);this.bubbleDown_(t);const o=this.getParent(t);o!==ve.st_nullNode()&&(this.getLeft(o)===t?this.setLeft_(o,ve.st_nullNode()):this.setRight_(o,ve.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),r&&this.setRoot_(s===ve.st_nullNode()||this.getParent(s)!==ve.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===ve.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===ve.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Ce{constructor(t){this.m_lists=new _e(6),this.m_listOfLists=Ce.st_nullNode(),void 0===t?(this.m_listNodes=new _e(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new _e(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){s(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){s(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){s(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Ce.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Ce.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Ce.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){s(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return s(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;e!==Ce.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Ce.st_nullNode()&&this.setNext_(n,i);if(e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Ce.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Ce.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Ce.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Ce.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let e=this.getFirstList();-1!==e;)e=this.deleteList(e)}isEmpty(t){return s(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class be extends Pe{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?Ee.isLeft_(e)&&Ee.isRight_(i)?-1:Ee.isLeft_(i)&&Ee.isRight_(e)?1:0:1}}class Ee{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new _e(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new _e(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new ve,this.m_secondaryTreaps.setComparator(new be(this)),this.m_secondaryLists=new Ce}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||o(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){s(0)}endConstruction(){this.m_bConstructing||o(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||o(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new Jt(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||o("");const s=this.m_intervalHandles[t];let i;-1===s&&e("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let n=this.getSecondaryFromInterval_(s),r=-1;r=this.m_secondaryTreaps.getTreapData(n),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(s),n),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(s),n),i=this.m_secondaryTreaps.size(n),0===i&&(this.m_secondaryTreaps.deleteTreap(n),this.setSecondaryToTertiary_(r,-1)),this.m_intervalNodes.deleteElement(s);let a=this.getPptr_(r),h=this.getLptr_(r),m=this.getRptr_(r);for(;!(i>0||r===this.m_root||-1!==h&&-1!==m);)r===this.getLptr_(a)?-1!==h?(this.setLptr_(a,h),this.setPptr_(h,a),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==m?(this.setLptr_(a,m),this.setPptr_(m,a),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setLptr_(a,-1),this.setPptr_(r,-1)):-1!==h?(this.setRptr_(a,h),this.setPptr_(h,a),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==m?(this.setRptr_(a,m),this.setPptr_(m,a),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setRptr_(a,-1),this.setPptr_(r,-1)),this.m_tertiaryNodes.deleteElement(r),r=a,n=this.getSecondaryFromTertiary_(r),i=-1!==n?this.m_secondaryTreaps.size(n):0,h=this.getLptr_(r),m=this.getRptr_(r),a=this.getPptr_(r)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof D?new De(this,t,e):(s(0),{})}getIterator(){return new De(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new Jt(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=q(t,-1);this.m_root=this.createRoot_();for(let i=0;i<e.size();i++){const t=e.read(i);let n=s[t>>1];if(-1!==n){const e=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(e,t))}else n=this.insertIntervalEnd_(t,this.m_root),s[t>>1]=n}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const d=this.getMin_(m),g=this.getMax_(m);let _=-1;for(;c;){h=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(_);if(g<e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(d>e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||_!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(_):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&_===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||o(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;if(t<e){s=t+(e-t>>1)+2}else s=-(t+2);return s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new ge).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,((t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&Ee.isLeft_(t)&&Ee.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return Ee.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return Ee.isLeft_(t)?e.xmin:e.xmax}}class De{constructor(t,e,s){this.m_query=D.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return a("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new D;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||o(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class Se{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new Jt(0),this.m_sortedEndIndicesBlue=new Jt(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Ce,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||o(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new qt(e))}endConstruction(){this.m_bAddRedRed||o(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||o(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||o(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||o(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||o(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new Ee(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=D.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=D.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&(this.m_queuedIndicesRed.length=this.m_envelopesRed.length,this.m_queuedIndicesRed.fill(-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=D.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&(this.m_queuedIndicesBlue.length=this.m_envelopesBlue.length,this.m_queuedIndicesBlue.fill(-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return a("should not be called"),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new ge).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,((t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1}))}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}var we=Vt;class Ae{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new Ae(this.tolerance+t,this.resolution)}scale(t){return new Ae(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function Te(t,e,s,i,n){const r=i*i,o=t.sub(e),a=s.sub(e),h=o.sqrLength(),m=a.sqrLength();if(h<=r||m<=r)return!0;const u=C(o.crossProduct(a));if(u<=r*h||u<=r*m){return o.dotProduct(a)>=0}return!1}function Ie(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function Ne(t,e){const s=new qt;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function qe(t,e){const s=qt.constructEmpty();t.queryLooseEnvelope(s);const i=qt.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function Me(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function Ye(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function Xe(t,e,s){const i=qt.constructEmpty();i.setFromPoints(t,e);return ke(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function Fe(t,e,s){return ke(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function Re(t,e,s){return ke(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function Le(t,e,s){return Re(t,e.queryInterval(1,0),s)}function ze(t,e,s){const i=qt.constructEmpty();return e.queryEnvelope(i),Fe(t,i,s)}function Ve(t,e,s=!1){return ke(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function Be(t,e,s){const i=qt.constructEmpty();return e.queryEnvelope(i),Ve(t,i,s)}function ke(t,e,s,i,n){const r=new Ae(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01);return r.total()<s?new Ae(s,0):r}function Ge(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function He(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function We(t){return t>=3}function je(t,e){const s=[0];return t.getImpl().getIsSimple(e,s)>=3}function Ze(t,e){t.getImpl().setIsSimple(3,e)}function Ue(t,e,s,i){if(C(e.x-t.x)+C(e.y-t.y)<=s*s){const s=t.z,n=e.z;return b(s,n,i)}return!1}function Oe(t){return t>=4}function Qe(t,e){return t===n.enumPolygon?We(e):e>=1}function Ke(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=e.querySegmentIterator(),h=qt.constructEmpty(),m=qt.constructEmpty(),u=new Se;u.setTolerance(s);let l=!1;for(u.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(h),h.isIntersecting(r)&&(l=!0,u.addRedEnvelope(o.getStartPointIndex(),h))}if(u.endRedConstruction(),!l)return null;let c=!1;for(u.startBlueConstruction();a.nextPath();)for(;a.hasNextSegment();){a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(r)&&(c=!0,u.addBlueEnvelope(a.getStartPointIndex(),m))}return u.endBlueConstruction(),c?u:null}function $e(t,e,s,i,n){t.getGeometryType(),e.getGeometryType();const r=qt.constructEmpty(),o=qt.constructEmpty();t.queryLooseEnvelope(r),e.queryLooseEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=qt.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Se;h.setTolerance(s);let m=!1;h.startRedConstruction();for(let l=0,c=t.getPathCount();l<c;l++)t.queryLoosePathEnvelope(l,r),r.isIntersecting(a)&&(m=!0,h.addRedEnvelope(l,r));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let l=0,c=e.getPathCount();l<c;l++)e.queryLoosePathEnvelope(l,o),o.isIntersecting(a)&&(u=!0,h.addBlueEnvelope(l,o));return h.endBlueConstruction(),u?h:null}function Je(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=new Se;a.setTolerance(s);let h=!1;for(a.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(i),i.isIntersecting(r)&&(h=!0,a.addRedEnvelope(o.getStartPointIndex(),i))}if(a.endRedConstruction(),!h)return null;let m=!1;a.startBlueConstruction();for(let u=0,l=e.getPointCount();u<l;u++){const t=e.getXY(u);r.contains(t)&&(m=!0,a.addBlueEnvelope(u,qt.construct(t.x,t.y,t.x,t.y)))}return a.endBlueConstruction(),m?a:null}function ts(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=new Se;o.setTolerance(s);let a=!1;o.startRedConstruction();const h=new f;for(let l=0,c=t.getPointCount();l<c;l++)t.queryXY(l,h),r.contains(h)&&(a=!0,o.addRedEnvelope(l,qt.construct(h.x,h.y,h.x,h.y)));if(o.endRedConstruction(),!a)return null;let m=!1;o.startBlueConstruction();const u=new f;for(let l=0,c=e.getPointCount();l<c;l++)e.queryXY(l,u),r.contains(u)&&(m=!0,o.addBlueEnvelope(l,qt.construct(u.x,u.y,u.x,u.y)));return o.endBlueConstruction(),m?o:null}function es(t){const e=new qt;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),ss(t,e)}function ss(t,e,s){const i=new qt;if(t.queryLooseEnvelope(i),i.isEmpty())return null;t.getGeometryType();const n=new fe(i,8);let r=-1;const o=new qt;let h=!1;do{for(let s=0,m=t.getPathCount();s<m;s++)if(t.queryLoosePathEnvelope(s,o),o.isIntersecting(e)){if(r=n.insertEx(s,o,r),-1===r){h&&a("build_quad_tree_for_paths"),i.assign(t.calculateEnvelope2D(!1)),h=!0,n.reset(i,8);break}h=!1}}while(h);return n}function is(t,e){if(!e){const e=new qt;t.queryLooseEnvelope(e);const s=new fe(e,8);let i=-1;const n=new qt,r=t.querySegmentIterator();let o=!1;for(;r.nextPath();)for(;r.hasNextSegment();){const h=r.nextSegment(),m=r.getStartPointIndex();if(h.queryLooseEnvelope(n),i=s.insertEx(m,n,i),-1===i){o&&a(""),e.assign(t.calculateEnvelope2D(!1)),o=!0,s.reset(e,8),r.resetToFirstPath();break}}return s}const s=new qt;t.queryLooseEnvelope(s);const i=new fe(s,8);let n=-1;const r=new qt,o=t.querySegmentIterator();let h=!1;for(;o.nextPath();)for(;o.hasNextSegment();){const m=o.nextSegment(),u=o.getStartPointIndex();if(m.queryLooseEnvelope(r),r.isIntersecting(e)&&(n=i.insertEx(u,r,n),-1===n)){h&&a(""),s.assign(t.calculateEnvelope2D(!1)),h=!0,i.reset(s,8),o.resetToFirstPath();break}}return i}function ns(e,s){if(s){const t=new fe(s,8),i=new f,n=new qt;let r=!1;for(let o=0;o<e.getPointCount();o++){if(i.setCoordsPoint2D(e.getXY(o)),!s.contains(i))continue;n.setCoords({pt:i});-1!==t.insert(o,n)||(r&&a(""),r=!0,t.reset(e.calculateEnvelope2D(),8),o=-1)}return t}return t("no-extent version not yet impl"),null}function rs(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let h=s;h<e;h+=i){const e=t.read(h);e<o?(r=!0,t.write(h,o)):e>a&&(r=!0,t.write(h,a))}return r}function os(t,e,s,i){if(!t.hasAttribute(s))return!1;const r=t.getGeometryType();if(r===n.enumGeometryCollection){const n=t,r=n.getGeometryCount();let o=0;for(let t=0;t<r;++t){o|=os(n.getGeometry(t),e,s,i)?1:0}return!!o}if(h(r)){const n=t,r=we.getPersistence(s),o=we.getComponentCount(s),h=n.getPointCount();if(1===r){const t=rs(n.getAttributeStreamRef(s),h*o,i,o,e);return t&&n.notifyModified(),t}if(2===r){const t=rs(n.getAttributeStreamRef(s),h*o,i,o,e);return t&&n.notifyModified(),t}a("snap_coordinate not implemented")}if(r===n.enumEnvelope){const n=t,r=n.queryInterval(s,i);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&n.setIntervalEnvelope(s,i,r),o}if(r===n.enumPoint){const n=t;let r=n.getAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setAttributeBasic(s,i,r),o}if(m(r)){const n=t;let r=n.getStartAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setStartAttribute(s,i,r),r=n.getEndAttributeAsDbl(s,i),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setEndAttribute(s,i,r),o}a("snap_coordinate not implemented")}var as=Vt;class hs{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=le(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=ce(),this.ensureAttributes(),this.setXYZ(new Bt(t.x,t.y,t.z))):(this.m_description=le(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=le()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new f(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new Bt;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:as.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;i("")}const s=as.getComponentCount(t);(e<0||e>=s)&&i("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]:as.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:i(""));const n=as.getComponentCount(t);(e<0||e>=n)&&i("");let r=this.m_description.getAttributeIndex(t);r<0&&(this.addAttribute(t),r=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(r)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=as.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return n.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof cs)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof kt){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new D;if(this.isEmpty())return s.setEmpty(),s;const i=this.getAttributeAsDbl(t,e);return s.vmin=i,s.vmax=i,s}applyTransformation(e){if(!this.isEmpty()){if(1===e.m_TransformationType){const t=this.getXY();return e.transformInPlace(t),void this.setXY(t)}t("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=Ie(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new hs({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==n.enumPoint&&e();const s=t;s.x=this.x,s.y=this.y,this.m_attribs?(s.assignVertexDescription(this.m_description),s.m_attribs=this.m_attribs.slice()):(s.releaseAttributes(),s.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=le(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&A(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==n.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let i=0,n=this.m_description.getTotalComponentCount()-2;i<n;i++)if(!b(this.m_attribs[i],s.m_attribs[i],e))return!1;return!0}getBoundary(){return null}clone(){const t=new hs({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==n.enumPoint&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.x=S(this.x,this.x=s.x),s.y=S(this.y,this.y=s.y),s.m_attribs=S(this.m_attribs,this.m_attribs=s.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=as.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,s,i){if(t.getDescription()!==s.getDescription()&&e("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||s.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const n=zt();t.queryValues(n,n.length);const r=zt();s.queryValues(r,r.length);const o=zt();let a=n,h=r;const m=o;let u=0;for(let e=0,l=this.m_description.getAttributeCount();e<l;e++){const t=this.m_description.getSemantics(e),s=as.getInterpolation(t),n=as.getComponentCount(t),r=as.getDefaultValue(t);T(s,a,h,m,u,n,i,r),a=a.slice(n),h=h.slice(n),u+=n}return this.setValues(o,u),this}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?A(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return f.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=le());const e=re();de(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=as.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const i=this.m_description.getTotalComponentCount();s(i<=e),t[0]=this.x,t[1]=this.y,A(t,this.m_attribs,2,0,i-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&A(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=as.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=as.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const i=this.m_description.getTotalComponentCount();s(i<=e),this.x=t[0],this.y=t[1],A(this.m_attribs,t,0,2,i-2)}dbgDefaultAttribs(){}}hs.type=n.enumPoint;var ms=Vt;function us(t,e){return e*(t.getTotalComponentCount()-2)}class ls{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new qt(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new qt(t.env2D);else if(t.move)this.m_envelope2D=new qt(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new qt(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=qt.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const i=e,n=t.getTotalComponentCount()-2;if(i.m_description!==t&&(i.releaseAttributes_(),i.m_description=t,n&&(i.m_data.m_attributes=new Array(2*n))),n){s(this.m_attributes&&i.m_data.m_attributes);const t=2*n;A(i.m_data.m_attributes,this.m_attributes,0,0,t)}i.m_data.m_envelope2D=new qt(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new qt(this.m_envelope2D),e.releaseAttributes();t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,i,n,r){s(0)}queryInterval(t,e,s,n){if(this.isEmpty())return void n.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(n):1===s?this.m_envelope2D.queryIntervalY(n):i(""));const r=ms.getComponentCount(e);(s<0||s>=r)&&i("");const o=t.getAttributeIndex(e);if(o>=0)return n.vmin=this.m_attributes[us(t,0)+t.getPointAttributeOffset(o)-2+s],void(n.vmax=this.m_attributes[us(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=ms.getDefaultValue(e);return void n.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new D;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}class cs{constructor(t){if(this.m_EnvelopeType=4,this.m_description=le(),void 0===t)this.m_data=new ls;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new ls,this.ensureAttributes_();else if(t?.env2D)this.m_data=new ls({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new ls({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new ls,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new ls({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new ls,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new ls({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,i,n,r){s(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new qt(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return n.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new f:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=ms.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof qt)this.m_data.m_envelope2D=new qt(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=D.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(s){if(s instanceof qt)return s.isValid()||e(""),void this.m_data.m_envelope2D.mergeEnvelope2D(s);if(s instanceof cs){if(s.m_data.isEmpty())return;const t=s.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(s.m_data.m_envelope2D);for(let e=1,i=t.getAttributeCount();e<i;e++){const i=t.getSemantics(e),n=ms.getComponentCount(i);for(let t=0;t<n;t++){const e=s.queryInterval(i,t),n=this.queryInterval(i,t);n.merge(e),this.setIntervalEnvelope(i,t,n)}}}else if(s instanceof hs){const t=s;if(t.isEmpty())return;const e=t.getDescription();if(this.mergeVertexDescription(e),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let s=1,i=e.getAttributeCount();s<i;s++){const i=e.getSemantics(s),n=ms.getComponentCount(i);for(let e=0;e<n;e++){const s=t.getAttributeAsDbl(i,e),n=this.queryInterval(i,e);n.mergeCoordinate(s),this.setIntervalEnvelope(i,e,n)}}}else t("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const e=this.m_description.getSemantics(s),i=ms.getComponentCount(e);for(let s=0;s<i;s++){const i=t.queryInterval(e,s),n=this.queryInterval(e,s);n.intersect(i),this.setIntervalEnvelope(e,s,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=ms.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=new D(s);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):i("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new D(s,i))}queryInterval(t,e){const s=new D;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(e){2!==e.m_EnvelopeType?3!==e.m_EnvelopeType?4!==e.m_EnvelopeType?t("unrecognized type for queryEnveloper"):this.copyTo(e):this.m_data.queryEnvelope3D(this.m_description,e):e.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?s(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new cs({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=le()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return s(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let i=0,n=2*(this.m_description.getTotalComponentCount()-2);i<n;i++)if(!b(this.m_data.m_attributes[i],s.m_data.m_attributes[i],e))return!1;return!0}getBoundary(){return t("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new cs({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==n.enumEnvelope&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.m_data.m_envelope2D=S(this.m_data.m_envelope2D,this.m_data.m_envelope2D=s.m_data.m_envelope2D),s.m_data.m_attributes=S(this.m_data.m_attributes,this.m_data.m_attributes=s.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&e(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&i(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=ms.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=ms.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let n=1,r=i.getAttributeCount();n<r;n++){const e=i.getSemantics(n),s=ms.getComponentCount(e);for(let i=0;i<s;i++){const s=t.getAttributeAsDbl(e,i);this.setInterval(e,i,s,s)}}}assignVertexDescriptionImpl(t){const e=re();de(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=new Array(2*i),s.fill(Number.NaN));for(let r=1;r<t.getAttributeCount();r++){const o=e[r];if(-1!==o){const e=t.getPointAttributeOffset(r)-2,a=ms.getComponentCount(t.getSemantics(r)),h=this.m_description.getPointAttributeOffset(o)-2;A(s,this.m_data.m_attributes,e,h,a),A(s,this.m_data.m_attributes,i+e,n+h,a)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&r(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=ms.getComponentCount(e)&&i("");const n=this.m_description.getAttributeIndex(e);return n>=0?this.m_data.m_attributes[us(this.m_description,t)+this.m_description.getPointAttributeOffset(n)-2+s]:Vt.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,n){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=n:0===s?this.m_data.m_envelope2D.xmax=n:i(""):1===s?this.m_data.m_envelope2D.ymin=n:0===s?this.m_data.m_envelope2D.xmin=n:i(""));const r=ms.getComponentCount(e);(s<0||s>=r)&&i(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[us(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=n}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}}cs.type=n.enumEnvelope;class ds{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function gs(t,s,i,n,r){(s<0||i<0||n<1||s+n*(i-1)+1>t.size())&&e("Index out of bound");for(let e=s,o=s+n*(i-1)+1;e<o;e+=n)t.writeAsDbl(e,r(t.readAsDbl(e)))}function _s(t,e){let s=I(t);const i=e.length/w();for(let n=0;n<e.length;++n){const t=Math.trunc(s*i);s=I(s);const n=Math.trunc(s*i),r=e[t];e[t]=e[n],e[n]=r}}function ps(t,e,s){if(0===t.length)return;let i=0,n=0;for(++n;n!==t.length;++n)e(t[i],t[n])||(s(i,n),i=n);s(i,n)}function fs(t,e,s,i,n){M(t,e,i-e,((t,e)=>n(t,e)?-1:1))}function xs(t,e,s){if(!(s<=e))for(;e<s;)t[s]=S(t[e],t[e]=t[s]),e++,s--}function ys(t,e,s,i){xs(t,e,s-1),xs(t,s,i-1),t.reverse()}function Ps(t,e,s){const i=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),A(t.getAttributeArray(),e,0,2,i-2)}var vs=Vt;const Cs="can not assign an empty point to a vertex";class bs{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=le(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new ds,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new ls,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:le();this.m_description=e,this.m_vertexAttributes=new ds,this.m_envelopeData=new ls,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!h(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==s.getPointCount())return!1;for(let n=0;n<this.m_description.getAttributeCount();n++){const t=this.m_description.getSemantics(n),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=vs.getComponentCount(t);if(!r.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,i,n){this.addAttribute(t),this.isEmpty()||0===s&&1===i||(gs(this.getAttributeStreamRef(t),e,this.getPointCount(),vs.getComponentCount(t),Ie(s,i,n)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||e("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(t,s){s||e("stream"),s&&vs.getPersistence(t)!==s.getPersistence()&&e(""),this.addAttribute(t);const i=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(i,s),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let i=0;i<this.m_description.getAttributeCount();i++){const e=this.m_description.getSemantics(i);for(let n=0,r=vs.getComponentCount(e);n<r;n++){const o=this.m_vertexAttributes.get(i).readAsDbl(r*t+n);s.setAttributeBasic(e,n,o)}}}setPointByVal(t,s){const i=s;i.isEmpty()&&e(Cs);const n=i.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,i.getX()),r.write(2*t+1,i.getY());for(let e=1,o=this.m_description.getAttributeCount();e<o;e++){const s=this.m_description.getSemantics(e),n=vs.getComponentCount(s);for(let r=0;r<n;r++){const o=i.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(t,e,i,n){s(0)}getPointByValAsArray(t,e,i,n){s(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=vs.getComponentCount(t);s>=n&&i("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):vs.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=vs.getComponentCount(t);n<r&&i("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=vs.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,i,n){s(0)}setAttribute(t,e,s,n){const r=vs.getComponentCount(t);s>=r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArray(t,e,s,n){(e<0||e>=this.m_pointCount)&&i("");const r=vs.getComponentCount(t);n!==r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let i=0;i<r;++i)a.writeAsDbl(e*r+i,s[i])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=Bt.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=vs.getDefaultValue(1),s}setXYZ(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y);this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof qt||t instanceof kt?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=D.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let i=!1;const n=vs.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let a=e,h=this.m_pointCount*n;a<h;a+=n){r.readAsDbl(a)!==s&&(r.writeAsDbl(a,s),i=!0)}i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=vs.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let r=0;r<i;r++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,o=this.m_pointCount*i;t<o;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return s(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||e(""),this.m_envelopeData=new ls({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&e(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*i,a=2*r,h=0;e<a;e+=2,h++)o.queryPoint2D(e,t[h]);return r}queryCoordinates3D(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=vs.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;if(!(1&i)){s=(14&i)>>1,e[0]=n,n<t&&(s=-1)}return s}setIsSimple(t,e,i=!1){if(2===t?s(this.getGeometryType()===n.enumPolyline):1===t?s(this.getGeometryType()===n.enumMultiPoint||this.getGeometryType()===n.enumPolyline):3===t&&s(this.getGeometryType()===n.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;i||(s|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&u("Cannot do shallow clone on unprepared geometry");const i=t,r=this.getGeometryType(),o=i.getGeometryType();s(r===o||r===n.enumPolygon&&o===n.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new ds;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(e)h.set(t,this.m_vertexAttributes.get(t));else{const e=vs.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==o){const t=[0];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)?(s(!e),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,e)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,n,r){(t<0||t>=this.m_pointCount)&&i(""),(e<0||e>=this.m_pointCount)&&i(""),r.assignVertexDescription(this.m_description);const o=new Array(vs.maxComponentCount()),a=new Array(vs.maxComponentCount()),h=zt();let m=0;for(let i=0;i<this.m_description.getAttributeCount();i++){const r=this.m_description.getSemantics(i),u=vs.getInterpolation(r),l=vs.getComponentCount(r),c=vs.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(m+l<=Lt),T(u,o,a,h,m,l,n,c),m+=l}Ps(r,h)}getShortestDistance(t,e){return f.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return f.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&e(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=re();de(t,this.m_description,e);const s=new ds;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return!!(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=Number.MAX_SAFE_INTEGER;let t=0;t=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let e=0;e<this.m_description.getAttributeCount();e++){const s=this.m_description.getSemantics(e);let i=0;if(null!==this.m_vertexAttributes.get(e)){const n=vs.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,vs.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,jt(s,t)),i=t;i<this.m_reservedPointCount&&(this.m_reservedPointCount=i)}}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new cs({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vs.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const r=new D;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new ls({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=qt.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){s(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof qt?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,s){if(t<0&&e(""),0===t)return;let i=t=Math.ceil(t);if(this.m_reservedPointCount<i){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),s?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,Zt(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*i),i=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,Zt(0,i)):this.m_vertexAttributes.get(0).resize(2*i);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),s=vs.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(i*s):this.m_vertexAttributes.set(t,Zt(e,i))}this.reserveImplImpl(i,s),this.m_reservedPointCount=i}}reserveRounded(t){t<0&&e(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&r("")}}class Es extends bs{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,s){t>this.getPointCount()&&e("invalid point index"),t<0&&(t=this.getPointCount());const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),r=Vt.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(e).insert(r*t,s,r*i);else{const s=Vt.getDefaultValue(n);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*i)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(Cs),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),r=Vt.getComponentCount(n);if(s.hasAttribute(n))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,n,r*i);else{const s=Vt.getDefaultValue(n);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*i)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&i(""),t<0&&(t=this.getPointCount()),0===s)return;const n=e[0].getDescription();this.mergeVertexDescription(n);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=Vt.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(n.hasAttribute(o))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=Vt.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,s,i){if((t>this.getPointCount()||i<0)&&e("invalid point index"),t<0&&(t=this.getPointCount()),0===i)return;const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++){const r=this.m_description.getSemantics(e),o=Vt.getComponentCount(r);if(this.m_vertexAttributes.get(e))if(0===r)this.m_vertexAttributes.get(e).insertRangeFromPoints(o*t,s,0,i,!0,o*n);else{const s=Vt.getDefaultValue(r);this.m_vertexAttributes.get(e).insertRange(o*t,s,o,o*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&i("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),n=Vt.getComponentCount(i);this.m_vertexAttributes.get(s).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),i=Vt.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s),i=Vt.getDefaultValue(t),n=Vt.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(n*e,i,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=Vt.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}queryAttributeAsInt(t,e,i,n){s(0)}add(t){t.isEmpty()&&e(Cs),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new f(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new Bt;i.setCoords(t,e,s),this.setXYZ(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,s,i){this===t&&e("Multi_point_impl.add");const n=i<0?t.getPointCount():i;if((s<0||s>t.getPointCount()||n<s)&&e(""),s===n)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=n-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let e=0,h=this.m_description.getAttributeCount();e<h;e++){const i=this.m_description.getSemantics(e),n=Vt.getComponentCount(i),h=this.getAttributeStreamRef(i);if(r.hasAttribute(i)){const e=t.getAttributeStreamRef(i);h.insertRangeFromStream(a*n,e,s*n,o*n,!0,1,a*n)}else{const t=Vt.getDefaultValue(i);h.insertRange(a*n,t,o*n,a*n)}}}addPoints2D(t,s,i,n){let r=s;const o=n<0?r:n;if((r<0||i<0||i>r||o<i)&&e(""),i===o)return;r=o-i;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[i+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,s,i,n){let r=s;const o=n<0?r:n;if((r<0||i<0||i>r||o<i)&&e(""),this.addAttribute(1),i===o)return;r=o-i;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0),m=new f;for(let e=0;e<r;e++)m.x=t[i+e].x,m.y=t[i+e].y,h.writePoint2D(2*(a+e),m);const u=this.getAttributeStreamRef(1);for(let e=0;e<r;e++)u.write(a+e,t[i+e].z);this.notifyModifiedFlags(2001)}getGeometryType(){return n.enumMultiPoint}getDimension(){return 0}createInstance(){return new Es({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(e){if(this.isEmpty())return;if(e.isIdentity())return;const s=this.m_vertexAttributes.get(0);1===e.m_TransformationType?s.applyTransformation(e,0,this.m_pointCount):t("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===n.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(e){4===e.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,e)):2===e.m_EnvelopeType?this.updateEnvelope(e):t("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){s(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return s(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}Es.type=n.enumMultiPoint;class Ds{constructor(){this.m_EnvelopeType=5,this.envAabb=qt.constructEmpty(),this.envRot=qt.constructEmpty()}static constructEmpty(){return new Ds}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:Ss(t),y:ws(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Ss(t),ws(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=Ss(t[i]),s=ws(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=Ss(t[s]),i=ws(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Ss(t),ws(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*Y();this.envRot.inflateCoords(e,e),e<0&&Ds.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function Ss(t){return t.x-t.y}function ws(t){return t.x+t.y}class As extends Nt{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Ts{constructor(t){this.m_geoms=[],this.m_description=le(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):e("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===n.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&e("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return n.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new D;const i=new D;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(e){if(4===e.m_EnvelopeType){const t=new cs;e.setEmpty(),e.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(t),e.merge(t)}else if(2===e.m_EnvelopeType){const t=new qt;e.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(t),e.mergeEnvelope2D(t)}t("3d envelope case not implemented")}queryLooseEnvelope(e){if(2===e.m_EnvelopeType){const t=new qt;e.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(t),e.mergeEnvelope2D(t)}t("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(e){if(1===e.m_TransformationType)for(const t of this.m_geoms)t.applyTransformation(e);t("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new Ts({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==n.enumGeometryCollection&&e("");const s=t;if(s!==this){s.m_geoms.length=0,s.assignVertexDescription(this.m_description);for(const t of this.m_geoms)s.m_geoms.push(t.clone())}}calculateArea2D(){const t=new X(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new X(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return s(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const s of this.m_geoms){const t=s.getBoundary();t&&e.m_geoms.push(t)}return t}clone(){return new Ts({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==n.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let i=0;i<this.m_geoms.length;++i)if(!this.m_geoms[i].equals(s.m_geoms[i],e))return!1;return!0}swap(t){t.getGeometryType()!==n.enumGeometryCollection&&e("");const s=t;s!==this&&(this.m_geoms=S(s.m_geoms,s.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}}function Is(t,e=-1){return new As(t,e)}Ts.type=n.enumGeometryCollection;class Ns{constructor(){this.x=V.getNAN(),this.y=V.getNAN()}static getNAN(){return new Ns}static constructPoint2D(t){const e=new Ns;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ns;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ns;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new Ns).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new Ns;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ns;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=dt.clone(),this.y=gt.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return f.construct(this.x.value(),this.y.value())}}class qs{constructor(){this.a11=new V(1),this.a12=new V(0),this.a21=new V(0),this.a22=new V(1)}clone(){const t=new qs;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=S(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new V(1),n=new V(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new V(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(gt)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(a),i.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else i=new V(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=S(t[0],t[0]=t[1]),e[1]=S(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var Ms=Vt;function Ys(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function Xs(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Fs(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function Rs(t,e,i,n,r,o,a,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),l=t,c=e,d=!1;m>u&&(c=S(l,l=c),n=S(i,i=n),u=S(m,m=u),d=!0);const g=0===i;{a[0]=g?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(f.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(l.getCoord2D(e[i])),!c.isCloserThanDistance(t,new D(0,1),r)){s=!1;break}if(s)return d&&(h[0]=S(a[0],a[0]=h[0])),1}}if(m<=3*r)return 0;let _=y(Math.max(r/m,.1),0,.5),p=.01*r,x=0,P=0,v=_,C=-1,b=0,E=1/32;for(let y=0;;y++){s(y<4095);const t=g?_:1-_,e=l.getCoord2D(t),i=c.getClosestCoordinate(e,!1);if(i===n)return b;const m=c.getCoord2D(i),u=f.distance(e,m);if(0===y&&(C=u),u<=p?(E=.5,P=u,x=_):(v=_,C=u),Math.abs(P-C)>.1*p&&v-x>1e-16)_=j(x,v,E);else{if(a[b]=t,h[b]=i,d&&(h[b]=S(a[b],a[b]=h[b])),1===o||1===b)return 1===b&&a[0]>a[1]&&(a[1]=S(a[0],a[0]=a[1]),h[1]=S(h[0],h[0]=h[1])),b+1;b++,x=v,P=C,v=.8,C=-1,_=.8,E=1/32,p=10*r,y=0}}}function Ls(t,e,s,i,n,r,o,a,h){if(G(s,0,1)&&G(i,0,1)){if(0===f.distance(t.getCoord2D(s),e.getCoord2D(i))){const h=1e-12,m=new Ns,u=st();if(t.queryDerivative(new V(s,u),m),m.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new V(s,u).add(e),m)}1===s&&m.negateThis();const l=new Ns;if(e.queryDerivative(new V(i,u),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new V(i,u).add(t),l)}1===i&&l.negateThis(),m.isZero()||m.normalize(),l.isZero()||l.normalize();const c=m.dotProduct(l),d=m.crossProduct(l);d.scaleError(3);const g=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(c.ge(gt)&&(d.isZero()||Math.abs(d.value())<g())){return Rs(t,e,s,i,n,r,o,a)}}}return 0}function zs(t,e,i){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(Ls(t,e,0,0,i,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(Ls(t,e,1,1,i,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(Ls(t,e,0,1,i,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(Ls(t,e,1,0,i,2,[0,0],[0,0]))return!0}return!1}function Vs(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function Bs(t,e,s){t.m_XStart=e,t.m_YStart=s}function ks(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Gs(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Hs(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function Ws(t,e){const s=new Bt;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=js(t,e),s}function js(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:Ms.getDefaultValue(1)}function Zs(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Us(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let r=1;r<t.m_description.getAttributeCount();r++){const i=t.m_description.getSemantics(r);for(let n=0,r=Ms.getComponentCount(i);n<r;n++){const r=Qs(t,e,i,n);s.setAttributeBasic(i,n,r)}}}function Os(t,e,s){s.isEmpty()&&r(""),Hs(t,e,s.getXY());const i=s.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let n=1,r=i.getAttributeCount();n<r;n++){const r=i.getSemantics(n),o=Ms.getComponentCount(r);for(let i=0;i<o;i++){Ks(t,e,r,i,s.getAttributeAsDbl(r,i))}}}function Qs(t,e,s,n){if((e<0||e>1)&&i(""),0===s)return(n<0||n>=2)&&i(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=Ms.getComponentCount(s);(n<0||n>=r)&&i("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:Ms.getDefaultValue(s)}function Ks(t,e,s,n,r){if((e<0||e>1)&&i(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:i(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:i(""):i(""),void t.endPointModified();const o=Ms.getComponentCount(s);(n<0||n>=o)&&i("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function $s(t,e){if(t===e)return;e.isEmpty()&&r("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Ms.getComponentCount(n);for(let s=0;s<r;s++){let i=Qs(e,0,n,s);Ks(t,0,n,s,i),i=Qs(e,1,n,s),Ks(t,1,n,s,i)}}}function Js(t,e){const s=re();de(e,t.m_description,s);let i=null;const n=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(n>0&&(i=new Array(2*n),A(i,e.getDefaultPointAttributes(),0,2,n),A(i,e.getDefaultPointAttributes(),n,2,n),null!==t.m_description))for(let o=1;o<e.getAttributeCount();o++){const a=s[o];if(-1!==a){const s=t.m_description.getPointAttributeOffset(a)-2,h=e.getPointAttributeOffset(o)-2,m=Ms.getComponentCount(e.getSemantics(o));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[n+h]=t.m_attributes[r+s]}}t.m_attributes=i,t.m_description=e}function ti(t){return t.absNorm()*P()}function ei(t,e){return Math.max(t.absNorm(),e.absNorm())*P()}function si(t,e,s){const i=new Ds;t.queryEnvelopeW(D.unit(),i);const n=new Ds;return e.queryEnvelopeW(D.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function ii(t,e,s){const i=Et(t,s),n=Et(e,s);i.sort(((t,e)=>t.compare(e))),n.sort(((t,e)=>t.compare(e)));for(let r=0;r<3;r++){if(i[r].compare(n[r])<0)return-1;if(0!==i[r].compare(n[r]))return 1}return 0}var ni=Vt;class ri{constructor(t){if(t.copy){if(this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description){this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice())}}else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:le(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:ce(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=le());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:ce(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);a("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=q(2*t,Number.NaN)),A(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),A(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(e){return t("not implemented"),0}snapControlPoints3D(){return t("not implemented"),!1}setCoordsForIntersector3D(e,s,i){t("not implemented")}transformAttribute(e,s,i,n,r){t("")}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let r=1,o=n.getAttributeCount();r<o;r++){const s=n.getSemantics(r),i=ni.getComponentCount(s);for(let n=0;n<i;n++){Ks(this,0,s,n,t.getAttributeAsDbl(s,n));Ks(this,1,s,n,e.getAttributeAsDbl(s,n))}}}getStartXY(){return new f(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return Ws(this,0)}setStartXYZ(t){Zs(this,0,t)}setStartXYZCoords(t,e,s){Zs(this,0,Bt.construct(t,e,s))}queryStart(t){Us(this,0,t)}setStart(t){Os(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return Qs(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){Ks(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=ni.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=ni.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return s(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return s(0),0}getEndXY(){return new f(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return Ws(this,1)}setEndXYZ(t){Zs(this,1,t)}setEndXYZCoords(t,e,s){Zs(this,1,Bt.construct(t,e,s))}queryEnd(t){Us(this,1,t)}setEnd(t){Os(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return Qs(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){Ks(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("");const s=t;s.assignVertexDescription(this.m_description),s.m_attributes&&A(s.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),s.m_XStart=this.m_XStart,s.m_YStart=this.m_YStart,s.m_XEnd=this.m_XEnd,s.m_YEnd=this.m_YEnd,this.copyToImpl(s)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=D.constructEmpty();return s.vmin=Qs(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(Qs(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=f.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){s(0)}getCoordZ(t){return s(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=ni.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=qt.constructEmpty();this.queryLooseEnvelopeOnInterval(e,i);if(i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&f.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=ni.getComponentCount(e);t<s;t++){const s=Qs(this,0,e,t);Ks(this,0,e,t,Qs(this,1,e,t)),Ks(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,i,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==i||null!==n){const e=new Array(9),r=new Array(9),o=this.intersect(t,null,e,r,0);s(o<=9),0===o&&a(""),null!==i&&(i[0]=e[0]),null!==n&&(n[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,h=-1,m=o;return r=this.getStartXY(),h=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==n&&(n[0]=h),null!==i&&(i[0]=0)),r=this.getEndXY(),h=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==n&&(n[0]=h),null!==i&&(i[0]=1)),r=t.getStartXY(),h=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=h),null!==n&&(n[0]=0)),r=t.getEndXY(),h=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=h),null!==n&&(n[0]=1)),o}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return j(t,e,s)}moveTo(t){const e=this.isClosed(),s=new k;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){s(0)}getDescription(){return this.m_description}assignVertexDescription(t){Js(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.m_XStart=S(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=S(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=S(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=S(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=S(this.m_attributes,this.m_attributes=s.m_attributes),this.swapImpl(s)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let n=0,r=2*(this.m_description.getTotalComponentCount()-2);n<r;n++)if(!b(this.m_attributes[n],i.m_attributes[n],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,s,i){if(this.addAttribute(t),0===t&&this.isCurve()){(s<0||s>1)&&e("");const t=new k,n=0===s?i:0,r=1===s?i:0;t.setShiftCoords(n,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,s,i),this.setEndAttribute(t,s,i)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=ni.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}ri.s_maxMonotonicPartParams=8;class oi extends ri{constructor(t){super(t)}}class ai extends oi{isTrue3D(){return!0}constructor(t){super(t)}}function hi(t,e,s){mi(e,t.getStartXY(),t.getEndXY(),s)}function mi(t,e,s,i){Q(e,s,t,i)}function ui(t,e){return j(t.m_XStart,t.m_XEnd,e)}function li(t,e){return j(t.m_YStart,t.m_YEnd,e)}function ci(t,e){const s=t.getStartZ(),i=t.getEndZ();return j(s,i,e)}function di(t,e,s){const i=Ns.constructPoint2D(t.getStartXY()),n=Ns.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}function gi(t,e,s){e.value()<=.5?tt(2,Ns.constructPoint2D(t.getStartXY()),Ns.constructPoint2D(t.getEndXY()),e,s):et(2,Ns.constructPoint2D(t.getStartXY()),Ns.constructPoint2D(t.getEndXY()),e,s)}function _i(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function pi(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}function fi(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=S(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=S(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=S(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function xi(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:vi(t,e)?4:0}function yi(t,e,s,i,n,r,o,a){null!==i&&(i.length=2),null!==n&&(n.length=2),null!==s&&(s.length=2);const h=Pi(t,e,2,s,i,n,r,o,a);return i&&(i.length=h),n&&(n.length=h),s&&(s.length=h),h}function Pi(t,e,s,i,n,r,o,a,h){const m=bi(t,e.getStartXY(),o,!1),u=bi(t,e.getEndXY(),o,!1),l=bi(e,t.getStartXY(),o,!1),c=bi(e,t.getEndXY(),o,!1);let d=0,g=0;if(!Number.isNaN(m)){let s=!1;a&&G(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[g]=m),r&&(r[g]=0),i&&(i[g]=f.construct(e.m_XStart,e.m_YStart)),g++)}if(!Number.isNaN(u)){let o=!1;a&&G(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=u),r&&(r[g]=1),i&&(i[g]=f.construct(e.m_XEnd,e.m_YEnd))),g++)}if(2!==g&&!Number.isNaN(l)&&!(0===m&&0===l||0===u&&1===l)){let o=!1;a&&G(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=0),r&&(r[g]=l),i&&(i[g]=f.construct(t.m_XStart,t.m_YStart))),g++)}if(2!==g&&!Number.isNaN(c)&&!(1===m&&0===c||1===u&&1===c)){let o=!1;a&&G(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=1),r&&(r[g]=c),i&&(i[g]=f.construct(e.m_XEnd,e.m_YEnd))),g++)}if(g>0)return h&&(r=S(n,n=r)),2===g&&s>=2&&n&&n[0]>n[1]&&(n[1]=S(n[0],n[0]=n[1]),r&&(r[1]=S(r[0],r[0]=r[1])),i&&(i[1]=S(i[0],i[0]=i[1]))),g;if(d>0)return 0;const _=Ai(t,e,o);return Number.isNaN(_.x)?0:(i&&(i[0]=t.getCoord2D(_.x)),n&&(n[0]=_.x),r&&(r[0]=_.y),1)}function vi(t,e){const s=Ei(t,e.m_XStart,e.m_YStart),i=Ei(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=Ei(e,t.m_XStart,t.m_YStart),r=Ei(e,t.m_XEnd,t.m_YEnd);if(n<0&&r<0||n>0&&r>0)return!1;return wi(t)>wi(e)?Si(t,e):Si(e,t)}function Ci(t,e){const s={bIntersect:!1,t1:Number.NaN,t2:Number.NaN},i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return s;const h=e.m_XStart-t.m_XStart,m=e.m_YStart-t.m_YStart,u=r*m-h*o,l=i*m-h*n,c=1/a;return s.t1=u*c,s.t2=l*c,s.bIntersect=!0,s}function bi(t,e,s,i){const n=f.getNAN(),r=f.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(n.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,m=f.getNAN();m.setSub(e,n);let u=m.length(),l=3*u*st();if(u<=Math.max(s,l))return i&&0===u?Number.NaN:a;if(m.setSub(e,r),u=m.length(),l=3*u*st(),u<=Math.max(s,l))return i&&0===u?Number.NaN:h;m.setCoords(r.x-n.x,r.y-n.y);const c=m.length();if(c>0){const t=1/c;m.scale(t);const i=f.getNAN();i.setSub(e,n);const u=i.dotProduct(m),l=8*i.dotProductAbs(m)*st();m.leftPerpendicularThis();const d=i.dotProduct(m),g=8*i.dotProductAbs(m)*st(),_=Math.max(s,l);if(u<-_||u>c+_)return Number.NaN;const p=Math.max(s,g);if(Math.abs(d)<=p){let i=u*t;i=y(i,0,1);const m=f.getNAN();if(mi(i,n,r,m),f.distance(m,e)<=s){if(i<.5){if(f.distance(m,n)<=s&&f.distance(e,n)<=s)return a}else if(f.distance(m,r)<=s&&f.distance(e,r)<=s)return h;return o?1-i:i}}}return Number.NaN}function Ei(t,e,s){const i=f.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=f.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const r=n.crossProduct(i),o=4*st()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?-1:r<-o?1:0}function Di(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,r=i?t.m_YStart:t.m_YEnd,o=f.getNAN();o.x=e.getEndX()-n,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*st()*s.dotProductAbs(o)){o.x=e.getStartX()-n,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*st()*s.dotProductAbs(o)}return!0}function Si(t,e){const s=f.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Di(t,e,s,!1)&&(s.negateThis(),!!Di(t,e,s,!0))}function wi(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function Ai(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return f.getNAN();const h=4*st()*(Math.abs(r*n)+Math.abs(i*o)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,l=r*u-m*o,c=4*st()*(Math.abs(r*u)+Math.abs(m*o)),d=l/a,g=Math.abs(a),_=(c*g+h*Math.abs(l))/(a*a)+st()*Math.abs(d);if(d<-_||d>1+_)return f.getNAN();const p=i*u-m*n,x=p/a,v=(4*st()*(Math.abs(i*u)+Math.abs(m*n))*g+h*Math.abs(p))/(a*a)+st()*Math.abs(x);if(x<-v||x>1+v)return f.getNAN();let C=y(d,0,1),b=y(x,0,1);const E=f.getNAN();hi(t,C,E);const D=f.getNAN();if(hi(e,b,D),!s||f.distance(E,D)>s){const i=f.getNAN();Q(E,D,.5,i),C=t.getClosestCoordinate(i,!1),b=e.getClosestCoordinate(i,!1);const n=f.getNAN();hi(t,C,n);const r=f.getNAN();hi(e,b,r),n.subThis(r);const o=n.length(),a=(t.absNorm()+e.absNorm())*P();if(o>Math.max(s,a))return f.getNAN()}return new f(C,b)}class Ti{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&i("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&i("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&i(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&i(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&o(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&i(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&i(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){if(null!==this.m_segFlagStream){return 1!==(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}return!1}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class Ii{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&(s(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Ii;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0==--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){s(this.uniqueUse())}setQuadTree(t){s(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){s(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Ni(t){return!(t.isEmpty()||t.getGeometryType()!==n.enumPolyline&&t.getGeometryType()!==n.enumPolygon)&&!(t.getPointCount()<20)}function qi(t){return!(t.isEmpty()||t.getGeometryType()!==n.enumPolyline&&t.getGeometryType()!==n.enumPolygon)&&!(t.getPointCount()<20)}function Mi(t,e){return t.readPoint2D(e+4)}function Yi(t){const e=t.getGeometryType();return e===n.enumEllipticArc?10:e===n.enumBezier?4:e===n.enumRationalBezier2?5:e===n.enumBezier2?2:void a("")}function Xi(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Fi(t,e,i,n){const r=4*st()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=st();if(1===t.getMaxDerivative()){s(i>0);const o=Gi(t,0,e,st(),r);return n[0]=o.root,o.cRoots}let a,h=[];const m=new D(e.vmin-r,e.vmax+r);h.push(new f(m.vmin,m.vmax));let u=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){a=h,h=[];for(let m=0,l=a.length;m<l;m++){if(a[m][0]<a[m][1]){let l,c,d;if(s===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:d}=Gi(t,s,D.construct(a[m][0],a[m][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:d}=Hi(t,s,D.construct(a[m][0],a[m][1]),o,.5*r)),1===d){if(0===s){if(u<i){if(a[m][0]<=e.vmin&&a[m][1]>=e.vmin&&l!==e.vmin){0===t.getValue(0,e.vmin)&&(l=e.vmin)}if(a[m][0]<=e.vmax&&a[m][1]>=e.vmax&&l!==e.vmax){0===t.getValue(0,e.vmax)&&(l=e.vmax)}n[u]=e.snapClip(l),u>0?n[u]-n[u-1]>r&&u++:u++}}else{const t=f.getNAN();t[0]=a[m][0],t[1]=l,h.push(t);const e=f.getNAN();e[0]=l,e[1]=a[m][1],h.push(e)}continue}}h.push(a[m])}}return u}function Ri(t,e,s,i){const n=new V,r=Zi(new V(t),new V(e),s,n);return i[0]=n.value(),r}function Li(t,e,s,i,n,r){const o=x(V,2),a=Ui(new V(t),new V(e),new V(s),i,n,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function zi(t,e,s,i,n,r,o){const a=x(V,3),h=Oi(new V(t),new V(e),new V(s),new V(i),n,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function Vi(t,e,s,i,n,r,o,a){return ki(t,e,s,i,n,r,o,a)}function Bi(t,e,s,i,n,r){return ji(t,e,s,i,n,r)}function ki(t,e,s,i,n,r,o,a){const h=new Array(s*s);h.fill(0),A(a,i,0,0,s);const m=new Array(s),u=new Array(s),l=new Array(s);let c=t(a,s,e);const d=100;let g=0;for(g=0;g<d;g++){const i=c;for(let t=0;t<s;++t)u[t]=a[t];if(g%s==0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,d=0;for(let u=0;u<s;++u){for(let t=0;t<s;++t)m[t]=h[u*s+t];const i=c;c=Wi(t,e,a,m,n,r,s);const l=i-c;l>o&&(d=u,o=l)}for(let t=0;t<s;t++)m[t]=a[t]-u[t],l[t]=a[t]+(a[t]-u[t]);const _=t(l,s,e);if(_<i){if(2*(i-2*c+_)*C(i-c-o)<C(i-_)*o){c=Wi(t,e,a,m,n,r,s);for(let t=0;t<s;++t)h[d*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=m[t]}}if(i<=c)return t(a,s,e)}return c}function Gi(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,h=s.vmax,m=0,u=Number.MAX_VALUE,l=t.getValue(e,o),c=t.getValue(e,h),d=0,g=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(r.funcAtRoot=l,r.root=o,r.cRoots=0===l?1:0,r):(r.funcAtRoot=c,r.root=h,r.cRoots=0===c?1:0,r);Math.abs(l)<Math.abs(c)&&(h=S(o,o=h),c=S(l,l=c)),m=o,d=l;let p=!0,f=0;for(;0!==c&&Math.abs(o-h)>i*Math.abs(h)+n;f++){let s=f>64;if(!s){g=l!==d&&c!==d?o*c*d/((l-c)*(l-d))+h*l*d/((c-l)*(c-d))+m*l*c/((d-l)*(d-c)):h-c*(h-o)/(c-l);const t=(3*o+h)/4;if(s=!(g>t&&g<h||g>h&&g<t),!s){const t=i*Math.abs(h)+n;if(p){const e=Math.abs(h-m);s=Math.abs(g-h)>=.5*e||e<t}else{const e=Math.abs(m-u);s=Math.abs(g-h)>=.5*e||e<t}}}if(s?(g=(o+h)/2,p=!0):p=!1,_=t.getValue(e,g),0===_)return r.root=g,r.funcAtRoot=_,r.cRoots=1,r;if(!s){const s=o-g,i=g-h;if(Math.abs(s)>10*Math.abs(i)){let s=h+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);ct(l)*ct(i)>0?(o=s,l=i):s=j(o,h,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=o-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);ct(c)*ct(s)>0?(h=i,c=s):i=j(o,h,.25)}}}u=m,m=h,d=c,ct(l)*ct(_)<0?(h=g,c=_):(o=g,l=_),Math.abs(l)<Math.abs(c)&&(h=S(o,o=h),c=S(l,l=c)),128===f&&a("Root_finder iterations exceeded")}return r.root=h,r.funcAtRoot=c,r.cRoots=1,r}function Hi(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,h=t.getValue(e,o),m=s.vmax,u=t.getValue(e,m);if(h>=0&&u>=0||h<=0&&u<=0)return Math.abs(h)<Math.abs(u)?(r.funcAtRoot=h,r.root=o,r.cRoots=0===h?1:0,r):(r.funcAtRoot=u,r.root=m,r.cRoots=0===u?1:0,r);u<0&&(u=S(h,h=u),m=S(o,o=m));let l=.5*(o+m),c=Math.abs(m-o),d=c,g=t.getValue(e,l),_=t.getValue(e+1,l);const p=1,f=4;let x=f;const y=2;let P=1,v=0,C=0,b=p;const E=32;let D=0;for(;++D<100;){let s;D>E||0===_||b===y&&v>1||b===p&&x<f?(b=p,P>1&&P--):(b=y,C>1&&Math.abs(2*g)>Math.abs(c*_)&&P++),c=d;let i=!1;if(b===p)do{if(C>2){const t=16*Math.abs(c);if(.5*Math.abs(o-m)>t){const e=Math.min(o,m),i=Math.max(o,m);if(l===e){s=l,l=e+t,d=l-s;break}if(l===i){s=l,l=i-t,d=l-s;break}}}d=.5*(m-o),s=l,l=o+d,i=o===l||m===l}while(0);else for(;;){d=P*g/_,s=l,l-=d,i=l===s;const t=Math.min(o,m),e=Math.max(o,m);if(l<t){if(P>1){l=s,P--;continue}d=s-t,l=t}else if(l>e){if(P>1){l=s,P--;continue}d=s-e,l=e}break}if(i||Math.abs(d)<n){s!==l&&(g=t.getValue(e,l));break}g=t.getValue(e,l),_=t.getValue(e+1,l);const r=o,a=m;g<0?(h=g,o=l):(u=g,m=l),b===y&&(o===r&&m===a||C>1&&Math.abs(d)>=.5001*Math.abs(c))?v++:v=0,b===p?(x++,C=0):(x=0,C++)}return 100===D&&a("Root_finder iterations exceeded"),r.root=l,r.funcAtRoot=g,r.cRoots=1,r}function Wi(t,e,s,i,n,r,o){const a=i.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=i[f]*i[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let m=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(o);for(let e=0;e<o;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(a[t]),i=Math.abs(a[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<o;e++){const i=t[e];if(0===a[i])continue;let o=(n[i]-s[i])/a[i],h=(r[i]-s[i])/a[i];h<o&&(h=S(o,o=h)),o>m&&(m=o),h<u&&(u=h)}}let l=0;const c=(Math.abs(m)+Math.abs(u))*st()*100,d=new Array(o),g=a.slice();function _(i,n){for(let t=0,e=o;t<e;t++)d[t]=s[t]+i*g[t];return t(d,o,e)}c>0&&(l=Bi(_,null,m,0,u,c));const p=_(l);for(let f=0,x=o;f<x;f++)s[f]=y(d[f],n[f],r[f]);return p}function ji(t,e,s,i,n,r){const o=It();let a=i,h=t(a,e),m=s,u=n,l=t(m,e),c=t(u,e);h>l&&(h=l,a=m),h>c&&(h=c,a=u);let d=m,g=u,_=l,p=c;_>p&&(_=S(p,p=_),g=S(d,d=g));let f=a-d,x=d-g;const y=.5*Math.min(r,u-m),P=2*y,v=100;let C,b=0;for(C=0;C<v&&!(u-m<=P);++C){const s=m+.5*(u-m);let i=b>0;if(!i&&Math.abs(x)<=y&&(i=!0,b=3),!i){const t=a-d,e=a-g,s=t*(h-p);let n=e*(h-_),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*x/2)||r<=n*(m-a)||r>=n*(u-a)?(i=!0,b=3):(x=f,f=r/n)}i&&(x=a>=s?m-a:u-a,f=o*x,b--);let n=a+f;n<m+y?n=m+y:n>u-y&&(n=u-y);const r=t(n,e);r<h?(n>=a?(m=a,l=h):(u=a,c=h),g=d,d=a,a=n,p=_,_=h,h=r):(n<a?(m=n,l=r):(u=n,c=r),r<=_||d===a?(g=d,d=n,p=_,_=r):(r<=p||g===a||g===d)&&(g=n,p=r))}return a}function Zi(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Ui(t,e,s,i,n,r){if(0===t.value()){if(n)return r[0].set(1),i.containsCoordinate(r[0].value())?1:0;return Zi(e,s,i,r[0])}if(n){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),i.containsCoordinate(r[1].value())||(e=1),i.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=S(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(_t));if(o.lt(gt))return 0;const a=new V(e.value()>=0?1:-1),h=o.clone().sqrtThis(),m=new V(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let u=0;r[0].setE(m.divE(t));const l=new V(r[0].value()),c=new V(t.value()).mulE(l).addE(new V(e.value()).mulE(l).addE(new V(s.value())));return c.isZero()||sn(r[0],t,e,s,r[0]),i.containsCoordinate(r[0].value())&&u++,0!==h.value()&&0!==m.value()?(r[u].assign(s.divE(m)),l.set(r[u].value()),c.assign(new V(t.value()).mulE(l).addE(new V(e.value()).mulE(l).addE(new V(s.value())))),c.isZero()||sn(r[u],t,e,s,r[u]),i.containsCoordinate(r[u].value())&&u++,2===u&&r[0].value()>r[1].value()&&(r[1]=S(r[0],r[0]=r[1])),u):u}function Oi(t,e,s,i,n,r,o){if(0===t.value()){return Ui(e,s,i,n,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=Ui(t,e.addE(t),i.negate(),n,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(dt)&&(o[s-1]=S(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)o[t]=h[t];return s}return nn(t,e,s,i,n,o)}function Qi(t,s,i,n,r,o){return(o<s||s<0)&&e("nth_degree_real_roots"),rn(t,s,i,n,r)}function Ki(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class $i{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=this.truePower-t+1;for(let s=0,i=this.truePower-t;s<=i;++s){e[s]=this.coefs[s+t].clone();let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let n=e;n>=1;n--)if(0!==this.coefs[n].value()){this.truePower=n;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new X(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new X(0),i=new V(1),n=new V(0);for(let o=0,a=this.power;o<=a;++o)n.addThisE(this.coefs[o].mulE(i)),s.pe(i.value()*this.coefs[o].eps()),i.mulThis(e);s.pe(n.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new V(1),i=new V(0);for(let s=0,n=this.truePower-o;s<=n;++s)i.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!i.isZero())return Math.pow(r*s.getResult()/Math.abs(i.value()),1/o)}return 0}}function Ji(t,e,s,i,n,r){let o=t,a=e,h=a-o;if(!r){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(a=S(o,o=a),n=S(s,s=n)),s>=0||n<=0)return!1}let m,u=!1,l=s,c=0;for(;c<100;c++){const t=i.calcF(l);if(m=i.calcDF(l),m.isZero())return!1;if(!t.value()||c>3&&t.isZero()){u=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/m.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!u&&(n.set(l,i.estimateError(l)),!0)}function tn(t,e,s,i,n,r,o,a){return Ji(t,e,s.value(),Ki(i,n,r,o),a,!1)}class en{constructor(t,e,s){this.coefs=x(V,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new V(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new V(t);return V.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new V(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function sn(t,e,s,i,n){return Ji(0,0,t.value(),new en(e,s,i),n,!0)}function nn(t,e,s,i,n,r){const o=x(V,3);let h=0;const m=e.negate().divThisE(t.clone().mulThis(3));n.containsCoordinate(m.value())&&(o[0].setE(m),h=1);const u=x(V,2),l=Ui(t.mul(3),e.mul(2),s,n,!1,u);if(l<0)return i.isZero()?-1:0;for(let a=0;a<l;a++)n.containsCoordinate(u[a].value())&&o[h++].setE(u[a]);M(o,0,h,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const c=x(V,5);c[0].set(n.vmin);for(let a=0;a<h;a++)c[1+a].setE(o[a]);c[1+h].set(n.vmax);const d=h+2;let g=1,_=0;{const n=c[0].clone();if(t.clone().mulThisE(n).addThisE(e).mulThisE(n).addThisE(s).mulThisE(n).addThisE(i).isZero()){const o=Ki(t,e,s,i);n.setError(o.estimateError(n.value())),r[_]=n,_++,g++}}for(let p=g;p<d;p++){const o=c[p].clone(),h=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(i).isZero();if(h||!c[p].eq(c[p-1])){if(h||tn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,i,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&a("cubic_polynomial_solver_too_many_roots"),h){const n=Ki(t,e,s,i);o.setError(n.estimateError(o.value()))}r[_]=o,_++}if(c[p].value()===n.vmax)break;h&&p++}}return _}function rn(t,e,s,i,n,r){const o=new $i(t,e,s,st());let a=0;if(2===o.truePower)a=Ui(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Zi(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=Fi(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let h=0;h<a;h++)n[h].setError(o.getError(n[h].value()));return a}var on=Vt;class an extends oi{constructor(t){void 0===t||F(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new f(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):a("unexpected constructor args")}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),go(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),go(this)}getGeometryType(){return n.enumBezier2}queryEnvelope(e){if(2!==e.m_EnvelopeType)t("env type not impl");else{if(e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY()),e.contains(this.m_cp))return;const t=To(this);if(null!==t){const s=new f;for(const i of t.specialPoints)this.queryCoord2D(i,s),e.mergeNe(s)}else{const t=[];fo(this,t);const s=new f;for(const i of t)this.queryCoord2D(i,s),e.mergeNe(s)}}}applyTransformation(t){if(1===t.m_TransformationType){const e=x(f,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}s(0)}createInstance(){return new an({vd:this.m_description})}calculateLength2D(){return xo(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return f.distance(this.getStartXY(),this.m_cp)+f.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=x(f,3);this.queryControlPoints(i),ea(i,t,e,s)}queryCoord2DE(t,e){sa(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=R(this.getStartX(),this.m_cp.x,t),s=R(this.m_cp.x,this.getEndX(),t);return R(e,s,t)}{const e=L(this.getStartX(),this.m_cp.x,t),s=L(this.m_cp.x,this.getEndX(),t);return L(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=R(this.getStartX(),this.m_cp.x,t),s=R(this.m_cp.x,this.getEndX(),t);return R(e,s,t)}{const e=L(this.getStartY(),this.m_cp.y,t),s=L(this.m_cp.y,this.getEndY(),t);return L(e,s,t)}}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=on.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=on.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){na(this,t,e)}cutBezierIgnoreAttributes(t,s,i){if((t<0||s>1||t>s)&&e("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===s)return i.setStartXY(this.getStartXY()),i.m_cp.assign(this.m_cp),void i.setEndXY(this.getEndXY());const n=x(f,3);this.queryControlPoints(n),Bo(n,t,s,n),i.constructPoints(n)}splitBezierIgnoreAttributes(t,e,i){s(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=on.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,on.getDefaultValue(e))}getClosestCoordinate(t,e){return No(this,t,D.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return No(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=po(this);let r=0;if(2===n.specialPointsCount())return 0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){Ro(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){const n=x(V,3),r=x(V,2),o=new D(0,1);let a=0;if(t){if(n[0]=new V(this.getStartY()).sub(e),n[1]=new V(this.m_cp.y).subE(new V(this.getStartY())).mulThisByPower2(2),n[2]=new V(this.getStartY()).add(this.getEndY()).subE(new V(this.m_cp.y).mulThisByPower2(2)),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordX(r[h].value())}else if(n[0]=new V(this.getStartX()).sub(e),n[1]=new V(this.m_cp.x).subE(new V(this.getStartX())).mulThisByPower2(2),n[2]=new V(this.getStartX()).add(this.getEndX()).subE(new V(this.m_cp.x).mulThisByPower2(2)),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordY(r[h].value());if(i)for(let h=0;h<a;h++)i[h]=r[h].value();else s&&B(s,a);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new qt;this.queryEnvelope(t);const s=new D;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,4);this.queryControlPoints(s),Bo(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return xo(this,t,!0)}lengthToT(t){return Do(this,t)}calculateWeightedAreaCentroid2D(t){const e=x(f,3);Ko(this,e);const s=e[2],i=e[1],n=new f,r=s.y*i.x-s.x*i.y;n.x=-(4*s.x+5*i.x)*r/60,n.y=-(4*s.y+5*i.y)*r/60;const o=So(this);return n.x+=(e[0].x-t.x)*o,n.y+=(e[0].y-t.y)*o,n}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):Ao(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(zo(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(t){for(let s=0;s<3;s++)t[s].isNAN()&&e("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=y(t,0,1);let s=Co(this,1,e);return s.isZero()&&(s=Co(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Co(this,1,y(t,0,1))}getCurvature(t){const e=Co(this,1,t),s=Co(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new qt;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),r=new f;this.queryCoord2D(n,r);return f.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,s){const i=po(this),n=i.specialPointsCount();if(!s)return i.specialPointsCount();t<n&&e("");for(let e=0;e<n;e++)s[e]=i.specialPoints[e];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){S(this.m_XStart,this.m_XStart=this.m_XEnd),S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=[t];if(!Fs(this,e))return!1;const s=this.getEndXY().sub(this.getStartXY()),i=s.length(),n=this.getControlPoint1();n.sub(this.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e[0])}copyIgnoreAttributes(t){const e=x(f,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return So(this)}absNorm(){return Go(this)}queryEnvelopeW(t,e){const s=x(f,3);this.queryControlPoints(s),Xo(s,t,e)}setSegmentFromCoords(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return ma(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return ua(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ro(this)}setCoordsForIntersector(t,e,s){ko(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Io(e,To(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=S(this.m_cp,this.m_cp=e.m_cp),_o(this,e)}afterCompletedModification(){go(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Mo(this,t,e.length,e,s)}endPointModified(){go(this)}clearEndPointModified(){}}an.type=n.enumBezier2;var hn=Vt;class mn extends oi{constructor(s){return void 0===s||F(s,"vd")?(super({vd:s?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new f(0,0),void(this.m_weights=[1,0,1])):(s.fromPoint&&s.weight?s={fromPoint:s.fromPoint,controlPoint1:s.controlPoint1,toPoint:s.toPoint,weight0:1,weight1:s.weight,weight2:1}:s.points&&s.weight?s={fromPoint:s.points[0],controlPoint1:s.points[1],toPoint:s.points[2],weight0:1,weight1:s.weight,weight2:1}:s.points&&s.weights&&(s={fromPoint:s.points[0],controlPoint1:s.points[1],toPoint:s.points[2],weight0:s.weights[0],weight1:s.weights[1],weight2:s.weights[2]}),s.fromPoint&&s.weight0?(super({start:s.fromPoint,end:s.toPoint}),(s.weight0<=0||s.weight1<0||s.weight2<=0)&&e("weights"),this.m_cp=s.controlPoint1.clone(),void(this.m_weights=[s.weight0,s.weight1,s.weight2])):s.copy?(super(s),this.m_cp=s.copy.m_cp.clone(),void(this.m_weights=s.copy.m_weights.slice())):s.move?(super(s),this.m_cp=s.move.m_cp.clone(),void(this.m_weights=s.move.m_weights.slice())):void t("unexpected constructor param"))}getBoundary(){return Vh(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Kn(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),Kn(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Kn(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return n.enumRationalBezier2}queryEnvelope(t){if(t instanceof qt){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=br(this);if(null!==e){const s=new f;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=x(f,3);this.queryControlPoints(s),tr(s,this.m_weights,e);const i=new f;for(const n of e)this.queryCoord2D(n,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof k){const e=x(f,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new mn({vd:this.m_description})}calculateLength2D(){return er(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return f.distance(this.getStartXY(),this.m_cp)+f.distance(this.getEndXY(),this.m_cp)}return f.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){$r(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void hi(new rl({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void hi(new rl({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const i=x(f,3);this.queryControlPoints(i),eo(i,this.m_weights,t,e)}getCoordX(t){const e=new f;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new f;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=hn.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=hn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){lr(this,t,e)}cutBezierIgnoreAttributes(t,s,i){(t<0||s>1||t>s)&&e("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const n=x(f,3);this.queryControlPoints(n);const r=[0,0,0];Fr(n,this.m_weights,t,s,n,r),i.setControlPointsAndWeights(n,r)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=hn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,hn.getDefaultValue(e))}getClosestCoordinate(t,e){return Dr(this,t,D.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Dr(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=Jn(this);let r=0;if(2===n.specialPointsCount())return 0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){qr(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),r=x(V,2),o=new D(0,1);let a=0;const h=x(f,3);if(this.queryControlPoints(h),t){if(n[0]=new V(h[0].y).sub(e).mul(this.m_weights[0]),n[1]=new V(h[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new V(h[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordX(r[m].value())}else if(n[0]=new V(h[0].x).sub(e).mul(this.m_weights[0]),n[1]=new V(h[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new V(h[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordY(r[m].value());if(i)for(let m=0;m<a;m++)i[m]=r[m].value();else s&&M(s,0,a,U);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof qt)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=qt.constructEmpty();this.queryEnvelope(t);const s=D.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,3);this.queryControlPoints(s);const i=[0,0,0];Fr(s,this.m_weights,t.vmin,t.vmax,s,i),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return er(this,t,!0)}lengthToT(t){return _r(this,t)}calculateWeightedAreaCentroid2D(t){const e=yr(this),s=pr(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):Cr(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Yr(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=x(f,3);return this.queryControlPoints(e),dr(e,this.m_weights,t)}getDerivative(t){const e=y(t,0,1),s=x(f,4);return sr(this,1,e,s),s[1]}getCurvature(t){const e=x(f,4);sr(this,2,t,e);const s=e[1].sqrLength();if(0===s)return Number.NaN;e[1].divThis(Math.sqrt(s));return e[1].crossProduct(e[2])/s}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=x(f,3);return this.queryControlPoints(t),Nr(t)}getMonotonicPartParams(t,s){const i=Jn(this),n=i.specialPointsCount();if(!s)return i.specialPointsCount();t<n&&e("");for(let e=0;e<n;e++)s[e]=i.specialPoints[e];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=S(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!Fs(this,e)&&Br(this,e[0])}copyIgnoreAttributes(t){const e=x(f,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return pr(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return s(0),0}queryEnvelopeW(t,e){Tr(this,t,e)}setSegmentFromCoords(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=x(f,3);this.queryControlPoints(e);const s=f.sqrDistance(e[1],e[0]),i=f.sqrDistance(e[1],e[2]);let n=e[0].clone(),r=s;s>i&&(n=e[2].clone(),r=i);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(n)),o}needsSnapControlPoints(t){if(!t)return!1;const e=x(f,3);this.queryControlPoints(e);const s=f.sqrDistance(e[1],e[0]),i=f.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return qr(this)}setCoordsForIntersector(t,e,s){Lr(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Er(e,br(this))}reverseImpl(){this.m_weights[2]=S(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=x(f,3);this.queryControlPoints(i);const n=x(f,3);s.queryControlPoints(n);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new Bt;t.setCoordsPoint2DZ(i[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new Bt;if(s.setCoordsPoint2DZ(n[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=S(this.m_cp,this.m_cp=e.m_cp),e.m_weights=S(this.m_weights,this.m_weights=e.m_weights),$n(this,e)}afterCompletedModification(){Kn(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Ar(this,t,e,s)}endPointModified(){Kn(this)}clearEndPointModified(){}setCpsAndWeights(t,s,i,n,r,o){(n<=0||o<=0||r<0)&&e("weights"),(t.isNAN()||s.isNAN()||i.isNAN())&&e("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(s),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(i)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}mn.type=n.enumRationalBezier2;class un{static constructPoint2D(t){return new un(Z.constructDouble(t.x),Z.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new Z).setNAN(),void(this.y=(new Z).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new f(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new un(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new un(this.x.add(t.x),this.y.add(t.y))}sub(t){return new un(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}class ln{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map((t=>t.clone())),s(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map((t=>t.clone())),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map((t=>t.clone())),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}fmSubThis(t,e){return s(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return s(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(t){return s(0),this}subNumber0(t){return s(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let o=e;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let o=s+1;o<this.m_elements.length;++o)this.m_elements[o]=new this.m_zeroCtor;for(let o=n+1;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let a=i+1;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=n;++a)this.m_elements[a].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let n=0,r=e.power();n<=r;n++){const i=this.m_elements[t].clone();i.mulThis(e.m_elements[n]),t+n<s.length?s[t+n].addThis(i):s.push(i)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(t){return s(0),this}mulBigint0(t){return s(0),this}mulBigIntThis(t){return s(0),this}mulInt320(t){return s(0),this}div0(t){return s(0),this}absThis(){return s(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let r=n.power();const o=n.power()-t.power();let a=o;for(e.m_elements=x(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(n);break}if(r===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(t){return s(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){s(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(Z.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce(((t,e)=>{const s=e.hiBitIndex();return t<s?s:t}),0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class cn extends ln{constructor(t){super(void 0===t?{zeroCtor:Z}:{...t,zeroCtor:Z})}clone(){return new cn({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let n=e-1;n>=0;--n)s.mulThis(i),s.addThis(this.m_elements[n].abs());return s}}class dn extends ln{constructor(t){super(void 0===t?{zeroCtor:cn}:{...t,zeroCtor:cn})}clone(){return new dn({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new cn({coef0:t[s]}));return this.updatePower(),this}}function gn(){return{polypoly1:new dn,polypoly2:new dn,polyX2:new cn,polyY2:new cn,polyX2Deriv:new cn,polyY2Deriv:new cn,polypolyX1:new dn,polypolyY1:new dn,polypolyX1Deriv:new dn,polypolyY1Deriv:new dn,lazyPolypolyD1:new dn,lazyPolypolyD1Deriv:new dn,lazyPolyD2:new cn,lazyPolyD2Deriv:null,polypoly11:new dn,polypoly12:new dn,tempPp:new dn,tempPp1:new dn,tempPp2:new dn,tempP:new cn,tempP1:new cn,tempP2:new cn}}function _n(t,e,i,n,r,o,h,m,u,l,c,d,g,_,p,f,x,y=!1){const P=gn();P.polyX2.construct(h,m),P.polyY2.construct(u,l),P.polypolyX1.constructFromMPValues(t,e),P.polypolyY1.constructFromMPValues(i,n),P.polypoly11.assignCopy(P.polypolyX1),P.polypoly12.assignCopy(P.polypolyY1),c&&(P.lazyPolyD2.construct(c,d),P.polypoly11.mulElementThis(P.lazyPolyD2),P.polypoly12.mulElementThis(P.lazyPolyD2)),r?(P.lazyPolypolyD1.constructFromMPValues(r,o),P.lazyPolypolyD1Deriv=new dn({copy:P.lazyPolypolyD1}),P.lazyPolypolyD1Deriv.derivative1This(),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyX2),P.polypoly11.subThis(P.tempPp),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyY2),P.polypoly12.subThis(P.tempPp)):(P.polypoly11.sub0This(P.polyX2),P.polypoly12.sub0This(P.polyY2)),P.polypolyX1Deriv.assignCopy(P.polypolyX1),P.polypolyX1Deriv.derivative1This(),P.polypolyY1Deriv.assignCopy(P.polypolyY1),P.polypolyY1Deriv.derivative1This(),r&&(P.polypolyX1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyX1),P.polypolyX1Deriv.subThis(P.tempPp2),P.polypolyY1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyY1),P.polypolyY1Deriv.subThis(P.tempPp2)),P.polyX2Deriv.assignCopy(P.polyX2),P.polyX2Deriv.derivative1This(),P.polyY2Deriv.assignCopy(P.polyY2),P.polyY2Deriv.derivative1This(),c&&(s(null===P.lazyPolyD2Deriv),P.lazyPolyD2Deriv=new cn({copy:P.lazyPolyD2}),P.lazyPolyD2Deriv.derivative1This(),P.polyX2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyX2),P.polyX2Deriv.subThis(P.tempP1),P.polyY2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyY2),P.polyY2Deriv.subThis(P.tempP1)),P.polypoly1.assignCopy(P.polypoly11),P.polypoly1.mulElementThis(P.polyX2Deriv),P.tempPp.assignCopy(P.polypoly12),P.tempPp.mulElementThis(P.polyY2Deriv),P.polypoly1.addThis(P.tempPp),P.polypoly2.assignCopy(P.polypolyX1Deriv),P.polypoly2.mulElementThis(P.polyY2Deriv),P.tempPp.assignCopy(P.polypolyY1Deriv),P.tempPp.mulElementThis(P.polyX2Deriv),P.polypoly2.subThis(P.tempPp);let v=[];const C=[];x||(x=[]),f||(f=[]),Dn(P.polypoly11,P.polypoly12,P.tempP);let b=57,E=.25*Number.EPSILON;const D=[];let S=Sn(P.tempP,g,p,E,b,D);if(S<0)return-1;for(let s=0;s<S;s++){cn.evaluateCoefs(P.polypoly11,Z.constructDouble(D[s]),P.tempP1);const t=[];let e=Sn(P.tempP1,g,_,E,b,t);if(0!==e)if(cn.evaluateCoefs(P.polypoly12,Z.constructDouble(D[s]),P.tempP2),e<0){e=Sn(P.tempP2,g,_,E,b,t),e<0&&a("mp_curve_proximity");for(let i=0;i<e;i++)C.push(xt(t[i],D[s]))}else{const i=P.tempP2.absEvaluate(ft);i.mulThis(Z.constructDouble(1e-12));for(let n=0;n<e;n++){const e=P.tempP2.evaluate(Z.constructDouble(t[n]));e.absThis(),e.lt(i)&&C.push(xt(t[n],D[s]))}}}S=C.length,Dn(P.polypoly1,P.polypoly2,P.tempP),b=57,E=.25*Number.EPSILON;const w=[];let A=Sn(P.tempP,g,p,E,b,w);A<0&&(A=0);for(let s=0;s<A;s++){cn.evaluateCoefs(P.polypoly1,Z.constructDouble(w[s]),P.tempP1);const t=[];let e=Sn(P.tempP1,g,_,E,b,t);if(0!==e)if(cn.evaluateCoefs(P.polypoly2,Z.constructDouble(w[s]),P.tempP2),e<0){if(e=Sn(P.tempP2,g,_,E,b,t),e<0)continue;for(let i=0;i<e;i++)v.push(xt(t[i],w[s]))}else{const i=P.tempP2.absEvaluate(ft);i.mulThis(Z.constructDouble(1e-12));for(let n=0;n<e;n++){const e=P.tempP2.evaluate(Z.constructDouble(t[n]));e.absThis(),e.lt(i)&&v.push(xt(t[n],w[s]))}}}if(A=v.length,0===S&&0===A)return 0;v=v.concat(C),v.sort(((t,e)=>y?U(t.second,e.second):U(t.first,e.first)));const T=Dt(v,((t,e)=>t.first===e.first&&t.second===e.second));v=v.slice(0,T),f.length=0,x.length=0;for(const s of v)f.push(s.first),x.push(s.second);return s(f.length===x.length),x.length}function pn(t,e,s,i,n,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(Z.constructInt32(1)).isZero();if(1===t.power()){const s=yn(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(i),1!==s?0:(r[0].limitPrecisionThis(i),1)}if(2===t.power()){return Pn(t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(3===t.power()){return vn(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(4===t.power()){return Cn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}return Nn(t,e,s,i,a,n,r,o)}function fn(){return{polyIntersect:new cn,polyX1:new cn,polyY1:new cn,polyX1Deriv:new cn,polyY1Deriv:new cn,lazyPolyD1:new cn,lazyPolyD1Deriv:new cn,tempP:new cn,tempP1:new cn,tempP2:new cn,polypoly1Proximity:new dn,polypoly2Proximity:new dn}}function xn(t,e,s,i,n,r,o,a,h,m,u){const l=fn();l.polyX1.construct(t,e),l.polyY1.construct(s,i),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.polyIntersect.assignCopy(l.polyX1),l.polyIntersect.mulThis(l.polyX1),l.polyIntersect.mulElementThis(o[0]),l.tempP.assignCopy(l.polyY1),l.tempP.mulThis(l.polyY1),l.tempP.mulElementThis(o[1]),l.polyIntersect.addThis(l.tempP),n?(l.lazyPolyD1.construct(n,r),l.tempP.assignCopy(l.lazyPolyD1),l.tempP.mulThis(l.lazyPolyD1),l.tempP.mulElementThis(o[2]),l.polyIntersect.addThis(l.tempP)):l.polyIntersect.add0(o[2]);{const n=o[0].clone(),r=n.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const m=o[2].clone(),u=n.clone();u.subThis(a),l.polyX1.construct(t,e),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1.construct(s,i),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(h),l.tempP.mulElementThis(m),l.polypoly1Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(a.mul(u).mul(m).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(n.mul(h)),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1),l.tempP1.mulElementThis(r.mul(a)),l.tempP.addThis(l.tempP1),l.tempP.add0(u.mul(u).mul(m)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulElementThis(u.mul(n).mul(a).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.construct0(n.mul(u).mul(u)),l.polypoly1Proximity.addElement(l.tempP),l.polypoly1Proximity.updatePower(),l.tempP.construct0(pt),l.polypoly2Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1Deriv),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1Deriv),l.tempP.addThis(l.tempP1),l.tempP.mulElementThis(n.mul(a)),l.polypoly2Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1Deriv),l.tempP.mulElementThis(u.mul(n)),l.polypoly2Proximity.addElement(l.tempP),l.polypoly2Proximity.updatePower()}const c=[],d=[];u||(u=[]);let g=2*l.polyIntersect.power()+58;const _=.5*Number.EPSILON,p=Sn(l.polyIntersect,a,h,_,g,d);if(p<0)return-1;Dn(l.polypoly1Proximity,l.polypoly2Proximity,l.tempP),g=2*l.tempP.power()+58;let f=Sn(l.tempP,a,h,_,g,c);if(f<0&&(f=0),0===p&&0===f)return 0;const x=c.concat(d);u.length=x.length,A(u,x,0,0,x.length),lt(u);const y=Dt(u,((t,e)=>0===U(t,e)));return u.length=y,u.length}function yn(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function Pn(t,e,s,i,n,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),n.containsCoordinate(1)?1:0;return yn(e,s,n,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),n.containsCoordinate(o[1].value())||(e=1),n.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=S(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const m=i+2,u=Z.sqrt(h,m),l=u.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(Z.constructAssign(t,m)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[0].value()))&&c++,u.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=S(o[0],o[0]=o[1]))),c}function vn(t,e,i,n,r,o,a,h){if(t.isZero()){return Pn(e,i,n,r,o,a,h)}const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=S(h[t],h[t]=h[s-1]),s--);e=s}return M(h,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let s=0;o.containsCoordinate(0)&&(h[0].setInt32(0),s=1);return m(Pn(t,e,i,r,o,a,h.slice(1)),s)}if(a){let s=0;o.containsCoordinate(1)&&(h[0].setInt32(1),s=1);const i=e.add(t),a=n.negate(),u=t.add(i).add(a).isZero();return m(Pn(t,i,a,r,o,u,h.slice(s)),s)}const u=new Z,l=new Z,c=new Z,d=e.clone();if(d.isZero())l.setThis(i),l.divThis(t),c.setThis(n),l.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();const s=e.clone();s.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(i).mulDoubleThis(3).subThis(s).divThis(r).divDoubleThis(3),c.setThis(s),c.mulThis(e),c.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(i).mulDoubleThis(9),c.subThis(u),u.setThis(r),u.mulThis(n).mulDoubleThis(27),c.addThis(u),c.divThis(r).divThis(t).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(d),Mn(o,r,h,1)):(h[0].setThis(Z.cubicRoot(c,r).add(d)),Mn(o,r,h,1))}const g=c.clone();if(g.sqrThis().ldexpThis(-2),u.setThis(l.clone()),u.sqrThis().mulThis(l).divDoubleThis(27),g.addThis(u),g.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(d),h[1].addThis(d),Mn(o,r,h,2);if(g.GZ())return g.setThis(Z.sqrt(g,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.addThis(g),h[0].setThis(Z.cubicRoot(u,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.subThis(g),h[0].addThis(Z.cubicRoot(u,r+8)),h[0].addThis(d),Mn(o,r,h,1);u.setThis(l),u.divDoubleThis(3).negateThis(),s(u.GEZ());const _=Z.sqrt(u,r+8),p=_.clone();p.negateThis(),p.addThis(d),_.addThis(d);const f=Z.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),y=Z.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),P=new cn({zeroCtor:Z});P.construct0(n),P.addElement(i),P.addElement(e),P.addElement(t);const v=new cn({copy:P});v.derivative1This();let C=0;const b=x(Z,4);b[C++].setThis(f),p.gt(f)&&p.lt(y)&&b[C++].setThis(p),_.gt(f)&&_.lt(y)&&b[C++].setThis(_),b[C++].setThis(y);const E=3*r;let D=52,w=Number.EPSILON;for(;D<E;)2*D<=E?(w*=w,D*=2):(w*=Number.EPSILON,D+=52);D+=2;let A=0,T=!1;for(let s=1;s<C;s++){if(Tn(P,v,b[s-1],b[s],w,D,h[0])){A=1,T=s+1<C;break}}if(!A)return 0;if(T){const t=new cn({zeroCtor:Z,coef0:h[0]});t.negateThis(),t.addElement(ft);const e=new cn({zeroCtor:Z}),i=new cn({zeroCtor:Z});P.div(t,e,i),s(2===e.power()),s(0===i.power());const n=Pn(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));s(n>=0&&n<=2),A+=n}return Mn(o,r,h,A)}function Cn(t,e,s,i,n,r,o,a,h){if(t.isZero())return vn(e,s,i,n,r,o,a,h);const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=S(h[t],h[t]=h[s-1]),s--);e=s}return M(h,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return m(vn(t,e,s,i,r,o,a,h.slice(n)),n)}const u=new cn({zeroCtor:Z,coef0:n});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new cn({zeroCtor:Z,coef0:Z.constructInt32(-1)});e.addElement(Z.constructInt32(1));const s=new cn({zeroCtor:Z}),i=new cn({zeroCtor:Z});u.div(e,s,i);return m(vn(3===s.power()?s.getElement(3):pt.clone(),s.power()>=2?s.getElement(2):pt.clone(),s.power()>=1?s.getElement(1):pt.clone(),s.getElement(0),r,o,s.evaluate(ft).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=vn(3===u.power()?u.getElement(3):pt.clone(),u.power()>=2?u.getElement(2):pt.clone(),u.power()>=1?u.getElement(1):pt.clone(),u.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),M(h,0,t,((t,e)=>t.compare(e))),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const d=qn(u),g=Z.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(d.lt(g)?d:g).mul(Z.constructDouble(c)).toDouble(),Nn(u,o,c,l,a,!1,h,4)}function bn(t,e){let s=t,i=e;i.power()>s.power()&&(i=S(s,s=i));const n=s.power()-i.power(),r=new cn({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let o=0,a=s.power();o<a;o++)if(o>=n){const t=new cn({copy:i.getElement(o-n)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),En(s)}function En(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Dn(t,e,s){const i=t.clone(),n=e.clone();for(En(i),En(n);0!==i.power()||0!==n.power();)bn(i,n);s.assignMove(i.getElement(0))}function Sn(t,e,s,i,n,r){r.length=0;const o=t.power(),a=x(Z,2*o+4),h=pn(t,s||D.unit(),i,n,!1,a,a.length);if(h>0){r.length=0;for(let t=0;t<h;t++){const e=a[t].value();t>0&&e<=r.at(-1)||r.push(e)}return r.length}return h}function wn(t,e,i){if(s(i>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function An(t,e,i,n){if(t.power()<2)return wn(t,i,n);s(n>=1);let r=t.getElement(1);r.mulThis(t.getElement(1));const o=t.getElement(0);if(o.mulThis(t.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),i[0].setThis(s),1}s(n>=2),r=Z.sqrt(r,e+8);const a=t.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);const m=a.clone();return m.addThis(r),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function Tn(t,e,s,i,n,r,o){let h=s.clone(),m=i.clone();h.limitPrecisionThis(r),m.limitPrecisionThis(r);let u=t.evaluate(h);u.limitPrecisionThis(r+2);let l=t.evaluate(m);if(l.limitPrecisionThis(r+2),u.GEZ()&&l.GEZ()||u.LEZ()&&l.LEZ())return u.absLessAbs(l)?(o=h,u.isZero()):(o=m,l.isZero());const c=l.LZ();c&&(l=S(u,u=l),m=S(h,h=m));const d=c?m:h,g=c?h:m,_=h.add(m).ldexpThis(-1);_.limitPrecisionThis(r);const p=m.sub(h);p.limitPrecisionThis(r),p.absThis();const f=p.clone();let x=t.evaluate(_),y=e.evaluate(_);const P=new cn({copy:t}),v=new cn({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=ft.clone();i.ldexpThis(-(r+2));for(let n=64;n<s;){P.limitPrecisionThis(n),v.limitPrecisionThis(n);const r=P.evaluate(_),o=v.evaluate(_),a=r.sub(x),h=o.sub(y);if(a.divThis(x).absThis().lt(i)&&(y.isZero()||h.divThis(y).absThis().lt(i)))break;P.assignCopy(t),v.assignCopy(e),n=Math.min(n+64,s)}x.limitPrecisionThis(r+2),y.limitPrecisionThis(r+2)}const C=1,b=4;let E=b;const D=2;let w=1,A=0,T=0,I=C;const N=32,q=Z.constructDouble(.25*n),M=Z.constructDouble(.5001);let Y=0;const X=300;for(;++Y<X;){if(Y>N&&A>0||y.isZero()||I===D&&A>1||I===C&&E<b)I=C,w>1&&w--;else if(I=D,T>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(x)&&w++}p.setThis(f);const t=new Z;let e=!1;if(I===C)do{if(T>2){const e=p.clone();if(e.absThis(),e.ldexpThis(4),g.sub(d).ldexpThis(-1).gt(e)){if(_.equals(d)){t.setThis(_),_.setThis(d.add(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}if(_.equals(g)){t.setThis(_),_.setThis(g.sub(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}}}f.setThis(m.sub(h)),f.ldexpThis(-1),f.limitPrecisionThis(r),t.setThis(_),_.setThis(h.add(f)),_.limitPrecisionThis(r),_.lt(d)?_.setThis(d):_.gt(g)&&_.setThis(g),e=h.equals(_)||m.equals(_)}while(0);else for(;;){if(f.setThis(x.div(y)),f.limitPrecisionThis(r),1!==w&&f.mulDoubleThis(w),t.setThis(_),_.subThis(f),_.limitPrecisionThis(r),e=_.equals(t),_.lt(d)){if(w>1){_.setThis(t),w--;continue}f.setThis(t.sub(d)),_.setThis(d)}else if(_.gt(g)){if(w>1){_.setThis(t),w--;continue}f.setThis(t.sub(g)),_.setThis(g)}break}if(e||f.absLessAbs(q)){t.equals(_)||(x=P.evaluate(_),x.limitPrecisionThis(r+2));break}x=P.evaluate(_),x.limitPrecisionThis(r+2),y=v.evaluate(_),y.limitPrecisionThis(r+2);const s=h.clone(),i=m.clone();x.LZ()?(u.setThis(x),h.setThis(_)):(l.setThis(x),m.setThis(_)),I===D&&(h.equals(s)&&m.equals(i)||T>1&&!f.absLessAbs(M.mul(p)))?A++:A=0,I===C?(E++,T=0):(E=0,T++)}return Y>=X&&a("Root_finder iterations exceeded"),o.setThis(_),!0}function In(t,e,s,i,n){const r=t.evaluate(s);if(r.isZero())return!0;const o=Z.constructDouble(.5*i),a=s.clone();a.subThis(o);const h=t.evaluate(a),m=s.clone();m.addThis(o);const u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ())return!0;if(r.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ())return!0;const l=h.LEZ()&&u.LEZ(),c=h.GEZ()&&u.GEZ();let d=!1;return l?r.gt(h)&&r.gt(u)&&(d=!0):c&&r.lt(h)&&r.lt(u)&&(d=!0),!!d&&r.absThis().lt(Z.constructDouble(1e-17))}function Nn(t,e,i,n,r,o,a,h){s(i>0),s(h>=t.power());const m=a,u=[];let l=[];const c=new cn({zeroCtor:t.m_zeroCtor}),d=new cn({zeroCtor:t.m_zeroCtor}),g=new cn({zeroCtor:t.m_zeroCtor}),_=Z.constructDouble(i),p=Z.constructDouble(e.vmin),f=Z.constructDouble(e.vmax),x=p.sub(_),y=f.add(_),P=qn(t),v=P.clone();if(v.negateThis(),x.lt(v))x.setThis(v.sub(_));else if(x.gt(P))return 0;if(y.gt(P))y.setThis(P.add(_));else if(y.lt(v))return 0;let C=t,b=null;if(r){const e=new cn({coef0:Z.constructInt32(-1)});e.addElement(ft),b=new cn,C=b;const s=new cn,i=new cn;for(t.div(e,s,i),b.assignCopy(s);C.evaluate(ft).isZero();)C.div(e,s,i),b.assignCopy(s)}let E=!1;if(C.power()>0&&C.getElement(0).isZero())for(E=!0,b||(b=new cn({copy:C}),C=b);C.getElement(0).isZero();)b.shiftRight(1);let D=n+2*C.power()+2,S=i/Math.pow(2,C.power()+2),w=D;if(pt.gt(x)&&pt.lt(y))for(let s=0,q=C.power();s<q;s++)if(C.getElement(s).isZero()){u.push(pt.clone());break}for(let q=C.power()-1;q>0;q--)if(S*=2,D-=2,w-=2,C.power()-q!=1)if(C.power()-q!=2){d.assignMove(g),g.assignMove(C.derivative(q-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new Z;if(Tn(d,c,l[e].first,l[e].second,S,D,s)){u.push(s);let i=s.sub(_);i.limitPrecisionThis(w),t.push(xt(l[e].first,i)),i=s.add(_),i.limitPrecisionThis(w),t.push(xt(i,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(d)}else{d.assignMove(C.derivative(q));const t=An(d,D,m,h);s(t>=0&&t<=2);for(let e=0;e<t;e++)m[e].gt(x)&&m[e].lt(y)&&!m[e].isZero()&&u.push(m[e].clone());if(u.length>1&&u.sort(((t,e)=>t.compare(e))),u.length>0){let t=u[0].sub(_);t.limitPrecisionThis(w),l.push(xt(x.clone(),t));let e=1===u.length?y.clone():u[1].sub(_);t=u[0].add(_),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(xt(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(_),e.limitPrecisionThis(w),t=u[1].add(_),t.limitPrecisionThis(w),l.push(xt(t,e)),u.length>2&&(t=u[2].add(_),t.limitPrecisionThis(w),l.push(xt(t,y.clone()))))}else l.push(xt(x.clone(),y.clone()));c.assignCopy(d),g.assignMove(C.derivative(q-1))}else{d.assignMove(C.derivative(q));1===wn(d,m,h)&&(m[0].gt(x)&&m[0].lt(y)&&!m[0].isZero()&&u.push(m[0].clone()),c.assignMove(d),g.assignMove(C.derivative(q-1)))}u.sort(((t,e)=>t.compare(e))),0===l.length&&(c.assignMove(C.derivative(C.power())),c.isZero()||l.push(xt(x.clone(),y.clone())));let A=0,T=0,I=0;const N=new Z;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<u.length&&u[I].lt(l[T].first)&&(t=!0),!t){Tn(C,c,l[T].first,l[T].second,i,n,N)&&(N.lt(p)?m[A++].setThis(p):N.gt(f)?m[A++].setThis(f):m[A++].setThis(N)),T++;continue}}if(!(I<u.length))break;0!==I&&u[I-1].equals(u[I])||In(C,c,u[I],i)&&(N.setThis(u[I]),N.lt(p)?N.setThis(p):N.gt(f)&&N.setThis(f),0!==A&&m[A].equals(N)||m[A++].setThis(N)),I++}return E&&pt.gt(x)&&pt.lt(y)&&(m[A++].setThis(pt),M(m,0,A,((t,e)=>t.compare(e)))),r&&ft.gt(x)&&ft.lt(y)&&(m[A++].setThis(ft),M(m,0,A,((t,e)=>t.compare(e)))),A}function qn(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=pt.clone();for(let i=0,n=t.power();i<n;i++){const n=t.getElement(i);n.limitPrecisionThis(53),n.divThis(e).absThis(),n.gt(s)&&s.setThis(n)}return s.addThis(ft),s.mulThis(Z.constructDouble(1+100*Number.EPSILON)),s}function Mn(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=S(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=S(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=S(s[1],s[1]=s[2]))));for(let r=0;r<n;++r)s[r].limitPrecisionThis(e);return n}const Yn=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Xn=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],Fn=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],Rn=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],Ln=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],zn=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function Vn(t,e,s,i){const n=.5*(i-s),r=s+n,o=new X(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,i;switch(t){case 4:s=Yn[a][0],i=Yn[a][1];break;case 8:s=Xn[a][0],i=Xn[a][1];break;case 16:s=Fn[a][0],i=Fn[a][1];break;case 32:s=Rn[a][0],i=Rn[a][1];break;case 64:s=Ln[a][0],i=Ln[a][1];break;case 128:s=zn[a][0],i=zn[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=St(-n,s,r),m=St(n,s,r);o.pe(e(h)*i),o.pe(e(m)*i)}return o.getResult()*n}function Bn(t,e,s,i,n,r){return Hn(t,e,s,r,i,n)}function kn(t,e,s,i,n,r){let o=n;if(i)return r[0]=1,o=.5*(e-t)*(s(t)+s(e)),o;const a=r[0],h=(e-t)/a,m=t,u=new X(0);for(let l=1;l<=r[0];++l){const t=(l-.5)*h;u.add(s(m+t))}return o=.5*(o+(e-t)*u.getResult()/a),r[0]*=2,o}function Gn(t,e,s,i,n,r,o){let a=0,h=Math.abs(n-s[t]);const m=q(e,Number.NaN),u=q(e,Number.NaN);for(let g=0;g<e;++g){const e=Math.abs(n-s[t+g]);e<h&&(a=g,h=e),m[g]=i[t+g],u[g]=i[t+g]}let l=0,c=0,d=0;r[0]=i[t+a],a--;for(let g=1;g<e;g++){for(let i=0;i<e-g;i++){if(c=s[t+i]-n,d=s[t+i+g]-n,l=c-d,0===l)return!1;const e=(m[i+1]-u[i])/l;m[i]=c*e,u[i]=d*e}if(2*(a+1)<e-g){const t=a+1;o[0]=m[t]}else{const t=a;o[0]=u[t],a--}r[0]+=o[0]}return!0}function Hn(t,s,i,n,r,o){if(i<s&&e("xTo < xFrom"),i===s)return 0;const h=[0];let m=Number.MAX_VALUE;const u=[Number.MAX_VALUE];let l=0;const c=32,d=q(c+1,Number.NaN),g=q(c+1,Number.NaN),_=[0];d[0]=1;let p=0,f=0;for(let e=0;e<c;e++){if(l=kn(s,i,n,0===e,l,_),g[e]=l,e+1>=t){Gn(e+1-t,t,d,g,0,h,u)||a("polynomial_interpolation");const s=r*Math.abs(h[0])+o,i=Math.abs(m-h[0]);if(i<=s&&Math.abs(u[0])<=s){if(p++,p>1&&(i<=.1*f||0===f||p>2))return h[0]}else p=0;f=i,m=h[0]}g[e+1]=g[e],d[e+1]=.25*d[e]}return h[0]}class Wn{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function jn(t,e,i,n,r,o,a,h){for(;;){const m=f.distance(e[0],e[2]),u=f.distance(e[0],e[1])+f.distance(e[1],e[2]);if(u-m<=r+n*u)return t+j(m,u,.5);const l=x(f,4),c=t=>{ir(e,i,1,t,l);return l[1].length()};if(0===a&&h<8){s(h<8);let m=c(0),l=c(1);o[0]+=2,m>l&&(l=S(m,m=l),e[2]=S(e[0],e[0]=e[2]),i[2]=S(i[0],i[0]=i[2]));let d=m/(m+l),g=1,_=u;for(;d<1/32&&_>=r+n*_;){g/=4;const t=c(g);o[0]++,d=m/(t+m);const s=new f;if(eo(e,i,.5*g,s),_=f.distance(s,e[0]),_<=r){const t=new f;eo(e,i,g,t),_+=f.distance(t,s)}}if(1!==g){const s=x(f,3),m=[0,0,0];Xr(e,i,g,e,i,s,m),t=jn(t,s,m,n,r,o,0,h+1),a++,h++;continue}}let d=!1;const g=8;o[0]+=g;const _=Vn(g,c,0,1),p=16;o[0]+=p;const y=Vn(p,c,0,1);if(d=Math.abs(_-y)>r+n*u,!d)return t+y;if(a<8&&h<9){const s=x(f,3),m=[0,0,0];Xr(e,i,.5,e,i,s,m),t=jn(t,s,m,n,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const v=Vn(P,c,0,1);if(d=Math.abs(y-v)>r+n*u,!d)return t+v;const C=64;o[0]+=C;const b=Vn(C,c,0,1);if(d=Math.abs(v-b)>r+n*u,!d)return t+b;const E=128;o[0]+=E;const D=Vn(E,c,0,1);return d=Math.abs(b-D)>r+n*u,t+D}}function Zn(t,e,s,i,n){if(s===e)return 0;const r=x(f,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=x(f,3);Fr(r,o,e,s,h,a);return jn(0,h,a,i,n,[0],0,0)}let Un=class{constructor(t,e,s){this.controlPoints=Et(t,3),this.weights=[0,0,0],A(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return s(0),0}};function On(t,e,s,i){const n=wr(0,0,0,0,f.getNAN()),r=new Array(18),o=x(f,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,io(a),1],m=ro(a,s),u=ro(a,i),l=Fi(new Un(o,h,new f(0,0)),D.construct(m,u),18,r);eo(o,h,m,n.pt),n.t=m,n.d=f.distance(n.pt,new f(0,0));const c=new f;eo(o,h,u,c);const d=f.distance(c,new f(0,0));d<n.d&&(n.d=d,n.t=u,n.pt.assign(c));for(let g=0;g<l;g++){eo(o,h,r[g],c);const t=f.distance(c,new f(0,0));t<n.d&&(n.d=t,n.t=no(a,r[g]),n.pt.assign(c))}return n}function Qn(t,e,s,i,n){let r=!0;const o=x(f,4),a=Bn(5,e,s,i,n,(e=>{sr(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()}));r=!1;const h=Bn(5,e,s,i,n,(e=>{sr(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()}));return new f(a,h)}function Kn(t){t.m_cachedValues=null}function $n(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Jn(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Wn,s=x(f,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),tr(s,i,e.specialPoints),Er(t,e),e}function tr(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=x(V,8);i[0].set(0);let n=1;{const s=new V(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new V(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new V(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=x(V,2);let h=Ui(o,r,s,new D(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)G(a[t].value(),0,1)||(i[n]=a[t],n++)}{const s=new V(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new V(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new V(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=x(V,2);let h=Ui(o,r,s,new D(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)G(a[t].value(),0,1)||(i[n]=a[t],n++)}if(i[n].set(1),n++,n>2){M(i,0,n,((t,e)=>U(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let r=0;r<n;r++)s[r]=i[r].value()}function er(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+er(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Jn(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Pr(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Zn(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function sr(t,e,s,i){const n=x(f,3);t.queryControlPoints(n);const r=[0,0,0];t.queryWeights(r),ir(n,r,e,s,i)}function ir(t,e,s,i,n){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=x(f,4);nr(r,o,s,i,a);for(let h=0;h<=s;h++)n[h].setCoords(a[h].x,a[h].y)}function nr(t,e,i,n,r){s(i>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const h=rr(o,e,0,n),m=ar(e,0,n),u=h.divide(m);if(r[0].assign(u),0===i)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],c=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],d=m*m,g=rr(c,l,0,n).mul(2).divide(d);if(r[1].assign(g),1===i)return;const _=ar(e,1,n),p=2*m*_,f=rr(c,l,1,n).mul(2).sub(g.mul(p)).divide(d);if(r[2].assign(f),2===i)return;const x=rr(c,l,2,n).mul(2),y=2*(_*_+m*ar(e,2,n)),P=x.sub(f.mul(p).mul(2)).sub(g.mul(y)).divide(d);r[3].assign(P),3!==i&&a("")}function rr(t,e,s,i){if(0===s){if(i<=.5){const s=new f;H(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new f;H(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new f;return H(2,s,n,i,r),r}{const s=new f;W(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new f;W(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new f;return W(2,s,n,i,r),r}}if(1===s){const s=t[1].mul(e[1]),n=s.sub(t[0].mul(e[0])).mul(1-i).add(t[2].mul(e[2]).sub(s).mul(i));return n.mulThis(2),n}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}a("")}function or(t,e,s,i){if(i.toDouble()<=.5){const s=new Ns;tt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ns;tt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ns;return tt(2,s,n,i,r),r}{const s=new Ns;et(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ns;et(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ns;return et(2,s,n,i,r),r}}function ar(t,e,s){if(0===e){const e=j(t[0],t[1],s),i=j(t[1],t[2],s);return j(e,i,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}a("")}function hr(t,e,s){if(s.toDouble()<=.5){const e=K(t[0],t[1],s),i=K(t[1],t[2],s);return K(e,i,s)}{const e=$(t[0],t[1],s),i=$(t[1],t[2],s);return $(e,i,s)}}function mr(t,e,s,i,n){const r=[Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);ur(r,[new V(e[0]),new V(e[1]),new V(e[2])],s,i,n)}function ur(t,e,i,n,r){s(i>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=Ns.constructCoords(0,0)}const a=or(o,e,0,n),h=hr(e,0,n),m=a.divE(h);r[0].setE(m);const u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],l=or([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,n).mul(2),c=h.sqr(),d=l.divE(c);r[1].setE(d)}function lr(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=new Array(3);t.queryWeights(n),cr(i,n,e,s)}function cr(t,e,s,i){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const n=x(Ns,4);mr(t,e,1,s,n),i.setE(n[1])}function dr(t,e,s){const i=y(s,0,1),n=x(f,4);if(ir(t,e,3,i,n),n[1].isZero()){if(n[2].isZero())return n[3];{const t=n[2].clone();return 1===i&&t.negateThis(),t}}return n[1]}let gr=class{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-er(this.b,e,!1):0}getError(t){return s(0),0}};function _r(t,e,s){const i=er(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new gr(t,e),D.unit(),1,n)&&a(""),n[0]}function pr(t){const e=x(f,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),fr(e,s)}function fr(t,e){const i=io(e);if(1===i){return wo(t)}if(0===i)return 0;const n=[new f(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=n[1].crossProduct(n[2]);if(i<1){s(i>0);const t=1-i;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const s=t*(1+i),n=Math.atan2(Math.sqrt(t),Math.sqrt(1+i));e=i*(.5*i-wt(s)*n)/s}return r*e}{const t=(i-1)*(i+1);return.25*i/Math.pow(t,1.5)*(-2*i*Math.sqrt(t)*r-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-n[1].x*n[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}function xr(t,e){const i=io(e);if(1===i){const e=x(f,3);Qo(t,e);const s=e[2].clone(),i=e[1].clone(),n=new f,r=s.y*i.x-s.x*i.y;return n.x=-(4*s.x+5*i.x)*r/60,n.y=-(4*s.y+5*i.y)*r/60,n}if(0===i)return new f(0,0);s(i>0);const n=t[1].sub(t[0]),r=t[2].sub(t[0]);if(i<1){const t=Math.sqrt(1-i),e=Math.sqrt(1+i),s=(n.y*r.x-n.x*r.y)*i/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=i*t*e,h=i*i,m=n.mul(2*(2+h)),u=r.mul(2*h-5),l=m.add(u).mul(a),c=r.sub(n.mul(2*h)).mul(6*o);return l.add(c).mul(s)}{const t=Math.sqrt(i-1),e=Math.sqrt(i+1),s=(n.y*r.x-n.x*r.y)*i/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=i*t*e,h=i*i,m=n.mul(4).sub(r.mul(5)),u=n.add(r).mul(2*h),l=m.add(u).mul(a),c=r.sub(n.mul(2*h)).mul(6*o);return l.add(c).mul(s)}}function yr(t){const e=x(f,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),xr(e,s)}function Pr(t){return vr(t.calculateUpperLength2D())}function vr(t){return 256*st()*t}function Cr(t){if(0===t.m_weights[1])return!0;const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function br(t){return t.m_cachedValues}function Er(t,e){t.m_cachedValues=e}function Dr(t,e,s,i,n){const r=x(f,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Sr(r,o,e,D.unit(),i,n,1,a)?a[0]:Number.NaN}function Sr(t,e,i,n,r,o,a,h){c(D.unit().contains(n)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const m=new Array(3);for(let s=0;s<3;++s)m[s]=t[s].sub(i);const u=io(e),l=un.constructPoint2D(m[0]),d=un.constructPoint2D(m[1]),g=un.constructPoint2D(m[2]),_=Z.constructDouble(u),p=_.clone();p.ldexpThis(1);const y=l.dotProduct(d.sub(l)).mul(_),P=_.mul(_.addDouble(2)),v=g.sub(d.mul(P.ldexp(1))),C=d.sqrLength().mul(_.mul(_).ldexp(1)).add(l.sqrLength().mul(_.ldexp(2).subDouble(1))).add(l.dotProduct(v)),b=g.sub(d.mul(p)).add(l.mul(p.subDouble(1))),E=d.mul(_).sub(l).dotProduct(b).mulDouble(3),S=d.dotProduct(g).mul(_.subDouble(3).mul(_)).ldexp(1),w=d.sqrLength().mul(_.mul(_).ldexp(2)),A=l.sqrLength().mul(_.ldexp(2).subDouble(3)),T=l.dotProduct(g.sub(d.mul(_.mulDouble(3).subDouble(1)).mul(_))).ldexp(1),I=g.sqrLength().addThis(S).addThis(w).addThis(A).addThis(T),N=l.add(g).sub(d.mul(p)),q=_.subDouble(1),M=g.sub(l).dotProduct(N).mul(q),Y=new f(0,0),X=[];let F=new f;eo(m,e,n.vmin,F);let R=f.distance(F,Y);if(R<=o&&X.push(new f(n.vmin,R)),n.vmin!==n.vmax&&(eo(m,e,n.vmax,F),R=f.distance(F,Y),R<=o&&X.push(new f(n.vmax,R))),n.width()>0){const t=m[2].isZero(),s=x(Z,4),i=Cn(M,I,E,C,y,58,n,t,s);for(let r=0;r<i;r++){if(!n.containsExclusiveCoordinate(s[r].toDouble()))continue;let t=s[r].toDouble();t=no(e,t);const i=new f;eo(m,e,t,i),R=f.distance(i,Y),R<=o&&X.push(new f(t,R))}}if(r){s(n.equals(D.unit()));{eo(m,e,-1,F,!0);const t=new f;eo(m,e,0,t);const s=new rl({start:F,end:t}),i=s.getClosestCoordinate(Y,!0);i<1&&(F=s.getCoord2D(i),R=f.distance(F,Y),R<=o&&X.push(new f(i-1,R)))}{eo(m,e,2,F,!0);const t=new f;eo(m,e,n.vmax,t);const s=new rl({start:t,end:F}),i=s.getClosestCoordinate(Y,!0);i>0&&(F=s.getCoord2D(i),R=f.distance(F,Y),R<=o&&X.push(new f(1+i,R)))}}if(!X.length)return 0;X.sort(((t,e)=>t.compare(e)));let L=0;const z=X[0].x;if(h[L++]=z,L<a){const t=Xe(m,4,!1).total(),e=X[0].y;for(let s=1,i=X.length;s<i;s++)if(X[s].y>e+t){X.length=s;break}X.sort(((t,e)=>U(t.x,e.x))),L=0,h[L++]=X[0].x;for(let s=1,i=X.length;s<i;s++)X[s].x!==h[L-1]&&L<a&&(h[L++]=X[s].x)}return L}function wr(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function Ar(t,e,i,n,r){const o=new Ds;if(Tr(t,D.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Jn(t);let h=0;const m=[];let u=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=On(t,e,u,i);if(0===m.length)m.push(n);else if(n.t===n.tmin)s(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){s(m.at(-1).d>=n.d);const t=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=t}else m.push(n);u=i}for(const s of m)if(s.d<=n){const t=s.t;i?(i[h]=t,h++):h++}return h}function Tr(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),Ir(i,n,e,s)}function Ir(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=x(f,3),r=[0,0,0];Fr(t,e,s.vmin,s.vmax,n,r),i.setFromPoints(n,3)}function Nr(t){const e=O(t[0].y,t[1].y),s=O(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=O(t[0].x,t[1].x),s=O(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function qr(t){const e=x(f,3);t.queryControlPoints(e);const s=Mr(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Mr(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[2][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Yr(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weighted_centroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=Jn(t),o=Pr(t),a=o/t.calculateUpperLength2D();let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=Qn(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function Xr(t,e,i,n,r,o,a){s(i>=0&&i<=1&&n!==o&&r!==a),s(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,io(e),1],m=ro(e,i),u=Et(t,3),l=x(Bt,3);Qr(u,h,l);const c=x(Bt,3),d=x(Bt,3);oo(l,m,n?c:null,o?d:null),ao(e,i,r,a);const g=Nr(u);if(n){for(let t=0;t<3;++t)to(c[t],n[t]);mo(u,n),g&&Mr(n)}if(o){for(let t=0;t<3;++t)to(d[t],o[t]);mo(u,o),g&&Mr(o)}}function Fr(t,e,i,n,r,o){if(s(i>=0&&n<=1&&i<=n),i===n){const s=new f,n=Kr(t,e,i,s);return ho(t,s),r[0].assign(s),r[1].assign(s),r[2].assign(s),o[0]=n,o[1]=n,void(o[2]=n)}if(0===i&&1===n)return r[0].assign(t[0]),r[1].assign(t[1]),r[2].assign(t[2]),o[0]=e[0],o[1]=e[1],void(o[2]=e[2]);const a=x(Bt,3);{const s=[1,io(e),1],r=ro(e,i),o=ro(e,n);Qr(t,s,a),oo(a,o,a,null);oo(a,r>=o?1:r/o,null,a)}const h=[0,0,0];ao(e,n,h,null),ao(h,i/n,null,h);const m=Nr(t),u=x(f,3);to(a[1],u[1]),eo(t,e,i,u[0]),eo(t,e,n,u[2]),mo(t,u);for(let s=0;s<3;++s)r[s].assign(u[s]),o[s]=h[s];m&&Mr(r)}function Rr(t,e,s){const i=io(e),n=[1,i,1],r=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),Q(t[0],t[1],r,s[1]),Q(t[2],t[1],r,s[2]),new da({cp:s}),new mn({points:t,weight:i});let o=0,a=.1,h=0;for(let m=0;m<9;m++,a+=.1){const e=new f;eo(t,n,a,e);const i=new f;Ua(s,a,i);const r=f.sqrDistance(e,i);r>o&&(o=r,h=a)}{const e=new f;eo(t,n,h,e);const i=[0];gh(s,e,D.unit(),!1,-1,1,i);const r=new f;return Ua(s,i[0],r),o=f.sqrDistance(e,r),Math.sqrt(o)}}function Lr(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Q(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&qr(t)}function zr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Hr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Vr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Wr(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Br(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();n.subThis(t.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e)}function kr(t,e,s,i,n){if(n){const i=Qu(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Ys(e,s))return 1;return 0!==jr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Gr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Zr(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Hr(t,e,i,n,r,o,a,h,m,u){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(i.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!=o)for(let t=0;t<s;t++)o.push(0);if(null!=n)for(let i=0;i<s;i++){const s=new f;e.queryCoord2D(t[i],s),n.push(s)}}return s}const l=ei(e,i);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new rl({start:e.getStartXY(),end:e.getEndXY()}),s=yi(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<s;++i){const s=t.getCoord2D(r[i]);r[i]=e.getClosestCoordinate(s,!1)}return s}if(si(e,i,a))return 0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[1,io(d),1],_=i.getEndXY().sub(i.getStartXY()),p=_.clone();p.leftPerpendicularThis();const y=c[0].clone(),P=c[1].clone(),v=c[2].clone(),C=P.sub(y),b=v.sub(y),E=v.sub(P),S=g[0],w=g[1],A=g[2],T=S*w,I=S*A,N=w*A,q=C.dotProduct(p)*T,M=b.dotProduct(p)*I;let Y=q,X=M-2*q,F=E.dotProduct(p)*N+M-M;const R=new Array(13),L=new Array(13);let z=Li(F,X,Y,D.unit(),!1,R);z<0&&(R[0]=0,R[1]=1,z=2);let V=0;for(let s=0,x=V;s<z;++s){const t=new f;eo(c,g,R[s+x],t),L[V]=i.getClosestCoordinate(t,!1);f.distance(t,i.getCoord2D(L[V]))<=a&&(R[V]=R[s+x],V++)}const B=x(f,3),k=x(f,3);if(e.queryControlPoints(k),k[0].subThis(i.getStartXY()),k[1].subThis(i.getStartXY()),k[2].subThis(i.getStartXY()),Ur(k,g,B,!1),Math.abs(_.x)>=Math.abs(_.y)){const t=_.y/_.x;F=B[2].y-B[2].x*t,X=B[1].y-B[1].x*t,Y=B[0].y-B[0].x*t}else{const t=_.x/_.y;F=B[2].x-B[2].y*t,X=B[1].x-B[1].y*t,Y=B[0].x-B[0].y*t}const G=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),H=[0,0];z=Li(F,X,Y,D.unit(),G,H);for(let s=0,x=V;s<z;++s){R[s+x]=H[s];const t=new f;eo(c,g,R[s+x],t),L[V]=i.getClosestCoordinate(t,!1);f.distance(t,i.getCoord2D(L[V]))<=a&&(R[V]=R[s+x],V++)}s(V<R.length+4);for(let s=0;s<V;s++)R[s]=no(d,R[s]);z=e.intersectPoint(i.getStartXY(),H,a);for(let s=0;s<z;s++)R[V]=H[s],L[V++]=0;z=e.intersectPoint(i.getEndXY(),H,a);for(let s=0;s<z;s++)R[V]=H[s],L[V++]=1;z=i.intersectPoint(e.getStartXY(),H,a);for(let s=0;s<z;s++)L[V]=H[s],R[V++]=0;z=i.intersectPoint(e.getEndXY(),H,a);for(let s=0;s<z;s++)L[V]=H[s],R[V++]=1;return 0===V?0:el(t,e,i,R,L,V,n,r,o,a,h,m,u)}function Wr(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return Hr(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=x(f,4);{e.queryControlPoints(d);const t=x(f,4),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(d,4,t);const r=x(Z,3),a=x(Z,3),h=x(Z,3),m=[0,0,0];e.queryWeights(m),Or(t,m,r,a,h);const u=x(Z,3);u[0].setDouble(s.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(s.getSemiMajorAxis()),u[1].sqrThis(),u[2].setThis(u[0]),u[2].mulThis(u[1]),u[2].negateThis();const g=xn(r,2,a,2,h,2,u,!0,D.unit(),D.unit(),l);if(g>0){let t=0;for(let i=0;i<g;i++){const n=new f;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a);f.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const g=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),i=Dr(e,t,D.unit(),!1,-1),n=new f;e.queryCoord2D(i,n);f.distance(t,n)<=o&&(l.push(i),c.push(g[_]))}for(let _=0;_<2;_++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[_]],!1),i=new f;s.queryCoord2D(e,i);f.distance(d[t[_]],i)<=o&&(l.push(g[_]),c.push(e))}}return el(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function jr(t,e,i,n,r,o,a,h,m,u){const l=x(f,3);e.queryControlPoints(l);const c=x(f,3);if(i.queryControlPoints(c),ii(l,c,3)<0)return jr(t,i,e,n,o,r,a,h,m,!u);const d=ei(e,i);if(e.isDegenerateToLineHelper(d)){const s=new rl({start:e.getStartXY(),end:e.getEndXY()}),l=Hr(t,i,s,n,o,r,a,h,m,!u);if(r)for(let t=0;t<l;++t){const i=s.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(i,!1)}return l}if(i.isDegenerateToLineHelper(d)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()}),l=Hr(t,e,s,n,r,o,a,h,m,u);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=i.getClosestCoordinate(e,!1)}return l}if(si(e,i,a=Math.max(a,d)))return 0;const g=new Array(3);e.queryWeights(g);const _=new Array(3);i.queryWeights(_);const p=[1,io(g),1],y=[1,io(_),1],P=new D(0,1),v=new D(0,1);{const t=Ds.constructEmpty();Ir(l,p,new D(0,1),t);const e=Ds.constructEmpty();Ir(c,y,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(so(l,p,t,P),so(c,y,t,v),P.isEmpty()||v.isEmpty())return 0;Fr(l,p,P.vmin,P.vmax,l,p),Fr(c,y,v.vmin,v.vmax,c,y)}}const C=il(l,2,c,2,a);if(0===C)return 0;const b=[],E=[];if(-1===C){const t=x(Z,3),e=x(Z,3),s=x(Z,3);Or(l,p,t,e,s);const i=x(Z,3),n=x(Z,3),r=x(Z,3);Or(c,y,i,n,r);const o=[],h=[],m=_n(t,2,e,2,s,2,i,2,n,2,r,2,!0,D.unit(),D.unit(),o,h);if(m>0)for(let u=0;u<m;u++){const t=new f;eo(c,y,h[u],t);const e=new f;eo(l,p,o[u],e);f.distance(e,t)<=a&&(b.push(o[u]),E.push(h[u]))}}for(let x=0;x<2;x++){let t,e,i;0===x?(t=l,e=c,i=y):(t=c,e=l,i=p);for(let n=0;n<2;n++){const r=0===n?0:t.length-1,o=new f,h=[0],m=Sr(e,i,t[r],D.unit(),!1,-1,1,h);s(1===m),eo(e,i,h[0],o),f.distance(t[r],o)<=a&&(0===x?(b.push(0===r?0:1),E.push(h[0])):(E.push(0===r?0:1),b.push(h[0])))}}if(0===b.length)return 0;if(!P.equalsRange(0,1))for(let s=0;s<b.length;++s)b[s]=mn.recalculateParentT(P.vmin,P.vmax,b[s]);if(!v.equalsRange(0,1))for(let s=0;s<E.length;++s)E[s]=mn.recalculateParentT(v.vmin,v.vmax,E[s]);for(let s=0;s<b.length;++s)b[s]=no(g,b[s]);for(let s=0;s<E.length;++s)E[s]=no(_,E[s]);return el(t,e,i,b,E,b.length,n,r,o,a,h,m,u)}function Zr(t,e,s,i,n,r,o,a,h,m){if(e.isLine()){return Zo(t,s,new rl({start:e.getStartXY(),end:e.getEndXY()}),i,r,n,o,a,h,!m)}if(s.isLine()){return Hr(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=x(f,3);e.queryControlPoints(l);const c=x(f,3);s.queryControlPoints(c);const d=il(l,2,c,2,o);if(0===d)return 0;const g=[],_=[];if(-1===d){const t=x(Z,3),i=x(Z,3),n=x(Z,3),r=[0,0,0];e.queryWeights(r),Or(l,r,t,i,n);const a=x(un,3);ta(c,a);const h=_n(t,2,i,2,n,2,[a[0].x,a[1].x,a[2].x],2,[a[0].y,a[1].y,a[2].y],2,null,0,!0,D.unit(),D.unit(),g,_);if(h>0){let t=0;for(let i=0;i<h;i++){const n=new f;s.queryCoord2D(_[i],n);const r=new f;e.queryCoord2D(g[i],r),f.distance(r,n)<=o&&(g[t]=g[i],_[t]=_[i],t++)}g.length=t,_.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let i=0;i<2;i++){const n=0===i?0:t.length-1;let r;const a=new f;0===p?(r=No(s,t[n],D.unit(),!1),s.queryCoord2D(r,a)):(r=Dr(e,t[n],D.unit(),!1,-1),e.queryCoord2D(r,a)),f.distance(t[n],a)<=o&&(0===p?(g.push(0===n?0:1),_.push(r)):(_.push(0===n?0:1),g.push(r)))}}return el(t,e,s,g,_,g.length,i,n,r,o,a,h,m)}function Ur(t,e,s,i=!1){const n=x(f,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}function Or(t,e,s,i,n){const r=Z.constructDouble(e[0]),o=Z.constructDouble(e[1]),a=Z.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(r),i[1].setDouble(t[1].y),i[1].mulThis(o),i[2].setDouble(t[2].y),i[2].mulThis(a),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function Qr(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function Kr(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,m,u;if(s<=.5){const t=R(n[0],n[1],a),e=R(n[1],n[2],a);h=j(t,e,a);const s=R(r[0],r[1],a),i=R(r[1],r[2],a);m=j(s,i,a);const l=R(o[0],o[1],a),c=R(o[1],o[2],a);u=R(l,c,a)}else{const t=L(n[0],n[1],a),e=L(n[1],n[2],a);h=L(t,e,a);const s=L(r[0],r[1],a),i=L(r[1],r[2],a);m=L(s,i,a);const l=L(o[0],o[1],a),c=L(o[1],o[2],a);u=L(l,c,a)}return h/=u,m/=u,i.setCoords(h,m),ho(t,i),u}function $r(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n);Jr([Ns.constructPoint2D(i[0]),Ns.constructPoint2D(i[1]),Ns.constructPoint2D(i[2])],[new V(n[0]),new V(n[1]),new V(n[2])],e,s)}function Jr(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const n=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],r=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],o=[e[0].clone(),e[1].clone(),e[2].clone()],a=new V,h=new V,m=new V;if(s.value()<=.5){const t=K(n[0],n[1],s),e=K(n[1],n[2],s);a.setE(K(t,e,s));const i=K(r[0],r[1],s),u=K(r[1],r[2],s);h.setE(K(i,u,s));const l=K(o[0],o[1],s),c=K(o[1],o[2],s);m.setE(K(l,c,s))}else{const t=$(n[0],n[1],s),e=$(n[1],n[2],s);a.setE($(t,e,s));const i=$(r[0],r[1],s),u=$(r[1],r[2],s);h.setE($(i,u,s));const l=$(o[0],o[1],s),c=$(o[1],o[2],s);m.setE($(l,c,s))}a.divThisE(m),h.divThisE(m);const u=new f(a.value(),h.value());ho([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,a.eps()),i.y.set(u.y,h.eps())}function to(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function eo(t,e,s,i,n){if(n){if(s<0){return void hi(new rl({start:t[0],end:t[0].add(dr(t,e,0).getUnitVector())}),s,i)}if(s>1){return void hi(new rl({start:t[2],end:t[2].add(dr(t,e,1).getUnitVector())}),s-1,i)}}Kr(t,e,s,i)}function so(t,e,s,i){i.setEmpty();const n=[];n.push(new D(0,1));const r=.5*Math.max(s.width(),s.height());for(;n.length;){const o=n.at(-1);n.pop();const a=new Ds;if(Ir(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{const t=o.getCenter();n.push(D.construct(o.vmin,t)),n.push(D.construct(t,o.vmax))}}}}function io(t){return t[1]/Math.sqrt(t[0]*t[2])}function no(t,e){const s=Math.sqrt(t[2]/t[0]);return e/j(s,1,e)}function ro(t,e){const s=Math.sqrt(t[0]/t[2]);return e/j(s,1,e)}function oo(t,e,i,n){s(e>=0&&e<=1);(new Bt).setCoordsPoint3D(t[0]);(new Bt).setCoordsPoint3D(t[1]);(new Bt).setCoordsPoint3D(t[2]);const r=new Bt,o=new Bt,a=new Bt;J(3,t[0],t[1],e,r),J(3,t[1],t[2],e,o),J(3,r,o,e,a);const h=t[2].clone();i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(a)),n&&(n[0].assign(a),n[1].assign(o),n[2].assign(h))}function ao(t,e,i,n){const r=[t[0],t[1],t[2]];s(e>=0&&e<=1&&i!==n);const o=j(r[0],r[1],e),a=j(r[1],r[2],e),h=j(o,a,e);i&&(i[0]=r[0],i[1]=o,i[2]=h),n&&(n[0]=h,n[1]=a,n[2]=r[2])}function ho(t,e){const s=D.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=y(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=y(e.y,s.vmin,s.vmax)}function mo(t,e){const s=new D;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=y(e[0].x,s.vmin,s.vmax),e[1].x=y(e[1].x,s.vmin,s.vmax),e[2].x=y(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=y(e[0].y,s.vmin,s.vmax),e[1].y=y(e[1].y,s.vmin,s.vmax),e[2].y=y(e[2].y,s.vmin,s.vmax)}class uo{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}class lo{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-xo(this.b,e,!1):0}getError(t){return s(0),0}}function co(t,e,s,i,n){let r=!0;const o=x(f,3);t.queryControlPoints(o);let a=r?0:1,h=o[1][a]-o[0][a],m=o[2][a]-o[0][a];const u=Bn(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=R(0,h,t),i=R(h,m,t);e=R(s,i,t)}else{const s=L(0,h,t),i=L(h,m,t);e=L(s,i,t)}return e*bo(o,1,t).length()}));r=!1,a=r?0:1,h=o[1][a]-o[0][a],m=o[2][a]-o[0][a];const l=Bn(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=R(0,h,t),i=R(h,m,t);e=R(s,i,t)}else{const s=L(0,h,t),i=L(h,m,t);e=L(s,i,t)}return e*bo(o,1,t).length()}));return new f(u,l)}function go(t){t.m_cachedValues=null}function _o(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function po(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new uo;return fo(t,e.specialPoints),Io(t,e),e}function fo(t,e){const s=x(f,3);t.queryControlPoints(s);const i=x(V,8);i[0].set(0);let n=1;{const t=x(V,3);$o(s,t,!1);const e=x(V,2),r=new D(0,1);let o=Zi(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)G(e[s].value(),0,1)||(i[n]=e[s],n++)}{const t=x(V,3);Jo(s,t,!1);const e=x(V,2),r=new D(0,1);let o=Zi(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)G(e[s].value(),0,1)||(i[n]=e[s],n++)}if(i[n].set(1),n++,n>2){M(i,0,n,((t,e)=>t.value()-e.value()));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),e.length=n;for(let r=0;r<n;r++)e[r]=i[r].value()}function xo(t,e,s){const i=x(f,3);return t.queryControlPoints(i),yo(i,e,s)}function yo(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+yo(t,1,!1)}if(1===e)return Po(t);const i=x(f,3);return Vo(t,e,i,null),Po(i)}function Po(t){if(t[0].equals(t[1]))return f.distance(t[2],t[0]);if(t[1].equals(t[2]))return f.distance(t[0],t[2]);const e=f.distance(t[0],t[1])+f.distance(t[2],t[1]),s=f.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const i=1,n=x(f,3);Qo(t,n,!0);const r=4*(C(n[2].x)+C(n[2].y)),o=2*(n[2].x*n[1].x+n[2].y*n[1].y),a=C(n[1].x)+C(n[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r)){if(1e-14*Math.abs(a)>=Math.abs(o)){return Math.sqrt(a)*i}return 2/(3*o)*(Math.pow(o*i+a,1.5)-Math.pow(a,1.5))}const h=o/r,m=a/r,u=m-h*h,l=i+h;if(0===u){if(h>=0&&l>=0||h<=0&&l<=0){return Math.abs(.5*Math.sqrt(r)*(l*l-h*h))}return.5*Math.sqrt(r)*(l*l+h*h)}const c=Math.sqrt(u+l*l),d=Math.sqrt(m);return.5*Math.sqrt(r)*(l*c-h*d+u*Math.log(Math.abs((l+c)/(h+d))))}function vo(t,e){const s=y(e,0,1);let i=bo(t,1,s);return i.isZero()&&(i=bo(t,2,s)),i}function Co(t,e,s){const i=x(f,3);return t.queryControlPoints(i),bo(i,e,s)}function bo(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):f.construct(0,0)}function Eo(t,e,s){{const e=Ns.constructPoint2D(t[1]).subE(Ns.constructPoint2D(t[0])),i=new V(1).subE(s),n=Ns.constructPoint2D(t[2]).subE(Ns.constructPoint2D(t[1])),r=e.mulE(i).addE(n.mulE(s));return r.mulThisE(new V(2)),r}}function Do(t,e,s){const i=xo(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new lo(t,e),D.unit(),1,n)&&a(""),n[0]}function So(t){const e=x(f,3);return t.queryControlPoints(e),wo(e)}function wo(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Ao(t){const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function To(t){return t.m_cachedValues}function Io(t,e){t.m_cachedValues=e}function No(t,e,s,i,n){c(D.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=x(f,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=qo(r,e,a);if(s.containsCoordinate(a[0]))o=f.distance(e,h);else{a[0]=s.vmin,ea(r,a[0],h),o=f.distance(h,e);const t=new f;ea(r,s.vmax,t);const i=f.distance(t,e);o>i&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=i)}if(!i)return a[0];if(s.vmin<=0){const i=new f;t.queryCoord2DExtended(-1,i,!0);const n=new f;t.queryCoord2D(s.vmin,n);const r=new rl({start:i,end:n}),m=r.getClosestCoordinate(e,!0);if(m<1){const t=r.getCoord2D(m),s=f.distance(t,e);s<o&&(o=s,a[0]=m-1,h.assign(t))}}if(s.vmin>=1){const i=new f;t.queryCoord2DExtended(2,i,!0);const n=new f;t.queryCoord2D(s.vmax,n);const r=new rl({start:n,end:i}),m=r.getClosestCoordinate(e,!0);if(m>0){const t=r.getCoord2D(m),s=f.distance(t,e);s<o&&(o=s,a[0]=1+m,h.assign(t))}}return a[0]}function qo(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(n),a=r.dotProduct(i)+2*n.dotProduct(n),h=3*n.dotProduct(i),m=i.dotProduct(i),u=new Array(3),l=zi(m,h,a,o,D.unit(),!1,u),c=t[0].clone();let d=0,g=f.sqrDistance(t[0],e),_=f.sqrDistance(t[2],e);_<g&&(d=1,c.assign(t[2]),g=_);for(let p=0;p<l;p++){const s=new f;ea(t,u[p],s),_=f.sqrDistance(s,e),_<g&&(g=_,c.assign(s),d=u[p])}return s&&(s[0]=d),c}function Mo(t,e,s,i,n,r){const o=new Ds;if(Yo(t,D.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=new f,h=No(t,e,D.unit(),!1);t.queryCoord2D(h,a);return f.distance(a,e)<=n?(i&&(i[0]=h),1):0}function Yo(t,e,s){const i=x(f,3);t.queryControlPoints(i),Xo(i,e,s)}function Xo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=x(f,3);Bo(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function Fo(t,e,s){s.setEmpty();const i=[];i.push(new D(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Ds;if(Xo(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(D.construct(r.vmin,t)),i.push(D.construct(t,r.vmax))}}}}function Ro(t){const e=x(f,3);t.queryControlPoints(e);const s=Lo(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Lo(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[2][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function zo(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weighted_centroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=po(t),o=ti(t),a=Math.min(o/t.calculateUpperLength2D(),1e-7);let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=co(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function Vo(t,e,s,i){(new f).setCoordsPoint2D(t[0]);(new f).setCoordsPoint2D(t[1]);(new f).setCoordsPoint2D(t[2]);const n=new f,r=new f,o=new f;if(Q(t[0],t[1],e,n),Q(t[1],t[2],e,r),Q(n,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(o)),i){const e=t[2];i[0].assign(o),i[1].assign(r),i[2].assign(e)}}function Bo(t,e,s,i){if(e===s){const s=new f;return ea(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=x(f,3);Vo(t,s,n,null),Vo(n,e/s,null,n),ea(t,e,n[0]),ea(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ko(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Q(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Ro(t)}function Go(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function Ho(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Zo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Wo(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Uo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function jo(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==Oo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Zo(t,e,i,n,r,o,a,h,m,u){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(i.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!==o)for(let t=0;t<s;t++)o.push(0);if(null!==n)for(let i=0;i<s;i++){const s=new f;e.queryCoord2D(t[i],s),n.push(s)}}return s}const l=ei(e,i);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new rl({start:e.getStartXY(),end:e.getEndXY()}),s=yi(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<s;++i){const s=t.getCoord2D(r[i]);r[i]=e.getClosestCoordinate(s,!1)}return s}if(si(e,i,a))return 0;const c=un.constructPoint2D(i.getStartXY()),d=un.constructPoint2D(i.getEndXY()).sub(c),g=d.clone();g.leftPerpendicularThis();const _=un.constructPoint2D(e.m_cp).sub(un.constructPoint2D(e.getStartXY())),p=un.constructPoint2D(e.getEndXY()).sub(un.constructPoint2D(e.m_cp));let y=_.dotProduct(g).toDouble(),P=p.sub(_).dotProduct(g).toDouble();const v=q(12,Number.NaN),C=q(12,Number.NaN);let b=Ri(P,y,D.unit(),v);b<0&&(v[0]=0,v[1]=1,b=2);let E,S=0;for(let s=0,x=S;s<b;++s){const t=e.getCoord2D(v[s+x]);C[S]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(C[S]))<=a&&(v[S]=v[s+x],S++)}const w=x(f,3);e.queryControlPoints(w);{const t=x(un,3);if(ta(w,t,!1),t[0]=t[0].sub(c),d.x.abs().gte(d.y.abs())){const e=d.y.div(d.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),y=t[1].y.sub(t[1].x.mul(e)).toDouble(),E=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=d.x.div(d.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),y=t[1].x.sub(t[1].y.mul(e)).toDouble(),E=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const A=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),T=[0,0];b=Li(P,y,E,D.unit(),A,T);for(let s=0,x=S;s<b;++s){v[s+x]=T[s];const t=e.getCoord2D(v[s+x]);C[S]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(C[S]))<=a&&(v[S]=v[s+x],S++)}s(S<v.length+4),b=e.intersectPoint(i.getStartXY(),T,a);for(let s=0;s<b;s++)v[S]=T[s],C[S++]=0;b=e.intersectPoint(i.getEndXY(),T,a);for(let s=0;s<b;s++)v[S]=T[s],C[S++]=1;b=i.intersectPoint(e.getStartXY(),T,a);for(let s=0;s<b;s++)C[S]=T[s],v[S++]=0;b=i.intersectPoint(e.getEndXY(),T,a);for(let s=0;s<b;s++)C[S]=T[s],v[S++]=0;return 0===S?0:el(t,e,i,v,C,S,n,r,o,a,h,m,u)}function Uo(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return Zo(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=x(f,3);{e.queryControlPoints(d);const t=x(f,3),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(d,3,t);const r=x(un,3);ta(t,r);const a=[r[0].x,r[1].x,r[2].x],h=[r[0].y,r[1].y,r[2].y],m=x(Z,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2]=m[0],m[2].mul(m[1]),m[2].negate();const u=xn(a,2,h,2,null,0,m,!0,D.unit(),D.unit(),l);if(u>0){let t=0;for(let i=0;i<u;i++){const n=new f;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a),f.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const g=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),e=[0];qo(d,t,e);const i=new f;ea(d,e[0],i),f.distance(t,i)<=o&&(l.push(e[0]),c.push(g[_]))}for(let _=0;_<2;_++){const t=[0,2];{const e=s.getClosestCoordinate(d[t[_]],!1),i=new f;s.queryCoord2D(e,i),f.distance(d[t[_]],i)<=o&&(l.push(g[_]),c.push(e))}}return el(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function Oo(t,e,s,i,n,r,o,a,h,m){const u=x(f,3);e.queryControlPoints(u);const l=x(f,3);if(s.queryControlPoints(l),ii(u,l,3)<0)return Oo(t,s,e,i,r,n,o,a,h,!m);const c=ei(e,s);if(si(e,s,o=Math.max(o,c)))return 0;if(la(e,s,i,n,r,o,a,h,m))return 2;const d=new D(0,1),g=new D(0,1);{const t=new Ds;Xo(u,D.unit(),t);const e=new Ds;Xo(l,D.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Fo(u,t,d),Fo(l,t,g),d.isEmpty()||g.isEmpty())return 0;Bo(u,d.vmin,d.vmax,u),Bo(l,g.vmin,g.vmax,l)}}const _=il(u,2,l,2,o);if(0===_)return 0;const p=[],y=[];if(-1===_){const t=x(un,3);ta(u,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=x(un,3);ta(l,i);const n=_n(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,!0,D.unit(),D.unit(),p,y,m);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new f,i=new f;ea(l,y[e],i),ea(u,p[e],s),f.distance(s,i)<=o&&(p[t]=p[e],y[t]=y[e],t++)}p.length=t,y.length=t}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:2,n=[0];qo(e,t[i],n);const r=new f;ea(e,n[0],r),f.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),y.push(n[0])):(y.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let f=0;f<p.length;++f)p[f]=an.recalculateParentT(d.vmin,d.vmax,p[f]);if(!g.equalsRange(0,1))for(let f=0;f<y.length;++f)y[f]=an.recalculateParentT(g.vmin,g.vmax,y[f]);return el(t,e,s,p,y,p.length,i,n,r,o,a,h,m)}function Qo(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Ko(t,e,s=!1){const i=x(f,3);t.queryControlPoints(i),Qo(i,e,s)}function $o(t,e,s=!1){const i=0,n=new V(t[1][i]).subE(new V(t[0][i]));e[1]=n.mul(2),e[2]=new V(t[2][i]).subE(new V(t[1][i])).subE(n),s?e[0].set(0):e[0].set(t[0][i])}function Jo(t,e,s=!1){const i=1,n=new V(t[1][i]).subE(new V(t[0][i]));e[1]=n.mul(2),e[2]=new V(t[2][i]).subE(new V(t[1][i])).subE(n),s?e[0].set(0):e[0].set(t[0][i])}function ta(t,e,s=!1){const i=un.constructPoint2D(t[1]),n=i.sub(un.constructPoint2D(t[0]));e[1]=n.mul(Z.constructInt32(2)),e[2]=un.constructPoint2D(t[2]).sub(i).sub(n),e[0]=s?new un(pt,pt):un.constructPoint2D(t[0])}function ea(t,e,s,i){if(i){if(e<0){return void hi(new rl({start:t[0],end:t[0].add(vo(t,0).getUnitVector())}),e,s)}if(e>1){return void hi(new rl({start:t[2],end:t[2].add(vo(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=t[1].clone(),n=new f;H(2,t[0],i,e,n);const r=new f;H(2,i,t[2],e,r);const o=new f;H(2,n,r,e,o),s.assign(o)}else{const i=t[1].clone(),n=new f;W(2,t[0],i,e,n);const r=new f;W(2,i,t[2],e,r);const o=new f;W(2,n,r,e,o),s.assign(o)}}function sa(t,e,s){const i=x(f,3);t.queryControlPoints(i),ia(i,e,s)}function ia(t,e,s){if(e.value()<=.5){const i=Ns.constructPoint2D(t[1]),n=new Ns;tt(2,Ns.constructPoint2D(t[0]),i,e,n);const r=new Ns;tt(2,i,Ns.constructPoint2D(t[2]),e,r);const o=new Ns;tt(2,n,r,e,o),s.setE(o)}else{const i=Ns.constructPoint2D(t[1]),n=new Ns;et(2,Ns.constructPoint2D(t[0]),i,e,n);const r=new Ns;et(2,i,Ns.constructPoint2D(t[2]),e,r);const o=new Ns;et(2,n,r,e,o),s.setE(o)}}function na(t,e,s){const i=x(f,4);t.queryControlPoints(i),ra(i,e,s)}function ra(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(Eo(t,1,e))}function oa(t,e){let s=1;t[1].isEqualPoint2D(t[0])&&(s=2,t[2].isEqualPoint2D(t[0])&&(s=3));let i=2;t[2].isEqualPoint2D(t[3])&&(i=1,t[1].isEqualPoint2D(t[3])&&(i=0)),e[0].assign(t[0]),e[2].assign(t[3]);const n=f.intersectLinesAtOnePoint(t[0],t[s],t[i],t[3]),r=new f;Q(t[0],t[3],.5,r);const o=new f;Ua(t,.5,o);const a=new f;e[1].assign(n),ea(e,.5,a);const h=new f;e[1].assign(r),ea(e,.5,h);const m=f.sqrDistance(o,a),u=f.sqrDistance(o,h);return m<u?(e[1].setCoordsPoint2D(n),Math.sqrt(m)):(e[1].setCoordsPoint2D(r),Math.sqrt(u))}function aa(t,e,s){s[0].assign(t[0]),s[1].assign(t[1]),s[2].assign(t[2]);const i=new f;eo(t,e,.5,i);const n=new f;ea(s,.5,n);const r=f.sqrDistance(i,n);return Math.sqrt(r)}function ha(t,e){e[0].assign(t[0]),e[3].assign(t[2]),Q(t[0],t[1],2/3,e[1]),Q(t[1],t[2],1/3,e[2])}function ma(t,e){const s=x(f,3);t.queryControlPoints(s);const i=f.sqrDistance(s[1],s[0]),n=f.sqrDistance(s[1],s[2]);let r=s[0].clone(),o=i;i>n&&(r=s[2].clone(),o=n);let a=!1;return o<=e&&0!==o&&(a=!0,t.setControlPoint1(r)),a}function ua(t,e){if(!e)return!1;const s=x(f,3);t.queryControlPoints(s);const i=f.sqrDistance(s[1],s[0]),n=f.sqrDistance(s[1],s[2]);s[0].clone();let r=i;return i>n&&(s[2].clone(),r=n),r<=e&&0!==r}function la(t,e,s,i,n,r,o,a,h){const m=x(f,3);t.queryControlPoints(m);const u=x(f,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return s&&(s.length=0,s.push(m[0]),s.push(m[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=S(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=S(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[2]),h&&(s[1]=S(s[0],s[0]=s[1]))),!0)}var ca=Vt;class da extends oi{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=x(f,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||F(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=x(f,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=x(f,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),a("unrecognized constructor params"),this.m_cp=x(f,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return Vh(this)}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=x(f,4);ha(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),J(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),J(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),$s(this,t)}getGeometryType(){return n.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void s(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Aa(this);if(null!==e){const s=new f;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const i=x(V,8),n=x(f,4);this.queryControlPoints(n);const r=vh(n,i),o=new f;for(let s=1;s<r-1;s++)this.queryCoord2D(i[s].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=x(f,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Ia(this)}s(0)}createInstance(){return new da({vd:this.m_description})}calculateLength2D(){return Ea(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return f.distance(this.getStartXY(),this.m_cp[0])+f.distance(this.m_cp[0],this.m_cp[1])+f.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DExtends(t,e,s){const i=x(f,4);this.queryControlPoints(i),Ua(i,t,e,s)}queryCoord2DE(t,e){Qa(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtends(t,e,!0),e.x}const e=j(this.getStartX(),this.m_cp[0].x,t),s=j(this.m_cp[0].x,this.m_cp[1].x,t),i=j(this.m_cp[1].x,this.getEndX(),t),n=j(e,s,t),r=j(s,i,t);return j(n,r,t)}getCoordY(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtends(t,e,!0),e.y}const e=j(this.getStartY(),this.m_cp[0].y,t),s=j(this.m_cp[0].y,this.m_cp[1].y,t),i=j(this.m_cp[1].y,this.getEndY(),t),n=j(e,s,t),r=j(s,i,t);return j(n,r,t)}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=ca.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=ca.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){$a(this,t,e)}cutBezierIgnoreAttributes(t,s,i){(t<0||s>1||t>s)&&e("Cubic_bezier.cut_bezier_ignore_attributes");const n=x(f,4);this.queryControlPoints(n);const r=x(f,4);Za(n,t,s,r),i.setControlPoints(r)}splitBezierIgnoreAttributes(t,s,i){this===s&&this===i&&e("Cubic_bezier.split_bezier_ignore_attributes");const n=x(f,4);this.queryControlPoints(n);const r=x(f,4),o=x(f,4);ja(n,t,r,o),s&&s.setControlPoints(r),i&&i.setControlPoints(o)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.getStartAttributeAsDbl(e,s),n=this.getEndAttributeAsDbl(e,s),r=this.calculateLength2D(),o=r>0?this.tToLength(t)/r:0,a=ca.getInterpolation(e);return z(a,i,n,o,ca.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return _h(this,t,D.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===_h(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=wa(this);if(2===n.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){ka(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){const n=x(f,4);return this.queryControlPoints(n),Ch(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=qt.constructEmpty();this.queryEnvelope(t);const s=D.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,4);this.queryControlPoints(s),Za(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ea(this,t,!0)}lengthToT(t){return Da(this,t)}calculateWeightedAreaCentroid2D(t){const e=x(f,4);xa(this,e);const s=e[3],i=e[2],n=e[1],r=new f;r.x=(5*s.x*s.x*(7*i.y+16*n.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*n.x+140*i.x*n.y+112*n.x*n.y)-2*(s.y*(20*i.x*i.x+70*i.x*n.x+56*n.x*n.x)-7*(4*i.x+5*n.x)*(-i.y*n.x+i.x*n.y)))/840,r.y=(-5*s.y*s.y*(7*i.x+16*n.x)+s.y*(5*s.x*(7*i.y+16*n.y)-4*(10*i.x*i.y+35*i.y*n.x+28*n.x*n.y))+2*(-7*(4*i.y+5*n.y)*(i.y*n.x-i.x*n.y)+s.x*(20*i.y*i.y+70*i.y*n.y+56*n.y*n.y)))/840;const o=Ba(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):fa(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Sa(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let s=0;s<4;s++)t[s].isNAN()&&e("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=x(f,4);return this.queryControlPoints(e),Ka(e,t)}getDerivative(t){const e=x(f,4);return this.queryControlPoints(e),La(e,1,t)}getCurvature(t){const e=Va(this,1,t),s=Va(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new qt;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),r=new f;this.queryCoord2D(n,r);return f.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}isMonotoneQuickAndDirty(){const t=x(f,4);return this.queryControlPoints(t),Ha(t)}getMonotonicPartParams(t,i){const n=wa(this),r=n.specialPointsCount();if(s(ri.s_maxMonotonicPartParams>=r),!i)return n.specialPointsCount();t<r&&e("");for(let e=0;e<r;e++)i[e]=n.specialPoints[e];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=S(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new V;return Xa(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=this.getEndXY().sub(this.getStartXY()),s=e.length(),i=.1*t;let n=this.getControlPoint1();n.subThis(this.getStartXY());let r=Math.abs(n.crossProduct(e))/s;return!(r>i)&&(n=this.getControlPoint2(),n.subThis(this.getStartXY()),r=Math.abs(n.crossProduct(e))/s,!(r>i))}copyIgnoreAttributes(t){const e=x(f,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Ba(this)}absNorm(){return ph(this)}queryEnvelopeW(t,e){lh(this,t,e)}setSegmentFromCoords(t,e){xh(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=x(f,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=x(f,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(f.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);f.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=x(f,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(f.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);f.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return Eh(this,t,e)}ensureXYMonotone(){return ka(this)}setCoordsForIntersector(t,e,s){qa(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Ta(e,Aa(this))}reverseImpl(){this.m_cp[1]=S(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,i=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[i])}equalsImplTol(t,e){const s=t,i=0,n=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[i],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[n],e)}swapImpl(t){const e=t;e.m_cp[0]=S(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=S(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),Na(this,e)}afterCompletedModification(){Ia(this)}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return uh(this,t,e,s)}endPointModified(){Ia(this)}clearEndPointModified(){}}da.type=n.enumBezier;class ga{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function _a(t){return pa(t.calculateUpperLength2D())}function pa(t){return 256*st()*t}function fa(t){const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function xa(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function ya(t,e,s){const i=x(f,4);t.queryControlPoints(i),va(i,e,s)}function Pa(t,e,s){const i=x(f,4);t.queryControlPoints(i),Ca(i,e,s)}function va(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function Ca(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function ba(t,e,s=!1){const i=x(un,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(Z.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(Z.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(pt,pt):e[0]=i[0].clone()}function Ea(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ea(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=wa(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=_a(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=wh(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Da(t,e,s){const i=Ea(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new Dh(t,e),D.unit(),1,n)&&a(""),n[0]}function Sa(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weightedCentroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=wa(t),o=_a(t),a=o/t.calculateUpperLength2D();let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=Ah(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function wa(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ga,s=x(V,8),i=x(f,4);t.queryControlPoints(i);const n=vh(i,s);e.specialPoints=[];for(let r=0;r<n;r++)e.specialPoints.push(s[r].value());return Ta(t,e),e}function Aa(t){let e=null;return e=t.m_cachedValues,e}function Ta(t,e){t.m_cachedValues=e}function Ia(t){t.m_cachedValues=null}function Na(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function qa(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints2D(t.m_cp,2,t.m_cp):(Q(e,s,1/3,t.m_cp[0]),Q(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&ka(t)}function Ma(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function Ya(t,e,s,i){const n=new Array(18),r=x(f,4);t.queryControlPoints(r);const o=Fi(new dh(r,e),D.construct(s,i),18,n),a=new f;t.queryCoord2D(s,a);let h=s,m=f.distance(a,e);const u=new f;t.queryCoord2D(i,u);const l=f.distance(u,e);l<m&&(m=l,h=i,a.assign(u));for(let c=0;c<o;c++){t.queryCoord2D(n[c],u);const s=f.distance(u,e);s<m&&(m=s,h=n[c],a.assign(u))}return Ma(s,i,h,m,a)}function Xa(t,e){const i=x(V,4);ya(t,i,!0);const n=x(V,4);Pa(t,n,!0);const r=i[3].clone(),o=i[2].clone(),a=i[1].clone(),h=n[3].clone(),m=n[2].clone(),u=n[1].clone(),l=o.mulE(a).addE(m.mulE(u)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),d=r.mulE(o).addE(h.mulE(m)).mul(36),g=r.mulE(r).addE(h.mulE(h)).mul(36),_=x(V,3),p=Oi(g,d,c,l,new D(0,1),!1,_);if(s(p<=3),p>0){const s=Va(t,1,0).sqrLength(),i=Va(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let r=0;r<p;r++){const s=Va(t,1,_[r].value()).sqrLength();s<n&&(n=s,e=_[r])}}}function Fa(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}function Ra(t,e,s,i){{const e=dt.subE(s),n=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new V(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));i.setE(o.mulE(new V(3)))}}function La(t,e,s){const i=new f;return Fa(t,e,s,i),i}function za(t,e,s){const i=[Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3])],n=new Ns;return Ra(i,e,s,n),n}function Va(t,e,s){const i=x(f,4);return t.queryControlPoints(i),La(i,e,s)}function Ba(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e);return(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function ka(t){const e=x(f,4);t.queryControlPoints(e);const s=Ga(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Ga(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[3][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),O(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),O(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),O(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),O(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),O(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),O(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function Ha(t){const e=O(t[0].y,t[1].y),s=O(t[1].y,t[2].y),i=O(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=O(t[0].x,t[1].x),s=O(t[1].x,t[2].x),i=O(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}function Wa(t,e,s){const i=new f,n=new f,r=new f,o=new f,a=new f;e<=.5?(H(2,t[0],t[1],e,i),H(2,t[1],t[2],e,n),H(2,t[2],t[3],e,r),H(2,i,n,e,o),H(2,n,r,e,a),H(2,o,a,e,s)):(W(2,t[0],t[1],e,i),W(2,t[1],t[2],e,n),W(2,t[2],t[3],e,r),W(2,i,n,e,o),W(2,n,r,e,a),W(2,o,a,e,s))}function ja(t,e,i,n){s(e>=0&&e<=1);const r=new f,o=new f,a=new f,h=new f,m=new f,u=new f;e<=.5?(H(2,t[0],t[1],e,r),H(2,t[1],t[2],e,o),H(2,t[2],t[3],e,a),H(2,r,o,e,h),H(2,o,a,e,m),H(2,h,m,e,u)):(W(2,t[0],t[1],e,r),W(2,t[1],t[2],e,o),W(2,t[2],t[3],e,a),W(2,r,o,e,h),W(2,o,a,e,m),W(2,h,m,e,u));const l=t[3].clone();i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(h),i[3].assign(u)),n&&(n[0].assign(u),n[1].assign(m),n[2].assign(a),n[3].assign(l))}function Za(t,e,i,n){if(s(e>=0&&i<=1&&e<=i),e===i){const s=new f;return Ua(t,e,s),n[0].assign(s),n[1].assign(s),n[2].assign(s),void n[3].assign(s)}if(0===e&&1===i){for(let e=0;e<4;++e)n[e].assign(t[e]);return}const r=x(f,4);ja(t,i,r,null),ja(r,i>0?e/i:0,null,r),Ua(t,e,r[0]),Ua(t,i,r[3]),n[0].setCoordsPoint2D(r[0]),n[1].setCoordsPoint2D(r[1]),n[2].setCoordsPoint2D(r[2]),n[3].setCoordsPoint2D(r[3])}function Ua(t,e,s,i){if(i){if(e<0){return void hi(new rl({start:t[0],end:t[0].add(Ka(t,0).getUnitVector())}),e,s)}if(e>1){return void hi(new rl({start:t[3],end:t[3].add(Ka(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=new f;H(2,t[0],t[1],e,i);const n=new f;H(2,t[1],t[2],e,n);const r=new f;H(2,t[2],t[3],e,r);const o=new f;H(2,i,n,e,o);const a=new f;H(2,n,r,e,a),H(2,o,a,e,s)}else{const i=new f;W(2,t[0],t[1],e,i);const n=new f;W(2,t[1],t[2],e,n);const r=new f;W(2,t[2],t[3],e,r);const o=new f;W(2,i,n,e,o);const a=new f;W(2,n,r,e,a),W(2,o,a,e,s)}}function Oa(t,e,s){if(e.value()<=.5){const i=new Ns;tt(2,Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),e,i);const n=new Ns;tt(2,Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),e,n);const r=new Ns;tt(2,Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3]),e,r);const o=new Ns;tt(2,i,n,e,o);const a=new Ns;tt(2,n,r,e,a),tt(2,o,a,e,s)}else{const i=new Ns;et(2,Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),e,i);const n=new Ns;et(2,Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),e,n);const r=new Ns;et(2,Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3]),e,r);const o=new Ns;et(2,i,n,e,o);const a=new Ns;et(2,n,r,e,a),et(2,o,a,e,s)}}function Qa(t,e,s){const i=x(f,4);t.queryControlPoints(i),Oa(i,e,s)}function Ka(t,e){const s=y(e,0,1);let i=La(t,1,s);return i.isZero()&&(i=La(t,2,s),i.isZero()?i=La(t,3,s):1===s&&i.negateThis()),i}function $a(t,e,s){const i=x(f,4);t.queryControlPoints(i),Ja(i,e,s)}function Ja(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(za(t,1,e))}function th(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==rh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function eh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==oh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function sh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==ah(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ih(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==hh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function nh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==mh(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function rh(t,e,s,i,n,r,o,a,h,m){if(null!==n&&(n.length=0),null!=r&&(r.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==n)for(let e=0;e<a;e++)n.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=i)for(let s=0;s<a;s++){const n=new f;e.queryCoord2D(t[s],n),i.push(n)}}return a}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=x(f,4);xa(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const d=c.clone();d.leftPerpendicularThis();let g=3*l[3].dotProduct(d),_=2*l[2].dotProduct(d),p=l[1].dotProduct(d);const y=new Array(15),P=new Array(15);let v=Li(g,_,p,D.unit(),!1,y);v<0&&(y[0]=0,y[1]=1,v=2);let C,b=0;for(let x=0,D=b;x<v;++x){const t=e.getCoord2D(y[x+D]);P[b]=s.getClosestCoordinate(t,!1),f.distance(t,s.getCoord2D(P[b]))<=o&&(y[b]=y[x+D],b++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;g=l[3].y-l[3].x*t,_=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,C=l[0].y-l[0].x*t}else{const t=c.x/c.y;g=l[3].x-l[3].y*t,_=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,C=l[0].x-l[0].y*t}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),S=[0,0,0];v=zi(g,_,p,C,D.unit(),E,S);for(let x=0,D=b;x<v;++x){y[x+D]=S[x];const t=e.getCoord2D(y[x+D]);P[b]=s.getClosestCoordinate(t,!1);f.distance(t,s.getCoord2D(P[b]))<=o&&(y[b]=y[x+D],b++)}v=e.intersectPoint(s.getStartXY(),S,o);for(let f=0;f<v;f++)y[b]=S[f],P[b++]=0;v=e.intersectPoint(s.getEndXY(),S,o);for(let f=0;f<v;f++)y[b]=S[f],P[b++]=1;return 0!==s.intersectPoint(e.getStartXY(),S,o)&&(P[b]=S[0],y[b++]=0),0!==s.intersectPoint(e.getEndXY(),S,o)&&(P[b]=S[0],y[b++]=1),0===b?0:el(t,e,s,y,P,b,i,n,r,o,a,h,m)}function oh(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return rh(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=[],g=x(f,4);{e.queryControlPoints(g);const t=x(f,4),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(g,4,t);const r=x(un,4);ba(t,r);const a=[r[0].x,r[1].x,r[2].x,r[3].x],h=[r[0].y,r[1].y,r[2].y,r[3].y],m=x(Z,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2].setThis(m[0]),m[2].mulThis(m[1]),m[2].negateThis();const u=xn(a,3,h,3,null,0,m,!0,D.unit(),D.unit(),c);if(u>0){let t=0;for(let i=0;i<u;i++){const n=new f;e.queryCoord2D(c[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a);f.distance(n,a)<=o&&(l.push(n.clone()),c[t]=c[i],d.push(r),t++)}c.length=t,l.length=t}}const _=[0,1];for(let p=0;p<2;p++){const t=0===p?s.getStartXY():s.getEndXY(),e=[0];gh(g,t,D.unit(),!1,-1,1,e);const i=new f;Ua(g,e[0],i);f.distance(t,i)<=o&&(c.push(e[0]),d.push(_[p]),l.push(i.clone()))}for(let p=0;p<2;p++){const t=[0,3];{const e=s.getClosestCoordinate(g[t[p]],!1),i=new f;s.queryCoord2D(e,i);f.distance(g[t[p]],i)<=o&&(c.push(_[p]),d.push(e),l.push(i.clone()))}}return el(t,e,s,c,d,c.length,i,n,r,o,a,h,m)}function ah(t,e,i,n,r,o,a,h,m,u){const l=x(f,4);e.queryControlPoints(l);const c=x(f,4);if(i.queryControlPoints(c),ii(l,c,4)<0)return ah(t,i,e,n,o,r,a,h,m,!u);const d=ei(e,i);if(si(e,i,a=Math.max(a,d)))return 0;if(Th(e,i,n,r,o,a,h,m,u))return 2;const g=new D(0,1),_=new D(0,1);{const t=new Ds;ch(l,new D(0,1),t);const e=new Ds;ch(c,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(bh(l,t,g),bh(c,t,_),g.isEmpty()||_.isEmpty())return 0;Za(l,g.vmin,g.vmax,l),Za(c,_.vmin,_.vmax,c)}}const p=il(l,3,c,3,a);if(0===p)return 0;const y=[],P=[],v=[];let C=!1;if(-1===p){const t=x(un,4);ba(l,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=x(un,4);ba(c,i);const n=[],r=[],o=_n(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,!0,D.unit(),D.unit(),n,r);if(o>0)for(let h=0;h<o;h++){const t=new f;Ua(c,r[h],t);const e=new f;Ua(l,n[h],e);f.distance(e,t)<=a&&(y.push(e.clone()),v.push(r[h]),P.push(n[h]))}else-1===o&&(C=!0)}for(let s=0;s<2;s++){const t=0===s?l:c,e=0===s?c:l;for(let i=0;i<2;i++){const n=0===i?0:3,r=[0];gh(e,t[n],D.unit(),!1,-1,1,r);const o=new f;Ua(e,r[0],o);f.distance(t[n],o)<=a&&(0===s?(P.push(0===n?0:1),v.push(r[0])):(v.push(0===n?0:1),P.push(r[0])),y.push(o.clone()))}}if(0===P.length&&C){const t=e.calculateUpperLength2D()>i.calculateUpperLength2D();{const n=[0,0];if(2===yh(t?e:i,n,!0)&&(s(D.unit().containsCoordinate(n[0])),!D.unit().containsCoordinate(n[1]))){const e=new f;Ua(t?l:c,n[0],e);const s=[0,0];1===gh(t?c:l,e,D.unit(),!1,-1,2,s)&&(y.push(e.clone()),P.push(t?n[0]:s[0]),v.push(t?s[0]:n[0]))}}}if(0===P.length)return 0;if(!g.equalsRange(0,1))for(let s=0;s<P.length;++s)P[s]=da.recalculateParentT(g.vmin,g.vmax,P[s]);if(!_.equalsRange(0,1))for(let s=0;s<v.length;++s)v[s]=da.recalculateParentT(_.vmin,_.vmax,v[s]);return el(t,e,i,P,v,P.length,n,r,o,a,h,m,u)}function hh(t,e,i,n,r,o,a,h,m,u){const l=ei(e,i);if(i.isDegenerateToLineHelper(l)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()}),l=rh(t,e,s,n,r,o,a,h,m,u);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=i.getClosestCoordinate(e,!1)}return l}if(si(e,i,a=Math.max(a,l)))return 0;const c=x(f,4);e.queryControlPoints(c);const d=x(f,3);i.queryControlPoints(d);const g=new D(0,1),_=new D(0,1),p=[0,0,0];i.queryWeights(p);const y=[1,io(p),1];{const t=new Ds;ch(c,new D(0,1),t);const e=new Ds;Ir(d,y,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(bh(c,t,g),so(d,y,t,_),g.isEmpty()||_.isEmpty())return 0;Za(c,g.vmin,g.vmax,c),Fr(d,y,_.vmin,_.vmax,d,y)}}const P=il(c,3,d,2,a);if(0===P)return 0;const v=[],C=[],b=[];if(-1===P){const t=x(un,4);ba(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=x(Z,3),n=x(Z,3),r=x(Z,3);Or(d,y,i,n,r);const o=[],h=[],m=_n(i,2,n,2,r,2,e,3,s,3,null,0,!0,D.unit(),D.unit(),h,o);if(m>0)for(let u=0;u<m;u++){const t=new f;Ua(c,o[u],t);const e=new f;eo(d,y,h[u],e);f.distance(t,e)<=a&&(v.push(t.clone()),C.push(o[u]),b.push(h[u]))}}for(let x=0;x<2;x++){let t,e;0===x?(t=c,e=d):(e=c,t=d);for(let i=0;i<2;i++){const n=0===i?0:t.length-1,r=[0],o=new f;if(0===x){const i=Sr(e,y,t[n],D.unit(),!1,-1,1,r);s(1===i),eo(e,y,r[0],o)}else{const i=gh(e,t[n],D.unit(),!1,-1,1,r);s(1===i),Ua(e,r[0],o)}f.distance(t[n],o)<=a&&(0===x?(C.push(0===n?0:1),b.push(r[0])):(b.push(0===n?0:1),C.push(r[0])),v.push(o.clone()))}}if(0===C.length)return 0;if(!g.equalsRange(0,1))for(let s=0;s<C.length;++s)C[s]=da.recalculateParentT(g.vmin,g.vmax,C[s]);if(!_.equalsRange(0,1))for(let s=0;s<b.length;++s)b[s]=mn.recalculateParentT(_.vmin,_.vmax,b[s]);for(let s=0;s<b.length;++s)b[s]=no(p,b[s]);return el(t,e,i,C,b,C.length,n,r,o,a,h,m,u)}function mh(t,e,i,n,r,o,a,h,m,u){const l=ei(e,i);if(si(e,i,a=Math.max(a,l)))return 0;const c=x(f,4);e.queryControlPoints(c);const d=x(f,3);i.queryControlPoints(d);const g=il(c,3,d,2,a);if(0===g)return 0;const _=[],p=[],y=[];if(-1===g){const t=x(un,4);ba(c,t);const s=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],r=x(un,3);ta(d,r);const o=_n([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,s,3,n,3,null,0,!0,D.unit(),D.unit(),y,p);if(o>0){let t=0;for(let s=0;s<o;s++){const n=new f;e.queryCoord2D(p[s],n);const r=new f;i.queryCoord2D(y[s],r);f.distance(n,r)<=a&&(_.push(n.clone()),p[t]=p[s],y[t]=y[s],t++)}p.length=t,_.length=t}}for(let x=0;x<2;x++){let t,e;0===x?(t=c,e=d):(e=c,t=d);for(let i=0;i<2;i++){const n=0===i?0:t.length-1,r=[0],o=new f;if(0===x)qo(e,t[n],r),ea(e,r[0],o);else{const i=gh(e,t[n],D.unit(),!1,-1,1,r);s(1===i),Ua(e,r[0],o)}f.distance(t[n],o)<=a&&(0===x?(p.push(0===n?0:1),y.push(r[0])):(y.push(0===n?0:1),p.push(r[0])),_.push(o.clone()))}}return el(t,e,i,p,y,p.length,n,r,o,a,h,m,u)}function uh(t,e,n,r,o){const a=new Ds;if(lh(t,D.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=wa(t);let m=0,u=h.specialPoints[0];const l=[];for(let i=1,c=h.specialPoints.length;i<c;++i){const n=h.specialPoints[i],r=Ya(t,e,u,n);if(0===l.length)l.push(r);else if(r.t===r.tmin)s(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){s(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);u=n}for(const s of l)if(s.d<=r){const t=s.t;n?(m>=n.length&&i(""),n[m]=t,m++):m++}return m}function lh(t,e,s){const i=x(f,4);t.queryControlPoints(i),ch(i,e,s)}function ch(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=x(f,4);Za(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class dh{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e),i=La(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e),i=La(this.controlPoints,2,e),n=La(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=La(this.controlPoints,1,e),s=La(this.controlPoints,2,e),i=La(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=La(this.controlPoints,2,e),s=La(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=La(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(t){return 0}}function gh(t,e,i,n,r,o,a){c(D.unit().contains(i)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],m=new f;Ua(t,i.vmin,m);let u=f.distance(m,e);if(u<=r&&h.push(new f(i.vmin,u)),i.vmin!==i.vmax&&(Ua(t,i.vmax,m),u=f.distance(m,e),u<=r&&h.push(new f(i.vmax,u))),i.width()>0){const s=new Array(18),n=Fi(new dh(t,e),i,18,s);for(let i=0;i<n;i++)Ua(t,s[i],m),u=f.distance(m,e),u>r||h.push(new f(s[i],u))}if(n){s(i.equals(D.unit()));{Ua(t,-1,m,!0);const s=new f;Ua(t,0,s);const i=new rl({start:m,end:s}),n=i.getClosestCoordinate(e,!0);n<1&&(m.assign(i.getCoord2D(n)),u=f.distance(m,e),u<=r&&h.push(new f(n-1,u)))}{Ua(t,2,m,!0);const s=new f;Ua(t,i.vmax,s);const n=new rl({start:s,end:m}),o=n.getClosestCoordinate(e,!0);o>0&&(m.assign(n.getCoord2D(o)),u=f.distance(m,e),u<=r&&h.push(new f(1+o,u)))}}if(!h.length)return 0;h.sort(((t,e)=>t.compare(e)));let l=0;const d=h[0].x;if(a[l++]=d,l<o){const e=Xe(t,4,!1).total(),s=h[0].y;for(let t=1,i=h.length;t<i;t++)if(h[t].y>s+e){h.length=t;break}h.sort(((t,e)=>U(t.x,e.x))),l=0,a[l++]=h[0].x;for(let t=1,i=h.length;t<i;t++)h[t].x!==a[l-1]&&l<o&&(a[l++]=h[t].x)}return l}function _h(t,e,s,i,n,r,o){const a=x(f,4);return t.queryControlPoints(a),gh(a,e,s,i,n,r,o)}function ph(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function fh(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function xh(t,e,i){if(s(i>=2),2===i){const s=new f;Q(e[0],e[i-1],1/3,s);const n=new f;return Q(e[0],e[i-1],2/3,n),void t.construct(e[0],s,n,e[i-1])}const n=e[0],r=e[i-1],o=[0,0],a=_h(t,n,D.unit(),!1,Number.NaN,2,o),h=[0,0],m=_h(t,r,D.unit(),!1,Number.NaN,2,h),u=[];for(let s=0;s<a;s++)for(let a=0;a<m;a++){const m=o[s],l=h[a],c=(s,o)=>{const a=[];a.length=i-2;const h=()=>{let t=0;for(let s=1,n=i-1;s<n;s++){t+=f.distance(e[s-1],e[s]);const i=t;a[s-1]=i}t+=f.distance(e[i-2],e[i-1]);for(let e=1,s=i-1;e<s;e++)a[e-1]/=t};let u=!1,c=!1;{const e=new ol;m<=l?(t.queryCut(m,l,e,!0),s.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())):(t.queryCut(l,m,e,!0),s.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())),n.equals(s)&&(u=!0),r.equals(o)&&(c=!0)}h();let d=Number.MAX_VALUE;const g=s.clone(),_=o.clone();for(let t=0;t<5;t++){d=Ih(!0,!1,n,g,_,r,u,c,a,i-2,e,i)}for(let t=0;t<30;t++){const t=g.clone();_.clone();const s=Ih(!0,!0,n,g,_,r,u,c,a,i-2,e,i);if(d<=s&&t.equals(g)&&t.equals(_))break;d=s}h();let p=!1,x=Number.EPSILON;const y=s.clone(),P=o.clone();for(let t=0;t<30;t++){const t=y.clone();P.clone();const s=Ih(p,!0,n,y,P,r,u,c,a,i-2,e,i);if(x<=s&&t.equals(y)&&t.equals(P))break;p=!0,x=s}return x<d?(s.assign(y),o.assign(P)):(s.assign(g),o.assign(_),x=d),x},d=new f,g=new f,_=[c(d,g),f.distance(n,d)+f.distance(d,g)+f.distance(g,r),d.x,d.y,g.x,g.y];u.splice(u.length,0,..._)}let l=u[0],c=u[1],d=0;for(let s=6;s<u.length;s+=6)u[s]<l&&(l=u[s],c=u[s+1],d=s);let g=d;for(let s=0;s<u.length;s+=6)s!==d&&u[s+1]<c&&Math.abs(l-u[s])<10*l&&(c=u[s+1],g=s);t.construct(n,new f(u[g+2],u[g+3]),new f(u[g+4],u[g+5]),r)}function yh(t,e,s=!1){const i=x(f,4);t.queryControlPoints(i);const n=x(un,4);let r,o,a;ba(i,n,!0);const h=n[3].x.isZero(),m=n[3].y.isZero();if(h||m)if(h&&!m){if(n[2].x.isZero())return 0;r=n[1].x.div(n[2].x).negate(),o=n[2].y.div(n[3].y),a=n[1].y.div(n[3].y)}else{if(h||!m)return 0;if(n[2].y.isZero())return 0;r=n[1].y.div(n[2].y).negate(),o=n[2].x.div(n[3].x),a=n[1].x.div(n[3].x)}else{n[2].x.divThis(n[3].x),n[1].x.divThis(n[3].x),n[2].y.divThis(n[3].y),n[1].y.divThis(n[3].y);const t=n[2].x.sub(n[2].y);if(t.isZero())return 0;r=n[1].x.sub(n[1].y).div(t).negate(),o=n[2].x.clone(),a=n[1].x.clone()}if(!s&&r.abs().value()>2)return 0;const u=[0,0],l=t.getStartXY().equals(t.getEndXY()),c=Li(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),D.unit(),l,u);if(0===c)return 0;if(u[0]>=0&&u[0]<=1){const t=r.toDouble()-u[0];if(s||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=S(e[0],e[0]=e[1])),2}if(2===c&&u[1]>=0&&u[1]<=1){const t=r.toDouble()-u[1];if(s||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=S(e[0],e[0]=e[1])),2}return 0}function Ph(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=x(V,2);let a=Ui(r,n,i,new D(0,1),!1,o);a<0&&(a=0);let h=0;for(let m=0;m<a;m++)G(o[m].value(),0,1)||(s[h].setE(o[m]),h++);return h}function vh(t,e){e[0].set(0);let i=1;const n=x(V,4);va(t,n,!0);const r=x(V,4);Ca(t,r,!0);{const t=n[3].mul(3),s=n[2].mul(2),r=n[1].clone(),o=x(V,2);let a=Ui(t,s,r,new D(0,1),!1,o);a<0&&(a=0);for(let n=0;n<a;n++)G(o[n].value(),0,1)||(e[i]=o[n],i++)}{const t=r[3].mul(3),s=r[2].mul(2),n=r[1].clone(),o=x(V,2);let a=Ui(t,s,n,new D(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)G(o[r].value(),0,1)||(e[i]=o[r],i++)}if(i+=Ph(n,r,e.slice(i)),e[i].set(1),i++,i>2){M(e,0,i,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let s=0;const n=e[0].clone();let r=0;const o=fh(t)*st(),a=new f;Wa(t,e[0].value(),a);for(let h=1;h<i;h++){const i=new f;if(Wa(t,e[h].value(),i),e[h].eq(n)||i.isEqualPoint2D(a,o)){if(0!==s){if(0===e[h].eps())n.setE(e[h]),r=0;else if(0!==r){const t=C(1/e[h].eps()),s=1/r,i=t+s;n.set((e[h].value()*t+n.value()*s)/i),r=1/i,n.setError(Math.sqrt(r))}e[s].setE(n),Wa(t,n.value(),a)}}else s++,e[s].setE(e[h]),n.setE(e[h]),Wa(t,n.value(),a),r=C(e[h].eps())}s++,i=s}return 1===i&&(i=2,e[1].set(1)),s(0===e[0].value()),s(1===e[i-1].value()),i}function Ch(t,e,s,i,n){const r=x(V,4),o=x(V,3),a=new D(0,1);let h=0;if(e){if(Ca(t,r,!1),h=Oi(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new f;Ua(t,o[m].value(),e),i[m]=e.x}}else if(va(t,r,!1),h=Oi(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new f;Ua(t,o[m].value(),e),i[m]=e.y}if(n)for(let m=0;m<h;m++)n[m]=o[m].value();else i&&M(i,0,h,U);return h}function bh(t,e,s){s.setEmpty();const i=[];i.push(new D(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Ds;if(ch(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(D.construct(r.vmin,t)),i.push(D.construct(t,r.vmax))}}}}function Eh(t,e,s){s.length=0;{const e=new V;Xa(t,e);const i=new Ns;if($a(t,e,i),i.isZero())return e.isZero()||e.eq(new V(1))?0:(s.push(e.value()),1)}const i=x(V,4);ya(t,i,!0);const n=x(V,4);Pa(t,n,!0);const r=x(V,6),o=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),a=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));r[0]=n[1].mulE(n[1]).mulE(o).addE(i[1].mulE(i[1]).mulE(a)).addE(i[1].mulE(n[1]).mulE(h).mul(2)).mul(6),r[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const m=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(m).mul(156),l=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(c).addE(n[1].mulE(n[3]).mulE(l)).mul(72),g=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),_=i[2].mulE(n[2]).mulE(g).mul(120),p=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),f=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(p).mul(36);r[2]=u.addE(d).addE(_).addE(f);const y=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),P=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),v=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),C=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);r[3]=y.addE(P).addE(v).addE(C),r[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),r[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=x(V,5),E=Qi(r,5,new D(0,1),!1,b,5);if(E>0){let i=Math.abs(t.getCurvature(0)),n=0;const r=Math.abs(t.getCurvature(1));(r>i||!Number.isFinite(r))&&(n=1);for(let e=0;e<E;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!G(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}return 0}class Dh{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ea(this.b,e,!1):0}getError(t){return 0}}function Sh(t,e,i,n,r,o,a){for(;;){const h=f.distance(e[0],e[3]),m=f.distance(e[0],e[1])+f.distance(e[1],e[2])+f.distance(e[2],e[3]);if(m-h<=n+i*m)return t+j(h,m,.5);const u=t=>La(e,1,t).length();if(0===o){s(a<8);let h=u(0),l=u(1);r[0]+=2,h>l&&(l=S(h,h=l),e[3]=S(e[0],e[0]=e[3]),e[2]=S(e[1],e[1]=e[2]));let c=h/(h+l),d=1,g=m;for(;c<1/32&&g>=32*(n+i*g);){d/=4;const t=u(d);r[0]++,c=h/(t+h);const s=new f;if(Ua(e,.5*d,s),g=f.distance(s,e[0]),g<=n){const t=new f;Ua(e,d,t),g+=f.distance(t,s)}}if(1!==d){const s=x(f,4);ja(e,d,e,s),t=Sh(t,s,i,n,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=Vn(l,u,0,1),d=16;r[0]+=d;const g=Vn(d,u,0,1);let _=Math.abs(c-g)>n+i*m;if(!_)return t+g;if(o<3){const s=x(f,4);ja(e,.5,e,s),t=Sh(t,s,i,n,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const y=Vn(p,u,0,1);if(_=Math.abs(g-y)>n+i*m,!_)return t+y;const P=64;r[0]+=P;const v=Vn(P,u,0,1);if(_=Math.abs(y-v)>n+i*m,!_)return t+v;const C=128;r[0]+=C;const b=Vn(C,u,0,1);return _=Math.abs(v-b)>n+i*m,t+b}}function wh(t,e,s,i,n){if(s===e)return 0;const r=x(f,4);t.queryControlPoints(r);const o=x(f,4);Za(r,e,s,o);return Sh(0,o,i,n,[0],0,0)}function Ah(t,e,s,i,n){let r=!0;const o=Bn(5,e,s,i,n,(e=>{const s=Va(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));r=!1;const a=Bn(5,e,s,i,n,(e=>{const s=Va(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));return new f(o,a)}function Th(t,e,s,i,n,r,o,a,h){const m=x(f,4);t.queryControlPoints(m);const u=x(f,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return s&&(s.length=0,s.push(m[0]),s.push(m[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=S(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=S(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[3]),h&&(s[1]=S(s[0],s[0]=s[1]))),!0)}function Ih(t,e,s,i,n,r,o,a,h,m,u,l){let c=0,d=0,g=0,_=0,p=0,f=0,x=0;for(let v=1,b=l-1;v<b;v++){let e,o,a,m,l,P,b=-1,E=h[v-1];t&&(v>2?(E=y(2*h[v-2]-h[v-3],0,1),h[v-1]=E):2===v&&E<=h[0]&&(E=h[0]));for(let c=0;c<11&&(e=h[v-1],o=e*e,a=o*e,m=1-e,l=m*m,P=l*m,t)&&!(Math.abs(e-b)<1e-12)&&10!==c;c++){const t=s.x-2*i.x+n.x,a=s.x-3*i.x+3*n.x-r.x,m=s.y-2*i.y+n.y,c=s.y-3*i.y+3*n.y-r.y,d=s.x-i.x-2*t*e+a*o,g=-u[v].x+s.x*P+e*(3*i.x*l+e*(3*n.x-3*n.x*e+r.x*e)),_=s.y-i.y-2*m*e+c*o,p=-u[v].y+s.y*P+e*(3*i.y*l+e*(3*n.y-3*n.y*e+r.y*e));b=e;const f=e- -6*(d*g+_*p)/(6*(3*C(d)-(-2*t+2*a*e)*g)+6*(3*C(_)-(-2*m+2*c*e)*p));h[v-1]=y(f,v>1?h[v-2]:0,1)}c+=3*o*l*l,d+=3*a*P,g+=3*o*o*l;const D=-(P*s.x+a*r.x-u[v].x);_+=D*e*l,p+=D*o*m;const S=-(P*s.y+a*r.y-u[v].y);f+=S*e*l,x+=S*o*m}if(e){const t=c*g-d*d;Math.abs(t)>=1e-12*(Math.abs(c*g)+Math.abs(d*d))+1e-10?(o||(i.x=(_*g-p*d)/t,i.y=(f*g-x*d)/t),a||(n.x=(c*p-d*_)/t,n.y=(c*x-d*f)/t)):(Q(s,r,.3,i),Q(s,r,.6,n))}let P=0;for(let y=1,v=l-1;y<v;y++){const t=h[y-1],e=1-t,o=s.mul(yt(e)),a=i.mul(3*t*e*e),m=n.mul(3*t*t*e),l=r.mul(yt(t));P+=o.add(a).add(m).add(l).sub(u[y]).sqrLength()}return P}function Nh(t,e,s,i){const n=t.getPathStart(e),r=t.getPathEnd(e);if(r-n<3)return;const o=2*n,a=f.getNAN();s.queryPoint2D(o,a);const h=a.x,m=a.y,u=f.getNAN();s.queryPoint2D(o+2,u);const l=f.getNAN();for(let c=o+4,d=2*r;c<d;c+=2)s.queryPoint2D(c,l),i.pe((l.x-a.x)*(u.y-m)),a.setCoordsPoint2D(u),u.setCoordsPoint2D(l);i.pe((h-a.x)*(u.y-m))}function qh(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var Mh=Vt;class Yh{static toSegType(t){let e=0;switch(t){case n.enumLine:e=1;break;case n.enumBezier:e=2;break;case n.enumEllipticArc:e=4;break;case n.enumRationalBezier2:e=8;break;case n.enumBezier2:e=16;break;default:a("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Xh extends bs{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?n.enumPolygon:n.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){s(this.m_bPolygon);const i=this.getPathIndexFromPointIndex(t),n=this.getPathStart(i);if(n===t)return;const r=this.getPathEnd(i);(t>=r||t<n)&&e("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=Mh.getComponentCount(s);this.m_vertexAttributes.get(e).rotate(n*i,t*i,r*i)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(n,t,r),this.m_curveData.m_segmentParamIndex.rotate(n,t,r))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new ee(t),s=new X(0),i=new X(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Ti({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();Nh(this,r,n,i),qh(this,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),Nh(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return s(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Xh.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),r=Xi(s);for(let t=0;t<r;t++){const s=this.m_curveData.m_segmentParams.read(i+t),r=e.m_curveData.m_segmentParams.read(n+t);if(!v(s,r))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=Ut(1,0),this.m_pathFlags=Ot(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Yh),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new X(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new X(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return s(0),0}calculatePathLength3D(t,e){return s(0),0}copyTo(t){d(t.getGeometryType())||e(""),this!==t&&super.copyTo(t)}swap(t){s(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,s){this===t&&e("Multi_path_impl::add");for(let e=0,i=t.getPathCount();e<i;e++)this.addPath(t,e,!s)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addSegmentsFromPath(t,s,n,r,o){if(this===t&&e("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=t.getPathCount()-1),(s>=t.getPathCount()||n<0||r<0||n+r>t.getSegmentCountPath(s))&&i("add_segments_from_path"),0===r)return;const a=t.getPathStart(s),h=t.isClosedPath(s)&&n+r===t.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let m=r;const u=a+n;let l=u+1;o&&(m++,l--),!o&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(u)&&(t.getXY(u).equals(this.getXY(this.m_pointCount-1))||e("add_segments_from_path: start point mismatch"));const c=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+m),this.verifyAllStreamsAfterSizeChange(),o){if(0===m)return;this.m_paths.add(this.m_pointCount);let e=t.m_pathFlags.read(s);this.m_bPolygon&&(e|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,e),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const d=h?m-1:m;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const s=this.m_description.getSemantics(e),i=Mh.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(d>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=Mh.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*c,t,d*i,i*c),h&&this.m_vertexAttributes.get(e).insertRange(i*c+d*i,t,i,i*c);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*c,t.m_vertexAttributes.get(n),i*l,d*i,!0,i,i*c)}h&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(c+d),t.m_vertexAttributes.get(n),i*a,i,!0,i,i*(c+d))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=u;s<r;s++){e+=Xi(t.m_curveData.m_segmentFlags.read(i)),i++}if(e>0){this.initSegmentData(e);let s=u,i=c-(o?0:1),n=0;for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),Xh.isNonLinearSegmentFlag(e)){n++;let r=t.m_curveData.m_segmentParamIndex.read(s);const o=Xi(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<o;e++){const e=t.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(n)}}if(h){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&e("");const s=this.getPathSize(t);if(0===s)return;const i=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=i;const e=new this.m_segmentBufferCTor;let r=!1;for(let i=0;i<s;i++,t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Xh.isNonLinearSegmentFlag(s))continue;r=!0,this.querySegment(t,e,!0),e.get().reverse();const i=this.m_curveData.m_segmentParamIndex.read(t);e.get().writeInBufferStream(this.m_curveData.m_segmentParams,i)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(i,s-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(i,s-t,1)}}const r=n?1:0;for(let e=0,a=this.m_description.getAttributeCount();e<a;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),n=Mh.getComponentCount(t);this.m_vertexAttributes.get(e).reverseRange(n*(i+r),n*(s-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const s=this.getPathCount();t<0&&(t=s-1),t>=s&&e("");const i=this.getPathStart(t),n=this.getPathSize(t);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),s=Mh.getComponentCount(t);this.m_vertexAttributes.get(e).eraseRange(s*i,s*n,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=i,s=i+n;e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Xh.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(i,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(i,n,this.m_pointCount)}for(let e=t+1;e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e-1,t-n)}if(this.m_pathFlags)for(let e=t+1;e<=s;e++){const t=this.m_pathFlags.read(e);this.m_pathFlags.write(e-1,t)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,s,i,n){this===s&&e("Multi_path_impl::insert_path");const r=this.getPathCount();if(!n&&s.hasNonLinearSegmentsPath(i))return t=this.insertPath(t,s,i,!0),this.reversePath(t),t;i>=s.getPathCount()&&e(""),t>r&&e(""),t<0&&(t=r),i<0&&(i=s.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(s.getDescription());const o=s.getPathStart(i),a=s.getPathSize(i);if(0===a)return this.insertPath2D(t,null,0,0,!0);const h=this.m_pointCount,m=s.isClosedPath(i)&&!n?1:0;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const u=t<r?this.getPathStart(t):h;for(let e=0,d=this.m_description.getAttributeCount();e<d;e++){const t=this.m_description.getSemantics(e),i=s.getDescription().getAttributeIndex(t),r=Mh.getComponentCount(t);if(i>=0&&s.m_vertexAttributes.get(i))0!==m&&this.m_vertexAttributes.get(e).insertRangeFromStream(u*r,s.m_vertexAttributes.get(i),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(e).insertRangeFromStream((u+m)*r,s.m_vertexAttributes.get(i),r*(o+m),r*(a-m),n,r,r*(h+m));else{const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(u*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let e=r;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+a)}this.m_pathFlags.add(0);for(let e=r-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=s.getPathFlagsStreamRef().read(i);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let i=0;i<a;i++){e+=Xi(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=Ot(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=Ut(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,a,h),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,a,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+e):this.m_curveData.m_segmentParams=Qt(e),t=o;let i=u,n=0;for(let e=0;e<a;e++){const e=s.m_curveData.m_segmentFlags.read(t);if(Xh.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(i,e),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const r=Xi(e);let o=s.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=s.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(e,1)}t++,i++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,s,i,n,r){const o=this.getPathCount();(t>o||i<0)&&e(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,i,n,r,2*a);else{const t=Mh.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let e=1,m=this.m_description.getAttributeCount();e<m;e++){const t=this.m_description.getSemantics(e),s=Mh.getComponentCount(t),i=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,s,i,n,r){const o=s.getImpl(),a=this.getPathCount();(t>a||i<0)&&e("");const h=n<0?o.getPointCount()-i:n;if(h>o.getPointCount()&&e(""),i>=o.getPointCount()&&e("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=i;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):m;for(let e=0,g=this.m_description.getAttributeCount();e<g;e++){const t=this.m_description.getSemantics(e),s=o.getDescription().getAttributeIndex(t),i=Mh.getComponentCount(t);if(s>=0){const s=o.getAttributeStreamRef(t);this.m_vertexAttributes.get(e).insertRangeFromStream(l*i,s,i*u,i*h,r,i,i*m)}else{const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(l*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let d=0;this.m_bPolygon&&(d|=1),this.m_pathFlags.write(t,d),this.notifyModifiedFlags(2001)}insertPoints(t,s,n,r,o,a,h){if(this===n&&e("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=n.getPathCount()-1),(t>this.getPathCount()||s>=0&&s>this.getPathSize(t)||r>=n.getPathCount()||a>n.getPathSize(r))&&i(""),!a)return;if(this.mergeVertexDescription(n.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=n.m_pathFlags.read(r);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}s<0&&(s=this.getPathSize(t));const m=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const u=this.getPathStart(t),l=u+s;a<0&&(a=n.getPathSize(r));const c=n.getPathStart(r),d=c+a;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const t=this.m_description.getSemantics(e),i=Mh.getComponentCount(t),r=n.m_description.getAttributeIndex(t);if(r<0||!n.m_vertexAttributes.get(r)){const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(i*l,s,d*i,i*m)}else this.m_vertexAttributes.get(e)?.insertRangeFromStream(i*(u+s),n.m_vertexAttributes.get(r),i*(c+o),a*i,h,i,i*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+s,1,a,m),this.m_curveData.m_segmentParamIndex.insertRange(u+s,-1,a,m),s>0&&this.isNonLinearSegment(u+s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+s-1),-1),this.m_curveData.m_segmentFlags.write(u+s-1,1),this.m_curveData.m_segmentParamIndex.write(u+s-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&i(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let i=1,m=this.m_description.getAttributeCount();i<m;i++){const t=this.m_description.getSemantics(i),s=Mh.getComponentCount(t),n=Mh.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange((h+e)*s,n,s*r,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,m=this.getPathCount();i<=m;i++)this.m_paths.write(i,this.m_paths.read(i)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl();if(t<0&&(t=this.getPathCount()),r<0&&(r=s.getPointCount()),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>s.getPointCount())&&i(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),u=m+e,l=0,c=l+r;for(let i=0,d=this.m_description.getAttributeCount();i<d;i++){const t=this.m_description.getSemantics(i),s=Mh.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=Mh.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange(s*u,e,c*s,s*h);continue}const d=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(i).insertRangeFromStream(s*(m+e),d,s*(l+n),r*s,o,s,s*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,r,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,r,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,d=this.getPathCount();i<=d;i++){const t=this.m_paths.read(i);this.m_paths.write(i,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Mh.getComponentCount(e),i=Mh.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByVal(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=Mh.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=Mh.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let s=t+1,i=n;s<=i;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&i("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&i("Multi_path.remove_point");const o=n+e;for(let i=0,a=this.m_description.getAttributeCount();i<a;i++)if(this.m_vertexAttributes.get(i)){const t=this.m_description.getSemantics(i),e=Mh.getComponentCount(t);this.m_vertexAttributes.get(i).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let i=s;i>=t+1;i--){const t=this.m_paths.read(i);this.m_paths.write(i,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)Xh.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=Xh.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new hs({x:t,y:e}))}startPath(t){this.startPathPoint(new hs({pt:t}))}startPath3D(t){this.startPathPoint(new hs({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new hs({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&e("");const s=t.getDescription();let i;if(this.m_description!==s){this.mergeVertexDescription(s);const e=new hs({vd:this.m_description});t.copyCommonAttributesTo(e),i=e}else i=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,i):(this.insertPoint(-1,-1,i),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=Ut(2),this.m_paths.write(0,0),this.m_pathFlags=Ot(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{const s=zt(),i=new hs({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=he(this.m_description,ce()),s=zt(),i=new hs({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByVal(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new Bt(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=zt(),s=new hs({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&a("");const s=this.getPathCount();if(t>s&&e(""),!this.isClosedPath(t))return;this.m_pathFlags||a("");const i=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Mh.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*r,this.m_vertexAttributes.get(t),s*n,s,!0,1,s*i)}for(let e=s;e>t;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,i),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,i)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&a(""),t>this.getPathCount()&&e(""),this.m_pathFlags||a(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&a(""),this.isEmpty())return;this.m_pathFlags||a("");let t=0;const e=this.getPathCount();for(let a=0;a<e;a++)this.isClosedPath(a)&&(this.getPathSize(a)>0?t++:this.m_pathFlags.clearBits(a,1));if(0===t)return;const s=this.hasNonLinearSegments();let i=0;const n=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let h=null,m=null;for(let a=0;a<n;++a){const e=this.getPathStart(a),n=this.getPathSize(a),u=this.isClosedPath(a);if(n>0){const a=e+i;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=Mh.getComponentCount(i);if(!o[s]){const e=Zt(i,r*(this.m_pointCount+t));o[s]=e}o[s].writeRange(a*r,n*r,this.m_vertexAttributes.get(s),e*r,!0,1),u&&o[s].writeRange((a+n)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===h){const e=this.m_pointCount+t;h=Ot(e),m=Ut(e)}h.writeRange(a,n,this.m_curveData.m_segmentFlags,e,!0,1),m.writeRange(a,n,this.m_curveData.m_segmentParamIndex,e,!0,1),u&&(h.write(a+n,1),m.write(a+n,-1))}}this.m_paths.write(a,e+i),u&&(this.m_pathFlags.clearBits(a,1),++i)}this.m_paths.write(n,this.m_pointCount+t),this.m_pathFlags.clearBits(n,1);for(let a=0;a<r;a++)this.m_vertexAttributes.get(a)&&this.m_vertexAttributes.set(a,o[a]);s&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(t);if(this.m_pathFlags.write(t,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==s&&(this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,s){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),s.getEndXY().equals(this.getXY(this.getPathStart(t)))||e("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(s,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(s.getDescription());const i=s.getStartXY(),r=this.getPathEnd(t)-1;i.equals(this.getXY(r))||e("close_path_with_segment: start point mismatch");const o=s.getGeometryType();if(o===n.enumLine)return void this.closePathWithLine(t);{const t=Yi(s);this.initSegmentData(t);const e=Yh.toSegType(o),i=this.m_curveData.m_segmentFlags.read(r);if(i!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);s.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const i=this.m_pathFlags.read(t);this.m_pathFlags.write(t,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(t){return s(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Xh.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof qt)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=zt(),n=new hs({vd:s,attribBuffer:i,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,n),0===r?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,s){if(t.isClosed()||e("add_path_from_closedSegment: segment must be closed"),s){const e=t.getReversed(),s=new hs;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new hs;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,s){const i=t.getDescription();this.mergeVertexDescription(i);const r=zt(),o=new hs({vd:i,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===n.enumLine)(s||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let i=!1;if((s||this.isEmptyImpl())&&(i=!0),!i){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||e("add_segment: start point mismatch")}if(i&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=zt(),e=new hs({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const n=Yi(t);this.initSegmentData(n),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=n;const r=Yh.toSegType(a);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,s,i,n){for(let a=t;a<i-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,s,i,n);if(0!==o)for(let e=1;e<r;e++){const r=this.m_description.getSemantics(e);this.interpolateAttributesSemanticsImpl(r,t,s,i,n,o)}}interpolateAttributesSemantics(t,s,i,n,r){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===Mh.getInterpolation(t)&&e("angular interpolation");for(let a=s;a<n-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,i,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,s,i,n,r,o)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(t,s,i,n){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===Mh.getInterpolation(t)&&e("angular interpolation");const r=this.calculatePathSubLength2D(s,i,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,s,i,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,n,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(i)+n,m=Mh.getComponentCount(t),u=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new Array(Mh.maxComponentCount());A(c,u,0,0,m);let d=0;const g=Mh.getDefaultValue(t),_=Mh.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,m),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;d+=e.calculateLength2D();T(_,u,l,c,0,m,d/r,g),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,m)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,n){const r=this.querySegmentIterator(),o=Mh.getInterpolation(t),a=this.getPathStart(e)+s,h=this.getPathStart(e)+i;if(h===a)return;const m=Mh.getComponentCount(t),u=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new X(0);r.resetToVertex(a,e),r.setCirculator(this.isClosedPath(e));const d=Mh.getDefaultValue(t),g=new Array(Mh.maxComponentCount());A(g,u,0,0,m);const _=0===n;let p=.5;do{const e=r.nextSegment();if(this.setAttributeFromArray(t,r.getStartPointIndex(),g,m),!_){const t=e.calculateLength2D();c.pe(t),p=c.getResult()/n}T(o,u,l,g,0,m,p,d)}while(r.getEndPointIndex()!==h)}querySegment(t,s,i){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&e("get_segment"),this.getSegmentFromPath(n,r,s,i)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const s=this.getPathIndexFromPointIndex(t),i=t-this.getPathStart(s);return i>=this.getSegmentCountPath(s)&&e("get_segment"),this.getSegmentTypeFromPath(s,i)}getSegmentFromPath(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(n)),o){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:a("")}const h=s.get();let m,u=null;i?(u=le(),h.assignVertexDescription(u)):h.assignVertexDescription(this.m_description),m=n===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):n+1;Vs(h,this.getXY(n));if(ks(h,this.getXY(m)),!i)for(let a=1,l=this.m_description.getAttributeCount();a<l;a++){const t=this.m_description.getSemantics(a),e=Mh.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,n,s);h.setStartAttribute(t,s,e);const i=this.getAttributeAsDbl(t,m,s);h.setEndAttribute(t,s,i)}}if(Xh.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(n);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++){if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);Mi(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,s,i,n=!1){const r={iSegment:-1},o=n?r:{iSegment:-1,tSegment:0};if(i.setEmpty(),this.isEmpty())return r;if((t<0||t>=this.getPathCount())&&e("query_point_along_path"),s<0)return r;const a=this.getPathSize(t);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(t),i),o.tSegment=0,r.iSegment=this.getPathStart(t),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),m=new X(0);for(;h.hasNextSegment();){const t=h.nextSegment(),e=t.calculateLength2D(),n=m.getResult();if(m.add(e),m.getResult()>=s){let a=s-n;a>e&&(a=e);const m=t.lengthToT(a);return t.queryCoord(m,i),o.tSegment=m,r.iSegment=h.getStartPointIndex(),r}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,i),o.tSegment=1,r.iSegment=this.getPathEnd(t)-1,r}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,i),this.getPathSize(t)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(t)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(t),r)}}queryPointsAlongPath(t,s,i,n,r,o){{let t=0;for(let a=0;a<s;++a)n&&n[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),t>i[a]&&e("query_points_along"),t=i[a]}const a=this.getPathSize(t);if(0===s||0===a)return 0;if(1===a){const e=this.getPathStart(t);return n&&this.getPointByVal(e,n[0]),o&&(o[0]=0),r&&(r[0]=e),1}const h=this.getPathStart(t),m=new X(0),u=this.querySegmentIteratorAtVertex(h);let l=0,c=0,d=i[l];for(;u.hasNextSegment();){const t=u.nextSegment(),e=t.calculateLength2D(),a=m.getResult();for(m.add(e);m.getResult()>=d;){let h=d-a;h>e&&(h=e);const m=t.lengthToT(h);if(n&&t.queryCoord(m,n[c]),o&&(o[c]=m),r&&(r[c]=u.getStartPointIndex()),c++,l++,d=i[l],l===s)return c}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;n&&this.getPointByVal(e,n[c]),o&&(o[c]=s),r&&(r[c]=e),c++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;n&&this.getPointByVal(e+1,n[c]),o&&(o[c]=s),r&&(r[c]=e),c++}return c}queryPointsAlong(t,s,i,n,r){{let o=0;for(let a=0;a<t;++a)i&&i[a].setEmpty(),n&&(n[a]=-1),r&&(r[a]=0),o>s[a]&&e("query_points_along"),o=s[a]}if(0===t)return 0;const o=new X(0),a=this.querySegmentIterator();let h=-1,m=0,u=0,l=s[m];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const e=a.nextSegment(),c=e.calculateLength2D(),d=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-d;o>c&&(o=c);const h=e.lengthToT(o);if(i&&e.queryCoord(h,i[u]),r&&(r[u]=h),n&&(n[u]=a.getStartPointIndex()),u++,m++,l=s[m],m===t)return u}}if(h<0)return 0;if(this.isClosedPath(h)){const t=this.getPathStart(h),e=0;i&&this.getPointByVal(t,i[u]),r&&(r[u]=e),n&&(n[u]=t),u++}else if(this.getPathSize(h)>1){const t=this.getPathEnd(h)-2,e=1;i&&this.getPointByVal(t+1,i[u]),r&&(r[u]=e),n&&(n[u]=t),u++}return u}querySegmentIterator(){return new Ti({parent:this})}querySegmentIteratorAtVertex(t){return new Ti({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,i,n){if(i instanceof cs&&s(0,"not implemented for Envelope"),i instanceof kt&&s(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&e(""),this.isEmpty())return void i.setEmpty();const r=this.getAttributeStreamRef(0),o=qt.constructEmpty();o.setEmpty();for(let e=2*this.getPathStart(t),a=2*this.getPathEnd(t);e<a;){const t=a-e;s(!(1&t)),o.mergePointsInterleaved(r,e/2,t/2),e+=t}if(i.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(t)){const e=this.querySegmentIterator();if(e.resetToPath(t),e.nextPath())for(;e.hasNextSegment();){const t=e.nextCurve();if(!t)break;{const e=qt.constructEmpty();n?t.queryEnvelope(e):t.queryLooseEnvelope(e),i.mergeEnvelope2D(e)}}else s(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=Xi(4)*this.m_curveData.m_arcCount+Xi(2)*this.m_curveData.m_bezierCount+Xi(8)*this.m_curveData.m_rbezier2Count+Xi(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let i=0,n=this.getPointCount();i<n;i++){const e=this.m_curveData.m_segmentFlags.read(i);if(Xh.isNonLinearSegmentFlag(e)){t+=Xi(e)}}const e=Qt(t);let s=0;for(let i=0,n=this.getPointCount();i<n;i++){const t=this.m_curveData.m_segmentFlags.read(i);if(Xh.isNonLinearSegmentFlag(t)){let n=this.m_curveData.m_segmentParamIndex.read(i);this.m_curveData.m_segmentParamIndex.write(i,s);const r=Xi(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){s(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=Ut(0),this.m_pathFlags=Ot(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=Ut(0),this.m_pathFlags=Ot(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Fh(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new Yh),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,i){if(i>=0&&i<e){if(s>=t.read(i)){if(s<t.read(i+1))return i;i++}else i--;if(i>=0&&i<e&&s>=t.read(i)&&s<t.read(i+1))return i}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;g("")}let n=0,r=e-1;for(;r>n;){const e=n+(r-n>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(t){s(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),i=this.getPathEnd(t),n=this.getPathStart(t);let r=-1;const o=new f;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let s=n+0;s<i;s++){const t=e.readPoint2D(2*s);-1===o.compare(t)&&(r=s,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(t,s){if(s>=this.getPathCount()&&e("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const i=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let e,n;return s<0?(e=0,n=this.m_pointCount):(e=this.getPathStart(s),n=this.getPathEnd(s)),i.applyTransformation(t,2*e,n-e),void this.notifyModifiedFlags(2001)}const n=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const e=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=i.readPoint2D(2*e);if(!this.hasNonLinearSegmentsPath(o)){i.applyTransformation(t,2*e,r-e);continue}const m=f.getNAN();for(let s=e;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&i.writePoint2D(2*e,h),this.getSegmentBuffer(s,n,!0),n.get().applyTransformation(t);const m=this.m_curveData.m_segmentParamIndex.read(s);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,m),i.writePoint2D(2*s,n.get().getStartXY()),o&&i.writePoint2D(2*e,n.get().getEndXY());continue}const o=2*s;i.queryPoint2D(o,m),t.transformInPlace(m),i.writePoint2D(o,m)}if(o===s)break}while(++o<r);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getPathStart(s)+i;(r<n||n<0||r>this.getPointCount()-1)&&o("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(n,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===r)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===r)break}while(a.nextPath());return h}calculatePathSubLength2D(t,s,i){const n=this.getPathStart(t)+s,r=this.getPathStart(t)+i;(n<0||r>this.getPointCount()-1)&&o("");const a=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||e("cannot iterate across an open path"),a.setCirculator(!0)),n===r)return 0;let h=0,m=0;a.resetToVertex(n,t);do{m+=h;h=a.nextSegment().calculateLength2D()}while(a.getStartPointIndex()!==r);return m}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=qt.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,s){this===t&&e("Multi_path_impl::add");let i=this.getPathCount();for(let e=0,n=t.getPathCount();e<n;e++)this.addPath(t,e,!s),this.openPathAndDuplicateStartVertex(i),i++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,s,i){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&e("getSegmentBuffer"),this.getSegmentFromPath(n,r,s,i)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,i=this.getSegmentFlagsStreamRef();let r=1;switch(i&&(r=31&i.read(s)),r){case 1:return n.enumLine;case 2:return n.enumBezier;case 4:return n.enumEllipticArc;case 8:return n.enumRationalBezier2;case 16:return n.enumBezier2;default:a("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let e=!1;for(let s=0,i=this.getPathCount();s<i;s++){const i=this.getPathStart(s),n=this.getPathEnd(s),r=n-i;for(let s=i;s<n;s++){const n=31&this.m_curveData.m_segmentFlags.read(s);if(1===n)continue;2!==n&&t("ensure_xy_monotone_segments");const o=(s-i+1)%r+i,a=this.m_curveData.m_segmentParamIndex.read(s),h=x(f,4);h[0]=this.getXY(s),h[3]=this.getXY(o),h[1].x=this.m_curveData.m_segmentParams.read(a),h[1].y=this.m_curveData.m_segmentParams.read(a+1),h[2].x=this.m_curveData.m_segmentParams.read(a+2),h[2].y=this.m_curveData.m_segmentParams.read(a+3),Ga(h)&&(e=!0,this.m_curveData.m_segmentParams.write(a,h[1].x),this.m_curveData.m_segmentParams.write(a+1,h[1].y),this.m_curveData.m_segmentParams.write(a+2,h[2].x),this.m_curveData.m_segmentParams.write(a+3,h[2].y))}}return e&&this.notifyModifiedFlags(2001),e}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ii),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=is(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ii),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=es(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Xh.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Yh),Xh.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Yh),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Yh);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=Ot(e,1),this.m_curveData.m_segmentParamIndex=Ut(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=Qt(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Yh),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=ct(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,i,n){(t<0||t>=this.getPointCount())&&e("Multi_path_impl.replace_segment"),s(i.isCurve());const r=this.getPathIndexFromPointIndex(t),o=this.getPathStart(r),a=(t-o+1)%this.getPathSize(r)+o;{const e=this.getXY(t),n=this.getXY(a),r=!e.isEqualPoint2D(i.getStartXY())||!n.isEqualPoint2D(i.getEndXY());s(!r)}const h=i.getDescription();this.mergeVertexDescription(h);const m=new Array(32),u=new hs({vd:h,attribBuffer:m,initDefaultValues:!1}),l=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),c=Xi(l),d=Yi(i);let g,_=!1;c>=d?(s(null!==this.m_curveData),_=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(d),_=!1,g=this.m_curveData.m_curveParamWritePoint);const p=i.getGeometryType(),f=Yh.toSegType(p);n||(i.queryStart(u),this.setPointByVal(t,u),i.queryEnd(u),this.setPointByVal(a,u)),this.m_curveData.m_segmentParamIndex.write(t,1!==f?g:-1),this.m_curveData.m_segmentFlags.write(t,f),1!==f&&i.writeInBufferStream(this.m_curveData.m_segmentParams,g),_||(this.m_curveData.m_curveParamWritePoint+=d),l!==f&&(this.incCurveType(l,-1),this.incCurveType(f,1),this.modifyCurveCounter(1===l?1:-1))}setAttributeImpl(t,s,i){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(s<0||s>1)&&e("");const t=new k,n=0===s?i:0,r=0===s?0:1;t.setShiftCoords(n,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,s,i)}}Xh.st_totalCurveCount=0;class Fh{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new qt(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e);return this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=qt.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Rh extends Xh{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=ol):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ol,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ol):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ol,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=ol,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):a("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=ol)}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Rh.type}getDimension(){return 1}createInstance(){return new Rh({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Rh.type=n.enumPolyline;var Lh=n;function zh(e,s){if(e.isEmpty())return!1;const i=e.getGeometryType();if(i===Lh.enumPolygon)return 0!==e.calculateArea2D();if(i===Lh.enumPolyline)return Bh(e.getImpl(),s,!0).bNotEmpty;if(i===Lh.enumEnvelope)return!0;if(m(i))return!!e.isClosed();if(l(i))return!1;if(i===Lh.enumGeometryCollection){const t=e;for(let e=0,i=t.getGeometryCount();e<i;e++)if(zh(t.getGeometry(e),s))return!0;return!1}t("")}function Vh(e,s){const i=e.getGeometryType();if(i===Lh.enumPolygon){const t=new Rh({vd:e.getDescription()});return e.isEmpty()||e.copyToUnchecked(t),t}if(i===Lh.enumPolyline)return Bh(e.getImpl(),s,!1).boundary;if(i===Lh.enumEnvelope){const t=new Rh({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(m(i)){const t=new Es({vd:e.getDescription()});if(!e.isEmpty()&&!e.isClosed()){const s=new hs;t.reserve(2),e.queryStart(s),t.add(s),e.queryEnd(s),t.add(s)}return t}if(i===Lh.enumGeometryCollection){const t=e;let i=null;for(let n=0,r=t.getGeometryCount();n<r;n++){const r=Vh(t.getGeometry(n),s);if(null!==r){null===i&&(i=e.createInstance());const t=r;i.addGeometry(t)}}return i}if(l(i))return new hs({vd:e.getDescription()});t("")}function Bh(t,e,s){const i=!1,n=t;let r=null;if(s||(r=new Es({vd:n.getDescription()})),!n.isEmpty()){const t=new Jt(0);for(let e=0,s=n.getPathCount();e<s;e++){if(n.getPathSize(e)>0&&!n.isClosedPathInXYPlane(e)){const s=n.getPathStart(e);t.add(s);const i=n.getPathEnd(e)-1;t.add(i)}}if(t.size()>0){const e=new ge,i=n.getAttributeStreamRef(0),o={userSort(t,e,s){const n=f.getNAN(),r=f.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,r),n.compare(r))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),o);let a=i.readPoint2D(2*t.read(0)),h=0,m=1;const u=new hs;for(let n=1,r=t.size();n<r;n++){const e=i.readPoint2D(2*t.read(n));if(e.isEqualPoint2D(a))t.read(h)>t.read(n)?(t.write(h,N()),h=n):t.write(n,N()),m++;else{if(1&m){if(s)return{bNotEmpty:!0,boundary:new Es({})}}else t.write(h,N());a=e,h=n,m=1}}if(1&m){if(s)return{bNotEmpty:!0,boundary:new Es({})}}else t.write(h,N());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==N();e++)n.getPointByVal(t.read(e),u),r.add(u)}}}return s?{bNotEmpty:i,boundary:new Es({})}:{bNotEmpty:i,boundary:r}}const kh=it/180,Gh=180/it;function Hh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=vt(e,360),e<0&&(e+=360),e)}function Wh(t){let e=t;return e=Hh(e),e>180&&(e-=360),e}function jh(t){return t*kh}function Zh(t){return t*Gh}function Uh(t){const e=ht();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=vt(s,e),s<0&&(s+=e),s)}function Oh(t){const e=nt();let s=t;return s>-e&&s<=e||(s=Uh(s),s>e&&(s-=ht())),s}function Qh(t,e){return Wh(e-t)}var Kh=Vt;class $h extends oi{constructor(t){if(void 0===t||F(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new f(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new f(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new f(0,0),this.m_interior=new f(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new f(0,0),this.m_interior=new f(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new f(0,0),this.m_interior=new f(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=f.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=f.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return km(this,t,e,1),this}constructLineCircularArc(t,e){return km(this,t,e,0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new f(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(i),a=Math.sin(i);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new k;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new k;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return uu(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const n=f.calculateCircleCenterFromThreePoints(t,e,s);if(!n.isFinite()||!Number.isFinite(f.distance(t,n))){const i=f.distance(t,e),n=f.distance(t,s);this.constructLineCircularArc(t,i>=n?e:s)}return this.constructCircleCenterAndPoint(n,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new V(t.x),n=new V(e.x),r=new V(s.x),o=new V(t.y),a=new V(e.y),h=new V(s.y),m=new V(.5),u=n.subE(i),l=a.subE(o),c=r.subE(i),d=h.subE(o),g=u.mulE(d).subThisE(l.mulE(c));if(g.scaleError(10),g.isZero()){if(!u.isZero()||!l.isZero())return km(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const _=u.sqr().addThisE(l.sqr()).mulThisE(m),p=c.sqr().addThisE(d.sqr()).mulThisE(m),x=_.mulE(d).subThisE(p.mulE(l)),y=u.mulE(p).subThisE(c.mulE(_));x.divThisE(g),y.divThisE(g);const P=x.sqr().addThisE(y.sqr());P.sqrtThis();const v=x.addE(i),C=y.addE(o);let b=t.x-v.value(),E=t.y-C.value();const D=Math.atan2(E,b);b=e.x-v.value(),E=e.y-C.value();const S=Math.atan2(E,b);b=s.x-v.value(),E=s.y-C.value();const w=Math.atan2(E,b);let A=w-2*nt();for(;A<D;)A+=2*nt();let T=S-2*nt();for(;T<A;)T+=2*nt();let I=w+2*nt();for(;I>D;)I-=2*nt();let N,q=S+2*nt();for(;q>I;)q-=2*nt();N=T-D<D-q?T-D:q-D;const M=new f(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,P.value(),1,0,Math.abs(N)>nt(),N>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return Bm(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return Bm(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Oh(r),a=Math.cos(o),h=Math.sin(o),m=new f(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=f.getNAN(),l=Oh(i);u.x=m.x*Math.cos(l),u.y=m.y*Math.sin(l),u.rotateDirect(a,h),u.addThis(s);const c=Pt(n,ht());let d=c;Math.abs(d)===ht()&&(d=0);const g=f.getNAN();return g.x=m.x*Math.cos(l+d),g.y=m.y*Math.sin(l+d),g.rotateDirect(a,h),g.addThis(s),this.constructEllipticArcEndPointsCenter(u,g,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>nt(),c>0,s)}constructEllipticArcAsNURB(t,s,i,n){(n>=1||n<0)&&e("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||e("construct_elliptic_arc_as_NURB: control_point");return au([t,s,i],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,cu(this),this.afterCompletedModification(),t!==this&&$s(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!Fs(this,[t])&&Gm(this)}isDegenerateToLine(){return Gm(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return f.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!Jm(this)}isMajor(){return eu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return n.enumEllipticArc}queryEnvelope(e){if(4===e.m_EnvelopeType){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=qt.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=Kh.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else 2===e.m_EnvelopeType?fu(this,D.unit(),e):t("3d not impl")}applyTransformation(t){Zm(this,t,!1)}createInstance(){return new $h}calculateLength2D(){return Xm(this,0,1)}queryCoord2D(t,e){if(Gm(this))mi(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(f.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(f.construct(this.m_XEnd,this.m_YEnd));else{const s=Nm(this,t),i=new f(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){Cm(this,t,e)}getCoordX(t){const e=new f;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new f;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();let r=0===t&&1===e;if(r&&!i)return void this.copyTo(n);const o=f.getNAN();this.queryCoord2D(t,o);const a=f.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,Bs(n,o.x,o.y),Gs(n,a.x,a.y),r)return void Om(n,Fm(this));n.m_startAngle=Nm(this,t),n.m_sweepAngle=Nm(this,e)-n.m_startAngle,n.m_startAngle=Sm(n.m_startAngle),tu(n,Math.abs(n.m_sweepAngle)>nt()),n.assignVertexDescription(this.m_description),cu(n),Tm(n);const h=this.m_description.getAttributeCount();if(h>1){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),i=Kh.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),i=Kh.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){vu(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new f;this.queryCoord2D(t,n);const r=new f;this.queryCoord2D(e,r),i||(n.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,Bs(s,n.x,n.y),Gs(s,r.x,r.y),i?Om(s,Fm(this)):(s.m_startAngle=Nm(this,t),s.m_sweepAngle=Nm(this,e)-s.m_startAngle,s.m_startAngle=Sm(s.m_startAngle),tu(s,Math.abs(s.m_sweepAngle)>Math.PI),cu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Lm(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=Kh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,Kh.getDefaultValue(e))}getClosestCoordinate(t,e){return xu(this,t,D.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return xu(this,t,e,!1)}getYMonotonicParts(t,i=!1){t.length<2&&e("");const n=this.getSemiAxes(),r=Math.atan2(n.y*this.m_cosr,n.x*this.m_sinr),o=r+nt(),a=new Array(3);let h=0;if(a[0]=Im(this,r),a[0]>0&&a[0]<1&&h++,a[1]=Im(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,s(t.length>=h);let m=0;for(let e=0;e<h;e++){const s=a[e];this.queryCut(m,s,t[e],i),m=s}return h}getMonotonicParts(t,i){if(t.length<4&&e(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),i&&t[0].get().dropAllAttributes(),1;const n=this.getSemiAxes(),r=new Array(4);r[0]=Math.atan2(n.y*this.m_cosr,n.x*this.m_sinr),r[1]=r[0]+nt(),r[2]=Math.atan2(-n.y*this.m_sinr,n.x*this.m_cosr),r[3]=r[2]+nt();const o=new Array(5);let a=0;for(let e=0;e<4;e++)o[a]=Im(this,r[e]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;B(o,a),o[a-1]<1&&(o[a]=1,a++),s(t.length>=a);let h=0;for(let e=0;e<a;e++){const s=o[e];this.queryCut(h,s,t[e],i),h=s}return a}intersectionWithAxis2D(t,e,s,i){if(Gm(this)){return new rl({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i)}let n,r;const o=new V(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;n=new V(a.x).mulThis(this.m_sinr),r=new V(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;n=new V(a.x).mulThis(this.m_cosr),r=new V(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=n.sqr(),m=r.sqr(),u=h.addE(m),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),d=l.sqr().subThisE(u.mulE(c).mulThis(4)),g=n.mulE(o).mulThis(-2),_=o.sqr().subThisE(m),p=g.sqr().subThisE(u.mulE(_).mulThis(4));let f=d.eps()*Math.abs(p.value())<=p.eps()*Math.abs(d.value());f?n.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(g),c.setE(_));const y=x(V,2);let P=Ui(u,l,c,D.construct(-1,1),!1,y);if(0===P)return 0;const v=[0,0];let C=0;for(let x=0;x<P;x++){const t=new V,e=new V;f?(t.setE(y[x]),e.setE(o.subE(r.mulE(y[x])).divThisE(n))):(e.setE(y[x]),t.setE(o.subE(n.mulE(y[x])).divThisE(r)));const s=Im(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(v[C]=s,C++)}return P=C,0===P?0:(2===P&&v[0]>v[1]&&(v[1]=S(v[0],v[0]=v[1])),i&&A(i,v,0,0,P),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),P>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=S(s[0],s[0]=s[1])))),P)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(e){3!==e.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new D(0,1),e):t("3d not impl")}clone(t){const e=new $h;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Gm(this))return 0===e?D.construct(this.getStartX(),this.getEndX()):D.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=Im(this,t),n[1]=Im(this,i);const r=0===e?D.construct(this.getStartX(),this.getEndX()):D.construct(this.getStartY(),this.getEndY()),o=new f;for(let a=0;a<2;a++){const t=n[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new D(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Gm(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),n=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=rt){let t=f.lerp(i,n,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*f.distance(i,n))),e.setCoords(i),e.mergeNe(n),void e.mergeNe(t)}fu(this,s,e)}tToLength(t){return Gm(this)?t*f.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Hm(this,t)}parametricAngleToT(t){return Im(this,t)}tToParametricAngle(t){return Nm(this,t)}lengthToT(t){if(Gm(this)){const e=f.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return Wm(this,t)}calculateWeightedAreaCentroid2D(t){if(Gm(this)){const t=new f;return t.setCoords(0,0),t}const e=lu(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),n=this.m_semiMajorAxis,r=this.getSemiMinorAxis(),o=this.m_startAngle+this.m_sweepAngle,a=new f;a.x=n*r*(n*this.m_cosr*(-Math.sin(o)+Math.sin(this.m_startAngle))+r*(-Math.cos(o)+Math.cos(this.m_startAngle))*this.m_sinr)/3,a.y=n*r*(r*(Math.cos(o)-Math.cos(this.m_startAngle))*this.m_cosr+n*(-Math.sin(o)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const h=i.add(s).mul(i.crossProduct(s)/6);return a.x-=h.x,a.y-=h.y,a.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new f;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Gm(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),n=Math.sin(s),r=Math.cos(e),o=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,a=s*(n-i),h=s*(r-o);t.setCoords(a,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),a=e*e,h=s*s,m=e*s,u=a-h,l=u/h,c=u/a,d=Math.sqrt(l),g=Math.sqrt(c),_=.5*m*(Math.asinh(d*n)/d+n*Math.sqrt(1+l*n*n))-.5*m*(Math.asinh(d*i)/d+i*Math.sqrt(1+l*i*i)),p=-.5*m*(Math.asin(g*o)/g+o*Math.sqrt(1-c*o*o))- -.5*m*(Math.asin(g*r)/g+r*Math.sqrt(1-c*r*r));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Gm(this)){const s=f.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),n=new f;this.queryCoord2D(i,n);return f.distance(n,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}getTangent(t){if(Gm(this))return this.getEndXY().sub(this.getStartXY());{const e=Nm(this,t),s=new f;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Gm(this))return this.getEndXY().sub(this.getStartXY());{const e=Nm(this,t),s=new f;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!iu(this)&&(Gm(this)?(nu(this),!1):ru(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new f(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new f(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=Nm(this,t),s=new f,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const n=new f;n.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),n.rotateDirect(this.m_cosr,this.m_sinr));const r=s.sqrLength();if(0===r)return Number.NaN;const o=Math.sqrt(r);s.divThis(o);return s.crossProduct(n)/r}getMonotonicPartParams(t,s){const i=new Array(6);i[0]=0;let n=1;if(this.isDegenerateToLine())i[1]=1,n=2;else{const t=this.getSemiAxes(),e=new Array(4);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=ot());for(let s=0;s<4;s++){const t=Im(this,e[s]);t>0&&t<1&&(i[n]=t,n++)}n>2&&B(i,n),i[n]=1,n++}if(s){t<n&&e("");for(let t=0;t<n;t++)s[t]=i[t]}return n}calculateLowerLength2D(){const t=f.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=f.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Gm(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,Qm(t)}calculateArea2DHelper(){return lu(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Gm(this))return;const s=this.getSemiAxes(),i=new Array(8);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=Im(this,t),i[1]=Im(this,e),i[2]=Im(this,n),i[3]=Im(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=Im(this,n),i[5]=Im(this,r),i[6]=Im(this,o),i[7]=Im(this,a)}const n=f.getNAN();for(let r=0;r<8;r++){const s=i[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,n),e.mergeNe(n))}}setSegmentFromCoords(t,e){zm(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return a("should not1; be called"),0}ensureXYMonotone(){if(Gm(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return km(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=x(f,3);let e=ou(this,t);if(Mr(t)){let s=!1;if(0===this.projectionBehavior()){const i=new qt;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const n=new f;n.setSub(t[2],t[0]),n.leftPerpendicularThis(),n.normalize(),n.scale(f.distance(t[2],t[0]));const r=f.lerp(t[2],t[0],.5),o=r.sub(n),a=r.add(n);i.clipLine(o,a);const h=f.getClosestCoordinate(o,a,t[1],!1);t[1]=f.lerp(o,a,h);const m=t[2].sub(t[1]),u=t[0].sub(t[1]),l=m.crossProduct(u),c=m.dotProduct(u);e=at()-Math.abs(.5*Math.atan2(l,c)),s=!0}return au(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Lm(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,Om(e,Fm(this))}reverseImpl(){$m(this,!Jm(this)),Tm(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&cu(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(jh(Wh(Zh(this.m_rotation-s.m_rotation)))),n=Math.abs(nt()-i),r=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}swapImpl(t){const e=t;this.m_center=S(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=S(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=S(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=S(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=S(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=S(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=S(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=S(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=S(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=S(e.m_bits,e.m_bits=this.m_bits),Km(this,e)}afterCompletedModification(){nu(this),Qm(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&i(""),Gm(this)){return new rl({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=f.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),r=f.getNAN();return this.queryCoord2D(n,r),f.distance(r,t)<=s?G(n,0,1)&&(this.queryCoord2D(0===n?1:0,r),f.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Qm(this)}clearEndPointModified(){nu(this)}}function Jh(t,e,s){t.isEmpty()&&r(""),p(t);const i=t.getImpl(),n=[];return sm(i.getPointCount(),n),im(em(i),n,i.getPointCount(),e)}function tm(t,e,s,i){const n=[];return sm(e,n),im(t,n,e,s)}function em(t){return{at:e=>t.getXY(e)}}function sm(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&_s(t,e)}function im(t,e,s,i,n){let r=0;const o=[0,0,0];let a=0;const h=3;let m=0;for(let u=0;u<h;++u){let n=!1;for(;m<s;){const s=t.at(e[m]);let l=1;if(3===r?l=f.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===r?l=f.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===r&&s.equals(t.at(i[0]))&&(l=0),l<=0){if(l<0&&u+1<h){e[a]=S(e[m],e[m]=e[a]);for(let t=0;t<r;t++)if(i[t]===e[m]){o[t]=m;break}a++}m++;continue}n=!0;let c=0;for(let t=0;t<r;t++)o[t]>m&&(i[c]=i[t],o[c]=o[t],c++);r=c,i[r]=e[m],o[r]=m,r++,r<3?m=a:(1===f.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=S(i[0],i[0]=i[2]),o[2]=S(o[0],o[0]=o[2])),m++)}if(!n)break;if(u+1<h){a=0;let s=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=S(o[t],o[t]=o[e]),i[e]=S(i[t],i[t]=i[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=S(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===f.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=S(i[0],i[0]=i[2]),o[2]=S(o[0],o[0]=o[2]))}m=r}return r}$h.type=n.enumEllipticArc;class nm extends Xh{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!0}),this.m_segmentBufferCTor=ol):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=ol,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=ol):e.envelope?t("envelope constructor not impl"):a("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=ol)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Vh(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return nm.type}getDimension(){return 2}createInstance(){return new nm({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function rm(t,e,s,i,n,r){return new um(0,0,0,null,!1,w()).densifyEx(t,e,s,i,!1,r)}function om(t,s,i,r){return Number.isFinite(s)||e("replace_all_curves_with_beziers: maxDeviation"),gm(n.enumBezier,t,s,i)}function am(e,i,r,o,a,h,m,u){h&&(h.length=0),m&&(m.length=0);const l=e.getGeometryType();if(l===n.enumLine)return h&&(h.push(e.getStartXY()),h.push(f.getNAN()),h.push(f.getNAN()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;if(l===n.enumBezier){if(!o)return h&&(h.push(e.getStartXY()),h.push(e.getControlPoint1()),h.push(e.getControlPoint2()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;const t=[];t.length=9;let s=e.getMonotonicPartParams(t.length,t);if(t.length=s,s=lm(e,r,t),2===s&&a&&(t[1]=.5,t.push(1),s=3),m&&m.splice(0,0,...t.slice(0,s)),h){const i=new ol;for(let n=1;n<s;n++){const s=t[n-1],r=t[n];e.queryCut(s,r,i,!0);const o=i.get();ka(o),1===n&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===n.enumEllipticArc){const t=e;if(t.isDegenerateToLine()||t.isDegenerate(0))return h&&(h.push(e.getStartXY()),h.push(f.getNAN()),h.push(f.getNAN()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;if(o&&(a||!t.isMonotoneQuickAndDirty())){const n=[];n.length=6;let u=t.getMonotonicPartParams(n.length,n);n.length=u,u=lm(e,r,n),2===u&&a&&(n[1]=.5,n.push(1),u=3);let l=0;if(u>2){const e=new ol,a=m||[];let c=0;for(let d=1;d<u;d++){const g=n[c],_=n[d];if(t.queryCut(g,_,e,!0),e.get().isDegenerate(0))continue;const p=a.length,f=_m(1===d,e.get(),i,r,o,h,m);s(f>0),l+=f;const x=d===u-1,y=n[c],P=e.get().getSweepAngle()/t.getSweepAngle();for(let e=p,s=a.length;e<s;e++)if(a[e]=!x||e+1<s?y+a[e]*P:1,h){const s=3*e,i=t.getCoord2D(a[e]);if(h[s].setCoordsPoint2D(i),s>0){Ga(h.slice(s-3))}}c=d}return l}}return _m(!0,t,i,r,o,h,m)}if(l===n.enumRationalBezier2){const t=e;if(o&&(a||!t.isMonotoneQuickAndDirty())){const s=[];s.length=6;let n=t.getMonotonicPartParams(s.length,s);s.length=n,n=lm(e,r,s),2===n&&a&&(s[1]=.5,s.push(1),n=3);let o=0;if(n>2){const e=new ol,a=m||[];for(let u=1;u<n;u++){const l=s[u-1],c=s[u];t.queryCut(l,c,e,!0);const d=a.length;o+=fm(1===u,e.get(),i,r,!1,h,m);const g=u===n-1,_=s[u-1];for(let e=d,s=a.length;e<s;e++)if(a[e]=!g||e+1<s?_+a[e]:1,h){const s=3*e,i=t.getCoord2D(a[e]);if(h[s].setCoordsPoint2D(i),s>0){Lo(h.slice(s-3))}}}return o}}return fm(!0,t,i,r,o,h,m)}if(l===n.enumBezier2){const t=e,s=x(f,3);t.queryControlPoints(s);const n=new da;return n.constructFromQuadratic(s),am(n,i,r,o,a,h,m)}t("")}function hm(e,s,i,r,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const u=e.getGeometryType();if(u===n.enumLine)return a&&(a.push(e.getStartXY()),a.push(f.getNAN()),a.push(e.getEndXY())),h&&(h.push(0),h.push(1)),1;if(u===n.enumBezier2){const t=[];t.length=9;let s=e.getMonotonicPartParams(t.length,t);if(t.length=s,s=lm(e,i,t),2===s&&o&&(t[1]=.5,t.push(1),s=3),h&&h.splice(0,0,...t.slice(0,s)),a){const i=new ol;for(let n=1;n<s;n++){const s=t[n-1],r=t[n];e.queryCut(s,r,i,!0);const o=i.get();Ro(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getEndXY())}}return s-1}if(u===n.enumEllipticArc){const t=e;if(t.isDegenerateToLine()||t.isDegenerate(0))return a&&(a.push(e.getStartXY()),a.push(f.getNAN()),a.push(e.getEndXY())),h&&(h.push(0),h.push(1)),1;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n),2===r&&o&&(n[1]=.5,n.push(1),r=3);let m=0;if(r>2){const e=new ol,o=h||[];for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=o.length;m+=xm(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1],p=e.get().getSweepAngle()/t.getSweepAngle();for(let e=d,s=o.length;e<s;e++)if(o[e]=!g||e+1<s?_+o[e]*p:1,a){const s=2*e,i=t.getCoord2D(o[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}return m}}return _m(!0,t,s,i,r,a,h)}if(u===n.enumBezier){const t=e;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n),2===r&&o&&(n[1]=.5,n.push(1),r=3);let m=0;if(r>2){const e=new ol,o=h||[];for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=o.length;m+=ym(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1];for(let e=d,s=o.length;e<s;e++)if(o[e]=!g||e+1<s?_+o[e]:1,a){const s=2*e,i=t.getCoord2D(o[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}return m}}return ym(!0,t,s,i,r,a,h)}if(u===n.enumRationalBezier2){const t=e;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n),2===r&&o&&(n[1]=.5,n.push(1),r=3);let m=0;if(r>2){const e=new ol,o=h||[];for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=o.length;m+=pm(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1];for(let e=d,s=o.length;e<s;e++)if(o[e]=!g||e+1<s?_+o[e]:1,a){const s=2*e,i=t.getCoord2D(o[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}return m}}return pm(!0,t,s,i,r,a,h)}t("")}function mm(t,e,i,r,o,a,h,m,u){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),l===n.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(f.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=q(9,Number.NaN);let d;if(o)d=t.getMonotonicPartParams(c.length,c),c.length=d,d=lm(t,i,c);else{if(d=2,c[0]=0,c[1]=1,l===$h.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,d=4):(c[0]=0,c[1]=.5,c[2]=1,d=3)}}else s(l===mn.type);c.length=d}if(2===d&&r&&(c[1]=.5,c.push(1),d=3),a){const e=new ol;let s=1;for(;s<d;){const i=c[s-1],r=c[s];t.queryCut(i,r,e,!0);const m=x(f,3),u=[1,1,1];if(l===n.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-i)/3;c.splice(s,0,i+t),c.splice(s+1,0,i+2*t),d+=2;continue}u[1]=ou(t,m)}else{const t=e.get();t.queryControlPoints(m),t.queryWeights(u)}o&&Mr(m),1===s&&(a.push(m[0].clone()),h.push(u[0])),a.push(m[1].clone()),a.push(m[2].clone()),h.push(u[1]),h.push(u[2]),s++}}return m&&(m.length=d,A(m,c,0,0,d)),d-1}nm.type=n.enumPolygon;class um{static constructDefault(t){return new um(0,0,0,t,!1,w())}constructor(t,e,s,i,n,r){this.m_segmentBuffer=null,this.m_dummyPoint=new hs,this.m_progressCounter=0,this.m_progressTracker=i,this.m_bSetDensifyFlag=n,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>at()?at():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=r,c(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,i,n,r){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=i>at()?at():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=n,this.m_maxSegmentsPerCurve=r,c(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return _(e)?t:d(e)?this.densifyMultiPath(t):m(e)?this.densifySegmentImpl(t):e===n.enumEnvelope?this.densifyEnvelope(t):void a("")}densifySegmentEx(t,e,s,i,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==n.enumLine)&&(!i||s))return void(e?o===n.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===n.enumBezier)return void this.densifyCubicBezier(t,e,s,i,r);if(o===n.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,i,r);if(o===n.enumBezier2)return void this.densifyBezier2(t,e,s,i,r);if(o===n.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,i,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,i,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();if(e.getGeometryType()===n.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Rh({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new nm({vd:t.getDescription()});e.addEnvelope(t,!1);const s=qt.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();if(e.getGeometryType()===n.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=e.getImpl(),i=t.getImpl(),r=i.getAttributeStreamRef(0),o=new rl;for(let n=0,a=i.getPathCount();n<a;n++){const t=i.isClosedPath(n);if(0===i.getPathSize(n))continue;const a=i.getPathStart(n),h=r.readPoint2D(2*a),m=h.clone();s.startPath(h);for(let u=a+1,l=i.getPathEnd(n);u<l;u++){const t=r.readPoint2D(2*u),i=f.distance(m,t);if(i>this.m_maxLength){let e=Math.ceil(i/this.m_maxLength);e>w()&&(e=w());const n=1/e;let r,a,h;m.compare(t)<0?(o.setStartXY(m),o.setEndXY(t),r=0,a=1):(o.setStartXY(t),o.setEndXY(m),r=e-2,a=-1);for(let t=0,i=e-1;t<i;t++,r+=a){this.progress_(),h=n*(r+1);const t=new f;o.queryCoord2D(h,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),m.assign(t)}if(t){const t=f.distance(m,h);if(t>this.m_maxLength){const e=h;let i=Math.ceil(t/this.m_maxLength);i>w()&&(i=w());const n=1/i;let r,a;m.compare(e)<0?(o.setStartXY(m),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(m),r=i-2,a=-1);const u=new f(0,0);let l;for(let t=0,h=i-1;t<h;t++,r+=a)this.progress_(),l=n*(r+1),o.queryCoord2D(l,u),s.lineTo(u),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(e,i,r,o,a,h){s(e.getGeometryType()!==n.enumBezier);let m=e.getStartXY().compare(e.getEndXY());if(0===m&&i<1){e.getGeometryType()===n.enumEllipticArc?m=e.getSweepAngle()<0?1:-1:t("densify segment by length")}let u=0;if(o&&(r?(e.queryStart(this.m_dummyPoint),r.startPathPoint(this.m_dummyPoint)):h.push(0),++u),i*this.m_maxSegmentsPerCurve<1&&(i=1/this.m_maxSegmentsPerCurve),i<1){this.m_segmentBuffer||(this.m_segmentBuffer=new ol);let t=Math.ceil(1/i);t>w()&&(t=w()),i=1/t,this.m_segmentBuffer.create(e.getGeometryType());let s,n,o,a=e;m<0?(s=0,n=1):(e.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),s=t-2,n=-1,a=this.m_segmentBuffer.get());const l=t-1;for(let e=0;e<l;e++,s+=n)o=i*(s+1),r?(a.queryCoord(o,this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&r.setAttribute(10,r.getPointCount()-1,0,1)):h.push(m>0?1-o:o),this.progress_();o=1,u+=l}(!a||a&&o&&u<2)&&(r?(e.queryEnd(this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,i,n){const r=new da;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=x(f,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=[],l=[],c=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let d=!0,g=0;if(h>0)for(u.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new f(0,1)]),l.push(0);u.length;){this.progress_();const t=u.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){d&&(g=o.findMinDeriv(),d=!1);let e=.5*(a+h);Math.abs(g-e)<.4*(h-a)&&(e=g);const s=(e-a)/(h-a),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),m=t[2].mul(1-s).add(t[3].mul(s)),c=i.mul(1-s).add(n.mul(s)),_=n.mul(1-s).add(m.mul(s)),p=c.mul(1-s).add(_.mul(s)),x=t[3];t[1]=i,t[2]=c,t[3]=p,t[4].setCoords(a,e);const y=[p,_,m,x,new f(e,h)];u.push(y),l[l.length-1]=r+1,l.push(r+1)}else u.pop(),l.pop(),(u.length>0||!i||i&&s&&m<2)&&(e?(o.queryCoord(a,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==a&&0!==a&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(1-a),++m)}else for(u.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new f(0,1)]),l.push(0);u.length;){this.progress_();const t=u.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){d&&(g=o.findMinDeriv(),d=!1);let e=.5*(a+h);Math.abs(g-e)<.4*(h-a)&&(e=g);const s=(e-a)/(h-a),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),m=t[2].mul(1-s).add(t[3].mul(s)),c=i.mul(1-s).add(n.mul(s)),_=n.mul(1-s).add(m.mul(s)),p=c.mul(1-s).add(_.mul(s)),x=t[0];t[0]=p,t[1]=_,t[2]=m,t[4].setCoords(e,h);const y=[x,i,c,p,new f(a,e)];u.push(y),l[l.length-1]=r+1,l.push(r+1)}else u.pop(),l.pop(),(u.length>0||!i||i&&s&&m<2)&&(e?(o.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h),++m)}}densifyRationalBezier2(t,e,s,i,n){const r=new mn;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new mn,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.rationalBezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}densifyBezier2(t,e,s,i,n){const r=new an;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),l=new an,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.bezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}densifyEllipticArc(t,e,s,i,n){const r=new $h;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=t.isClockwise()?0:1),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new $h,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.ellipticArcNeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}calculateLengthSubdivisionStep(e,s){const i=e.calculateUpperLength2D();if(!e.isCurve())return i?s/i:1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;if(t.isCircular()||t.isDegenerate(0)||t.isDegenerateToLine()){let t=s/i;return t<this.m_minStep&&(t=this.m_minStep),t}return s/i*t.getSemiAxes().y/t.getSemiAxes().x}e.getGeometryType()===n.enumBezier&&t(""),t("")}calculateDeviationSubdivisionStep(e,s){if(!e.isCurve())return 1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;if(t.isDegenerate(0)||t.isDegenerateToLine())return 1;{const i=t.getSemiMajorAxis(),n=1-s/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(s/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(e,o)}}t("")}calculateAngularSubdivisionStep(e,s){if(!e.isCurve())return 1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;return t.isDegenerate(0)||t.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(e,s*t.getSemiMinorAxis())}t("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}const r=x(f,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!n&&this.m_maxDeviation>0&&(n=!um.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkRationalBezier2MaxAngle(r,o,this.m_cosMaxAngle)),n}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}const r=x(f,3);return e.queryControlPoints(r),!n&&this.m_maxDeviation>0&&(n=!um.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkBezier2MaxAngle(r,this.m_cosMaxAngle)),n}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}return!n&&this.m_maxDeviation>0&&(n=!um.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if(f.distance(t[0],t[1])+f.distance(t[1],t[2])+f.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!um.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!um.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1])),r=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(n),Math.abs(r))<=e){const e=new f;Ua(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),i=[0,0];if(1===yu(t,s,i)){const s=t.getCoord2D(i[0]),n=f.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new f;Q(t.getStartXY(),t.getEndXY(),n,r);return f.distance(s,r)<=e}}const s=t.getCoord2D(.5),i=new f;Q(t.getEndXY(),t.getStartXY(),.5,i);return f.distance(s,i)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0)&&!(s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==n.enumEllipticArc||t.isCircular())}}function lm(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const r=[];r.length=i-1;for(let o=1,a=i;o<a;o++){const e=t.tToLength(s[o]);r[o-1]=e-n,n=e}for(;r.length>1;){const t=r.findIndex((t=>t<=2*e));if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===r.length||r[e]>r[n])&&(n=e,i--)}r[n]+=r[t],r.splice(t,1),s.splice(i,1)}return s.length}function cm(t,e,s,i,n){const r=[],o=[],a=am(e,s,0,i,!1,r,o),h=new da;let m=n;const u=e.getDescription();h.assignVertexDescription(u);const l=u.getAttributeCount()>1,c=new hs,d=new rl;for(let g=0,_=0;g<a;g++){if(r[_+1].isNAN()){if(l){let t=o[g];e.queryCoord(t,c),d.setStart(c),t=o[g+1],e.queryCoord(t,c),d.setEnd(c)}d.setStartXY(r[_]),d.setEndXY(r[_+3]),t.addSegment(d,m)}else{if(l){let t=o[g];e.queryCoord(t,c),h.setStart(c),t=o[g+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setControlPoint2(r[_+2]),h.setEndXY(r[_+3]),t.addSegment(h,m)}_+=3,m=!1}}function dm(t,e,s,i,n){const r=[],o=[],a=hm(e,s,0,i,!1,r,o),h=new an;let m=n;const u=e.getDescription();h.assignVertexDescription(u);const l=u.getAttributeCount()>1,c=new hs,d=new rl;for(let g=0,_=0;g<a;g++){if(r[_+1].isNAN()){if(l){let t=o[g];e.queryCoord(t,c),d.setStart(c),t=o[g+1],e.queryCoord(t,c),d.setEnd(c)}d.setStartXY(r[_]),d.setEndXY(r[_+2]),t.addSegment(d,m)}else{if(l){let t=o[g];e.queryCoord(t,c),h.setStart(c),t=o[g+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setEndXY(r[_+2]),t.addSegment(h,m)}_+=2,m=!1}}function gm(t,e,i,r,o){s(t===n.enumBezier||t===n.enumEllipticArc||t===n.enumBezier2);const h=e.createInstance();h.getGeometryType()===n.enumPolygon&&h.setFillRule(e.getFillRule());const m=e.querySegmentIterator();for(let u=0,l=e.getPathCount();u<l;++u){if(!e.hasNonLinearSegmentsPath(u)){h.addPath(e,u,!0);continue}const o=e.getPathStart(u);let l=!0,c=0;for(m.resetToPath(u),s(m.nextPath());m.hasNextSegment();){const s=m.nextCurve();if(!s)break;{const d=m.getStartPointIndex()-o,g=d-c;g>0&&(h.addSegmentsFromPath(e,u,c,g,l),l=!1),c=d+1,t===n.enumBezier?cm(h,s,i,r,l):t===n.enumBezier2?dm(h,s,i,r,l):a(""),l=!1}}const d=e.getSegmentCountPath(u);d-c!=0&&h.addSegmentsFromPath(e,u,c,d-c,l)}return h}function _m(t,e,s,i,n,r,o,a){const h=e.clone();h.dropAllAttributes();const m=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(f.getNAN()),e.push(f.getNAN()),e.push(i.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(h.isDegenerateToLine()||h.isDegenerate(0))return m(t,r,o,e);const u=h.getStartXY(),l=h.getEndXY(),c=h.getSemiAxes(),d=new k;if(h.isCircular())d.setIdentity();else{const t=h.getAxisXRotation();d.setScaleCoords(1,h.getMinorMajorRatio()),d.rotateAngle(t)}const g=h.getCenter();d.shift(g);const _=d.clone();_.invertThis(),h.applyTransformation(_);const p=h.getSweepAngle();if(0===p)return m(t,r,o,e);const y=qt.constructEmpty();y.setCoords({center:g,width:2*c.x,height:2*c.x});const P=.05*y.calculateToleranceFromEnvelope(),v=Math.max(s/c.x,P/c.x);let C=4*Math.pow(v/.0741,1/6);C=Math.min(C,Math.PI/2);const b=Uh(h.getStartAngle());let E=p>0?Math.floor(b/C):Math.ceil(b/C);E*=C;const D=p>0?C:-C;E+D===b&&(E+=D);let S=4/3*Math.tan(Math.abs(C)/4);p>0&&(S=-S),o&&t&&o.push(0);const w=C/Math.abs(p);let A=(E-b)/p;const T=u.clone(),I=new f;h.queryCoord2D(0,I);const N=I.clone(),q=1-.01*w;let M=0,Y=0;for(;A<1;){let s;if(A+=w,Y>0&&A<q)s=S;else{A>=q&&(A=1);const t=(A-Y)*p;s=4/3*Math.tan(Math.abs(t)/4),p>0&&(s=-s)}h.queryCoord2D(A,I);const a=new f;d.queryTransform(I,a);const m=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(m,a),1!==A&&(f.distance(T,a)<=2*i||f.distance(a,l)<=2*i))continue;T.setCoordsPoint2D(a);const c=x(f,4);c[0].assign(N),c[3].assign(I),c[1].rightPerpendicularOther(N),c[1].scaleAddThis(s,N),c[2].leftPerpendicularOther(I),c[2].scaleAddThis(s,I),d.transformPoints2D(c,3,c),c[3].assign(a),0===Y&&c[0].setCoordsPoint2D(u),1===A&&c[3].setCoordsPoint2D(l),n&&Ga(c);let g=!0;for(let t=1;t<4;t++)if(!c[t].isEqualPoint2D(c[0])){g=!1;break}g||(o&&o.push(m),r&&(0===Y&&t&&r.push(c[0].clone()),r.push(c[1].clone()),r.push(c[2].clone()),r.push(c[3].clone())),M++),Y=A,N.setCoordsPoint2D(I)}return M}function pm(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);o&&t&&o.push(0);let l=0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[],_=q(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=lm(e,i,_);let y=0,P=t;for(let v=1;v<p;v++){const t=_[v];for(g.push(y),g.push(t);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=x(f,3);Fr(c,d,t,e,s,[0,0,0]);const i=x(f,3),n=aa(s,d,i),a=16,h=g.length>a;u>=n||h?(o.push(e),r&&(P&&(r.push(i[0]),P=!1),r.push(i[1]),r.push(i[2])),l++):(g.push(.5*(t+e)),g.push(t))}y=t}return l}function fm(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);o&&t&&o.push(0);let l=0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[],_=q(9,Number.NaN);let p=0;n?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=lm(e,i,_)):(_.length=2,p=2,_[0]=0,_[1]=1);let y=0,P=t;for(let v=1;v<p;v++){const t=_[v];for(g.length=0,g.push(t),g.push(y);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=x(f,3),i=[0,0,0];Fr(c,d,t,e,s,i);const n=x(f,4),a=Rr(s,i,n),h=16,m=g.length>h;u>=a||m?(o.push(e),r&&(P&&(r.push(n[0]),P=!1),r.push(n[1]),r.push(n[2]),r.push(n[3])),l++):(g.push(.5*(t+e)),g.push(t))}y=t}return l}function xm(t,e,s,i,n,r,o,a){const h=e.clone();if(h.dropAllAttributes(),h.isDegenerateToLine()||0===h.getSweepAngle())return r&&(t&&r.push(e.getStartXY()),r.push(f.getNAN()),r.push(e.getEndXY())),o&&(t&&o.push(0),o.push(1)),1;const m=h.getStartXY(),u=h.getEndXY(),l=h.getSemiAxes(),c=new k;if(h.isCircular())c.setIdentity();else{const t=h.getAxisXRotation();c.setScaleCoords(1,h.getMinorMajorRatio()),c.rotateAngle(t)}const d=h.getCenter();c.shift(d);const g=c.clone();g.invertThis(),h.applyTransformation(g);const _=qt.constructEmpty();_.setCoords({center:d,width:2*l.x,height:2*l.x});const p=.05*_.calculateToleranceFromEnvelope(),y=Math.max(s/l.x,p/l.x),P=Math.sqrt(2*y+y*y);let v=2*Math.sqrt(2*P*(1+y-P));v=Math.min(v,Math.PI/2);const C=h.getSweepAngle(),b=Math.ceil(Math.abs(C)/v),E=Math.max(b,1);v=C/E;const D=1/E;let S=Math.tan(Math.abs(v)/2);C>0&&(S=-S),o&&t&&o.push(0);const w=new f;h.queryCoord2D(0,w);for(let A=0;A<E;A++){const e=w.clone(),s=(A+1)*D;if(o&&o.push(s),!r)continue;h.queryCoord2D(s,w);const i=x(f,3);i[0].assign(e),i[2].assign(w),i[1].rightPerpendicularOther(i[0]),i[1].mulThis(S),i[1].addThis(i[0]),c.transformPoints2D(i,3,i),0===A&&i[0].setCoordsPoint2D(m),A===E-1&&i[2].setCoordsPoint2D(u),0===A&&t&&r.push(i[0]),r.push(i[1]),r.push(i[2])}return E}function ym(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);o&&t&&o.push(0);let l=0;const c=x(f,4);e.queryControlPoints(c);const d=[],g=q(9,Number.NaN);let _=e.getMonotonicPartParams(g.length,g);g.length=_,_=lm(e,i,g);let p=0,y=t;for(let P=1;P<_;P++){const t=g[P];for(d.push(p),d.push(t);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=x(f,4);Za(c,t,e,s);const i=x(f,3),n=oa(s,i),a=16,h=d.length>a;u>=n||h?(o.push(e),r&&(y&&(r.push(i[0]),y=!1),r.push(i[1]),r.push(i[2])),l++):(d.push(.5*(t+e)),d.push(t))}p=t}return l}function Pm(){return{e2:0,completeE:0}}class vm{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?f.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function Cm(t,e,s){if(Gm(t)){gi(new rl({start:t.getStartXY(),end:t.getEndXY()}),e,s)}else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new V;qm(t,e,i);const n=new V,r=new V;V.st_cosAndSin(i,n,r);const o=Ns.constructCoordsE(new V(t.m_semiMajorAxis).mulThisE(n),new V(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new V(t.m_rotation);V.st_cosAndSin(a,n,r),o.rotateDirect(n,r),o.addThisE(Ns.constructPoint2D(t.m_center)),s.setE(o)}}function bm(t,e){return t.convertToCanonic(e)}function Em(t,e){const s=new D(t.getStartAngle(),t.getEndAngle());s.normalize();const i=ht(),n=vt(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}function Dm(t,e,s,i){let n=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;n>nt();)n-=2*nt();for(;n<=-nt();)n+=2*nt();if(!Number.isNaN(e)){for(;e>nt();)e-=2*nt();for(;e<=-nt();)e+=2*nt();!s&&e>n&&(e-=2*nt()),s&&e<n&&(e+=2*nt()),r=e-n,Math.abs(r)<o&&!i&&(r=s?2*nt():-2*nt()),Math.abs(r)>2*nt()-o&&i&&(r=0)}Math.abs(r)>2*nt()-o&&(r=r>=0?2*nt():-2*nt(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),i=Math.abs(r)<=nt(),r&&(s=r>0),t.m_startAngle=Sm(n),t.m_sweepAngle=r,tu(t,!i),$m(t,s)}function Sm(t){let e=t,s=!1;return e<=-nt()?(e+=ht(),s=!0):e>nt()&&(e-=ht(),s=!0),e<=-nt()?(e=vt(e,ht()),e<=-nt()&&(e+=ht()),s=!0):e>nt()&&(e=vt(e,ht()),e>nt()&&(e-=ht()),s=!0),s&&(e>nt()||e<=-nt())&&(e=nt()),e}function wm(t,e,s){const i=s,n=i.getSemiAxes();let r=new f(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return r=i.convertFromCanonic(r),f.sqrDistance(r,i.getStartXY())}function Am(t,e,s){const i=s,n=i.getSemiAxes(),r=t[0]+i.getStartAngle();let o=new f(n.x*Math.cos(r),n.y*Math.sin(r));return o=i.convertFromCanonic(o),f.sqrDistance(o,i.getEndXY())}function Tm(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=eu(t),r=Jm(t),o=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Sm(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?r?ht():-ht():0}else{const i=t.convertToCanonic(e),a=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=a.x,i.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=f.calculateAngle(i,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=ht()):t.m_sweepAngle>0&&(t.m_sweepAngle-=ht()),t.m_startAngle=Sm(t.m_startAngle);let m=wm([t.m_startAngle],1,t);if(m=Math.sqrt(m),m>.25*ti(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Vi(wm,t,1,[t.m_startAngle],[e],[s],1e-14,i),t.m_startAngle=Sm(i[0])}if(m=Am([t.m_sweepAngle],1,t),m=Math.sqrt(m),m>.25*ti(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Vi(Am,t,1,[t.m_sweepAngle],[e],[s],1e-14,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>nt();if(tu(t,u),n!==u&&!n&&Math.abs(t.m_sweepAngle)>1.5*nt())return void km(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void km(t,e,s,o)}}function Im(t,e){return(Em(t,e)-t.getStartAngle())/t.getSweepAngle()}function Nm(t,e){return t.m_startAngle+e*t.m_sweepAngle}function qm(t,e,s){s.assign(new V(t.m_startAngle).addE(e.mulE(new V(t.m_sweepAngle))))}function Mm(t,e){const s=new V(t.m_cosr).sqrThis(),i=new V(t.m_sinr).sqrThis(),n=new V(t.m_minorMajorRatio),r=new V(1/t.m_minorMajorRatio),o=n.mulE(s).addThisE(r.mulE(i)),a=n.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=n.mulE(i).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new V(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function Ym(t,e){const s=new qs;s.a11.setE(t[0]),s.a12=V.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[f.getNAN(),f.getNAN()],n=[new V,new V];s.eigenSymmetric(n,i);const r=t[3].clone();r.negateThis(),r.invThis(),n[0].mulThisE(r),n[1].mulThisE(r),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble();return Math.atan2(i[0].y,i[0].x)}function Xm(t,e,s){if(Gm(t))return(s-e)*f.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const i=Hm(t,e);return Hm(t,s)-i}function Fm(t){return t.m_cachedValues}function Rm(t){if(t.m_cachedValues)return t.m_cachedValues;const e=Pm();return e.e2=Vm(t),e.completeE=Ct(e.e2),t.m_cachedValues=e,e}function Lm(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Gm(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,cu(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*at()){const i=x(f,3),n=ou(t,i);if(Nr(i)){i[0].assign(e),i[2].assign(s),Mr(i);if(0===t.projectionBehavior()){let e=0,s=2;f.sqrDistance(i[1],i[0])<f.sqrDistance(i[1],i[2])&&(s=S(e,e=s));const n=i[s].sub(i[e]),r=n.length();n.divThis(r);const o=i[1].sub(i[e]),a=o.length(),h=o.dotProduct(n)/a,m=o.crossProduct(n)/a,u=new f;Q(i[e],i[s],.5,u);const l=.5*r/m*y(1-h,0,1),c=i[1].side(i[e],i[s]),d=n.clone();c?d.leftPerpendicularThis():d.rightPerpendicularThis();const g=u.sub(d.mul(l));t.constructCircularArcThreePoint(i[0],i[2],g)}else au(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?Cu(t,e,s):bu(t,e,s)}}function zm(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void km(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new f;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const m=new Array(4);m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];const u=Math.trunc(s<5?1:(s+4)/5),l=x($h,4),c=new Array(4);let d=0;for(let g=0;g<4;g++){l[g].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,r,o,h[g],m[g],a),c[g]=0;let t=0;for(let i=u;i<s-1;i+=u){const s=l[g].getClosestCoordinate(e[i],!1);c[g]+=f.sqrDistance(l[g].getCoord2D(s),e[i]),t++}c[g]/=t,c[g]<c[d]&&(d=g)}t.assignCopy(l[d])}function Vm(t){return 1-C(t.m_minorMajorRatio)}function Bm(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,Vs(t,e),ks(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),tu(t,o),$m(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,ru(t,void 0===h)}function km(t,e,s,i){t.m_bits=0,t.m_rotation=0,Vs(t,e),ks(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,tu(t,!1),$m(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function Gm(t){return t.m_center.isNAN()}function Hm(t,e){if(0===e)return 0;const s=Rm(t),i=Nm(t,e),n=at(),r=jm(t),o=mt(i+n,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function Wm(t,e){if(Gm(t)){const s=f.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=Rm(t),n=at(),r=jm(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=ut(o,i.e2,i.completeE);a-=n,a-=t.getStartAngle();return a/s}function jm(t){const e=Rm(t);return mt(t.getStartAngle()+at(),e.e2,e.completeE)}function Zm(t,e,i){if(2===e.m_TransformationType)return void s(0);if(s(!iu(t)),e.isIdentity())return;Qm(t);const n=f.getNAN();n.x=t.m_XStart,n.y=t.m_YStart,e.transformInPlace(n);const r=f.getNAN();if(r.x=t.m_XEnd,r.y=t.m_YEnd,e.transformInPlace(r),Gm(t))return t.m_XStart=n.x,t.m_YStart=n.y,t.m_XEnd=r.x,void(t.m_YEnd=r.y);const o=t.m_center.clone();if(e.transformInPlace(o),i||e.isUniformNoRotation()){let s=Jm(t);e.isReflective()&&(s=!s);if(0===t.projectionBehavior()){if(!n.equals(r)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(n,r,s)}return void Um(t,n,r,o,s,!1)}const i=new f(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const a=Math.atan2(i.y,i.x),h=t.getSemiAxes();e.transformWithoutTranslateInPlace(h);const m=t.m_center.clone();return e.transformInPlace(m),void t.constructEllipticArcEndPointsCenter(n,r,h.x,h.y/h.x,a,t.isMajor(),s,m)}{{const s=new Array(4);Mm(t,s);const i=new qs;i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]);if(!i.det().isZero()){const a=new qs;if(a.a11.set(e.xx),a.a12.set(e.xy),a.a21.set(e.yx),a.a22.set(e.yy),a.invertThis()){const h=a.clone();h.transposeThis();const m=i.clone();m.mulThis(a),m.mulLeftThis(h);if(!m.det().isZero()){const i=x(V,4);i[0].setE(m.a11),i[1].setE(m.a12),i[1].mulThisByPower2(2),i[2].setE(m.a22),i[3].setE(s[3]);const a=f.getNAN(),h=Ym(i,a);let u=Jm(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(n,r,a.x,a.y/a.x,h,t.isMajor(),u,o)}}}}const s=[f.getNAN(),f.getNAN(),f.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let i=t.isClockwise();i&&(s[2]=S(s[0],s[0]=s[2]));const a=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const h=new f(0,0),m=t.createInstance();au(s,a,h,!1,m),t.constructEllipticArcEndPointsCenter(n,r,m.getSemiMajorAxis(),m.getMinorMajorRatio(),m.getAxisXRotation(),t.isMajor(),!i,o)}}function Um(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);Dm(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function Om(t,e){t.m_cachedValues=e}function Qm(t){t.m_cachedValues=null}function Km(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function $m(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function Jm(t){return!!(1&t.m_bits)}function tu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function eu(t){return!!(2&t.m_bits)}function su(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ns;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ns).setWithEps(t.m_center,e));const i=new V;i.setWithEps(t.m_rotation,e);const n=new V,r=new V;V.st_cosAndSin(i,n,r),s.rotateReverse(n,r);const o=new Ns;o.setWithEps(t.getEndXY()),o.subThisE(Ns.constructPoint2D(t.m_center)),o.rotateReverse(n,r);const a=new V;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),m=new V;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=s.x.sqr().addThisE(s.y.sqr()).subThisE(dt),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(dt);return!u.isZero()||!l.isZero()}function iu(t){return!!(8&t.m_bits)}function nu(t){t.m_bits&=-9}function ru(t,e){nu(t);const s=t.getStartXY(),i=t.getEndXY();let n=!1;const r=eu(t),o=Jm(t),a=t.projectionBehavior(),h=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:g("NAN minor major ratio and non-zero major axis")),m||=e?h:t.m_center.isNAN(),m)return km(t,s,i,a),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const u=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(h){const e=t.convertToCanonic(s);e.x/=u.x,e.y/=u.y;const i=Math.sqrt(C(e.x)+C(e.y));if(n=1!==i,t.m_semiMajorAxis*=i,u.mulThis(i),t.m_startAngle=Sm(Math.atan2(e.y,e.x)),!r)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),n;t.m_sweepAngle=o?ht():-ht()}else{let e=t.m_center.isNAN()||su(t);if(!e){const n=t.convertToCanonic(s);n.x/=u.x,n.y/=u.y;const r=new f(1,0);t.m_startAngle=f.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=u.x,o.y/=u.y,t.m_sweepAngle=f.calculateAngle(n,o),e=!mu(t)}if(e){n=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let a=C(e.x/u.x)+C(e.y/u.y);a>1&&(a=Math.sqrt(a),t.m_semiMajorAxis*=a,u.mulThis(a));const h=new f(0,0);{const t=u.x*u.x,s=u.y*u.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);h.setCoords(u.x*e.y/u.y,-u.y*e.x/u.x),h.mulThis(t),r===o&&h.negateThis()}}{const e=new f(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(Tm(t),!mu(t))return km(t,s,i,a),!0}return cu(t),t.afterCompletedModification(),n}function ou(t,e){s(Math.abs(t.getSweepAngle())<15*Math.PI/16);const i=t.getSemiMajorAxis(),n=t.getSemiMinorAxis();let r;if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),r=1,r;if(0===n)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=f.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,m=new f(-i*Math.sin(a),n*Math.cos(a)),u=new f(-i*Math.sin(h),n*Math.cos(h));m.normalize(),u.normalize(),m.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const l=m.crossProduct(u);e[1].assign(m.mul(e[1].crossProduct(u)/l)),e[1].addThis(e[0]);return r=Math.cos(.5*o),r}function au(t,e,i,n,r){if(n){const s=.5,i=Math.sqrt(e),n=C(1-s)+2*i*s*(1-s)+C(s),o=t[0].mul(C(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul(C(s))).divThis(n);return r.constructCircularArcThreePoint(t[0],t[2],o),!0}const o=t[0].sub(t[1]),a=t[2].sub(t[1]),h=o.crossProduct(a),m=o.dotProduct(a),u=e;s(u<=1),s(u>0);const l=.5/(1-u),c=o.sqrLength(),d=m,g=a.sqrLength(),_=C(h),p=o.sub(a).sqrLength();if(0===_)return km(r,t[0],t[2],1),!1;if(m<=-Math.sqrt(c)*Math.sqrt(g))return km(r,t[0],t[2],1),!1;const f=[0,0],x=new D;x.setInfinite();const y=Li(2*_,-(p/u+4*d),2*(1-u)/u,x,!1,f);if(0===y)return km(r,t[0],t[2],1),!1;1===y&&(f[1]=f[0]);const P=Math.sqrt(l/f[0]),v=Math.sqrt(l/f[1]),b=.5/u;let E=b-g*f[0],S=b-c*f[0];Math.abs(E)>Math.abs(S)?S=d*f[0]-b+1:E=d*f[0]-b+1;const w=o.mul(E).add(a.mul(S)),A=w.norm(1)<1e-15*P?0:Math.atan2(w.y,w.x)+Math.PI,T=o.add(a),I=i?i.clone():t[1].add(T.mul(l)),N=t[0].sub(I),q=t[2].sub(I),M=N.crossProduct(q)<0,Y=!1;new $h;return r.constructEllipticArcEndPointsCenter(t[0],t[2],P,v/P,A,Y,!M,I)}function hu(t,e,s,i,n){return au(t,e,s,i,n)}function mu(t){let e=!1;{const s=new f(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);e=f.distance(t.getStartXY(),s)>ti(t)}let s=!1;if(!e){const e=new f(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center);s=f.distance(t.getEndXY(),e)>ti(t)}return!e&&!s}function uu(t,s,i,n){0===i&&e("construct_enclosing_circle");const r=[0,0,0],o=tm(s,i,r);if(1===o)t.constructCircleRadius(0,s[r[0]],n);else if(2===o){const e=f.lerp(s[r[0]],s[r[1]],.5),i=f.distance(s[r[0]],e),o=f.distance(s[r[1]],e);t.constructCircleRadius(Math.max(i,o),e,n)}else if(3===o){const e=f.calculateCircleCenterFromThreePoints(s[r[0]],s[r[1]],s[r[2]]),i=f.distance(s[r[0]],e),o=f.distance(s[r[1]],e),a=f.distance(s[r[2]],e);t.constructCircleRadius(Math.max(i,o,a),e,n)}else a("unexpected")}function lu(t){if(Gm(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,u=0;t.m_rotation&&(m=(a-h)*(a+h),u=2*a*h);const l=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;if(t.m_rotation){c=.125*(-2*Math.sin(r+n)*Math.sin(r-n))*u-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h}return i*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function cu(t){t.queryCoord2D(.5,t.m_interior)}function du(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==_u(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function gu(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==pu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function _u(t,e,i,n,r,o,a,h,m,u){if(Gm(e)){return yi(new rl({start:e.getStartXY(),end:e.getEndXY()}),i,n,r,o,a,h,u)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0);const l=ei(e,i);if(si(e,i,a=Math.max(l,a)))return 0;const c=i.getStartXY();c.subThis(e.m_center);const d=i.getEndXY();d.subThis(e.m_center),c.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);const g=d.clone();g.subThis(c);const _=e.m_semiMajorAxis,p=1/_,x=e.getSemiMinorAxis(),y=1/x,P=g.clone();P.leftPerpendicularThis();const v=Math.atan2(x*P.y,_*P.x),C=new Array(16),b=new Array(16);let E=0;const S=[v,v+Math.PI];for(let s=0;s<2;++s){const t=Im(e,S[s]);if(t>=0&&t<=1){C[E]=t;const s=e.getCoord2D(C[E]);b[E]=i.getClosestCoordinate(s,!1),f.distance(s,i.getCoord2D(b[E]))<=a&&E++}}const w=c.x*p,A=c.y*y,T=g.x*p,I=g.y*y;let N=Li(T*T+I*I,2*(w*T+A*I),w*w+A*A-1,D.unit(),!1,b);s(N>=0);for(let s=0;s<N;s++){const t=g.mul(b[s]).add(c);t.x*=p,t.y*=y;const n=Im(e,Math.atan2(t.y,t.x));if(n>=0&&n<=1){C[E]=n;const t=e.getCoord2D(n);b[E]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(b[E]))<=a&&E++}}s(E<C.length+4);const q=new Array(16);N=e.intersectPoint(i.getStartXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=q[s],b[E]=0;N=e.intersectPoint(i.getEndXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=q[s],b[E]=1;N=i.intersectPoint(e.getStartXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=0,b[E]=q[s];N=i.intersectPoint(e.getEndXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=1,b[E]=q[s];return 0===E?0:el(t,e,i,C,b,E,n,r,o,a,h,m,u)}function pu(t,e,i,n,r,o,a,h,m,u){if(Gm(e)){const s=new rl({start:e.getStartXY(),end:e.getEndXY()});return _u(t,i,s,n,o,r,a,h,m,!u)}if(Gm(i)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()});return _u(t,e,s,n,r,o,a,h,m,u)}const l=ei(e,i);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),n=e.getCenter(),u=i.getSemiAxes(),l=i.getCenter(),d=f.distance(l,n),g=t.x+u.x;if(d>g+a)return 0;if(t.y>u.x){if(d+u.x+a<t.y)return 0}else if(u.y>t.x&&d+t.x+a<u.y)return 0;if(m&&!h){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),a=1===i.m_minorMajorRatio&&i.isClosed()&&i.isMajor();if(n&&a&&(c=!0,d<=g)){if(Math.max(t.x,u.x)<=Math.min(t.x,u.x)+d)return s(!r&&!o),1}}}if(!c&&si(e,i,a))return 0;const d=[],g=[],_=!1,p=!1,x=mm(e,0,0,_,p,d,g,null),y=[],P=[],v=mm(i,0,0,_,p,y,P,null);if(1===x&&1===v){const t=new mn({points:d,weights:g}),s=new mn({points:y,weights:P}),l=[],c=[],_=jr(!1,t,s,n,null===r?null:l,null===o?null:c,a,h,m,u);if(_>0&&null!==r||null!==o){r&&(r.length=0),o&&(o.length=0);for(let n=0;n<_;++n){if(r)if(G(l[n],0,1))r.push(l[n]);else{const s=t.tToLength(l[n]),i=e.lengthToT(s);r.push(i)}if(o)if(G(c[n],0,1))o.push(c[n]);else{const t=s.tToLength(c[n]),e=i.lengthToT(t);o.push(e)}}}return _}let C=[];const b=[];let E=0;const D=m&&!h;for(let s=0;s<x;s++){const t=new mn({points:d.slice(2*s,2*s+3),weights:g.slice(2*s,2*s+3)});let n=0;for(let r=0;r<v;r++){b.length<=r&&b.push(new mn({points:y.slice(2*r,2*r+3),weights:P.slice(2*r,2*r+3)}));const o=[],h=[],m=D?null:o,u=D?null:h,l=jr(!1,t,b[r],null,m,u,a,!1,D,!1);if(l>0&&D)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===s)o[a]=0;else if(1===o[a]&&s===x-1)o[a]=1;else{const s=t.tToLength(o[a])+E,i=e.lengthToT(s);o[a]=i}if(0===h[a]&&0===r)h[a]=0;else if(1===h[a]&&r===v-1)h[a]=1;else{const t=b[r].tToLength(h[a])+n,e=i.lengthToT(t);h[a]=e}C.push(xt(o[a],h[a]))}n+=b[r].calculateLength2D()}E+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter((t=>!G(t.first,0,1)||!G(t.second,0,1)||!e.getCoord2D(t.first).equals(i.getCoord2D(t.second))))),m)return C.length;const S=[],w=[];for(const s of C)S.push(s.first),w.push(s.second);return el(t,e,i,S,w,S.length,n,r,o,a,h,m,u)}function fu(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Gm(t))return;const i=t.getSemiAxes(),n=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=r+Math.PI;n[0]=Im(t,e),n[1]=Im(t,s),n[2]=Im(t,r),n[3]=Im(t,o)}const r=new f;for(let o=0;o<4;o++){const i=n[o];e.containsExclusiveCoordinate(i)&&(t.queryCoord2D(i,r),s.mergeNe(r))}}function xu(t,e,i,n,r){if(0===t.m_semiMajorAxis)return i.vmin;let o=f.getNAN();t.queryCoord2D(i.vmin,o);let a=f.getNAN();if(t.queryCoord2D(i.vmax,a),Gm(t)){return new rl({start:o,end:a}).getClosestCoordinate(e,n)}const h=bm(t,e);if(o=bm(t,o),a=bm(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;const e=Im(t,Math.atan2(h.y,h.x));if(n||i.containsCoordinate(e))return e;return f.distance(h,o)<=f.distance(h,a)?i.vmin:i.vmax}const m=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),l=(m-u)*(m+u),c=C(l),d=h.x,g=h.y,_=C(u*g),p=u*l*g*2,y=[new V(_),new V(p),new V(c-C(m*d)-_),new V(-p),new V(-c)],P=x(V,4),v=Qi(y,4,new D(-1,1),!1,P,4);let b=i.vmin,E=f.sqrDistance(h,o);{const t=f.sqrDistance(h,a);t<E&&(b=i.vmax,E=t)}s(!n);let S=new Array(8);for(let s=0;s<v;++s){const e=P[s].value(),i=Math.sqrt(1-e*e),n=Math.atan2(e,i),r=Math.atan2(e,-i);S[2*s]=Im(t,n),S[2*s+1]=Im(t,r)}S=S.slice(0,2*v),lt(S);for(let s=0,x=2*v;s<x;++s)if(S[s]>i.vmin&&S[s]<i.vmax){const i=f.sqrDistance(e,t.getCoord2D(S[s]));E>i&&(E=i,b=S[s])}return b}function yu(t,e,i){s(!Gm(t));const n=new k;n.setRotateAngle(-t.getAxisXRotation());const r=new f;n.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+nt();let h=Im(t,o),m=Im(t,a);m<h&&(m=S(h,h=m));let u=0;return h>=0&&h<=1&&(i[u++]=h),m>=0&&m<=1&&(i[u++]=m),u}function Pu(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&(t.isMajor()!==e.isMajor()&&(!!t.m_center.equals(e.m_center)&&(t.m_sinr===e.m_sinr&&(t.m_cosr===e.m_cosr&&(t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise()))))))}function vu(t,e,s){if(Gm(t))s.setE(Ns.constructPoint2D(t.getEndXY()).subE(Ns.constructPoint2D(t.getStartXY())));else{const i=new V;qm(t,e,i);const n=new Ns;if(n.setCoordsE(new V(t.m_semiMajorAxis).negate().mulE((new V).setSin(i)),new V(t.getSemiMinorAxis()).mulE((new V).setCos(i))),t.m_rotation){const e=new V(t.m_rotation);n.rotateDirect((new V).setCos(e),(new V).setSin(e))}n.scaleThis(new V(t.getSweepAngle())),s.setE(n)}}function Cu(t,e,s,i){const n=t.getStartXY(),r=t.getEndXY(),o=n.equals(r),a=e.equals(s);if(!o&&!a){const i=new k;i.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=f.distance(e,s),a=f.distance(n,r),h=o/a;i.scale(h,h);const m=r.sub(n);m.divThis(a);const u=s.sub(e);u.divThis(o);const l=m.crossProduct(u),c=u.dotProduct(m);return i.rotate(c,l),i.shiftCoords(e.x,e.y),Zm(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,void(t.m_YEnd=s.y)}const h=new f;if(t.queryCoord2D(.5,h),a){if(o){const i=t.m_center.add(e.sub(n));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),i),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const m=e.add(s).mul(.5),u=s.sub(e);u.rightPerpendicularThis();const l=m.add(u),c=f.getClosestCoordinate(m,l,t.getCenter(),!0),d=new f;Q(m,l,c,d);const g=f.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,g,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}function bu(t,e,i,n){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(i);if(!a&&!h){const s=new k;return s.initializeFromTwoPoints(r,o,e,i),Zm(t,s,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void km(t,e,i,1);if(a&&h){const s=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!a){const s=.5*(ht()-Math.abs(t.getSweepAngle())),n=(t.getSweepAngle()+s*ct(t.getSweepAngle()))/t.getSweepAngle(),r=new f;t.queryCoord2D(n,r),t.constructEllipticArcEndPointsCenter(r,r,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const o=t.getCenter().add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const m=f.sqrDistance(e,i);let u=.25,l=.75;if(m<f.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],i=Fi(new vm(t,m),D.construct(0,.25),1,e);i>0&&(s(1===i),u=e[0],l=1-e[0])}const c=t.getCoord2D(u),d=t.getCoord2D(l);s(!c.equals(d)),t.constructEllipticArcEndPointsCenter(c,d,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),bu(t,e,i)}function Eu(s,i){let r=i,o=null;r||(o=_(s)?ce():le(),r=o);let a=null;switch(s){case n.enumPoint:a=new hs({vd:r});break;case n.enumLine:a=new rl({vd:r});break;case n.enumBezier:a=new da({vd:r});break;case n.enumEllipticArc:a=new $h({vd:r});break;case n.enumRationalBezier2:a=new mn({vd:r});break;case n.enumBezier2:a=new an({vd:r});break;case n.enumEnvelope:a=new cs({vd:r});break;case n.enumMultiPoint:a=new Es({vd:r});break;case n.enumPolyline:a=new Rh({vd:r});break;case n.enumPolygon:a=new nm({vd:r});break;case n.enumMultipatch:t("multipatch not impl");break;case n.enumGeometryCollection:a=new Ts({vd:r});break;default:e("Geometry.create")}return a}var Du=Vt;const Su=-1,wu=1;class Au{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function Tu(t){return void 0!==t.parent}class Iu{constructor(t){Tu(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==Su;){for(;this.m_path!==Su;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==Su)return this.m_vertex;if(this.m_bOneGeom)return Su;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===Su)break;this.m_bSkipMultiPoints&&!d(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return Su}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==Su&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return Su}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==Su?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==Su&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):Su}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new Iu({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class Nu{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class qu{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,i=this.m_indices.length;s<i;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,wu),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,wu),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==Su?this.getPrevVertex(e):this.getLastVertex(t),r=n!==Su?this.getNextVertex(n):Su,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByVal(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==Su&&this.setPrevVertex(r,o),n!==Su&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===Su&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==Su||this.setFirstVertex(t,o)),h&&r===Su&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new hs({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(n.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let n=0,r=s.getPathCount();n<r;n++){if(0===s.getPathSize(n))continue;const e=this.insertPath(t,Su);this.setClosedPath(e,s.isClosedPath(n));for(let t=s.getPathStart(n),r=s.getPathEnd(n);t<r;t++){const n=this.insertVertex_(e,Su,null,!1);if(i){const e=this.getVertexIndex(n);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const i=new ol;s.querySegment(t,i,!0),this.setSegmentToIndex(e,i.releaseSegment())}}}s.isStrongPathStart(n)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(n)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===n.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new qt;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()){o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)}if(o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,u=0,l=-1,c=Su,d=!1,g=s.nextSegment();if(null!==g)for(;;g=s.nextSegment()){let r=null===g;const o=null!==g?s.getPathIndex():a,_=null!==g?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?u++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(u===m){this.setClosedPath(c,d);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-l),this.m_verticesMp.addPoints(e,l,n),s=i.getPathSize(a),t=n-1}else if(!d||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,Su,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new ol;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===g)break;u=1,l=_,a!==o?(c=this.insertPath(t,Su),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),d=i.isClosedPath(o),a=o):c=this.insertPath(t,Su)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,i){const n=e.getImpl(),r=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),o=qt.constructEmpty();e.queryEnvelope(o),s(i.isIntersecting(o)&&!i.containsEnvelope(o));let a=qt.construct(Number.NEGATIVE_INFINITY,i.ymin,Number.POSITIVE_INFINITY,i.ymax),h=qt.construct(i.xmin,Number.NEGATIVE_INFINITY,i.xmax,Number.POSITIVE_INFINITY);const m=n.getAccelerators();if(m&&m.getQuadTree()){const t=m.getQuadTree(),e=t.getIntersectionCount(a,0,0);e>t.getIntersectionCount(h,0,e+1)&&(h=S(a,a=h))}else a.height()>h.width()&&(h=S(a,a=h));const u=[],l=n.queryLimitedSegmentIterator(a);let c=-1,d=-100,g=-1,_=0,p=-1,f=-1,x=Su,y=!0,P=l.nextSegment();if(null!==P)for(;;P=l.nextSegment()){let i=null===P;const o=null!==P?l.getPathIndex():c,a=null!==P?l.getStartPointIndex():d;if(i||(o===c?d+1===a?_++:i=!0:(i=c>=0,c<0&&(c=o,g=n.getSegmentCountPath(c),p=a,x=Su,_=1))),i){if(!(0===u.length&&g===_)){0!==u.length&&u[0].first===p||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,p,p+1),-1===f&&(f=p),x===Su&&(x=this.insertPath(t,Su),this.setClosedPath(x,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(x,Su,null,!1));for(const{first:i,second:o}of u){-1===f&&(f=i);let a=-1,h=-1;const m=i+o-1;if(o===g){const t=m+1;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,i,t),a=m,s(1===u.length)}else if(m+1<n.getPathEnd(c)){const t=m+2;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,i,t),a=m}else{const t=n.getPathStart(c),s=t!==f?1:0,r=m+1;h=r-i+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-i)+s),this.m_verticesMp.addPoints(e,i,r),a=m,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),x===Su&&(x=this.insertPath(t,Su),this.setClosedPath(x,!0));for(let t=0,e=i;t<h;t++,e++){const t=this.insertVertex_(x,Su,null,!1);if(r){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new ol;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===u.length||u.at(-1).first+u.at(-1).second!==p+_){let t=p+_;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),f!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(x,Su,null,!1))}}u.length=0,y=!0,o!==c&&(c=o,g=n.getSegmentCountPath(c),x=Su,f=-1),p=a,_=1}if(!P)break;{const t=qt.constructEmpty();P.queryLooseEnvelope(t),h.isIntersecting(t)?(y?u.push(xt(a,1)):u.at(-1).second++,y=!1):y=!0}d=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const i=e.getGeometryType()===n.enumPolygon,r=qt.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?i?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,Su);this.insertVertex_(i,Su,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,Su);for(let i=0,n=e.getPointCount();i<n;i++)this.insertVertex_(s,Su,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)?(-1===r&&(r=m,o=m),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,Su);for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&this.insertVertex_(h,Su,null,!1)}}splitSegmentForward(t,s,i,r,o){const a=this.getNextVertex(t);a===Su&&e("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),m=this.getPathFromVertex(t);let u=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(i);e<c;e++){const t=this.getVertexIndex(u),r=this.getNextVertex(u),d=s.getResultSegment(i,e);let g=null;if(d.getGeometryType()!==n.enumLine&&(g=d.clone(),g.dropAllAttributes()),0===e&&(d.queryStart(h),this.setSegmentToIndex(t,null),this.setPointEx(u,h,s.getResultSegmentStartPointRank(i,e),s.getResultSegmentStartPointWeight(i,e),o)),this.setSegmentRank(u,s.getResultSegmentInteriorRank(i,e)),this.setSegmentWeight(u,s.getResultSegmentInteriorWeight(i,e)),l){const t=s.getResultSegmentSegmentParentage(i,e),n=s.getResultSegmentStartPointIsBreak(i,e);this.setSegmentParentageAndBreak(u,t,n)}if(d.queryEnd(h),e<c-1){this.setSegmentToIndex(t,g);const n=this.insertVertex(m,r,h);this.setWeight(n,s.getResultSegmentEndPointWeight(i,e)),this.setRank(n,s.getResultSegmentEndPointRank(i,e)),this.select(n),u=n}else{this.setPointEx(a,h,s.getResultSegmentEndPointRank(i,e),s.getResultSegmentEndPointWeight(i,e),o);const n=s.getResultSegmentEndPointIsBreak(i,e);this.setSegmentParentageBreakVertex(a,n),this.setSegmentToIndex(t,g)}}}splitSegmentBackward(t,s,i,r,o){const a=this.getNextVertex(t);a===Su&&e("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),m=this.getPathFromVertex(t);let u=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(i);e<c;e++){const t=c-e-1,r=this.getVertexIndex(u),d=this.getNextVertex(u),g=s.getResultSegment(i,t);let _=null;if(g.getGeometryType()!==n.enumLine&&(_=g.clone(),_.reverse(),_.dropAllAttributes()),0===e&&(g.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(u,h,s.getResultSegmentEndPointRank(i,t),s.getResultSegmentEndPointWeight(i,t),o),this.setSegmentParentageAndBreak(u,s.getResultSegmentSegmentParentage(i,t),s.getResultSegmentEndPointIsBreak(i,t))),g.getGeometryType()===n.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(u,s.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(u,s.getResultSegmentInteriorWeight(i,t)),g.queryStart(h),e<c-1){const e=this.insertVertex(m,d,h);this.setWeight(e,s.getResultSegmentStartPointWeight(i,t)),this.setRank(e,s.getResultSegmentStartPointRank(i,t)),this.select(e),u=e,l&&this.setSegmentParentageAndBreak(e,s.getResultSegmentSegmentParentage(i,t),s.getResultSegmentEndPointIsBreak(i,t))}else this.setPointEx(a,h,s.getResultSegmentStartPointRank(i,t),s.getResultSegmentStartPointWeight(i,t),o)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?Ut(0,-1):Ut(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return Ut(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=S(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,Su,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return Su}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,((t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s}))}sortVerticesSimpleByYHelper3D(t,e,i){s(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=kt.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=f.getNAN(),this.m_workPoint2_2D=f.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=Su,this.m_lastGeometry=Su,this.m_vertexIndexList=new _e(5),this.m_pathIndexList=new _e(8),this.m_geometryIndexList=new _e(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new ge,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new qt(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=qt.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let r=i.next();r!==Su;r=i.next()){if(n?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=qt.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}n=!1}return s}getEnvelope3D(t){return s(0),kt.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){s(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,s){const i=t.getGeometryType();if(d(i))return this.addMultiPath(t,s);if(i===n.enumMultiPoint)return this.addMultiPoint(t,s);if(i===n.enumPoint)return this.addPoint_(t,s);if(i===n.enumEnvelope){const e=new nm;return e.addEnvelope(t,!1),this.addMultiPath(e,s)}e("")}appendGeometry(t,s){this.mergeVertexDescription(s.getDescription());const i=s.getGeometryType();d(i)?this.appendMultiPath(t,s):i!==n.enumMultiPoint?e(""):this.appendMultiPoint(t,s)}assignRankToGeometryVertices(t,e){e<wu&&(e=wu);const s=this.queryVertexIterator();for(let i=s.next();i!==Su;i=s.next())this.setRank(i,e),this.setSegmentRank(i,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(n.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=Su,s=-1,i=-1;for(let r=this.getFirstGeometry();r!==Su;)if(t!==n.enumUnknown&&this.getGeometryType(r)!==t)r=this.getNextGeometry(r);else{if(e===Su){e=r,s=this.getPathCount(e),i=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let s=this.getFirstPath(r);s!==Su;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(r),i+=this.getPointCount(r);const t=this.getLastPath(e),n=this.getFirstPath(r);t!==Su?this.setNextPath(t,n):this.setFirstPath(e,n),n!==Su&&(this.setPrevPath(n,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,Su),this.setLastPath(r,Su);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==Su&&(this.setGeometryVertexCount(e,i),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let c=this.getFirstPath(t);c!==Su;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==Su;c=this.getNextPath(c))this.setPathGeometry(c,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const u=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,u)}addPathFromMultiPath(t,e,s){const i=this.createGeometry(s?n.enumPolygon:n.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return i;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(i,Su);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let n=r.getPathStart(e),h=r.getPathEnd(e);n<h;n++){const t=this.insertVertex_(o,Su,null,!1);if(a){const e=this.getVertexIndex(t);if(1&r.getSegmentFlags(n))this.setSegmentToIndex(e,null);else{const t=new ol;r.querySegment(n,t,!0),this.setSegmentToIndex(e,t.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),i}getGeometry(t){const e=this.getGeometryType(t),s=Eu(e,this.m_verticesMp.getDescription()),i=this.getPointCount(t);if(0===i)return s;if(d(e)){const e=s.getImpl(),n=this.getPathCount(t),r=Ut(n+1),o=Ot(n+1,0),a=s.getDescription(),h=this.hasCurves();for(let s=0,m=a.getAttributeCount();s<m;s++){const h=a.getSemantics(s),m=Du.getComponentCount(h),u=jt(h,i),l=this.m_vertices.getAttributeStreamRef(h);let c=0,d=0,g=0;for(let e=this.getFirstPath(t);e!==Su;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&o.setBits(d,t);const s=this.getPathSize(e);if(r.write(d++,g),g+=s,0===h){const t=l,s=u;let i;for(let n=this.getFirstVertex(e);c<g;n=this.getNextVertex(n),c++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*c,i)}}else for(let i=this.getFirstVertex(e);c<g;i=this.getNextVertex(i),c++){const t=this.getVertexIndex(i);for(let e=0;e<m;e++){const s=l.readAsDbl(t*m+e);u.writeAsDbl(c*m+e,s)}}}e.setAttributeStreamRef(h,u),r.write(n,i)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,i=0;for(let n=this.getFirstPath(t);n!==Su;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===n.enumMultiPoint){const e=s.getImpl(),n=s.getDescription();e.reserve(i),e.resizeNoInit(i);for(let s=0,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=Du.getComponentCount(i),o=e.getAttributeStreamRef(i),a=this.m_vertices.getAttributeStreamRef(i);let h=0;const m=this.getFirstPath(t),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(i,o)}e.notifyModifiedFlags(65535)}else a("getGeometry");return s}queryPointGeometryOnly(t,s){this.getGeometryType(t)!==n.enumMultiPoint&&e("get_point_geometry_only");const i=this.getPointCount(t);if(i>1&&e("get_point_geometry_only"),0===i)return s.assignVertexDescription(this.m_vertexDescription),void s.setEmpty();const r=this.getFirstPath(t),o=this.getFirstVertex(r);this.queryPoint(o,s)}removeGeometry(t){for(let i=this.getFirstPath(t);i!==Su;i=this.removePath(i));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==Su?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==Su?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=le());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new Es({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===Su?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let e=0;e<this.m_geometryIndices.length;e++)if(null===this.m_geometryIndices[e])return this.m_geometryIndices[e]=Ut(0),e;this.m_geometryIndices.push(Ut(0));const t=this.m_geometryIndices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==Su;t=this.getNextGeometry(t))if(!d(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,i,r,o){const a=t*t;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage();for(let l=o===Su?this.getFirstGeometry():o;l!==Su;l=o===Su?this.getNextGeometry(l):Su){const t=this.getGeometryType(l);if(!d(t))continue;if(i&&t!==n.enumPolygon)continue;const o=this.getGeometryType(l)===n.enumPolygon;let c=this.getGeometryModified(l);for(let i=this.getFirstPath(l);i!==Su;){let t=0;for(let e=this.getFirstVertex(i);t<Math.trunc(this.getPathSize(i)/2);){const n=this.getNextVertex(e);if(n===Su)break;const o=this.getXY(e),d=this.getXY(n);let g=f.sqrDistance(o,d),_=!0;do{if(g<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(g=e*e,g>a)break}}if(0===g?0===h&&(h=-1):h=1,n!==this.getLastVertex(i)){const t=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(n));if(this.transferAllDataToTheVertex(n,e),this.removeVertex(n,!1),r&&!c&&(this.setGeometryModified(l,!0),c=!0),u&&e!==n){this.setSegmentParentageBreakVertex(e,t);const i=this.getNextVertex(e);s(i!==Su),this.isDiscontinuousSegmentParentage(i)&&this.setSegmentParentageBreakVertex(i,!0)}}_=!1}}while(0);_&&(e=this.getNextVertex(e)),t++}let n=this.getFirstVertex(i);for(let e=this.isClosedPath(i)?n:this.getLastVertex(i);this.getPathSize(i)>0;){const t=this.getPrevVertex(e);if(t===Su)break;{const s=this.getXY(t),o=this.getXY(e);let d=f.sqrDistance(s,o),g=!0;do{if(d<=a){if(m){const e=this.getSegment(t);if(null!==e){const t=e.calculateLength2D();if(d=t*t,d>a)break}}0===d?0===h&&(h=-1):h=1;const s=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!c&&(this.setGeometryModified(l,!0),c=!0),u&&t!==e&&(s||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),n===t&&(n=this.getFirstVertex(i)),g=!1}}while(0);if(g&&(e=this.getPrevVertex(e),e===n))break}}const d=this.getPathSize(i);let g=e&&d<(o?3:2);g&&o&&2===d&&m&&(g=!this.pathHasCurves(i)),g?(i=this.removePath(i),0===h&&(h=-1),r&&!c&&(this.setGeometryModified(l,!0),c=!0)):i=this.getNextPath(i)}}return h}filterClosePoints3D(t,e,i,n,r,o){return s(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==Su;e=this.getNextGeometry(e))if(d(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==Su;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===Su)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return s(0),!1}transferAllDataToTheVertex(t,e){const s=this.getVertexIndex(t),i=this.getVertexIndex(e);if(this.m_weights){const t=this.getWeightWithIndex(s);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(s);this.setRankWithIndex(i,t)}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(i,t)}for(let r=0,o=this.m_indices.length;r<o;r++)if(r!==this.m_selectionIndex&&null!==this.m_indices[r]){const s=this.getUserIndex(t,r);-1!==s&&this.setUserIndex(e,r,s)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,s,i,n,r){let o=0;const a=this.getNextVertex(t);a===Su&&e("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),u=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),d=this.m_bHasAttributes;d&&u&&(l=u.calculateLength2D());const g=this.getSegmentParentage(t),_=this.getHelperPoint();if(u){let t=0,e=0,r=Su;for(let p=0;p<i;p++){const i=s[p];if(t<i&&i<1){const s=u.cut(t,i);if(null!==n&&(p>0&&s.setStartXY(n[p-1]),s.setEndXY(n[p]),s.normalizeAfterEndpointChange(),e=p),d){const t=l>0?u.calculateSubLengthFromStart(i)/l:0;this.m_vertices.interpolateTwoVertices(h,m,t,_)}_.setXY(s.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,s),-1!==g&&this.setSegmentParentageAndBreak(r,g,!1),t=i}}if(r!==Su){const s=u.cut(t,1);null!==n&&(s.setStartXY(n[e]),s.normalizeAfterEndpointChange());const i=this.getVertexIndex(r);this.setSegmentToIndex(i,s)}}else{let t=0;for(let e=0;e<i;e++){const i=s[e];if(t<i&&i<1){this.m_vertices.interpolateTwoVertices(h,m,i,_);const t=this.insertVertex(c,a,_);o++,-1!==g&&this.setSegmentParentageAndBreak(t,g,!1)}t=i}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,s,i){this.getNextVertex(t)===Su&&e("");let n=t,r=!1;for(let e=0;e<s;++e){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(i);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==Su;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,i){return s(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByVal(s,e)}setPointOnlyEx(t,e,i,n){s(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new f(e,s),t,!1),n.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new f(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,i){s(0)}setXYZ(t,e,i){s(0)}setXYZCoords(t,e,i,n){s(0)}queryXYZ(t,e){s(0)}getXYZ(t){return s(0),Bt.getNAN()}getXYZWithIndex(t){return s(0),Bt.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){s(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,i,n){s(0)}setAttribute(t,e,i,n){s(0)}setAttributeInt(t,e,i,n){s(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return s(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return s(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=Qt(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=Qt(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return wu;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?wu:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?wu:this.m_ranks.read(t)}setRank(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_ranks){if(s)return;this.m_ranks=Ut(this.m_vertices.getPointCount(),wu)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,wu)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_ranks){if(s)return;this.m_ranks=Ut(this.m_vertices.getPointCount(),wu)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,wu)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=Qt(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=Qt(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return qu.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?qu.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?wu:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Ut(this.m_vertices.getPointCount(),wu)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,wu)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Ut(this.m_vertices.getPointCount(),wu)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,wu)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];if(s<i.size()){return i.read(s)}return-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(),e;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return s(t>=0&&t<=w()),t}createUserIndexUninitialized(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(!1),e;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Su;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){s(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===Su)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new hs({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,i=!1){return s(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return s(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===Su)return!1;const s=this.getPathSize(t);let i=e;for(let r=0;r<s;r++,i=this.getNextVertex(i)){const t=this.getSegment(i);if(null!==t&&t.getGeometryType()!==n.enumLine)return!0}return!1}insertPath(t,s){let i=Su;s!==Su?(t!==this.getGeometryFromPath(s)&&e(""),i=this.getPrevPath(s)):i=this.getLastPath(t);const n=this.newPath(t);return s!==Su&&this.setPrevPath(s,n),this.setNextPath(n,s),this.setPrevPath(n,i),i!==Su?this.setNextPath(i,n):this.setFirstPath(t,n),s===Su&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==Su?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Su?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==Su){let s=e;for(let e=0,n=this.getPathSize(t);e<n;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,Su),this.setPrevVertex(s,Su);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){s(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===Su)return 0;const s=this.getXY(e),i=new X(0),r=this.getPathSize(t);if(r>2){const t=s.clone(),n=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const m=f.getNAN();for(let e=2;e<r;e++,a=this.getNextVertex(a))this.queryXY(a,m),i.pe((m.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);i.pe((n-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<r;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===n.enumLine)continue;const s=2*e.calculateArea2DHelper();i.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let e=0;e<this.m_pathindices.length;e++)if(null===this.m_pathindices[e])return this.m_pathindices[e]=this.allocatePathIndex(),e;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Su;r=this.getNextPath(r)){const t=this.getPathIndex(r);t<n&&i.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,s,i){if(i===Su&&e(""),s===i)return;const n=this.getNextPath(i);let r=this.getPrevPath(i);const o=this.getGeometryFromPath(i);r===Su?this.setFirstPath(o,n):this.setNextPath(r,n),n===Su?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(i)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=s===Su?this.getLastPath(t):this.getPrevPath(s),this.setPrevPath(i,r),this.setNextPath(i,s),s===Su?this.setLastPath(t,i):this.setPrevPath(s,i),r===Su?this.setFirstPath(t,i):this.setNextPath(r,i),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(i)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(i,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,Su,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==Su&&this.setNextVertex(i,n);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:Su),n!==Su&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:Su);if(this.hasCurves()&&i!==Su&&n!==Su){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(t,e){s(t!==e);const i=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==Su&&this.setNextVertex(n,e);let o=this.getPathSize(i);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,Su),this.setNextVertex(r,Su);let h=0,m=t;const u=this.getFirstVertex(i);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(i,o>0?e:Su),this.setPathSize(i,o);const c=this.getGeometryFromPath(i);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,Su,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||a(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==Su;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==Su;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=Su){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=Su){let s=Su,i=Su,n=Su,r=Su,o=0,a=!1;for(s=e!==Su?e:this.getFirstGeometry();s!==Su;s=this.getNextGeometry(s))if(!t||d(this.getGeometryType(s))){for(i=this.getFirstPath(s);i!==Su;i=this.getNextPath(i))if(n=this.getFirstVertex(i),r=n,o=0,n!==Su){a=!0;break}if(a||e!==Su)break}return a||(s=Su),Iu.create_(this,s,i,n,r,o,t,!1,e!==Su)}queryVertexIteratorOnSelection(t=Su){return this.m_selection?Iu.create_(this,t,Su,Su,Su,-1,!1,!0,t!==Su):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){s(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=Su,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return s(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){return s(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===Su)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return s(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==Su?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Su?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,Su),this.setLastVertex(t,Su),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,Su);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return s(0),0}findVertex3D(t,e,i){return s(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);s!==Su&&this.setNextVertex(s,i),i!==Su&&this.setPrevVertex(i,s);if(this.hasCurves()&&s!==Su&&i!==Su){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){s(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new Au(this))}sortVerticesSimpleByX(t,e,i){s(0)}sortVerticesSimpleByY3D(t,e,i){s(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==Su&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==Su&&this.replaceCurveWithLine(t);const i=new f;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(s(e<=N()>>1),e<<=1,e|=i?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(s(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){s(e<=N()>>1),e<<=1;e|=this.getSegmentParentageBreakVertex(t)?1:0}this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new Nu(e)}return new Nu(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=N()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===Su)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function Mu(t){if(t.isEmpty())return new nm({vd:t.getDescription()});const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new hs({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new hs,s=new Rh({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const i=e.getAttributeStreamRef(0),n=new Lu({stream:i,n:s});let r=0,o=1;const a=i.readPoint2D(r<<1),h=new f;for(;o<s&&i.queryPoint2D(o<<1,h).equals(a);)o++;if(n.m_treeHull.addElement(r),o<s){n.m_treeHull.addBiggestElement(o);const t=new f;for(let s=o+1;s<e.getPointCount();s++){i.queryPoint2D(s<<1,t);const e=n.treeHull(t);-1!==e&&n.m_treeHull.setElement(e,s)}}const m=e.getDescription(),u=m.getAttributeCount()>1,l=n.m_treeHull.size();let c=null;if(l>=2){c=l>=3?new nm({vd:m}):new Rh({vd:m});const t=c.getImpl();t.reserve(n.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new f;for(let r=n.m_treeHull.getFirst();-1!==r;r=n.m_treeHull.getNext(r))if(u){const s=new hs;e.getPointByVal(n.m_treeHull.getElement(r),s),t.insertPoint(0,-1,s)}else i.queryPoint2D(n.m_treeHull.getElement(r)<<1,s),t.insertPoint2D(0,-1,s)}else if(u){const t=new hs({vd:m});e.getPointByVal(n.m_treeHull.getElement(n.m_treeHull.getFirst()),t),c=t}else{const t=i.readPoint2D(n.m_treeHull.getElement(n.m_treeHull.getFirst())<<1);c=new hs(t)}return c}function Yu(t,e,i){if(e<=262144)return Bu(t,e,i);s(0);const n=new Lu({points:t,n:e}),r=0;let o=1;const a=t[r].clone();for(;o<e&&t[o].equals(a);)o++;if(n.m_treeHull.addElement(r),o<e){n.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],i=n.treeHull(e);-1!==i&&n.m_treeHull.setElement(i,s)}}let h=0;for(let s=n.m_treeHull.getFirst();-1!==s;s=n.m_treeHull.getNext(s))i[h++]=n.m_treeHull.getElement(s);return h}function Xu(t,e,s){const i=t.getImpl(),n=i.getPathStart(e),r=i.getPathEnd(e),o=!i.isClosedPath(e)&&i.isClosedPathInXYPlane(e),a=i.getAttributeStreamRef(0),h=2*n;let m=2*r;if(o&&(m-=2),m-h<6)return!0;const u=a.readPoint2D(h),l=a.readPoint2D(h+2),c=a.readPoint2D(h+4);if(!ku(f.orientationRobust(l,c,u)))return!1;const d=l.clone(),g=new f;for(let _=h+6;_<m;_+=2){g.assign(l),l.assign(c),a.queryPoint2D(_,c);if(!ku(f.orientationRobust(l,c,u)))return!1;if(!ku(f.orientationRobust(d,c,u)))return!1;if(!ku(f.orientationRobust(l,c,g)))return!1}return!0}function Fu(t,e,s,i,r){if(s.setNAN(),i.setCoords(1,0),r.setCoords(0,0),t.isEmpty())return;if(t.getGeometryType()===n.enumPoint)return void s.assign(t.getXY());const o=t,a=o.getPointCount();if(2===a){const t=o.getXY(0),e=o.getXY(1);s.assign(t.add(e).mul(.5));const n=e.sub(t);i=Wu(n),r.setCoords(.5*n.length(),0)}else{let t=Number.MAX_VALUE;const n=[0,1,0,0],h=new bt(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);n[0]<a;++n[0],ju(h,0,a)){n[1]===n[0]&&(++n[1],ju(h,1,a));for(let t=1;;++t){for(;;){const e=Zu(o.getXY(h.get(0,0)),o.getXY(h.get(0,1)),o.getXY(h.get(t,0)),o.getXY(h.get(t,1)),2^t);if(e>0)break;if(++n[t],ju(h,t,a),0===e)break}if(3===t)break;n[t+1]<n[t]&&(n[t+1]=n[t],h.set(t+1,0,h.get(t,0)),h.set(t+1,1,h.get(t,1)))}const m=o.getXY(h.get(0,0)).add(o.getXY(h.get(2,0))).mul(.5),u=Wu(o.getXY(h.get(0,1)).sub(o.getXY(h.get(0,0)))),l=new f;let c,d;if(l.x=Math.max(0,u.dotProduct(o.getXY(h.get(1,0)).sub(o.getXY(h.get(3,0))))),l.y=Math.max(0,u.crossProduct(o.getXY(h.get(0,0)).sub(o.getXY(h.get(2,0))))),e?(c=l.x*l.y,d=c<t):(c=l.y,d=c<t),d){t=c;const e=o.getXY(h.get(1,0)),n=o.getXY(h.get(3,0)),a=e.add(n).mul(.5).sub(m);s.assign(m.add(u.mul(u.dotProduct(a)))),i.assign(u),r.assign(l)}}r.mulThis(.5),r.x<r.y&&(r.y=S(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}qu.st_defaultRank=1;class Ru{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,s(0),this.m_convexHull=t,this.m_function=this.done_}next(){return s(0),!1}get_vertex_handle_p(){return s(0),0}get_vertex_handle_q(){return s(0),0}get_current_support(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}intialize_(){return s(0),!1}increment_(){return s(0),!1}increment_q_(){return s(0),!1}increment_p_(){return s(0),!1}parallel_edge_with_q_support_(){return s(0),!1}parallel_edge_with_p_support_(){return s(0),!1}done_(){return s(0),!1}}class Lu{nullGetXY(t){return a("m_getXY is null"),{}}nullDeleteNode(t){a("m_deleteNode is null")}constructor(t){return this.m_treeHull=new ve,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=Su,void(this.m_pathHandle=Su)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=Su,void(this.m_pathHandle=Su)):void o("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new qu,this.m_geometryHandle=this.m_shape.createGeometry(n.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,Su),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return s(0),new f}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){s(0)}addGeometry(t){if(t.isEmpty())return;const s=t.getGeometryType();if(s===n.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else h(s)?this.addMultiVertexGeometry(t):m(s)?this.addSegment(t):s===n.enumEnvelope?this.addEnvelope(t):s===n.enumPoint?this.addPoint(t):e("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new hs,e=this.m_treeHull.getFirst(),s=new nm({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return s(0),new Ru(this)}getXY(t){return s(0),new f}getXYWithIndex(t){return s(0),new f}getFirst(){return s(0),0}getLast(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}getVertexIndex(t){return s(0),0}getPointCount(){return s(0),0}addMultiVertexGeometry(t){const e=new hs,s=t.getImpl(),i=new f;for(let n=0;n<t.getPointCount();n++){s.queryXY(n,i);const r=this.addPoint2D(i);if(-1!==r){t.getPointByVal(n,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}addEnvelope(t){const e=new hs;for(let s=0;s<4;s++){const i=new f;t.queryCorner(s,i);const n=this.addPoint2D(i);if(-1!==n){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}addSegment(t){const e=new hs,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const n=t.getEndXY(),r=this.addPoint2D(n);if(-1!==r){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),n=this.m_treeHull.getElement(s),r=this.m_treeHull.getElement(i),o=this.m_getXY(n),a=this.m_getXY(r),h=f.orientationRobust(a,t,o);if(ku(h)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(Gu(h)){let n=this.m_treeHull.getRoot(),r=this.m_treeHull.getFirst(),a=this.m_treeHull.getLast(),h=-1,m=-1,u=-1;for(;r!==this.m_treeHull.getPrev(a);){m=this.m_treeHull.getElement(n);const e=this.m_getXY(m);Gu(f.orientationRobust(e,t,o))?(a=n,n=this.m_treeHull.getLeft(n)):(r=n,n=this.m_treeHull.getRight(n))}n=a,h=r,m=this.m_treeHull.getElement(n),u=this.m_treeHull.getElement(h);const l=this.m_getXY(m),c=this.m_getXY(u);if(h!==s){if(!ku(f.orientationRobust(c,t,l)))break}e=this.m_treeHull.addElementAtPosition(h,n,-2,!0,!1),this.treeHullWalkForward(t,n,i),this.treeHullWalkBackward(t,h,s);break}{const n=Hu(t,a,o);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),r=this.m_treeHull.getNext(i);const o=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(ku(f.orientationRobust(s,t,o)))break;const a=i;i=r,n=e,o.assign(s),r=this.m_treeHull.getNext(i),this.m_deleteNode(a)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),r=this.m_treeHull.getPrev(i);const o=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(ku(f.orientationRobust(o,t,s)))break;const a=i;i=r,n=e,o.assign(s),r=this.m_treeHull.getPrev(i),this.m_deleteNode(a)}return i}}function zu(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:f.orientationRobust(t,e,s)}function Vu(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:f.orientationRobust(t,e,s)}function Bu(t,e,s){const i=new Jt(0);for(let a=0;a<e;a++)i.add(a);const n={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};ge.sortEx(i,0,e,n);let r=0;t:for(let a=0;a<e;++a){const e=i.read(a);for(;r>=2;){const n=s[r-2],o=s[r-1];if(t[o].equals(t[e])){i.write(a,-1);continue t}if(!(zu(t[n],t[o],t[e])>=0)){o===i.read(a-1)&&i.write(a-1,-1);break}r--}s[r++]=e,2===r&&t[e].equals(t[s[0]])&&(i.write(1,-1),r--)}const o=r+1;t:for(let a=e-2;a>=0;--a){const e=i.read(a);if(!(e<0)){for(;r>=o;){const i=s[r-2],n=s[r-1];if(t[n].equals(t[e]))continue t;if(!(Vu(t[i],t[n],t[e])>=0))break;r--}if(0!==a){const i=s[r-1];s[r++]=e,t[e].equals(t[i])&&r--}}}return r>1&&t[s[0]].equals(t[s[r-1]])&&r--,r}function ku(t){return t<0}function Gu(t){return t>0}function Hu(t,e,s){let i=-1;if(e.y===s.y)i=0;else if(e.x===s.x)i=1;else{i=Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1}let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Wu(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function ju(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Zu(t,s,i,n,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:s.negateThis(),t.negateThis();break;case 3:s.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:e("")}return f.orientationRobustEx(t,s,i,n)}function Uu(t,e,s,i,n){return Ou(t,!1,e,s,i,n)}function Ou(t,e,s,i,r,o){const h=s.getGeometryType(),m=i.getGeometryType(),u=Math.max(r,ei(s,i));if(h===n.enumLine&&m===n.enumLine)return xi(s,i,u,o);let l=s,c=i,d=s.getStartXY(),g=s.getEndXY();if(d.compare(g)>0&&(l=s.clone().reverse()),d=i.getStartXY(),g=i.getEndXY(),d.compare(g)>0&&(c=i.clone().reverse()),e){if(s.equals(i))return 2;if(zs(s,i,u))return 4}switch(h){case n.enumLine:switch(m){case n.enumEllipticArc:return du(t,c,l,u,o);case n.enumBezier:return th(t,c,l,u,o);case n.enumRationalBezier2:return zr(t,c,l,u,o);case n.enumBezier2:return Ho(t,c,l,u,o);default:a("")}break;case n.enumEllipticArc:switch(m){case n.enumLine:return du(t,l,c,u,o);case n.enumEllipticArc:return gu(t,l,c,u,o);case n.enumBezier:return eh(t,c,l,u,o);case n.enumRationalBezier2:return Vr(t,c,l,u,o);case n.enumBezier2:return Wo(t,c,l,u,o);default:a("")}break;case n.enumBezier:switch(m){case n.enumLine:return th(t,l,c,u,o);case n.enumEllipticArc:return eh(t,l,c,u,o);case n.enumBezier:return sh(t,l,c,u,o);case n.enumRationalBezier2:return ih(t,l,c,u,o);case n.enumBezier2:return nh(t,l,c,u,o);default:a("")}break;case n.enumRationalBezier2:switch(m){case n.enumLine:return zr(t,l,c,u,o);case n.enumEllipticArc:return Vr(t,l,c,u,o);case n.enumBezier:return ih(t,c,l,u,o);case n.enumRationalBezier2:return kr(t,l,c,u,o);case n.enumBezier2:return Gr(t,l,c,u,o);default:a("")}break;case n.enumBezier2:switch(m){case n.enumLine:return Ho(t,l,c,u,o);case n.enumEllipticArc:return Wo(t,l,c,u,o);case n.enumBezier:return nh(t,c,l,u,o);case n.enumRationalBezier2:return Gr(t,c,l,u,o);case n.enumBezier2:return jo(t,l,c,u,o);default:a("")}break;default:a("")}}function Qu(t,e,s=!0){if(!s&&!Ku(t,e))return 0;const i=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===n.enumEllipticArc){return Pu(t,e,!1)?s:0}if(r===n.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===n.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===n.enumEllipticArc){return Pu(t,e,!0)?s:-1}if(r===n.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===n.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function Ku(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==n.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function $u(t,s,i,r,o,h,m){!o&&h&&e("");const u=s.getGeometryType(),l=i.getGeometryType(),c=Math.max(m,ei(s,i));if(r&&(r.length=0),o&&(o.length=0),h&&(h.length=0),u===n.enumLine&&l===n.enumLine)return yi(s,i,r,o,h,c,!1,!1);let d=s,g=i,_=s.getStartXY(),p=s.getEndXY(),f=!1,x=!1;_.compare(p)>0&&(d=s.clone(!0).reverse(),f=!0),_=i.getStartXY(),p=i.getEndXY(),_.compare(p)>0&&(g=i.clone(!0).reverse(),x=!0);let y=0;switch(u){case n.enumLine:switch(l){case n.enumEllipticArc:y=_u(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier:y=rh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Hr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Zo(t,g,d,r,h,o,c,!1,!1,!0);break;default:a("")}break;case n.enumEllipticArc:switch(l){case n.enumLine:y=_u(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=pu(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=oh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Wr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Uo(t,g,d,r,h,o,c,!1,!1,!0);break;default:a("")}break;case n.enumRationalBezier2:switch(l){case n.enumLine:y=Hr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=Wr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=hh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=jr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier2:y=Zr(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;case n.enumBezier2:switch(l){case n.enumLine:y=Zo(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=Uo(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=mh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Zr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Oo(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;case n.enumBezier:switch(l){case n.enumLine:y=rh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=oh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=ah(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumRationalBezier2:y=hh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier2:y=mh(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;default:a("")}if(f){if(o){for(let t=0;t<y;t++)o[t]=1-o[t];o.reverse()}r&&r.reverse(),h&&h.reverse()}if(x&&h)for(let e=0;e<y;e++)h[e]=1-h[e];return y}function Ju(t,e,s){if(e===s)return 0;e>s&&(s=S(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function tl(t,e,s,i,n){const r=[],o=[],a=[];for(let m=0,u=n;m<u;m++)r.push(t.calculateSubLengthFromStart(s[m])),o.push(e.calculateSubLengthFromStart(i[m])),G(s[m],0,1)&&G(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&a.push(m);if(0===a.length||a.length===n)return;a.sort(((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0));let h=-1;for(const m of a){if(h>=0&&s[m]===s[h]&&s[m]===s[h]){h=m;continue}h=m;const a=[];a.length=n;for(let t=0;t<a.length;++t)a[t]=t;a.sort(((t,e)=>{const s=r[m],i=o[m],n=r[t]-s,a=o[t]-i,h=n*n+a*a,u=r[e]-s,l=o[e]-i,c=u*u+l*l;return h<c?-1:h>c?1:0}));for(let r=0;r<n;r++){const n=a[r];if(n===m||s[n]===s[m]&&i[n]===i[m]||G(s[n],0,1)&&G(i[n],0,1))continue;const o=(s,i,n,r)=>{const o=new Ns,a=new V;a.setWithEps(1);const h=new V;h.set(i,a.eps()),t.queryCoord2DE(h,o);const m=new Ns;t.queryCoord2DE(new V(s),m);let u=!1;return o.eq(m)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new V(n),m),u=o.eq(m)),!u},h=f.getNAN();t.queryCoord2D(s[n],h);const u=f.getNAN();e.queryCoord2D(i[n],u);if(0===f.distance(h,u)&&o(s[m],s[n],i[m],i[n]))break;const l=new D(i[n],i[m]);l.normalizeNoNAN();const c=new D(s[n],s[m]);c.normalizeNoNAN();let d=-1,g=Number.POSITIVE_INFINITY,_=Number.POSITIVE_INFINITY,p=s[n];h.assign(t.getCoord2D(p));for(let r=0;r<5;r++){const r=e.getClosestCoordinateOnInterval(h,l,-1);u.assign(e.getCoord2D(r));const a=f.distance(h,u);if(p=t.getClosestCoordinateOnInterval(u,c,-1),p===s[m]&&r===i[m]){d=1;break}h.assign(t.getCoord2D(p));const x=f.distance(u,h);if(!(x<_&&a<g)){d=0;break}if(0===x&&0===a){o(s[m],s[n],i[m],i[n])?(s[n]=p,i[n]=r,d=0):d=1;break}_=x,g=a}if(-1===d&&(d=G(s[n],0,1)||G(i[n],0,1)?0:1),1!==d)break;s[n]=s[m],i[n]=i[m]}}}function el(t,e,s,i,n,r,o,a,h,m,u,l,c){if(!r)return 0;const d=(t,e)=>{for(let s=0;s<r;++s){let i=e[s];if(G(i,0,1)){i=At(i);continue}const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&Ju(t,0,i)<=ti(t)&&(e[s]=0):n.equals(t.getEndXY())&&Ju(t,i,1)<=ti(t)&&(e[s]=1)}};d(e,i),d(s,n),tl(e,s,i,n,r);const g=[];for(let f=0,x=r;f<x;f++)g.push(f);const _=(t,e)=>c?Tt(n[t],i[t],n[e],i[e]):Tt(i[t],n[t],i[e],n[e]);if(g.length>1){g.sort(_);const t=Math.max(ti(e),ti(s));let r=0;for(let o=1,a=g.length;o<a;o++){const a=i[g[r]],h=i[g[o]],m=n[g[r]],u=n[g[o]];if(a!==h||m!==u)if(!(Ju(e,a,h)<=t&&Ju(s,m,u)<=t)||G(a,0,1)&&G(m,0,1)||G(h,0,1)&&G(u,0,1))r++,g[r]=g[o];else{const t=f.distance(e.getCoord2D(a),s.getCoord2D(m)),i=f.distance(e.getCoord2D(h),s.getCoord2D(u));if(t<=i)continue;if(i<t){g[r]=g[o];continue}}}if(g.length=r+1,1===g.length&&0!==g[0]&&(i[0]=i[g[0]],n[0]=n[g[0]],g[0]=0),g.length>2){const t=D.constructEmpty(),r=D.constructEmpty();t.setCoords(i[g[0]],i[g.at(-1)]),r.setCoords(n[g[0]],n[g.at(-1)]);let o=!0;for(let e=1,s=g.length-1;e<s;e++)if(!t.containsCoordinate(i[g[e]])||!r.containsCoordinate(n[g[e]])){o=!1;break}if(o){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let a=j(t.vmin,t.vmax,i[n]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,m)){o=!1;break}a=j(r.vmin,r.vmax,i[n]);const u=s.getCoord2D(a);if(!e.isCloserThanDistance(u,t,m)){o=!1;break}}}o&&(g[1]=g.at(-1),g.length=2)}}if(1===g.length&&t){const t=0,r=0;Ls(e,s,i[0],n[0],m,1,[t],[r])&&(g.push(1),i[1]=t,n[1]=r,g.sort(_))}if(u&&1===g.length){let t=!0;for(let r=0,o=g.length;r<o;r++){if(G(i[g[r]],0,1)&&G(n[g[r]],0,1)){if(0===f.distance(e.getCoord2D(i[g[r]]),s.getCoord2D(n[g[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let x=0,y=g.length;x<y;x++){if(a&&a.push(i[g[x]]),h&&h.push(n[g[x]]),o){const t=f.getNAN();e.queryCoord2D(i[g[x]],t),o.push(t)}p++}return p}function sl(t,e,s,i,n,r,o,a,h){if(G(s,0,1)&&G(i,0,1)){if(0===f.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new Ns,l=Number.EPSILON;if(t.queryDerivative(new V(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new V(s,l).add(e),u)}1===s&&u.negateThis();const c=new Ns;if(e.queryDerivative(new V(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new V(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const d=u.dotProduct(c),g=u.crossProduct(c);g.scaleError(3);const _=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(gt)&&(g.isZero()||Math.abs(g.value())<_())){return Rs(t,e,s,i,n,r,o,a)}}}return 0}function il(t,e,i,n,r){let o=-1,a=-1,h=-1,m=-1;{const s=[0,e],r=[e,0],u=[0,n],l=[n,0];for(let e=0;e<2&&-1===o;++e)for(let n=0;n<2;++n)if(t[s[e]].equals(i[u[n]])){o=s[e],a=r[e],h=u[n],m=l[n];break}}if(-1===o){const s=new Ds;s.setFromPoints(t,e+1);const o=new Ds;return o.setFromPoints(i,n+1),o.inflate(r),s.isIntersectingW(o)?-1:0}{const u=new Array(e+1),l=Yu(t,e+1,u);s(l>1);let c=0,d=0;for(let t=0;t<l;++t)o===u[t]&&(d=t,c++),a===u[t]&&c++;if(2!==c)return-1;const g=new Array(n+1),_=Yu(i,n+1,g);s(_>1),c=0;let p=0;for(let t=0;t<_;++t)h===g[t]&&(p=t,c++),m===g[t]&&c++;if(2!==c)return-1;const x=t[u[(d+l-1)%l]],y=t[u[(d+1)%l]],P=i[g[(p+_-1)%_]],v=i[g[(p+1)%_]],C=t[o],b=[x,y,P,v],E=[0,1,2,3];E.sort(((t,e)=>f.compareVectorsOrigin(C,b[t],b[e])));let D=E[0];for(let t=1;t<4;t++){if(E[t]!==(D+1)%4)return-1;D=E[t]}{const t=x.sub(C),e=v.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}{const t=y.sub(C),e=P.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}return 1}}var nl=Vt;class rl extends ai{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return s(0),0}calculateUpperLength3D(){return s(0),0}changeEndPoints3D(t,e){s(0)}getClosestCoordinate3D(t,e,i){return s(0),0}getBoundary(){return Vh(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?ui(this,t):li(this,t);const i=nl.getInterpolation(e),n=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return z(i,n,r,t,nl.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){s(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return rl.type}queryEnvelope(e){if(4===e.m_EnvelopeType){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=qt.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=nl.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else 2===e.m_EnvelopeType?e.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===e.m_EnvelopeType?(e.setEmpty(),e.mergeCoords(this.m_XStart,this.m_YStart,Qs(this,0,1,0)),e.mergeCoords(this.m_XEnd,this.m_YEnd,Qs(this,1,1,0))):t("env type not impl")}applyTransformation(t){s(t instanceof k);const e=new f;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new rl({vd:this.m_description})}calculateLength2D(){return Math.sqrt(wi(this))}calculateLength3D(t){return s(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryCoord2D(t,e){return hi(this,t,e)}queryCoord3D(t,e){s(0)}getCoordZ(t){return ci(this,t)}queryCoord2DE(t,e){gi(this,t,e)}getCoordX(t){return ui(this,t)}getCoordY(t){return li(this,t)}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const r=f.getNAN();if(hi(this,t,r),n.setStartXYCoords(r.x,r.y),hi(this,e,r),n.setEndXYCoords(r.x,r.y),!i)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),i=nl.getComponentCount(s);for(let r=0;r<i;r++){const i=this.getAttributeAsDbl(t,s,r);n.setStartAttribute(s,r,i);const o=this.getAttributeAsDbl(e,s,r);n.setEndAttribute(s,r,o)}}}queryDerivative(t,e){di(this,t,e)}getClosestCoordinate(t,e){return f.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new f;this.queryCoord2D(e.vmin,i);const n=new f;this.queryCoord2D(e.vmax,n);const r=f.getClosestCoordinate(i,n,t,!1);return ri.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=ui(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new rl;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new f;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=f.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new f;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return bi(this,t,e,s)>=0}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,s){return s&&(t<2&&e(""),s[0]=0,s[1]=1),2}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=ui(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=li(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(e,s){if(2===s.m_EnvelopeType){let t=y(e.vmin,0,1);const i=new f;return this.queryCoord2D(t,i),s.setCoords({pt:i}),t=y(e.vmax,0,1),this.queryCoord2D(t,i),void s.mergeNe(i)}t("3d dst not impl")}orientBottomUp(){fi(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return pi(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(t,e){_i(this,t[0],t[e-1])}writeInBufferStream(t,e){return s(0),0}readFromBufferStream(t,e){s(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){_i(this,t,e)}static isIntersectingLineLine(t,e,s,i){return xi(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return xi(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&i("");const n=bi(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}}rl.type=n.enumLine;class ol{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new rl,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):a("bad constructor params"))}assignCopy(t){return t instanceof ol?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof ol){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:a("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){s(0)}createImpl(t){switch(t){case n.enumLine:1&this.m_mask||(this.m_lineBuffer=new rl,this.m_mask|=1,this.m_active=1);break;case n.enumEllipticArc:2&this.m_mask||(this.m_curves=new $h,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case n.enumBezier:4&this.m_mask||(this.m_curves=new da,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case n.enumBezier2:8&this.m_mask||(this.m_curves=new an,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case n.enumRationalBezier2:16&this.m_mask||(this.m_curves=new mn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:e("")}}create(t){t===n.enumLine?this.createLine():t===n.enumEllipticArc?this.createEllipticArc():t===n.enumBezier?this.createCubicBezier():t===n.enumRationalBezier2?this.createQuadraticRationalBezier():t===n.enumBezier2?this.createQuadraticBezier():e("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){s(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(n.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(n.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(n.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(n.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(n.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&a("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():a("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(e){return e instanceof ol?this===e||(this.empty()?e.empty():!e.empty()&&this.get().equals(e.get())):(t("seg comparison not yet impl"),!1)}}export{Ci as $,Jt as A,ge as B,Ae as C,um as D,cs as E,Ni as F,qe as G,_s as H,Ce as I,Ve as J,Ne as K,rl as L,Es as M,Ze as N,jh as O,hs as P,Bt as Q,Vh as R,ol as S,ve as T,ys as U,Vt as V,fs as W,Xu as X,Fu as Y,Lu as Z,Mu as _,qt as a,Ts as a0,tm as a1,Jh as a2,$h as a3,wu as a4,om as a5,Li as a6,Fi as a7,ka as a8,ps as a9,Ot as aA,Ye as aB,Wt as aC,nu as aD,Um as aE,Dm as aF,Xi as aG,jt as aH,Te as aI,zh as aJ,os as aK,Be as aL,qi as aM,ns as aN,Ke as aO,Je as aP,ts as aQ,$e as aR,Qh as aS,Zh as aT,xa as aa,Bn as ab,is as ac,am as ad,mm as ae,da as af,mn as ag,io as ah,hu as ai,ri as aj,$u as ak,Iu as al,Ou as am,ti as an,un as ao,Ns as ap,Nm as aq,fi as ar,Qu as as,Ku as at,sl as au,Nu as av,iu as aw,Qt as ax,Me as ay,Ut as az,qu as b,Fe as c,rm as d,kt as e,Re as f,nm as g,Rh as h,je as i,Oe as j,Ge as k,Se as l,We as m,Su as n,Qe as o,Is as p,_e as q,ee as r,Gt as s,ze as t,He as u,Le as v,Uu as w,$t as x,Ue as y,Pe as z};
|
|
5
|
+
import{a as t,t as e,g as s,w as i,G as n,y as r,u as o,b as a,i as h,e as m,z as u,h as l,A as c,f as d,o as g,q as _,p}from"./Geometry.js";import{P as f,m as x,l as y,O as P,Q as v,e as C,R as b,x as E,E as D,b as S,o as w,D as A,U as T,V as I,j as N,a as q,W as M,X as Y,K as X,Y as F,Z as R,_ as L,$ as z,H as V,a0 as B,T as k,a1 as G,a2 as H,a3 as W,w as j,M as Z,F as U,a4 as O,B as Q,a5 as K,a6 as $,a7 as J,a8 as tt,a9 as et,aa as st,ab as it,ac as nt,q as rt,ad as ot,ae as at,af as ht,ag as mt,ah as ut,n as lt,s as ct,ai as dt,C as gt,aj as _t,ak as pt,al as ft,d as xt,am as yt,an as Pt,r as vt,ao as Ct,ap as bt,aq as Et,v as Dt,ar as St,as as wt,at as At,au as Tt,av as It}from"./Transformation2D.js";import{G as Nt}from"./SimpleGeometryCursor.js";class qt{static construct(t,e,s,i){return new qt(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax),this.normalize()}static constructEmpty(){return new qt(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new qt(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return f.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(e){void 0!==e.xmin?(this.xmin=e.xmin,this.xmax=e.xmax,this.ymin=e.ymin,this.ymax=e.ymax):void 0!==e.x?(this.xmin=e.x,this.xmax=e.x,this.ymin=e.y,this.ymax=e.y):void 0!==e.pt1?(this.xmin=e.pt1.x,this.ymin=e.pt1.y,this.xmax=e.pt2.x,this.ymax=e.pt2.y,this.normalize()):void 0!==e.env2D?(this.xmin=e.env2D.xmin,this.xmax=e.env2D.xmax,this.ymin=e.env2D.ymin,this.ymax=e.env2D.ymax,this.normalize()):void 0!==e.pt?(this.xmin=e.pt.x,this.xmax=e.pt.x,this.ymin=e.pt.y,this.ymax=e.pt.y):void 0!==e.center?(this.xmin=e.center.x-.5*e.width,this.xmax=this.xmin+e.width,this.ymin=e.center.y-.5*e.height,this.ymax=this.ymin+e.height,this.normalize()):t("unrecognized input type for setCoords"),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0===e)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let i=1,n=2*e;i<n;i+=2){if(!this.isEmpty()){for(let t=i,n=2*e;t<n;t+=2)this.mergeNeCoords(s[t],s[t+1]);return}this.setCoords({x:s[i],y:s[i+1]}),i+=2}}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new f(this.xmin,this.ymin)}getLowerRight(){return new f(this.xmax,this.ymin)}getUpperLeft(){return new f(this.xmin,this.ymax)}getUpperRight(){return new f(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new f(this.xmin,this.ymin);case 1:return new f(this.xmin,this.ymax);case 2:return new f(this.xmax,this.ymax);default:return new f(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,r=e.y-t.y;if(Math.abs(n)>Math.abs(r)?s&qt.XMASK?(s&qt.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&qt.XMASK?(i&qt.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&qt.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):(i&qt.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s&qt.YMASK?(s&qt.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):i&qt.YMASK?(i&qt.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s?(s&qt.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&qt.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),n=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=f.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),n=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=f.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),n=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),r=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}{const s=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=f.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),n=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),r=f.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),o=Math.max(s,i),a=Math.max(n,r),h=Math.max(o,a);e=Math.min(h,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=x(f,4);this.queryCorners(s);const i=x(f,4);t.queryCorners(i);for(let n=0;n<4;n++)for(let t=0;t<4;t++){const r=f.sqrDistance(s[n],i[t]);r>e&&(e=r)}return e}sqrMaxMinDistance(t){const e=f.sqrDistance(t,this.getLowerLeft()),s=f.sqrDistance(t,this.getUpperLeft()),i=f.sqrDistance(t,this.getLowerRight()),n=f.sqrDistance(t,this.getUpperRight());let r,o=Math.max(e,s);return r=Math.max(e,i),o>r&&(o=r),r=Math.max(s,n),o>r&&(o=r),r=Math.max(i,n),o>r&&(o=r),o}sqrMinDistance(t){if(this.contains(t))return 0;return this.sqrDistance(t)}sqrMaxDistance(t){let e=f.sqrDistance(t,this.getLowerLeft());return e=Math.max(f.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(f.sqrDistance(t,this.getUpperRight()),e),e=Math.max(f.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=y(t.x,this.xmin,this.xmax),s=y(t.y,this.ymin,this.ymax);return f.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new f;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}querySide(t,s){switch(t){case 0:s.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:s.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:s.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:s.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:e("query_side")}return s}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){if(this.isEmpty())return P();return(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*P()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}qt.XLESSXMIN=1,qt.YLESSYMIN=4,qt.XMASK=3,qt.YMASK=12;const Mt=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],Yt=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],Xt=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],Ft=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],Rt=[4,8,4,8,1],Lt=25;function zt(){return new Array(Lt)}let Vt=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return Xt[t]}static getPersistence(t){return Ft[t]}static getPersistenceSize(t){return Rt[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return Yt[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return Mt[t]}static isDefaultValue(t,e){return v(Mt[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=new Array(Lt),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=14;for(;s<n;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let r=0;for(s=0,n=this.getAttributeCount();s<n;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=r;for(let t=0;t<i;t++)this.m_defaultPointAttributes[r]=n,r++}}};class Bt{static construct(t,e,s){return new Bt(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new Bt(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new Bt;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return s(0),0}static sqrDistance(t,e){return C(t.x-e.x)+C(t.y-e.y)+C(t.z-e.z)}static sqrDistanceCoords(t,e,s,i,n,r){return C(t-i)+C(e-n)+C(s-r)}static distance(t,e){return Math.sqrt(Bt.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&b(this.z,t.z,e)}static compareByLength(t,e,i,n){return s(0),0}isEqualCoords(t,e,i,n){return s(0),this.x===t&&this.y===e&&this.z===i}isEqualsTols(t,e,i){return s(0),!1}isEqualCoordsTols(t,e,i,n,r){return s(0),!1}static st_isEqual(t,e,i,n){return s(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,i){return s(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}sub(t){return Bt.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return Bt.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new Bt(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}scaleZThis(t){return this.z*=t,this}setNAN(){return s(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return Bt.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return s(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return s(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return s(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,i,n=!1){return s(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return s(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return s(0),{}}static average(t,e){return s(0),{}}static size(){return Bt.dimensions}static lerp(t,e,s){const i=new Bt;return E(t,e,s,i),i}static slerp(t,e,i){return s(0),{}}static compareVectors(t,e){return s(0),0}static selectRightHandedBasisFromNormal(t,e,s){const i=t.getUnitVector(),n=i.createAPerpendicular(),r=new Bt;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new Bt(0,0,1)),this.crossProductVector(new Bt(1,0,0)),this.crossProductVector(new Bt(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce(((t,s,i)=>e[t]>e[i]?t:i),0)];return s.normalizeThis(),s}calculateAngle(t){return s(0),0}static crossDotSign(t,e,i){return s(0),0}static isBisectorRobust(t,e,i){return s(0),0}static compareZOrder(t,e){return s(0),!1}}Bt.dimensions=3;class kt{static constructEmpty(){return new kt(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,i){s(0)}getEnvelope2D(){return new qt(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new D(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=S(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=S(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=S(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}sqrDistanceEnvelope3DAndPoints(t,e,i,n=1){return s(0),0}sqrMaxDistance(t,e=1){return s(0),0}}const Gt=-559038737;var Ht=Vt;function Wt(t,s,i){switch(t){case 0:return new te(s,i);case 1:return new ee(s,i);case 2:return new Jt(s,i);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new $t(s,i);default:e("")}}function jt(t,e){const s=Ht.getComponentCount(t);return Wt(Ht.getPersistence(t),e*s,Ht.getDefaultValue(t))}function Zt(t,e){const s=Ht.getComponentCount(t);return Wt(Ht.getPersistence(t),e*s)}function Ut(t,e){return new Jt(t,e)}function Ot(t,e){return new $t(t,e)}function Qt(t,e){return new ee(t,e)}class Kt{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>Kt.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(t){return this.m_a[t]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,s,i){(s<0||i<0||i+s>this.size())&&e(),this.m_a.fill(t,s,s+i)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,i){if(this.getPersistence()!==t.getPersistence())return!1;return se(this,t,e,s,i)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,i,n,r,o,a){s(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;n&&this.checkResize(Math.max(0,a)+n),this.m_a.copyWithin(t+n,t,a>=0?a:m),this.m_a.set(h.readRange(i,n),t),r||this.reverseRange(t,n,o)}writeRange(t,i,n,r,o,a){s(this.getPersistence()===n.getPersistence());const h=n;if((t<0||i<0||r<0)&&e(),h.size()<r+i&&e(),0===i)return;this.size()<i+t&&this.resize(i+t);const m=h.m_a.subarray(r,r+i);ie(this.m_a,t,i,m)}insertAttributes(t,e,s,i){const n=Ht.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let r=0;r<n;r++)this.m_a[t+r]=e.getAttributeAsDbl(s,r)}insertAttributesFromPoints(t,e,i,n,r){s(Ht.getPersistence(n)===this.getPersistence());const o=Ht.getComponentCount(n),a=this.m_size;if(this.checkResize(Math.max(0,r)+o*i),this.m_a.copyWithin(t+o*i,t,r>=0?r:a),0===n){const s=new f;for(let n=t,r=0;r<i;r++,n+=2)e[r].queryXY(s),this.m_a[n]=s.x,this.m_a[n+1]=s.y}else if(1===o)for(let s=t,h=0;h<i;h++,s++)this.m_a[s]=e[h].getAttributeAsDbl(n,0);else for(let s=t,h=0;h<i;h++,s+=o)for(let t=0;t<o;t++)this.m_a[s+t]=e[h].getAttributeAsDbl(n,t)}eraseRange(t,s,i){this.m_size<t+s&&e(),this.m_a.copyWithin(t,t+s),this.m_size-=s}reverseRange(t,s,i){if((i<1||s%i!=0)&&e(),this.m_a.subarray(t,t+s).reverse(),i>1)for(let e=t,n=t+s;e<n;e+=i){let t=e,s=e+i-1;for(;t<s;){const e=this.m_a[t];this.m_a[t]=this.m_a[s],this.m_a[s]=e,t++,s--}}}rotate(t,e,s){(e<t||e>s||t>s)&&i("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,Kt.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}Kt.s_constructMin=2,Kt.s_resizeMin=30;class $t extends Kt{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new $t({ctor:Int8Array,copy:this})}restrictedClone(t){return new $t({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class Jt extends Kt{getPersistence(){return 2}clone(){return new Jt({ctor:Int32Array,copy:this})}restrictedClone(t){return new Jt({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){s(e<=w()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class te extends Kt{getPersistence(){return 0}clone(){return new te({ctor:Float32Array,copy:this})}restrictedClone(t){return new te({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class ee extends Kt{getPersistence(){return 1}getArray(){return this.m_a}applyTransformation(t,s,i){(1&s||s+2*i>this.size())&&e();const n=0===s?this.m_a:this.m_a.subarray(s);t.transformInterleavedPoints(n,i,n)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new f(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let a=s,h=t,m=0;m<i;++m,++a){const t=e[a];this.m_a[h++]=t.x,this.m_a[h++]=t.y}else for(let a=s+i-1,h=t,m=0;m<i;++m,--a){const t=e[a];this.m_a[h++]=t.x,this.m_a[h++]=t.y}}queryRange(t,s,i,n,r){if((t<0||s<0)&&e(),!n&&(r<=0||s%r!=0)&&e(),0===s)return;if(1===s)return void(i[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+s);i.set(o)}writeRangeFromArray(t,s,i,n,r){if((t<0||s<0)&&e(),0===s)return;if(1===s)return void(this.m_a[t]=i[0]);let o=i;s<i.length&&(o=i.subarray(0,s)),this.m_a.set(o,t)}clone(){return new ee({ctor:Float64Array,copy:this})}restrictedClone(t){return new ee({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}function se(t,e,s,i,n){if(t.getPersistence()!==e.getPersistence())return!1;const r=t.getPersistence()<=1,o=t.size(),a=e.size();if(i>o||i>a)return!1;if(n)if(r){for(let h=s;h<i;h++)if(!b(t.read(h),e.read(h),n))return!1}else for(let h=s;h<i;h++){let s=t.read(h)-e.read(h);if(s<0&&(s=-s),s>n)return!1}else for(let h=s;h<i;h++){const s=t.read(h),i=e.read(h);if(s!==i){if(r&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}function ie(t,s,i,n,r,o){if((s<0||i<0)&&e(),0===i)return;if(1===i)return void(t[s]=n[0]);let a=n;i<n.length&&(a=n.subarray(0,i)),t.set(a,s)}var ne=Vt;function re(){return new Array(14)}class oe{static getInstance(){return oe.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new ne(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new ne(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new ne(t);return this.m_map.set(t,s),s}}function ae(t){return oe.getInstance().FindOrAdd(t)}function he(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:ae(s)}function me(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:ae(s)}function ue(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:ae(s)}function le(){return oe.getInstance().GetVD2D()}function ce(){return oe.getInstance().GetVD3D()}function de(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}oe.s_thisInstance=new oe;class ge{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new Jt(0),this.m_bucketedIndices=new Jt(0)}static sortEx(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);(new ge).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let m=e;m<s;m++){const e=i.getValue(t.read(m));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let r=e;r<s;r++){const s=t.read(r),n=i.getValue(s),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let r=e;r<s;r++){const s=this.m_bucketedIndices.read(r-e),n=i.getValue(s),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let m=0,u=this.m_buckets.size();m<u;m++){const s=h;h=this.m_buckets.read(m),h>s&&i.userSort(e+s,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(ge.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}ge.c_maxBuckets=65536;class _e{constructor(t){this.m_buffer=null,this.m_firstFree=-1,this.m_last=0,this.m_size=0,this.m_capacity=0,this.m_bufferSize=0,this.m_stride=0,this.m_stride=t,this.m_realStride=t,this.m_blockSize=Math.trunc(_e.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>_e.st_blockPower][1+(t&_e.st_blockMask)]=_e.st_deadVertex,!0}deleteElement(t){(t>>_e.st_blockPower)*this.m_blockSize*this.m_realStride+(t&_e.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>_e.st_blockPower][t&_e.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>_e.st_blockPower][(t&_e.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>_e.st_blockPower][(t&_e.st_blockMask)+e]=s}getStride(){return this.m_stride}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.m_capacity){const t=0!==this.m_capacity?Math.trunc(2*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<_e.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>_e.st_blockPower][t&_e.st_blockMask];this.m_size++;const e=this.m_buffer[t>>_e.st_blockPower],s=t&_e.st_blockMask;for(let i=0;i<this.m_stride;i++)e[s+i]=-1;return t}elementToIndex(t){return(t>>_e.st_blockPower)*this.m_blockSize+(t&_e.st_blockMask)/this.m_realStride}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.m_size=0,t&&(this.m_buffer=null,this.m_capacity=0)}size(){return this.m_size}setCapacity(t){t>this.m_capacity&&this.grow(t)}capacity(){return this.m_capacity}swap(t,e){const s=this.m_buffer[t>>_e.st_blockPower],i=this.m_buffer[e>>_e.st_blockPower],n=t&_e.st_blockMask,r=e&_e.st_blockMask;for(let o=0;o<this.m_stride;o++){const t=s[n+o];s[n+o]=i[r+o],i[r+o]=t}}swapField(t,e,s){const i=this.m_buffer[t>>_e.st_blockPower],n=this.m_buffer[e>>_e.st_blockPower],r=(t&_e.st_blockMask)+s,o=(e&_e.st_blockMask)+s,a=i[r];i[r]=n[o],n[o]=a}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}ensureBufferBlocksCapacity(t){if(this.m_buffer.length<t){const e=new Array(t);for(let t=0;t<this.m_buffer.length;t++)e[t]=this.m_buffer[t];this.m_buffer=e}}grow(t){null===this.m_buffer&&(this.m_bufferSize=0,this.m_buffer=new Array(8));const e=Math.trunc((t+this.m_blockSize-1)/this.m_blockSize);if(this.ensureBufferBlocksCapacity(e),1===e){let e=0;const s=t*this.m_realStride;for(;s>_e.st_sizes[e];)e++;const i=new Int32Array(_e.st_sizes[e]);1===this.m_bufferSize?(i.set(this.m_buffer[0]),this.m_buffer[0]=i):(this.m_buffer[this.m_bufferSize]=i,this.m_bufferSize++),this.m_capacity=Math.trunc(i.length/this.m_realStride)}else{if(1===this.m_bufferSize&&this.m_buffer[0].length<_e.st_realBlockSize){const t=new Int32Array(_e.st_realBlockSize);t.set(this.m_buffer[0]),this.m_buffer[0]=t,this.m_capacity=this.m_blockSize}for(;this.m_bufferSize<e;)this.m_buffer[this.m_bufferSize++]=new Int32Array(_e.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}function pe(t,e){return{element:t,box:e.clone()}}_e.st_realBlockSize=16384,_e.st_blockMask=16383,_e.st_blockPower=14,_e.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],_e.st_deadVertex=-2125315821;class fe{constructor(t,e,s){this.m_extent=new qt,this.m_dataExtent=new qt,this.m_childExtents=[new qt,new qt,new qt,new qt],this.m_elementNodes=new _e(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new _e(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){s(0)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){s(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return s(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return s(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return s(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>fe.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new qt;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const n=s.length;for(let r=0;r<n;r++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const i=new qt;i.setCoords({env2D:t}),i.inflateCoords(e,e);const n=[],r=[];n.push(this.m_root),r.push(this.m_extent.clone());const o=x(qt,4);let a=0;for(;n.length>0;){let t=!1;const e=n.at(-1),h=r.at(-1);if(n.pop(),r.pop(),i.containsEnvelope(h)){if(a+=this.getSubTreeElementCount(e),s>0&&a>=s)return s}else if(i.isIntersecting(h)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(i)&&(a++,s>0&&a>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){fe.setChildExtents_(h,o);for(let t=0;t<4;t++){const s=this.getChild_(e,t);if(-1!==s&&this.getSubTreeElementCount_(s)>0){i.isIntersecting(o[t])&&(n.push(s),r.push(o[t].clone()))}}}}return a}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new xe(this,t,e)}getIteratorForQT(){return new xe(this)}getSortedIterator(t,e){return new ye(this.getIterator(t,e))}getSortedIteratorForQT(){return new ye(this.getIteratorForQT())}visitLeavesNearest(t,e,i,n){s(0)}reset_(t,s){(s<0||s>127)&&e("invalid height"),this.m_height=s,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,n,r,o){if(!i.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,r,o);if(!r)for(let u=n;-1!==u;u=this.getParent_(u))this.setSubTreeElementCount_(u,this.getSubTreeElementCount_(u)+1);const a=new qt;a.setCoords({env2D:i});let h,m=n;for(h=s;h<this.m_height&&this.canPushDown_(m);h++){fe.setChildExtents_(a,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(m,s);-1===e&&(e=this.createChild_(m,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),m=e,a.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,h,a,m,r,n,o,-1)}insertDuplicates_(t,e,s,i,n,r,o){if(!r){if(!i.containsEnvelope(e))return-1;this.setSubTreeElementCount_(n,this.getSubTreeElementCount_(n)+1),this.setContainedSubTreeElementCount_(n,this.getContainedSubTreeElementCount_(n)+1)}const a=Math.max(e.width(),e.height());let h=-1;const m=[],u=[],l=[];m.push(n),u.push(i.clone()),l.push(s);const c=x(qt,4);for(;m.length>0;){let s=!1;const i=m.at(-1),d=u.at(-1),g=l.at(-1);if(m.pop(),u.pop(),l.pop(),g+1<this.m_height&&this.canPushDown_(i)){a<=Math.max(d.width(),d.height())/2&&(s=!0)}if(s){fe.setChildExtents_(d,c);let t=!1;for(let s=0;s<4;s++)if(t=c[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),m.push(t),u.push(c[s].clone()),l.push(g+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let s=0;s<4;s++){if(c[s].isIntersecting(e)){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),m.push(t),u.push(c[s].clone()),l.push(g+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1)}}}else h=this.insertAtQuad_(t,e,g,d,i,r,n,o,h),r=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let u=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),u=a}else-1===h?(u=this.createElement_(),this.setDataValues_(this.getData_(u),t,e)):u=this.createElementFromDuplicate_(h);return this.setQuad_(u,n),-1!==m?(this.setPrevElement_(u,m),this.setNextElement_(m,u)):this.setFirstElement_(n,u),this.setLastElement_(n,u),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),u}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===fe.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const n=new qt;let r=this.getFirstElement_(s),o=-1,a=-1;do{a=this.getData_(r),i=this.getElementValue_(a),n.setCoords({env2D:this.getBoundingBoxValue_(a)}),o=this.getNextElement_(r),this.m_bStoreDuplicates?this.insertDuplicates_(i,n,t,e,s,!0,r):this.insert_(i,n,t,e,s,!0,r),r=o}while(-1!==r)}canPushDown_(t){return this.getLocalElementCount_(t)>=fe.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){s(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&fe.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>fe.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const i=e<<fe.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=pe(e,s)}}fe.m_quadrantMask=3,fe.m_heightBitShift=2,fe.m_flushingCount=5;class xe{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new f,this.m_queryEnd=new f,this.m_queryBox=new qt,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new qt,new qt,new qt,new qt],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof qt)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===n.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new f,e=new f,s=new qt;let i=!1;for(;!i;){for(;-1!==this.m_currentElementHandle;){const n=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(n)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){i=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){i=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),i=this.m_extentsStack.at(-1);fe.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let n=0;n<4;n++){const i=this.m_quadTree.getChild_(s,n);if(-1!==i&&this.m_quadTree.getSubTreeElementCount(i)>0&&this.m_childExtents[n].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new qt;s.setCoords({env2D:this.m_childExtents[n]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(i),this.m_extentsStack.push(this.m_childExtents[n].clone()))}else this.m_quadsStack.push(i),this.m_extentsStack.push(this.m_childExtents[n].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return s(0),{}}}class ye{constructor(t){this.m_bucketSort=new ge,this.m_sortedHandles=new Jt(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,((t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s)))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return s(0),{}}}class Pe{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class ve{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new _e(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||(s(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,i,n,r=-1){if(-1===r&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.getRoot_(r)===ve.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,r),this.addToList_(-1,t,r),t}let o,a,h,m,u;if(n?(o=e!==ve.st_nullNode()?this.m_comparator.compare(this,s,e):-1,a=t!==ve.st_nullNode()?this.m_comparator.compare(this,s,t):1):(o=-1,a=1),i&&(0===o||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===o?e:t;return this.setDuplicateElement_(i,r),-1}u=e!==ve.st_nullNode()&&t!==ve.st_nullNode()?this.m_random>I(this.m_random)>>1:e!==ve.st_nullNode(),u?(m=o,h=e):(m=a,h=t);let l=-1,c=-1,d=!0;for(;;){if(m<0){const t=this.getLeft(h);if(t===ve.st_nullNode()){c=h,l=this.newNode_(s),this.setLeft_(h,l),this.setParent_(l,h);break}h=t}else{const t=this.getRight(h);if(t===ve.st_nullNode()){c=this.getNext(h),l=this.newNode_(s),this.setRight_(h,l),this.setParent_(l,h);break}h=t}d&&(m*=-1,d=!1)}return this.bubbleUp_(l),this.getParent(l)===ve.st_nullNode()&&this.setRoot_(l,r),this.addToList_(c,l,r),l}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==ve.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==ve.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===ve.st_nullNode()&&(this.m_defaultTreap===ve.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==ve.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),ve.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==ve.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==ve.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=ve.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return _e.isValidElement(t)}dbgCheck_(t){}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const i=this.getPriority_(t);for(;e!==ve.st_nullNode()||s!==ve.st_nullNode();){const n=e!==ve.st_nullNode()?this.getPriority_(e):N(),r=s!==ve.st_nullNode()?this.getPriority_(s):N();if(i<=Math.min(n,r))return;n<=r?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==ve.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==ve.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==ve.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==ve.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==ve.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?ve.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==ve.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=I(this.m_random),this.m_random&N()>>1}maxPriority(){return s(0),0}getMaxDepthHelper_(t){return t===ve.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===ve.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===ve.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===ve.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===ve.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),i=this.getRight(t),n=this.getParent(t),r=t;if(-1!==s&&-1!==i){let o;this.m_random=I(this.m_random),o=this.m_random>N()>>1?this.getNext(t):this.getPrev(t);const a=this.getParent(o)===t;this.m_treapData.swapField(t,o,0),this.m_treapData.swapField(t,o,1),this.m_treapData.swapField(t,o,2),-1!==n?this.getLeft(n)===t?this.setLeft_(n,o):this.setRight_(n,o):this.setRoot_(o,e),a?(s===o?(this.setLeft_(o,t),this.setParent_(i,o)):i===o&&(this.setRight_(o,t),this.setParent_(s,o)),this.setParent_(t,o),n=o):(this.setParent_(s,o),this.setParent_(i,o),n=this.getParent(t),r=o),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const o=-1!==s?s:i;-1===n?this.setRoot_(o,e):this.getLeft(n)===r?this.setLeft_(n,o):this.setRight_(n,o),-1!==o&&this.setParent_(o,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,N());let s=ve.st_nullNode(),i=ve.st_nullNode();const n=this.getRoot_(e),r=n===t;if(r&&(s=this.getLeft(n),i=this.getRight(n),s===ve.st_nullNode()&&i===ve.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(ve.st_nullNode(),e);this.bubbleDown_(t);const o=this.getParent(t);o!==ve.st_nullNode()&&(this.getLeft(o)===t?this.setLeft_(o,ve.st_nullNode()):this.setRight_(o,ve.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),r&&this.setRoot_(s===ve.st_nullNode()||this.getParent(s)!==ve.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===ve.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===ve.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Ce{constructor(t){this.m_lists=new _e(6),this.m_listOfLists=Ce.st_nullNode(),void 0===t?(this.m_listNodes=new _e(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new _e(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){s(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(t,e){s(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){s(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Ce.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Ce.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Ce.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){s(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return s(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;e!==Ce.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Ce.st_nullNode()&&this.setNext_(n,i);if(e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Ce.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Ce.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Ce.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Ce.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let e=this.getFirstList();-1!==e;)e=this.deleteList(e)}isEmpty(t){return s(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class be extends Pe{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?Ee.isLeft_(e)&&Ee.isRight_(i)?-1:Ee.isLeft_(i)&&Ee.isRight_(e)?1:0:1}}class Ee{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new _e(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new _e(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new ve,this.m_secondaryTreaps.setComparator(new be(this)),this.m_secondaryLists=new Ce}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||o(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){s(0)}endConstruction(){this.m_bConstructing||o(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||o(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new Jt(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||o("");const s=this.m_intervalHandles[t];let i;-1===s&&e("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let n=this.getSecondaryFromInterval_(s),r=-1;r=this.m_secondaryTreaps.getTreapData(n),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(s),n),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(s),n),i=this.m_secondaryTreaps.size(n),0===i&&(this.m_secondaryTreaps.deleteTreap(n),this.setSecondaryToTertiary_(r,-1)),this.m_intervalNodes.deleteElement(s);let a=this.getPptr_(r),h=this.getLptr_(r),m=this.getRptr_(r);for(;!(i>0||r===this.m_root||-1!==h&&-1!==m);)r===this.getLptr_(a)?-1!==h?(this.setLptr_(a,h),this.setPptr_(h,a),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==m?(this.setLptr_(a,m),this.setPptr_(m,a),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setLptr_(a,-1),this.setPptr_(r,-1)):-1!==h?(this.setRptr_(a,h),this.setPptr_(h,a),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==m?(this.setRptr_(a,m),this.setPptr_(m,a),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setRptr_(a,-1),this.setPptr_(r,-1)),this.m_tertiaryNodes.deleteElement(r),r=a,n=this.getSecondaryFromTertiary_(r),i=-1!==n?this.m_secondaryTreaps.size(n):0,h=this.getLptr_(r),m=this.getRptr_(r),a=this.getPptr_(r)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof D?new De(this,t,e):(s(0),{})}getIterator(){return new De(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new Jt(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=q(t,-1);this.m_root=this.createRoot_();for(let i=0;i<e.size();i++){const t=e.read(i);let n=s[t>>1];if(-1!==n){const e=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(e,t))}else n=this.insertIntervalEnd_(t,this.m_root),s[t>>1]=n}}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const d=this.getMin_(m),g=this.getMax_(m);let _=-1;for(;c;){h=o+(a-o>>1),_=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(_);if(g<e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(d>e){if(-1!==i)if(_===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(_);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||_!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(_):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&_===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||o(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;if(t<e){s=t+(e-t>>1)+2}else s=-(t+2);return s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new ge).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,((t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&Ee.isLeft_(t)&&Ee.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return Ee.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return Ee.isLeft_(t)?e.xmin:e.xmax}}class De{constructor(t,e,s){this.m_query=D.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return a("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new D;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||o(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&Ee.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class Se{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new Jt(0),this.m_sortedEndIndicesBlue=new Jt(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Ce,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||o(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new qt(e))}endConstruction(){this.m_bAddRedRed||o(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||o(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||o(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||o(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||o(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new Ee(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new Ee(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new Ee(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=D.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=D.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&(this.m_queuedIndicesRed.length=this.m_envelopesRed.length,this.m_queuedIndicesRed.fill(-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=D.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&(this.m_queuedIndicesBlue.length=this.m_envelopesBlue.length,this.m_queuedIndicesBlue.fill(-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return a("should not be called"),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new ge).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,((t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1}))}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}var we=Vt;class Ae{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new Ae(this.tolerance+t,this.resolution)}scale(t){return new Ae(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function Te(t,e,s,i,n){const r=i*i,o=t.sub(e),a=s.sub(e),h=o.sqrLength(),m=a.sqrLength();if(h<=r||m<=r)return!0;const u=C(o.crossProduct(a));if(u<=r*h||u<=r*m){return o.dotProduct(a)>=0}return!1}function Ie(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function Ne(t,e){const s=new qt;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function qe(t,e){const s=qt.constructEmpty();t.queryLooseEnvelope(s);const i=qt.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function Me(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function Ye(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function Xe(t,e,s){const i=qt.constructEmpty();i.setFromPoints(t,e);return ke(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function Fe(t,e,s){return ke(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function Re(t,e,s){return ke(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function Le(t,e,s){return Re(t,e.queryInterval(1,0),s)}function ze(t,e,s){const i=qt.constructEmpty();return e.queryEnvelope(i),Fe(t,i,s)}function Ve(t,e,s=!1){return ke(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function Be(t,e,s){const i=qt.constructEmpty();return e.queryEnvelope(i),Ve(t,i,s)}function ke(t,e,s,i,n){const r=new Ae(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01);return r.total()<s?new Ae(s,0):r}function Ge(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function He(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function We(t){return t>=3}function je(t,e){const s=[0];return t.getImpl().getIsSimple(e,s)>=3}function Ze(t,e){t.getImpl().setIsSimple(3,e)}function Ue(t,e,s,i){if(C(e.x-t.x)+C(e.y-t.y)<=s*s){const s=t.z,n=e.z;return b(s,n,i)}return!1}function Oe(t){return t>=4}function Qe(t,e){return t===n.enumPolygon?We(e):e>=1}function Ke(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=e.querySegmentIterator(),h=qt.constructEmpty(),m=qt.constructEmpty(),u=new Se;u.setTolerance(s);let l=!1;for(u.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(h),h.isIntersecting(r)&&(l=!0,u.addRedEnvelope(o.getStartPointIndex(),h))}if(u.endRedConstruction(),!l)return null;let c=!1;for(u.startBlueConstruction();a.nextPath();)for(;a.hasNextSegment();){a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(r)&&(c=!0,u.addBlueEnvelope(a.getStartPointIndex(),m))}return u.endBlueConstruction(),c?u:null}function $e(t,e,s,i,n){t.getGeometryType(),e.getGeometryType();const r=qt.constructEmpty(),o=qt.constructEmpty();t.queryLooseEnvelope(r),e.queryLooseEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=qt.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Se;h.setTolerance(s);let m=!1;h.startRedConstruction();for(let l=0,c=t.getPathCount();l<c;l++)t.queryLoosePathEnvelope(l,r),r.isIntersecting(a)&&(m=!0,h.addRedEnvelope(l,r));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let l=0,c=e.getPathCount();l<c;l++)e.queryLoosePathEnvelope(l,o),o.isIntersecting(a)&&(u=!0,h.addBlueEnvelope(l,o));return h.endBlueConstruction(),u?h:null}function Je(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=new Se;a.setTolerance(s);let h=!1;for(a.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(i),i.isIntersecting(r)&&(h=!0,a.addRedEnvelope(o.getStartPointIndex(),i))}if(a.endRedConstruction(),!h)return null;let m=!1;a.startBlueConstruction();for(let u=0,l=e.getPointCount();u<l;u++){const t=e.getXY(u);r.contains(t)&&(m=!0,a.addBlueEnvelope(u,qt.construct(t.x,t.y,t.x,t.y)))}return a.endBlueConstruction(),m?a:null}function ts(t,e,s){const i=qt.constructEmpty(),n=qt.constructEmpty();t.queryEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=qt.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=new Se;o.setTolerance(s);let a=!1;o.startRedConstruction();const h=new f;for(let l=0,c=t.getPointCount();l<c;l++)t.queryXY(l,h),r.contains(h)&&(a=!0,o.addRedEnvelope(l,qt.construct(h.x,h.y,h.x,h.y)));if(o.endRedConstruction(),!a)return null;let m=!1;o.startBlueConstruction();const u=new f;for(let l=0,c=e.getPointCount();l<c;l++)e.queryXY(l,u),r.contains(u)&&(m=!0,o.addBlueEnvelope(l,qt.construct(u.x,u.y,u.x,u.y)));return o.endBlueConstruction(),m?o:null}function es(t){const e=new qt;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),ss(t,e)}function ss(t,e,s){const i=new qt;if(t.queryLooseEnvelope(i),i.isEmpty())return null;t.getGeometryType();const n=new fe(i,8);let r=-1;const o=new qt;let h=!1;do{for(let s=0,m=t.getPathCount();s<m;s++)if(t.queryLoosePathEnvelope(s,o),o.isIntersecting(e)){if(r=n.insertEx(s,o,r),-1===r){h&&a("build_quad_tree_for_paths"),i.assign(t.calculateEnvelope2D(!1)),h=!0,n.reset(i,8);break}h=!1}}while(h);return n}function is(t,e){if(!e){const e=new qt;t.queryLooseEnvelope(e);const s=new fe(e,8);let i=-1;const n=new qt,r=t.querySegmentIterator();let o=!1;for(;r.nextPath();)for(;r.hasNextSegment();){const h=r.nextSegment(),m=r.getStartPointIndex();if(h.queryLooseEnvelope(n),i=s.insertEx(m,n,i),-1===i){o&&a(""),e.assign(t.calculateEnvelope2D(!1)),o=!0,s.reset(e,8),r.resetToFirstPath();break}}return s}const s=new qt;t.queryLooseEnvelope(s);const i=new fe(s,8);let n=-1;const r=new qt,o=t.querySegmentIterator();let h=!1;for(;o.nextPath();)for(;o.hasNextSegment();){const m=o.nextSegment(),u=o.getStartPointIndex();if(m.queryLooseEnvelope(r),r.isIntersecting(e)&&(n=i.insertEx(u,r,n),-1===n)){h&&a(""),s.assign(t.calculateEnvelope2D(!1)),h=!0,i.reset(s,8),o.resetToFirstPath();break}}return i}function ns(e,s){if(s){const t=new fe(s,8),i=new f,n=new qt;let r=!1;for(let o=0;o<e.getPointCount();o++){if(i.setCoordsPoint2D(e.getXY(o)),!s.contains(i))continue;n.setCoords({pt:i});-1!==t.insert(o,n)||(r&&a(""),r=!0,t.reset(e.calculateEnvelope2D(),8),o=-1)}return t}return t("no-extent version not yet impl"),null}function rs(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let h=s;h<e;h+=i){const e=t.read(h);e<o?(r=!0,t.write(h,o)):e>a&&(r=!0,t.write(h,a))}return r}function os(t,e,s,i){if(!t.hasAttribute(s))return!1;const r=t.getGeometryType();if(r===n.enumGeometryCollection){const n=t,r=n.getGeometryCount();let o=0;for(let t=0;t<r;++t){o|=os(n.getGeometry(t),e,s,i)?1:0}return!!o}if(h(r)){const n=t,r=we.getPersistence(s),o=we.getComponentCount(s),h=n.getPointCount();if(1===r){const t=rs(n.getAttributeStreamRef(s),h*o,i,o,e);return t&&n.notifyModified(),t}if(2===r){const t=rs(n.getAttributeStreamRef(s),h*o,i,o,e);return t&&n.notifyModified(),t}a("snap_coordinate not implemented")}if(r===n.enumEnvelope){const n=t,r=n.queryInterval(s,i);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&n.setIntervalEnvelope(s,i,r),o}if(r===n.enumPoint){const n=t;let r=n.getAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setAttributeBasic(s,i,r),o}if(m(r)){const n=t;let r=n.getStartAttributeAsDbl(s,i),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setStartAttribute(s,i,r),r=n.getEndAttributeAsDbl(s,i),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&n.setEndAttribute(s,i,r),o}a("snap_coordinate not implemented")}var as=Vt;class hs{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=le(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=ce(),this.ensureAttributes(),this.setXYZ(new Bt(t.x,t.y,t.z))):(this.m_description=le(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=le()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new f(this.x,this.y)}queryXY(t){t.x=this.x,t.y=this.y}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new Bt;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:as.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;i("")}const s=as.getComponentCount(t);(e<0||e>=s)&&i("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]:as.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:i(""));const n=as.getComponentCount(t);(e<0||e>=n)&&i("");let r=this.m_description.getAttributeIndex(t);r<0&&(this.addAttribute(t),r=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(r)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=as.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return n.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof cs)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof kt){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new D;if(this.isEmpty())return s.setEmpty(),s;const i=this.getAttributeAsDbl(t,e);return s.vmin=i,s.vmax=i,s}applyTransformation(e){if(!this.isEmpty()){if(1===e.m_TransformationType){const t=this.getXY();return e.transformInPlace(t),void this.setXY(t)}t("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=Ie(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new hs({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==n.enumPoint&&e();const s=t;s.x=this.x,s.y=this.y,this.m_attribs?(s.assignVertexDescription(this.m_description),s.m_attribs=this.m_attribs.slice()):(s.releaseAttributes(),s.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=le(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&A(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==n.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let i=0,n=this.m_description.getTotalComponentCount()-2;i<n;i++)if(!b(this.m_attribs[i],s.m_attribs[i],e))return!1;return!0}getBoundary(){return null}clone(){const t=new hs({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==n.enumPoint&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.x=S(this.x,this.x=s.x),s.y=S(this.y,this.y=s.y),s.m_attribs=S(this.m_attribs,this.m_attribs=s.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=as.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,s,i){if(t.getDescription()!==s.getDescription()&&e("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||s.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const n=zt();t.queryValues(n,n.length);const r=zt();s.queryValues(r,r.length);const o=zt();let a=n,h=r;const m=o;let u=0;for(let e=0,l=this.m_description.getAttributeCount();e<l;e++){const t=this.m_description.getSemantics(e),s=as.getInterpolation(t),n=as.getComponentCount(t),r=as.getDefaultValue(t);T(s,a,h,m,u,n,i,r),a=a.slice(n),h=h.slice(n),u+=n}return this.setValues(o,u),this}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?A(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return f.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=le());const e=re();de(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=as.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){const i=this.m_description.getTotalComponentCount();s(i<=e),t[0]=this.x,t[1]=this.y,A(t,this.m_attribs,2,0,i-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&A(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=as.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=as.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const i=this.m_description.getTotalComponentCount();s(i<=e),this.x=t[0],this.y=t[1],A(this.m_attribs,t,0,2,i-2)}dbgDefaultAttribs(){}}hs.type=n.enumPoint;var ms=Vt;function us(t,e){return e*(t.getTotalComponentCount()-2)}class ls{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new qt(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new qt(t.env2D);else if(t.move)this.m_envelope2D=new qt(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new qt(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=qt.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}copyTo(t,e){const i=e,n=t.getTotalComponentCount()-2;if(i.m_description!==t&&(i.releaseAttributes_(),i.m_description=t,n&&(i.m_data.m_attributes=new Array(2*n))),n){s(this.m_attributes&&i.m_data.m_attributes);const t=2*n;A(i.m_data.m_attributes,this.m_attributes,0,0,t)}i.m_data.m_envelope2D=new qt(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new qt(this.m_envelope2D),e.releaseAttributes();t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}transformAttribute(t,e,i,n,r){s(0)}queryInterval(t,e,s,n){if(this.isEmpty())return void n.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(n):1===s?this.m_envelope2D.queryIntervalY(n):i(""));const r=ms.getComponentCount(e);(s<0||s>=r)&&i("");const o=t.getAttributeIndex(e);if(o>=0)return n.vmin=this.m_attributes[us(t,0)+t.getPointAttributeOffset(o)-2+s],void(n.vmax=this.m_attributes[us(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=ms.getDefaultValue(e);return void n.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new D;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}class cs{constructor(t){if(this.m_EnvelopeType=4,this.m_description=le(),void 0===t)this.m_data=new ls;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new ls,this.ensureAttributes_();else if(t?.env2D)this.m_data=new ls({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new ls({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new ls,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new ls({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new ls,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new ls({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,i,n,r){s(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new qt(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return n.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterXY(){return this.m_data.isEmpty()?new f:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=ms.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof qt)this.m_data.m_envelope2D=new qt(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=D.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(s){if(s instanceof qt)return s.isValid()||e(""),void this.m_data.m_envelope2D.mergeEnvelope2D(s);if(s instanceof cs){if(s.m_data.isEmpty())return;const t=s.getDescription();this.mergeVertexDescription(t),this.m_data.m_envelope2D.mergeEnvelope2D(s.m_data.m_envelope2D);for(let e=1,i=t.getAttributeCount();e<i;e++){const i=t.getSemantics(e),n=ms.getComponentCount(i);for(let t=0;t<n;t++){const e=s.queryInterval(i,t),n=this.queryInterval(i,t);n.merge(e),this.setIntervalEnvelope(i,t,n)}}}else if(s instanceof hs){const t=s;if(t.isEmpty())return;const e=t.getDescription();if(this.mergeVertexDescription(e),this.m_data.isEmpty())return void this.setFromPoint(t);this.m_data.m_envelope2D.merge(t.getXY());for(let s=1,i=e.getAttributeCount();s<i;s++){const i=e.getSemantics(s),n=ms.getComponentCount(i);for(let e=0;e<n;e++){const s=t.getAttributeAsDbl(i,e),n=this.queryInterval(i,e);n.mergeCoordinate(s),this.setIntervalEnvelope(i,e,n)}}}else t("unrecognized type for envelope.merge")}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const e=this.m_description.getSemantics(s),i=ms.getComponentCount(e);for(let s=0;s<i;s++){const i=t.queryInterval(e,s),n=this.queryInterval(e,s);n.intersect(i),this.setIntervalEnvelope(e,s,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=ms.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const n=new D(s);if(n.normalize(),0===t){if(n.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=n.vmin,this.m_data.m_envelope2D.xmax=n.vmax):1===e?(this.m_data.m_envelope2D.ymin=n.vmin,this.m_data.m_envelope2D.ymax=n.vmax):i("")}else this.setAttributeAsDblImpl(0,t,e,n.vmin),this.setAttributeAsDblImpl(1,t,e,n.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new D(s,i))}queryInterval(t,e){const s=new D;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(e){2!==e.m_EnvelopeType?3!==e.m_EnvelopeType?4!==e.m_EnvelopeType?t("unrecognized type for queryEnveloper"):this.copyTo(e):this.m_data.queryEnvelope3D(this.m_description,e):e.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?s(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new cs({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=le()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return s(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let i=0,n=2*(this.m_description.getTotalComponentCount()-2);i<n;i++)if(!b(this.m_data.m_attributes[i],s.m_data.m_attributes[i],e))return!1;return!0}getBoundary(){return t("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new cs({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==n.enumEnvelope&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.m_data.m_envelope2D=S(this.m_data.m_envelope2D,this.m_data.m_envelope2D=s.m_data.m_envelope2D),s.m_data.m_attributes=S(this.m_data.m_attributes,this.m_data.m_attributes=s.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&e(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&i(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=ms.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=ms.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let n=1,r=i.getAttributeCount();n<r;n++){const e=i.getSemantics(n),s=ms.getComponentCount(e);for(let i=0;i<s;i++){const s=t.getAttributeAsDbl(e,i);this.setInterval(e,i,s,s)}}}assignVertexDescriptionImpl(t){const e=re();de(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=new Array(2*i),s.fill(Number.NaN));for(let r=1;r<t.getAttributeCount();r++){const o=e[r];if(-1!==o){const e=t.getPointAttributeOffset(r)-2,a=ms.getComponentCount(t.getSemantics(r)),h=this.m_description.getPointAttributeOffset(o)-2;A(s,this.m_data.m_attributes,e,h,a),A(s,this.m_data.m_attributes,i+e,n+h,a)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&r(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=ms.getComponentCount(e)&&i("");const n=this.m_description.getAttributeIndex(e);return n>=0?this.m_data.m_attributes[us(this.m_description,t)+this.m_description.getPointAttributeOffset(n)-2+s]:Vt.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,n){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=n:0===s?this.m_data.m_envelope2D.xmax=n:i(""):1===s?this.m_data.m_envelope2D.ymin=n:0===s?this.m_data.m_envelope2D.xmin=n:i(""));const r=ms.getComponentCount(e);(s<0||s>=r)&&i(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[us(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=n}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}}cs.type=n.enumEnvelope;class ds{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function gs(t,s,i,n,r){(s<0||i<0||n<1||s+n*(i-1)+1>t.size())&&e("Index out of bound");for(let e=s,o=s+n*(i-1)+1;e<o;e+=n)t.writeAsDbl(e,r(t.readAsDbl(e)))}function _s(t,e){let s=I(t);const i=e.length/w();for(let n=0;n<e.length;++n){const t=Math.trunc(s*i);s=I(s);const n=Math.trunc(s*i),r=e[t];e[t]=e[n],e[n]=r}}function ps(t,e,s){if(0===t.length)return;let i=0,n=0;for(++n;n!==t.length;++n)e(t[i],t[n])||(s(i,n),i=n);s(i,n)}function fs(t,e,s,i,n){M(t,e,i-e,((t,e)=>n(t,e)?-1:1))}function xs(t,e,s){if(!(s<=e))for(;e<s;)t[s]=S(t[e],t[e]=t[s]),e++,s--}function ys(t,e,s,i){xs(t,e,s-1),xs(t,s,i-1),t.reverse()}function Ps(t,e,s){const i=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),A(t.getAttributeArray(),e,0,2,i-2)}var vs=Vt;const Cs="can not assign an empty point to a vertex";class bs{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=le(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new ds,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new ls,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:le();this.m_description=e,this.m_vertexAttributes=new ds,this.m_envelopeData=new ls,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!h(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==s.getPointCount())return!1;for(let n=0;n<this.m_description.getAttributeCount();n++){const t=this.m_description.getSemantics(n),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=vs.getComponentCount(t);if(!r.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,i,n){this.addAttribute(t),this.isEmpty()||0===s&&1===i||(gs(this.getAttributeStreamRef(t),e,this.getPointCount(),vs.getComponentCount(t),Ie(s,i,n)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||e("AttributeStream : Geometry does not have the attribute");const s=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(s)}setAttributeStreamRef(t,s){s||e("stream"),s&&vs.getPersistence(t)!==s.getPersistence()&&e(""),this.addAttribute(t);const i=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(i,s),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let i=0;i<this.m_description.getAttributeCount();i++){const e=this.m_description.getSemantics(i);for(let n=0,r=vs.getComponentCount(e);n<r;n++){const o=this.m_vertexAttributes.get(i).readAsDbl(r*t+n);s.setAttributeBasic(e,n,o)}}}setPointByVal(t,s){const i=s;i.isEmpty()&&e(Cs);const n=i.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,i.getX()),r.write(2*t+1,i.getY());for(let e=1,o=this.m_description.getAttributeCount();e<o;e++){const s=this.m_description.getSemantics(e),n=vs.getComponentCount(s);for(let r=0;r<n;r++){const o=i.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(t,e,i,n){s(0)}getPointByValAsArray(t,e,i,n){s(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=vs.getComponentCount(t);s>=n&&i("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):vs.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=vs.getComponentCount(t);n<r&&i("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=vs.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,i,n){s(0)}setAttribute(t,e,s,n){const r=vs.getComponentCount(t);s>=r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArray(t,e,s,n){(e<0||e>=this.m_pointCount)&&i("");const r=vs.getComponentCount(t);n!==r&&i(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let i=0;i<r;++i)a.writeAsDbl(e*r+i,s[i])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=Bt.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=vs.getDefaultValue(1),s}setXYZ(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y);this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof qt||t instanceof kt?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=D.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let i=!1;const n=vs.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let a=e,h=this.m_pointCount*n;a<h;a+=n){r.readAsDbl(a)!==s&&(r.writeAsDbl(a,s),i=!0)}i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=vs.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let r=0;r<i;r++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,o=this.m_pointCount*i;t<o;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return s(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||e(""),this.m_envelopeData=new ls({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&e(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*i,a=2*r,h=0;e<a;e+=2,h++)o.queryPoint2D(e,t[h]);return r}queryCoordinates3D(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=vs.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;if(!(1&i)){s=(14&i)>>1,e[0]=n,n<t&&(s=-1)}return s}setIsSimple(t,e,i=!1){if(2===t?s(this.getGeometryType()===n.enumPolyline):1===t?s(this.getGeometryType()===n.enumMultiPoint||this.getGeometryType()===n.enumPolyline):3===t&&s(this.getGeometryType()===n.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;i||(s|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&u("Cannot do shallow clone on unprepared geometry");const i=t,r=this.getGeometryType(),o=i.getGeometryType();s(r===o||r===n.enumPolygon&&o===n.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new ds;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(e)h.set(t,this.m_vertexAttributes.get(t));else{const e=vs.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,r!==o){const t=[0];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)?(s(!e),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,e)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,n,r){(t<0||t>=this.m_pointCount)&&i(""),(e<0||e>=this.m_pointCount)&&i(""),r.assignVertexDescription(this.m_description);const o=new Array(vs.maxComponentCount()),a=new Array(vs.maxComponentCount()),h=zt();let m=0;for(let i=0;i<this.m_description.getAttributeCount();i++){const r=this.m_description.getSemantics(i),u=vs.getInterpolation(r),l=vs.getComponentCount(r),c=vs.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(m+l<=Lt),T(u,o,a,h,m,l,n,c),m+=l}Ps(r,h)}getShortestDistance(t,e){return f.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return f.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&e(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const s=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(s)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=re();de(t,this.m_description,e);const s=new ds;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return!!(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=Number.MAX_SAFE_INTEGER;let t=0;t=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let e=0;e<this.m_description.getAttributeCount();e++){const s=this.m_description.getSemantics(e);let i=0;if(null!==this.m_vertexAttributes.get(e)){const n=vs.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,vs.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,jt(s,t)),i=t;i<this.m_reservedPointCount&&(this.m_reservedPointCount=i)}}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new cs({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vs.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const r=new D;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new ls({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=qt.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){s(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof qt?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,s){if(t<0&&e(""),0===t)return;let i=t=Math.ceil(t);if(this.m_reservedPointCount<i){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),s?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,Zt(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*i),i=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,Zt(0,i)):this.m_vertexAttributes.get(0).resize(2*i);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),s=vs.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(i*s):this.m_vertexAttributes.set(t,Zt(e,i))}this.reserveImplImpl(i,s),this.m_reservedPointCount=i}}reserveRounded(t){t<0&&e(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&r("")}}class Es extends bs{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,s){t>this.getPointCount()&&e("invalid point index"),t<0&&(t=this.getPointCount());const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),r=Vt.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(e).insert(r*t,s,r*i);else{const s=Vt.getDefaultValue(n);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*i)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(Cs),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,n=this.m_description.getAttributeCount();e<n;e++){const n=this.m_description.getSemantics(e),r=Vt.getComponentCount(n);if(s.hasAttribute(n))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,n,r*i);else{const s=Vt.getDefaultValue(n);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*i)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&i(""),t<0&&(t=this.getPointCount()),0===s)return;const n=e[0].getDescription();this.mergeVertexDescription(n);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=Vt.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(n.hasAttribute(o))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=Vt.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,s,i){if((t>this.getPointCount()||i<0)&&e("invalid point index"),t<0&&(t=this.getPointCount()),0===i)return;const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++){const r=this.m_description.getSemantics(e),o=Vt.getComponentCount(r);if(this.m_vertexAttributes.get(e))if(0===r)this.m_vertexAttributes.get(e).insertRangeFromPoints(o*t,s,0,i,!0,o*n);else{const s=Vt.getDefaultValue(r);this.m_vertexAttributes.get(e).insertRange(o*t,s,o,o*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&i("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),n=Vt.getComponentCount(i);this.m_vertexAttributes.get(s).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),i=Vt.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s),i=Vt.getDefaultValue(t),n=Vt.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(n*e,i,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,s,i,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,i+s),(i<0||r<i||this.m_pointCount>0&&i>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=Vt.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<r;e++,u++)t[u].x=o.read(2*e),t[u].y=o.read(2*e+1),t[u].z=m?a.read(e):h;return r}queryAttributeAsInt(t,e,i,n){s(0)}add(t){t.isEmpty()&&e(Cs),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new f(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new Bt;i.setCoords(t,e,s),this.setXYZ(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,s,i){this===t&&e("Multi_point_impl.add");const n=i<0?t.getPointCount():i;if((s<0||s>t.getPointCount()||n<s)&&e(""),s===n)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=n-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let e=0,h=this.m_description.getAttributeCount();e<h;e++){const i=this.m_description.getSemantics(e),n=Vt.getComponentCount(i),h=this.getAttributeStreamRef(i);if(r.hasAttribute(i)){const e=t.getAttributeStreamRef(i);h.insertRangeFromStream(a*n,e,s*n,o*n,!0,1,a*n)}else{const t=Vt.getDefaultValue(i);h.insertRange(a*n,t,o*n,a*n)}}}addPoints2D(t,s,i,n){let r=s;const o=n<0?r:n;if((r<0||i<0||i>r||o<i)&&e(""),i===o)return;r=o-i;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[i+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,s,i,n){let r=s;const o=n<0?r:n;if((r<0||i<0||i>r||o<i)&&e(""),this.addAttribute(1),i===o)return;r=o-i;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0),m=new f;for(let e=0;e<r;e++)m.x=t[i+e].x,m.y=t[i+e].y,h.writePoint2D(2*(a+e),m);const u=this.getAttributeStreamRef(1);for(let e=0;e<r;e++)u.write(a+e,t[i+e].z);this.notifyModifiedFlags(2001)}getGeometryType(){return n.enumMultiPoint}getDimension(){return 0}createInstance(){return new Es({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(e){if(this.isEmpty())return;if(e.isIdentity())return;const s=this.m_vertexAttributes.get(0);1===e.m_TransformationType?s.applyTransformation(e,0,this.m_pointCount):t("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===n.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(e){4===e.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,e)):2===e.m_EnvelopeType?this.updateEnvelope(e):t("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){s(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return s(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}Es.type=n.enumMultiPoint;class Ds{constructor(){this.m_EnvelopeType=5,this.envAabb=qt.constructEmpty(),this.envRot=qt.constructEmpty()}static constructEmpty(){return new Ds}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:Ss(t),y:ws(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Ss(t),ws(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=Ss(t[i]),s=ws(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=Ss(t[s]),i=ws(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Ss(t),ws(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*Y();this.envRot.inflateCoords(e,e),e<0&&Ds.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function Ss(t){return t.x-t.y}function ws(t){return t.x+t.y}class As extends Nt{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Ts{constructor(t){this.m_geoms=[],this.m_description=le(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):e("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===n.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&e("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return n.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=t}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new D;const i=new D;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(e){if(4===e.m_EnvelopeType){const t=new cs;e.setEmpty(),e.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(t),e.merge(t)}else if(2===e.m_EnvelopeType){const t=new qt;e.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(t),e.mergeEnvelope2D(t)}t("3d envelope case not implemented")}queryLooseEnvelope(e){if(2===e.m_EnvelopeType){const t=new qt;e.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(t),e.mergeEnvelope2D(t)}t("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(e){if(1===e.m_TransformationType)for(const t of this.m_geoms)t.applyTransformation(e);t("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new Ts({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==n.enumGeometryCollection&&e("");const s=t;if(s!==this){s.m_geoms.length=0,s.assignVertexDescription(this.m_description);for(const t of this.m_geoms)s.m_geoms.push(t.clone())}}calculateArea2D(){const t=new X(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new X(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return s(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const s of this.m_geoms){const t=s.getBoundary();t&&e.m_geoms.push(t)}return t}clone(){return new Ts({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==n.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let i=0;i<this.m_geoms.length;++i)if(!this.m_geoms[i].equals(s.m_geoms[i],e))return!1;return!0}swap(t){t.getGeometryType()!==n.enumGeometryCollection&&e("");const s=t;s!==this&&(this.m_geoms=S(s.m_geoms,s.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}}function Is(t,e=-1){return new As(t,e)}Ts.type=n.enumGeometryCollection;class Ns{constructor(){this.x=V.getNAN(),this.y=V.getNAN()}static getNAN(){return new Ns}static constructPoint2D(t){const e=new Ns;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ns;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ns;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new Ns).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new Ns;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ns;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=dt.clone(),this.y=gt.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return f.construct(this.x.value(),this.y.value())}}class qs{constructor(){this.a11=new V(1),this.a12=new V(0),this.a21=new V(0),this.a22=new V(1)}clone(){const t=new qs;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=S(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new V(1),n=new V(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new V(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(gt)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(a),i.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else i=new V(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=S(t[0],t[0]=t[1]),e[1]=S(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var Ms=Vt;function Ys(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function Xs(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Fs(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function Rs(t,e,i,n,r,o,a,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),l=t,c=e,d=!1;m>u&&(c=S(l,l=c),n=S(i,i=n),u=S(m,m=u),d=!0);const g=0===i;{a[0]=g?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(f.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(l.getCoord2D(e[i])),!c.isCloserThanDistance(t,new D(0,1),r)){s=!1;break}if(s)return d&&(h[0]=S(a[0],a[0]=h[0])),1}}if(m<=3*r)return 0;let _=y(Math.max(r/m,.1),0,.5),p=.01*r,x=0,P=0,v=_,C=-1,b=0,E=1/32;for(let y=0;;y++){s(y<4095);const t=g?_:1-_,e=l.getCoord2D(t),i=c.getClosestCoordinate(e,!1);if(i===n)return b;const m=c.getCoord2D(i),u=f.distance(e,m);if(0===y&&(C=u),u<=p?(E=.5,P=u,x=_):(v=_,C=u),Math.abs(P-C)>.1*p&&v-x>1e-16)_=j(x,v,E);else{if(a[b]=t,h[b]=i,d&&(h[b]=S(a[b],a[b]=h[b])),1===o||1===b)return 1===b&&a[0]>a[1]&&(a[1]=S(a[0],a[0]=a[1]),h[1]=S(h[0],h[0]=h[1])),b+1;b++,x=v,P=C,v=.8,C=-1,_=.8,E=1/32,p=10*r,y=0}}}function Ls(t,e,s,i,n,r,o,a,h){if(G(s,0,1)&&G(i,0,1)){if(0===f.distance(t.getCoord2D(s),e.getCoord2D(i))){const h=1e-12,m=new Ns,u=st();if(t.queryDerivative(new V(s,u),m),m.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new V(s,u).add(e),m)}1===s&&m.negateThis();const l=new Ns;if(e.queryDerivative(new V(i,u),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new V(i,u).add(t),l)}1===i&&l.negateThis(),m.isZero()||m.normalize(),l.isZero()||l.normalize();const c=m.dotProduct(l),d=m.crossProduct(l);d.scaleError(3);const g=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(c.ge(gt)&&(d.isZero()||Math.abs(d.value())<g())){return Rs(t,e,s,i,n,r,o,a)}}}return 0}function zs(t,e,i){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(Ls(t,e,0,0,i,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(Ls(t,e,1,1,i,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(Ls(t,e,0,1,i,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(Ls(t,e,1,0,i,2,[0,0],[0,0]))return!0}return!1}function Vs(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function Bs(t,e,s){t.m_XStart=e,t.m_YStart=s}function ks(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Gs(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Hs(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function Ws(t,e){const s=new Bt;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=js(t,e),s}function js(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:Ms.getDefaultValue(1)}function Zs(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Us(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let r=1;r<t.m_description.getAttributeCount();r++){const i=t.m_description.getSemantics(r);for(let n=0,r=Ms.getComponentCount(i);n<r;n++){const r=Qs(t,e,i,n);s.setAttributeBasic(i,n,r)}}}function Os(t,e,s){s.isEmpty()&&r(""),Hs(t,e,s.getXY());const i=s.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let n=1,r=i.getAttributeCount();n<r;n++){const r=i.getSemantics(n),o=Ms.getComponentCount(r);for(let i=0;i<o;i++){Ks(t,e,r,i,s.getAttributeAsDbl(r,i))}}}function Qs(t,e,s,n){if((e<0||e>1)&&i(""),0===s)return(n<0||n>=2)&&i(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=Ms.getComponentCount(s);(n<0||n>=r)&&i("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:Ms.getDefaultValue(s)}function Ks(t,e,s,n,r){if((e<0||e>1)&&i(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:i(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:i(""):i(""),void t.endPointModified();const o=Ms.getComponentCount(s);(n<0||n>=o)&&i("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function $s(t,e){if(t===e)return;e.isEmpty()&&r("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Ms.getComponentCount(n);for(let s=0;s<r;s++){let i=Qs(e,0,n,s);Ks(t,0,n,s,i),i=Qs(e,1,n,s),Ks(t,1,n,s,i)}}}function Js(t,e){const s=re();de(e,t.m_description,s);let i=null;const n=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(n>0&&(i=new Array(2*n),A(i,e.getDefaultPointAttributes(),0,2,n),A(i,e.getDefaultPointAttributes(),n,2,n),null!==t.m_description))for(let o=1;o<e.getAttributeCount();o++){const a=s[o];if(-1!==a){const s=t.m_description.getPointAttributeOffset(a)-2,h=e.getPointAttributeOffset(o)-2,m=Ms.getComponentCount(e.getSemantics(o));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[n+h]=t.m_attributes[r+s]}}t.m_attributes=i,t.m_description=e}function ti(t){return t.absNorm()*P()}function ei(t,e){return Math.max(t.absNorm(),e.absNorm())*P()}function si(t,e,s){const i=new Ds;t.queryEnvelopeW(D.unit(),i);const n=new Ds;return e.queryEnvelopeW(D.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function ii(t,e,s){const i=Et(t,s),n=Et(e,s);i.sort(((t,e)=>t.compare(e))),n.sort(((t,e)=>t.compare(e)));for(let r=0;r<3;r++){if(i[r].compare(n[r])<0)return-1;if(0!==i[r].compare(n[r]))return 1}return 0}var ni=Vt;class ri{constructor(t){if(t.copy){if(this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description){this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice())}}else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:le(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:ce(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=le());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:ce(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);a("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=q(2*t,Number.NaN)),A(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),A(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(e){return t("not implemented"),0}snapControlPoints3D(){return t("not implemented"),!1}setCoordsForIntersector3D(e,s,i){t("not implemented")}transformAttribute(e,s,i,n,r){t("")}mergeVertexDescriptionImpl(t){const e=he(this.getDescription(),t);this.assignVertexDescription(e)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let r=1,o=n.getAttributeCount();r<o;r++){const s=n.getSemantics(r),i=ni.getComponentCount(s);for(let n=0;n<i;n++){Ks(this,0,s,n,t.getAttributeAsDbl(s,n));Ks(this,1,s,n,e.getAttributeAsDbl(s,n))}}}getStartXY(){return new f(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return Ws(this,0)}setStartXYZ(t){Zs(this,0,t)}setStartXYZCoords(t,e,s){Zs(this,0,Bt.construct(t,e,s))}queryStart(t){Us(this,0,t)}setStart(t){Os(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return Qs(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){Ks(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=ni.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=ni.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return s(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return s(0),0}getEndXY(){return new f(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return Ws(this,1)}setEndXYZ(t){Zs(this,1,t)}setEndXYZCoords(t,e,s){Zs(this,1,Bt.construct(t,e,s))}queryEnd(t){Us(this,1,t)}setEnd(t){Os(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return Qs(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){Ks(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("");const s=t;s.assignVertexDescription(this.m_description),s.m_attributes&&A(s.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),s.m_XStart=this.m_XStart,s.m_YStart=this.m_YStart,s.m_XEnd=this.m_XEnd,s.m_YEnd=this.m_YEnd,this.copyToImpl(s)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=D.constructEmpty();return s.vmin=Qs(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(Qs(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=f.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){s(0)}getCoordZ(t){return s(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=ni.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=qt.constructEmpty();this.queryLooseEnvelopeOnInterval(e,i);if(i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&f.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=ni.getComponentCount(e);t<s;t++){const s=Qs(this,0,e,t);Ks(this,0,e,t,Qs(this,1,e,t)),Ks(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,i,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==i||null!==n){const e=new Array(9),r=new Array(9),o=this.intersect(t,null,e,r,0);s(o<=9),0===o&&a(""),null!==i&&(i[0]=e[0]),null!==n&&(n[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,h=-1,m=o;return r=this.getStartXY(),h=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==n&&(n[0]=h),null!==i&&(i[0]=0)),r=this.getEndXY(),h=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==n&&(n[0]=h),null!==i&&(i[0]=1)),r=t.getStartXY(),h=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=h),null!==n&&(n[0]=0)),r=t.getEndXY(),h=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(h)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=h),null!==n&&(n[0]=1)),o}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return j(t,e,s)}moveTo(t){const e=this.isClosed(),s=new k;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){s(0)}getDescription(){return this.m_description}assignVertexDescription(t){Js(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=me(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=ue(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=le();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&e("wrong geometry type");const s=t;s.m_description=S(this.m_description,this.m_description=s.m_description),s.m_XStart=S(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=S(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=S(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=S(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=S(this.m_attributes,this.m_attributes=s.m_attributes),this.swapImpl(s)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let n=0,r=2*(this.m_description.getTotalComponentCount()-2);n<r;n++)if(!b(this.m_attributes[n],i.m_attributes[n],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,s,i){if(this.addAttribute(t),0===t&&this.isCurve()){(s<0||s>1)&&e("");const t=new k,n=0===s?i:0,r=1===s?i:0;t.setShiftCoords(n,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,s,i),this.setEndAttribute(t,s,i)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=ni.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}ri.s_maxMonotonicPartParams=8;class oi extends ri{constructor(t){super(t)}}class ai extends oi{isTrue3D(){return!0}constructor(t){super(t)}}function hi(t,e,s){mi(e,t.getStartXY(),t.getEndXY(),s)}function mi(t,e,s,i){Q(e,s,t,i)}function ui(t,e){return j(t.m_XStart,t.m_XEnd,e)}function li(t,e){return j(t.m_YStart,t.m_YEnd,e)}function ci(t,e){const s=t.getStartZ(),i=t.getEndZ();return j(s,i,e)}function di(t,e,s){const i=Ns.constructPoint2D(t.getStartXY()),n=Ns.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}function gi(t,e,s){e.value()<=.5?tt(2,Ns.constructPoint2D(t.getStartXY()),Ns.constructPoint2D(t.getEndXY()),e,s):et(2,Ns.constructPoint2D(t.getStartXY()),Ns.constructPoint2D(t.getEndXY()),e,s)}function _i(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function pi(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}function fi(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=S(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=S(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=S(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function xi(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:vi(t,e)?4:0}function yi(t,e,s,i,n,r,o,a){null!==i&&(i.length=2),null!==n&&(n.length=2),null!==s&&(s.length=2);const h=Pi(t,e,2,s,i,n,r,o,a);return i&&(i.length=h),n&&(n.length=h),s&&(s.length=h),h}function Pi(t,e,s,i,n,r,o,a,h){const m=bi(t,e.getStartXY(),o,!1),u=bi(t,e.getEndXY(),o,!1),l=bi(e,t.getStartXY(),o,!1),c=bi(e,t.getEndXY(),o,!1);let d=0,g=0;if(!Number.isNaN(m)){let s=!1;a&&G(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[g]=m),r&&(r[g]=0),i&&(i[g]=f.construct(e.m_XStart,e.m_YStart)),g++)}if(!Number.isNaN(u)){let o=!1;a&&G(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=u),r&&(r[g]=1),i&&(i[g]=f.construct(e.m_XEnd,e.m_YEnd))),g++)}if(2!==g&&!Number.isNaN(l)&&!(0===m&&0===l||0===u&&1===l)){let o=!1;a&&G(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=0),r&&(r[g]=l),i&&(i[g]=f.construct(t.m_XStart,t.m_YStart))),g++)}if(2!==g&&!Number.isNaN(c)&&!(1===m&&0===c||1===u&&1===c)){let o=!1;a&&G(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(d++,o=!0),o||(s>g&&(n&&(n[g]=1),r&&(r[g]=c),i&&(i[g]=f.construct(e.m_XEnd,e.m_YEnd))),g++)}if(g>0)return h&&(r=S(n,n=r)),2===g&&s>=2&&n&&n[0]>n[1]&&(n[1]=S(n[0],n[0]=n[1]),r&&(r[1]=S(r[0],r[0]=r[1])),i&&(i[1]=S(i[0],i[0]=i[1]))),g;if(d>0)return 0;const _=Ai(t,e,o);return Number.isNaN(_.x)?0:(i&&(i[0]=t.getCoord2D(_.x)),n&&(n[0]=_.x),r&&(r[0]=_.y),1)}function vi(t,e){const s=Ei(t,e.m_XStart,e.m_YStart),i=Ei(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=Ei(e,t.m_XStart,t.m_YStart),r=Ei(e,t.m_XEnd,t.m_YEnd);if(n<0&&r<0||n>0&&r>0)return!1;return wi(t)>wi(e)?Si(t,e):Si(e,t)}function Ci(t,e){const s={bIntersect:!1,t1:Number.NaN,t2:Number.NaN},i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return s;const h=e.m_XStart-t.m_XStart,m=e.m_YStart-t.m_YStart,u=r*m-h*o,l=i*m-h*n,c=1/a;return s.t1=u*c,s.t2=l*c,s.bIntersect=!0,s}function bi(t,e,s,i){const n=f.getNAN(),r=f.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(n.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,m=f.getNAN();m.setSub(e,n);let u=m.length(),l=3*u*st();if(u<=Math.max(s,l))return i&&0===u?Number.NaN:a;if(m.setSub(e,r),u=m.length(),l=3*u*st(),u<=Math.max(s,l))return i&&0===u?Number.NaN:h;m.setCoords(r.x-n.x,r.y-n.y);const c=m.length();if(c>0){const t=1/c;m.scale(t);const i=f.getNAN();i.setSub(e,n);const u=i.dotProduct(m),l=8*i.dotProductAbs(m)*st();m.leftPerpendicularThis();const d=i.dotProduct(m),g=8*i.dotProductAbs(m)*st(),_=Math.max(s,l);if(u<-_||u>c+_)return Number.NaN;const p=Math.max(s,g);if(Math.abs(d)<=p){let i=u*t;i=y(i,0,1);const m=f.getNAN();if(mi(i,n,r,m),f.distance(m,e)<=s){if(i<.5){if(f.distance(m,n)<=s&&f.distance(e,n)<=s)return a}else if(f.distance(m,r)<=s&&f.distance(e,r)<=s)return h;return o?1-i:i}}}return Number.NaN}function Ei(t,e,s){const i=f.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=f.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const r=n.crossProduct(i),o=4*st()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?-1:r<-o?1:0}function Di(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,r=i?t.m_YStart:t.m_YEnd,o=f.getNAN();o.x=e.getEndX()-n,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*st()*s.dotProductAbs(o)){o.x=e.getStartX()-n,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*st()*s.dotProductAbs(o)}return!0}function Si(t,e){const s=f.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Di(t,e,s,!1)&&(s.negateThis(),!!Di(t,e,s,!0))}function wi(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function Ai(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return f.getNAN();const h=4*st()*(Math.abs(r*n)+Math.abs(i*o)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,l=r*u-m*o,c=4*st()*(Math.abs(r*u)+Math.abs(m*o)),d=l/a,g=Math.abs(a),_=(c*g+h*Math.abs(l))/(a*a)+st()*Math.abs(d);if(d<-_||d>1+_)return f.getNAN();const p=i*u-m*n,x=p/a,v=(4*st()*(Math.abs(i*u)+Math.abs(m*n))*g+h*Math.abs(p))/(a*a)+st()*Math.abs(x);if(x<-v||x>1+v)return f.getNAN();let C=y(d,0,1),b=y(x,0,1);const E=f.getNAN();hi(t,C,E);const D=f.getNAN();if(hi(e,b,D),!s||f.distance(E,D)>s){const i=f.getNAN();Q(E,D,.5,i),C=t.getClosestCoordinate(i,!1),b=e.getClosestCoordinate(i,!1);const n=f.getNAN();hi(t,C,n);const r=f.getNAN();hi(e,b,r),n.subThis(r);const o=n.length(),a=(t.absNorm()+e.absNorm())*P();if(o>Math.max(s,a))return f.getNAN()}return new f(C,b)}class Ti{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&i("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&i("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&i(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&i(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&o(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&i(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&i(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&i(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){if(null!==this.m_segFlagStream){return 1!==(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}return!1}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class Ii{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&(s(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Ii;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0==--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){s(this.uniqueUse())}setQuadTree(t){s(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){s(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Ni(t){return!(t.isEmpty()||t.getGeometryType()!==n.enumPolyline&&t.getGeometryType()!==n.enumPolygon)&&!(t.getPointCount()<20)}function qi(t){return!(t.isEmpty()||t.getGeometryType()!==n.enumPolyline&&t.getGeometryType()!==n.enumPolygon)&&!(t.getPointCount()<20)}function Mi(t,e){return t.readPoint2D(e+4)}function Yi(t){const e=t.getGeometryType();return e===n.enumEllipticArc?10:e===n.enumBezier?4:e===n.enumRationalBezier2?5:e===n.enumBezier2?2:void a("")}function Xi(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function Fi(t,e,i,n){const r=4*st()*(Math.abs(e.vmin)+Math.abs(e.vmax)),o=st();if(1===t.getMaxDerivative()){s(i>0);const o=Gi(t,0,e,st(),r);return n[0]=o.root,o.cRoots}let a,h=[];const m=new D(e.vmin-r,e.vmax+r);h.push(new f(m.vmin,m.vmax));let u=0;for(let s=t.getMaxDerivative()-1;s>=0;s--){a=h,h=[];for(let m=0,l=a.length;m<l;m++){if(a[m][0]<a[m][1]){let l,c,d;if(s===t.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:d}=Gi(t,s,D.construct(a[m][0],a[m][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:d}=Hi(t,s,D.construct(a[m][0],a[m][1]),o,.5*r)),1===d){if(0===s){if(u<i){if(a[m][0]<=e.vmin&&a[m][1]>=e.vmin&&l!==e.vmin){0===t.getValue(0,e.vmin)&&(l=e.vmin)}if(a[m][0]<=e.vmax&&a[m][1]>=e.vmax&&l!==e.vmax){0===t.getValue(0,e.vmax)&&(l=e.vmax)}n[u]=e.snapClip(l),u>0?n[u]-n[u-1]>r&&u++:u++}}else{const t=f.getNAN();t[0]=a[m][0],t[1]=l,h.push(t);const e=f.getNAN();e[0]=l,e[1]=a[m][1],h.push(e)}continue}}h.push(a[m])}}return u}function Ri(t,e,s,i){const n=new V,r=Zi(new V(t),new V(e),s,n);return i[0]=n.value(),r}function Li(t,e,s,i,n,r){const o=x(V,2),a=Ui(new V(t),new V(e),new V(s),i,n,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function zi(t,e,s,i,n,r,o){const a=x(V,3),h=Oi(new V(t),new V(e),new V(s),new V(i),n,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function Vi(t,e,s,i,n,r,o,a){return ki(t,e,s,i,n,r,o,a)}function Bi(t,e,s,i,n,r){return ji(t,e,s,i,n,r)}function ki(t,e,s,i,n,r,o,a){const h=new Array(s*s);h.fill(0),A(a,i,0,0,s);const m=new Array(s),u=new Array(s),l=new Array(s);let c=t(a,s,e);const d=100;let g=0;for(g=0;g<d;g++){const i=c;for(let t=0;t<s;++t)u[t]=a[t];if(g%s==0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,d=0;for(let u=0;u<s;++u){for(let t=0;t<s;++t)m[t]=h[u*s+t];const i=c;c=Wi(t,e,a,m,n,r,s);const l=i-c;l>o&&(d=u,o=l)}for(let t=0;t<s;t++)m[t]=a[t]-u[t],l[t]=a[t]+(a[t]-u[t]);const _=t(l,s,e);if(_<i){if(2*(i-2*c+_)*C(i-c-o)<C(i-_)*o){c=Wi(t,e,a,m,n,r,s);for(let t=0;t<s;++t)h[d*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=m[t]}}if(i<=c)return t(a,s,e)}return c}function Gi(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,h=s.vmax,m=0,u=Number.MAX_VALUE,l=t.getValue(e,o),c=t.getValue(e,h),d=0,g=0,_=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(r.funcAtRoot=l,r.root=o,r.cRoots=0===l?1:0,r):(r.funcAtRoot=c,r.root=h,r.cRoots=0===c?1:0,r);Math.abs(l)<Math.abs(c)&&(h=S(o,o=h),c=S(l,l=c)),m=o,d=l;let p=!0,f=0;for(;0!==c&&Math.abs(o-h)>i*Math.abs(h)+n;f++){let s=f>64;if(!s){g=l!==d&&c!==d?o*c*d/((l-c)*(l-d))+h*l*d/((c-l)*(c-d))+m*l*c/((d-l)*(d-c)):h-c*(h-o)/(c-l);const t=(3*o+h)/4;if(s=!(g>t&&g<h||g>h&&g<t),!s){const t=i*Math.abs(h)+n;if(p){const e=Math.abs(h-m);s=Math.abs(g-h)>=.5*e||e<t}else{const e=Math.abs(m-u);s=Math.abs(g-h)>=.5*e||e<t}}}if(s?(g=(o+h)/2,p=!0):p=!1,_=t.getValue(e,g),0===_)return r.root=g,r.funcAtRoot=_,r.cRoots=1,r;if(!s){const s=o-g,i=g-h;if(Math.abs(s)>10*Math.abs(i)){let s=h+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);ct(l)*ct(i)>0?(o=s,l=i):s=j(o,h,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=o-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);ct(c)*ct(s)>0?(h=i,c=s):i=j(o,h,.25)}}}u=m,m=h,d=c,ct(l)*ct(_)<0?(h=g,c=_):(o=g,l=_),Math.abs(l)<Math.abs(c)&&(h=S(o,o=h),c=S(l,l=c)),128===f&&a("Root_finder iterations exceeded")}return r.root=h,r.funcAtRoot=c,r.cRoots=1,r}function Hi(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,h=t.getValue(e,o),m=s.vmax,u=t.getValue(e,m);if(h>=0&&u>=0||h<=0&&u<=0)return Math.abs(h)<Math.abs(u)?(r.funcAtRoot=h,r.root=o,r.cRoots=0===h?1:0,r):(r.funcAtRoot=u,r.root=m,r.cRoots=0===u?1:0,r);u<0&&(u=S(h,h=u),m=S(o,o=m));let l=.5*(o+m),c=Math.abs(m-o),d=c,g=t.getValue(e,l),_=t.getValue(e+1,l);const p=1,f=4;let x=f;const y=2;let P=1,v=0,C=0,b=p;const E=32;let D=0;for(;++D<100;){let s;D>E||0===_||b===y&&v>1||b===p&&x<f?(b=p,P>1&&P--):(b=y,C>1&&Math.abs(2*g)>Math.abs(c*_)&&P++),c=d;let i=!1;if(b===p)do{if(C>2){const t=16*Math.abs(c);if(.5*Math.abs(o-m)>t){const e=Math.min(o,m),i=Math.max(o,m);if(l===e){s=l,l=e+t,d=l-s;break}if(l===i){s=l,l=i-t,d=l-s;break}}}d=.5*(m-o),s=l,l=o+d,i=o===l||m===l}while(0);else for(;;){d=P*g/_,s=l,l-=d,i=l===s;const t=Math.min(o,m),e=Math.max(o,m);if(l<t){if(P>1){l=s,P--;continue}d=s-t,l=t}else if(l>e){if(P>1){l=s,P--;continue}d=s-e,l=e}break}if(i||Math.abs(d)<n){s!==l&&(g=t.getValue(e,l));break}g=t.getValue(e,l),_=t.getValue(e+1,l);const r=o,a=m;g<0?(h=g,o=l):(u=g,m=l),b===y&&(o===r&&m===a||C>1&&Math.abs(d)>=.5001*Math.abs(c))?v++:v=0,b===p?(x++,C=0):(x=0,C++)}return 100===D&&a("Root_finder iterations exceeded"),r.root=l,r.funcAtRoot=g,r.cRoots=1,r}function Wi(t,e,s,i,n,r,o){const a=i.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=i[f]*i[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let m=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(o);for(let e=0;e<o;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(a[t]),i=Math.abs(a[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<o;e++){const i=t[e];if(0===a[i])continue;let o=(n[i]-s[i])/a[i],h=(r[i]-s[i])/a[i];h<o&&(h=S(o,o=h)),o>m&&(m=o),h<u&&(u=h)}}let l=0;const c=(Math.abs(m)+Math.abs(u))*st()*100,d=new Array(o),g=a.slice();function _(i,n){for(let t=0,e=o;t<e;t++)d[t]=s[t]+i*g[t];return t(d,o,e)}c>0&&(l=Bi(_,null,m,0,u,c));const p=_(l);for(let f=0,x=o;f<x;f++)s[f]=y(d[f],n[f],r[f]);return p}function ji(t,e,s,i,n,r){const o=It();let a=i,h=t(a,e),m=s,u=n,l=t(m,e),c=t(u,e);h>l&&(h=l,a=m),h>c&&(h=c,a=u);let d=m,g=u,_=l,p=c;_>p&&(_=S(p,p=_),g=S(d,d=g));let f=a-d,x=d-g;const y=.5*Math.min(r,u-m),P=2*y,v=100;let C,b=0;for(C=0;C<v&&!(u-m<=P);++C){const s=m+.5*(u-m);let i=b>0;if(!i&&Math.abs(x)<=y&&(i=!0,b=3),!i){const t=a-d,e=a-g,s=t*(h-p);let n=e*(h-_),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*x/2)||r<=n*(m-a)||r>=n*(u-a)?(i=!0,b=3):(x=f,f=r/n)}i&&(x=a>=s?m-a:u-a,f=o*x,b--);let n=a+f;n<m+y?n=m+y:n>u-y&&(n=u-y);const r=t(n,e);r<h?(n>=a?(m=a,l=h):(u=a,c=h),g=d,d=a,a=n,p=_,_=h,h=r):(n<a?(m=n,l=r):(u=n,c=r),r<=_||d===a?(g=d,d=n,p=_,_=r):(r<=p||g===a||g===d)&&(g=n,p=r))}return a}function Zi(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Ui(t,e,s,i,n,r){if(0===t.value()){if(n)return r[0].set(1),i.containsCoordinate(r[0].value())?1:0;return Zi(e,s,i,r[0])}if(n){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),i.containsCoordinate(r[1].value())||(e=1),i.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=S(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(_t));if(o.lt(gt))return 0;const a=new V(e.value()>=0?1:-1),h=o.clone().sqrtThis(),m=new V(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let u=0;r[0].setE(m.divE(t));const l=new V(r[0].value()),c=new V(t.value()).mulE(l).addE(new V(e.value()).mulE(l).addE(new V(s.value())));return c.isZero()||sn(r[0],t,e,s,r[0]),i.containsCoordinate(r[0].value())&&u++,0!==h.value()&&0!==m.value()?(r[u].assign(s.divE(m)),l.set(r[u].value()),c.assign(new V(t.value()).mulE(l).addE(new V(e.value()).mulE(l).addE(new V(s.value())))),c.isZero()||sn(r[u],t,e,s,r[u]),i.containsCoordinate(r[u].value())&&u++,2===u&&r[0].value()>r[1].value()&&(r[1]=S(r[0],r[0]=r[1])),u):u}function Oi(t,e,s,i,n,r,o){if(0===t.value()){return Ui(e,s,i,n,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=Ui(t,e.addE(t),i.negate(),n,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(dt)&&(o[s-1]=S(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)o[t]=h[t];return s}return nn(t,e,s,i,n,o)}function Qi(t,s,i,n,r,o){return(o<s||s<0)&&e("nth_degree_real_roots"),rn(t,s,i,n,r)}function Ki(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class $i{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=this.truePower-t+1;for(let s=0,i=this.truePower-t;s<=i;++s){e[s]=this.coefs[s+t].clone();let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let n=e;n>=1;n--)if(0!==this.coefs[n].value()){this.truePower=n;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new X(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new X(0),i=new V(1),n=new V(0);for(let o=0,a=this.power;o<=a;++o)n.addThisE(this.coefs[o].mulE(i)),s.pe(i.value()*this.coefs[o].eps()),i.mulThis(e);s.pe(n.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new V(1),i=new V(0);for(let s=0,n=this.truePower-o;s<=n;++s)i.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!i.isZero())return Math.pow(r*s.getResult()/Math.abs(i.value()),1/o)}return 0}}function Ji(t,e,s,i,n,r){let o=t,a=e,h=a-o;if(!r){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(a=S(o,o=a),n=S(s,s=n)),s>=0||n<=0)return!1}let m,u=!1,l=s,c=0;for(;c<100;c++){const t=i.calcF(l);if(m=i.calcDF(l),m.isZero())return!1;if(!t.value()||c>3&&t.isZero()){u=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/m.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!u&&(n.set(l,i.estimateError(l)),!0)}function tn(t,e,s,i,n,r,o,a){return Ji(t,e,s.value(),Ki(i,n,r,o),a,!1)}class en{constructor(t,e,s){this.coefs=x(V,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new V(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new V(t);return V.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new V(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function sn(t,e,s,i,n){return Ji(0,0,t.value(),new en(e,s,i),n,!0)}function nn(t,e,s,i,n,r){const o=x(V,3);let h=0;const m=e.negate().divThisE(t.clone().mulThis(3));n.containsCoordinate(m.value())&&(o[0].setE(m),h=1);const u=x(V,2),l=Ui(t.mul(3),e.mul(2),s,n,!1,u);if(l<0)return i.isZero()?-1:0;for(let a=0;a<l;a++)n.containsCoordinate(u[a].value())&&o[h++].setE(u[a]);M(o,0,h,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const c=x(V,5);c[0].set(n.vmin);for(let a=0;a<h;a++)c[1+a].setE(o[a]);c[1+h].set(n.vmax);const d=h+2;let g=1,_=0;{const n=c[0].clone();if(t.clone().mulThisE(n).addThisE(e).mulThisE(n).addThisE(s).mulThisE(n).addThisE(i).isZero()){const o=Ki(t,e,s,i);n.setError(o.estimateError(n.value())),r[_]=n,_++,g++}}for(let p=g;p<d;p++){const o=c[p].clone(),h=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(i).isZero();if(h||!c[p].eq(c[p-1])){if(h||tn(c[p-1].value(),c[p].value(),c[p-1].clone().addThisE(c[p]).divThisByPower2(2),t,e,s,i,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&a("cubic_polynomial_solver_too_many_roots"),h){const n=Ki(t,e,s,i);o.setError(n.estimateError(o.value()))}r[_]=o,_++}if(c[p].value()===n.vmax)break;h&&p++}}return _}function rn(t,e,s,i,n,r){const o=new $i(t,e,s,st());let a=0;if(2===o.truePower)a=Ui(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Zi(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=Fi(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let h=0;h<a;h++)n[h].setError(o.getError(n[h].value()));return a}var on=Vt;class an extends oi{constructor(t){void 0===t||F(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new f(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):a("unexpected constructor args")}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),go(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),go(this)}getGeometryType(){return n.enumBezier2}queryEnvelope(e){if(2!==e.m_EnvelopeType)t("env type not impl");else{if(e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY()),e.contains(this.m_cp))return;const t=To(this);if(null!==t){const s=new f;for(const i of t.specialPoints)this.queryCoord2D(i,s),e.mergeNe(s)}else{const t=[];fo(this,t);const s=new f;for(const i of t)this.queryCoord2D(i,s),e.mergeNe(s)}}}applyTransformation(t){if(1===t.m_TransformationType){const e=x(f,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}s(0)}createInstance(){return new an({vd:this.m_description})}calculateLength2D(){return xo(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return f.distance(this.getStartXY(),this.m_cp)+f.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=x(f,3);this.queryControlPoints(i),ea(i,t,e,s)}queryCoord2DE(t,e){sa(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=R(this.getStartX(),this.m_cp.x,t),s=R(this.m_cp.x,this.getEndX(),t);return R(e,s,t)}{const e=L(this.getStartX(),this.m_cp.x,t),s=L(this.m_cp.x,this.getEndX(),t);return L(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=R(this.getStartX(),this.m_cp.x,t),s=R(this.m_cp.x,this.getEndX(),t);return R(e,s,t)}{const e=L(this.getStartY(),this.m_cp.y,t),s=L(this.m_cp.y,this.getEndY(),t);return L(e,s,t)}}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=on.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=on.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){na(this,t,e)}cutBezierIgnoreAttributes(t,s,i){if((t<0||s>1||t>s)&&e("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===s)return i.setStartXY(this.getStartXY()),i.m_cp.assign(this.m_cp),void i.setEndXY(this.getEndXY());const n=x(f,3);this.queryControlPoints(n),Bo(n,t,s,n),i.constructPoints(n)}splitBezierIgnoreAttributes(t,e,i){s(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=on.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,on.getDefaultValue(e))}getClosestCoordinate(t,e){return No(this,t,D.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return No(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=po(this);let r=0;if(2===n.specialPointsCount())return 0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){Ro(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){const n=x(V,3),r=x(V,2),o=new D(0,1);let a=0;if(t){if(n[0]=new V(this.getStartY()).sub(e),n[1]=new V(this.m_cp.y).subE(new V(this.getStartY())).mulThisByPower2(2),n[2]=new V(this.getStartY()).add(this.getEndY()).subE(new V(this.m_cp.y).mulThisByPower2(2)),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordX(r[h].value())}else if(n[0]=new V(this.getStartX()).sub(e),n[1]=new V(this.m_cp.x).subE(new V(this.getStartX())).mulThisByPower2(2),n[2]=new V(this.getStartX()).add(this.getEndX()).subE(new V(this.m_cp.x).mulThisByPower2(2)),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let h=0;h<a;h++)s[h]=this.getCoordY(r[h].value());if(i)for(let h=0;h<a;h++)i[h]=r[h].value();else s&&B(s,a);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new qt;this.queryEnvelope(t);const s=new D;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,4);this.queryControlPoints(s),Bo(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return xo(this,t,!0)}lengthToT(t){return Do(this,t)}calculateWeightedAreaCentroid2D(t){const e=x(f,3);Ko(this,e);const s=e[2],i=e[1],n=new f,r=s.y*i.x-s.x*i.y;n.x=-(4*s.x+5*i.x)*r/60,n.y=-(4*s.y+5*i.y)*r/60;const o=So(this);return n.x+=(e[0].x-t.x)*o,n.y+=(e[0].y-t.y)*o,n}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):Ao(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(zo(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(t){for(let s=0;s<3;s++)t[s].isNAN()&&e("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=y(t,0,1);let s=Co(this,1,e);return s.isZero()&&(s=Co(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Co(this,1,y(t,0,1))}getCurvature(t){const e=Co(this,1,t),s=Co(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new qt;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),r=new f;this.queryCoord2D(n,r);return f.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,s){const i=po(this),n=i.specialPointsCount();if(!s)return i.specialPointsCount();t<n&&e("");for(let e=0;e<n;e++)s[e]=i.specialPoints[e];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){S(this.m_XStart,this.m_XStart=this.m_XEnd),S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=[t];if(!Fs(this,e))return!1;const s=this.getEndXY().sub(this.getStartXY()),i=s.length(),n=this.getControlPoint1();n.sub(this.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e[0])}copyIgnoreAttributes(t){const e=x(f,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return So(this)}absNorm(){return Go(this)}queryEnvelopeW(t,e){const s=x(f,3);this.queryControlPoints(s),Xo(s,t,e)}setSegmentFromCoords(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return ma(this,t)}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(t){return ua(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return Ro(this)}setCoordsForIntersector(t,e,s){ko(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Io(e,To(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=S(this.m_cp,this.m_cp=e.m_cp),_o(this,e)}afterCompletedModification(){go(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Mo(this,t,e.length,e,s)}endPointModified(){go(this)}clearEndPointModified(){}}an.type=n.enumBezier2;var hn=Vt;class mn extends oi{constructor(s){return void 0===s||F(s,"vd")?(super({vd:s?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new f(0,0),void(this.m_weights=[1,0,1])):(s.fromPoint&&s.weight?s={fromPoint:s.fromPoint,controlPoint1:s.controlPoint1,toPoint:s.toPoint,weight0:1,weight1:s.weight,weight2:1}:s.points&&s.weight?s={fromPoint:s.points[0],controlPoint1:s.points[1],toPoint:s.points[2],weight0:1,weight1:s.weight,weight2:1}:s.points&&s.weights&&(s={fromPoint:s.points[0],controlPoint1:s.points[1],toPoint:s.points[2],weight0:s.weights[0],weight1:s.weights[1],weight2:s.weights[2]}),s.fromPoint&&s.weight0?(super({start:s.fromPoint,end:s.toPoint}),(s.weight0<=0||s.weight1<0||s.weight2<=0)&&e("weights"),this.m_cp=s.controlPoint1.clone(),void(this.m_weights=[s.weight0,s.weight1,s.weight2])):s.copy?(super(s),this.m_cp=s.copy.m_cp.clone(),void(this.m_weights=s.copy.m_weights.slice())):s.move?(super(s),this.m_cp=s.move.m_cp.clone(),void(this.m_weights=s.move.m_weights.slice())):void t("unexpected constructor param"))}getBoundary(){return Vh(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Kn(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),Kn(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Kn(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return n.enumRationalBezier2}queryEnvelope(t){if(t instanceof qt){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=br(this);if(null!==e){const s=new f;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=x(f,3);this.queryControlPoints(s),tr(s,this.m_weights,e);const i=new f;for(const n of e)this.queryCoord2D(n,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof k){const e=x(f,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new mn({vd:this.m_description})}calculateLength2D(){return er(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return f.distance(this.getStartXY(),this.m_cp)+f.distance(this.getEndXY(),this.m_cp)}return f.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){$r(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void hi(new rl({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void hi(new rl({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const i=x(f,3);this.queryControlPoints(i),eo(i,this.m_weights,t,e)}getCoordX(t){const e=new f;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new f;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=hn.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=hn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){lr(this,t,e)}cutBezierIgnoreAttributes(t,s,i){(t<0||s>1||t>s)&&e("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const n=x(f,3);this.queryControlPoints(n);const r=[0,0,0];Fr(n,this.m_weights,t,s,n,r),i.setControlPointsAndWeights(n,r)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=hn.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,hn.getDefaultValue(e))}getClosestCoordinate(t,e){return Dr(this,t,D.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return Dr(this,t,e,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=Jn(this);let r=0;if(2===n.specialPointsCount())return 0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){qr(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),r=x(V,2),o=new D(0,1);let a=0;const h=x(f,3);if(this.queryControlPoints(h),t){if(n[0]=new V(h[0].y).sub(e).mul(this.m_weights[0]),n[1]=new V(h[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new V(h[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordX(r[m].value())}else if(n[0]=new V(h[0].x).sub(e).mul(this.m_weights[0]),n[1]=new V(h[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new V(h[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Ui(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordY(r[m].value());if(i)for(let m=0;m<a;m++)i[m]=r[m].value();else s&&M(s,0,a,U);return a}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof qt)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=qt.constructEmpty();this.queryEnvelope(t);const s=D.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,3);this.queryControlPoints(s);const i=[0,0,0];Fr(s,this.m_weights,t.vmin,t.vmax,s,i),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return er(this,t,!0)}lengthToT(t){return _r(this,t)}calculateWeightedAreaCentroid2D(t){const e=yr(this),s=pr(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):Cr(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Yr(this,1)),t)}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=x(f,3);return this.queryControlPoints(e),dr(e,this.m_weights,t)}getDerivative(t){const e=y(t,0,1),s=x(f,4);return sr(this,1,e,s),s[1]}getCurvature(t){const e=x(f,4);sr(this,2,t,e);const s=e[1].sqrLength();if(0===s)return Number.NaN;e[1].divThis(Math.sqrt(s));return e[1].crossProduct(e[2])/s}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=x(f,3);return this.queryControlPoints(t),Nr(t)}getMonotonicPartParams(t,s){const i=Jn(this),n=i.specialPointsCount();if(!s)return i.specialPointsCount();t<n&&e("");for(let e=0;e<n;e++)s[e]=i.specialPoints[e];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=S(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!Fs(this,e)&&Br(this,e[0])}copyIgnoreAttributes(t){const e=x(f,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return pr(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return s(0),0}queryEnvelopeW(t,e){Tr(this,t,e)}setSegmentFromCoords(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=x(f,3);this.queryControlPoints(e);const s=f.sqrDistance(e[1],e[0]),i=f.sqrDistance(e[1],e[2]);let n=e[0].clone(),r=s;s>i&&(n=e[2].clone(),r=i);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(n)),o}needsSnapControlPoints(t){if(!t)return!1;const e=x(f,3);this.queryControlPoints(e);const s=f.sqrDistance(e[1],e[0]),i=f.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return qr(this)}setCoordsForIntersector(t,e,s){Lr(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],Er(e,br(this))}reverseImpl(){this.m_weights[2]=S(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=x(f,3);this.queryControlPoints(i);const n=x(f,3);s.queryControlPoints(n);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new Bt;t.setCoordsPoint2DZ(i[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new Bt;if(s.setCoordsPoint2DZ(n[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=S(this.m_cp,this.m_cp=e.m_cp),e.m_weights=S(this.m_weights,this.m_weights=e.m_weights),$n(this,e)}afterCompletedModification(){Kn(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Ar(this,t,e,s)}endPointModified(){Kn(this)}clearEndPointModified(){}setCpsAndWeights(t,s,i,n,r,o){(n<=0||o<=0||r<0)&&e("weights"),(t.isNAN()||s.isNAN()||i.isNAN())&&e("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(s),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(i)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}mn.type=n.enumRationalBezier2;class un{static constructPoint2D(t){return new un(Z.constructDouble(t.x),Z.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new Z).setNAN(),void(this.y=(new Z).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new f(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new un(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new un(this.x.add(t.x),this.y.add(t.y))}sub(t){return new un(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}class ln{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map((t=>t.clone())),s(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map((t=>t.clone())),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map((t=>t.clone())),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}fmSubThis(t,e){return s(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return s(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(t){return s(0),this}subNumber0(t){return s(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let o=e;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let o=s+1;o<this.m_elements.length;++o)this.m_elements[o]=new this.m_zeroCtor;for(let o=n+1;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let a=i+1;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=n;++a)this.m_elements[a].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let n=0,r=e.power();n<=r;n++){const i=this.m_elements[t].clone();i.mulThis(e.m_elements[n]),t+n<s.length?s[t+n].addThis(i):s.push(i)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(t){return s(0),this}mulBigint0(t){return s(0),this}mulBigIntThis(t){return s(0),this}mulInt320(t){return s(0),this}div0(t){return s(0),this}absThis(){return s(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let r=n.power();const o=n.power()-t.power();let a=o;for(e.m_elements=x(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(n);break}if(r===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(t){return s(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){s(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(Z.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce(((t,e)=>{const s=e.hiBitIndex();return t<s?s:t}),0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class cn extends ln{constructor(t){super(void 0===t?{zeroCtor:Z}:{...t,zeroCtor:Z})}clone(){return new cn({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let n=e-1;n>=0;--n)s.mulThis(i),s.addThis(this.m_elements[n].abs());return s}}class dn extends ln{constructor(t){super(void 0===t?{zeroCtor:cn}:{...t,zeroCtor:cn})}clone(){return new dn({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new cn({coef0:t[s]}));return this.updatePower(),this}}function gn(){return{polypoly1:new dn,polypoly2:new dn,polyX2:new cn,polyY2:new cn,polyX2Deriv:new cn,polyY2Deriv:new cn,polypolyX1:new dn,polypolyY1:new dn,polypolyX1Deriv:new dn,polypolyY1Deriv:new dn,lazyPolypolyD1:new dn,lazyPolypolyD1Deriv:new dn,lazyPolyD2:new cn,lazyPolyD2Deriv:null,polypoly11:new dn,polypoly12:new dn,tempPp:new dn,tempPp1:new dn,tempPp2:new dn,tempP:new cn,tempP1:new cn,tempP2:new cn}}function _n(t,e,i,n,r,o,h,m,u,l,c,d,g,_,p,f,x,y=!1){const P=gn();P.polyX2.construct(h,m),P.polyY2.construct(u,l),P.polypolyX1.constructFromMPValues(t,e),P.polypolyY1.constructFromMPValues(i,n),P.polypoly11.assignCopy(P.polypolyX1),P.polypoly12.assignCopy(P.polypolyY1),c&&(P.lazyPolyD2.construct(c,d),P.polypoly11.mulElementThis(P.lazyPolyD2),P.polypoly12.mulElementThis(P.lazyPolyD2)),r?(P.lazyPolypolyD1.constructFromMPValues(r,o),P.lazyPolypolyD1Deriv=new dn({copy:P.lazyPolypolyD1}),P.lazyPolypolyD1Deriv.derivative1This(),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyX2),P.polypoly11.subThis(P.tempPp),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyY2),P.polypoly12.subThis(P.tempPp)):(P.polypoly11.sub0This(P.polyX2),P.polypoly12.sub0This(P.polyY2)),P.polypolyX1Deriv.assignCopy(P.polypolyX1),P.polypolyX1Deriv.derivative1This(),P.polypolyY1Deriv.assignCopy(P.polypolyY1),P.polypolyY1Deriv.derivative1This(),r&&(P.polypolyX1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyX1),P.polypolyX1Deriv.subThis(P.tempPp2),P.polypolyY1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyY1),P.polypolyY1Deriv.subThis(P.tempPp2)),P.polyX2Deriv.assignCopy(P.polyX2),P.polyX2Deriv.derivative1This(),P.polyY2Deriv.assignCopy(P.polyY2),P.polyY2Deriv.derivative1This(),c&&(s(null===P.lazyPolyD2Deriv),P.lazyPolyD2Deriv=new cn({copy:P.lazyPolyD2}),P.lazyPolyD2Deriv.derivative1This(),P.polyX2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyX2),P.polyX2Deriv.subThis(P.tempP1),P.polyY2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyY2),P.polyY2Deriv.subThis(P.tempP1)),P.polypoly1.assignCopy(P.polypoly11),P.polypoly1.mulElementThis(P.polyX2Deriv),P.tempPp.assignCopy(P.polypoly12),P.tempPp.mulElementThis(P.polyY2Deriv),P.polypoly1.addThis(P.tempPp),P.polypoly2.assignCopy(P.polypolyX1Deriv),P.polypoly2.mulElementThis(P.polyY2Deriv),P.tempPp.assignCopy(P.polypolyY1Deriv),P.tempPp.mulElementThis(P.polyX2Deriv),P.polypoly2.subThis(P.tempPp);let v=[];const C=[];x||(x=[]),f||(f=[]),Dn(P.polypoly11,P.polypoly12,P.tempP);let b=57,E=.25*Number.EPSILON;const D=[];let S=Sn(P.tempP,g,p,E,b,D);if(S<0)return-1;for(let s=0;s<S;s++){cn.evaluateCoefs(P.polypoly11,Z.constructDouble(D[s]),P.tempP1);const t=[];let e=Sn(P.tempP1,g,_,E,b,t);if(0!==e)if(cn.evaluateCoefs(P.polypoly12,Z.constructDouble(D[s]),P.tempP2),e<0){e=Sn(P.tempP2,g,_,E,b,t),e<0&&a("mp_curve_proximity");for(let i=0;i<e;i++)C.push(xt(t[i],D[s]))}else{const i=P.tempP2.absEvaluate(ft);i.mulThis(Z.constructDouble(1e-12));for(let n=0;n<e;n++){const e=P.tempP2.evaluate(Z.constructDouble(t[n]));e.absThis(),e.lt(i)&&C.push(xt(t[n],D[s]))}}}S=C.length,Dn(P.polypoly1,P.polypoly2,P.tempP),b=57,E=.25*Number.EPSILON;const w=[];let A=Sn(P.tempP,g,p,E,b,w);A<0&&(A=0);for(let s=0;s<A;s++){cn.evaluateCoefs(P.polypoly1,Z.constructDouble(w[s]),P.tempP1);const t=[];let e=Sn(P.tempP1,g,_,E,b,t);if(0!==e)if(cn.evaluateCoefs(P.polypoly2,Z.constructDouble(w[s]),P.tempP2),e<0){if(e=Sn(P.tempP2,g,_,E,b,t),e<0)continue;for(let i=0;i<e;i++)v.push(xt(t[i],w[s]))}else{const i=P.tempP2.absEvaluate(ft);i.mulThis(Z.constructDouble(1e-12));for(let n=0;n<e;n++){const e=P.tempP2.evaluate(Z.constructDouble(t[n]));e.absThis(),e.lt(i)&&v.push(xt(t[n],w[s]))}}}if(A=v.length,0===S&&0===A)return 0;v=v.concat(C),v.sort(((t,e)=>y?U(t.second,e.second):U(t.first,e.first)));const T=Dt(v,((t,e)=>t.first===e.first&&t.second===e.second));v=v.slice(0,T),f.length=0,x.length=0;for(const s of v)f.push(s.first),x.push(s.second);return s(f.length===x.length),x.length}function pn(t,e,s,i,n,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(Z.constructInt32(1)).isZero();if(1===t.power()){const s=yn(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(i),1!==s?0:(r[0].limitPrecisionThis(i),1)}if(2===t.power()){return Pn(t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(3===t.power()){return vn(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(4===t.power()){return Cn(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}return Nn(t,e,s,i,a,n,r,o)}function fn(){return{polyIntersect:new cn,polyX1:new cn,polyY1:new cn,polyX1Deriv:new cn,polyY1Deriv:new cn,lazyPolyD1:new cn,lazyPolyD1Deriv:new cn,tempP:new cn,tempP1:new cn,tempP2:new cn,polypoly1Proximity:new dn,polypoly2Proximity:new dn}}function xn(t,e,s,i,n,r,o,a,h,m,u){const l=fn();l.polyX1.construct(t,e),l.polyY1.construct(s,i),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.polyIntersect.assignCopy(l.polyX1),l.polyIntersect.mulThis(l.polyX1),l.polyIntersect.mulElementThis(o[0]),l.tempP.assignCopy(l.polyY1),l.tempP.mulThis(l.polyY1),l.tempP.mulElementThis(o[1]),l.polyIntersect.addThis(l.tempP),n?(l.lazyPolyD1.construct(n,r),l.tempP.assignCopy(l.lazyPolyD1),l.tempP.mulThis(l.lazyPolyD1),l.tempP.mulElementThis(o[2]),l.polyIntersect.addThis(l.tempP)):l.polyIntersect.add0(o[2]);{const n=o[0].clone(),r=n.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const m=o[2].clone(),u=n.clone();u.subThis(a),l.polyX1.construct(t,e),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1.construct(s,i),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(h),l.tempP.mulElementThis(m),l.polypoly1Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(a.mul(u).mul(m).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(n.mul(h)),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1),l.tempP1.mulElementThis(r.mul(a)),l.tempP.addThis(l.tempP1),l.tempP.add0(u.mul(u).mul(m)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulElementThis(u.mul(n).mul(a).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.construct0(n.mul(u).mul(u)),l.polypoly1Proximity.addElement(l.tempP),l.polypoly1Proximity.updatePower(),l.tempP.construct0(pt),l.polypoly2Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1Deriv),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1Deriv),l.tempP.addThis(l.tempP1),l.tempP.mulElementThis(n.mul(a)),l.polypoly2Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1Deriv),l.tempP.mulElementThis(u.mul(n)),l.polypoly2Proximity.addElement(l.tempP),l.polypoly2Proximity.updatePower()}const c=[],d=[];u||(u=[]);let g=2*l.polyIntersect.power()+58;const _=.5*Number.EPSILON,p=Sn(l.polyIntersect,a,h,_,g,d);if(p<0)return-1;Dn(l.polypoly1Proximity,l.polypoly2Proximity,l.tempP),g=2*l.tempP.power()+58;let f=Sn(l.tempP,a,h,_,g,c);if(f<0&&(f=0),0===p&&0===f)return 0;const x=c.concat(d);u.length=x.length,A(u,x,0,0,x.length),lt(u);const y=Dt(u,((t,e)=>0===U(t,e)));return u.length=y,u.length}function yn(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function Pn(t,e,s,i,n,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),n.containsCoordinate(1)?1:0;return yn(e,s,n,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),n.containsCoordinate(o[1].value())||(e=1),n.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=S(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const m=i+2,u=Z.sqrt(h,m),l=u.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(Z.constructAssign(t,m)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[0].value()))&&c++,u.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=S(o[0],o[0]=o[1]))),c}function vn(t,e,i,n,r,o,a,h){if(t.isZero()){return Pn(e,i,n,r,o,a,h)}const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=S(h[t],h[t]=h[s-1]),s--);e=s}return M(h,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let s=0;o.containsCoordinate(0)&&(h[0].setInt32(0),s=1);return m(Pn(t,e,i,r,o,a,h.slice(1)),s)}if(a){let s=0;o.containsCoordinate(1)&&(h[0].setInt32(1),s=1);const i=e.add(t),a=n.negate(),u=t.add(i).add(a).isZero();return m(Pn(t,i,a,r,o,u,h.slice(s)),s)}const u=new Z,l=new Z,c=new Z,d=e.clone();if(d.isZero())l.setThis(i),l.divThis(t),c.setThis(n),l.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();const s=e.clone();s.sqrThis();const r=t.clone();r.sqrThis(),l.setThis(t),l.mulThis(i).mulDoubleThis(3).subThis(s).divThis(r).divDoubleThis(3),c.setThis(s),c.mulThis(e),c.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(i).mulDoubleThis(9),c.subThis(u),u.setThis(r),u.mulThis(n).mulDoubleThis(27),c.addThis(u),c.divThis(r).divThis(t).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(d),Mn(o,r,h,1)):(h[0].setThis(Z.cubicRoot(c,r).add(d)),Mn(o,r,h,1))}const g=c.clone();if(g.sqrThis().ldexpThis(-2),u.setThis(l.clone()),u.sqrThis().mulThis(l).divDoubleThis(27),g.addThis(u),g.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(d),h[1].addThis(d),Mn(o,r,h,2);if(g.GZ())return g.setThis(Z.sqrt(g,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.addThis(g),h[0].setThis(Z.cubicRoot(u,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.subThis(g),h[0].addThis(Z.cubicRoot(u,r+8)),h[0].addThis(d),Mn(o,r,h,1);u.setThis(l),u.divDoubleThis(3).negateThis(),s(u.GEZ());const _=Z.sqrt(u,r+8),p=_.clone();p.negateThis(),p.addThis(d),_.addThis(d);const f=Z.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),y=Z.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),P=new cn({zeroCtor:Z});P.construct0(n),P.addElement(i),P.addElement(e),P.addElement(t);const v=new cn({copy:P});v.derivative1This();let C=0;const b=x(Z,4);b[C++].setThis(f),p.gt(f)&&p.lt(y)&&b[C++].setThis(p),_.gt(f)&&_.lt(y)&&b[C++].setThis(_),b[C++].setThis(y);const E=3*r;let D=52,w=Number.EPSILON;for(;D<E;)2*D<=E?(w*=w,D*=2):(w*=Number.EPSILON,D+=52);D+=2;let A=0,T=!1;for(let s=1;s<C;s++){if(Tn(P,v,b[s-1],b[s],w,D,h[0])){A=1,T=s+1<C;break}}if(!A)return 0;if(T){const t=new cn({zeroCtor:Z,coef0:h[0]});t.negateThis(),t.addElement(ft);const e=new cn({zeroCtor:Z}),i=new cn({zeroCtor:Z});P.div(t,e,i),s(2===e.power()),s(0===i.power());const n=Pn(e.getElement(2),e.getElement(1),e.getElement(0),r,o,!1,h.slice(1));s(n>=0&&n<=2),A+=n}return Mn(o,r,h,A)}function Cn(t,e,s,i,n,r,o,a,h){if(t.isZero())return vn(e,s,i,n,r,o,a,h);const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=S(h[t],h[t]=h[s-1]),s--);e=s}return M(h,0,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return m(vn(t,e,s,i,r,o,a,h.slice(n)),n)}const u=new cn({zeroCtor:Z,coef0:n});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new cn({zeroCtor:Z,coef0:Z.constructInt32(-1)});e.addElement(Z.constructInt32(1));const s=new cn({zeroCtor:Z}),i=new cn({zeroCtor:Z});u.div(e,s,i);return m(vn(3===s.power()?s.getElement(3):pt.clone(),s.power()>=2?s.getElement(2):pt.clone(),s.power()>=1?s.getElement(1):pt.clone(),s.getElement(0),r,o,s.evaluate(ft).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=vn(3===u.power()?u.getElement(3):pt.clone(),u.power()>=2?u.getElement(2):pt.clone(),u.power()>=1?u.getElement(1):pt.clone(),u.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),M(h,0,t,((t,e)=>t.compare(e))),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const d=qn(u),g=Z.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(d.lt(g)?d:g).mul(Z.constructDouble(c)).toDouble(),Nn(u,o,c,l,a,!1,h,4)}function bn(t,e){let s=t,i=e;i.power()>s.power()&&(i=S(s,s=i));const n=s.power()-i.power(),r=new cn({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let o=0,a=s.power();o<a;o++)if(o>=n){const t=new cn({copy:i.getElement(o-n)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),En(s)}function En(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Dn(t,e,s){const i=t.clone(),n=e.clone();for(En(i),En(n);0!==i.power()||0!==n.power();)bn(i,n);s.assignMove(i.getElement(0))}function Sn(t,e,s,i,n,r){r.length=0;const o=t.power(),a=x(Z,2*o+4),h=pn(t,s||D.unit(),i,n,!1,a,a.length);if(h>0){r.length=0;for(let t=0;t<h;t++){const e=a[t].value();t>0&&e<=r.at(-1)||r.push(e)}return r.length}return h}function wn(t,e,i){if(s(i>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function An(t,e,i,n){if(t.power()<2)return wn(t,i,n);s(n>=1);let r=t.getElement(1);r.mulThis(t.getElement(1));const o=t.getElement(0);if(o.mulThis(t.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),i[0].setThis(s),1}s(n>=2),r=Z.sqrt(r,e+8);const a=t.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);const m=a.clone();return m.addThis(r),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function Tn(t,e,s,i,n,r,o){let h=s.clone(),m=i.clone();h.limitPrecisionThis(r),m.limitPrecisionThis(r);let u=t.evaluate(h);u.limitPrecisionThis(r+2);let l=t.evaluate(m);if(l.limitPrecisionThis(r+2),u.GEZ()&&l.GEZ()||u.LEZ()&&l.LEZ())return u.absLessAbs(l)?(o=h,u.isZero()):(o=m,l.isZero());const c=l.LZ();c&&(l=S(u,u=l),m=S(h,h=m));const d=c?m:h,g=c?h:m,_=h.add(m).ldexpThis(-1);_.limitPrecisionThis(r);const p=m.sub(h);p.limitPrecisionThis(r),p.absThis();const f=p.clone();let x=t.evaluate(_),y=e.evaluate(_);const P=new cn({copy:t}),v=new cn({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=ft.clone();i.ldexpThis(-(r+2));for(let n=64;n<s;){P.limitPrecisionThis(n),v.limitPrecisionThis(n);const r=P.evaluate(_),o=v.evaluate(_),a=r.sub(x),h=o.sub(y);if(a.divThis(x).absThis().lt(i)&&(y.isZero()||h.divThis(y).absThis().lt(i)))break;P.assignCopy(t),v.assignCopy(e),n=Math.min(n+64,s)}x.limitPrecisionThis(r+2),y.limitPrecisionThis(r+2)}const C=1,b=4;let E=b;const D=2;let w=1,A=0,T=0,I=C;const N=32,q=Z.constructDouble(.25*n),M=Z.constructDouble(.5001);let Y=0;const X=300;for(;++Y<X;){if(Y>N&&A>0||y.isZero()||I===D&&A>1||I===C&&E<b)I=C,w>1&&w--;else if(I=D,T>1){const t=p.mul(y);t.absThis(),t.ldexpThis(-3),t.absLessAbs(x)&&w++}p.setThis(f);const t=new Z;let e=!1;if(I===C)do{if(T>2){const e=p.clone();if(e.absThis(),e.ldexpThis(4),g.sub(d).ldexpThis(-1).gt(e)){if(_.equals(d)){t.setThis(_),_.setThis(d.add(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}if(_.equals(g)){t.setThis(_),_.setThis(g.sub(e)),_.limitPrecisionThis(r),f.setThis(_.sub(t));break}}}f.setThis(m.sub(h)),f.ldexpThis(-1),f.limitPrecisionThis(r),t.setThis(_),_.setThis(h.add(f)),_.limitPrecisionThis(r),_.lt(d)?_.setThis(d):_.gt(g)&&_.setThis(g),e=h.equals(_)||m.equals(_)}while(0);else for(;;){if(f.setThis(x.div(y)),f.limitPrecisionThis(r),1!==w&&f.mulDoubleThis(w),t.setThis(_),_.subThis(f),_.limitPrecisionThis(r),e=_.equals(t),_.lt(d)){if(w>1){_.setThis(t),w--;continue}f.setThis(t.sub(d)),_.setThis(d)}else if(_.gt(g)){if(w>1){_.setThis(t),w--;continue}f.setThis(t.sub(g)),_.setThis(g)}break}if(e||f.absLessAbs(q)){t.equals(_)||(x=P.evaluate(_),x.limitPrecisionThis(r+2));break}x=P.evaluate(_),x.limitPrecisionThis(r+2),y=v.evaluate(_),y.limitPrecisionThis(r+2);const s=h.clone(),i=m.clone();x.LZ()?(u.setThis(x),h.setThis(_)):(l.setThis(x),m.setThis(_)),I===D&&(h.equals(s)&&m.equals(i)||T>1&&!f.absLessAbs(M.mul(p)))?A++:A=0,I===C?(E++,T=0):(E=0,T++)}return Y>=X&&a("Root_finder iterations exceeded"),o.setThis(_),!0}function In(t,e,s,i,n){const r=t.evaluate(s);if(r.isZero())return!0;const o=Z.constructDouble(.5*i),a=s.clone();a.subThis(o);const h=t.evaluate(a),m=s.clone();m.addThis(o);const u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ())return!0;if(r.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ())return!0;const l=h.LEZ()&&u.LEZ(),c=h.GEZ()&&u.GEZ();let d=!1;return l?r.gt(h)&&r.gt(u)&&(d=!0):c&&r.lt(h)&&r.lt(u)&&(d=!0),!!d&&r.absThis().lt(Z.constructDouble(1e-17))}function Nn(t,e,i,n,r,o,a,h){s(i>0),s(h>=t.power());const m=a,u=[];let l=[];const c=new cn({zeroCtor:t.m_zeroCtor}),d=new cn({zeroCtor:t.m_zeroCtor}),g=new cn({zeroCtor:t.m_zeroCtor}),_=Z.constructDouble(i),p=Z.constructDouble(e.vmin),f=Z.constructDouble(e.vmax),x=p.sub(_),y=f.add(_),P=qn(t),v=P.clone();if(v.negateThis(),x.lt(v))x.setThis(v.sub(_));else if(x.gt(P))return 0;if(y.gt(P))y.setThis(P.add(_));else if(y.lt(v))return 0;let C=t,b=null;if(r){const e=new cn({coef0:Z.constructInt32(-1)});e.addElement(ft),b=new cn,C=b;const s=new cn,i=new cn;for(t.div(e,s,i),b.assignCopy(s);C.evaluate(ft).isZero();)C.div(e,s,i),b.assignCopy(s)}let E=!1;if(C.power()>0&&C.getElement(0).isZero())for(E=!0,b||(b=new cn({copy:C}),C=b);C.getElement(0).isZero();)b.shiftRight(1);let D=n+2*C.power()+2,S=i/Math.pow(2,C.power()+2),w=D;if(pt.gt(x)&&pt.lt(y))for(let s=0,q=C.power();s<q;s++)if(C.getElement(s).isZero()){u.push(pt.clone());break}for(let q=C.power()-1;q>0;q--)if(S*=2,D-=2,w-=2,C.power()-q!=1)if(C.power()-q!=2){d.assignMove(g),g.assignMove(C.derivative(q-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new Z;if(Tn(d,c,l[e].first,l[e].second,S,D,s)){u.push(s);let i=s.sub(_);i.limitPrecisionThis(w),t.push(xt(l[e].first,i)),i=s.add(_),i.limitPrecisionThis(w),t.push(xt(i,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(d)}else{d.assignMove(C.derivative(q));const t=An(d,D,m,h);s(t>=0&&t<=2);for(let e=0;e<t;e++)m[e].gt(x)&&m[e].lt(y)&&!m[e].isZero()&&u.push(m[e].clone());if(u.length>1&&u.sort(((t,e)=>t.compare(e))),u.length>0){let t=u[0].sub(_);t.limitPrecisionThis(w),l.push(xt(x.clone(),t));let e=1===u.length?y.clone():u[1].sub(_);t=u[0].add(_),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(xt(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(_),e.limitPrecisionThis(w),t=u[1].add(_),t.limitPrecisionThis(w),l.push(xt(t,e)),u.length>2&&(t=u[2].add(_),t.limitPrecisionThis(w),l.push(xt(t,y.clone()))))}else l.push(xt(x.clone(),y.clone()));c.assignCopy(d),g.assignMove(C.derivative(q-1))}else{d.assignMove(C.derivative(q));1===wn(d,m,h)&&(m[0].gt(x)&&m[0].lt(y)&&!m[0].isZero()&&u.push(m[0].clone()),c.assignMove(d),g.assignMove(C.derivative(q-1)))}u.sort(((t,e)=>t.compare(e))),0===l.length&&(c.assignMove(C.derivative(C.power())),c.isZero()||l.push(xt(x.clone(),y.clone())));let A=0,T=0,I=0;const N=new Z;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<u.length&&u[I].lt(l[T].first)&&(t=!0),!t){Tn(C,c,l[T].first,l[T].second,i,n,N)&&(N.lt(p)?m[A++].setThis(p):N.gt(f)?m[A++].setThis(f):m[A++].setThis(N)),T++;continue}}if(!(I<u.length))break;0!==I&&u[I-1].equals(u[I])||In(C,c,u[I],i)&&(N.setThis(u[I]),N.lt(p)?N.setThis(p):N.gt(f)&&N.setThis(f),0!==A&&m[A].equals(N)||m[A++].setThis(N)),I++}return E&&pt.gt(x)&&pt.lt(y)&&(m[A++].setThis(pt),M(m,0,A,((t,e)=>t.compare(e)))),r&&ft.gt(x)&&ft.lt(y)&&(m[A++].setThis(ft),M(m,0,A,((t,e)=>t.compare(e)))),A}function qn(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=pt.clone();for(let i=0,n=t.power();i<n;i++){const n=t.getElement(i);n.limitPrecisionThis(53),n.divThis(e).absThis(),n.gt(s)&&s.setThis(n)}return s.addThis(ft),s.mulThis(Z.constructDouble(1+100*Number.EPSILON)),s}function Mn(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=S(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=S(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=S(s[1],s[1]=s[2]))));for(let r=0;r<n;++r)s[r].limitPrecisionThis(e);return n}const Yn=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Xn=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],Fn=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],Rn=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],Ln=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],zn=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function Vn(t,e,s,i){const n=.5*(i-s),r=s+n,o=new X(0);for(let a=0,h=Math.trunc(t/2);a<h;++a){let s,i;switch(t){case 4:s=Yn[a][0],i=Yn[a][1];break;case 8:s=Xn[a][0],i=Xn[a][1];break;case 16:s=Fn[a][0],i=Fn[a][1];break;case 32:s=Rn[a][0],i=Rn[a][1];break;case 64:s=Ln[a][0],i=Ln[a][1];break;case 128:s=zn[a][0],i=zn[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=St(-n,s,r),m=St(n,s,r);o.pe(e(h)*i),o.pe(e(m)*i)}return o.getResult()*n}function Bn(t,e,s,i,n,r){return Hn(t,e,s,r,i,n)}function kn(t,e,s,i,n,r){let o=n;if(i)return r[0]=1,o=.5*(e-t)*(s(t)+s(e)),o;const a=r[0],h=(e-t)/a,m=t,u=new X(0);for(let l=1;l<=r[0];++l){const t=(l-.5)*h;u.add(s(m+t))}return o=.5*(o+(e-t)*u.getResult()/a),r[0]*=2,o}function Gn(t,e,s,i,n,r,o){let a=0,h=Math.abs(n-s[t]);const m=q(e,Number.NaN),u=q(e,Number.NaN);for(let g=0;g<e;++g){const e=Math.abs(n-s[t+g]);e<h&&(a=g,h=e),m[g]=i[t+g],u[g]=i[t+g]}let l=0,c=0,d=0;r[0]=i[t+a],a--;for(let g=1;g<e;g++){for(let i=0;i<e-g;i++){if(c=s[t+i]-n,d=s[t+i+g]-n,l=c-d,0===l)return!1;const e=(m[i+1]-u[i])/l;m[i]=c*e,u[i]=d*e}if(2*(a+1)<e-g){const t=a+1;o[0]=m[t]}else{const t=a;o[0]=u[t],a--}r[0]+=o[0]}return!0}function Hn(t,s,i,n,r,o){if(i<s&&e("xTo < xFrom"),i===s)return 0;const h=[0];let m=Number.MAX_VALUE;const u=[Number.MAX_VALUE];let l=0;const c=32,d=q(c+1,Number.NaN),g=q(c+1,Number.NaN),_=[0];d[0]=1;let p=0,f=0;for(let e=0;e<c;e++){if(l=kn(s,i,n,0===e,l,_),g[e]=l,e+1>=t){Gn(e+1-t,t,d,g,0,h,u)||a("polynomial_interpolation");const s=r*Math.abs(h[0])+o,i=Math.abs(m-h[0]);if(i<=s&&Math.abs(u[0])<=s){if(p++,p>1&&(i<=.1*f||0===f||p>2))return h[0]}else p=0;f=i,m=h[0]}g[e+1]=g[e],d[e+1]=.25*d[e]}return h[0]}class Wn{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function jn(t,e,i,n,r,o,a,h){for(;;){const m=f.distance(e[0],e[2]),u=f.distance(e[0],e[1])+f.distance(e[1],e[2]);if(u-m<=r+n*u)return t+j(m,u,.5);const l=x(f,4),c=t=>{ir(e,i,1,t,l);return l[1].length()};if(0===a&&h<8){s(h<8);let m=c(0),l=c(1);o[0]+=2,m>l&&(l=S(m,m=l),e[2]=S(e[0],e[0]=e[2]),i[2]=S(i[0],i[0]=i[2]));let d=m/(m+l),g=1,_=u;for(;d<1/32&&_>=r+n*_;){g/=4;const t=c(g);o[0]++,d=m/(t+m);const s=new f;if(eo(e,i,.5*g,s),_=f.distance(s,e[0]),_<=r){const t=new f;eo(e,i,g,t),_+=f.distance(t,s)}}if(1!==g){const s=x(f,3),m=[0,0,0];Xr(e,i,g,e,i,s,m),t=jn(t,s,m,n,r,o,0,h+1),a++,h++;continue}}let d=!1;const g=8;o[0]+=g;const _=Vn(g,c,0,1),p=16;o[0]+=p;const y=Vn(p,c,0,1);if(d=Math.abs(_-y)>r+n*u,!d)return t+y;if(a<8&&h<9){const s=x(f,3),m=[0,0,0];Xr(e,i,.5,e,i,s,m),t=jn(t,s,m,n,r,o,a+1,h+1),a++,h++;continue}const P=32;o[0]+=P;const v=Vn(P,c,0,1);if(d=Math.abs(y-v)>r+n*u,!d)return t+v;const C=64;o[0]+=C;const b=Vn(C,c,0,1);if(d=Math.abs(v-b)>r+n*u,!d)return t+b;const E=128;o[0]+=E;const D=Vn(E,c,0,1);return d=Math.abs(b-D)>r+n*u,t+D}}function Zn(t,e,s,i,n){if(s===e)return 0;const r=x(f,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=x(f,3);Fr(r,o,e,s,h,a);return jn(0,h,a,i,n,[0],0,0)}let Un=class{constructor(t,e,s){this.controlPoints=Et(t,3),this.weights=[0,0,0],A(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new f;eo(this.controlPoints,this.weights,e,t);const s=x(f,4);ir(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return s(0),0}};function On(t,e,s,i){const n=wr(0,0,0,0,f.getNAN()),r=new Array(18),o=x(f,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,io(a),1],m=ro(a,s),u=ro(a,i),l=Fi(new Un(o,h,new f(0,0)),D.construct(m,u),18,r);eo(o,h,m,n.pt),n.t=m,n.d=f.distance(n.pt,new f(0,0));const c=new f;eo(o,h,u,c);const d=f.distance(c,new f(0,0));d<n.d&&(n.d=d,n.t=u,n.pt.assign(c));for(let g=0;g<l;g++){eo(o,h,r[g],c);const t=f.distance(c,new f(0,0));t<n.d&&(n.d=t,n.t=no(a,r[g]),n.pt.assign(c))}return n}function Qn(t,e,s,i,n){let r=!0;const o=x(f,4),a=Bn(5,e,s,i,n,(e=>{sr(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()}));r=!1;const h=Bn(5,e,s,i,n,(e=>{sr(t,1,e,o);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*o[1].length()}));return new f(a,h)}function Kn(t){t.m_cachedValues=null}function $n(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function Jn(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Wn,s=x(f,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),tr(s,i,e.specialPoints),Er(t,e),e}function tr(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=x(V,8);i[0].set(0);let n=1;{const s=new V(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new V(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new V(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=x(V,2);let h=Ui(o,r,s,new D(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)G(a[t].value(),0,1)||(i[n]=a[t],n++)}{const s=new V(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new V(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new V(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=x(V,2);let h=Ui(o,r,s,new D(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)G(a[t].value(),0,1)||(i[n]=a[t],n++)}if(i[n].set(1),n++,n>2){M(i,0,n,((t,e)=>U(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let r=0;r<n;r++)s[r]=i[r].value()}function er(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+er(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Jn(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Pr(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Zn(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function sr(t,e,s,i){const n=x(f,3);t.queryControlPoints(n);const r=[0,0,0];t.queryWeights(r),ir(n,r,e,s,i)}function ir(t,e,s,i,n){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=x(f,4);nr(r,o,s,i,a);for(let h=0;h<=s;h++)n[h].setCoords(a[h].x,a[h].y)}function nr(t,e,i,n,r){s(i>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const h=rr(o,e,0,n),m=ar(e,0,n),u=h.divide(m);if(r[0].assign(u),0===i)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],c=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],d=m*m,g=rr(c,l,0,n).mul(2).divide(d);if(r[1].assign(g),1===i)return;const _=ar(e,1,n),p=2*m*_,f=rr(c,l,1,n).mul(2).sub(g.mul(p)).divide(d);if(r[2].assign(f),2===i)return;const x=rr(c,l,2,n).mul(2),y=2*(_*_+m*ar(e,2,n)),P=x.sub(f.mul(p).mul(2)).sub(g.mul(y)).divide(d);r[3].assign(P),3!==i&&a("")}function rr(t,e,s,i){if(0===s){if(i<=.5){const s=new f;H(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new f;H(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new f;return H(2,s,n,i,r),r}{const s=new f;W(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new f;W(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new f;return W(2,s,n,i,r),r}}if(1===s){const s=t[1].mul(e[1]),n=s.sub(t[0].mul(e[0])).mul(1-i).add(t[2].mul(e[2]).sub(s).mul(i));return n.mulThis(2),n}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}a("")}function or(t,e,s,i){if(i.toDouble()<=.5){const s=new Ns;tt(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ns;tt(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ns;return tt(2,s,n,i,r),r}{const s=new Ns;et(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ns;et(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ns;return et(2,s,n,i,r),r}}function ar(t,e,s){if(0===e){const e=j(t[0],t[1],s),i=j(t[1],t[2],s);return j(e,i,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}a("")}function hr(t,e,s){if(s.toDouble()<=.5){const e=K(t[0],t[1],s),i=K(t[1],t[2],s);return K(e,i,s)}{const e=$(t[0],t[1],s),i=$(t[1],t[2],s);return $(e,i,s)}}function mr(t,e,s,i,n){const r=[Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);ur(r,[new V(e[0]),new V(e[1]),new V(e[2])],s,i,n)}function ur(t,e,i,n,r){s(i>0);const o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=Ns.constructCoords(0,0)}const a=or(o,e,0,n),h=hr(e,0,n),m=a.divE(h);r[0].setE(m);const u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],l=or([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,n).mul(2),c=h.sqr(),d=l.divE(c);r[1].setE(d)}function lr(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=new Array(3);t.queryWeights(n),cr(i,n,e,s)}function cr(t,e,s,i){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const n=x(Ns,4);mr(t,e,1,s,n),i.setE(n[1])}function dr(t,e,s){const i=y(s,0,1),n=x(f,4);if(ir(t,e,3,i,n),n[1].isZero()){if(n[2].isZero())return n[3];{const t=n[2].clone();return 1===i&&t.negateThis(),t}}return n[1]}let gr=class{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-er(this.b,e,!1):0}getError(t){return s(0),0}};function _r(t,e,s){const i=er(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new gr(t,e),D.unit(),1,n)&&a(""),n[0]}function pr(t){const e=x(f,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),fr(e,s)}function fr(t,e){const i=io(e);if(1===i){return wo(t)}if(0===i)return 0;const n=[new f(0,0),t[1].sub(t[0]),t[2].sub(t[0])],r=n[1].crossProduct(n[2]);if(i<1){s(i>0);const t=1-i;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const s=t*(1+i),n=Math.atan2(Math.sqrt(t),Math.sqrt(1+i));e=i*(.5*i-wt(s)*n)/s}return r*e}{const t=(i-1)*(i+1);return.25*i/Math.pow(t,1.5)*(-2*i*Math.sqrt(t)*r-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-n[1].x*n[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}function xr(t,e){const i=io(e);if(1===i){const e=x(f,3);Qo(t,e);const s=e[2].clone(),i=e[1].clone(),n=new f,r=s.y*i.x-s.x*i.y;return n.x=-(4*s.x+5*i.x)*r/60,n.y=-(4*s.y+5*i.y)*r/60,n}if(0===i)return new f(0,0);s(i>0);const n=t[1].sub(t[0]),r=t[2].sub(t[0]);if(i<1){const t=Math.sqrt(1-i),e=Math.sqrt(1+i),s=(n.y*r.x-n.x*r.y)*i/Math.pow(t*e,5)/12,o=Math.atan2(t,e),a=i*t*e,h=i*i,m=n.mul(2*(2+h)),u=r.mul(2*h-5),l=m.add(u).mul(a),c=r.sub(n.mul(2*h)).mul(6*o);return l.add(c).mul(s)}{const t=Math.sqrt(i-1),e=Math.sqrt(i+1),s=(n.y*r.x-n.x*r.y)*i/Math.pow(t*e,5)/12,o=Math.atanh(t/e),a=i*t*e,h=i*i,m=n.mul(4).sub(r.mul(5)),u=n.add(r).mul(2*h),l=m.add(u).mul(a),c=r.sub(n.mul(2*h)).mul(6*o);return l.add(c).mul(s)}}function yr(t){const e=x(f,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),xr(e,s)}function Pr(t){return vr(t.calculateUpperLength2D())}function vr(t){return 256*st()*t}function Cr(t){if(0===t.m_weights[1])return!0;const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function br(t){return t.m_cachedValues}function Er(t,e){t.m_cachedValues=e}function Dr(t,e,s,i,n){const r=x(f,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Sr(r,o,e,D.unit(),i,n,1,a)?a[0]:Number.NaN}function Sr(t,e,i,n,r,o,a,h){c(D.unit().contains(n)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const m=new Array(3);for(let s=0;s<3;++s)m[s]=t[s].sub(i);const u=io(e),l=un.constructPoint2D(m[0]),d=un.constructPoint2D(m[1]),g=un.constructPoint2D(m[2]),_=Z.constructDouble(u),p=_.clone();p.ldexpThis(1);const y=l.dotProduct(d.sub(l)).mul(_),P=_.mul(_.addDouble(2)),v=g.sub(d.mul(P.ldexp(1))),C=d.sqrLength().mul(_.mul(_).ldexp(1)).add(l.sqrLength().mul(_.ldexp(2).subDouble(1))).add(l.dotProduct(v)),b=g.sub(d.mul(p)).add(l.mul(p.subDouble(1))),E=d.mul(_).sub(l).dotProduct(b).mulDouble(3),S=d.dotProduct(g).mul(_.subDouble(3).mul(_)).ldexp(1),w=d.sqrLength().mul(_.mul(_).ldexp(2)),A=l.sqrLength().mul(_.ldexp(2).subDouble(3)),T=l.dotProduct(g.sub(d.mul(_.mulDouble(3).subDouble(1)).mul(_))).ldexp(1),I=g.sqrLength().addThis(S).addThis(w).addThis(A).addThis(T),N=l.add(g).sub(d.mul(p)),q=_.subDouble(1),M=g.sub(l).dotProduct(N).mul(q),Y=new f(0,0),X=[];let F=new f;eo(m,e,n.vmin,F);let R=f.distance(F,Y);if(R<=o&&X.push(new f(n.vmin,R)),n.vmin!==n.vmax&&(eo(m,e,n.vmax,F),R=f.distance(F,Y),R<=o&&X.push(new f(n.vmax,R))),n.width()>0){const t=m[2].isZero(),s=x(Z,4),i=Cn(M,I,E,C,y,58,n,t,s);for(let r=0;r<i;r++){if(!n.containsExclusiveCoordinate(s[r].toDouble()))continue;let t=s[r].toDouble();t=no(e,t);const i=new f;eo(m,e,t,i),R=f.distance(i,Y),R<=o&&X.push(new f(t,R))}}if(r){s(n.equals(D.unit()));{eo(m,e,-1,F,!0);const t=new f;eo(m,e,0,t);const s=new rl({start:F,end:t}),i=s.getClosestCoordinate(Y,!0);i<1&&(F=s.getCoord2D(i),R=f.distance(F,Y),R<=o&&X.push(new f(i-1,R)))}{eo(m,e,2,F,!0);const t=new f;eo(m,e,n.vmax,t);const s=new rl({start:t,end:F}),i=s.getClosestCoordinate(Y,!0);i>0&&(F=s.getCoord2D(i),R=f.distance(F,Y),R<=o&&X.push(new f(1+i,R)))}}if(!X.length)return 0;X.sort(((t,e)=>t.compare(e)));let L=0;const z=X[0].x;if(h[L++]=z,L<a){const t=Xe(m,4,!1).total(),e=X[0].y;for(let s=1,i=X.length;s<i;s++)if(X[s].y>e+t){X.length=s;break}X.sort(((t,e)=>U(t.x,e.x))),L=0,h[L++]=X[0].x;for(let s=1,i=X.length;s<i;s++)X[s].x!==h[L-1]&&L<a&&(h[L++]=X[s].x)}return L}function wr(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function Ar(t,e,i,n,r){const o=new Ds;if(Tr(t,D.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=Jn(t);let h=0;const m=[];let u=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=On(t,e,u,i);if(0===m.length)m.push(n);else if(n.t===n.tmin)s(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){s(m.at(-1).d>=n.d);const t=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=t}else m.push(n);u=i}for(const s of m)if(s.d<=n){const t=s.t;i?(i[h]=t,h++):h++}return h}function Tr(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),Ir(i,n,e,s)}function Ir(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=x(f,3),r=[0,0,0];Fr(t,e,s.vmin,s.vmax,n,r),i.setFromPoints(n,3)}function Nr(t){const e=O(t[0].y,t[1].y),s=O(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=O(t[0].x,t[1].x),s=O(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function qr(t){const e=x(f,3);t.queryControlPoints(e);const s=Mr(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Mr(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[2][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function Yr(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weighted_centroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=Jn(t),o=Pr(t),a=o/t.calculateUpperLength2D();let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=Qn(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function Xr(t,e,i,n,r,o,a){s(i>=0&&i<=1&&n!==o&&r!==a),s(e[0]>0&&e[2]>0&&e[1]>=0);const h=[1,io(e),1],m=ro(e,i),u=Et(t,3),l=x(Bt,3);Qr(u,h,l);const c=x(Bt,3),d=x(Bt,3);oo(l,m,n?c:null,o?d:null),ao(e,i,r,a);const g=Nr(u);if(n){for(let t=0;t<3;++t)to(c[t],n[t]);mo(u,n),g&&Mr(n)}if(o){for(let t=0;t<3;++t)to(d[t],o[t]);mo(u,o),g&&Mr(o)}}function Fr(t,e,i,n,r,o){if(s(i>=0&&n<=1&&i<=n),i===n){const s=new f,n=Kr(t,e,i,s);return ho(t,s),r[0].assign(s),r[1].assign(s),r[2].assign(s),o[0]=n,o[1]=n,void(o[2]=n)}if(0===i&&1===n)return r[0].assign(t[0]),r[1].assign(t[1]),r[2].assign(t[2]),o[0]=e[0],o[1]=e[1],void(o[2]=e[2]);const a=x(Bt,3);{const s=[1,io(e),1],r=ro(e,i),o=ro(e,n);Qr(t,s,a),oo(a,o,a,null);oo(a,r>=o?1:r/o,null,a)}const h=[0,0,0];ao(e,n,h,null),ao(h,i/n,null,h);const m=Nr(t),u=x(f,3);to(a[1],u[1]),eo(t,e,i,u[0]),eo(t,e,n,u[2]),mo(t,u);for(let s=0;s<3;++s)r[s].assign(u[s]),o[s]=h[s];m&&Mr(r)}function Rr(t,e,s){const i=io(e),n=[1,i,1],r=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),Q(t[0],t[1],r,s[1]),Q(t[2],t[1],r,s[2]),new da({cp:s}),new mn({points:t,weight:i});let o=0,a=.1,h=0;for(let m=0;m<9;m++,a+=.1){const e=new f;eo(t,n,a,e);const i=new f;Ua(s,a,i);const r=f.sqrDistance(e,i);r>o&&(o=r,h=a)}{const e=new f;eo(t,n,h,e);const i=[0];gh(s,e,D.unit(),!1,-1,1,i);const r=new f;return Ua(s,i[0],r),o=f.sqrDistance(e,r),Math.sqrt(o)}}function Lr(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Q(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&qr(t)}function zr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Hr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Vr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Wr(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Br(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();n.subThis(t.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e)}function kr(t,e,s,i,n){if(n){const i=Qu(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Ys(e,s))return 1;return 0!==jr(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Gr(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Zr(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Hr(t,e,i,n,r,o,a,h,m,u){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(i.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!=o)for(let t=0;t<s;t++)o.push(0);if(null!=n)for(let i=0;i<s;i++){const s=new f;e.queryCoord2D(t[i],s),n.push(s)}}return s}const l=ei(e,i);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new rl({start:e.getStartXY(),end:e.getEndXY()}),s=yi(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<s;++i){const s=t.getCoord2D(r[i]);r[i]=e.getClosestCoordinate(s,!1)}return s}if(si(e,i,a))return 0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[1,io(d),1],_=i.getEndXY().sub(i.getStartXY()),p=_.clone();p.leftPerpendicularThis();const y=c[0].clone(),P=c[1].clone(),v=c[2].clone(),C=P.sub(y),b=v.sub(y),E=v.sub(P),S=g[0],w=g[1],A=g[2],T=S*w,I=S*A,N=w*A,q=C.dotProduct(p)*T,M=b.dotProduct(p)*I;let Y=q,X=M-2*q,F=E.dotProduct(p)*N+M-M;const R=new Array(13),L=new Array(13);let z=Li(F,X,Y,D.unit(),!1,R);z<0&&(R[0]=0,R[1]=1,z=2);let V=0;for(let s=0,x=V;s<z;++s){const t=new f;eo(c,g,R[s+x],t),L[V]=i.getClosestCoordinate(t,!1);f.distance(t,i.getCoord2D(L[V]))<=a&&(R[V]=R[s+x],V++)}const B=x(f,3),k=x(f,3);if(e.queryControlPoints(k),k[0].subThis(i.getStartXY()),k[1].subThis(i.getStartXY()),k[2].subThis(i.getStartXY()),Ur(k,g,B,!1),Math.abs(_.x)>=Math.abs(_.y)){const t=_.y/_.x;F=B[2].y-B[2].x*t,X=B[1].y-B[1].x*t,Y=B[0].y-B[0].x*t}else{const t=_.x/_.y;F=B[2].x-B[2].y*t,X=B[1].x-B[1].y*t,Y=B[0].x-B[0].y*t}const G=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),H=[0,0];z=Li(F,X,Y,D.unit(),G,H);for(let s=0,x=V;s<z;++s){R[s+x]=H[s];const t=new f;eo(c,g,R[s+x],t),L[V]=i.getClosestCoordinate(t,!1);f.distance(t,i.getCoord2D(L[V]))<=a&&(R[V]=R[s+x],V++)}s(V<R.length+4);for(let s=0;s<V;s++)R[s]=no(d,R[s]);z=e.intersectPoint(i.getStartXY(),H,a);for(let s=0;s<z;s++)R[V]=H[s],L[V++]=0;z=e.intersectPoint(i.getEndXY(),H,a);for(let s=0;s<z;s++)R[V]=H[s],L[V++]=1;z=i.intersectPoint(e.getStartXY(),H,a);for(let s=0;s<z;s++)L[V]=H[s],R[V++]=0;z=i.intersectPoint(e.getEndXY(),H,a);for(let s=0;s<z;s++)L[V]=H[s],R[V++]=1;return 0===V?0:el(t,e,i,R,L,V,n,r,o,a,h,m,u)}function Wr(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return Hr(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=x(f,4);{e.queryControlPoints(d);const t=x(f,4),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(d,4,t);const r=x(Z,3),a=x(Z,3),h=x(Z,3),m=[0,0,0];e.queryWeights(m),Or(t,m,r,a,h);const u=x(Z,3);u[0].setDouble(s.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(s.getSemiMajorAxis()),u[1].sqrThis(),u[2].setThis(u[0]),u[2].mulThis(u[1]),u[2].negateThis();const g=xn(r,2,a,2,h,2,u,!0,D.unit(),D.unit(),l);if(g>0){let t=0;for(let i=0;i<g;i++){const n=new f;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a);f.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const g=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),i=Dr(e,t,D.unit(),!1,-1),n=new f;e.queryCoord2D(i,n);f.distance(t,n)<=o&&(l.push(i),c.push(g[_]))}for(let _=0;_<2;_++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[_]],!1),i=new f;s.queryCoord2D(e,i);f.distance(d[t[_]],i)<=o&&(l.push(g[_]),c.push(e))}}return el(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function jr(t,e,i,n,r,o,a,h,m,u){const l=x(f,3);e.queryControlPoints(l);const c=x(f,3);if(i.queryControlPoints(c),ii(l,c,3)<0)return jr(t,i,e,n,o,r,a,h,m,!u);const d=ei(e,i);if(e.isDegenerateToLineHelper(d)){const s=new rl({start:e.getStartXY(),end:e.getEndXY()}),l=Hr(t,i,s,n,o,r,a,h,m,!u);if(r)for(let t=0;t<l;++t){const i=s.getCoord2D(r[t]);r[t]=e.getClosestCoordinate(i,!1)}return l}if(i.isDegenerateToLineHelper(d)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()}),l=Hr(t,e,s,n,r,o,a,h,m,u);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=i.getClosestCoordinate(e,!1)}return l}if(si(e,i,a=Math.max(a,d)))return 0;const g=new Array(3);e.queryWeights(g);const _=new Array(3);i.queryWeights(_);const p=[1,io(g),1],y=[1,io(_),1],P=new D(0,1),v=new D(0,1);{const t=Ds.constructEmpty();Ir(l,p,new D(0,1),t);const e=Ds.constructEmpty();Ir(c,y,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(so(l,p,t,P),so(c,y,t,v),P.isEmpty()||v.isEmpty())return 0;Fr(l,p,P.vmin,P.vmax,l,p),Fr(c,y,v.vmin,v.vmax,c,y)}}const C=il(l,2,c,2,a);if(0===C)return 0;const b=[],E=[];if(-1===C){const t=x(Z,3),e=x(Z,3),s=x(Z,3);Or(l,p,t,e,s);const i=x(Z,3),n=x(Z,3),r=x(Z,3);Or(c,y,i,n,r);const o=[],h=[],m=_n(t,2,e,2,s,2,i,2,n,2,r,2,!0,D.unit(),D.unit(),o,h);if(m>0)for(let u=0;u<m;u++){const t=new f;eo(c,y,h[u],t);const e=new f;eo(l,p,o[u],e);f.distance(e,t)<=a&&(b.push(o[u]),E.push(h[u]))}}for(let x=0;x<2;x++){let t,e,i;0===x?(t=l,e=c,i=y):(t=c,e=l,i=p);for(let n=0;n<2;n++){const r=0===n?0:t.length-1,o=new f,h=[0],m=Sr(e,i,t[r],D.unit(),!1,-1,1,h);s(1===m),eo(e,i,h[0],o),f.distance(t[r],o)<=a&&(0===x?(b.push(0===r?0:1),E.push(h[0])):(E.push(0===r?0:1),b.push(h[0])))}}if(0===b.length)return 0;if(!P.equalsRange(0,1))for(let s=0;s<b.length;++s)b[s]=mn.recalculateParentT(P.vmin,P.vmax,b[s]);if(!v.equalsRange(0,1))for(let s=0;s<E.length;++s)E[s]=mn.recalculateParentT(v.vmin,v.vmax,E[s]);for(let s=0;s<b.length;++s)b[s]=no(g,b[s]);for(let s=0;s<E.length;++s)E[s]=no(_,E[s]);return el(t,e,i,b,E,b.length,n,r,o,a,h,m,u)}function Zr(t,e,s,i,n,r,o,a,h,m){if(e.isLine()){return Zo(t,s,new rl({start:e.getStartXY(),end:e.getEndXY()}),i,r,n,o,a,h,!m)}if(s.isLine()){return Hr(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=x(f,3);e.queryControlPoints(l);const c=x(f,3);s.queryControlPoints(c);const d=il(l,2,c,2,o);if(0===d)return 0;const g=[],_=[];if(-1===d){const t=x(Z,3),i=x(Z,3),n=x(Z,3),r=[0,0,0];e.queryWeights(r),Or(l,r,t,i,n);const a=x(un,3);ta(c,a);const h=_n(t,2,i,2,n,2,[a[0].x,a[1].x,a[2].x],2,[a[0].y,a[1].y,a[2].y],2,null,0,!0,D.unit(),D.unit(),g,_);if(h>0){let t=0;for(let i=0;i<h;i++){const n=new f;s.queryCoord2D(_[i],n);const r=new f;e.queryCoord2D(g[i],r),f.distance(r,n)<=o&&(g[t]=g[i],_[t]=_[i],t++)}g.length=t,_.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let i=0;i<2;i++){const n=0===i?0:t.length-1;let r;const a=new f;0===p?(r=No(s,t[n],D.unit(),!1),s.queryCoord2D(r,a)):(r=Dr(e,t[n],D.unit(),!1,-1),e.queryCoord2D(r,a)),f.distance(t[n],a)<=o&&(0===p?(g.push(0===n?0:1),_.push(r)):(_.push(0===n?0:1),g.push(r)))}}return el(t,e,s,g,_,g.length,i,n,r,o,a,h,m)}function Ur(t,e,s,i=!1){const n=x(f,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}function Or(t,e,s,i,n){const r=Z.constructDouble(e[0]),o=Z.constructDouble(e[1]),a=Z.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(r),i[1].setDouble(t[1].y),i[1].mulThis(o),i[2].setDouble(t[2].y),i[2].mulThis(a),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function Qr(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function Kr(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,m,u;if(s<=.5){const t=R(n[0],n[1],a),e=R(n[1],n[2],a);h=j(t,e,a);const s=R(r[0],r[1],a),i=R(r[1],r[2],a);m=j(s,i,a);const l=R(o[0],o[1],a),c=R(o[1],o[2],a);u=R(l,c,a)}else{const t=L(n[0],n[1],a),e=L(n[1],n[2],a);h=L(t,e,a);const s=L(r[0],r[1],a),i=L(r[1],r[2],a);m=L(s,i,a);const l=L(o[0],o[1],a),c=L(o[1],o[2],a);u=L(l,c,a)}return h/=u,m/=u,i.setCoords(h,m),ho(t,i),u}function $r(t,e,s){const i=x(f,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n);Jr([Ns.constructPoint2D(i[0]),Ns.constructPoint2D(i[1]),Ns.constructPoint2D(i[2])],[new V(n[0]),new V(n[1]),new V(n[2])],e,s)}function Jr(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const n=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],r=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],o=[e[0].clone(),e[1].clone(),e[2].clone()],a=new V,h=new V,m=new V;if(s.value()<=.5){const t=K(n[0],n[1],s),e=K(n[1],n[2],s);a.setE(K(t,e,s));const i=K(r[0],r[1],s),u=K(r[1],r[2],s);h.setE(K(i,u,s));const l=K(o[0],o[1],s),c=K(o[1],o[2],s);m.setE(K(l,c,s))}else{const t=$(n[0],n[1],s),e=$(n[1],n[2],s);a.setE($(t,e,s));const i=$(r[0],r[1],s),u=$(r[1],r[2],s);h.setE($(i,u,s));const l=$(o[0],o[1],s),c=$(o[1],o[2],s);m.setE($(l,c,s))}a.divThisE(m),h.divThisE(m);const u=new f(a.value(),h.value());ho([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,a.eps()),i.y.set(u.y,h.eps())}function to(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function eo(t,e,s,i,n){if(n){if(s<0){return void hi(new rl({start:t[0],end:t[0].add(dr(t,e,0).getUnitVector())}),s,i)}if(s>1){return void hi(new rl({start:t[2],end:t[2].add(dr(t,e,1).getUnitVector())}),s-1,i)}}Kr(t,e,s,i)}function so(t,e,s,i){i.setEmpty();const n=[];n.push(new D(0,1));const r=.5*Math.max(s.width(),s.height());for(;n.length;){const o=n.at(-1);n.pop();const a=new Ds;if(Ir(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{const t=o.getCenter();n.push(D.construct(o.vmin,t)),n.push(D.construct(t,o.vmax))}}}}function io(t){return t[1]/Math.sqrt(t[0]*t[2])}function no(t,e){const s=Math.sqrt(t[2]/t[0]);return e/j(s,1,e)}function ro(t,e){const s=Math.sqrt(t[0]/t[2]);return e/j(s,1,e)}function oo(t,e,i,n){s(e>=0&&e<=1);(new Bt).setCoordsPoint3D(t[0]);(new Bt).setCoordsPoint3D(t[1]);(new Bt).setCoordsPoint3D(t[2]);const r=new Bt,o=new Bt,a=new Bt;J(3,t[0],t[1],e,r),J(3,t[1],t[2],e,o),J(3,r,o,e,a);const h=t[2].clone();i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(a)),n&&(n[0].assign(a),n[1].assign(o),n[2].assign(h))}function ao(t,e,i,n){const r=[t[0],t[1],t[2]];s(e>=0&&e<=1&&i!==n);const o=j(r[0],r[1],e),a=j(r[1],r[2],e),h=j(o,a,e);i&&(i[0]=r[0],i[1]=o,i[2]=h),n&&(n[0]=h,n[1]=a,n[2]=r[2])}function ho(t,e){const s=D.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=y(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=y(e.y,s.vmin,s.vmax)}function mo(t,e){const s=new D;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=y(e[0].x,s.vmin,s.vmax),e[1].x=y(e[1].x,s.vmin,s.vmax),e[2].x=y(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=y(e[0].y,s.vmin,s.vmax),e[1].y=y(e[1].y,s.vmin,s.vmax),e[2].y=y(e[2].y,s.vmin,s.vmax)}class uo{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}class lo{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-xo(this.b,e,!1):0}getError(t){return s(0),0}}function co(t,e,s,i,n){let r=!0;const o=x(f,3);t.queryControlPoints(o);let a=r?0:1,h=o[1][a]-o[0][a],m=o[2][a]-o[0][a];const u=Bn(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=R(0,h,t),i=R(h,m,t);e=R(s,i,t)}else{const s=L(0,h,t),i=L(h,m,t);e=L(s,i,t)}return e*bo(o,1,t).length()}));r=!1,a=r?0:1,h=o[1][a]-o[0][a],m=o[2][a]-o[0][a];const l=Bn(5,e,s,i,n,(t=>{let e;if(t<=.5){const s=R(0,h,t),i=R(h,m,t);e=R(s,i,t)}else{const s=L(0,h,t),i=L(h,m,t);e=L(s,i,t)}return e*bo(o,1,t).length()}));return new f(u,l)}function go(t){t.m_cachedValues=null}function _o(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function po(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new uo;return fo(t,e.specialPoints),Io(t,e),e}function fo(t,e){const s=x(f,3);t.queryControlPoints(s);const i=x(V,8);i[0].set(0);let n=1;{const t=x(V,3);$o(s,t,!1);const e=x(V,2),r=new D(0,1);let o=Zi(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)G(e[s].value(),0,1)||(i[n]=e[s],n++)}{const t=x(V,3);Jo(s,t,!1);const e=x(V,2),r=new D(0,1);let o=Zi(t[2].mul(2),t[1],r,e[0]);o<0&&(o=0);for(let s=0;s<o;s++)G(e[s].value(),0,1)||(i[n]=e[s],n++)}if(i[n].set(1),n++,n>2){M(i,0,n,((t,e)=>t.value()-e.value()));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),e.length=n;for(let r=0;r<n;r++)e[r]=i[r].value()}function xo(t,e,s){const i=x(f,3);return t.queryControlPoints(i),yo(i,e,s)}function yo(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+yo(t,1,!1)}if(1===e)return Po(t);const i=x(f,3);return Vo(t,e,i,null),Po(i)}function Po(t){if(t[0].equals(t[1]))return f.distance(t[2],t[0]);if(t[1].equals(t[2]))return f.distance(t[0],t[2]);const e=f.distance(t[0],t[1])+f.distance(t[2],t[1]),s=f.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const i=1,n=x(f,3);Qo(t,n,!0);const r=4*(C(n[2].x)+C(n[2].y)),o=2*(n[2].x*n[1].x+n[2].y*n[1].y),a=C(n[1].x)+C(n[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r)){if(1e-14*Math.abs(a)>=Math.abs(o)){return Math.sqrt(a)*i}return 2/(3*o)*(Math.pow(o*i+a,1.5)-Math.pow(a,1.5))}const h=o/r,m=a/r,u=m-h*h,l=i+h;if(0===u){if(h>=0&&l>=0||h<=0&&l<=0){return Math.abs(.5*Math.sqrt(r)*(l*l-h*h))}return.5*Math.sqrt(r)*(l*l+h*h)}const c=Math.sqrt(u+l*l),d=Math.sqrt(m);return.5*Math.sqrt(r)*(l*c-h*d+u*Math.log(Math.abs((l+c)/(h+d))))}function vo(t,e){const s=y(e,0,1);let i=bo(t,1,s);return i.isZero()&&(i=bo(t,2,s)),i}function Co(t,e,s){const i=x(f,3);return t.queryControlPoints(i),bo(i,e,s)}function bo(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):f.construct(0,0)}function Eo(t,e,s){{const e=Ns.constructPoint2D(t[1]).subE(Ns.constructPoint2D(t[0])),i=new V(1).subE(s),n=Ns.constructPoint2D(t[2]).subE(Ns.constructPoint2D(t[1])),r=e.mulE(i).addE(n.mulE(s));return r.mulThisE(new V(2)),r}}function Do(t,e,s){const i=xo(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new lo(t,e),D.unit(),1,n)&&a(""),n[0]}function So(t){const e=x(f,3);return t.queryControlPoints(e),wo(e)}function wo(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Ao(t){const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function To(t){return t.m_cachedValues}function Io(t,e){t.m_cachedValues=e}function No(t,e,s,i,n){c(D.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=x(f,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=qo(r,e,a);if(s.containsCoordinate(a[0]))o=f.distance(e,h);else{a[0]=s.vmin,ea(r,a[0],h),o=f.distance(h,e);const t=new f;ea(r,s.vmax,t);const i=f.distance(t,e);o>i&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=i)}if(!i)return a[0];if(s.vmin<=0){const i=new f;t.queryCoord2DExtended(-1,i,!0);const n=new f;t.queryCoord2D(s.vmin,n);const r=new rl({start:i,end:n}),m=r.getClosestCoordinate(e,!0);if(m<1){const t=r.getCoord2D(m),s=f.distance(t,e);s<o&&(o=s,a[0]=m-1,h.assign(t))}}if(s.vmin>=1){const i=new f;t.queryCoord2DExtended(2,i,!0);const n=new f;t.queryCoord2D(s.vmax,n);const r=new rl({start:n,end:i}),m=r.getClosestCoordinate(e,!0);if(m>0){const t=r.getCoord2D(m),s=f.distance(t,e);s<o&&(o=s,a[0]=1+m,h.assign(t))}}return a[0]}function qo(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(n),a=r.dotProduct(i)+2*n.dotProduct(n),h=3*n.dotProduct(i),m=i.dotProduct(i),u=new Array(3),l=zi(m,h,a,o,D.unit(),!1,u),c=t[0].clone();let d=0,g=f.sqrDistance(t[0],e),_=f.sqrDistance(t[2],e);_<g&&(d=1,c.assign(t[2]),g=_);for(let p=0;p<l;p++){const s=new f;ea(t,u[p],s),_=f.sqrDistance(s,e),_<g&&(g=_,c.assign(s),d=u[p])}return s&&(s[0]=d),c}function Mo(t,e,s,i,n,r){const o=new Ds;if(Yo(t,D.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(e))return 0;const a=new f,h=No(t,e,D.unit(),!1);t.queryCoord2D(h,a);return f.distance(a,e)<=n?(i&&(i[0]=h),1):0}function Yo(t,e,s){const i=x(f,3);t.queryControlPoints(i),Xo(i,e,s)}function Xo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=x(f,3);Bo(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function Fo(t,e,s){s.setEmpty();const i=[];i.push(new D(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Ds;if(Xo(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(D.construct(r.vmin,t)),i.push(D.construct(t,r.vmax))}}}}function Ro(t){const e=x(f,3);t.queryControlPoints(e);const s=Lo(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function Lo(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[2][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function zo(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weighted_centroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=po(t),o=ti(t),a=Math.min(o/t.calculateUpperLength2D(),1e-7);let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=co(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function Vo(t,e,s,i){(new f).setCoordsPoint2D(t[0]);(new f).setCoordsPoint2D(t[1]);(new f).setCoordsPoint2D(t[2]);const n=new f,r=new f,o=new f;if(Q(t[0],t[1],e,n),Q(t[1],t[2],e,r),Q(n,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(o)),i){const e=t[2];i[0].assign(o),i[1].assign(r),i[2].assign(e)}}function Bo(t,e,s,i){if(e===s){const s=new f;return ea(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=x(f,3);Vo(t,s,n,null),Vo(n,e/s,null,n),ea(t,e,n[0]),ea(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ko(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):Q(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&Ro(t)}function Go(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function Ho(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Zo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Wo(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==Uo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function jo(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==Oo(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Zo(t,e,i,n,r,o,a,h,m,u){if(null!=r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],s=e.intersectPoint(i.getStartXY(),t,a);if(s>0){if(null!==r)for(let e=0;e<s;e++)r.push(t[e]);if(null!==o)for(let t=0;t<s;t++)o.push(0);if(null!==n)for(let i=0;i<s;i++){const s=new f;e.queryCoord2D(t[i],s),n.push(s)}}return s}const l=ei(e,i);if(a=Math.max(a,l),e.isDegenerateToLineHelper(l)){const t=new rl({start:e.getStartXY(),end:e.getEndXY()}),s=yi(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<s;++i){const s=t.getCoord2D(r[i]);r[i]=e.getClosestCoordinate(s,!1)}return s}if(si(e,i,a))return 0;const c=un.constructPoint2D(i.getStartXY()),d=un.constructPoint2D(i.getEndXY()).sub(c),g=d.clone();g.leftPerpendicularThis();const _=un.constructPoint2D(e.m_cp).sub(un.constructPoint2D(e.getStartXY())),p=un.constructPoint2D(e.getEndXY()).sub(un.constructPoint2D(e.m_cp));let y=_.dotProduct(g).toDouble(),P=p.sub(_).dotProduct(g).toDouble();const v=q(12,Number.NaN),C=q(12,Number.NaN);let b=Ri(P,y,D.unit(),v);b<0&&(v[0]=0,v[1]=1,b=2);let E,S=0;for(let s=0,x=S;s<b;++s){const t=e.getCoord2D(v[s+x]);C[S]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(C[S]))<=a&&(v[S]=v[s+x],S++)}const w=x(f,3);e.queryControlPoints(w);{const t=x(un,3);if(ta(w,t,!1),t[0]=t[0].sub(c),d.x.abs().gte(d.y.abs())){const e=d.y.div(d.x);P=t[2].y.sub(t[2].x.mul(e)).toDouble(),y=t[1].y.sub(t[1].x.mul(e)).toDouble(),E=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=d.x.div(d.y);P=t[2].x.sub(t[2].y.mul(e)).toDouble(),y=t[1].x.sub(t[1].y.mul(e)).toDouble(),E=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const A=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),T=[0,0];b=Li(P,y,E,D.unit(),A,T);for(let s=0,x=S;s<b;++s){v[s+x]=T[s];const t=e.getCoord2D(v[s+x]);C[S]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(C[S]))<=a&&(v[S]=v[s+x],S++)}s(S<v.length+4),b=e.intersectPoint(i.getStartXY(),T,a);for(let s=0;s<b;s++)v[S]=T[s],C[S++]=0;b=e.intersectPoint(i.getEndXY(),T,a);for(let s=0;s<b;s++)v[S]=T[s],C[S++]=1;b=i.intersectPoint(e.getStartXY(),T,a);for(let s=0;s<b;s++)C[S]=T[s],v[S++]=0;b=i.intersectPoint(e.getEndXY(),T,a);for(let s=0;s<b;s++)C[S]=T[s],v[S++]=0;return 0===S?0:el(t,e,i,v,C,S,n,r,o,a,h,m,u)}function Uo(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return Zo(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=x(f,3);{e.queryControlPoints(d);const t=x(f,3),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(d,3,t);const r=x(un,3);ta(t,r);const a=[r[0].x,r[1].x,r[2].x],h=[r[0].y,r[1].y,r[2].y],m=x(Z,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2]=m[0],m[2].mul(m[1]),m[2].negate();const u=xn(a,2,h,2,null,0,m,!0,D.unit(),D.unit(),l);if(u>0){let t=0;for(let i=0;i<u;i++){const n=new f;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a),f.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const g=[0,1];for(let _=0;_<2;_++){const t=0===_?s.getStartXY():s.getEndXY(),e=[0];qo(d,t,e);const i=new f;ea(d,e[0],i),f.distance(t,i)<=o&&(l.push(e[0]),c.push(g[_]))}for(let _=0;_<2;_++){const t=[0,2];{const e=s.getClosestCoordinate(d[t[_]],!1),i=new f;s.queryCoord2D(e,i),f.distance(d[t[_]],i)<=o&&(l.push(g[_]),c.push(e))}}return el(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function Oo(t,e,s,i,n,r,o,a,h,m){const u=x(f,3);e.queryControlPoints(u);const l=x(f,3);if(s.queryControlPoints(l),ii(u,l,3)<0)return Oo(t,s,e,i,r,n,o,a,h,!m);const c=ei(e,s);if(si(e,s,o=Math.max(o,c)))return 0;if(la(e,s,i,n,r,o,a,h,m))return 2;const d=new D(0,1),g=new D(0,1);{const t=new Ds;Xo(u,D.unit(),t);const e=new Ds;Xo(l,D.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Fo(u,t,d),Fo(l,t,g),d.isEmpty()||g.isEmpty())return 0;Bo(u,d.vmin,d.vmax,u),Bo(l,g.vmin,g.vmax,l)}}const _=il(u,2,l,2,o);if(0===_)return 0;const p=[],y=[];if(-1===_){const t=x(un,3);ta(u,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=x(un,3);ta(l,i);const n=_n(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,!0,D.unit(),D.unit(),p,y,m);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new f,i=new f;ea(l,y[e],i),ea(u,p[e],s),f.distance(s,i)<=o&&(p[t]=p[e],y[t]=y[e],t++)}p.length=t,y.length=t}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:2,n=[0];qo(e,t[i],n);const r=new f;ea(e,n[0],r),f.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),y.push(n[0])):(y.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let f=0;f<p.length;++f)p[f]=an.recalculateParentT(d.vmin,d.vmax,p[f]);if(!g.equalsRange(0,1))for(let f=0;f<y.length;++f)y[f]=an.recalculateParentT(g.vmin,g.vmax,y[f]);return el(t,e,s,p,y,p.length,i,n,r,o,a,h,m)}function Qo(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function Ko(t,e,s=!1){const i=x(f,3);t.queryControlPoints(i),Qo(i,e,s)}function $o(t,e,s=!1){const i=0,n=new V(t[1][i]).subE(new V(t[0][i]));e[1]=n.mul(2),e[2]=new V(t[2][i]).subE(new V(t[1][i])).subE(n),s?e[0].set(0):e[0].set(t[0][i])}function Jo(t,e,s=!1){const i=1,n=new V(t[1][i]).subE(new V(t[0][i]));e[1]=n.mul(2),e[2]=new V(t[2][i]).subE(new V(t[1][i])).subE(n),s?e[0].set(0):e[0].set(t[0][i])}function ta(t,e,s=!1){const i=un.constructPoint2D(t[1]),n=i.sub(un.constructPoint2D(t[0]));e[1]=n.mul(Z.constructInt32(2)),e[2]=un.constructPoint2D(t[2]).sub(i).sub(n),e[0]=s?new un(pt,pt):un.constructPoint2D(t[0])}function ea(t,e,s,i){if(i){if(e<0){return void hi(new rl({start:t[0],end:t[0].add(vo(t,0).getUnitVector())}),e,s)}if(e>1){return void hi(new rl({start:t[2],end:t[2].add(vo(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=t[1].clone(),n=new f;H(2,t[0],i,e,n);const r=new f;H(2,i,t[2],e,r);const o=new f;H(2,n,r,e,o),s.assign(o)}else{const i=t[1].clone(),n=new f;W(2,t[0],i,e,n);const r=new f;W(2,i,t[2],e,r);const o=new f;W(2,n,r,e,o),s.assign(o)}}function sa(t,e,s){const i=x(f,3);t.queryControlPoints(i),ia(i,e,s)}function ia(t,e,s){if(e.value()<=.5){const i=Ns.constructPoint2D(t[1]),n=new Ns;tt(2,Ns.constructPoint2D(t[0]),i,e,n);const r=new Ns;tt(2,i,Ns.constructPoint2D(t[2]),e,r);const o=new Ns;tt(2,n,r,e,o),s.setE(o)}else{const i=Ns.constructPoint2D(t[1]),n=new Ns;et(2,Ns.constructPoint2D(t[0]),i,e,n);const r=new Ns;et(2,i,Ns.constructPoint2D(t[2]),e,r);const o=new Ns;et(2,n,r,e,o),s.setE(o)}}function na(t,e,s){const i=x(f,4);t.queryControlPoints(i),ra(i,e,s)}function ra(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(Eo(t,1,e))}function oa(t,e){let s=1;t[1].isEqualPoint2D(t[0])&&(s=2,t[2].isEqualPoint2D(t[0])&&(s=3));let i=2;t[2].isEqualPoint2D(t[3])&&(i=1,t[1].isEqualPoint2D(t[3])&&(i=0)),e[0].assign(t[0]),e[2].assign(t[3]);const n=f.intersectLinesAtOnePoint(t[0],t[s],t[i],t[3]),r=new f;Q(t[0],t[3],.5,r);const o=new f;Ua(t,.5,o);const a=new f;e[1].assign(n),ea(e,.5,a);const h=new f;e[1].assign(r),ea(e,.5,h);const m=f.sqrDistance(o,a),u=f.sqrDistance(o,h);return m<u?(e[1].setCoordsPoint2D(n),Math.sqrt(m)):(e[1].setCoordsPoint2D(r),Math.sqrt(u))}function aa(t,e,s){s[0].assign(t[0]),s[1].assign(t[1]),s[2].assign(t[2]);const i=new f;eo(t,e,.5,i);const n=new f;ea(s,.5,n);const r=f.sqrDistance(i,n);return Math.sqrt(r)}function ha(t,e){e[0].assign(t[0]),e[3].assign(t[2]),Q(t[0],t[1],2/3,e[1]),Q(t[1],t[2],1/3,e[2])}function ma(t,e){const s=x(f,3);t.queryControlPoints(s);const i=f.sqrDistance(s[1],s[0]),n=f.sqrDistance(s[1],s[2]);let r=s[0].clone(),o=i;i>n&&(r=s[2].clone(),o=n);let a=!1;return o<=e&&0!==o&&(a=!0,t.setControlPoint1(r)),a}function ua(t,e){if(!e)return!1;const s=x(f,3);t.queryControlPoints(s);const i=f.sqrDistance(s[1],s[0]),n=f.sqrDistance(s[1],s[2]);s[0].clone();let r=i;return i>n&&(s[2].clone(),r=n),r<=e&&0!==r}function la(t,e,s,i,n,r,o,a,h){const m=x(f,3);t.queryControlPoints(m);const u=x(f,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return s&&(s.length=0,s.push(m[0]),s.push(m[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=S(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=S(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[2]),h&&(s[1]=S(s[0],s[0]=s[1]))),!0)}var ca=Vt;class da extends oi{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=x(f,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||F(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=x(f,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=x(f,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),a("unrecognized constructor params"),this.m_cp=x(f,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return Vh(this)}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=x(f,4);ha(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),J(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),J(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),$s(this,t)}getGeometryType(){return n.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void s(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=Aa(this);if(null!==e){const s=new f;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const i=x(V,8),n=x(f,4);this.queryControlPoints(n);const r=vh(n,i),o=new f;for(let s=1;s<r-1;s++)this.queryCoord2D(i[s].value(),o),t.mergeNe(o)}applyTransformation(t){if(1===t.m_TransformationType){const e=x(f,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Ia(this)}s(0)}createInstance(){return new da({vd:this.m_description})}calculateLength2D(){return Ea(this,1,!1)}calculateLowerLength2D(){return f.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return f.distance(this.getStartXY(),this.m_cp[0])+f.distance(this.m_cp[0],this.m_cp[1])+f.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DExtends(t,e,s){const i=x(f,4);this.queryControlPoints(i),Ua(i,t,e,s)}queryCoord2DE(t,e){Qa(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtends(t,e,!0),e.x}const e=j(this.getStartX(),this.m_cp[0].x,t),s=j(this.m_cp[0].x,this.m_cp[1].x,t),i=j(this.m_cp[1].x,this.getEndX(),t),n=j(e,s,t),r=j(s,i,t);return j(n,r,t)}getCoordY(t){if(t<0||t>1){const e=new f;return this.queryCoord2DExtends(t,e,!0),e.y}const e=j(this.getStartY(),this.m_cp[0].y,t),s=j(this.m_cp[0].y,this.m_cp[1].y,t),i=j(this.m_cp[1].y,this.getEndY(),t),n=j(e,s,t),r=j(s,i,t);return j(n,r,t)}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=ca.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=ca.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){$a(this,t,e)}cutBezierIgnoreAttributes(t,s,i){(t<0||s>1||t>s)&&e("Cubic_bezier.cut_bezier_ignore_attributes");const n=x(f,4);this.queryControlPoints(n);const r=x(f,4);Za(n,t,s,r),i.setControlPoints(r)}splitBezierIgnoreAttributes(t,s,i){this===s&&this===i&&e("Cubic_bezier.split_bezier_ignore_attributes");const n=x(f,4);this.queryControlPoints(n);const r=x(f,4),o=x(f,4);ja(n,t,r,o),s&&s.setControlPoints(r),i&&i.setControlPoints(o)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.getStartAttributeAsDbl(e,s),n=this.getEndAttributeAsDbl(e,s),r=this.calculateLength2D(),o=r>0?this.tToLength(t)/r:0,a=ca.getInterpolation(e);return z(a,i,n,o,ca.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return _h(this,t,D.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===_h(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,i){t.length<2&&e("");const n=wa(this);if(2===n.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;s(t.length>=n.specialPointsCount()-1);for(let e=1,s=n.specialPointsCount();e<s;++e)this.queryCut(n.specialPoints[e-1],n.specialPoints[e],t[r],i),r++;for(let e=0;e<r;++e){ka(t[e].get())}return r}intersectionWithAxis2D(t,e,s,i){const n=x(f,4);return this.queryControlPoints(n),Ch(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,t,i,null);return s(2!==n),-1===n?e:i[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());s(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=qt.constructEmpty();this.queryEnvelope(t);const s=D.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=x(f,4);this.queryControlPoints(s),Za(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Ea(this,t,!0)}lengthToT(t){return Da(this,t)}calculateWeightedAreaCentroid2D(t){const e=x(f,4);xa(this,e);const s=e[3],i=e[2],n=e[1],r=new f;r.x=(5*s.x*s.x*(7*i.y+16*n.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*n.x+140*i.x*n.y+112*n.x*n.y)-2*(s.y*(20*i.x*i.x+70*i.x*n.x+56*n.x*n.x)-7*(4*i.x+5*n.x)*(-i.y*n.x+i.x*n.y)))/840,r.y=(-5*s.y*s.y*(7*i.x+16*n.x)+s.y*(5*s.x*(7*i.y+16*n.y)-4*(10*i.x*i.y+35*i.y*n.x+28*n.x*n.y))+2*(-7*(4*i.y+5*n.y)*(i.y*n.x-i.x*n.y)+s.x*(20*i.y*i.y+70*i.y*n.y+56*n.y*n.y)))/840;const o=Ba(this);return r.x+=(e[0].x-t.x)*o,r.y+=(e[0].y-t.y)*o,r}calculateWeightedCentroid2D(){const t=new f;return this.isDegenerate(0)?(t.setCoords(0,0),t):fa(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(Sa(this,1)),t)}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let s=0;s<4;s++)t[s].isNAN()&&e("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=x(f,4);return this.queryControlPoints(e),Ka(e,t)}getDerivative(t){const e=x(f,4);return this.queryControlPoints(e),La(e,1,t)}getCurvature(t){const e=Va(this,1,t),s=Va(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new qt;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const n=this.getClosestCoordinate(t,!1),r=new f;this.queryCoord2D(n,r);return f.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}isMonotoneQuickAndDirty(){const t=x(f,4);return this.queryControlPoints(t),Ha(t)}getMonotonicPartParams(t,i){const n=wa(this),r=n.specialPointsCount();if(s(ri.s_maxMonotonicPartParams>=r),!i)return n.specialPointsCount();t<r&&e("");for(let e=0;e<r;e++)i[e]=n.specialPoints[e];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=S(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new V;return Xa(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=this.getEndXY().sub(this.getStartXY()),s=e.length(),i=.1*t;let n=this.getControlPoint1();n.subThis(this.getStartXY());let r=Math.abs(n.crossProduct(e))/s;return!(r>i)&&(n=this.getControlPoint2(),n.subThis(this.getStartXY()),r=Math.abs(n.crossProduct(e))/s,!(r>i))}copyIgnoreAttributes(t){const e=x(f,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return Ba(this)}absNorm(){return ph(this)}queryEnvelopeW(t,e){lh(this,t,e)}setSegmentFromCoords(t,e){xh(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=x(f,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=x(f,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(f.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);f.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=x(f,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(f.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);f.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return Eh(this,t,e)}ensureXYMonotone(){return ka(this)}setCoordsForIntersector(t,e,s){qa(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Ta(e,Aa(this))}reverseImpl(){this.m_cp[1]=S(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,i=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[i])}equalsImplTol(t,e){const s=t,i=0,n=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[i],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[n],e)}swapImpl(t){const e=t;e.m_cp[0]=S(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=S(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),Na(this,e)}afterCompletedModification(){Ia(this)}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return uh(this,t,e,s)}endPointModified(){Ia(this)}clearEndPointModified(){}}da.type=n.enumBezier;class ga{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function _a(t){return pa(t.calculateUpperLength2D())}function pa(t){return 256*st()*t}function fa(t){const e=f.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}function xa(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function ya(t,e,s){const i=x(f,4);t.queryControlPoints(i),va(i,e,s)}function Pa(t,e,s){const i=x(f,4);t.queryControlPoints(i),Ca(i,e,s)}function va(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function Ca(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function ba(t,e,s=!1){const i=x(un,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(Z.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(Z.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(pt,pt):e[0]=i[0].clone()}function Ea(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ea(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=wa(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=_a(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=wh(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Da(t,e,s){const i=Ea(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Fi(new Dh(t,e),D.unit(),1,n)&&a(""),n[0]}function Sa(t,s,i){void 0===i&&(i=s,s=0);const n=new f;if(s<0||i>1)return n.setNAN(),n;if(s>i&&e("calculate_sub_weightedCentroid"),s===i||t.isDegenerate(0))return n.setCoords(0,0),n;const r=wa(t),o=_a(t),a=o/t.calculateUpperLength2D();let h=s,m=0;for(let e=1,u=r.specialPointsCount();e<u;e++)if(s<r.specialPoints[e]){m=e-1;break}n.setCoords(0,0);for(let e=m+1,u=r.specialPointsCount();e<u;e++){const s=Math.min(r.specialPoints[e],i),m=Ah(t,h,s,a,o);if(n.addThis(m),h=s,i<=r.specialPoints[e])break}return n.add(t.getStartXY().mul(t.calculateLength2D()))}function wa(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new ga,s=x(V,8),i=x(f,4);t.queryControlPoints(i);const n=vh(i,s);e.specialPoints=[];for(let r=0;r<n;r++)e.specialPoints.push(s[r].value());return Ta(t,e),e}function Aa(t){let e=null;return e=t.m_cachedValues,e}function Ta(t,e){t.m_cachedValues=e}function Ia(t){t.m_cachedValues=null}function Na(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function qa(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new k,o=x(f,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new f;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=x(f,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints2D(t.m_cp,2,t.m_cp):(Q(e,s,1/3,t.m_cp[0]),Q(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&ka(t)}function Ma(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function Ya(t,e,s,i){const n=new Array(18),r=x(f,4);t.queryControlPoints(r);const o=Fi(new dh(r,e),D.construct(s,i),18,n),a=new f;t.queryCoord2D(s,a);let h=s,m=f.distance(a,e);const u=new f;t.queryCoord2D(i,u);const l=f.distance(u,e);l<m&&(m=l,h=i,a.assign(u));for(let c=0;c<o;c++){t.queryCoord2D(n[c],u);const s=f.distance(u,e);s<m&&(m=s,h=n[c],a.assign(u))}return Ma(s,i,h,m,a)}function Xa(t,e){const i=x(V,4);ya(t,i,!0);const n=x(V,4);Pa(t,n,!0);const r=i[3].clone(),o=i[2].clone(),a=i[1].clone(),h=n[3].clone(),m=n[2].clone(),u=n[1].clone(),l=o.mulE(a).addE(m.mulE(u)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),d=r.mulE(o).addE(h.mulE(m)).mul(36),g=r.mulE(r).addE(h.mulE(h)).mul(36),_=x(V,3),p=Oi(g,d,c,l,new D(0,1),!1,_);if(s(p<=3),p>0){const s=Va(t,1,0).sqrLength(),i=Va(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let r=0;r<p;r++){const s=Va(t,1,_[r].value()).sqrLength();s<n&&(n=s,e=_[r])}}}function Fa(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}function Ra(t,e,s,i){{const e=dt.subE(s),n=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new V(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));i.setE(o.mulE(new V(3)))}}function La(t,e,s){const i=new f;return Fa(t,e,s,i),i}function za(t,e,s){const i=[Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3])],n=new Ns;return Ra(i,e,s,n),n}function Va(t,e,s){const i=x(f,4);return t.queryControlPoints(i),La(i,e,s)}function Ba(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e);return(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function ka(t){const e=x(f,4);t.queryControlPoints(e);const s=Ga(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Ga(t){let e=!1;for(let s=0;s<2;s++){const i=O(t[0][s],t[3][s]);i>0?(O(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),O(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),O(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),O(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?(O(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),O(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),O(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),O(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),O(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function Ha(t){const e=O(t[0].y,t[1].y),s=O(t[1].y,t[2].y),i=O(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=O(t[0].x,t[1].x),s=O(t[1].x,t[2].x),i=O(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}function Wa(t,e,s){const i=new f,n=new f,r=new f,o=new f,a=new f;e<=.5?(H(2,t[0],t[1],e,i),H(2,t[1],t[2],e,n),H(2,t[2],t[3],e,r),H(2,i,n,e,o),H(2,n,r,e,a),H(2,o,a,e,s)):(W(2,t[0],t[1],e,i),W(2,t[1],t[2],e,n),W(2,t[2],t[3],e,r),W(2,i,n,e,o),W(2,n,r,e,a),W(2,o,a,e,s))}function ja(t,e,i,n){s(e>=0&&e<=1);const r=new f,o=new f,a=new f,h=new f,m=new f,u=new f;e<=.5?(H(2,t[0],t[1],e,r),H(2,t[1],t[2],e,o),H(2,t[2],t[3],e,a),H(2,r,o,e,h),H(2,o,a,e,m),H(2,h,m,e,u)):(W(2,t[0],t[1],e,r),W(2,t[1],t[2],e,o),W(2,t[2],t[3],e,a),W(2,r,o,e,h),W(2,o,a,e,m),W(2,h,m,e,u));const l=t[3].clone();i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(h),i[3].assign(u)),n&&(n[0].assign(u),n[1].assign(m),n[2].assign(a),n[3].assign(l))}function Za(t,e,i,n){if(s(e>=0&&i<=1&&e<=i),e===i){const s=new f;return Ua(t,e,s),n[0].assign(s),n[1].assign(s),n[2].assign(s),void n[3].assign(s)}if(0===e&&1===i){for(let e=0;e<4;++e)n[e].assign(t[e]);return}const r=x(f,4);ja(t,i,r,null),ja(r,i>0?e/i:0,null,r),Ua(t,e,r[0]),Ua(t,i,r[3]),n[0].setCoordsPoint2D(r[0]),n[1].setCoordsPoint2D(r[1]),n[2].setCoordsPoint2D(r[2]),n[3].setCoordsPoint2D(r[3])}function Ua(t,e,s,i){if(i){if(e<0){return void hi(new rl({start:t[0],end:t[0].add(Ka(t,0).getUnitVector())}),e,s)}if(e>1){return void hi(new rl({start:t[3],end:t[3].add(Ka(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=new f;H(2,t[0],t[1],e,i);const n=new f;H(2,t[1],t[2],e,n);const r=new f;H(2,t[2],t[3],e,r);const o=new f;H(2,i,n,e,o);const a=new f;H(2,n,r,e,a),H(2,o,a,e,s)}else{const i=new f;W(2,t[0],t[1],e,i);const n=new f;W(2,t[1],t[2],e,n);const r=new f;W(2,t[2],t[3],e,r);const o=new f;W(2,i,n,e,o);const a=new f;W(2,n,r,e,a),W(2,o,a,e,s)}}function Oa(t,e,s){if(e.value()<=.5){const i=new Ns;tt(2,Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),e,i);const n=new Ns;tt(2,Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),e,n);const r=new Ns;tt(2,Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3]),e,r);const o=new Ns;tt(2,i,n,e,o);const a=new Ns;tt(2,n,r,e,a),tt(2,o,a,e,s)}else{const i=new Ns;et(2,Ns.constructPoint2D(t[0]),Ns.constructPoint2D(t[1]),e,i);const n=new Ns;et(2,Ns.constructPoint2D(t[1]),Ns.constructPoint2D(t[2]),e,n);const r=new Ns;et(2,Ns.constructPoint2D(t[2]),Ns.constructPoint2D(t[3]),e,r);const o=new Ns;et(2,i,n,e,o);const a=new Ns;et(2,n,r,e,a),et(2,o,a,e,s)}}function Qa(t,e,s){const i=x(f,4);t.queryControlPoints(i),Oa(i,e,s)}function Ka(t,e){const s=y(e,0,1);let i=La(t,1,s);return i.isZero()&&(i=La(t,2,s),i.isZero()?i=La(t,3,s):1===s&&i.negateThis()),i}function $a(t,e,s){const i=x(f,4);t.queryControlPoints(i),Ja(i,e,s)}function Ja(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(za(t,1,e))}function th(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==rh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function eh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==oh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function sh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==ah(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function ih(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==hh(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function nh(t,e,s,i,n){if(n){if(0!==Qu(e,s))return t?4:2}else if(Ys(e,s))return 1;return 0!==mh(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function rh(t,e,s,i,n,r,o,a,h,m){if(null!==n&&(n.length=0),null!=r&&(r.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==n)for(let e=0;e<a;e++)n.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=i)for(let s=0;s<a;s++){const n=new f;e.queryCoord2D(t[s],n),i.push(n)}}return a}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=x(f,4);xa(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const d=c.clone();d.leftPerpendicularThis();let g=3*l[3].dotProduct(d),_=2*l[2].dotProduct(d),p=l[1].dotProduct(d);const y=new Array(15),P=new Array(15);let v=Li(g,_,p,D.unit(),!1,y);v<0&&(y[0]=0,y[1]=1,v=2);let C,b=0;for(let x=0,D=b;x<v;++x){const t=e.getCoord2D(y[x+D]);P[b]=s.getClosestCoordinate(t,!1),f.distance(t,s.getCoord2D(P[b]))<=o&&(y[b]=y[x+D],b++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;g=l[3].y-l[3].x*t,_=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,C=l[0].y-l[0].x*t}else{const t=c.x/c.y;g=l[3].x-l[3].y*t,_=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,C=l[0].x-l[0].y*t}const E=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),S=[0,0,0];v=zi(g,_,p,C,D.unit(),E,S);for(let x=0,D=b;x<v;++x){y[x+D]=S[x];const t=e.getCoord2D(y[x+D]);P[b]=s.getClosestCoordinate(t,!1);f.distance(t,s.getCoord2D(P[b]))<=o&&(y[b]=y[x+D],b++)}v=e.intersectPoint(s.getStartXY(),S,o);for(let f=0;f<v;f++)y[b]=S[f],P[b++]=0;v=e.intersectPoint(s.getEndXY(),S,o);for(let f=0;f<v;f++)y[b]=S[f],P[b++]=1;return 0!==s.intersectPoint(e.getStartXY(),S,o)&&(P[b]=S[0],y[b++]=0),0!==s.intersectPoint(e.getEndXY(),S,o)&&(P[b]=S[0],y[b++]=1),0===b?0:el(t,e,s,y,P,b,i,n,r,o,a,h,m)}function oh(t,e,s,i,n,r,o,a,h,m){if(Gm(s)){return rh(t,e,new rl({start:s.getStartXY(),end:s.getEndXY()}),i,n,r,o,a,h,m)}const u=ei(e,s);if(si(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=[],g=x(f,4);{e.queryControlPoints(g);const t=x(f,4),i=new k;s.canonicToWorldTransformation(i);const n=new k;n.setInvert(i),n.transformPoints2D(g,4,t);const r=x(un,4);ba(t,r);const a=[r[0].x,r[1].x,r[2].x,r[3].x],h=[r[0].y,r[1].y,r[2].y,r[3].y],m=x(Z,3);m[0].setDouble(s.getSemiMinorAxis()),m[0].sqrThis(),m[1].setDouble(s.getSemiMajorAxis()),m[1].sqrThis(),m[2].setThis(m[0]),m[2].mulThis(m[1]),m[2].negateThis();const u=xn(a,3,h,3,null,0,m,!0,D.unit(),D.unit(),c);if(u>0){let t=0;for(let i=0;i<u;i++){const n=new f;e.queryCoord2D(c[i],n);const r=s.getClosestCoordinate(n,!1),a=new f;s.queryCoord2D(r,a);f.distance(n,a)<=o&&(l.push(n.clone()),c[t]=c[i],d.push(r),t++)}c.length=t,l.length=t}}const _=[0,1];for(let p=0;p<2;p++){const t=0===p?s.getStartXY():s.getEndXY(),e=[0];gh(g,t,D.unit(),!1,-1,1,e);const i=new f;Ua(g,e[0],i);f.distance(t,i)<=o&&(c.push(e[0]),d.push(_[p]),l.push(i.clone()))}for(let p=0;p<2;p++){const t=[0,3];{const e=s.getClosestCoordinate(g[t[p]],!1),i=new f;s.queryCoord2D(e,i);f.distance(g[t[p]],i)<=o&&(c.push(_[p]),d.push(e),l.push(i.clone()))}}return el(t,e,s,c,d,c.length,i,n,r,o,a,h,m)}function ah(t,e,i,n,r,o,a,h,m,u){const l=x(f,4);e.queryControlPoints(l);const c=x(f,4);if(i.queryControlPoints(c),ii(l,c,4)<0)return ah(t,i,e,n,o,r,a,h,m,!u);const d=ei(e,i);if(si(e,i,a=Math.max(a,d)))return 0;if(Th(e,i,n,r,o,a,h,m,u))return 2;const g=new D(0,1),_=new D(0,1);{const t=new Ds;ch(l,new D(0,1),t);const e=new Ds;ch(c,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(bh(l,t,g),bh(c,t,_),g.isEmpty()||_.isEmpty())return 0;Za(l,g.vmin,g.vmax,l),Za(c,_.vmin,_.vmax,c)}}const p=il(l,3,c,3,a);if(0===p)return 0;const y=[],P=[],v=[];let C=!1;if(-1===p){const t=x(un,4);ba(l,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=x(un,4);ba(c,i);const n=[],r=[],o=_n(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,!0,D.unit(),D.unit(),n,r);if(o>0)for(let h=0;h<o;h++){const t=new f;Ua(c,r[h],t);const e=new f;Ua(l,n[h],e);f.distance(e,t)<=a&&(y.push(e.clone()),v.push(r[h]),P.push(n[h]))}else-1===o&&(C=!0)}for(let s=0;s<2;s++){const t=0===s?l:c,e=0===s?c:l;for(let i=0;i<2;i++){const n=0===i?0:3,r=[0];gh(e,t[n],D.unit(),!1,-1,1,r);const o=new f;Ua(e,r[0],o);f.distance(t[n],o)<=a&&(0===s?(P.push(0===n?0:1),v.push(r[0])):(v.push(0===n?0:1),P.push(r[0])),y.push(o.clone()))}}if(0===P.length&&C){const t=e.calculateUpperLength2D()>i.calculateUpperLength2D();{const n=[0,0];if(2===yh(t?e:i,n,!0)&&(s(D.unit().containsCoordinate(n[0])),!D.unit().containsCoordinate(n[1]))){const e=new f;Ua(t?l:c,n[0],e);const s=[0,0];1===gh(t?c:l,e,D.unit(),!1,-1,2,s)&&(y.push(e.clone()),P.push(t?n[0]:s[0]),v.push(t?s[0]:n[0]))}}}if(0===P.length)return 0;if(!g.equalsRange(0,1))for(let s=0;s<P.length;++s)P[s]=da.recalculateParentT(g.vmin,g.vmax,P[s]);if(!_.equalsRange(0,1))for(let s=0;s<v.length;++s)v[s]=da.recalculateParentT(_.vmin,_.vmax,v[s]);return el(t,e,i,P,v,P.length,n,r,o,a,h,m,u)}function hh(t,e,i,n,r,o,a,h,m,u){const l=ei(e,i);if(i.isDegenerateToLineHelper(l)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()}),l=rh(t,e,s,n,r,o,a,h,m,u);if(o)for(let t=0;t<l;++t){const e=s.getCoord2D(o[t]);o[t]=i.getClosestCoordinate(e,!1)}return l}if(si(e,i,a=Math.max(a,l)))return 0;const c=x(f,4);e.queryControlPoints(c);const d=x(f,3);i.queryControlPoints(d);const g=new D(0,1),_=new D(0,1),p=[0,0,0];i.queryWeights(p);const y=[1,io(p),1];{const t=new Ds;ch(c,new D(0,1),t);const e=new Ds;Ir(d,y,new D(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(bh(c,t,g),so(d,y,t,_),g.isEmpty()||_.isEmpty())return 0;Za(c,g.vmin,g.vmax,c),Fr(d,y,_.vmin,_.vmax,d,y)}}const P=il(c,3,d,2,a);if(0===P)return 0;const v=[],C=[],b=[];if(-1===P){const t=x(un,4);ba(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=x(Z,3),n=x(Z,3),r=x(Z,3);Or(d,y,i,n,r);const o=[],h=[],m=_n(i,2,n,2,r,2,e,3,s,3,null,0,!0,D.unit(),D.unit(),h,o);if(m>0)for(let u=0;u<m;u++){const t=new f;Ua(c,o[u],t);const e=new f;eo(d,y,h[u],e);f.distance(t,e)<=a&&(v.push(t.clone()),C.push(o[u]),b.push(h[u]))}}for(let x=0;x<2;x++){let t,e;0===x?(t=c,e=d):(e=c,t=d);for(let i=0;i<2;i++){const n=0===i?0:t.length-1,r=[0],o=new f;if(0===x){const i=Sr(e,y,t[n],D.unit(),!1,-1,1,r);s(1===i),eo(e,y,r[0],o)}else{const i=gh(e,t[n],D.unit(),!1,-1,1,r);s(1===i),Ua(e,r[0],o)}f.distance(t[n],o)<=a&&(0===x?(C.push(0===n?0:1),b.push(r[0])):(b.push(0===n?0:1),C.push(r[0])),v.push(o.clone()))}}if(0===C.length)return 0;if(!g.equalsRange(0,1))for(let s=0;s<C.length;++s)C[s]=da.recalculateParentT(g.vmin,g.vmax,C[s]);if(!_.equalsRange(0,1))for(let s=0;s<b.length;++s)b[s]=mn.recalculateParentT(_.vmin,_.vmax,b[s]);for(let s=0;s<b.length;++s)b[s]=no(p,b[s]);return el(t,e,i,C,b,C.length,n,r,o,a,h,m,u)}function mh(t,e,i,n,r,o,a,h,m,u){const l=ei(e,i);if(si(e,i,a=Math.max(a,l)))return 0;const c=x(f,4);e.queryControlPoints(c);const d=x(f,3);i.queryControlPoints(d);const g=il(c,3,d,2,a);if(0===g)return 0;const _=[],p=[],y=[];if(-1===g){const t=x(un,4);ba(c,t);const s=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y],r=x(un,3);ta(d,r);const o=_n([r[0].x,r[1].x,r[2].x],2,[r[0].y,r[1].y,r[2].y],2,null,0,s,3,n,3,null,0,!0,D.unit(),D.unit(),y,p);if(o>0){let t=0;for(let s=0;s<o;s++){const n=new f;e.queryCoord2D(p[s],n);const r=new f;i.queryCoord2D(y[s],r);f.distance(n,r)<=a&&(_.push(n.clone()),p[t]=p[s],y[t]=y[s],t++)}p.length=t,_.length=t}}for(let x=0;x<2;x++){let t,e;0===x?(t=c,e=d):(e=c,t=d);for(let i=0;i<2;i++){const n=0===i?0:t.length-1,r=[0],o=new f;if(0===x)qo(e,t[n],r),ea(e,r[0],o);else{const i=gh(e,t[n],D.unit(),!1,-1,1,r);s(1===i),Ua(e,r[0],o)}f.distance(t[n],o)<=a&&(0===x?(p.push(0===n?0:1),y.push(r[0])):(y.push(0===n?0:1),p.push(r[0])),_.push(o.clone()))}}return el(t,e,i,p,y,p.length,n,r,o,a,h,m,u)}function uh(t,e,n,r,o){const a=new Ds;if(lh(t,D.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;const h=wa(t);let m=0,u=h.specialPoints[0];const l=[];for(let i=1,c=h.specialPoints.length;i<c;++i){const n=h.specialPoints[i],r=Ya(t,e,u,n);if(0===l.length)l.push(r);else if(r.t===r.tmin)s(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){s(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);u=n}for(const s of l)if(s.d<=r){const t=s.t;n?(m>=n.length&&i(""),n[m]=t,m++):m++}return m}function lh(t,e,s){const i=x(f,4);t.queryControlPoints(i),ch(i,e,s)}function ch(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=x(f,4);Za(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class dh{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e),i=La(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new f;Ua(this.controlPoints,e,t);const s=La(this.controlPoints,1,e),i=La(this.controlPoints,2,e),n=La(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=La(this.controlPoints,1,e),s=La(this.controlPoints,2,e),i=La(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=La(this.controlPoints,2,e),s=La(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=La(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(t){return 0}}function gh(t,e,i,n,r,o,a){c(D.unit().contains(i)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],m=new f;Ua(t,i.vmin,m);let u=f.distance(m,e);if(u<=r&&h.push(new f(i.vmin,u)),i.vmin!==i.vmax&&(Ua(t,i.vmax,m),u=f.distance(m,e),u<=r&&h.push(new f(i.vmax,u))),i.width()>0){const s=new Array(18),n=Fi(new dh(t,e),i,18,s);for(let i=0;i<n;i++)Ua(t,s[i],m),u=f.distance(m,e),u>r||h.push(new f(s[i],u))}if(n){s(i.equals(D.unit()));{Ua(t,-1,m,!0);const s=new f;Ua(t,0,s);const i=new rl({start:m,end:s}),n=i.getClosestCoordinate(e,!0);n<1&&(m.assign(i.getCoord2D(n)),u=f.distance(m,e),u<=r&&h.push(new f(n-1,u)))}{Ua(t,2,m,!0);const s=new f;Ua(t,i.vmax,s);const n=new rl({start:s,end:m}),o=n.getClosestCoordinate(e,!0);o>0&&(m.assign(n.getCoord2D(o)),u=f.distance(m,e),u<=r&&h.push(new f(1+o,u)))}}if(!h.length)return 0;h.sort(((t,e)=>t.compare(e)));let l=0;const d=h[0].x;if(a[l++]=d,l<o){const e=Xe(t,4,!1).total(),s=h[0].y;for(let t=1,i=h.length;t<i;t++)if(h[t].y>s+e){h.length=t;break}h.sort(((t,e)=>U(t.x,e.x))),l=0,a[l++]=h[0].x;for(let t=1,i=h.length;t<i;t++)h[t].x!==a[l-1]&&l<o&&(a[l++]=h[t].x)}return l}function _h(t,e,s,i,n,r,o){const a=x(f,4);return t.queryControlPoints(a),gh(a,e,s,i,n,r,o)}function ph(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function fh(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function xh(t,e,i){if(s(i>=2),2===i){const s=new f;Q(e[0],e[i-1],1/3,s);const n=new f;return Q(e[0],e[i-1],2/3,n),void t.construct(e[0],s,n,e[i-1])}const n=e[0],r=e[i-1],o=[0,0],a=_h(t,n,D.unit(),!1,Number.NaN,2,o),h=[0,0],m=_h(t,r,D.unit(),!1,Number.NaN,2,h),u=[];for(let s=0;s<a;s++)for(let a=0;a<m;a++){const m=o[s],l=h[a],c=(s,o)=>{const a=[];a.length=i-2;const h=()=>{let t=0;for(let s=1,n=i-1;s<n;s++){t+=f.distance(e[s-1],e[s]);const i=t;a[s-1]=i}t+=f.distance(e[i-2],e[i-1]);for(let e=1,s=i-1;e<s;e++)a[e-1]/=t};let u=!1,c=!1;{const e=new ol;m<=l?(t.queryCut(m,l,e,!0),s.assign(e.get().getControlPoint1()),o.assign(e.get().getControlPoint2())):(t.queryCut(l,m,e,!0),s.assign(e.get().getControlPoint2()),o.assign(e.get().getControlPoint1())),n.equals(s)&&(u=!0),r.equals(o)&&(c=!0)}h();let d=Number.MAX_VALUE;const g=s.clone(),_=o.clone();for(let t=0;t<5;t++){d=Ih(!0,!1,n,g,_,r,u,c,a,i-2,e,i)}for(let t=0;t<30;t++){const t=g.clone();_.clone();const s=Ih(!0,!0,n,g,_,r,u,c,a,i-2,e,i);if(d<=s&&t.equals(g)&&t.equals(_))break;d=s}h();let p=!1,x=Number.EPSILON;const y=s.clone(),P=o.clone();for(let t=0;t<30;t++){const t=y.clone();P.clone();const s=Ih(p,!0,n,y,P,r,u,c,a,i-2,e,i);if(x<=s&&t.equals(y)&&t.equals(P))break;p=!0,x=s}return x<d?(s.assign(y),o.assign(P)):(s.assign(g),o.assign(_),x=d),x},d=new f,g=new f,_=[c(d,g),f.distance(n,d)+f.distance(d,g)+f.distance(g,r),d.x,d.y,g.x,g.y];u.splice(u.length,0,..._)}let l=u[0],c=u[1],d=0;for(let s=6;s<u.length;s+=6)u[s]<l&&(l=u[s],c=u[s+1],d=s);let g=d;for(let s=0;s<u.length;s+=6)s!==d&&u[s+1]<c&&Math.abs(l-u[s])<10*l&&(c=u[s+1],g=s);t.construct(n,new f(u[g+2],u[g+3]),new f(u[g+4],u[g+5]),r)}function yh(t,e,s=!1){const i=x(f,4);t.queryControlPoints(i);const n=x(un,4);let r,o,a;ba(i,n,!0);const h=n[3].x.isZero(),m=n[3].y.isZero();if(h||m)if(h&&!m){if(n[2].x.isZero())return 0;r=n[1].x.div(n[2].x).negate(),o=n[2].y.div(n[3].y),a=n[1].y.div(n[3].y)}else{if(h||!m)return 0;if(n[2].y.isZero())return 0;r=n[1].y.div(n[2].y).negate(),o=n[2].x.div(n[3].x),a=n[1].x.div(n[3].x)}else{n[2].x.divThis(n[3].x),n[1].x.divThis(n[3].x),n[2].y.divThis(n[3].y),n[1].y.divThis(n[3].y);const t=n[2].x.sub(n[2].y);if(t.isZero())return 0;r=n[1].x.sub(n[1].y).div(t).negate(),o=n[2].x.clone(),a=n[1].x.clone()}if(!s&&r.abs().value()>2)return 0;const u=[0,0],l=t.getStartXY().equals(t.getEndXY()),c=Li(1,-r.toDouble(),r.add(o).mul(r).add(a).toDouble(),D.unit(),l,u);if(0===c)return 0;if(u[0]>=0&&u[0]<=1){const t=r.toDouble()-u[0];if(s||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=S(e[0],e[0]=e[1])),2}if(2===c&&u[1]>=0&&u[1]<=1){const t=r.toDouble()-u[1];if(s||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=S(e[0],e[0]=e[1])),2}return 0}function Ph(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=x(V,2);let a=Ui(r,n,i,new D(0,1),!1,o);a<0&&(a=0);let h=0;for(let m=0;m<a;m++)G(o[m].value(),0,1)||(s[h].setE(o[m]),h++);return h}function vh(t,e){e[0].set(0);let i=1;const n=x(V,4);va(t,n,!0);const r=x(V,4);Ca(t,r,!0);{const t=n[3].mul(3),s=n[2].mul(2),r=n[1].clone(),o=x(V,2);let a=Ui(t,s,r,new D(0,1),!1,o);a<0&&(a=0);for(let n=0;n<a;n++)G(o[n].value(),0,1)||(e[i]=o[n],i++)}{const t=r[3].mul(3),s=r[2].mul(2),n=r[1].clone(),o=x(V,2);let a=Ui(t,s,n,new D(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)G(o[r].value(),0,1)||(e[i]=o[r],i++)}if(i+=Ph(n,r,e.slice(i)),e[i].set(1),i++,i>2){M(e,0,i,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let s=0;const n=e[0].clone();let r=0;const o=fh(t)*st(),a=new f;Wa(t,e[0].value(),a);for(let h=1;h<i;h++){const i=new f;if(Wa(t,e[h].value(),i),e[h].eq(n)||i.isEqualPoint2D(a,o)){if(0!==s){if(0===e[h].eps())n.setE(e[h]),r=0;else if(0!==r){const t=C(1/e[h].eps()),s=1/r,i=t+s;n.set((e[h].value()*t+n.value()*s)/i),r=1/i,n.setError(Math.sqrt(r))}e[s].setE(n),Wa(t,n.value(),a)}}else s++,e[s].setE(e[h]),n.setE(e[h]),Wa(t,n.value(),a),r=C(e[h].eps())}s++,i=s}return 1===i&&(i=2,e[1].set(1)),s(0===e[0].value()),s(1===e[i-1].value()),i}function Ch(t,e,s,i,n){const r=x(V,4),o=x(V,3),a=new D(0,1);let h=0;if(e){if(Ca(t,r,!1),h=Oi(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new f;Ua(t,o[m].value(),e),i[m]=e.x}}else if(va(t,r,!1),h=Oi(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new f;Ua(t,o[m].value(),e),i[m]=e.y}if(n)for(let m=0;m<h;m++)n[m]=o[m].value();else i&&M(i,0,h,U);return h}function bh(t,e,s){s.setEmpty();const i=[];i.push(new D(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Ds;if(ch(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(D.construct(r.vmin,t)),i.push(D.construct(t,r.vmax))}}}}function Eh(t,e,s){s.length=0;{const e=new V;Xa(t,e);const i=new Ns;if($a(t,e,i),i.isZero())return e.isZero()||e.eq(new V(1))?0:(s.push(e.value()),1)}const i=x(V,4);ya(t,i,!0);const n=x(V,4);Pa(t,n,!0);const r=x(V,6),o=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),a=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));r[0]=n[1].mulE(n[1]).mulE(o).addE(i[1].mulE(i[1]).mulE(a)).addE(i[1].mulE(n[1]).mulE(h).mul(2)).mul(6),r[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const m=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(m).mul(156),l=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(c).addE(n[1].mulE(n[3]).mulE(l)).mul(72),g=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),_=i[2].mulE(n[2]).mulE(g).mul(120),p=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),f=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(p).mul(36);r[2]=u.addE(d).addE(_).addE(f);const y=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),P=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),v=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),C=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);r[3]=y.addE(P).addE(v).addE(C),r[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),r[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=x(V,5),E=Qi(r,5,new D(0,1),!1,b,5);if(E>0){let i=Math.abs(t.getCurvature(0)),n=0;const r=Math.abs(t.getCurvature(1));(r>i||!Number.isFinite(r))&&(n=1);for(let e=0;e<E;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!G(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}return 0}class Dh{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ea(this.b,e,!1):0}getError(t){return 0}}function Sh(t,e,i,n,r,o,a){for(;;){const h=f.distance(e[0],e[3]),m=f.distance(e[0],e[1])+f.distance(e[1],e[2])+f.distance(e[2],e[3]);if(m-h<=n+i*m)return t+j(h,m,.5);const u=t=>La(e,1,t).length();if(0===o){s(a<8);let h=u(0),l=u(1);r[0]+=2,h>l&&(l=S(h,h=l),e[3]=S(e[0],e[0]=e[3]),e[2]=S(e[1],e[1]=e[2]));let c=h/(h+l),d=1,g=m;for(;c<1/32&&g>=32*(n+i*g);){d/=4;const t=u(d);r[0]++,c=h/(t+h);const s=new f;if(Ua(e,.5*d,s),g=f.distance(s,e[0]),g<=n){const t=new f;Ua(e,d,t),g+=f.distance(t,s)}}if(1!==d){const s=x(f,4);ja(e,d,e,s),t=Sh(t,s,i,n,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=Vn(l,u,0,1),d=16;r[0]+=d;const g=Vn(d,u,0,1);let _=Math.abs(c-g)>n+i*m;if(!_)return t+g;if(o<3){const s=x(f,4);ja(e,.5,e,s),t=Sh(t,s,i,n,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const y=Vn(p,u,0,1);if(_=Math.abs(g-y)>n+i*m,!_)return t+y;const P=64;r[0]+=P;const v=Vn(P,u,0,1);if(_=Math.abs(y-v)>n+i*m,!_)return t+v;const C=128;r[0]+=C;const b=Vn(C,u,0,1);return _=Math.abs(v-b)>n+i*m,t+b}}function wh(t,e,s,i,n){if(s===e)return 0;const r=x(f,4);t.queryControlPoints(r);const o=x(f,4);Za(r,e,s,o);return Sh(0,o,i,n,[0],0,0)}function Ah(t,e,s,i,n){let r=!0;const o=Bn(5,e,s,i,n,(e=>{const s=Va(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));r=!1;const a=Bn(5,e,s,i,n,(e=>{const s=Va(t,1,e);return(r?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));return new f(o,a)}function Th(t,e,s,i,n,r,o,a,h){const m=x(f,4);t.queryControlPoints(m);const u=x(f,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return s&&(s.length=0,s.push(m[0]),s.push(m[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=S(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=S(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[3]),h&&(s[1]=S(s[0],s[0]=s[1]))),!0)}function Ih(t,e,s,i,n,r,o,a,h,m,u,l){let c=0,d=0,g=0,_=0,p=0,f=0,x=0;for(let v=1,b=l-1;v<b;v++){let e,o,a,m,l,P,b=-1,E=h[v-1];t&&(v>2?(E=y(2*h[v-2]-h[v-3],0,1),h[v-1]=E):2===v&&E<=h[0]&&(E=h[0]));for(let c=0;c<11&&(e=h[v-1],o=e*e,a=o*e,m=1-e,l=m*m,P=l*m,t)&&!(Math.abs(e-b)<1e-12)&&10!==c;c++){const t=s.x-2*i.x+n.x,a=s.x-3*i.x+3*n.x-r.x,m=s.y-2*i.y+n.y,c=s.y-3*i.y+3*n.y-r.y,d=s.x-i.x-2*t*e+a*o,g=-u[v].x+s.x*P+e*(3*i.x*l+e*(3*n.x-3*n.x*e+r.x*e)),_=s.y-i.y-2*m*e+c*o,p=-u[v].y+s.y*P+e*(3*i.y*l+e*(3*n.y-3*n.y*e+r.y*e));b=e;const f=e- -6*(d*g+_*p)/(6*(3*C(d)-(-2*t+2*a*e)*g)+6*(3*C(_)-(-2*m+2*c*e)*p));h[v-1]=y(f,v>1?h[v-2]:0,1)}c+=3*o*l*l,d+=3*a*P,g+=3*o*o*l;const D=-(P*s.x+a*r.x-u[v].x);_+=D*e*l,p+=D*o*m;const S=-(P*s.y+a*r.y-u[v].y);f+=S*e*l,x+=S*o*m}if(e){const t=c*g-d*d;Math.abs(t)>=1e-12*(Math.abs(c*g)+Math.abs(d*d))+1e-10?(o||(i.x=(_*g-p*d)/t,i.y=(f*g-x*d)/t),a||(n.x=(c*p-d*_)/t,n.y=(c*x-d*f)/t)):(Q(s,r,.3,i),Q(s,r,.6,n))}let P=0;for(let y=1,v=l-1;y<v;y++){const t=h[y-1],e=1-t,o=s.mul(yt(e)),a=i.mul(3*t*e*e),m=n.mul(3*t*t*e),l=r.mul(yt(t));P+=o.add(a).add(m).add(l).sub(u[y]).sqrLength()}return P}function Nh(t,e,s,i){const n=t.getPathStart(e),r=t.getPathEnd(e);if(r-n<3)return;const o=2*n,a=f.getNAN();s.queryPoint2D(o,a);const h=a.x,m=a.y,u=f.getNAN();s.queryPoint2D(o+2,u);const l=f.getNAN();for(let c=o+4,d=2*r;c<d;c+=2)s.queryPoint2D(c,l),i.pe((l.x-a.x)*(u.y-m)),a.setCoordsPoint2D(u),u.setCoordsPoint2D(l);i.pe((h-a.x)*(u.y-m))}function qh(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var Mh=Vt;class Yh{static toSegType(t){let e=0;switch(t){case n.enumLine:e=1;break;case n.enumBezier:e=2;break;case n.enumEllipticArc:e=4;break;case n.enumRationalBezier2:e=8;break;case n.enumBezier2:e=16;break;default:a("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class Xh extends bs{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?n.enumPolygon:n.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){s(this.m_bPolygon);const i=this.getPathIndexFromPointIndex(t),n=this.getPathStart(i);if(n===t)return;const r=this.getPathEnd(i);(t>=r||t<n)&&e("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=Mh.getComponentCount(s);this.m_vertexAttributes.get(e).rotate(n*i,t*i,r*i)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(n,t,r),this.m_curveData.m_segmentParamIndex.rotate(n,t,r))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new ee(t),s=new X(0),i=new X(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new Ti({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();Nh(this,r,n,i),qh(this,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),Nh(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return s(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Xh.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),r=Xi(s);for(let t=0;t<r;t++){const s=this.m_curveData.m_segmentParams.read(i+t),r=e.m_curveData.m_segmentParams.read(n+t);if(!v(s,r))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=Ut(1,0),this.m_pathFlags=Ot(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new Yh),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new X(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new X(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return s(0),0}calculatePathLength3D(t,e){return s(0),0}copyTo(t){d(t.getGeometryType())||e(""),this!==t&&super.copyTo(t)}swap(t){s(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,s){this===t&&e("Multi_path_impl::add");for(let e=0,i=t.getPathCount();e<i;e++)this.addPath(t,e,!s)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addSegmentsFromPath(t,s,n,r,o){if(this===t&&e("Multi_path_impl.add_segments_from_path"),o||0!==this.getPathCount()||(o=!0),s<0&&(s=t.getPathCount()-1),(s>=t.getPathCount()||n<0||r<0||n+r>t.getSegmentCountPath(s))&&i("add_segments_from_path"),0===r)return;const a=t.getPathStart(s),h=t.isClosedPath(s)&&n+r===t.getSegmentCountPath(s);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let m=r;const u=a+n;let l=u+1;o&&(m++,l--),!o&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(u)&&(t.getXY(u).equals(this.getXY(this.m_pointCount-1))||e("add_segments_from_path: start point mismatch"));const c=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+m),this.verifyAllStreamsAfterSizeChange(),o){if(0===m)return;this.m_paths.add(this.m_pointCount);let e=t.m_pathFlags.read(s);this.m_bPolygon&&(e|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,e),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const d=h?m-1:m;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const s=this.m_description.getSemantics(e),i=Mh.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(d>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=Mh.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*c,t,d*i,i*c),h&&this.m_vertexAttributes.get(e).insertRange(i*c+d*i,t,i,i*c);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*c,t.m_vertexAttributes.get(n),i*l,d*i,!0,i,i*c)}h&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(c+d),t.m_vertexAttributes.get(n),i*a,i,!0,i,i*(c+d))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=u;s<r;s++){e+=Xi(t.m_curveData.m_segmentFlags.read(i)),i++}if(e>0){this.initSegmentData(e);let s=u,i=c-(o?0:1),n=0;for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),Xh.isNonLinearSegmentFlag(e)){n++;let r=t.m_curveData.m_segmentParamIndex.read(s);const o=Xi(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<o;e++){const e=t.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(n)}}if(h){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&e("");const s=this.getPathSize(t);if(0===s)return;const i=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=i;const e=new this.m_segmentBufferCTor;let r=!1;for(let i=0;i<s;i++,t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!Xh.isNonLinearSegmentFlag(s))continue;r=!0,this.querySegment(t,e,!0),e.get().reverse();const i=this.m_curveData.m_segmentParamIndex.read(t);e.get().writeInBufferStream(this.m_curveData.m_segmentParams,i)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(i,s-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(i,s-t,1)}}const r=n?1:0;for(let e=0,a=this.m_description.getAttributeCount();e<a;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),n=Mh.getComponentCount(t);this.m_vertexAttributes.get(e).reverseRange(n*(i+r),n*(s-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const s=this.getPathCount();t<0&&(t=s-1),t>=s&&e("");const i=this.getPathStart(t),n=this.getPathSize(t);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++)if(this.m_vertexAttributes.get(e)){const t=this.m_description.getSemantics(e),s=Mh.getComponentCount(t);this.m_vertexAttributes.get(e).eraseRange(s*i,s*n,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=i,s=i+n;e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);Xh.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(i,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(i,n,this.m_pointCount)}for(let e=t+1;e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e-1,t-n)}if(this.m_pathFlags)for(let e=t+1;e<=s;e++){const t=this.m_pathFlags.read(e);this.m_pathFlags.write(e-1,t)}this.m_paths.resize(s),this.m_pathFlags.resize(s),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===s-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,s,i,n){this===s&&e("Multi_path_impl::insert_path");const r=this.getPathCount();if(!n&&s.hasNonLinearSegmentsPath(i))return t=this.insertPath(t,s,i,!0),this.reversePath(t),t;i>=s.getPathCount()&&e(""),t>r&&e(""),t<0&&(t=r),i<0&&(i=s.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(s.getDescription());const o=s.getPathStart(i),a=s.getPathSize(i);if(0===a)return this.insertPath2D(t,null,0,0,!0);const h=this.m_pointCount,m=s.isClosedPath(i)&&!n?1:0;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const u=t<r?this.getPathStart(t):h;for(let e=0,d=this.m_description.getAttributeCount();e<d;e++){const t=this.m_description.getSemantics(e),i=s.getDescription().getAttributeIndex(t),r=Mh.getComponentCount(t);if(i>=0&&s.m_vertexAttributes.get(i))0!==m&&this.m_vertexAttributes.get(e).insertRangeFromStream(u*r,s.m_vertexAttributes.get(i),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(e).insertRangeFromStream((u+m)*r,s.m_vertexAttributes.get(i),r*(o+m),r*(a-m),n,r,r*(h+m));else{const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(u*r,s,r*a,r*h)}}const l=h+a;this.m_paths.add(l);for(let e=r;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+a)}this.m_pathFlags.add(0);for(let e=r-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=s.getPathFlagsStreamRef().read(i);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),s.hasNonLinearSegments()){this.initSegmentData(0);let t=o,e=0;for(let i=0;i<a;i++){e+=Xi(s.m_curveData.m_segmentFlags.read(t)),t++}if(e>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=Ot(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=Ut(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,a,h),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,a,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+e):this.m_curveData.m_segmentParams=Qt(e),t=o;let i=u,n=0;for(let e=0;e<a;e++){const e=s.m_curveData.m_segmentFlags.read(t);if(Xh.isNonLinearSegmentFlag(e)){this.m_curveData.m_segmentFlags.write(i,e),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const r=Xi(e);let o=s.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=s.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(e,1)}t++,i++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,s,i,n,r){const o=this.getPathCount();(t>o||i<0)&&e(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(s)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,s,i,n,r,2*a);else{const t=Mh.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let e=1,m=this.m_description.getAttributeCount();e<m;e++){const t=this.m_description.getSemantics(e),s=Mh.getComponentCount(t),i=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,s,i,n,r){const o=s.getImpl(),a=this.getPathCount();(t>a||i<0)&&e("");const h=n<0?o.getPointCount()-i:n;if(h>o.getPointCount()&&e(""),i>=o.getPointCount()&&e("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,u=i;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const l=t<a?this.getPathStart(t):m;for(let e=0,g=this.m_description.getAttributeCount();e<g;e++){const t=this.m_description.getSemantics(e),s=o.getDescription().getAttributeIndex(t),i=Mh.getComponentCount(t);if(s>=0){const s=o.getAttributeStreamRef(t);this.m_vertexAttributes.get(e).insertRangeFromStream(l*i,s,i*u,i*h,r,i,i*m)}else{const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(l*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let d=0;this.m_bPolygon&&(d|=1),this.m_pathFlags.write(t,d),this.notifyModifiedFlags(2001)}insertPoints(t,s,n,r,o,a,h){if(this===n&&e("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=n.getPathCount()-1),(t>this.getPathCount()||s>=0&&s>this.getPathSize(t)||r>=n.getPathCount()||a>n.getPathSize(r))&&i(""),!a)return;if(this.mergeVertexDescription(n.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=n.m_pathFlags.read(r);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}s<0&&(s=this.getPathSize(t));const m=this.m_pointCount;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const u=this.getPathStart(t),l=u+s;a<0&&(a=n.getPathSize(r));const c=n.getPathStart(r),d=c+a;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const t=this.m_description.getSemantics(e),i=Mh.getComponentCount(t),r=n.m_description.getAttributeIndex(t);if(r<0||!n.m_vertexAttributes.get(r)){const s=Mh.getDefaultValue(t);this.m_vertexAttributes.get(e).insertRange(i*l,s,d*i,i*m)}else this.m_vertexAttributes.get(e)?.insertRangeFromStream(i*(u+s),n.m_vertexAttributes.get(r),i*(c+o),a*i,h,i,i*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+s,1,a,m),this.m_curveData.m_segmentParamIndex.insertRange(u+s,-1,a,m),s>0&&this.isNonLinearSegment(u+s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+s-1),-1),this.m_curveData.m_segmentFlags.write(u+s-1,1),this.m_curveData.m_segmentParamIndex.write(u+s-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+a)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&i(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let i=1,m=this.m_description.getAttributeCount();i<m;i++){const t=this.m_description.getSemantics(i),s=Mh.getComponentCount(t),n=Mh.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange((h+e)*s,n,s*r,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,m=this.getPathCount();i<=m;i++)this.m_paths.write(i,this.m_paths.read(i)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl();if(t<0&&(t=this.getPathCount()),r<0&&(r=s.getPointCount()),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>s.getPointCount())&&i(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),u=m+e,l=0,c=l+r;for(let i=0,d=this.m_description.getAttributeCount();i<d;i++){const t=this.m_description.getSemantics(i),s=Mh.getComponentCount(t);if(a.getDescription().getAttributeIndex(t)<0){const e=Mh.getDefaultValue(t);this.m_vertexAttributes.get(i).insertRange(s*u,e,c*s,s*h);continue}const d=a.getAttributeStreamRef(t);this.m_vertexAttributes.get(i).insertRangeFromStream(s*(m+e),d,s*(l+n),r*s,o,s,s*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,r,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,r,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let i=t+1,d=this.getPathCount();i<=d;i++){const t=this.m_paths.read(i);this.m_paths.write(i,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=Mh.getComponentCount(e),i=Mh.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&i(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByVal(a,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=Mh.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=Mh.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let s=t+1,i=n;s<=i;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&i("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&i("Multi_path.remove_point");const o=n+e;for(let i=0,a=this.m_description.getAttributeCount();i<a;i++)if(this.m_vertexAttributes.get(i)){const t=this.m_description.getSemantics(i),e=Mh.getComponentCount(t);this.m_vertexAttributes.get(i).eraseRange(e*o,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let i=s;i>=t+1;i--){const t=this.m_paths.read(i);this.m_paths.write(i,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)Xh.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=Xh.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new hs({x:t,y:e}))}startPath(t){this.startPathPoint(new hs({pt:t}))}startPath3D(t){this.startPathPoint(new hs({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new hs({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&e("");const s=t.getDescription();let i;if(this.m_description!==s){this.mergeVertexDescription(s);const e=new hs({vd:this.m_description});t.copyCommonAttributesTo(e),i=e}else i=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,i):(this.insertPoint(-1,-1,i),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=Ut(2),this.m_paths.write(0,0),this.m_pathFlags=Ot(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{const s=zt(),i=new hs({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=he(this.m_description,ce()),s=zt(),i=new hs({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByVal(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new Bt(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=zt(),s=new hs({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&a("");const s=this.getPathCount();if(t>s&&e(""),!this.isClosedPath(t))return;this.m_pathFlags||a("");const i=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),s=Mh.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*r,this.m_vertexAttributes.get(t),s*n,s,!0,1,s*i)}for(let e=s;e>t;e--){const t=this.m_paths.read(e);this.m_paths.write(e,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(r,1,1,i),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,i)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&a(""),t>this.getPathCount()&&e(""),this.m_pathFlags||a(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&a(""),this.isEmpty())return;this.m_pathFlags||a("");let t=0;const e=this.getPathCount();for(let a=0;a<e;a++)this.isClosedPath(a)&&(this.getPathSize(a)>0?t++:this.m_pathFlags.clearBits(a,1));if(0===t)return;const s=this.hasNonLinearSegments();let i=0;const n=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let h=null,m=null;for(let a=0;a<n;++a){const e=this.getPathStart(a),n=this.getPathSize(a),u=this.isClosedPath(a);if(n>0){const a=e+i;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=Mh.getComponentCount(i);if(!o[s]){const e=Zt(i,r*(this.m_pointCount+t));o[s]=e}o[s].writeRange(a*r,n*r,this.m_vertexAttributes.get(s),e*r,!0,1),u&&o[s].writeRange((a+n)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===h){const e=this.m_pointCount+t;h=Ot(e),m=Ut(e)}h.writeRange(a,n,this.m_curveData.m_segmentFlags,e,!0,1),m.writeRange(a,n,this.m_curveData.m_segmentParamIndex,e,!0,1),u&&(h.write(a+n,1),m.write(a+n,-1))}}this.m_paths.write(a,e+i),u&&(this.m_pathFlags.clearBits(a,1),++i)}this.m_paths.write(n,this.m_pointCount+t),this.m_pathFlags.clearBits(n,1);for(let a=0;a<r;a++)this.m_vertexAttributes.get(a)&&this.m_vertexAttributes.set(a,o[a]);s&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const s=this.m_pathFlags.read(t);if(this.m_pathFlags.write(t,1|s),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==s&&(this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,s){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&e("close_path_with_line"),s.getEndXY().equals(this.getXY(this.getPathStart(t)))||e("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(s,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(s.getDescription());const i=s.getStartXY(),r=this.getPathEnd(t)-1;i.equals(this.getXY(r))||e("close_path_with_segment: start point mismatch");const o=s.getGeometryType();if(o===n.enumLine)return void this.closePathWithLine(t);{const t=Yi(s);this.initSegmentData(t);const e=Yh.toSegType(o),i=this.m_curveData.m_segmentFlags.read(r);if(i!==e)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),s.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(e,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(r);s.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,e)}}const i=this.m_pathFlags.read(t);this.m_pathFlags.write(t,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(t){return s(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(Xh.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof qt)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=zt(),n=new hs({vd:s,attribBuffer:i,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,n),0===r?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,s){if(t.isClosed()||e("add_path_from_closedSegment: segment must be closed"),s){const e=t.getReversed(),s=new hs;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new hs;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,s){const i=t.getDescription();this.mergeVertexDescription(i);const r=zt(),o=new hs({vd:i,attribBuffer:r,initDefaultValues:!1}),a=t.getGeometryType();if(a===n.enumLine)(s||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let i=!1;if((s||this.isEmptyImpl())&&(i=!0),!i){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||e("add_segment: start point mismatch")}if(i&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{const t=zt(),e=new hs({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const n=Yi(t);this.initSegmentData(n),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=n;const r=Yh.toSegType(a);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,s,i,n){for(let a=t;a<i-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,s,i,n);if(0!==o)for(let e=1;e<r;e++){const r=this.m_description.getSemantics(e);this.interpolateAttributesSemanticsImpl(r,t,s,i,n,o)}}interpolateAttributesSemantics(t,s,i,n,r){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===Mh.getInterpolation(t)&&e("angular interpolation");for(let a=s;a<n-1;a++)this.isClosedPath(a)&&e("cannot interpolate across closed paths");const o=this.calculateSubLength2D(s,i,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,s,i,n,r,o)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(t,s,i,n){if(0===t)return;this.hasAttribute(t)||e("does not have the given attribute");2===Mh.getInterpolation(t)&&e("angular interpolation");const r=this.calculatePathSubLength2D(s,i,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,s,i,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,n,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(i)+n,m=Mh.getComponentCount(t),u=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new Array(Mh.maxComponentCount());A(c,u,0,0,m);let d=0;const g=Mh.getDefaultValue(t),_=Mh.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,m),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;d+=e.calculateLength2D();T(_,u,l,c,0,m,d/r,g),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,m)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,n){const r=this.querySegmentIterator(),o=Mh.getInterpolation(t),a=this.getPathStart(e)+s,h=this.getPathStart(e)+i;if(h===a)return;const m=Mh.getComponentCount(t),u=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(Mh.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new X(0);r.resetToVertex(a,e),r.setCirculator(this.isClosedPath(e));const d=Mh.getDefaultValue(t),g=new Array(Mh.maxComponentCount());A(g,u,0,0,m);const _=0===n;let p=.5;do{const e=r.nextSegment();if(this.setAttributeFromArray(t,r.getStartPointIndex(),g,m),!_){const t=e.calculateLength2D();c.pe(t),p=c.getResult()/n}T(o,u,l,g,0,m,p,d)}while(r.getEndPointIndex()!==h)}querySegment(t,s,i){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&e("get_segment"),this.getSegmentFromPath(n,r,s,i)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const s=this.getPathIndexFromPointIndex(t),i=t-this.getPathStart(s);return i>=this.getSegmentCountPath(s)&&e("get_segment"),this.getSegmentTypeFromPath(s,i)}getSegmentFromPath(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(n)),o){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:a("")}const h=s.get();let m,u=null;i?(u=le(),h.assignVertexDescription(u)):h.assignVertexDescription(this.m_description),m=n===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):n+1;Vs(h,this.getXY(n));if(ks(h,this.getXY(m)),!i)for(let a=1,l=this.m_description.getAttributeCount();a<l;a++){const t=this.m_description.getSemantics(a),e=Mh.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,n,s);h.setStartAttribute(t,s,e);const i=this.getAttributeAsDbl(t,m,s);h.setEndAttribute(t,s,i)}}if(Xh.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(n);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++){if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);Mi(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,s,i,n=!1){const r={iSegment:-1},o=n?r:{iSegment:-1,tSegment:0};if(i.setEmpty(),this.isEmpty())return r;if((t<0||t>=this.getPathCount())&&e("query_point_along_path"),s<0)return r;const a=this.getPathSize(t);if(0===a)return r;if(1===a)return this.getPointByVal(this.getPathStart(t),i),o.tSegment=0,r.iSegment=this.getPathStart(t),r;const h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),m=new X(0);for(;h.hasNextSegment();){const t=h.nextSegment(),e=t.calculateLength2D(),n=m.getResult();if(m.add(e),m.getResult()>=s){let a=s-n;a>e&&(a=e);const m=t.lengthToT(a);return t.queryCoord(m,i),o.tSegment=m,r.iSegment=h.getStartPointIndex(),r}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,i),o.tSegment=1,r.iSegment=this.getPathEnd(t)-1,r}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,i),this.getPathSize(t)>1?(o.tSegment=1,r.iSegment=this.getPathEnd(t)-2,r):(o.tSegment=0,r.iSegment=this.getPathStart(t),r)}}queryPointsAlongPath(t,s,i,n,r,o){{let t=0;for(let a=0;a<s;++a)n&&n[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),t>i[a]&&e("query_points_along"),t=i[a]}const a=this.getPathSize(t);if(0===s||0===a)return 0;if(1===a){const e=this.getPathStart(t);return n&&this.getPointByVal(e,n[0]),o&&(o[0]=0),r&&(r[0]=e),1}const h=this.getPathStart(t),m=new X(0),u=this.querySegmentIteratorAtVertex(h);let l=0,c=0,d=i[l];for(;u.hasNextSegment();){const t=u.nextSegment(),e=t.calculateLength2D(),a=m.getResult();for(m.add(e);m.getResult()>=d;){let h=d-a;h>e&&(h=e);const m=t.lengthToT(h);if(n&&t.queryCoord(m,n[c]),o&&(o[c]=m),r&&(r[c]=u.getStartPointIndex()),c++,l++,d=i[l],l===s)return c}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;n&&this.getPointByVal(e,n[c]),o&&(o[c]=s),r&&(r[c]=e),c++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;n&&this.getPointByVal(e+1,n[c]),o&&(o[c]=s),r&&(r[c]=e),c++}return c}queryPointsAlong(t,s,i,n,r){{let o=0;for(let a=0;a<t;++a)i&&i[a].setEmpty(),n&&(n[a]=-1),r&&(r[a]=0),o>s[a]&&e("query_points_along"),o=s[a]}if(0===t)return 0;const o=new X(0),a=this.querySegmentIterator();let h=-1,m=0,u=0,l=s[m];for(;a.nextPath();)for(;a.hasNextSegment();){h=a.getPathIndex();const e=a.nextSegment(),c=e.calculateLength2D(),d=o.getResult();for(o.add(c);o.getResult()>=l;){let o=l-d;o>c&&(o=c);const h=e.lengthToT(o);if(i&&e.queryCoord(h,i[u]),r&&(r[u]=h),n&&(n[u]=a.getStartPointIndex()),u++,m++,l=s[m],m===t)return u}}if(h<0)return 0;if(this.isClosedPath(h)){const t=this.getPathStart(h),e=0;i&&this.getPointByVal(t,i[u]),r&&(r[u]=e),n&&(n[u]=t),u++}else if(this.getPathSize(h)>1){const t=this.getPathEnd(h)-2,e=1;i&&this.getPointByVal(t+1,i[u]),r&&(r[u]=e),n&&(n[u]=t),u++}return u}querySegmentIterator(){return new Ti({parent:this})}querySegmentIteratorAtVertex(t){return new Ti({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,i,n){if(i instanceof cs&&s(0,"not implemented for Envelope"),i instanceof kt&&s(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&e(""),this.isEmpty())return void i.setEmpty();const r=this.getAttributeStreamRef(0),o=qt.constructEmpty();o.setEmpty();for(let e=2*this.getPathStart(t),a=2*this.getPathEnd(t);e<a;){const t=a-e;s(!(1&t)),o.mergePointsInterleaved(r,e/2,t/2),e+=t}if(i.setCoords({env2D:o}),this.hasNonLinearSegmentsPath(t)){const e=this.querySegmentIterator();if(e.resetToPath(t),e.nextPath())for(;e.hasNextSegment();){const t=e.nextCurve();if(!t)break;{const e=qt.constructEmpty();n?t.queryEnvelope(e):t.queryLooseEnvelope(e),i.mergeEnvelope2D(e)}}else s(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=Xi(4)*this.m_curveData.m_arcCount+Xi(2)*this.m_curveData.m_bezierCount+Xi(8)*this.m_curveData.m_rbezier2Count+Xi(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let i=0,n=this.getPointCount();i<n;i++){const e=this.m_curveData.m_segmentFlags.read(i);if(Xh.isNonLinearSegmentFlag(e)){t+=Xi(e)}}const e=Qt(t);let s=0;for(let i=0,n=this.getPointCount();i<n;i++){const t=this.m_curveData.m_segmentFlags.read(i);if(Xh.isNonLinearSegmentFlag(t)){let n=this.m_curveData.m_segmentParamIndex.read(i);this.m_curveData.m_segmentParamIndex.write(i,s);const r=Xi(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){s(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=Ut(0),this.m_pathFlags=Ot(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=Ut(0),this.m_pathFlags=Ot(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new Fh(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new Yh),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,i){if(i>=0&&i<e){if(s>=t.read(i)){if(s<t.read(i+1))return i;i++}else i--;if(i>=0&&i<e&&s>=t.read(i)&&s<t.read(i+1))return i}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;g("")}let n=0,r=e-1;for(;r>n;){const e=n+(r-n>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(t){s(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),i=this.getPathEnd(t),n=this.getPathStart(t);let r=-1;const o=new f;o.y=Number.NEGATIVE_INFINITY,o.x=Number.NEGATIVE_INFINITY;for(let s=n+0;s<i;s++){const t=e.readPoint2D(2*s);-1===o.compare(t)&&(r=s,o.setCoordsPoint2D(t))}return r}applyTransformationToPath(t,s){if(s>=this.getPathCount()&&e("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const i=this.m_vertexAttributes.get(0);if(!(s<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(s))){let e,n;return s<0?(e=0,n=this.m_pointCount):(e=this.getPathStart(s),n=this.getPathEnd(s)),i.applyTransformation(t,2*e,n-e),void this.notifyModifiedFlags(2001)}const n=new this.m_segmentBufferCTor,r=this.getPathCount();let o=s<0?0:s;do{const e=this.getPathStart(o),r=this.getPathEnd(o),a=this.isClosedPath(o),h=i.readPoint2D(2*e);if(!this.hasNonLinearSegmentsPath(o)){i.applyTransformation(t,2*e,r-e);continue}const m=f.getNAN();for(let s=e;s<r;++s){if(1!==(31&this.m_curveData.m_segmentFlags.read(s))){const o=a&&s+1===r;o&&i.writePoint2D(2*e,h),this.getSegmentBuffer(s,n,!0),n.get().applyTransformation(t);const m=this.m_curveData.m_segmentParamIndex.read(s);n.get().writeInBufferStream(this.m_curveData.m_segmentParams,m),i.writePoint2D(2*s,n.get().getStartXY()),o&&i.writePoint2D(2*e,n.get().getEndXY());continue}const o=2*s;i.queryPoint2D(o,m),t.transformInPlace(m),i.writePoint2D(o,m)}if(o===s)break}while(++o<r);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getPathStart(s)+i;(r<n||n<0||r>this.getPointCount()-1)&&o("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(n,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===r)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===r)break}while(a.nextPath());return h}calculatePathSubLength2D(t,s,i){const n=this.getPathStart(t)+s,r=this.getPathStart(t)+i;(n<0||r>this.getPointCount()-1)&&o("");const a=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||e("cannot iterate across an open path"),a.setCirculator(!0)),n===r)return 0;let h=0,m=0;a.resetToVertex(n,t);do{m+=h;h=a.nextSegment().calculateLength2D()}while(a.getStartPointIndex()!==r);return m}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=qt.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,s){this===t&&e("Multi_path_impl::add");let i=this.getPathCount();for(let e=0,n=t.getPathCount();e<n;e++)this.addPath(t,e,!s),this.openPathAndDuplicateStartVertex(i),i++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,s,i){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&e("getSegmentBuffer"),this.getSegmentFromPath(n,r,s,i)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,i=this.getSegmentFlagsStreamRef();let r=1;switch(i&&(r=31&i.read(s)),r){case 1:return n.enumLine;case 2:return n.enumBezier;case 4:return n.enumEllipticArc;case 8:return n.enumRationalBezier2;case 16:return n.enumBezier2;default:a("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let e=!1;for(let s=0,i=this.getPathCount();s<i;s++){const i=this.getPathStart(s),n=this.getPathEnd(s),r=n-i;for(let s=i;s<n;s++){const n=31&this.m_curveData.m_segmentFlags.read(s);if(1===n)continue;2!==n&&t("ensure_xy_monotone_segments");const o=(s-i+1)%r+i,a=this.m_curveData.m_segmentParamIndex.read(s),h=x(f,4);h[0]=this.getXY(s),h[3]=this.getXY(o),h[1].x=this.m_curveData.m_segmentParams.read(a),h[1].y=this.m_curveData.m_segmentParams.read(a+1),h[2].x=this.m_curveData.m_segmentParams.read(a+2),h[2].y=this.m_curveData.m_segmentParams.read(a+3),Ga(h)&&(e=!0,this.m_curveData.m_segmentParams.write(a,h[1].x),this.m_curveData.m_segmentParams.write(a+1,h[1].y),this.m_curveData.m_segmentParams.write(a+2,h[2].x),this.m_curveData.m_segmentParams.write(a+3,h[2].y))}}return e&&this.notifyModifiedFlags(2001),e}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ii),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=is(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Ii),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=es(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(Xh.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new Yh),Xh.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new Yh),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new Yh);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=Ot(e,1),this.m_curveData.m_segmentParamIndex=Ut(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=Qt(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new Yh),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=ct(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,i,n){(t<0||t>=this.getPointCount())&&e("Multi_path_impl.replace_segment"),s(i.isCurve());const r=this.getPathIndexFromPointIndex(t),o=this.getPathStart(r),a=(t-o+1)%this.getPathSize(r)+o;{const e=this.getXY(t),n=this.getXY(a),r=!e.isEqualPoint2D(i.getStartXY())||!n.isEqualPoint2D(i.getEndXY());s(!r)}const h=i.getDescription();this.mergeVertexDescription(h);const m=new Array(32),u=new hs({vd:h,attribBuffer:m,initDefaultValues:!1}),l=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),c=Xi(l),d=Yi(i);let g,_=!1;c>=d?(s(null!==this.m_curveData),_=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(d),_=!1,g=this.m_curveData.m_curveParamWritePoint);const p=i.getGeometryType(),f=Yh.toSegType(p);n||(i.queryStart(u),this.setPointByVal(t,u),i.queryEnd(u),this.setPointByVal(a,u)),this.m_curveData.m_segmentParamIndex.write(t,1!==f?g:-1),this.m_curveData.m_segmentFlags.write(t,f),1!==f&&i.writeInBufferStream(this.m_curveData.m_segmentParams,g),_||(this.m_curveData.m_curveParamWritePoint+=d),l!==f&&(this.incCurveType(l,-1),this.incCurveType(f,1),this.modifyCurveCounter(1===l?1:-1))}setAttributeImpl(t,s,i){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(s<0||s>1)&&e("");const t=new k,n=0===s?i:0,r=0===s?0:1;t.setShiftCoords(n,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,s,i)}}Xh.st_totalCurveCount=0;class Fh{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new qt(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e);return this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=qt.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class Rh extends Xh{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=ol):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ol,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ol):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ol,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=ol,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):a("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=ol)}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return Rh.type}getDimension(){return 1}createInstance(){return new Rh({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}Rh.type=n.enumPolyline;var Lh=n;function zh(e,s){if(e.isEmpty())return!1;const i=e.getGeometryType();if(i===Lh.enumPolygon)return 0!==e.calculateArea2D();if(i===Lh.enumPolyline)return Bh(e.getImpl(),s,!0).bNotEmpty;if(i===Lh.enumEnvelope)return!0;if(m(i))return!!e.isClosed();if(l(i))return!1;if(i===Lh.enumGeometryCollection){const t=e;for(let e=0,i=t.getGeometryCount();e<i;e++)if(zh(t.getGeometry(e),s))return!0;return!1}t("")}function Vh(e,s){const i=e.getGeometryType();if(i===Lh.enumPolygon){const t=new Rh({vd:e.getDescription()});return e.isEmpty()||e.copyToUnchecked(t),t}if(i===Lh.enumPolyline)return Bh(e.getImpl(),s,!1).boundary;if(i===Lh.enumEnvelope){const t=new Rh({vd:e.getDescription()});return e.isEmpty()||t.addEnvelope(e,!1),t}if(m(i)){const t=new Es({vd:e.getDescription()});if(!e.isEmpty()&&!e.isClosed()){const s=new hs;t.reserve(2),e.queryStart(s),t.add(s),e.queryEnd(s),t.add(s)}return t}if(i===Lh.enumGeometryCollection){const t=e;let i=null;for(let n=0,r=t.getGeometryCount();n<r;n++){const r=Vh(t.getGeometry(n),s);if(null!==r){null===i&&(i=e.createInstance());const t=r;i.addGeometry(t)}}return i}if(l(i))return new hs({vd:e.getDescription()});t("")}function Bh(t,e,s){const i=!1,n=t;let r=null;if(s||(r=new Es({vd:n.getDescription()})),!n.isEmpty()){const t=new Jt(0);for(let e=0,s=n.getPathCount();e<s;e++){if(n.getPathSize(e)>0&&!n.isClosedPathInXYPlane(e)){const s=n.getPathStart(e);t.add(s);const i=n.getPathEnd(e)-1;t.add(i)}}if(t.size()>0){const e=new ge,i=n.getAttributeStreamRef(0),o={userSort(t,e,s){const n=f.getNAN(),r=f.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,r),n.compare(r))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),o);let a=i.readPoint2D(2*t.read(0)),h=0,m=1;const u=new hs;for(let n=1,r=t.size();n<r;n++){const e=i.readPoint2D(2*t.read(n));if(e.isEqualPoint2D(a))t.read(h)>t.read(n)?(t.write(h,N()),h=n):t.write(n,N()),m++;else{if(1&m){if(s)return{bNotEmpty:!0,boundary:new Es({})}}else t.write(h,N());a=e,h=n,m=1}}if(1&m){if(s)return{bNotEmpty:!0,boundary:new Es({})}}else t.write(h,N());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==N();e++)n.getPointByVal(t.read(e),u),r.add(u)}}}return s?{bNotEmpty:i,boundary:new Es({})}:{bNotEmpty:i,boundary:r}}const kh=it/180,Gh=180/it;function Hh(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=vt(e,360),e<0&&(e+=360),e)}function Wh(t){let e=t;return e=Hh(e),e>180&&(e-=360),e}function jh(t){return t*kh}function Zh(t){return t*Gh}function Uh(t){const e=ht();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=vt(s,e),s<0&&(s+=e),s)}function Oh(t){const e=nt();let s=t;return s>-e&&s<=e||(s=Uh(s),s>e&&(s-=ht())),s}function Qh(t,e){return Wh(e-t)}var Kh=Vt;class $h extends oi{constructor(t){if(void 0===t||F(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new f(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new f(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new f(0,0),this.m_interior=new f(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new f(0,0),this.m_interior=new f(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new f(0,0),this.m_interior=new f(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return Vh(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=f.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=f.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return km(this,t,e,1),this}constructLineCircularArc(t,e){return km(this,t,e,0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new f(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(i),a=Math.sin(i);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new k;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new k;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return uu(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const n=f.calculateCircleCenterFromThreePoints(t,e,s);if(!n.isFinite()||!Number.isFinite(f.distance(t,n))){const i=f.distance(t,e),n=f.distance(t,s);this.constructLineCircularArc(t,i>=n?e:s)}return this.constructCircleCenterAndPoint(n,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new V(t.x),n=new V(e.x),r=new V(s.x),o=new V(t.y),a=new V(e.y),h=new V(s.y),m=new V(.5),u=n.subE(i),l=a.subE(o),c=r.subE(i),d=h.subE(o),g=u.mulE(d).subThisE(l.mulE(c));if(g.scaleError(10),g.isZero()){if(!u.isZero()||!l.isZero())return km(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const _=u.sqr().addThisE(l.sqr()).mulThisE(m),p=c.sqr().addThisE(d.sqr()).mulThisE(m),x=_.mulE(d).subThisE(p.mulE(l)),y=u.mulE(p).subThisE(c.mulE(_));x.divThisE(g),y.divThisE(g);const P=x.sqr().addThisE(y.sqr());P.sqrtThis();const v=x.addE(i),C=y.addE(o);let b=t.x-v.value(),E=t.y-C.value();const D=Math.atan2(E,b);b=e.x-v.value(),E=e.y-C.value();const S=Math.atan2(E,b);b=s.x-v.value(),E=s.y-C.value();const w=Math.atan2(E,b);let A=w-2*nt();for(;A<D;)A+=2*nt();let T=S-2*nt();for(;T<A;)T+=2*nt();let I=w+2*nt();for(;I>D;)I-=2*nt();let N,q=S+2*nt();for(;q>I;)q-=2*nt();N=T-D<D-q?T-D:q-D;const M=new f(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,P.value(),1,0,Math.abs(N)>nt(),N>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return Bm(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return Bm(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Oh(r),a=Math.cos(o),h=Math.sin(o),m=new f(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=f.getNAN(),l=Oh(i);u.x=m.x*Math.cos(l),u.y=m.y*Math.sin(l),u.rotateDirect(a,h),u.addThis(s);const c=Pt(n,ht());let d=c;Math.abs(d)===ht()&&(d=0);const g=f.getNAN();return g.x=m.x*Math.cos(l+d),g.y=m.y*Math.sin(l+d),g.rotateDirect(a,h),g.addThis(s),this.constructEllipticArcEndPointsCenter(u,g,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>nt(),c>0,s)}constructEllipticArcAsNURB(t,s,i,n){(n>=1||n<0)&&e("construct_elliptic_arc_as_NURB: weight"),s.isFinite()||e("construct_elliptic_arc_as_NURB: control_point");return au([t,s,i],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,cu(this),this.afterCompletedModification(),t!==this&&$s(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!Fs(this,[t])&&Gm(this)}isDegenerateToLine(){return Gm(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return f.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!Jm(this)}isMajor(){return eu(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return n.enumEllipticArc}queryEnvelope(e){if(4===e.m_EnvelopeType){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=qt.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=Kh.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else 2===e.m_EnvelopeType?fu(this,D.unit(),e):t("3d not impl")}applyTransformation(t){Zm(this,t,!1)}createInstance(){return new $h}calculateLength2D(){return Xm(this,0,1)}queryCoord2D(t,e){if(Gm(this))mi(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(f.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(f.construct(this.m_XEnd,this.m_YEnd));else{const s=Nm(this,t),i=new f(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){Cm(this,t,e)}getCoordX(t){const e=new f;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new f;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();let r=0===t&&1===e;if(r&&!i)return void this.copyTo(n);const o=f.getNAN();this.queryCoord2D(t,o);const a=f.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,Bs(n,o.x,o.y),Gs(n,a.x,a.y),r)return void Om(n,Fm(this));n.m_startAngle=Nm(this,t),n.m_sweepAngle=Nm(this,e)-n.m_startAngle,n.m_startAngle=Sm(n.m_startAngle),tu(n,Math.abs(n.m_sweepAngle)>nt()),n.assignVertexDescription(this.m_description),cu(n),Tm(n);const h=this.m_description.getAttributeCount();if(h>1){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),i=Kh.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),i=Kh.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){vu(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new f;this.queryCoord2D(t,n);const r=new f;this.queryCoord2D(e,r),i||(n.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,Bs(s,n.x,n.y),Gs(s,r.x,r.y),i?Om(s,Fm(this)):(s.m_startAngle=Nm(this,t),s.m_sweepAngle=Nm(this,e)-s.m_startAngle,s.m_startAngle=Sm(s.m_startAngle),tu(s,Math.abs(s.m_sweepAngle)>Math.PI),cu(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Lm(this,t,e,!1)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0,r=Kh.getInterpolation(e),o=this.getStartAttributeAsDbl(e,s),a=this.getEndAttributeAsDbl(e,s);return z(r,o,a,n,Kh.getDefaultValue(e))}getClosestCoordinate(t,e){return xu(this,t,D.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return xu(this,t,e,!1)}getYMonotonicParts(t,i=!1){t.length<2&&e("");const n=this.getSemiAxes(),r=Math.atan2(n.y*this.m_cosr,n.x*this.m_sinr),o=r+nt(),a=new Array(3);let h=0;if(a[0]=Im(this,r),a[0]>0&&a[0]<1&&h++,a[1]=Im(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,s(t.length>=h);let m=0;for(let e=0;e<h;e++){const s=a[e];this.queryCut(m,s,t[e],i),m=s}return h}getMonotonicParts(t,i){if(t.length<4&&e(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),i&&t[0].get().dropAllAttributes(),1;const n=this.getSemiAxes(),r=new Array(4);r[0]=Math.atan2(n.y*this.m_cosr,n.x*this.m_sinr),r[1]=r[0]+nt(),r[2]=Math.atan2(-n.y*this.m_sinr,n.x*this.m_cosr),r[3]=r[2]+nt();const o=new Array(5);let a=0;for(let e=0;e<4;e++)o[a]=Im(this,r[e]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;B(o,a),o[a-1]<1&&(o[a]=1,a++),s(t.length>=a);let h=0;for(let e=0;e<a;e++){const s=o[e];this.queryCut(h,s,t[e],i),h=s}return a}intersectionWithAxis2D(t,e,s,i){if(Gm(this)){return new rl({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i)}let n,r;const o=new V(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;n=new V(a.x).mulThis(this.m_sinr),r=new V(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;n=new V(a.x).mulThis(this.m_cosr),r=new V(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=n.sqr(),m=r.sqr(),u=h.addE(m),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),d=l.sqr().subThisE(u.mulE(c).mulThis(4)),g=n.mulE(o).mulThis(-2),_=o.sqr().subThisE(m),p=g.sqr().subThisE(u.mulE(_).mulThis(4));let f=d.eps()*Math.abs(p.value())<=p.eps()*Math.abs(d.value());f?n.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(g),c.setE(_));const y=x(V,2);let P=Ui(u,l,c,D.construct(-1,1),!1,y);if(0===P)return 0;const v=[0,0];let C=0;for(let x=0;x<P;x++){const t=new V,e=new V;f?(t.setE(y[x]),e.setE(o.subE(r.mulE(y[x])).divThisE(n))):(e.setE(y[x]),t.setE(o.subE(n.mulE(y[x])).divThisE(r)));const s=Im(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(v[C]=s,C++)}return P=C,0===P?0:(2===P&&v[0]>v[1]&&(v[1]=S(v[0],v[0]=v[1])),i&&A(i,v,0,0,P),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),P>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=S(s[0],s[0]=s[1])))),P)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return Xs(this,t)}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(e){3!==e.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new D(0,1),e):t("3d not impl")}clone(t){const e=new $h;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(Gm(this))return 0===e?D.construct(this.getStartX(),this.getEndX()):D.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=Im(this,t),n[1]=Im(this,i);const r=0===e?D.construct(this.getStartX(),this.getEndX()):D.construct(this.getStartY(),this.getEndY()),o=new f;for(let a=0;a<2;a++){const t=n[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new D(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(Gm(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),n=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=rt){let t=f.lerp(i,n,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*f.distance(i,n))),e.setCoords(i),e.mergeNe(n),void e.mergeNe(t)}fu(this,s,e)}tToLength(t){return Gm(this)?t*f.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:Hm(this,t)}parametricAngleToT(t){return Im(this,t)}tToParametricAngle(t){return Nm(this,t)}lengthToT(t){if(Gm(this)){const e=f.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return Wm(this,t)}calculateWeightedAreaCentroid2D(t){if(Gm(this)){const t=new f;return t.setCoords(0,0),t}const e=lu(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),n=this.m_semiMajorAxis,r=this.getSemiMinorAxis(),o=this.m_startAngle+this.m_sweepAngle,a=new f;a.x=n*r*(n*this.m_cosr*(-Math.sin(o)+Math.sin(this.m_startAngle))+r*(-Math.cos(o)+Math.cos(this.m_startAngle))*this.m_sinr)/3,a.y=n*r*(r*(Math.cos(o)-Math.cos(this.m_startAngle))*this.m_cosr+n*(-Math.sin(o)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const h=i.add(s).mul(i.crossProduct(s)/6);return a.x-=h.x,a.y-=h.y,a.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new f;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(Gm(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),n=Math.sin(s),r=Math.cos(e),o=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,a=s*(n-i),h=s*(r-o);t.setCoords(a,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),a=e*e,h=s*s,m=e*s,u=a-h,l=u/h,c=u/a,d=Math.sqrt(l),g=Math.sqrt(c),_=.5*m*(Math.asinh(d*n)/d+n*Math.sqrt(1+l*n*n))-.5*m*(Math.asinh(d*i)/d+i*Math.sqrt(1+l*i*i)),p=-.5*m*(Math.asin(g*o)/g+o*Math.sqrt(1-c*o*o))- -.5*m*(Math.asin(g*r)/g+r*Math.sqrt(1-c*r*r));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!Gm(this)){const s=f.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),n=new f;this.queryCoord2D(i,n);return f.distance(n,t)<=e}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}getTangent(t){if(Gm(this))return this.getEndXY().sub(this.getStartXY());{const e=Nm(this,t),s=new f;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(t){if(Gm(this))return this.getEndXY().sub(this.getStartXY());{const e=Nm(this,t),s=new f;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}normalizeAfterEndpointChange(){return!!iu(this)&&(Gm(this)?(nu(this),!1):ru(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new f(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new f(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){const e=Nm(this,t),s=new f,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const n=new f;n.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),n.rotateDirect(this.m_cosr,this.m_sinr));const r=s.sqrLength();if(0===r)return Number.NaN;const o=Math.sqrt(r);s.divThis(o);return s.crossProduct(n)/r}getMonotonicPartParams(t,s){const i=new Array(6);i[0]=0;let n=1;if(this.isDegenerateToLine())i[1]=1,n=2;else{const t=this.getSemiAxes(),e=new Array(4);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=ot());for(let s=0;s<4;s++){const t=Im(this,e[s]);t>0&&t<1&&(i[n]=t,n++)}n>2&&B(i,n),i[n]=1,n++}if(s){t<n&&e("");for(let t=0;t<n;t++)s[t]=i[t]}return n}calculateLowerLength2D(){const t=f.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=f.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=S(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=S(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=S(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return Gm(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,Qm(t)}calculateArea2DHelper(){return lu(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),Gm(this))return;const s=this.getSemiAxes(),i=new Array(8);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=Im(this,t),i[1]=Im(this,e),i[2]=Im(this,n),i[3]=Im(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=Im(this,n),i[5]=Im(this,r),i[6]=Im(this,o),i[7]=Im(this,a)}const n=f.getNAN();for(let r=0;r<8;r++){const s=i[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,n),e.mergeNe(n))}}setSegmentFromCoords(t,e){zm(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return a("should not1; be called"),0}ensureXYMonotone(){if(Gm(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return km(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=x(f,3);let e=ou(this,t);if(Mr(t)){let s=!1;if(0===this.projectionBehavior()){const i=new qt;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const n=new f;n.setSub(t[2],t[0]),n.leftPerpendicularThis(),n.normalize(),n.scale(f.distance(t[2],t[0]));const r=f.lerp(t[2],t[0],.5),o=r.sub(n),a=r.add(n);i.clipLine(o,a);const h=f.getClosestCoordinate(o,a,t[1],!1);t[1]=f.lerp(o,a,h);const m=t[2].sub(t[1]),u=t[0].sub(t[1]),l=m.crossProduct(u),c=m.dotProduct(u);e=at()-Math.abs(.5*Math.atan2(l,c)),s=!0}return au(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Lm(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,Om(e,Fm(this))}reverseImpl(){$m(this,!Jm(this)),Tm(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&cu(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(jh(Wh(Zh(this.m_rotation-s.m_rotation)))),n=Math.abs(nt()-i),r=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}swapImpl(t){const e=t;this.m_center=S(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=S(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=S(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=S(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=S(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=S(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=S(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=S(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=S(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=S(e.m_bits,e.m_bits=this.m_bits),Km(this,e)}afterCompletedModification(){nu(this),Qm(this)}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&i(""),Gm(this)){return new rl({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s)}{const e=f.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const n=this.getClosestCoordinate(t,!1),r=f.getNAN();return this.queryCoord2D(n,r),f.distance(r,t)<=s?G(n,0,1)&&(this.queryCoord2D(0===n?1:0,r),f.distance(r,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,Qm(this)}clearEndPointModified(){nu(this)}}function Jh(t,e,s){t.isEmpty()&&r(""),p(t);const i=t.getImpl(),n=[];return sm(i.getPointCount(),n),im(em(i),n,i.getPointCount(),e)}function tm(t,e,s,i){const n=[];return sm(e,n),im(t,n,e,s)}function em(t){return{at:e=>t.getXY(e)}}function sm(t,e){e.length=t;for(let s=0;s<e.length;++s)e[s]=s;t>3&&_s(t,e)}function im(t,e,s,i,n){let r=0;const o=[0,0,0];let a=0;const h=3;let m=0;for(let u=0;u<h;++u){let n=!1;for(;m<s;){const s=t.at(e[m]);let l=1;if(3===r?l=f.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===r?l=f.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===r&&s.equals(t.at(i[0]))&&(l=0),l<=0){if(l<0&&u+1<h){e[a]=S(e[m],e[m]=e[a]);for(let t=0;t<r;t++)if(i[t]===e[m]){o[t]=m;break}a++}m++;continue}n=!0;let c=0;for(let t=0;t<r;t++)o[t]>m&&(i[c]=i[t],o[c]=o[t],c++);r=c,i[r]=e[m],o[r]=m,r++,r<3?m=a:(1===f.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=S(i[0],i[0]=i[2]),o[2]=S(o[0],o[0]=o[2])),m++)}if(!n)break;if(u+1<h){a=0;let s=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=S(o[t],o[t]=o[e]),i[e]=S(i[t],i[t]=i[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=S(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===f.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=S(i[0],i[0]=i[2]),o[2]=S(o[0],o[0]=o[2]))}m=r}return r}$h.type=n.enumEllipticArc;class nm extends Xh{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!0}),this.m_segmentBufferCTor=ol):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=ol,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=ol):e.envelope?t("envelope constructor not impl"):a("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=ol)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return Vh(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return nm.type}getDimension(){return 2}createInstance(){return new nm({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function rm(t,e,s,i,n,r){return new um(0,0,0,null,!1,w()).densifyEx(t,e,s,i,!1,r)}function om(t,s,i,r){return Number.isFinite(s)||e("replace_all_curves_with_beziers: maxDeviation"),gm(n.enumBezier,t,s,i)}function am(e,i,r,o,a,h,m,u){h&&(h.length=0),m&&(m.length=0);const l=e.getGeometryType();if(l===n.enumLine)return h&&(h.push(e.getStartXY()),h.push(f.getNAN()),h.push(f.getNAN()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;if(l===n.enumBezier){if(!o)return h&&(h.push(e.getStartXY()),h.push(e.getControlPoint1()),h.push(e.getControlPoint2()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;const t=[];t.length=9;let s=e.getMonotonicPartParams(t.length,t);if(t.length=s,s=lm(e,r,t),2===s&&a&&(t[1]=.5,t.push(1),s=3),m&&m.splice(0,0,...t.slice(0,s)),h){const i=new ol;for(let n=1;n<s;n++){const s=t[n-1],r=t[n];e.queryCut(s,r,i,!0);const o=i.get();ka(o),1===n&&h.push(o.getStartXY()),h.push(o.getControlPoint1()),h.push(o.getControlPoint2()),h.push(o.getEndXY())}}return s-1}if(l===n.enumEllipticArc){const t=e;if(t.isDegenerateToLine()||t.isDegenerate(0))return h&&(h.push(e.getStartXY()),h.push(f.getNAN()),h.push(f.getNAN()),h.push(e.getEndXY())),m&&(m.push(0),m.push(1)),1;if(o&&(a||!t.isMonotoneQuickAndDirty())){const n=[];n.length=6;let u=t.getMonotonicPartParams(n.length,n);n.length=u,u=lm(e,r,n),2===u&&a&&(n[1]=.5,n.push(1),u=3);let l=0;if(u>2){const e=new ol,a=m||[];let c=0;for(let d=1;d<u;d++){const g=n[c],_=n[d];if(t.queryCut(g,_,e,!0),e.get().isDegenerate(0))continue;const p=a.length,f=_m(1===d,e.get(),i,r,o,h,m);s(f>0),l+=f;const x=d===u-1,y=n[c],P=e.get().getSweepAngle()/t.getSweepAngle();for(let e=p,s=a.length;e<s;e++)if(a[e]=!x||e+1<s?y+a[e]*P:1,h){const s=3*e,i=t.getCoord2D(a[e]);if(h[s].setCoordsPoint2D(i),s>0){Ga(h.slice(s-3))}}c=d}return l}}return _m(!0,t,i,r,o,h,m)}if(l===n.enumRationalBezier2){const t=e;if(o&&(a||!t.isMonotoneQuickAndDirty())){const s=[];s.length=6;let n=t.getMonotonicPartParams(s.length,s);s.length=n,n=lm(e,r,s),2===n&&a&&(s[1]=.5,s.push(1),n=3);let o=0;if(n>2){const e=new ol,a=m||[];for(let u=1;u<n;u++){const l=s[u-1],c=s[u];t.queryCut(l,c,e,!0);const d=a.length;o+=fm(1===u,e.get(),i,r,!1,h,m);const g=u===n-1,_=s[u-1];for(let e=d,s=a.length;e<s;e++)if(a[e]=!g||e+1<s?_+a[e]:1,h){const s=3*e,i=t.getCoord2D(a[e]);if(h[s].setCoordsPoint2D(i),s>0){Lo(h.slice(s-3))}}}return o}}return fm(!0,t,i,r,o,h,m)}if(l===n.enumBezier2){const t=e,s=x(f,3);t.queryControlPoints(s);const n=new da;return n.constructFromQuadratic(s),am(n,i,r,o,a,h,m)}t("")}function hm(e,s,i,r,o,a,h,m){a.length=0,h.length=0;const u=e.getGeometryType();if(u===n.enumLine)return a.push(e.getStartXY()),a.push(f.getNAN()),a.push(e.getEndXY()),h.push(0),h.push(1),1;if(u===n.enumBezier2){const t=[];t.length=9;let s=e.getMonotonicPartParams(t.length,t);t.length=s,s=lm(e,i,t),h.splice(0,0,...t.slice(0,s));{const i=new ol;for(let n=1;n<s;n++){const s=t[n-1],r=t[n];e.queryCut(s,r,i,!0);const o=i.get();Ro(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getEndXY())}}return s-1}if(u===n.enumEllipticArc){const t=e;if(t.isDegenerateToLine()||t.isDegenerate(0))return a.push(e.getStartXY()),a.push(f.getNAN()),a.push(e.getEndXY()),h.push(0),h.push(1),1;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n);let o=0;if(r>2){const e=new ol,m=h;for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=m.length;o+=xm(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1],p=e.get().getSweepAngle()/t.getSweepAngle();for(let e=d,s=m.length;e<s;e++){m[e]=!g||e+1<s?_+m[e]*p:1;{const s=2*e,i=t.getCoord2D(m[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}}return o}}return _m(!0,t,s,i,r,a,h)}if(u===n.enumBezier){const t=e;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n);let o=0;if(r>2){const e=new ol,m=h;for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=m.length;o+=ym(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1];for(let e=d,s=m.length;e<s;e++){m[e]=!g||e+1<s?_+m[e]:1;{const s=2*e,i=t.getCoord2D(m[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}}return o}}return ym(!0,t,s,i,r,a,h)}if(u===n.enumRationalBezier2){const t=e;if(!t.isMonotoneQuickAndDirty()){const n=[];n.length=6;let r=t.getMonotonicPartParams(n.length,n);n.length=r,r=lm(e,i,n);let o=0;if(r>2){const e=new ol,m=h;for(let u=1;u<r;u++){const l=n[u-1],c=n[u];t.queryCut(l,c,e,!0);const d=m.length;o+=pm(1===u,e.get(),s,i,!1,a,h);const g=u===r-1,_=n[u-1];for(let e=d,s=m.length;e<s;e++){m[e]=!g||e+1<s?_+m[e]:1;{const s=2*e,i=t.getCoord2D(m[e]);if(a[s].setCoordsPoint2D(i),s>0){Lo(a.slice(s-2))}}}}return o}}return pm(!0,t,s,i,r,a,h)}t("")}function mm(t,e,i,r,o,a,h,m,u){const l=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),l===n.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(f.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=q(9,Number.NaN);let d;if(o)d=t.getMonotonicPartParams(c.length,c),c.length=d,d=lm(t,i,c);else{if(d=2,c[0]=0,c[1]=1,l===$h.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,d=4):(c[0]=0,c[1]=.5,c[2]=1,d=3)}}else s(l===mn.type);c.length=d}if(2===d&&r&&(c[1]=.5,c.push(1),d=3),a){const e=new ol;let s=1;for(;s<d;){const i=c[s-1],r=c[s];t.queryCut(i,r,e,!0);const m=x(f,3),u=[1,1,1];if(l===n.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(r-i)/3;c.splice(s,0,i+t),c.splice(s+1,0,i+2*t),d+=2;continue}u[1]=ou(t,m)}else{const t=e.get();t.queryControlPoints(m),t.queryWeights(u)}o&&Mr(m),1===s&&(a.push(m[0].clone()),h.push(u[0])),a.push(m[1].clone()),a.push(m[2].clone()),h.push(u[1]),h.push(u[2]),s++}}return m&&(m.length=d,A(m,c,0,0,d)),d-1}nm.type=n.enumPolygon;class um{static constructDefault(t){return new um(0,0,0,t,!1,w())}constructor(t,e,s,i,n,r){this.m_segmentBuffer=null,this.m_dummyPoint=new hs,this.m_progressCounter=0,this.m_progressTracker=i,this.m_bSetDensifyFlag=n,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>at()?at():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=r,c(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,i,n,r){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=i>at()?at():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=n,this.m_maxSegmentsPerCurve=r,c(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return _(e)?t:d(e)?this.densifyMultiPath(t):m(e)?this.densifySegmentImpl(t):e===n.enumEnvelope?this.densifyEnvelope(t):void a("")}densifySegmentEx(t,e,s,i,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==n.enumLine)&&(!i||s))return void(e?o===n.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===n.enumBezier)return void this.densifyCubicBezier(t,e,s,i,r);if(o===n.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,i,r);if(o===n.enumBezier2)return void this.densifyBezier2(t,e,s,i,r);if(o===n.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,i,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,i,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();if(e.getGeometryType()===n.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new Rh({vd:t.getDescription()}),s=[0];return this.densifySegmentEx(t,e,!0,!1,s),e}densifyEnvelope(t){const e=new nm({vd:t.getDescription()});e.addEnvelope(t,!1);const s=qt.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();if(e.getGeometryType()===n.enumPolygon){e.setFillRule(t.getFillRule())}e.reserve(t.getPointCount());const s=e.getImpl(),i=t.getImpl(),r=i.getAttributeStreamRef(0),o=new rl;for(let n=0,a=i.getPathCount();n<a;n++){const t=i.isClosedPath(n);if(0===i.getPathSize(n))continue;const a=i.getPathStart(n),h=r.readPoint2D(2*a),m=h.clone();s.startPath(h);for(let u=a+1,l=i.getPathEnd(n);u<l;u++){const t=r.readPoint2D(2*u),i=f.distance(m,t);if(i>this.m_maxLength){let e=Math.ceil(i/this.m_maxLength);e>w()&&(e=w());const n=1/e;let r,a,h;m.compare(t)<0?(o.setStartXY(m),o.setEndXY(t),r=0,a=1):(o.setStartXY(t),o.setEndXY(m),r=e-2,a=-1);for(let t=0,i=e-1;t<i;t++,r+=a){this.progress_(),h=n*(r+1);const t=new f;o.queryCoord2D(h,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),m.assign(t)}if(t){const t=f.distance(m,h);if(t>this.m_maxLength){const e=h;let i=Math.ceil(t/this.m_maxLength);i>w()&&(i=w());const n=1/i;let r,a;m.compare(e)<0?(o.setStartXY(m),o.setEndXY(e),r=0,a=1):(o.setStartXY(e),o.setEndXY(m),r=i-2,a=-1);const u=new f(0,0);let l;for(let t=0,h=i-1;t<h;t++,r+=a)this.progress_(),l=n*(r+1),o.queryCoord2D(l,u),s.lineTo(u),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(e,i,r,o,a,h){s(e.getGeometryType()!==n.enumBezier);let m=e.getStartXY().compare(e.getEndXY());if(0===m&&i<1){e.getGeometryType()===n.enumEllipticArc?m=e.getSweepAngle()<0?1:-1:t("densify segment by length")}let u=0;if(o&&(r?(e.queryStart(this.m_dummyPoint),r.startPathPoint(this.m_dummyPoint)):h.push(0),++u),i*this.m_maxSegmentsPerCurve<1&&(i=1/this.m_maxSegmentsPerCurve),i<1){this.m_segmentBuffer||(this.m_segmentBuffer=new ol);let t=Math.ceil(1/i);t>w()&&(t=w()),i=1/t,this.m_segmentBuffer.create(e.getGeometryType());let s,n,o,a=e;m<0?(s=0,n=1):(e.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),s=t-2,n=-1,a=this.m_segmentBuffer.get());const l=t-1;for(let e=0;e<l;e++,s+=n)o=i*(s+1),r?(a.queryCoord(o,this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==o&&0!==o&&r.setAttribute(10,r.getPointCount()-1,0,1)):h.push(m>0?1-o:o),this.progress_();o=1,u+=l}(!a||a&&o&&u<2)&&(r?(e.queryEnd(this.m_dummyPoint),r.lineToPoint(this.m_dummyPoint)):h.push(1))}densifyCubicBezier(t,e,s,i,n){const r=new da;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());if(0===h&&a>0){const e=x(f,4);t.queryControlPoints(e),h=e[1].compare(e[2]),0===h&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=[],l=[],c=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let d=!0,g=0;if(h>0)for(u.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new f(0,1)]),l.push(0);u.length;){this.progress_();const t=u.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){d&&(g=o.findMinDeriv(),d=!1);let e=.5*(a+h);Math.abs(g-e)<.4*(h-a)&&(e=g);const s=(e-a)/(h-a),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),m=t[2].mul(1-s).add(t[3].mul(s)),c=i.mul(1-s).add(n.mul(s)),_=n.mul(1-s).add(m.mul(s)),p=c.mul(1-s).add(_.mul(s)),x=t[3];t[1]=i,t[2]=c,t[3]=p,t[4].setCoords(a,e);const y=[p,_,m,x,new f(e,h)];u.push(y),l[l.length-1]=r+1,l.push(r+1)}else u.pop(),l.pop(),(u.length>0||!i||i&&s&&m<2)&&(e?(o.queryCoord(a,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==a&&0!==a&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(1-a),++m)}else for(u.push([o.getStartXY(),o.getControlPoint1(),o.getControlPoint2(),o.getEndXY(),new f(0,1)]),l.push(0);u.length;){this.progress_();const t=u.at(-1),r=l.at(-1),a=t[4].x,h=t[4].y;if(r<c&&this.bezierNeedsSplit(t)){d&&(g=o.findMinDeriv(),d=!1);let e=.5*(a+h);Math.abs(g-e)<.4*(h-a)&&(e=g);const s=(e-a)/(h-a),i=t[0].mul(1-s).add(t[1].mul(s)),n=t[1].mul(1-s).add(t[2].mul(s)),m=t[2].mul(1-s).add(t[3].mul(s)),c=i.mul(1-s).add(n.mul(s)),_=n.mul(1-s).add(m.mul(s)),p=c.mul(1-s).add(_.mul(s)),x=t[0];t[0]=p,t[1]=_,t[2]=m,t[4].setCoords(e,h);const y=[x,i,c,p,new f(a,e)];u.push(y),l[l.length-1]=r+1,l.push(r+1)}else u.pop(),l.pop(),(u.length>0||!i||i&&s&&m<2)&&(e?(o.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h),++m)}}densifyRationalBezier2(t,e,s,i,n){const r=new mn;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new mn,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.rationalBezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}densifyBezier2(t,e,s,i,n){const r=new an;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=0),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),l=new an,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.bezier2NeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}densifyEllipticArc(t,e,s,i,n){const r=new $h;let o=t;const a=t.calculateUpperLength2D();let h=t.getStartXY().compare(t.getEndXY());0===h&&a>0&&(h=t.isClockwise()?0:1),h>0&&(t.copyTo(r),r.reverse(),o=r);let m=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):n.push(0),++m);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),l=new $h,c=[],d=[];for(c.push(new D(0,1)),d.push(0);c.length;){this.progress_();const t=c.at(-1).clone(),r=d.at(-1);if(r<u&&this.ellipticArcNeedsSplit(o,l,t.vmin,t.vmax)){const e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new D(e,t.vmax))):(c.at(-1).vmin=e,c.push(new D(t.vmin,e))),d[d.length-1]=r+1,d.push(r+1)}else if(c.pop(),d.pop(),c.length>0||!i||i&&s&&m<2){const s=h>0?t.vmin:t.vmax;e?(o.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):n.push(h>0?1-s:s),++m}}}calculateLengthSubdivisionStep(e,s){const i=e.calculateUpperLength2D();if(!e.isCurve())return i?s/i:1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;if(t.isCircular()||t.isDegenerate(0)||t.isDegenerateToLine()){let t=s/i;return t<this.m_minStep&&(t=this.m_minStep),t}return s/i*t.getSemiAxes().y/t.getSemiAxes().x}e.getGeometryType()===n.enumBezier&&t(""),t("")}calculateDeviationSubdivisionStep(e,s){if(!e.isCurve())return 1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;if(t.isDegenerate(0)||t.isDegenerateToLine())return 1;{const i=t.getSemiMajorAxis(),n=1-s/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(s/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(e,o)}}t("")}calculateAngularSubdivisionStep(e,s){if(!e.isCurve())return 1;if(e.getGeometryType()===n.enumEllipticArc){const t=e;return t.isDegenerate(0)||t.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(e,s*t.getSemiMinorAxis())}t("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}const r=x(f,3);e.queryControlPoints(r);const o=[0,0,0];return e.queryWeights(o),!n&&this.m_maxDeviation>0&&(n=!um.checkRationalBezier2MaxDeviation(r,o,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkRationalBezier2MaxAngle(r,o,this.m_cosMaxAngle)),n}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}const r=x(f,3);return e.queryControlPoints(r),!n&&this.m_maxDeviation>0&&(n=!um.checkBezier2MaxDeviation(r,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkBezier2MaxAngle(r,this.m_cosMaxAngle)),n}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;if(this.m_maxLength>0){if(e.calculateUpperLength2D()>this.m_maxLength)return n=!0,!0}return!n&&this.m_maxDeviation>0&&(n=!um.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!um.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n}bezierNeedsSplit(t){let e=!1;if(this.m_maxLength>0){if(f.distance(t[0],t[1])+f.distance(t[1],t[2])+f.distance(t[2],t[3])>this.m_maxLength)return e=!0,!0}return!e&&this.m_maxDeviation>0&&(e=!um.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!um.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1])),r=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(n),Math.abs(r))<=e){const e=new f;Ua(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),i=[0,0];if(1===yu(t,s,i)){const s=t.getCoord2D(i[0]),n=f.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),r=new f;Q(t.getStartXY(),t.getEndXY(),n,r);return f.distance(s,r)<=e}}const s=t.getCoord2D(.5),i=new f;Q(t.getEndXY(),t.getStartXY(),.5,i);return f.distance(s,i)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0)&&!(s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==n.enumEllipticArc||t.isCircular())}}function lm(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const r=[];r.length=i-1;for(let o=1,a=i;o<a;o++){const e=t.tToLength(s[o]);r[o-1]=e-n,n=e}for(;r.length>1;){const t=r.findIndex((t=>t<=2*e));if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===r.length||r[e]>r[n])&&(n=e,i--)}r[n]+=r[t],r.splice(t,1),s.splice(i,1)}return s.length}function cm(t,e,s,i,n){const r=[],o=[],a=am(e,s,0,i,!1,r,o),h=new da;let m=n;const u=e.getDescription();h.assignVertexDescription(u);const l=u.getAttributeCount()>1,c=new hs,d=new rl;for(let g=0,_=0;g<a;g++){if(r[_+1].isNAN()){if(l){let t=o[g];e.queryCoord(t,c),d.setStart(c),t=o[g+1],e.queryCoord(t,c),d.setEnd(c)}d.setStartXY(r[_]),d.setEndXY(r[_+3]),t.addSegment(d,m)}else{if(l){let t=o[g];e.queryCoord(t,c),h.setStart(c),t=o[g+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setControlPoint2(r[_+2]),h.setEndXY(r[_+3]),t.addSegment(h,m)}_+=3,m=!1}}function dm(t,e,s,i,n){const r=[],o=[],a=hm(e,s,0,i,!1,r,o),h=new an;let m=n;const u=e.getDescription();h.assignVertexDescription(u);const l=u.getAttributeCount()>1,c=new hs,d=new rl;for(let g=0,_=0;g<a;g++){if(r[_+1].isNAN()){if(l){let t=o[g];e.queryCoord(t,c),d.setStart(c),t=o[g+1],e.queryCoord(t,c),d.setEnd(c)}d.setStartXY(r[_]),d.setEndXY(r[_+2]),t.addSegment(d,m)}else{if(l){let t=o[g];e.queryCoord(t,c),h.setStart(c),t=o[g+1],e.queryCoord(t,c),h.setEnd(c)}h.setStartXY(r[_]),h.setControlPoint1(r[_+1]),h.setEndXY(r[_+2]),t.addSegment(h,m)}_+=2,m=!1}}function gm(t,e,i,r,o){s(t===n.enumBezier||t===n.enumEllipticArc||t===n.enumBezier2);const h=e.createInstance();h.getGeometryType()===n.enumPolygon&&h.setFillRule(e.getFillRule());const m=e.querySegmentIterator();for(let u=0,l=e.getPathCount();u<l;++u){if(!e.hasNonLinearSegmentsPath(u)){h.addPath(e,u,!0);continue}const o=e.getPathStart(u);let l=!0,c=0;for(m.resetToPath(u),s(m.nextPath());m.hasNextSegment();){const s=m.nextCurve();if(!s)break;{const d=m.getStartPointIndex()-o,g=d-c;g>0&&(h.addSegmentsFromPath(e,u,c,g,l),l=!1),c=d+1,t===n.enumBezier?cm(h,s,i,r,l):t===n.enumBezier2?dm(h,s,i,r,l):a(""),l=!1}}const d=e.getSegmentCountPath(u);d-c!=0&&h.addSegmentsFromPath(e,u,c,d-c,l)}return h}function _m(t,e,s,i,n,r,o,a){const h=e.clone();h.dropAllAttributes();const m=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(f.getNAN()),e.push(f.getNAN()),e.push(i.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(h.isDegenerateToLine()||h.isDegenerate(0))return m(t,r,o,e);const u=h.getStartXY(),l=h.getEndXY(),c=h.getSemiAxes(),d=new k;if(h.isCircular())d.setIdentity();else{const t=h.getAxisXRotation();d.setScaleCoords(1,h.getMinorMajorRatio()),d.rotateAngle(t)}const g=h.getCenter();d.shift(g);const _=d.clone();_.invertThis(),h.applyTransformation(_);const p=h.getSweepAngle();if(0===p)return m(t,r,o,e);const y=qt.constructEmpty();y.setCoords({center:g,width:2*c.x,height:2*c.x});const P=.05*y.calculateToleranceFromEnvelope(),v=Math.max(s/c.x,P/c.x);let C=4*Math.pow(v/.0741,1/6);C=Math.min(C,Math.PI/2);const b=Uh(h.getStartAngle());let E=p>0?Math.floor(b/C):Math.ceil(b/C);E*=C;const D=p>0?C:-C;E+D===b&&(E+=D);let S=4/3*Math.tan(Math.abs(C)/4);p>0&&(S=-S),o&&t&&o.push(0);const w=C/Math.abs(p);let A=(E-b)/p;const T=u.clone(),I=new f;h.queryCoord2D(0,I);const N=I.clone(),q=1-.01*w;let M=0,Y=0;for(;A<1;){let s;if(A+=w,Y>0&&A<q)s=S;else{A>=q&&(A=1);const t=(A-Y)*p;s=4/3*Math.tan(Math.abs(t)/4),p>0&&(s=-s)}h.queryCoord2D(A,I);const a=new f;d.queryTransform(I,a);const m=e.getClosestCoordinate(a,!1);if(e.queryCoord2D(m,a),1!==A&&(f.distance(T,a)<=2*i||f.distance(a,l)<=2*i))continue;T.setCoordsPoint2D(a);const c=x(f,4);c[0].assign(N),c[3].assign(I),c[1].rightPerpendicularOther(N),c[1].scaleAddThis(s,N),c[2].leftPerpendicularOther(I),c[2].scaleAddThis(s,I),d.transformPoints2D(c,3,c),c[3].assign(a),0===Y&&c[0].setCoordsPoint2D(u),1===A&&c[3].setCoordsPoint2D(l),n&&Ga(c);let g=!0;for(let t=1;t<4;t++)if(!c[t].isEqualPoint2D(c[0])){g=!1;break}g||(o&&o.push(m),r&&(0===Y&&t&&r.push(c[0].clone()),r.push(c[1].clone()),r.push(c[2].clone()),r.push(c[3].clone())),M++),Y=A,N.setCoordsPoint2D(I)}return M}function pm(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);t&&o.push(0);let l=0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[],_=q(9,Number.NaN);let p=e.getMonotonicPartParams(_.length,_);_.length=p,p=lm(e,i,_);let y=0,P=t;for(let v=1;v<p;v++){const t=_[v];for(g.push(y),g.push(t);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=x(f,3);Fr(c,d,t,e,s,[0,0,0]);const i=x(f,3),n=aa(s,d,i),a=16,h=g.length>a;u>=n||h?(o.push(e),P&&(r.push(i[0]),P=!1),r.push(i[1]),r.push(i[2]),l++):(g.push(.5*(t+e)),g.push(t))}y=t}return l}function fm(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);o&&t&&o.push(0);let l=0;const c=x(f,3);e.queryControlPoints(c);const d=[0,0,0];e.queryWeights(d);const g=[],_=q(9,Number.NaN);let p=0;n?(p=e.getMonotonicPartParams(_.length,_),_.length=p,p=lm(e,i,_)):(_.length=2,p=2,_[0]=0,_[1]=1);let y=0,P=t;for(let v=1;v<p;v++){const t=_[v];for(g.length=0,g.push(t),g.push(y);g.length>1;){const t=g.at(-1);g.pop();const e=g.at(-1),s=x(f,3),i=[0,0,0];Fr(c,d,t,e,s,i);const n=x(f,4),a=Rr(s,i,n),h=16,m=g.length>h;u>=a||m?(o.push(e),r&&(P&&(r.push(n[0]),P=!1),r.push(n[1]),r.push(n[2]),r.push(n[3])),l++):(g.push(.5*(t+e)),g.push(t))}y=t}return l}function xm(t,e,s,i,n,r,o,a){const h=e.clone();if(h.dropAllAttributes(),h.isDegenerateToLine()||0===h.getSweepAngle())return t&&r.push(e.getStartXY()),r.push(f.getNAN()),r.push(e.getEndXY()),t&&o.push(0),o.push(1),1;const m=h.getStartXY(),u=h.getEndXY(),l=h.getSemiAxes(),c=new k;if(h.isCircular())c.setIdentity();else{const t=h.getAxisXRotation();c.setScaleCoords(1,h.getMinorMajorRatio()),c.rotateAngle(t)}const d=h.getCenter();c.shift(d);const g=c.clone();g.invertThis(),h.applyTransformation(g);const _=qt.constructEmpty();_.setCoords({center:d,width:2*l.x,height:2*l.x});const p=.05*_.calculateToleranceFromEnvelope(),y=Math.max(s/l.x,p/l.x),P=Math.sqrt(2*y+y*y);let v=2*Math.sqrt(2*P*(1+y-P));v=Math.min(v,Math.PI/2);const C=h.getSweepAngle(),b=Math.ceil(Math.abs(C)/v),E=Math.max(b,1);v=C/E;const D=1/E;let S=Math.tan(Math.abs(v)/2);C>0&&(S=-S),t&&o.push(0);const w=new f;h.queryCoord2D(0,w);for(let A=0;A<E;A++){const e=w.clone(),s=(A+1)*D;if(o.push(s),!r)continue;h.queryCoord2D(s,w);const i=x(f,3);i[0].assign(e),i[2].assign(w),i[1].rightPerpendicularOther(i[0]),i[1].mulThis(S),i[1].addThis(i[0]),c.transformPoints2D(i,3,i),0===A&&i[0].setCoordsPoint2D(m),A===E-1&&i[2].setCoordsPoint2D(u),0===A&&t&&r.push(i[0]),r.push(i[1]),r.push(i[2])}return E}function ym(t,e,s,i,n,r,o,a){e.clone().dropAllAttributes();const h=new qt;e.queryLooseEnvelope(h);const m=.05*h.calculateToleranceFromEnvelope(),u=Math.max(s,m);t&&o.push(0);let l=0;const c=x(f,4);e.queryControlPoints(c);const d=[],g=q(9,Number.NaN);let _=e.getMonotonicPartParams(g.length,g);g.length=_,_=lm(e,i,g);let p=0,y=t;for(let P=1;P<_;P++){const t=g[P];for(d.push(p),d.push(t);d.length>1;){const t=d.at(-1);d.pop();const e=d.at(-1),s=x(f,4);Za(c,t,e,s);const i=x(f,3),n=oa(s,i),a=16,h=d.length>a;u>=n||h?(o.push(e),y&&(r.push(i[0]),y=!1),r.push(i[1]),r.push(i[2]),l++):(d.push(.5*(t+e)),d.push(t))}p=t}return l}function Pm(){return{e2:0,completeE:0}}class vm{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?f.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function Cm(t,e,s){if(Gm(t)){gi(new rl({start:t.getStartXY(),end:t.getEndXY()}),e,s)}else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new V;qm(t,e,i);const n=new V,r=new V;V.st_cosAndSin(i,n,r);const o=Ns.constructCoordsE(new V(t.m_semiMajorAxis).mulThisE(n),new V(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(r)),a=new V(t.m_rotation);V.st_cosAndSin(a,n,r),o.rotateDirect(n,r),o.addThisE(Ns.constructPoint2D(t.m_center)),s.setE(o)}}function bm(t,e){return t.convertToCanonic(e)}function Em(t,e){const s=new D(t.getStartAngle(),t.getEndAngle());s.normalize();const i=ht(),n=vt(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}function Dm(t,e,s,i){let n=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;n>nt();)n-=2*nt();for(;n<=-nt();)n+=2*nt();if(!Number.isNaN(e)){for(;e>nt();)e-=2*nt();for(;e<=-nt();)e+=2*nt();!s&&e>n&&(e-=2*nt()),s&&e<n&&(e+=2*nt()),r=e-n,Math.abs(r)<o&&!i&&(r=s?2*nt():-2*nt()),Math.abs(r)>2*nt()-o&&i&&(r=0)}Math.abs(r)>2*nt()-o&&(r=r>=0?2*nt():-2*nt(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),i=Math.abs(r)<=nt(),r&&(s=r>0),t.m_startAngle=Sm(n),t.m_sweepAngle=r,tu(t,!i),$m(t,s)}function Sm(t){let e=t,s=!1;return e<=-nt()?(e+=ht(),s=!0):e>nt()&&(e-=ht(),s=!0),e<=-nt()?(e=vt(e,ht()),e<=-nt()&&(e+=ht()),s=!0):e>nt()&&(e=vt(e,ht()),e>nt()&&(e-=ht()),s=!0),s&&(e>nt()||e<=-nt())&&(e=nt()),e}function wm(t,e,s){const i=s,n=i.getSemiAxes();let r=new f(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return r=i.convertFromCanonic(r),f.sqrDistance(r,i.getStartXY())}function Am(t,e,s){const i=s,n=i.getSemiAxes(),r=t[0]+i.getStartAngle();let o=new f(n.x*Math.cos(r),n.y*Math.sin(r));return o=i.convertFromCanonic(o),f.sqrDistance(o,i.getEndXY())}function Tm(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=eu(t),r=Jm(t),o=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Sm(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?r?ht():-ht():0}else{const i=t.convertToCanonic(e),a=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=a.x,i.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=f.calculateAngle(i,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=ht()):t.m_sweepAngle>0&&(t.m_sweepAngle-=ht()),t.m_startAngle=Sm(t.m_startAngle);let m=wm([t.m_startAngle],1,t);if(m=Math.sqrt(m),m>.25*ti(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Vi(wm,t,1,[t.m_startAngle],[e],[s],1e-14,i),t.m_startAngle=Sm(i[0])}if(m=Am([t.m_sweepAngle],1,t),m=Math.sqrt(m),m>.25*ti(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Vi(Am,t,1,[t.m_sweepAngle],[e],[s],1e-14,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>nt();if(tu(t,u),n!==u&&!n&&Math.abs(t.m_sweepAngle)>1.5*nt())return void km(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void km(t,e,s,o)}}function Im(t,e){return(Em(t,e)-t.getStartAngle())/t.getSweepAngle()}function Nm(t,e){return t.m_startAngle+e*t.m_sweepAngle}function qm(t,e,s){s.assign(new V(t.m_startAngle).addE(e.mulE(new V(t.m_sweepAngle))))}function Mm(t,e){const s=new V(t.m_cosr).sqrThis(),i=new V(t.m_sinr).sqrThis(),n=new V(t.m_minorMajorRatio),r=new V(1/t.m_minorMajorRatio),o=n.mulE(s).addThisE(r.mulE(i)),a=n.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=n.mulE(i).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new V(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function Ym(t,e){const s=new qs;s.a11.setE(t[0]),s.a12=V.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[f.getNAN(),f.getNAN()],n=[new V,new V];s.eigenSymmetric(n,i);const r=t[3].clone();r.negateThis(),r.invThis(),n[0].mulThisE(r),n[1].mulThisE(r),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble();return Math.atan2(i[0].y,i[0].x)}function Xm(t,e,s){if(Gm(t))return(s-e)*f.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const i=Hm(t,e);return Hm(t,s)-i}function Fm(t){return t.m_cachedValues}function Rm(t){if(t.m_cachedValues)return t.m_cachedValues;const e=Pm();return e.e2=Vm(t),e.completeE=Ct(e.e2),t.m_cachedValues=e,e}function Lm(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(Gm(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,cu(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*at()){const i=x(f,3),n=ou(t,i);if(Nr(i)){i[0].assign(e),i[2].assign(s),Mr(i);if(0===t.projectionBehavior()){let e=0,s=2;f.sqrDistance(i[1],i[0])<f.sqrDistance(i[1],i[2])&&(s=S(e,e=s));const n=i[s].sub(i[e]),r=n.length();n.divThis(r);const o=i[1].sub(i[e]),a=o.length(),h=o.dotProduct(n)/a,m=o.crossProduct(n)/a,u=new f;Q(i[e],i[s],.5,u);const l=.5*r/m*y(1-h,0,1),c=i[1].side(i[e],i[s]),d=n.clone();c?d.leftPerpendicularThis():d.rightPerpendicularThis();const g=u.sub(d.mul(l));t.constructCircularArcThreePoint(i[0],i[2],g)}else au(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?Cu(t,e,s):bu(t,e,s)}}function zm(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void km(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new f;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const m=new Array(4);m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];const u=Math.trunc(s<5?1:(s+4)/5),l=x($h,4),c=new Array(4);let d=0;for(let g=0;g<4;g++){l[g].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,r,o,h[g],m[g],a),c[g]=0;let t=0;for(let i=u;i<s-1;i+=u){const s=l[g].getClosestCoordinate(e[i],!1);c[g]+=f.sqrDistance(l[g].getCoord2D(s),e[i]),t++}c[g]/=t,c[g]<c[d]&&(d=g)}t.assignCopy(l[d])}function Vm(t){return 1-C(t.m_minorMajorRatio)}function Bm(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,Vs(t,e),ks(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),tu(t,o),$m(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,ru(t,void 0===h)}function km(t,e,s,i){t.m_bits=0,t.m_rotation=0,Vs(t,e),ks(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,tu(t,!1),$m(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function Gm(t){return t.m_center.isNAN()}function Hm(t,e){if(0===e)return 0;const s=Rm(t),i=Nm(t,e),n=at(),r=jm(t),o=mt(i+n,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function Wm(t,e){if(Gm(t)){const s=f.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=Rm(t),n=at(),r=jm(t);s<0&&(e=-e);const o=e/t.m_semiMajorAxis+r;let a=ut(o,i.e2,i.completeE);a-=n,a-=t.getStartAngle();return a/s}function jm(t){const e=Rm(t);return mt(t.getStartAngle()+at(),e.e2,e.completeE)}function Zm(t,e,i){if(2===e.m_TransformationType)return void s(0);if(s(!iu(t)),e.isIdentity())return;Qm(t);const n=f.getNAN();n.x=t.m_XStart,n.y=t.m_YStart,e.transformInPlace(n);const r=f.getNAN();if(r.x=t.m_XEnd,r.y=t.m_YEnd,e.transformInPlace(r),Gm(t))return t.m_XStart=n.x,t.m_YStart=n.y,t.m_XEnd=r.x,void(t.m_YEnd=r.y);const o=t.m_center.clone();if(e.transformInPlace(o),i||e.isUniformNoRotation()){let s=Jm(t);e.isReflective()&&(s=!s);if(0===t.projectionBehavior()){if(!n.equals(r)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(n,r,s)}return void Um(t,n,r,o,s,!1)}const i=new f(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const a=Math.atan2(i.y,i.x),h=t.getSemiAxes();e.transformWithoutTranslateInPlace(h);const m=t.m_center.clone();return e.transformInPlace(m),void t.constructEllipticArcEndPointsCenter(n,r,h.x,h.y/h.x,a,t.isMajor(),s,m)}{{const s=new Array(4);Mm(t,s);const i=new qs;i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]);if(!i.det().isZero()){const a=new qs;if(a.a11.set(e.xx),a.a12.set(e.xy),a.a21.set(e.yx),a.a22.set(e.yy),a.invertThis()){const h=a.clone();h.transposeThis();const m=i.clone();m.mulThis(a),m.mulLeftThis(h);if(!m.det().isZero()){const i=x(V,4);i[0].setE(m.a11),i[1].setE(m.a12),i[1].mulThisByPower2(2),i[2].setE(m.a22),i[3].setE(s[3]);const a=f.getNAN(),h=Ym(i,a);let u=Jm(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(n,r,a.x,a.y/a.x,h,t.isMajor(),u,o)}}}}const s=[f.getNAN(),f.getNAN(),f.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let i=t.isClockwise();i&&(s[2]=S(s[0],s[0]=s[2]));const a=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const h=new f(0,0),m=t.createInstance();au(s,a,h,!1,m),t.constructEllipticArcEndPointsCenter(n,r,m.getSemiMajorAxis(),m.getMinorMajorRatio(),m.getAxisXRotation(),t.isMajor(),!i,o)}}function Um(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);Dm(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function Om(t,e){t.m_cachedValues=e}function Qm(t){t.m_cachedValues=null}function Km(t,e){e.m_cachedValues=S(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}function $m(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function Jm(t){return!!(1&t.m_bits)}function tu(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function eu(t){return!!(2&t.m_bits)}function su(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ns;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ns).setWithEps(t.m_center,e));const i=new V;i.setWithEps(t.m_rotation,e);const n=new V,r=new V;V.st_cosAndSin(i,n,r),s.rotateReverse(n,r);const o=new Ns;o.setWithEps(t.getEndXY()),o.subThisE(Ns.constructPoint2D(t.m_center)),o.rotateReverse(n,r);const a=new V;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),m=new V;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=s.x.sqr().addThisE(s.y.sqr()).subThisE(dt),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(dt);return!u.isZero()||!l.isZero()}function iu(t){return!!(8&t.m_bits)}function nu(t){t.m_bits&=-9}function ru(t,e){nu(t);const s=t.getStartXY(),i=t.getEndXY();let n=!1;const r=eu(t),o=Jm(t),a=t.projectionBehavior(),h=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:g("NAN minor major ratio and non-zero major axis")),m||=e?h:t.m_center.isNAN(),m)return km(t,s,i,a),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const u=new f(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(h){const e=t.convertToCanonic(s);e.x/=u.x,e.y/=u.y;const i=Math.sqrt(C(e.x)+C(e.y));if(n=1!==i,t.m_semiMajorAxis*=i,u.mulThis(i),t.m_startAngle=Sm(Math.atan2(e.y,e.x)),!r)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),n;t.m_sweepAngle=o?ht():-ht()}else{let e=t.m_center.isNAN()||su(t);if(!e){const n=t.convertToCanonic(s);n.x/=u.x,n.y/=u.y;const r=new f(1,0);t.m_startAngle=f.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=u.x,o.y/=u.y,t.m_sweepAngle=f.calculateAngle(n,o),e=!mu(t)}if(e){n=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let a=C(e.x/u.x)+C(e.y/u.y);a>1&&(a=Math.sqrt(a),t.m_semiMajorAxis*=a,u.mulThis(a));const h=new f(0,0);{const t=u.x*u.x,s=u.y*u.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);h.setCoords(u.x*e.y/u.y,-u.y*e.x/u.x),h.mulThis(t),r===o&&h.negateThis()}}{const e=new f(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(Tm(t),!mu(t))return km(t,s,i,a),!0}return cu(t),t.afterCompletedModification(),n}function ou(t,e){s(Math.abs(t.getSweepAngle())<15*Math.PI/16);const i=t.getSemiMajorAxis(),n=t.getSemiMinorAxis();let r;if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),r=1,r;if(0===n)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=f.lerp(e[0],e[2],.5),r=1,r;const o=t.getSweepAngle(),a=t.getStartAngle(),h=a+o,m=new f(-i*Math.sin(a),n*Math.cos(a)),u=new f(-i*Math.sin(h),n*Math.cos(h));m.normalize(),u.normalize(),m.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const l=m.crossProduct(u);e[1].assign(m.mul(e[1].crossProduct(u)/l)),e[1].addThis(e[0]);return r=Math.cos(.5*o),r}function au(t,e,i,n,r){if(n){const s=.5,i=Math.sqrt(e),n=C(1-s)+2*i*s*(1-s)+C(s),o=t[0].mul(C(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul(C(s))).divThis(n);return r.constructCircularArcThreePoint(t[0],t[2],o),!0}const o=t[0].sub(t[1]),a=t[2].sub(t[1]),h=o.crossProduct(a),m=o.dotProduct(a),u=e;s(u<=1),s(u>0);const l=.5/(1-u),c=o.sqrLength(),d=m,g=a.sqrLength(),_=C(h),p=o.sub(a).sqrLength();if(0===_)return km(r,t[0],t[2],1),!1;if(m<=-Math.sqrt(c)*Math.sqrt(g))return km(r,t[0],t[2],1),!1;const f=[0,0],x=new D;x.setInfinite();const y=Li(2*_,-(p/u+4*d),2*(1-u)/u,x,!1,f);if(0===y)return km(r,t[0],t[2],1),!1;1===y&&(f[1]=f[0]);const P=Math.sqrt(l/f[0]),v=Math.sqrt(l/f[1]),b=.5/u;let E=b-g*f[0],S=b-c*f[0];Math.abs(E)>Math.abs(S)?S=d*f[0]-b+1:E=d*f[0]-b+1;const w=o.mul(E).add(a.mul(S)),A=w.norm(1)<1e-15*P?0:Math.atan2(w.y,w.x)+Math.PI,T=o.add(a),I=i?i.clone():t[1].add(T.mul(l)),N=t[0].sub(I),q=t[2].sub(I),M=N.crossProduct(q)<0,Y=!1;new $h;return r.constructEllipticArcEndPointsCenter(t[0],t[2],P,v/P,A,Y,!M,I)}function hu(t,e,s,i,n){return au(t,e,s,i,n)}function mu(t){let e=!1;{const s=new f(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);e=f.distance(t.getStartXY(),s)>ti(t)}let s=!1;if(!e){const e=new f(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center);s=f.distance(t.getEndXY(),e)>ti(t)}return!e&&!s}function uu(t,s,i,n){0===i&&e("construct_enclosing_circle");const r=[0,0,0],o=tm(s,i,r);if(1===o)t.constructCircleRadius(0,s[r[0]],n);else if(2===o){const e=f.lerp(s[r[0]],s[r[1]],.5),i=f.distance(s[r[0]],e),o=f.distance(s[r[1]],e);t.constructCircleRadius(Math.max(i,o),e,n)}else if(3===o){const e=f.calculateCircleCenterFromThreePoints(s[r[0]],s[r[1]],s[r[2]]),i=f.distance(s[r[0]],e),o=f.distance(s[r[1]],e),a=f.distance(s[r[2]],e);t.constructCircleRadius(Math.max(i,o,a),e,n)}else a("unexpected")}function lu(t){if(Gm(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,u=0;t.m_rotation&&(m=(a-h)*(a+h),u=2*a*h);const l=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;if(t.m_rotation){c=.125*(-2*Math.sin(r+n)*Math.sin(r-n))*u-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h}return i*(l+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function cu(t){t.queryCoord2D(.5,t.m_interior)}function du(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==_u(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function gu(t,e,s,i,n){if(n){if(0!==Qu(e,s))return 2}else if(Ys(e,s))return 1;return 0!==pu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function _u(t,e,i,n,r,o,a,h,m,u){if(Gm(e)){return yi(new rl({start:e.getStartXY(),end:e.getEndXY()}),i,n,r,o,a,h,u)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0);const l=ei(e,i);if(si(e,i,a=Math.max(l,a)))return 0;const c=i.getStartXY();c.subThis(e.m_center);const d=i.getEndXY();d.subThis(e.m_center),c.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);const g=d.clone();g.subThis(c);const _=e.m_semiMajorAxis,p=1/_,x=e.getSemiMinorAxis(),y=1/x,P=g.clone();P.leftPerpendicularThis();const v=Math.atan2(x*P.y,_*P.x),C=new Array(16),b=new Array(16);let E=0;const S=[v,v+Math.PI];for(let s=0;s<2;++s){const t=Im(e,S[s]);if(t>=0&&t<=1){C[E]=t;const s=e.getCoord2D(C[E]);b[E]=i.getClosestCoordinate(s,!1),f.distance(s,i.getCoord2D(b[E]))<=a&&E++}}const w=c.x*p,A=c.y*y,T=g.x*p,I=g.y*y;let N=Li(T*T+I*I,2*(w*T+A*I),w*w+A*A-1,D.unit(),!1,b);s(N>=0);for(let s=0;s<N;s++){const t=g.mul(b[s]).add(c);t.x*=p,t.y*=y;const n=Im(e,Math.atan2(t.y,t.x));if(n>=0&&n<=1){C[E]=n;const t=e.getCoord2D(n);b[E]=i.getClosestCoordinate(t,!1),f.distance(t,i.getCoord2D(b[E]))<=a&&E++}}s(E<C.length+4);const q=new Array(16);N=e.intersectPoint(i.getStartXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=q[s],b[E]=0;N=e.intersectPoint(i.getEndXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=q[s],b[E]=1;N=i.intersectPoint(e.getStartXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=0,b[E]=q[s];N=i.intersectPoint(e.getEndXY(),q,a);for(let s=0;s<N;s++,E++)C[E]=1,b[E]=q[s];return 0===E?0:el(t,e,i,C,b,E,n,r,o,a,h,m,u)}function pu(t,e,i,n,r,o,a,h,m,u){if(Gm(e)){const s=new rl({start:e.getStartXY(),end:e.getEndXY()});return _u(t,i,s,n,o,r,a,h,m,!u)}if(Gm(i)){const s=new rl({start:i.getStartXY(),end:i.getEndXY()});return _u(t,e,s,n,r,o,a,h,m,u)}const l=ei(e,i);a=Math.max(a,l);let c=!1;{const t=e.getSemiAxes(),n=e.getCenter(),u=i.getSemiAxes(),l=i.getCenter(),d=f.distance(l,n),g=t.x+u.x;if(d>g+a)return 0;if(t.y>u.x){if(d+u.x+a<t.y)return 0}else if(u.y>t.x&&d+t.x+a<u.y)return 0;if(m&&!h){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),a=1===i.m_minorMajorRatio&&i.isClosed()&&i.isMajor();if(n&&a&&(c=!0,d<=g)){if(Math.max(t.x,u.x)<=Math.min(t.x,u.x)+d)return s(!r&&!o),1}}}if(!c&&si(e,i,a))return 0;const d=[],g=[],_=!1,p=!1,x=mm(e,0,0,_,p,d,g,null),y=[],P=[],v=mm(i,0,0,_,p,y,P,null);if(1===x&&1===v){const t=new mn({points:d,weights:g}),s=new mn({points:y,weights:P}),l=[],c=[],_=jr(!1,t,s,n,null===r?null:l,null===o?null:c,a,h,m,u);if(_>0&&null!==r||null!==o){r&&(r.length=0),o&&(o.length=0);for(let n=0;n<_;++n){if(r)if(G(l[n],0,1))r.push(l[n]);else{const s=t.tToLength(l[n]),i=e.lengthToT(s);r.push(i)}if(o)if(G(c[n],0,1))o.push(c[n]);else{const t=s.tToLength(c[n]),e=i.lengthToT(t);o.push(e)}}}return _}let C=[];const b=[];let E=0;const D=m&&!h;for(let s=0;s<x;s++){const t=new mn({points:d.slice(2*s,2*s+3),weights:g.slice(2*s,2*s+3)});let n=0;for(let r=0;r<v;r++){b.length<=r&&b.push(new mn({points:y.slice(2*r,2*r+3),weights:P.slice(2*r,2*r+3)}));const o=[],h=[],m=D?null:o,u=D?null:h,l=jr(!1,t,b[r],null,m,u,a,!1,D,!1);if(l>0&&D)return 1;for(let a=0;a<l;++a){if(0===o[a]&&0===s)o[a]=0;else if(1===o[a]&&s===x-1)o[a]=1;else{const s=t.tToLength(o[a])+E,i=e.lengthToT(s);o[a]=i}if(0===h[a]&&0===r)h[a]=0;else if(1===h[a]&&r===v-1)h[a]=1;else{const t=b[r].tToLength(h[a])+n,e=i.lengthToT(t);h[a]=e}C.push(xt(o[a],h[a]))}n+=b[r].calculateLength2D()}E+=t.calculateLength2D()}if(0===C.length)return 0;if(h&&(C=C.filter((t=>!G(t.first,0,1)||!G(t.second,0,1)||!e.getCoord2D(t.first).equals(i.getCoord2D(t.second))))),m)return C.length;const S=[],w=[];for(const s of C)S.push(s.first),w.push(s.second);return el(t,e,i,S,w,S.length,n,r,o,a,h,m,u)}function fu(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),Gm(t))return;const i=t.getSemiAxes(),n=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,r=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=r+Math.PI;n[0]=Im(t,e),n[1]=Im(t,s),n[2]=Im(t,r),n[3]=Im(t,o)}const r=new f;for(let o=0;o<4;o++){const i=n[o];e.containsExclusiveCoordinate(i)&&(t.queryCoord2D(i,r),s.mergeNe(r))}}function xu(t,e,i,n,r){if(0===t.m_semiMajorAxis)return i.vmin;let o=f.getNAN();t.queryCoord2D(i.vmin,o);let a=f.getNAN();if(t.queryCoord2D(i.vmax,a),Gm(t)){return new rl({start:o,end:a}).getClosestCoordinate(e,n)}const h=bm(t,e);if(o=bm(t,o),a=bm(t,a),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;const e=Im(t,Math.atan2(h.y,h.x));if(n||i.containsCoordinate(e))return e;return f.distance(h,o)<=f.distance(h,a)?i.vmin:i.vmax}const m=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),l=(m-u)*(m+u),c=C(l),d=h.x,g=h.y,_=C(u*g),p=u*l*g*2,y=[new V(_),new V(p),new V(c-C(m*d)-_),new V(-p),new V(-c)],P=x(V,4),v=Qi(y,4,new D(-1,1),!1,P,4);let b=i.vmin,E=f.sqrDistance(h,o);{const t=f.sqrDistance(h,a);t<E&&(b=i.vmax,E=t)}s(!n);let S=new Array(8);for(let s=0;s<v;++s){const e=P[s].value(),i=Math.sqrt(1-e*e),n=Math.atan2(e,i),r=Math.atan2(e,-i);S[2*s]=Im(t,n),S[2*s+1]=Im(t,r)}S=S.slice(0,2*v),lt(S);for(let s=0,x=2*v;s<x;++s)if(S[s]>i.vmin&&S[s]<i.vmax){const i=f.sqrDistance(e,t.getCoord2D(S[s]));E>i&&(E=i,b=S[s])}return b}function yu(t,e,i){s(!Gm(t));const n=new k;n.setRotateAngle(-t.getAxisXRotation());const r=new f;n.queryTransform(e,r);const o=Math.atan2(-r.x*t.getMinorMajorRatio(),r.y),a=o+nt();let h=Im(t,o),m=Im(t,a);m<h&&(m=S(h,h=m));let u=0;return h>=0&&h<=1&&(i[u++]=h),m>=0&&m<=1&&(i[u++]=m),u}function Pu(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&(t.isMajor()!==e.isMajor()&&(!!t.m_center.equals(e.m_center)&&(t.m_sinr===e.m_sinr&&(t.m_cosr===e.m_cosr&&(t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise()))))))}function vu(t,e,s){if(Gm(t))s.setE(Ns.constructPoint2D(t.getEndXY()).subE(Ns.constructPoint2D(t.getStartXY())));else{const i=new V;qm(t,e,i);const n=new Ns;if(n.setCoordsE(new V(t.m_semiMajorAxis).negate().mulE((new V).setSin(i)),new V(t.getSemiMinorAxis()).mulE((new V).setCos(i))),t.m_rotation){const e=new V(t.m_rotation);n.rotateDirect((new V).setCos(e),(new V).setSin(e))}n.scaleThis(new V(t.getSweepAngle())),s.setE(n)}}function Cu(t,e,s,i){const n=t.getStartXY(),r=t.getEndXY(),o=n.equals(r),a=e.equals(s);if(!o&&!a){const i=new k;i.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=f.distance(e,s),a=f.distance(n,r),h=o/a;i.scale(h,h);const m=r.sub(n);m.divThis(a);const u=s.sub(e);u.divThis(o);const l=m.crossProduct(u),c=u.dotProduct(m);return i.rotate(c,l),i.shiftCoords(e.x,e.y),Zm(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,void(t.m_YEnd=s.y)}const h=new f;if(t.queryCoord2D(.5,h),a){if(o){const i=t.m_center.add(e.sub(n));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),i),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const m=e.add(s).mul(.5),u=s.sub(e);u.rightPerpendicularThis();const l=m.add(u),c=f.getClosestCoordinate(m,l,t.getCenter(),!0),d=new f;Q(m,l,c,d);const g=f.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,g,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}function bu(t,e,i,n){const r=t.getStartXY(),o=t.getEndXY(),a=r.equals(o),h=e.equals(i);if(!a&&!h){const s=new k;return s.initializeFromTwoPoints(r,o,e,i),Zm(t,s,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void km(t,e,i,1);if(a&&h){const s=t.m_center.add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),s)}if(!a){const s=.5*(ht()-Math.abs(t.getSweepAngle())),n=(t.getSweepAngle()+s*ct(t.getSweepAngle()))/t.getSweepAngle(),r=new f;t.queryCoord2D(n,r),t.constructEllipticArcEndPointsCenter(r,r,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const o=t.getCenter().add(e.sub(r));return void t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),o)}const m=f.sqrDistance(e,i);let u=.25,l=.75;if(m<f.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],i=Fi(new vm(t,m),D.construct(0,.25),1,e);i>0&&(s(1===i),u=e[0],l=1-e[0])}const c=t.getCoord2D(u),d=t.getCoord2D(l);s(!c.equals(d)),t.constructEllipticArcEndPointsCenter(c,d,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),bu(t,e,i)}function Eu(s,i){let r=i,o=null;r||(o=_(s)?ce():le(),r=o);let a=null;switch(s){case n.enumPoint:a=new hs({vd:r});break;case n.enumLine:a=new rl({vd:r});break;case n.enumBezier:a=new da({vd:r});break;case n.enumEllipticArc:a=new $h({vd:r});break;case n.enumRationalBezier2:a=new mn({vd:r});break;case n.enumBezier2:a=new an({vd:r});break;case n.enumEnvelope:a=new cs({vd:r});break;case n.enumMultiPoint:a=new Es({vd:r});break;case n.enumPolyline:a=new Rh({vd:r});break;case n.enumPolygon:a=new nm({vd:r});break;case n.enumMultipatch:t("multipatch not impl");break;case n.enumGeometryCollection:a=new Ts({vd:r});break;default:e("Geometry.create")}return a}var Du=Vt;const Su=-1,wu=1;class Au{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function Tu(t){return void 0!==t.parent}class Iu{constructor(t){Tu(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==Su;){for(;this.m_path!==Su;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==Su)return this.m_vertex;if(this.m_bOneGeom)return Su;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===Su)break;this.m_bSkipMultiPoints&&!d(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return Su}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==Su&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return Su}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==Su?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==Su&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):Su}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new Iu({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class Nu{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class qu{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,i=this.m_indices.length;s<i;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,wu),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,wu),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==Su?this.getPrevVertex(e):this.getLastVertex(t),r=n!==Su?this.getNextVertex(n):Su,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByVal(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==Su&&this.setPrevVertex(r,o),n!==Su&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===Su&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==Su||this.setFirstVertex(t,o)),h&&r===Su&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new hs({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(n.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let n=0,r=s.getPathCount();n<r;n++){if(0===s.getPathSize(n))continue;const e=this.insertPath(t,Su);this.setClosedPath(e,s.isClosedPath(n));for(let t=s.getPathStart(n),r=s.getPathEnd(n);t<r;t++){const n=this.insertVertex_(e,Su,null,!1);if(i){const e=this.getVertexIndex(n);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const i=new ol;s.querySegment(t,i,!0),this.setSegmentToIndex(e,i.releaseSegment())}}}s.isStrongPathStart(n)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(n)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===n.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new qt;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()){o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)}if(o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,u=0,l=-1,c=Su,d=!1,g=s.nextSegment();if(null!==g)for(;;g=s.nextSegment()){let r=null===g;const o=null!==g?s.getPathIndex():a,_=null!==g?s.getStartPointIndex():h;if(r||(a===o&&h+1===_?u++:r=!0),r){if(-1!==l){let t=-1,s=-1;if(u===m){this.setClosedPath(c,d);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-l),this.m_verticesMp.addPoints(e,l,n),s=i.getPathSize(a),t=n-1}else if(!d||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp.addPoints(e,l,h+2),s=h-l+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-l),this.m_verticesMp?.addPoints(e,l,h+1),t=h,s=h-l+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=l;e<s;e++,r++){const e=this.insertVertex_(c,Su,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new ol;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===g)break;u=1,l=_,a!==o?(c=this.insertPath(t,Su),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),d=i.isClosedPath(o),a=o):c=this.insertPath(t,Su)}h=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,i){const n=e.getImpl(),r=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),o=qt.constructEmpty();e.queryEnvelope(o),s(i.isIntersecting(o)&&!i.containsEnvelope(o));let a=qt.construct(Number.NEGATIVE_INFINITY,i.ymin,Number.POSITIVE_INFINITY,i.ymax),h=qt.construct(i.xmin,Number.NEGATIVE_INFINITY,i.xmax,Number.POSITIVE_INFINITY);const m=n.getAccelerators();if(m&&m.getQuadTree()){const t=m.getQuadTree(),e=t.getIntersectionCount(a,0,0);e>t.getIntersectionCount(h,0,e+1)&&(h=S(a,a=h))}else a.height()>h.width()&&(h=S(a,a=h));const u=[],l=n.queryLimitedSegmentIterator(a);let c=-1,d=-100,g=-1,_=0,p=-1,f=-1,x=Su,y=!0,P=l.nextSegment();if(null!==P)for(;;P=l.nextSegment()){let i=null===P;const o=null!==P?l.getPathIndex():c,a=null!==P?l.getStartPointIndex():d;if(i||(o===c?d+1===a?_++:i=!0:(i=c>=0,c<0&&(c=o,g=n.getSegmentCountPath(c),p=a,x=Su,_=1))),i){if(!(0===u.length&&g===_)){0!==u.length&&u[0].first===p||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,p,p+1),-1===f&&(f=p),x===Su&&(x=this.insertPath(t,Su),this.setClosedPath(x,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(x,Su,null,!1));for(const{first:i,second:o}of u){-1===f&&(f=i);let a=-1,h=-1;const m=i+o-1;if(o===g){const t=m+1;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,i,t),a=m,s(1===u.length)}else if(m+1<n.getPathEnd(c)){const t=m+2;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,i,t),a=m}else{const t=n.getPathStart(c),s=t!==f?1:0,r=m+1;h=r-i+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-i)+s),this.m_verticesMp.addPoints(e,i,r),a=m,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),x===Su&&(x=this.insertPath(t,Su),this.setClosedPath(x,!0));for(let t=0,e=i;t<h;t++,e++){const t=this.insertVertex_(x,Su,null,!1);if(r){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new ol;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===u.length||u.at(-1).first+u.at(-1).second!==p+_){let t=p+_;t===e.getPathEnd(c)&&(t=e.getPathStart(c)),f!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(x,Su,null,!1))}}u.length=0,y=!0,o!==c&&(c=o,g=n.getSegmentCountPath(c),x=Su,f=-1),p=a,_=1}if(!P)break;{const t=qt.constructEmpty();P.queryLooseEnvelope(t),h.isIntersecting(t)?(y?u.push(xt(a,1)):u.at(-1).second++,y=!1):y=!0}d=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const i=e.getGeometryType()===n.enumPolygon,r=qt.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?i?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,Su);this.insertVertex_(i,Su,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,Su);for(let i=0,n=e.getPointCount();i<n;i++)this.insertVertex_(s,Su,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)?(-1===r&&(r=m,o=m),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,Su);for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&this.insertVertex_(h,Su,null,!1)}}splitSegmentForward(t,s,i,r,o){const a=this.getNextVertex(t);a===Su&&e("Edit_shape.split_segment_forward_");const h=this.getHelperPoint(),m=this.getPathFromVertex(t);let u=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(i);e<c;e++){const t=this.getVertexIndex(u),r=this.getNextVertex(u),d=s.getResultSegment(i,e);let g=null;if(d.getGeometryType()!==n.enumLine&&(g=d.clone(),g.dropAllAttributes()),0===e&&(d.queryStart(h),this.setSegmentToIndex(t,null),this.setPointEx(u,h,s.getResultSegmentStartPointRank(i,e),s.getResultSegmentStartPointWeight(i,e),o)),this.setSegmentRank(u,s.getResultSegmentInteriorRank(i,e)),this.setSegmentWeight(u,s.getResultSegmentInteriorWeight(i,e)),l){const t=s.getResultSegmentSegmentParentage(i,e),n=s.getResultSegmentStartPointIsBreak(i,e);this.setSegmentParentageAndBreak(u,t,n)}if(d.queryEnd(h),e<c-1){this.setSegmentToIndex(t,g);const n=this.insertVertex(m,r,h);this.setWeight(n,s.getResultSegmentEndPointWeight(i,e)),this.setRank(n,s.getResultSegmentEndPointRank(i,e)),this.select(n),u=n}else{this.setPointEx(a,h,s.getResultSegmentEndPointRank(i,e),s.getResultSegmentEndPointWeight(i,e),o);const n=s.getResultSegmentEndPointIsBreak(i,e);this.setSegmentParentageBreakVertex(a,n),this.setSegmentToIndex(t,g)}}}splitSegmentBackward(t,s,i,r,o){const a=this.getNextVertex(t);a===Su&&e("Edit_shape.split_segment_backward_");const h=this.getHelperPoint(),m=this.getPathFromVertex(t);let u=t;const l=this.hasSegmentParentage();for(let e=0,c=s.getResultSegmentCount(i);e<c;e++){const t=c-e-1,r=this.getVertexIndex(u),d=this.getNextVertex(u),g=s.getResultSegment(i,t);let _=null;if(g.getGeometryType()!==n.enumLine&&(_=g.clone(),_.reverse(),_.dropAllAttributes()),0===e&&(g.queryEnd(h),this.setSegmentToIndex(r,null),this.setPointEx(u,h,s.getResultSegmentEndPointRank(i,t),s.getResultSegmentEndPointWeight(i,t),o),this.setSegmentParentageAndBreak(u,s.getResultSegmentSegmentParentage(i,t),s.getResultSegmentEndPointIsBreak(i,t))),g.getGeometryType()===n.enumLine?this.setSegmentToIndex(r,null):this.setSegmentToIndex(r,_),this.setSegmentRank(u,s.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(u,s.getResultSegmentInteriorWeight(i,t)),g.queryStart(h),e<c-1){const e=this.insertVertex(m,d,h);this.setWeight(e,s.getResultSegmentStartPointWeight(i,t)),this.setRank(e,s.getResultSegmentStartPointRank(i,t)),this.select(e),u=e,l&&this.setSegmentParentageAndBreak(e,s.getResultSegmentSegmentParentage(i,t),s.getResultSegmentEndPointIsBreak(i,t))}else this.setPointEx(a,h,s.getResultSegmentStartPointRank(i,t),s.getResultSegmentStartPointWeight(i,t),o)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?Ut(0,-1):Ut(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return Ut(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=S(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,Su,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return Su}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,((t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s}))}sortVerticesSimpleByYHelper3D(t,e,i){s(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=kt.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=f.getNAN(),this.m_workPoint2_2D=f.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=Su,this.m_lastGeometry=Su,this.m_vertexIndexList=new _e(5),this.m_pathIndexList=new _e(8),this.m_geometryIndexList=new _e(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new ge,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new qt(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=qt.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let r=i.next();r!==Su;r=i.next()){if(n?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=qt.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}n=!1}return s}getEnvelope3D(t){return s(0),kt.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){s(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,s){const i=t.getGeometryType();if(d(i))return this.addMultiPath(t,s);if(i===n.enumMultiPoint)return this.addMultiPoint(t,s);if(i===n.enumPoint)return this.addPoint_(t,s);if(i===n.enumEnvelope){const e=new nm;return e.addEnvelope(t,!1),this.addMultiPath(e,s)}e("")}appendGeometry(t,s){this.mergeVertexDescription(s.getDescription());const i=s.getGeometryType();d(i)?this.appendMultiPath(t,s):i!==n.enumMultiPoint?e(""):this.appendMultiPoint(t,s)}assignRankToGeometryVertices(t,e){e<wu&&(e=wu);const s=this.queryVertexIterator();for(let i=s.next();i!==Su;i=s.next())this.setRank(i,e),this.setSegmentRank(i,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(n.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=Su,s=-1,i=-1;for(let r=this.getFirstGeometry();r!==Su;)if(t!==n.enumUnknown&&this.getGeometryType(r)!==t)r=this.getNextGeometry(r);else{if(e===Su){e=r,s=this.getPathCount(e),i=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let s=this.getFirstPath(r);s!==Su;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(r),i+=this.getPointCount(r);const t=this.getLastPath(e),n=this.getFirstPath(r);t!==Su?this.setNextPath(t,n):this.setFirstPath(e,n),n!==Su&&(this.setPrevPath(n,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,Su),this.setLastPath(r,Su);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==Su&&(this.setGeometryVertexCount(e,i),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let c=this.getFirstPath(t);c!==Su;c=this.getNextPath(c))this.setPathGeometry(c,e);for(let c=this.getFirstPath(e);c!==Su;c=this.getNextPath(c))this.setPathGeometry(c,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const u=this.m_geometryIndexList.getField(t,2),l=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,l),this.m_geometryIndexList.setField(e,2,u)}addPathFromMultiPath(t,e,s){const i=this.createGeometry(s?n.enumPolygon:n.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return i;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(i,Su);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let n=r.getPathStart(e),h=r.getPathEnd(e);n<h;n++){const t=this.insertVertex_(o,Su,null,!1);if(a){const e=this.getVertexIndex(t);if(1&r.getSegmentFlags(n))this.setSegmentToIndex(e,null);else{const t=new ol;r.querySegment(n,t,!0),this.setSegmentToIndex(e,t.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),i}getGeometry(t){const e=this.getGeometryType(t),s=Eu(e,this.m_verticesMp.getDescription()),i=this.getPointCount(t);if(0===i)return s;if(d(e)){const e=s.getImpl(),n=this.getPathCount(t),r=Ut(n+1),o=Ot(n+1,0),a=s.getDescription(),h=this.hasCurves();for(let s=0,m=a.getAttributeCount();s<m;s++){const h=a.getSemantics(s),m=Du.getComponentCount(h),u=jt(h,i),l=this.m_vertices.getAttributeStreamRef(h);let c=0,d=0,g=0;for(let e=this.getFirstPath(t);e!==Su;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&o.setBits(d,t);const s=this.getPathSize(e);if(r.write(d++,g),g+=s,0===h){const t=l,s=u;let i;for(let n=this.getFirstVertex(e);c<g;n=this.getNextVertex(n),c++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*c,i)}}else for(let i=this.getFirstVertex(e);c<g;i=this.getNextVertex(i),c++){const t=this.getVertexIndex(i);for(let e=0;e<m;e++){const s=l.readAsDbl(t*m+e);u.writeAsDbl(c*m+e,s)}}}e.setAttributeStreamRef(h,u),r.write(n,i)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,i=0;for(let n=this.getFirstPath(t);n!==Su;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===n.enumMultiPoint){const e=s.getImpl(),n=s.getDescription();e.reserve(i),e.resizeNoInit(i);for(let s=0,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=Du.getComponentCount(i),o=e.getAttributeStreamRef(i),a=this.m_vertices.getAttributeStreamRef(i);let h=0;const m=this.getFirstPath(t),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}e.setAttributeStreamRef(i,o)}e.notifyModifiedFlags(65535)}else a("getGeometry");return s}queryPointGeometryOnly(t,s){this.getGeometryType(t)!==n.enumMultiPoint&&e("get_point_geometry_only");const i=this.getPointCount(t);if(i>1&&e("get_point_geometry_only"),0===i)return s.assignVertexDescription(this.m_vertexDescription),void s.setEmpty();const r=this.getFirstPath(t),o=this.getFirstVertex(r);this.queryPoint(o,s)}removeGeometry(t){for(let i=this.getFirstPath(t);i!==Su;i=this.removePath(i));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==Su?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==Su?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=le());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new Es({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===Su?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let e=0;e<this.m_geometryIndices.length;e++)if(null===this.m_geometryIndices[e])return this.m_geometryIndices[e]=Ut(0),e;this.m_geometryIndices.push(Ut(0));const t=this.m_geometryIndices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==Su;t=this.getNextGeometry(t))if(!d(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,i,r,o){const a=t*t;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage();for(let l=o===Su?this.getFirstGeometry():o;l!==Su;l=o===Su?this.getNextGeometry(l):Su){const t=this.getGeometryType(l);if(!d(t))continue;if(i&&t!==n.enumPolygon)continue;const o=this.getGeometryType(l)===n.enumPolygon;let c=this.getGeometryModified(l);for(let i=this.getFirstPath(l);i!==Su;){let t=0;for(let e=this.getFirstVertex(i);t<Math.trunc(this.getPathSize(i)/2);){const n=this.getNextVertex(e);if(n===Su)break;const o=this.getXY(e),d=this.getXY(n);let g=f.sqrDistance(o,d),_=!0;do{if(g<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(g=e*e,g>a)break}}if(0===g?0===h&&(h=-1):h=1,n!==this.getLastVertex(i)){const t=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(n));if(this.transferAllDataToTheVertex(n,e),this.removeVertex(n,!1),r&&!c&&(this.setGeometryModified(l,!0),c=!0),u&&e!==n){this.setSegmentParentageBreakVertex(e,t);const i=this.getNextVertex(e);s(i!==Su),this.isDiscontinuousSegmentParentage(i)&&this.setSegmentParentageBreakVertex(i,!0)}}_=!1}}while(0);_&&(e=this.getNextVertex(e)),t++}let n=this.getFirstVertex(i);for(let e=this.isClosedPath(i)?n:this.getLastVertex(i);this.getPathSize(i)>0;){const t=this.getPrevVertex(e);if(t===Su)break;{const s=this.getXY(t),o=this.getXY(e);let d=f.sqrDistance(s,o),g=!0;do{if(d<=a){if(m){const e=this.getSegment(t);if(null!==e){const t=e.calculateLength2D();if(d=t*t,d>a)break}}0===d?0===h&&(h=-1):h=1;const s=u&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(t));this.removeVertex(t,!0),r&&!c&&(this.setGeometryModified(l,!0),c=!0),u&&t!==e&&(s||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),n===t&&(n=this.getFirstVertex(i)),g=!1}}while(0);if(g&&(e=this.getPrevVertex(e),e===n))break}}const d=this.getPathSize(i);let g=e&&d<(o?3:2);g&&o&&2===d&&m&&(g=!this.pathHasCurves(i)),g?(i=this.removePath(i),0===h&&(h=-1),r&&!c&&(this.setGeometryModified(l,!0),c=!0)):i=this.getNextPath(i)}}return h}filterClosePoints3D(t,e,i,n,r,o){return s(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==Su;e=this.getNextGeometry(e))if(d(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==Su;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===Su)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(t,e){return s(0),!1}transferAllDataToTheVertex(t,e){const s=this.getVertexIndex(t),i=this.getVertexIndex(e);if(this.m_weights){const t=this.getWeightWithIndex(s);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(s);this.setRankWithIndex(i,t)}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(i,t)}for(let r=0,o=this.m_indices.length;r<o;r++)if(r!==this.m_selectionIndex&&null!==this.m_indices[r]){const s=this.getUserIndex(t,r);-1!==s&&this.setUserIndex(e,r,s)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,s,i,n,r){let o=0;const a=this.getNextVertex(t);a===Su&&e("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),u=this.getSegmentFromIndex(h);let l=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),d=this.m_bHasAttributes;d&&u&&(l=u.calculateLength2D());const g=this.getSegmentParentage(t),_=this.getHelperPoint();if(u){let t=0,e=0,r=Su;for(let p=0;p<i;p++){const i=s[p];if(t<i&&i<1){const s=u.cut(t,i);if(null!==n&&(p>0&&s.setStartXY(n[p-1]),s.setEndXY(n[p]),s.normalizeAfterEndpointChange(),e=p),d){const t=l>0?u.calculateSubLengthFromStart(i)/l:0;this.m_vertices.interpolateTwoVertices(h,m,t,_)}_.setXY(s.getEndXY()),r=this.insertVertex(c,a,_),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,s),-1!==g&&this.setSegmentParentageAndBreak(r,g,!1),t=i}}if(r!==Su){const s=u.cut(t,1);null!==n&&(s.setStartXY(n[e]),s.normalizeAfterEndpointChange());const i=this.getVertexIndex(r);this.setSegmentToIndex(i,s)}}else{let t=0;for(let e=0;e<i;e++){const i=s[e];if(t<i&&i<1){this.m_vertices.interpolateTwoVertices(h,m,i,_);const t=this.insertVertex(c,a,_);o++,-1!==g&&this.setSegmentParentageAndBreak(t,g,!1)}t=i}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,s,i){this.getNextVertex(t)===Su&&e("");let n=t,r=!1;for(let e=0;e<s;++e){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(i);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==Su;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,i){return s(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByVal(s,e)}setPointOnlyEx(t,e,i,n){s(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new f(e,s),t,!1),n.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==Su){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new f(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,i){s(0)}setXYZ(t,e,i){s(0)}setXYZCoords(t,e,i,n){s(0)}queryXYZ(t,e){s(0)}getXYZ(t){return s(0),Bt.getNAN()}getXYZWithIndex(t){return s(0),Bt.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){s(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,i,n){s(0)}setAttribute(t,e,i,n){s(0)}setAttributeInt(t,e,i,n){s(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return s(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return s(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=Qt(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=Qt(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return wu;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?wu:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?wu:this.m_ranks.read(t)}setRank(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_ranks){if(s)return;this.m_ranks=Ut(this.m_vertices.getPointCount(),wu)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,wu)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_ranks){if(s)return;this.m_ranks=Ut(this.m_vertices.getPointCount(),wu)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,wu)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=Qt(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=Qt(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return qu.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?qu.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?wu:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Ut(this.m_vertices.getPointCount(),wu)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,wu)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<wu&&(e=wu);const s=e===wu;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Ut(this.m_vertices.getPointCount(),wu)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,wu)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];if(s<i.size()){return i.read(s)}return-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(),e;this.m_indices.push(this.allocateIndex());const t=this.m_indices.length-1;return s(t>=0&&t<=w()),t}createUserIndexUninitialized(){for(let e=0;e<this.m_indices.length;e++)if(null===this.m_indices[e])return this.m_indices[e]=this.allocateIndex(!1),e;this.m_indices.push(this.allocateIndex(!1));const t=this.m_indices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Su;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){s(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===Su)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new hs({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,i=!1){return s(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return s(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===Su)return!1;const s=this.getPathSize(t);let i=e;for(let r=0;r<s;r++,i=this.getNextVertex(i)){const t=this.getSegment(i);if(null!==t&&t.getGeometryType()!==n.enumLine)return!0}return!1}insertPath(t,s){let i=Su;s!==Su?(t!==this.getGeometryFromPath(s)&&e(""),i=this.getPrevPath(s)):i=this.getLastPath(t);const n=this.newPath(t);return s!==Su&&this.setPrevPath(s,n),this.setNextPath(n,s),this.setPrevPath(n,i),i!==Su?this.setNextPath(i,n):this.setFirstPath(t,n),s===Su&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==Su?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Su?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==Su){let s=e;for(let e=0,n=this.getPathSize(t);e<n;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,Su),this.setPrevVertex(s,Su);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){s(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===Su)return 0;const s=this.getXY(e),i=new X(0),r=this.getPathSize(t);if(r>2){const t=s.clone(),n=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const m=f.getNAN();for(let e=2;e<r;e++,a=this.getNextVertex(a))this.queryXY(a,m),i.pe((m.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);i.pe((n-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<r;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===n.enumLine)continue;const s=2*e.calculateArea2DHelper();i.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let e=0;e<this.m_pathindices.length;e++)if(null===this.m_pathindices[e])return this.m_pathindices[e]=this.allocatePathIndex(),e;this.m_pathindices.push(this.allocatePathIndex());const t=this.m_pathindices.length-1;return s(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Su;r=this.getNextPath(r)){const t=this.getPathIndex(r);t<n&&i.write(t,s)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,s,i){if(i===Su&&e(""),s===i)return;const n=this.getNextPath(i);let r=this.getPrevPath(i);const o=this.getGeometryFromPath(i);r===Su?this.setFirstPath(o,n):this.setNextPath(r,n),n===Su?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(i)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=s===Su?this.getLastPath(t):this.getPrevPath(s),this.setPrevPath(i,r),this.setNextPath(i,s),s===Su?this.setLastPath(t,i):this.setPrevPath(s,i),r===Su?this.setFirstPath(t,i):this.setNextPath(r,i),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(i)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(i,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,Su,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==Su&&this.setNextVertex(i,n);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:Su),n!==Su&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:Su);if(this.hasCurves()&&i!==Su&&n!==Su){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(t,e){s(t!==e);const i=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==Su&&this.setNextVertex(n,e);let o=this.getPathSize(i);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,Su),this.setNextVertex(r,Su);let h=0,m=t;const u=this.getFirstVertex(i);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(i,o>0?e:Su),this.setPathSize(i,o);const c=this.getGeometryFromPath(i);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,Su,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||a(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==Su;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==Su;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=Su){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=Su){let s=Su,i=Su,n=Su,r=Su,o=0,a=!1;for(s=e!==Su?e:this.getFirstGeometry();s!==Su;s=this.getNextGeometry(s))if(!t||d(this.getGeometryType(s))){for(i=this.getFirstPath(s);i!==Su;i=this.getNextPath(i))if(n=this.getFirstVertex(i),r=n,o=0,n!==Su){a=!0;break}if(a||e!==Su)break}return a||(s=Su),Iu.create_(this,s,i,n,r,o,t,!1,e!==Su)}queryVertexIteratorOnSelection(t=Su){return this.m_selection?Iu.create_(this,t,Su,Su,Su,-1,!1,!0,t!==Su):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){s(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=Su,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return s(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(t){return s(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===Su)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return s(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==Su?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Su?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,Su),this.setLastVertex(t,Su),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,Su);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(t,e){return s(0),0}findVertex3D(t,e,i){return s(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);s!==Su&&this.setNextVertex(s,i),i!==Su&&this.setPrevVertex(i,s);if(this.hasCurves()&&s!==Su&&i!==Su){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){s(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new Au(this))}sortVerticesSimpleByX(t,e,i){s(0)}sortVerticesSimpleByY3D(t,e,i){s(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==Su&&this.replaceCurveWithLine(s);this.getNextVertex(t)!==Su&&this.replaceCurveWithLine(t);const i=new f;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&(s(e<=N()>>1),e<<=1,e|=i?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if(s(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}if(e>=0){s(e<=N()>>1),e<<=1;e|=this.getSegmentParentageBreakVertex(t)?1:0}this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new Nu(e)}return new Nu(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=N()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===Su)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function Mu(t){if(t.isEmpty())return new nm({vd:t.getDescription()});const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new hs({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new hs,s=new Rh({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const i=e.getAttributeStreamRef(0),n=new Lu({stream:i,n:s});let r=0,o=1;const a=i.readPoint2D(r<<1),h=new f;for(;o<s&&i.queryPoint2D(o<<1,h).equals(a);)o++;if(n.m_treeHull.addElement(r),o<s){n.m_treeHull.addBiggestElement(o);const t=new f;for(let s=o+1;s<e.getPointCount();s++){i.queryPoint2D(s<<1,t);const e=n.treeHull(t);-1!==e&&n.m_treeHull.setElement(e,s)}}const m=e.getDescription(),u=m.getAttributeCount()>1,l=n.m_treeHull.size();let c=null;if(l>=2){c=l>=3?new nm({vd:m}):new Rh({vd:m});const t=c.getImpl();t.reserve(n.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new f;for(let r=n.m_treeHull.getFirst();-1!==r;r=n.m_treeHull.getNext(r))if(u){const s=new hs;e.getPointByVal(n.m_treeHull.getElement(r),s),t.insertPoint(0,-1,s)}else i.queryPoint2D(n.m_treeHull.getElement(r)<<1,s),t.insertPoint2D(0,-1,s)}else if(u){const t=new hs({vd:m});e.getPointByVal(n.m_treeHull.getElement(n.m_treeHull.getFirst()),t),c=t}else{const t=i.readPoint2D(n.m_treeHull.getElement(n.m_treeHull.getFirst())<<1);c=new hs(t)}return c}function Yu(t,e,i){if(e<=262144)return Bu(t,e,i);s(0);const n=new Lu({points:t,n:e}),r=0;let o=1;const a=t[r].clone();for(;o<e&&t[o].equals(a);)o++;if(n.m_treeHull.addElement(r),o<e){n.m_treeHull.addBiggestElement(o);for(let s=o+1;s<e;s++){const e=t[s],i=n.treeHull(e);-1!==i&&n.m_treeHull.setElement(i,s)}}let h=0;for(let s=n.m_treeHull.getFirst();-1!==s;s=n.m_treeHull.getNext(s))i[h++]=n.m_treeHull.getElement(s);return h}function Xu(t,e,s){const i=t.getImpl(),n=i.getPathStart(e),r=i.getPathEnd(e),o=!i.isClosedPath(e)&&i.isClosedPathInXYPlane(e),a=i.getAttributeStreamRef(0),h=2*n;let m=2*r;if(o&&(m-=2),m-h<6)return!0;const u=a.readPoint2D(h),l=a.readPoint2D(h+2),c=a.readPoint2D(h+4);if(!ku(f.orientationRobust(l,c,u)))return!1;const d=l.clone(),g=new f;for(let _=h+6;_<m;_+=2){g.assign(l),l.assign(c),a.queryPoint2D(_,c);if(!ku(f.orientationRobust(l,c,u)))return!1;if(!ku(f.orientationRobust(d,c,u)))return!1;if(!ku(f.orientationRobust(l,c,g)))return!1}return!0}function Fu(t,e,s,i,r){if(s.setNAN(),i.setCoords(1,0),r.setCoords(0,0),t.isEmpty())return;if(t.getGeometryType()===n.enumPoint)return void s.assign(t.getXY());const o=t,a=o.getPointCount();if(2===a){const t=o.getXY(0),e=o.getXY(1);s.assign(t.add(e).mul(.5));const n=e.sub(t);i=Wu(n),r.setCoords(.5*n.length(),0)}else{let t=Number.MAX_VALUE;const n=[0,1,0,0],h=new bt(4,2);for(h.set(0,0,0),h.set(0,1,1),h.set(1,0,1),h.set(1,1,2);n[0]<a;++n[0],ju(h,0,a)){n[1]===n[0]&&(++n[1],ju(h,1,a));for(let t=1;;++t){for(;;){const e=Zu(o.getXY(h.get(0,0)),o.getXY(h.get(0,1)),o.getXY(h.get(t,0)),o.getXY(h.get(t,1)),2^t);if(e>0)break;if(++n[t],ju(h,t,a),0===e)break}if(3===t)break;n[t+1]<n[t]&&(n[t+1]=n[t],h.set(t+1,0,h.get(t,0)),h.set(t+1,1,h.get(t,1)))}const m=o.getXY(h.get(0,0)).add(o.getXY(h.get(2,0))).mul(.5),u=Wu(o.getXY(h.get(0,1)).sub(o.getXY(h.get(0,0)))),l=new f;let c,d;if(l.x=Math.max(0,u.dotProduct(o.getXY(h.get(1,0)).sub(o.getXY(h.get(3,0))))),l.y=Math.max(0,u.crossProduct(o.getXY(h.get(0,0)).sub(o.getXY(h.get(2,0))))),e?(c=l.x*l.y,d=c<t):(c=l.y,d=c<t),d){t=c;const e=o.getXY(h.get(1,0)),n=o.getXY(h.get(3,0)),a=e.add(n).mul(.5).sub(m);s.assign(m.add(u.mul(u.dotProduct(a)))),i.assign(u),r.assign(l)}}r.mulThis(.5),r.x<r.y&&(r.y=S(r.x,r.x=r.y),i.leftPerpendicularThis())}i.y<0?i.negateThis():0===i.y&&(i.x=1)}qu.st_defaultRank=1;class Ru{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,s(0),this.m_convexHull=t,this.m_function=this.done_}next(){return s(0),!1}get_vertex_handle_p(){return s(0),0}get_vertex_handle_q(){return s(0),0}get_current_support(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}intialize_(){return s(0),!1}increment_(){return s(0),!1}increment_q_(){return s(0),!1}increment_p_(){return s(0),!1}parallel_edge_with_q_support_(){return s(0),!1}parallel_edge_with_p_support_(){return s(0),!1}done_(){return s(0),!1}}class Lu{nullGetXY(t){return a("m_getXY is null"),{}}nullDeleteNode(t){a("m_deleteNode is null")}constructor(t){return this.m_treeHull=new ve,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=Su,void(this.m_pathHandle=Su)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=Su,void(this.m_pathHandle=Su)):void o("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new qu,this.m_geometryHandle=this.m_shape.createGeometry(n.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,Su),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return s(0),new f}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){s(0)}addGeometry(t){if(t.isEmpty())return;const s=t.getGeometryType();if(s===n.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else h(s)?this.addMultiVertexGeometry(t):m(s)?this.addSegment(t):s===n.enumEnvelope?this.addEnvelope(t):s===n.enumPoint?this.addPoint(t):e("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new hs,e=this.m_treeHull.getFirst(),s=new nm({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return s(0),new Ru(this)}getXY(t){return s(0),new f}getXYWithIndex(t){return s(0),new f}getFirst(){return s(0),0}getLast(){return s(0),0}getNext(t){return s(0),0}getPrev(t){return s(0),0}getVertexIndex(t){return s(0),0}getPointCount(){return s(0),0}addMultiVertexGeometry(t){const e=new hs,s=t.getImpl(),i=new f;for(let n=0;n<t.getPointCount();n++){s.queryXY(n,i);const r=this.addPoint2D(i);if(-1!==r){t.getPointByVal(n,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}addEnvelope(t){const e=new hs;for(let s=0;s<4;s++){const i=new f;t.queryCorner(s,i);const n=this.addPoint2D(i);if(-1!==n){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}addSegment(t){const e=new hs,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const n=t.getEndXY(),r=this.addPoint2D(n);if(-1!==r){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),n=this.m_treeHull.getElement(s),r=this.m_treeHull.getElement(i),o=this.m_getXY(n),a=this.m_getXY(r),h=f.orientationRobust(a,t,o);if(ku(h)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(Gu(h)){let n=this.m_treeHull.getRoot(),r=this.m_treeHull.getFirst(),a=this.m_treeHull.getLast(),h=-1,m=-1,u=-1;for(;r!==this.m_treeHull.getPrev(a);){m=this.m_treeHull.getElement(n);const e=this.m_getXY(m);Gu(f.orientationRobust(e,t,o))?(a=n,n=this.m_treeHull.getLeft(n)):(r=n,n=this.m_treeHull.getRight(n))}n=a,h=r,m=this.m_treeHull.getElement(n),u=this.m_treeHull.getElement(h);const l=this.m_getXY(m),c=this.m_getXY(u);if(h!==s){if(!ku(f.orientationRobust(c,t,l)))break}e=this.m_treeHull.addElementAtPosition(h,n,-2,!0,!1),this.treeHullWalkForward(t,n,i),this.treeHullWalkBackward(t,h,s);break}{const n=Hu(t,a,o);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),r=this.m_treeHull.getNext(i);const o=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(ku(f.orientationRobust(s,t,o)))break;const a=i;i=r,n=e,o.assign(s),r=this.m_treeHull.getNext(i),this.m_deleteNode(a)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,n=this.m_treeHull.getElement(i),r=this.m_treeHull.getPrev(i);const o=this.m_getXY(n);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(r),s=this.m_getXY(e);if(ku(f.orientationRobust(o,t,s)))break;const a=i;i=r,n=e,o.assign(s),r=this.m_treeHull.getPrev(i),this.m_deleteNode(a)}return i}}function zu(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:f.orientationRobust(t,e,s)}function Vu(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:f.orientationRobust(t,e,s)}function Bu(t,e,s){const i=new Jt(0);for(let a=0;a<e;a++)i.add(a);const n={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};ge.sortEx(i,0,e,n);let r=0;t:for(let a=0;a<e;++a){const e=i.read(a);for(;r>=2;){const n=s[r-2],o=s[r-1];if(t[o].equals(t[e])){i.write(a,-1);continue t}if(!(zu(t[n],t[o],t[e])>=0)){o===i.read(a-1)&&i.write(a-1,-1);break}r--}s[r++]=e,2===r&&t[e].equals(t[s[0]])&&(i.write(1,-1),r--)}const o=r+1;t:for(let a=e-2;a>=0;--a){const e=i.read(a);if(!(e<0)){for(;r>=o;){const i=s[r-2],n=s[r-1];if(t[n].equals(t[e]))continue t;if(!(Vu(t[i],t[n],t[e])>=0))break;r--}if(0!==a){const i=s[r-1];s[r++]=e,t[e].equals(t[i])&&r--}}}return r>1&&t[s[0]].equals(t[s[r-1]])&&r--,r}function ku(t){return t<0}function Gu(t){return t>0}function Hu(t,e,s){let i=-1;if(e.y===s.y)i=0;else if(e.x===s.x)i=1;else{i=Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1}let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Wu(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function ju(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Zu(t,s,i,n,r){switch(r){case 0:break;case 1:s.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:s.negateThis(),t.negateThis();break;case 3:s.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:e("")}return f.orientationRobustEx(t,s,i,n)}function Uu(t,e,s,i,n){return Ou(t,!1,e,s,i,n)}function Ou(t,e,s,i,r,o){const h=s.getGeometryType(),m=i.getGeometryType(),u=Math.max(r,ei(s,i));if(h===n.enumLine&&m===n.enumLine)return xi(s,i,u,o);let l=s,c=i,d=s.getStartXY(),g=s.getEndXY();if(d.compare(g)>0&&(l=s.clone().reverse()),d=i.getStartXY(),g=i.getEndXY(),d.compare(g)>0&&(c=i.clone().reverse()),e){if(s.equals(i))return 2;if(zs(s,i,u))return 4}switch(h){case n.enumLine:switch(m){case n.enumEllipticArc:return du(t,c,l,u,o);case n.enumBezier:return th(t,c,l,u,o);case n.enumRationalBezier2:return zr(t,c,l,u,o);case n.enumBezier2:return Ho(t,c,l,u,o);default:a("")}break;case n.enumEllipticArc:switch(m){case n.enumLine:return du(t,l,c,u,o);case n.enumEllipticArc:return gu(t,l,c,u,o);case n.enumBezier:return eh(t,c,l,u,o);case n.enumRationalBezier2:return Vr(t,c,l,u,o);case n.enumBezier2:return Wo(t,c,l,u,o);default:a("")}break;case n.enumBezier:switch(m){case n.enumLine:return th(t,l,c,u,o);case n.enumEllipticArc:return eh(t,l,c,u,o);case n.enumBezier:return sh(t,l,c,u,o);case n.enumRationalBezier2:return ih(t,l,c,u,o);case n.enumBezier2:return nh(t,l,c,u,o);default:a("")}break;case n.enumRationalBezier2:switch(m){case n.enumLine:return zr(t,l,c,u,o);case n.enumEllipticArc:return Vr(t,l,c,u,o);case n.enumBezier:return ih(t,c,l,u,o);case n.enumRationalBezier2:return kr(t,l,c,u,o);case n.enumBezier2:return Gr(t,l,c,u,o);default:a("")}break;case n.enumBezier2:switch(m){case n.enumLine:return Ho(t,l,c,u,o);case n.enumEllipticArc:return Wo(t,l,c,u,o);case n.enumBezier:return nh(t,c,l,u,o);case n.enumRationalBezier2:return Gr(t,c,l,u,o);case n.enumBezier2:return jo(t,l,c,u,o);default:a("")}break;default:a("")}}function Qu(t,e,s=!0){if(!s&&!Ku(t,e))return 0;const i=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===n.enumEllipticArc){return Pu(t,e,!1)?s:0}if(r===n.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===n.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(i)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===n.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===n.enumEllipticArc){return Pu(t,e,!0)?s:-1}if(r===n.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===n.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function Ku(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==n.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function $u(t,s,i,r,o,h,m){!o&&h&&e("");const u=s.getGeometryType(),l=i.getGeometryType(),c=Math.max(m,ei(s,i));if(r&&(r.length=0),o&&(o.length=0),h&&(h.length=0),u===n.enumLine&&l===n.enumLine)return yi(s,i,r,o,h,c,!1,!1);let d=s,g=i,_=s.getStartXY(),p=s.getEndXY(),f=!1,x=!1;_.compare(p)>0&&(d=s.clone(!0).reverse(),f=!0),_=i.getStartXY(),p=i.getEndXY(),_.compare(p)>0&&(g=i.clone(!0).reverse(),x=!0);let y=0;switch(u){case n.enumLine:switch(l){case n.enumEllipticArc:y=_u(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier:y=rh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Hr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Zo(t,g,d,r,h,o,c,!1,!1,!0);break;default:a("")}break;case n.enumEllipticArc:switch(l){case n.enumLine:y=_u(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=pu(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=oh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Wr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Uo(t,g,d,r,h,o,c,!1,!1,!0);break;default:a("")}break;case n.enumRationalBezier2:switch(l){case n.enumLine:y=Hr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=Wr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=hh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=jr(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier2:y=Zr(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;case n.enumBezier2:switch(l){case n.enumLine:y=Zo(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=Uo(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=mh(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumRationalBezier2:y=Zr(t,g,d,r,h,o,c,!1,!1,!0);break;case n.enumBezier2:y=Oo(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;case n.enumBezier:switch(l){case n.enumLine:y=rh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumEllipticArc:y=oh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier:y=ah(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumRationalBezier2:y=hh(t,d,g,r,o,h,c,!1,!1,!1);break;case n.enumBezier2:y=mh(t,d,g,r,o,h,c,!1,!1,!1);break;default:a("")}break;default:a("")}if(f){if(o){for(let t=0;t<y;t++)o[t]=1-o[t];o.reverse()}r&&r.reverse(),h&&h.reverse()}if(x&&h)for(let e=0;e<y;e++)h[e]=1-h[e];return y}function Ju(t,e,s){if(e===s)return 0;e>s&&(s=S(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function tl(t,e,s,i,n){const r=[],o=[],a=[];for(let m=0,u=n;m<u;m++)r.push(t.calculateSubLengthFromStart(s[m])),o.push(e.calculateSubLengthFromStart(i[m])),G(s[m],0,1)&&G(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&a.push(m);if(0===a.length||a.length===n)return;a.sort(((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0));let h=-1;for(const m of a){if(h>=0&&s[m]===s[h]&&s[m]===s[h]){h=m;continue}h=m;const a=[];a.length=n;for(let t=0;t<a.length;++t)a[t]=t;a.sort(((t,e)=>{const s=r[m],i=o[m],n=r[t]-s,a=o[t]-i,h=n*n+a*a,u=r[e]-s,l=o[e]-i,c=u*u+l*l;return h<c?-1:h>c?1:0}));for(let r=0;r<n;r++){const n=a[r];if(n===m||s[n]===s[m]&&i[n]===i[m]||G(s[n],0,1)&&G(i[n],0,1))continue;const o=(s,i,n,r)=>{const o=new Ns,a=new V;a.setWithEps(1);const h=new V;h.set(i,a.eps()),t.queryCoord2DE(h,o);const m=new Ns;t.queryCoord2DE(new V(s),m);let u=!1;return o.eq(m)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new V(n),m),u=o.eq(m)),!u},h=f.getNAN();t.queryCoord2D(s[n],h);const u=f.getNAN();e.queryCoord2D(i[n],u);if(0===f.distance(h,u)&&o(s[m],s[n],i[m],i[n]))break;const l=new D(i[n],i[m]);l.normalizeNoNAN();const c=new D(s[n],s[m]);c.normalizeNoNAN();let d=-1,g=Number.POSITIVE_INFINITY,_=Number.POSITIVE_INFINITY,p=s[n];h.assign(t.getCoord2D(p));for(let r=0;r<5;r++){const r=e.getClosestCoordinateOnInterval(h,l,-1);u.assign(e.getCoord2D(r));const a=f.distance(h,u);if(p=t.getClosestCoordinateOnInterval(u,c,-1),p===s[m]&&r===i[m]){d=1;break}h.assign(t.getCoord2D(p));const x=f.distance(u,h);if(!(x<_&&a<g)){d=0;break}if(0===x&&0===a){o(s[m],s[n],i[m],i[n])?(s[n]=p,i[n]=r,d=0):d=1;break}_=x,g=a}if(-1===d&&(d=G(s[n],0,1)||G(i[n],0,1)?0:1),1!==d)break;s[n]=s[m],i[n]=i[m]}}}function el(t,e,s,i,n,r,o,a,h,m,u,l,c){if(!r)return 0;const d=(t,e)=>{for(let s=0;s<r;++s){let i=e[s];if(G(i,0,1)){i=At(i);continue}const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&Ju(t,0,i)<=ti(t)&&(e[s]=0):n.equals(t.getEndXY())&&Ju(t,i,1)<=ti(t)&&(e[s]=1)}};d(e,i),d(s,n),tl(e,s,i,n,r);const g=[];for(let f=0,x=r;f<x;f++)g.push(f);const _=(t,e)=>c?Tt(n[t],i[t],n[e],i[e]):Tt(i[t],n[t],i[e],n[e]);if(g.length>1){g.sort(_);const t=Math.max(ti(e),ti(s));let r=0;for(let o=1,a=g.length;o<a;o++){const a=i[g[r]],h=i[g[o]],m=n[g[r]],u=n[g[o]];if(a!==h||m!==u)if(!(Ju(e,a,h)<=t&&Ju(s,m,u)<=t)||G(a,0,1)&&G(m,0,1)||G(h,0,1)&&G(u,0,1))r++,g[r]=g[o];else{const t=f.distance(e.getCoord2D(a),s.getCoord2D(m)),i=f.distance(e.getCoord2D(h),s.getCoord2D(u));if(t<=i)continue;if(i<t){g[r]=g[o];continue}}}if(g.length=r+1,1===g.length&&0!==g[0]&&(i[0]=i[g[0]],n[0]=n[g[0]],g[0]=0),g.length>2){const t=D.constructEmpty(),r=D.constructEmpty();t.setCoords(i[g[0]],i[g.at(-1)]),r.setCoords(n[g[0]],n[g.at(-1)]);let o=!0;for(let e=1,s=g.length-1;e<s;e++)if(!t.containsCoordinate(i[g[e]])||!r.containsCoordinate(n[g[e]])){o=!1;break}if(o){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let a=j(t.vmin,t.vmax,i[n]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,m)){o=!1;break}a=j(r.vmin,r.vmax,i[n]);const u=s.getCoord2D(a);if(!e.isCloserThanDistance(u,t,m)){o=!1;break}}}o&&(g[1]=g.at(-1),g.length=2)}}if(1===g.length&&t){const t=0,r=0;Ls(e,s,i[0],n[0],m,1,[t],[r])&&(g.push(1),i[1]=t,n[1]=r,g.sort(_))}if(u&&1===g.length){let t=!0;for(let r=0,o=g.length;r<o;r++){if(G(i[g[r]],0,1)&&G(n[g[r]],0,1)){if(0===f.distance(e.getCoord2D(i[g[r]]),s.getCoord2D(n[g[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let x=0,y=g.length;x<y;x++){if(a&&a.push(i[g[x]]),h&&h.push(n[g[x]]),o){const t=f.getNAN();e.queryCoord2D(i[g[x]],t),o.push(t)}p++}return p}function sl(t,e,s,i,n,r,o,a,h){if(G(s,0,1)&&G(i,0,1)){if(0===f.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new Ns,l=Number.EPSILON;if(t.queryDerivative(new V(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new V(s,l).add(e),u)}1===s&&u.negateThis();const c=new Ns;if(e.queryDerivative(new V(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new V(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const d=u.dotProduct(c),g=u.crossProduct(c);g.scaleError(3);const _=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(gt)&&(g.isZero()||Math.abs(g.value())<_())){return Rs(t,e,s,i,n,r,o,a)}}}return 0}function il(t,e,i,n,r){let o=-1,a=-1,h=-1,m=-1;{const s=[0,e],r=[e,0],u=[0,n],l=[n,0];for(let e=0;e<2&&-1===o;++e)for(let n=0;n<2;++n)if(t[s[e]].equals(i[u[n]])){o=s[e],a=r[e],h=u[n],m=l[n];break}}if(-1===o){const s=new Ds;s.setFromPoints(t,e+1);const o=new Ds;return o.setFromPoints(i,n+1),o.inflate(r),s.isIntersectingW(o)?-1:0}{const u=new Array(e+1),l=Yu(t,e+1,u);s(l>1);let c=0,d=0;for(let t=0;t<l;++t)o===u[t]&&(d=t,c++),a===u[t]&&c++;if(2!==c)return-1;const g=new Array(n+1),_=Yu(i,n+1,g);s(_>1),c=0;let p=0;for(let t=0;t<_;++t)h===g[t]&&(p=t,c++),m===g[t]&&c++;if(2!==c)return-1;const x=t[u[(d+l-1)%l]],y=t[u[(d+1)%l]],P=i[g[(p+_-1)%_]],v=i[g[(p+1)%_]],C=t[o],b=[x,y,P,v],E=[0,1,2,3];E.sort(((t,e)=>f.compareVectorsOrigin(C,b[t],b[e])));let D=E[0];for(let t=1;t<4;t++){if(E[t]!==(D+1)%4)return-1;D=E[t]}{const t=x.sub(C),e=v.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}{const t=y.sub(C),e=P.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}return 1}}var nl=Vt;class rl extends ai{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return s(0),0}calculateUpperLength3D(){return s(0),0}changeEndPoints3D(t,e){s(0)}getClosestCoordinate3D(t,e,i){return s(0),0}getBoundary(){return Vh(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?ui(this,t):li(this,t);const i=nl.getInterpolation(e),n=this.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s);return z(i,n,r,t,nl.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){s(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return rl.type}queryEnvelope(e){if(4===e.m_EnvelopeType){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=qt.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=nl.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else 2===e.m_EnvelopeType?e.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===e.m_EnvelopeType?(e.setEmpty(),e.mergeCoords(this.m_XStart,this.m_YStart,Qs(this,0,1,0)),e.mergeCoords(this.m_XEnd,this.m_YEnd,Qs(this,1,1,0))):t("env type not impl")}applyTransformation(t){s(t instanceof k);const e=new f;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new rl({vd:this.m_description})}calculateLength2D(){return Math.sqrt(wi(this))}calculateLength3D(t){return s(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryCoord2D(t,e){return hi(this,t,e)}queryCoord3D(t,e){s(0)}getCoordZ(t){return ci(this,t)}queryCoord2DE(t,e){gi(this,t,e)}getCoordX(t){return ui(this,t)}getCoordY(t){return li(this,t)}cut(t,e,s){const i=new ol;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const r=f.getNAN();if(hi(this,t,r),n.setStartXYCoords(r.x,r.y),hi(this,e,r),n.setEndXYCoords(r.x,r.y),!i)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),i=nl.getComponentCount(s);for(let r=0;r<i;r++){const i=this.getAttributeAsDbl(t,s,r);n.setStartAttribute(s,r,i);const o=this.getAttributeAsDbl(e,s,r);n.setEndAttribute(s,r,o)}}}queryDerivative(t,e){di(this,t,e)}getClosestCoordinate(t,e){return f.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new f;this.queryCoord2D(e.vmin,i);const n=new f;this.queryCoord2D(e.vmax,n);const r=f.getClosestCoordinate(i,n,t,!1);return ri.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=ui(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(t,e){return s(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new rl;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new f;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=f.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new f;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return bi(this,t,e,s)>=0}isIntersectingPoint3D(t,e,i,n,r=1){return s(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,s){return s&&(t<2&&e(""),s[0]=0,s[1]=1),2}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=ui(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=li(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(e,s){if(2===s.m_EnvelopeType){let t=y(e.vmin,0,1);const i=new f;return this.queryCoord2D(t,i),s.setCoords({pt:i}),t=y(e.vmax,0,1),this.queryCoord2D(t,i),void s.mergeNe(i)}t("3d dst not impl")}orientBottomUp(){fi(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return pi(this,t)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(t,e){_i(this,t[0],t[e-1])}writeInBufferStream(t,e){return s(0),0}readFromBufferStream(t,e){s(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){_i(this,t,e)}static isIntersectingLineLine(t,e,s,i){return xi(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return xi(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return $u(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&i("");const n=bi(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==Uu(!1,this,t,e,s)}}rl.type=n.enumLine;class ol{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new rl,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):a("bad constructor params"))}assignCopy(t){return t instanceof ol?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof ol){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:a("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){s(0)}createImpl(t){switch(t){case n.enumLine:1&this.m_mask||(this.m_lineBuffer=new rl,this.m_mask|=1,this.m_active=1);break;case n.enumEllipticArc:2&this.m_mask||(this.m_curves=new $h,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case n.enumBezier:4&this.m_mask||(this.m_curves=new da,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case n.enumBezier2:8&this.m_mask||(this.m_curves=new an,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case n.enumRationalBezier2:16&this.m_mask||(this.m_curves=new mn,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:e("")}}create(t){t===n.enumLine?this.createLine():t===n.enumEllipticArc?this.createEllipticArc():t===n.enumBezier?this.createCubicBezier():t===n.enumRationalBezier2?this.createQuadraticRationalBezier():t===n.enumBezier2?this.createQuadraticBezier():e("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){s(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(n.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(n.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(n.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(n.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(n.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&a("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():a("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(e){return e instanceof ol?this===e||(this.empty()?e.empty():!e.empty()&&this.get().equals(e.get())):(t("seg comparison not yet impl"),!1)}}export{Ci as $,Jt as A,ge as B,Ae as C,um as D,cs as E,Pe as F,Ni as G,qe as H,Ce as I,_s as J,Ne as K,rl as L,Es as M,Ze as N,Bt as O,hs as P,Vh as Q,jh as R,ol as S,ve as T,Xu as U,Vt as V,Fu as W,Lu as X,Mu as Y,ys as Z,fs as _,qt as a,Ts as a0,tm as a1,Jh as a2,$h as a3,wu as a4,om as a5,Li as a6,Fi as a7,ka as a8,ps as a9,Ot as aA,Ye as aB,Wt as aC,nu as aD,Um as aE,Dm as aF,Xi as aG,jt as aH,Te as aI,zh as aJ,os as aK,Be as aL,qi as aM,ns as aN,Ke as aO,Je as aP,ts as aQ,$e as aR,Qh as aS,Zh as aT,xa as aa,Bn as ab,is as ac,am as ad,mm as ae,da as af,mn as ag,io as ah,hu as ai,ri as aj,$u as ak,Iu as al,Ou as am,ti as an,un as ao,Ns as ap,Nm as aq,fi as ar,Qu as as,Ku as at,sl as au,Nu as av,iu as aw,Qt as ax,Me as ay,Ut as az,Fe as b,Ve as c,qu as d,rm as e,kt as f,Re as g,nm as h,Rh as i,je as j,Oe as k,Ge as l,Se as m,Su as n,We as o,Qe as p,Is as q,_e as r,ee as s,Gt as t,ze as u,He as v,Le as w,Uu as x,$t as y,Ue as z};
|