UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

5 lines • 476 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{i as t,a as e,g as s,q as n,G as i,s as r,u as o,t as a,d as h,w as u,f as m,e as l,h as c,n as g,p as d,x as _,j as p,o as f}from"./Geometry.js";import{j as P,k as y,l as x,m as C,r as v,V as b,d as S,n as E,o as D,O as w,p as A,q as T,t as I,E as M,u as Y,v as N,w as X,P as q,x as F,y as V,z as L,D as R,F as z,G as B,S as k,B as G,A as W,T as j,H as Z}from"./Envelope.js";import{E as H,d as U,A as O,P as Q,i as J,b as K,B as $,C as tt,c as et,D as st,F as nt,M as it,q as rt,G as ot,H as at,I as ht,J as ut,g as mt,m as lt,L as ct,N as gt,O as dt,s as _t,K as pt,Q as ft,R as Pt,T as yt,U as xt,V as Ct,W as vt,X as bt,Y as St,Z as Et,_ as Dt,$ as wt,a0 as At,o as Tt,a1 as It,l as Mt,j as Yt,e as Nt,a2 as Xt,a3 as qt,a4 as Ft,a5 as Vt,a6 as Lt,a7 as Rt,a as zt,a8 as Bt,a9 as kt,v as Gt,aa as Wt,ab as jt,w as Zt,ac as Ht,ad as Ut,ae as Ot,n as Qt,af as Jt,ag as Kt,ah as $t,ai as te,aj as ee,u as se,ak as ne,al as ie,am as re,an as oe,ao as ae,ap as he,aq as ue}from"./Point2D.js";import{Envelope2D as me}from"./Envelope2D.js";import{T as le}from"./Transformation2D.js";import{G as ce}from"./SimpleGeometryCursor.js";class ge{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 de(t,s,n,i,r){(s<0||n<0||i<1||s+i*(n-1)+1>t.size())&&e("Index out of bound");for(let e=s,o=s+i*(n-1)+1;e<o;e+=i)t.writeAsDbl(e,r(t.readAsDbl(e)))}function _e(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function pe(t,e){let s=$(t);const n=e.length/J();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=$(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function fe(t,e,s){if(0===t.length)return;let n=0,i=0;for(++i;i!==t.length;++i)e(t[n],t[i])||(s(n,i),n=i);s(n,i)}function Pe(t,e,s,n,i){tt(t,e,n-e,((t,e)=>i(t,e)?-1:1))}function ye(t,e,s){if(!(s<=e))for(;e<s;)t[s]=et(t[e],t[e]=t[s]),e++,s--}function xe(t,e,s,n){ye(t,e,s-1),ye(t,s,n-1),t.reverse()}function Ce(t,e,s){const n=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),K(t.getAttributeArray(),e,0,2,n-2)}var ve=b;const be="can not assign an empty point to a vertex";class Se{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=P(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new ge,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new y,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:P();this.m_description=e,this.m_vertexAttributes=new ge,this.m_envelopeData=new y,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(e,s){if(!t(e.getGeometryType()))return!1;const n=e;if(this===n)return!0;if(!this.m_description.equals(n.getDescription()))return!1;if(this.isEmptyImpl()!==n.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==n.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(e),o=n.getAttributeStreamRef(e),a=ve.getComponentCount(e);if(!r.equals(o,0,i*a,s))return!1}if(s){if(!this.equalsImplTol(e,s))return!1}else if(!this.equalsImpl(e))return!1;return!0}transformAttribute(t,s,n,i,r){if(this.addAttribute(t),!this.isEmpty()&&(0!==n||1!==i)){if(0===t){const t=new le;return 0===r?0===s?(t.setShiftCoords(n,0),t.scale(i,1)):1===s?(t.setShiftCoords(0,n),t.scale(1,i)):e(""):0===s?(t.setScaleCoords(1/i,1),t.shiftCoords(-n,0)):1===s?(t.setScaleCoords(1,1/i),t.shiftCoords(0,-n)):e(""),void this.applyTransformation(t)}de(this.getAttributeStreamRef(t),s,this.getPointCount(),ve.getComponentCount(t),N(n,i,r)),this.notifyModified()}}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=x(e,t);this.assignVertexDescription(s)}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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();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&&ve.getPersistence(t)!==s.getPersistence()&&e(""),this.addAttribute(t);const n=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(n,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 n=0;n<this.m_description.getAttributeCount();n++){const e=this.m_description.getSemantics(n);for(let i=0,r=ve.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByValNoCurves(t,s){const n=s;n.isEmpty()&&e(be);const i=n.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const r=this.m_vertexAttributes.get(0);r.write(2*t,n.getX()),r.write(2*t+1,n.getY());for(let e=1,o=this.m_description.getAttributeCount();e<o;e++){const s=this.m_description.getSemantics(e),i=ve.getComponentCount(s);for(let r=0;r<i;r++){const o=n.getAttributeAsDbl(s,r);this.m_vertexAttributes.get(e).writeAsDbl(t*i+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArrayNoCurves(t,e,n,i){s(0)}getPointByValAsArray(t,e,n,i){s(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=ve.getComponentCount(t);s>=i&&n("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*i+s):ve.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const r=ve.getComponentCount(t);i<r&&n("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,n=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=n.readAsDbl(t+e)}else{const e=ve.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,n,i){s(0)}setAttributeNoCurves(t,e,s,i){const r=ve.getComponentCount(t);s>=r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,i)}setAttributeFromArrayNoCurves(t,e,s,i){(e<0||e>=this.m_pointCount)&&n("");const r=ve.getComponentCount(t);i<r&&n(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let n=0;n<r;++n)a.writeAsDbl(e*r+n,s[n])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXYNoCurves(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoordsNoCurves(t,e,s){const n=this.m_vertexAttributes.get(0);n.write(2*t,e),n.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=S.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=ve.getDefaultValue(1),s}setXYZNoCurves(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 me||t instanceof E?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=H.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 n=!1;const i=ve.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*i;r<a;r+=i){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),n=!0)}}else for(let a=e,h=this.m_pointCount*i;a<h;a+=i){r.readAsDbl(a)!==s&&(r.writeAsDbl(a,s),n=!0)}n&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const n=ve.getComponentCount(t),i=this.getAttributeStreamRef(t);for(let r=0;r<n;r++)if(1===i.getPersistence()){const t=i;for(let i=0,r=this.m_pointCount*n;i<r;i++){const n=t.read(i);Number.isNaN(n)&&(t.write(i,e),s=!0)}}else for(let t=0,o=this.m_pointCount*n;t<o;t++){const n=i.readAsDbl(t);Number.isNaN(n)&&(i.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 y({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&e(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*n,a=2*r,h=0;e<a;e+=2,h++)o.queryPoint2D(e,t[h]);return r}queryCoordinates3D(t,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=ve.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):h;return r}clearAndSetDirtyFlagProtected(t,e){let s=0;const n=t&~e,i=e|n;s=this.m_flags,(s&i)!==e&&(this.m_flags=s&~n|e)}getIsSimple(t,e){e[0]=0;let s=-1;const n=this.m_flags,i=this.m_simpleTolerance;if(!(1&n)){s=(14&n)>>1,e[0]=i,i<t&&(s=-1)}return s}setIsSimple(t,e,n=!1){if(2===t?s(this.getGeometryType()===i.enumPolyline):1===t?s(this.getGeometryType()===i.enumMultiPoint||this.getGeometryType()===i.enumPolyline):3===t&&s(this.getGeometryType()===i.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;n||(s|=16);const i=31;this.clearAndSetDirtyFlagProtected(i,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)&&r("Cannot do shallow clone on unprepared geometry");const n=t,o=this.getGeometryType(),a=n.getGeometryType();s(o===a||o===i.enumPolygon&&a===i.enumPolyline,"failure in copyToUnchcked"),n.clearAccelerators(),n.m_description=this.m_description,n.m_vertexAttributes.destroyAndSetSize(0),n.m_envelopeData.releaseAttributes();const h=this.m_description.getAttributeCount(),u=new ge;if(!this.m_vertexAttributes.empty()){u.destroyAndSetSize(h);for(let t=0;t<h;t++)if(this.m_vertexAttributes.get(t))if(e)u.set(t,this.m_vertexAttributes.get(t));else{const e=ve.getComponentCount(this.m_description.getSemantics(t));u.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,n.m_envelopeData),n.m_flags=this.m_flags,n.m_simpleTolerance=this.m_simpleTolerance,o!==a){const t=[Number.NaN];n.getIsSimple(0,t)>=3?n.setIsSimple(1,t[0]):n.setIsSimple(-1,0)}n.m_vertexAttributes.swap(u),u.destroyAndSetSize(0),n.m_pointCount=this.m_pointCount,n.hasDirtyFlag(32)||n.m_vertexAttributes.empty()?(s(!e||0===n.m_pointCount),n.m_reservedPointCount=-1):n.m_reservedPointCount=n.m_pointCount;try{this.copyToImpl(n,e)}catch(m){throw n.setEmpty(),m}n.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,i,r){(t<0||t>=this.m_pointCount)&&n(""),(e<0||e>=this.m_pointCount)&&n(""),r.assignVertexDescription(this.m_description);const o=U(ve.maxComponentCount(),Number.NaN),a=U(ve.maxComponentCount(),Number.NaN),h=D();let u=0;for(let n=0;n<this.m_description.getAttributeCount();n++){const r=this.m_description.getSemantics(n),m=ve.getInterpolation(r),l=ve.getComponentCount(r),c=ve.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(u+l<=w),O(m,o,a,h,u,l,i,c),u+=l}Ce(r,h)}getShortestDistance(t,e){return Q.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return Q.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=A();T(t,this.m_description,e);const s=new ge;s.destroyAndSetSize(t.getAttributeCount());for(let n=0;n<t.getAttributeCount();n++){const t=e[n];-1!==t?s.set(n,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 0!==(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=-1;let t=Number.MAX_SAFE_INTEGER,e=0;e=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:Math.trunc((4*this.m_pointCount+2)/3);for(let s=0;s<this.m_description.getAttributeCount();s++){const n=this.m_description.getSemantics(s);let i=0;if(null!==this.m_vertexAttributes.get(s)){const t=ve.getComponentCount(n);i=this.m_vertexAttributes.get(s).size()/t,i<this.m_pointCount&&(this.m_vertexAttributes.get(s).resize(e*t,ve.getDefaultValue(n)),i=e)}else this.m_vertexAttributes.set(s,I(n,e)),i=e;i<t&&(t=i)}this.m_reservedPointCount=t}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 M({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),n=ve.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new H;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=i.readAsDbl(e*n+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new y({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=me.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 me?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 n=t=Math.ceil(t);if(this.m_reservedPointCount<n){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),s?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,Y(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*n),n=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,Y(0,n)):this.m_vertexAttributes.get(0).resize(2*n);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),s=ve.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,Y(e,n))}this.reserveImplImpl(n,s),this.m_reservedPointCount=n}}reserveRounded(t){t<0&&e(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&o("")}}class Ee extends Se{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 n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(e).insert(r*t,s,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(be),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(s.getDescription());const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=b.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,i,r*n);else{const s=b.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&n(""),t<0&&(t=this.getPointCount()),0===s)return;const i=e[0].getDescription();this.mergeVertexDescription(i);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let n=0,o=this.m_description.getAttributeCount();n<o;n++){const o=this.m_description.getSemantics(n),a=b.getComponentCount(o);if(this.m_vertexAttributes.get(n))if(i.hasAttribute(o))this.m_vertexAttributes.get(n).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=b.getDefaultValue(o);this.m_vertexAttributes.get(n).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,s,n){if((t>this.getPointCount()||n<0)&&e("invalid point index"),t<0&&(t=this.getPointCount()),0===n)return;const i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+n);for(let e=0,r=this.m_description.getAttributeCount();e<r;e++){const r=this.m_description.getSemantics(e),o=b.getComponentCount(r);if(this.m_vertexAttributes.get(e))if(0===r)this.m_vertexAttributes.get(e).insertRangeFromPoints(o*t,s,0,n,!0,o*i);else{const s=b.getDefaultValue(r);this.m_vertexAttributes.get(e).insertRange(o*t,s,o,o*i)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&n("remove_points"),0!==e){for(let s=0,n=this.m_description.getAttributeCount();s<n;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),i=b.getComponentCount(n);this.m_vertexAttributes.get(s).eraseRange(i*t,i*e,i*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),n=b.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(n*t,n,n*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,n=this.m_description.getAttributeCount();s<n;s++){const t=this.m_description.getSemantics(s),n=b.getDefaultValue(t),i=b.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(i*e,n,i*(this.m_pointCount-e),i*e)}}queryCoordinates3D(t,s,n,i){let r=i<0?this.m_pointCount:i;if(r=Math.min(r,n+s),(n<0||r<n||this.m_pointCount>0&&n>=this.m_pointCount)&&e(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=b.getDefaultValue(1),u=this.m_description.hasAttribute(1);u&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=n;e<r;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=u?a.read(e):h;return r}queryAttributeAsInt(t,e,n,i){s(0)}add(t){t.isEmpty()&&e(be),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByValNoCurves(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new Q(t,e);this.setXYNoCurves(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const n=new S;n.setCoords(t,e,s),this.setXYZNoCurves(this.m_pointCount-1,n)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,s,n){this===t&&e("Multi_point_impl.add");const i=n<0?t.getPointCount():n;if((s<0||s>t.getPointCount()||i<s)&&e(""),s===i)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=i-s,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let e=0,h=this.m_description.getAttributeCount();e<h;e++){const n=this.m_description.getSemantics(e),i=b.getComponentCount(n),h=this.getAttributeStreamRef(n);if(r.hasAttribute(n)){const e=t.getAttributeStreamRef(n);h.insertRangeFromStream(a*i,e,s*i,o*i,!0,1,a*i)}else{const t=b.getDefaultValue(n);h.insertRange(a*i,t,o*i,a*i)}}}addPoints2D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),n===o)return;r=o-n;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[n+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,s,n,i){let r=s;const o=i<0?r:i;if((r<0||n<0||n>r||o<n)&&e(""),this.addAttribute(1),n===o)return;r=o-n;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0),u=new Q;for(let e=0;e<r;e++)u.x=t[n+e].x,u.y=t[n+e].y,h.writePoint2D(2*(a+e),u);const m=this.getAttributeStreamRef(1);for(let e=0;e<r;e++)m.write(a+e,t[n+e].z);this.notifyModifiedFlags(2001)}setPointByVal(t,e){this.setPointByValNoCurves(t,e)}setXY(t,e){this.setXYNoCurves(t,e)}setXYCoords(t,e,s){this.setXYCoordsNoCurves(t,e,s)}setXYZ(t,e){this.setXYZNoCurves(t,e)}setAttribute(t,e,s,n){this.setAttributeNoCurves(t,e,s,n)}getGeometryType(){return i.enumMultiPoint}getDimension(){return 0}createInstance(){return new Ee({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):a("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):a("")}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){}}Ee.type=i.enumMultiPoint;class De{constructor(){this.m_EnvelopeType=5,this.envAabb=me.constructEmpty(),this.envRot=me.constructEmpty()}static constructEmpty(){return new De}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:Te(t),y:Ie(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Te(t),Ie(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let n=s;n<e;n++){const e=Te(t[n]),s=Ie(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=Te(t[s]),n=Ie(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Te(t),Ie(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*st();this.envRot.inflateCoords(e,e),e<0&&De.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()}sqrMaxMinDistance(t){const e=this.envAabb.sqrMaxMinDistance(t),s=this.envRot.sqrMaxMinDistance(Me(t))/2;return Math.max(e,s)}sqrMinDistance(t){const e=this.envAabb.sqrMinDistance(t),s=this.envRot.sqrMinDistance(Me(t))/2;return Math.max(e,s)}sqrMaxDistance(t){const e=this.envAabb.sqrMaxDistance(t),s=this.envRot.sqrMaxDistance(Me(t))/2;return Math.max(e,s)}getEnvelope2D(){return this.envAabb}getRotatedEnvelope2D(){return this.envRot}xyRot(t,e){const s=we(t.x,t.y),n=Ae(t.x,t.y);e.setCoords(s,n)}}function we(t,e){return t-e}function Ae(t,e){return t+e}function Te(t){return t.x-t.y}function Ie(t){return t.x+t.y}function Me(t){return new Q(Te(t),Ie(t))}class Ye{constructor(){this.x=at.getNAN(),this.y=at.getNAN()}static getNAN(){return new Ye}static constructPoint2D(t){const e=new Ye;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ye;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ye;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 Ye).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 Ye;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ye;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=ht.clone(),this.y=ut.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)),n=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),n=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(n),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 Q.construct(this.x.value(),this.y.value())}}class Ne{constructor(){this.a11=new at(1),this.a12=new at(0),this.a21=new at(0),this.a22=new at(1)}clone(){const t=new Ne;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)),n=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),i=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=n,this.a22=i,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),n=this.a21.negate().divThisE(t),i=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=n,this.a22=i}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=et(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let n=new at(1),i=new at(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new at(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(ut)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();i=e.mulE(a),n.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else n=new at(1/Math.sqrt(2)),i=n.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=n.toDouble(),e[0].y=i.toDouble(),e[1].x=i.negate().toDouble(),e[1].y=n.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=et(t[0],t[0]=t[1]),e[1]=et(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}class Xe{static constructPoint2D(t){return new Xe(it.constructDouble(t.x),it.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new it).setNAN(),void(this.y=(new it).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 Q(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 Xe(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new Xe(this.x.add(t.x),this.y.add(t.y))}sub(t){return new Xe(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)}subThis(t){return this.x.subThis(t.x),this.y.subThis(t.y),this}addThis(t){return this.x.addThis(t.x),this.y.addThis(t.y),this}}var qe=b;function Fe(t){let e=!1;for(let s=0;s<2;s++){const n=nt(t[0][s],t[3][s]);n>0?(nt(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),nt(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):n<0?(nt(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),nt(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),nt(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),nt(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),nt(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 Ve(t){const e=nt(t[0].y,t[1].y),s=nt(t[1].y,t[2].y),n=nt(t[2].y,t[3].y);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0){const e=nt(t[0].x,t[1].x),s=nt(t[1].x,t[2].x),n=nt(t[2].x,t[3].x);if(e>=0&&s>=0&&n>=0||e<=0&&s<=0&&n<=0)return!0}return!1}function Le(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const n=t.getEndXY();return!!n.equals(e.getStartXY())||!!n.equals(e.getEndXY())}function Re(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function ze(t,e,s){const n=lt(Q,4);let r=t.queryControlPointsHelper(n);const o=lt(Q,4);let a=e.queryControlPointsHelper(o);n[0].equals(o[0])||u("");const h=t.getGeometryType();if(h===e.getGeometryType()&&n.map(((t,e)=>o[e].equals(t))).reduce(((t,e)=>t&&e))){if(h!==i.enumRationalBezier2)return 0;{const s=e,n=[0,0,0],i=[0,0,0];if(t.queryWeights(n),s.queryWeights(i),n.map(((t,e)=>i[e]===t)).reduce(((t,e)=>t&&e)))return 0}}for(;r>2&&n[1].equals(n[0]);)n.splice(1,1),r--;for(;a>2&&o[1].equals(o[0]);)o.splice(1,1),a--;(n[1].equals(n[0])||o[1].equals(n[0]))&&u("");const m=Q.compareVectorsOrigin(n[0],n[1],o[1]);if(0===m){const s=Xe.constructPoint2D(n[0]),i=new Xe;t.queryCoord2DMP(1e-16,i),i.sub(s);const r=new Xe;e.queryCoord2DMP(1e-16,r),r.sub(s);return r.crossProduct(i).sign()}return m}function Be(t,e,n,i,r,o,a,h){let u=t.calculateUpperLength2D(),m=e.calculateUpperLength2D(),l=t,c=e,g=!1;u>m&&(c=et(l,l=c),i=et(n,n=i),m=et(u,u=m),g=!0);const d=0===n;{a[0]=d?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(Q.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let n=0;n<e.length;n++)if(t.assign(l.getCoord2D(e[n])),!c.isCloserThanDistance(t,new H(0,1),r)){s=!1;break}if(s)return g&&(h[0]=et(a[0],a[0]=h[0])),1}}if(u<=3*r)return 0;let _=_t(Math.max(r/u,.1),0,.5),p=.01*r,f=0,P=0,y=_,x=-1,C=0,v=1/32;for(let b=0;;b++){s(b<4095);const t=d?_:1-_,e=l.getCoord2D(t),n=c.getClosestCoordinate(e,!1);if(n===i)return C;const u=c.getCoord2D(n),m=Q.distance(e,u);if(0===b&&(x=m),m<=p?(v=.5,P=m,f=_):(y=_,x=m),Math.abs(P-x)>.1*p&&y-f>1e-16)_=rt(f,y,v);else{if(a[C]=t,h[C]=n,g&&(h[C]=et(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=et(a[0],a[0]=a[1]),h[1]=et(h[0],h[0]=h[1])),C+1;C++,f=y,P=x,y=.8,x=-1,_=.8,v=1/32,p=10*r,b=0}}}function ke(t,e,s,n,i,r,o,a,h){if(gt(s,0,1)&&gt(n,0,1)){if(0===Q.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,u=new Ye,m=dt();if(t.queryDerivative(new at(s,m),u),u.isTrueZero()){const e=1===s?-1e-12:h;t.queryDerivative(new at(s,m).add(e),u)}1===s&&u.negateThis();const l=new Ye;if(e.queryDerivative(new at(n,m),l),l.isTrueZero()){const t=1===s?-1e-12:h;e.queryDerivative(new at(n,m).add(t),l)}1===n&&l.negateThis(),u.isZero()||u.normalize(),l.isZero()||l.normalize();const c=u.dotProduct(l),g=u.crossProduct(l);g.scaleError(3);const d=()=>{{const s=t.calculateUpperLength2D(),n=e.calculateUpperLength2D();return Math.min(.01*i/Math.min(s,n),1e-10)}};if(c.ge(ut)&&(g.isZero()||Math.abs(g.value())<d())){return Be(t,e,s,n,i,r,o,a)}}}return 0}function Ge(t,e,n){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(ke(t,e,0,0,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(ke(t,e,1,1,n,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(ke(t,e,0,1,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(ke(t,e,1,0,n,2,[0,0],[0,0]))return!0}return!1}function We(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function je(t,e,s){t.m_XStart=e,t.m_YStart=s}function Ze(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function He(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Ue(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 Oe(t,e){const s=new S;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=Qe(t,e),s}function Qe(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:qe.getDefaultValue(1)}function Je(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 Ke(t,e,s){s.assignVertexDescription(t.m_description);const n=0===e?t.m_XStart:t.m_XEnd,i=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(n,i);for(let r=1;r<t.m_description.getAttributeCount();r++){const n=t.m_description.getSemantics(r);for(let i=0,r=qe.getComponentCount(n);i<r;i++){const r=ts(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function $e(t,e,s){s.isEmpty()&&o(""),Ue(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=qe.getComponentCount(r);for(let n=0;n<o;n++){es(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function ts(t,e,s,i){if((e<0||e>1)&&n(""),0===s)return(i<0||i>=2)&&n(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const r=qe.getComponentCount(s);(i<0||i>=r)&&n("");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+i]:qe.getDefaultValue(s)}function es(t,e,s,i,r){if((e<0||e>1)&&n(""),0===s)return 0===e?0===i?t.m_XStart=r:1===i?t.m_YStart=r:n(""):1===e?0===i?t.m_XEnd=r:1===i?t.m_YEnd=r:n(""):n(""),void t.endPointModified();const o=qe.getComponentCount(s);(i<0||i>=o)&&n("");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+i]=r}function ss(t,e){if(t===e)return;e.isEmpty()&&o("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let n=1,i=s.getAttributeCount();n<i;n++){const i=s.getSemantics(n),r=qe.getComponentCount(i);for(let s=0;s<r;s++){let n=ts(e,0,i,s);es(t,0,i,s,n),n=ts(e,1,i,s),es(t,1,i,s,n)}}}function ns(t,e){const s=A();T(e,t.m_description,s);let n=null;const i=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(i>0&&(n=U(2*i,Number.NaN),K(n,e.getDefaultPointAttributes(),0,2,i),K(n,e.getDefaultPointAttributes(),i,2,i),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,u=qe.getComponentCount(e.getSemantics(o));for(let e=0;e<u;++e)n[h]=t.m_attributes[s],n[i+h]=t.m_attributes[r+s]}}t.m_attributes=n,t.m_description=e}function is(t){return t.absNorm()*mt()}function rs(t,e){return Math.max(t.absNorm(),e.absNorm())*mt()}function os(t,e,s){const n=new De;t.queryEnvelopeW(H.unit(),n);const i=new De;return e.queryEnvelopeW(H.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function as(t,e,s){const n=ct(t,s),i=ct(e,s);n.sort(((t,e)=>t.compare(e))),i.sort(((t,e)=>t.compare(e)));for(let r=0;r<3;r++){if(n[r].compare(i[r])<0)return-1;if(0!==n[r].compare(i[r]))return 1}return 0}var hs=b;class us{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:P(),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:X(),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=P());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:X(),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]);h("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=U(2*t,Number.NaN)),K(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),K(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return a("not implemented"),0}queryWeights(t){}snapControlPoints3D(){return a("not implemented"),!1}setCoordsForIntersector3D(t,e,s){a("not implemented")}transformAttribute(t,e,s,n,i){a("")}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=x(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),n=e.getXY();this.changeEndPoints2D(s,n);let i=t.getDescription();i!==this.getDescription()&&this.mergeVertexDescription(i),i=e.getDescription(),i!==this.getDescription()&&this.mergeVertexDescription(i);for(let r=1,o=i.getAttributeCount();r<o;r++){const s=i.getSemantics(r),n=hs.getComponentCount(s);for(let i=0;i<n;i++){es(this,0,s,i,t.getAttributeAsDbl(s,i));es(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new Q(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 Oe(this,0)}setStartXYZ(t){Je(this,0,t)}setStartXYZCoords(t,e,s){Je(this,0,S.construct(t,e,s))}queryStart(t){Ke(this,0,t)}setStart(t){$e(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return ts(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){es(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=hs.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,n)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let n=e&&s.hasZ()?2:1,i=s.getAttributeCount();n<i;++n){const e=s.getSemantics(n),i=hs.getComponentCount(e);for(let s=0;s<i;++s){const n=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,n)}}}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 Q(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 Oe(this,1)}setEndXYZ(t){Je(this,1,t)}setEndXYZCoords(t,e,s){Je(this,1,S.construct(t,e,s))}queryEnd(t){Ke(this,1,t)}setEnd(t){$e(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return ts(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){es(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&&K(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=H.constructEmpty();return s.vmin=ts(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(ts(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=Q.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,n=this.m_description.getAttributeCount();s<n;s++){const n=this.m_description.getSemantics(s),i=hs.getComponentCount(n);for(let s=0;s<i;s++){const i=this.getAttributeAsDbl(t,n,s);e.setAttributeBasic(n,s,i)}}}isCloserThanDistance(t,e,s){const n=me.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&Q.distance(t,this.getCoord2D(i))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=et(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=et(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=hs.getComponentCount(e);t<s;t++){const s=ts(this,0,e,t);es(this,0,e,t,ts(this,1,e,t)),es(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,n,i){if(!e&&this.isIntersecting(t,0,!1)){if(null!==n||null!==i){const e=U(9,Number.NaN),r=U(9,Number.NaN),o=this.intersect(t,null,e,r,0);s(o<=9),0===o&&h(""),null!==n&&(n[0]=e[0]),null!==i&&(i[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,a=-1,u=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==i&&(i[0]=a),null!==n&&(n[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),u=r.length(),u<o&&(o=u,null!==n&&(n[0]=a),null!==i&&(i[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 rt(t,e,s)}moveTo(t){const e=this.isClosed(),s=new le;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){ns(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=C(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=v(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=P();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=et(this.m_description,this.m_description=s.m_description),s.m_XStart=et(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=et(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=et(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=et(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attribute