UNPKG

@arcgis/core

Version:

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

5 lines • 464 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{i as t,t as e,g as s,n,G as i,s as r,u as o,b as a,c as h,f as m,e as u,w as l,h as c,k as g,m as d,o as _,l as p}from"./Geometry.js";import{j as f,k as P,l as y,m as x,r as C,n as v,o as b,O as E,p as S,q as D,t as w,E as A,u as T,V as I,v as M,h as Y,w as X,P as N,A as q,B as F,x as V,y as L,z as R,D as z,F as k,G as B,H as G,S as W,T as j}from"./Envelope.js";import{i as Z,A as H,E as U,d as O,B as Q,P as J,a as K,C as $,b as tt,D as et,F as st,G as nt,H as it,g as rt,q as ot,I as at,J as ht,L as mt,N as ut,c as lt,K as ct,j as gt,O as dt,m as _t,Q as pt,R as ft,T as Pt,U as yt,V as xt,W as Ct,M as vt,X as bt,Y as Et,Z as St,_ as Dt,$ as wt,a0 as At,s as Tt,a1 as It,a2 as Mt,a3 as Yt,a4 as Xt,a5 as Nt,l as qt,a6 as Ft,a7 as Vt,a8 as Lt,a9 as Rt,aa as zt,v as kt,e as Bt,w as Gt,ab as Wt,ac as jt,ad as Zt,ae as Ht,n as Ut,af as Ot,ag as Qt,o as Jt,ah as Kt,ai as $t,u as te,aj as ee,ak as se,al as ne,am as ie,an as re}from"./Point2D.js";import{Envelope2D as oe}from"./Envelope2D.js";import{T as ae}from"./Transformation2D.js";import{G as he}from"./SimpleGeometryCursor.js";class me{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 ue(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 le(t,e,s){if(t)for(let n=e.length-1;n>=0;--n)s(e[n]);else e.forEach(s)}function ce(t,e){let s=H(t);const n=e.length/Z();for(let i=0;i<e.length;++i){const t=Math.trunc(s*n);s=H(s);const i=Math.trunc(s*n),r=e[t];e[t]=e[i],e[i]=r}}function ge(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 de(t,e,s,n,i){$(t,e,n-e,((t,e)=>i(t,e)?-1:1))}function _e(t,e,s){if(!(s<=e))for(;e<s;)t[s]=tt(t[e],t[e]=t[s]),e++,s--}function pe(t,e,s,n){_e(t,e,s-1),_e(t,s,n-1),t.reverse()}function fe(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 Pe=I;const ye="can not assign an empty point to a vertex";class xe{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=f(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new me,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new P,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:f();this.m_description=e,this.m_vertexAttributes=new me,this.m_envelopeData=new P,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=Pe.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,e,s,n,i){this.addAttribute(t),this.isEmpty()||0===s&&1===n||(ue(this.getAttributeStreamRef(t),e,this.getPointCount(),Pe.getComponentCount(t),M(s,n,i)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=y(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=x(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=C(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=f();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&&Pe.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=Pe.getComponentCount(e);i<r;i++){const o=this.m_vertexAttributes.get(n).readAsDbl(r*t+i);s.setAttributeBasic(e,i,o)}}}setPointByVal(t,s){const n=s;n.isEmpty()&&e(ye);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=Pe.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)}setPointByValFromArray(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=Pe.getComponentCount(t);s>=i&&n("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*i+s):Pe.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const r=Pe.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=Pe.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)}setAttribute(t,e,s,i){const r=Pe.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)}setAttributeFromArray(t,e,s,i){(e<0||e>=this.m_pointCount)&&n("");const r=Pe.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)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(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=Y.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=Pe.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 oe||t instanceof v?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=U.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=Pe.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=Pe.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 P({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=Pe.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=n;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 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(),m=new me;if(!this.m_vertexAttributes.empty()){m.destroyAndSetSize(h);for(let t=0;t<h;t++)if(this.m_vertexAttributes.get(t))if(e)m.set(t,this.m_vertexAttributes.get(t));else{const e=Pe.getComponentCount(this.m_description.getSemantics(t));m.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(m),m.destroyAndSetSize(0),n.m_pointCount=this.m_pointCount,n.hasDirtyFlag(32)?(s(!e),n.m_reservedPointCount=-1):n.m_reservedPointCount=n.m_pointCount;try{this.copyToImpl(n,e)}catch(u){throw n.setEmpty(),u}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=O(Pe.maxComponentCount(),Number.NaN),a=O(Pe.maxComponentCount(),Number.NaN),h=b();let m=0;for(let n=0;n<this.m_description.getAttributeCount();n++){const r=this.m_description.getSemantics(n),u=Pe.getInterpolation(r),l=Pe.getComponentCount(r),c=Pe.getDefaultValue(r);this.queryAttributeAsDbl(r,t,o,l),this.queryAttributeAsDbl(r,e,a,l),s(m+l<=E),Q(u,o,a,h,m,l,i,c),m+=l}fe(r,h)}getShortestDistance(t,e){return J.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return J.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=S();D(t,this.m_description,e);const s=new me;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!!(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 n=0;if(null!==this.m_vertexAttributes.get(e)){const i=Pe.getComponentCount(s);n=this.m_vertexAttributes.get(e).size()/i,n<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*i,Pe.getDefaultValue(s)),n=t)}else this.m_vertexAttributes.set(e,w(s,t)),n=t;n<this.m_reservedPointCount&&(this.m_reservedPointCount=n)}}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 A({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=Pe.getComponentCount(e),i=this.m_vertexAttributes.get(t);for(let t=0;t<n;t++){const r=new U;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 P({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=oe.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 oe?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,T(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,T(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=Pe.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(n*s):this.m_vertexAttributes.set(t,T(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 Ce extends xe{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=I.getComponentCount(i);if(0===i)this.m_vertexAttributes.get(e).insert(r*t,s,r*n);else{const s=I.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(r*t,s,r,r*n)}}this.notifyModifiedFlags(2001)}insertPoint(t,s){s.isEmpty()&&e(ye),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=I.getComponentCount(i);if(s.hasAttribute(i))this.m_vertexAttributes.get(e).insertAttributes(r*t,s,i,r*n);else{const s=I.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=I.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=I.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=I.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=I.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=I.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=I.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=I.getDefaultValue(t),i=I.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=I.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let u=0;for(let e=n;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,n,i){s(0)}add(t){t.isEmpty()&&e(ye),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 J(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const n=new Y;n.setCoords(t,e,s),this.setXYZ(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=I.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=I.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),m=new J;for(let e=0;e<r;e++)m.x=t[n+e].x,m.y=t[n+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[n+e].z);this.notifyModifiedFlags(2001)}getGeometryType(){return i.enumMultiPoint}getDimension(){return 0}createInstance(){return new Ce({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){}}Ce.type=i.enumMultiPoint;class ve{constructor(){this.m_EnvelopeType=5,this.envAabb=oe.constructEmpty(),this.envRot=oe.constructEmpty()}static constructEmpty(){return new ve}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:be(t),y:Ee(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(be(t),Ee(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=be(t[n]),s=Ee(t[n]);this.envRot.mergeNeCoords(e,s)}break}{const e=be(t[s]),n=Ee(t[s]);this.envRot.setCoords({x:e,y:n}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(be(t),Ee(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*et();this.envRot.inflateCoords(e,e),e<0&&ve.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 be(t){return t.x-t.y}function Ee(t){return t.x+t.y}class Se{constructor(){this.x=st.getNAN(),this.y=st.getNAN()}static getNAN(){return new Se}static constructPoint2D(t){const e=new Se;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Se;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Se;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 Se).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 Se;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Se;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=nt.clone(),this.y=it.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 J.construct(this.x.value(),this.y.value())}}class De{constructor(){this.a11=new st(1),this.a12=new st(0),this.a21=new st(0),this.a22=new st(1)}clone(){const t=new De;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=tt(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 st(1),i=new st(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new st(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(it)&&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 st(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]=tt(t[0],t[0]=t[1]),e[1]=tt(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var we=I;function Ae(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 Te(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Ie(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),n=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,n}function Me(t,e,n,i,r,o,a,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),l=t,c=e,g=!1;m>u&&(c=tt(l,l=c),i=tt(n,n=i),u=tt(m,m=u),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(J.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 U(0,1),r)){s=!1;break}if(s)return g&&(h[0]=tt(a[0],a[0]=h[0])),1}}if(m<=3*r)return 0;let _=lt(Math.max(r/m,.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 m=c.getCoord2D(n),u=J.distance(e,m);if(0===b&&(x=u),u<=p?(v=.5,P=u,f=_):(y=_,x=u),Math.abs(P-x)>.1*p&&y-f>1e-16)_=ot(f,y,v);else{if(a[C]=t,h[C]=n,g&&(h[C]=tt(a[C],a[C]=h[C])),1===o||1===C)return 1===C&&a[0]>a[1]&&(a[1]=tt(a[0],a[0]=a[1]),h[1]=tt(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 Ye(t,e,s,n,i,r,o,a,h){if(ht(s,0,1)&&ht(n,0,1)){if(0===J.distance(t.getCoord2D(s),e.getCoord2D(n))){const h=1e-12,m=new Se,u=ut();if(t.queryDerivative(new st(s,u),m),m.isTrueZero()){const e=1===s?-1e-12:h;t.queryDerivative(new st(s,u).add(e),m)}1===s&&m.negateThis();const l=new Se;if(e.queryDerivative(new st(n,u),l),l.isTrueZero()){const t=1===s?-1e-12:h;e.queryDerivative(new st(n,u).add(t),l)}1===n&&l.negateThis(),m.isZero()||m.normalize(),l.isZero()||l.normalize();const c=m.dotProduct(l),g=m.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(it)&&(g.isZero()||Math.abs(g.value())<d())){return Me(t,e,s,n,i,r,o,a)}}}return 0}function Xe(t,e,n){if(s(t.isCurve()||e.isCurve()),t.getStartXY().equals(e.getStartXY())){if(Ye(t,e,0,0,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getEndXY())){if(Ye(t,e,1,1,n,2,[0,0],[0,0]))return!0}if(t.getStartXY().equals(e.getEndXY())){if(Ye(t,e,0,1,n,2,[0,0],[0,0]))return!0}if(t.getEndXY().equals(e.getStartXY())){if(Ye(t,e,1,0,n,2,[0,0],[0,0]))return!0}return!1}function Ne(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function qe(t,e,s){t.m_XStart=e,t.m_YStart=s}function Fe(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Ve(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function Le(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 Re(t,e){const s=new Y;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=ze(t,e),s}function ze(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:we.getDefaultValue(1)}function ke(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 Be(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=we.getComponentCount(n);i<r;i++){const r=We(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function Ge(t,e,s){s.isEmpty()&&o(""),Le(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=we.getComponentCount(r);for(let n=0;n<o;n++){je(t,e,r,n,s.getAttributeAsDbl(r,n))}}}function We(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=we.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]:we.getDefaultValue(s)}function je(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=we.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 Ze(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=we.getComponentCount(i);for(let s=0;s<r;s++){let n=We(e,0,i,s);je(t,0,i,s,n),n=We(e,1,i,s),je(t,1,i,s,n)}}}function He(t,e){const s=S();D(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=O(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,m=we.getComponentCount(e.getSemantics(o));for(let e=0;e<m;++e)n[h]=t.m_attributes[s],n[i+h]=t.m_attributes[r+s]}}t.m_attributes=n,t.m_description=e}function Ue(t){return t.absNorm()*rt()}function Oe(t,e){return Math.max(t.absNorm(),e.absNorm())*rt()}function Qe(t,e,s){const n=new ve;t.queryEnvelopeW(U.unit(),n);const i=new ve;return e.queryEnvelopeW(U.unit(),i),i.inflate(s),!n.isIntersectingW(i)}function Je(t,e,s){const n=mt(t,s),i=mt(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 Ke=I;class $e{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:f(),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=f());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=O(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}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=y(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=Ke.getComponentCount(s);for(let i=0;i<n;i++){je(this,0,s,i,t.getAttributeAsDbl(s,i));je(this,1,s,i,e.getAttributeAsDbl(s,i))}}}getStartXY(){return new J(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 Re(this,0)}setStartXYZ(t){ke(this,0,t)}setStartXYZCoords(t,e,s){ke(this,0,Y.construct(t,e,s))}queryStart(t){Be(this,0,t)}setStart(t){Ge(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return We(this,0,t,e)}getStartAttributeAsInt(t,e){return s(0),0}setStartAttribute(t,e,s){je(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=Ke.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=Ke.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 J(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 Re(this,1)}setEndXYZ(t){ke(this,1,t)}setEndXYZCoords(t,e,s){ke(this,1,Y.construct(t,e,s))}queryEnd(t){Be(this,1,t)}setEnd(t){Ge(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return We(this,1,t,e)}getEndAttributeAsInt(t,e){return s(0),Math.trunc(0)}setEndAttribute(t,e,s){je(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=U.constructEmpty();return s.vmin=We(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(We(this,1,t,e)),s}calculateLength3D(t){return s(0),0}getCoord3D(t){return s(0),{}}getCoord2D(t){const e=J.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=Ke.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=oe.constructEmpty();this.queryLooseEnvelopeOnInterval(e,n);if(n.distance(t)>s)return!1;const i=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(i)&&J.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=tt(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=tt(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=Ke.getComponentCount(e);t<s;t++){const s=We(this,0,e,t);je(this,0,e,t,We(this,1,e,t)),je(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=O(9,Number.NaN),r=O(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,m=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=a),null!==n&&(n[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),m=r.length(),m<o&&(o=m,null!==i&&(i[0]=a),null!==n&&(n[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),m=r.length(),m<o&&(o=m,null!==n&&(n[0]=a),null!==i&&(i[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),m=r.length(),m<o&&(o=m,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 ot(t,e,s)}moveTo(t){const e=this.isClosed(),s=new ae;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){He(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=x(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=C(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=f();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=tt(this.m_description,this.m_description=s.m_description),s.m_XStart=tt(this.m_XStart,this.m_XStart=s.m_XStart),s.m_YStart=tt(this.m_YStart,this.m_YStart=s.m_YStart),s.m_XEnd=tt(this.m_XEnd,this.m_XEnd=s.m_XEnd),s.m_YEnd=tt(this.m_YEnd,this.m_YEnd=s.m_YEnd),s.m_attributes=tt(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 n=t;if(this===n)return!0;if(this.m_description!==n.m_description)return!1;if(Math.abs(this.m_XStart-n.m_XStart)>e||Math.abs(this.m_XEnd-n.m_XEnd)>e||Math.abs(this.m_YStart-n.m_YStart)>e||Math.abs(this.m_YEnd-n.m_YEnd)>e)return!1;for(let i=0,r=2*(this.m_description.getTotalComponentCount()-2);i<r;i++)if(!at(this.m_attributes[i],n.m_attributes[i],e))return!1;return s?this.equalsImpl(n):this.equalsImplTol(n,e)}getImpl(){return this}setAttributeBasic(t,s,n){if(this.addAttribute(t),0===t&&this.isCurve()){(s<0||s>1)&&e("");const t=new ae,i=0===s?n:0,r=1===s?n:0;t.setShiftCoords(i,r),0===s?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,s,n),this.setEndAttribute(t,s,n)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Ke.getComponentCount(t);for(let n=0;n<s;n++){const s=this.getStartAttributeAsDbl(t,n);Number.isNaN(s)&&this.setStartAttribute(t,n,e);const i=this.getEndAttributeAsDbl(t,n);Number.isNaN(i)&&this.setEndAttribute(t,n,e)}}}$e.s_maxMonotonicPartParams=8;class ts extends he{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 es{constructor(t){this.m_geoms=[],this.m_description=f(),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()===i.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 i.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=x(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=C(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=f();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new U;const n=new U;n.setEmpty();for(const i of this.m_geoms)s=i.queryInterval(t,e),n.merge(s);return n}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new A;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new oe;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}a("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new oe;t.setEmpty();for(const s of this.m_g