1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[68733],{81320:(t,e,i)=>{i.d(e,{$:()=>sa,A:()=>sW,B:()=>sN,C:()=>rn,D:()=>sc,E:()=>s9,F:()=>sy,H:()=>tc,I:()=>m,J:()=>function t(e,i){if(e.isEmpty())return!1;let r=e.getGeometryType();if(r===i8.enumPolygon)return 0!==e.calculateArea2D();if(r===i8.enumPolyline)return i9(e.getImpl(),i,!0).bNotEmpty;if(r===i8.enumEnvelope)return!0;if((0,s.f)(r))return!!e.isClosed();if((0,s.e)(r))return!1;if(r===i8.enumGeometryCollection){for(let s=0,r=e.getGeometryCount();s<r;s++)if(t(e.getGeometry(s),i))return!0;return!1}(0,s.b)("")},K:()=>function t(e,i,r,o,a,l,h,m){l&&(l.length=0),h&&(h.length=0);let u=e.getGeometryType();if(u===s.G.enumLine)return l&&(l.push(e.getStartXY()),l.push(n.P.getNAN()),l.push(n.P.getNAN()),l.push(e.getEndXY())),h&&(h.push(0),h.push(1)),1;if(u===s.G.enumBezier){if(!o)return l&&(l.push(e.getStartXY()),l.push(e.getControlPoint1()),l.push(e.getControlPoint2()),l.push(e.getEndXY())),h&&(h.push(0),h.push(1)),1;let t=(0,n.d)(9,NaN),i=e.getMonotonicPartParams(t.length,t);if(t.length=i,2===(i=sd(e,r,t))&&a&&(t[1]=.5,t.push(1),i=3),h&&h.splice(0,0,...t.slice(0,i)),l){let s=new ry;for(let r=1;r<i;r++){let i=t[r-1],n=t[r];e.queryCut(i,n,s,!0);let o=s.get();iT(o),1===r&&l.push(o.getStartXY()),l.push(o.getControlPoint1()),l.push(o.getControlPoint2()),l.push(o.getEndXY())}}return i-1}if(u===s.G.enumEllipticArc){if(e.isDegenerateToLine()||e.isDegenerate(0))return l&&(l.push(e.getStartXY()),l.push(n.P.getNAN()),l.push(n.P.getNAN()),l.push(e.getEndXY())),h&&(h.push(0),h.push(1)),1;if(o&&(a||!e.isMonotoneQuickAndDirty())){let t=(0,n.d)(6,NaN),m=e.getMonotonicPartParams(t.length,t);t.length=m,2===(m=sd(e,r,t))&&a&&(t[1]=.5,t.push(1),m=3);let u=0;if(m>2){let n=new ry,a=h||[],g=0;for(let c=1;c<m;c++){let d=t[g],_=t[c];if(e.queryCut(d,_,n,!0),n.get().isDegenerate(0))continue;let p=a.length,f=s_(1===c,n.get(),i,r,o,l,h);(0,s.g)(f>0),u+=f;let P=c===m-1,y=t[g],x=n.get().getSweepAngle()/e.getSweepAngle();for(let t=p,i=a.length;t<i;t++)if(a[t]=!P||t+1<i?y+a[t]*x:1,l){let i=3*t,s=e.getCoord2D(a[t]);l[i].setCoordsPoint2D(s),i>0&&iI(l.slice(i-3))}g=c}return u}}return s_(!0,e,i,r,o,l,h)}if(u===s.G.enumRationalBezier2){if(o&&(a||!e.isMonotoneQuickAndDirty())){let t=(0,n.d)(6,NaN),s=e.getMonotonicPartParams(t.length,t);t.length=s,2===(s=sd(e,r,t))&&a&&(t[1]=.5,t.push(1),s=3);let o=0;if(s>2){let n=new ry,a=h||[];for(let m=1;m<s;m++){let u=t[m-1],g=t[m];e.queryCut(u,g,n,!0);let c=a.length;o+=sp(1===m,n.get(),i,r,!1,l,h);let d=m===s-1,_=t[m-1];for(let t=c,i=a.length;t<i;t++)if(a[t]=!d||t+1<i?_+a[t]:1,l){let i=3*t,s=e.getCoord2D(a[t]);l[i].setCoordsPoint2D(s),i>0&&e8(l.slice(i-3))}}return o}}return sp(!0,e,i,r,o,l,h)}if(u===s.G.enumBezier2){let s=(0,n.m)(n.P,3);e.queryControlPoints(s);let m=new im;return m.constructFromQuadratic(s),t(m,i,r,o,a,l,h)}(0,s.b)("")},L:()=>rP,M:()=>_,N:()=>sg,O:()=>eF,P:()=>i6,Q:()=>tY,R:()=>sU,S:()=>ry,T:()=>B,U:()=>tm,V:()=>tu,W:()=>y,X:()=>L,Y:()=>tX,Z:()=>sS,_:()=>rl,a:()=>sm,a0:()=>rg,a1:()=>s8,a2:()=>rh,a3:()=>sr,a4:()=>tt,a5:()=>rm,a6:()=>ru,a7:()=>r_,a8:()=>s7,b:()=>ss,c:()=>i7,d:()=>su,e:()=>rs,f:()=>rt,g:()=>Z,i:()=>ri,l:()=>sh,n:()=>s5,s:()=>u,x:()=>t4,y:()=>im,z:()=>sB});var s=i(99383),r=i(42379),n=i(46253),o=i(7561),a=i(15756),l=i(59515);class h{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=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 m(t,e,i){if(t)for(let t=e.length-1;t>=0;--t)i(e[t]);else e.forEach(i)}function u(t,e){let i=(0,n.A)(t),s=e.length/(0,n.i)();for(let t=0;t<e.length;++t){let t=Math.trunc(i*s),r=Math.trunc((i=(0,n.A)(i))*s),o=e[t];e[t]=e[r],e[r]=o}}var g=r.V;let c="can not assign an empty point to a vertex";class d{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=(0,r.j)(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new h,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new r.k,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{let e=void 0!==t&&t.vd?t.vd:(0,r.j)();this.m_description=e,this.m_vertexAttributes=new h,this.m_envelopeData=new r.k,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!(0,s.i)(t.getGeometryType()))return!1;if(this===t)return!0;
1if(!this.m_description.equals(t.getDescription())||this.isEmptyImpl()!==t.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;let i=this.getPointCount();if(i!==t.getPointCount())return!1;for(let s=0;s<this.m_description.getAttributeCount();s++){let r=this.m_description.getSemantics(s),n=this.getAttributeStreamRef(r),o=t.getAttributeStreamRef(r),a=g.getComponentCount(r);if(!n.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,i,n,o){this.addAttribute(t),this.isEmpty()||0===i&&1===n||(function(t,e,i,r,n){(e<0||i<0||r<1||e+r*(i-1)+1>t.size())&&(0,s.t)("Index out of bound");for(let s=e,o=e+r*(i-1)+1;s<o;s+=r)t.writeAsDbl(s,n(t.readAsDbl(s)))}(this.getAttributeStreamRef(t),e,this.getPointCount(),g.getComponentCount(t),(0,r.v)(i,n,o)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.l)(e,t);this.assignVertexDescription(i)}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;let e=(0,r.m)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.j)();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,s.t)("AttributeStream : Geometry does not have the attribute");let e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,s.t)("stream"),e&&g.getPersistence(t)!==e.getPersistence()&&(0,s.t)(""),this.addAttribute(t);let i=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(i,e),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){e.assignVertexDescription(this.m_description);for(let i=0;i<this.m_description.getAttributeCount();i++){let s=this.m_description.getSemantics(i);for(let r=0,n=g.getComponentCount(s);r<n;r++){let o=this.m_vertexAttributes.get(i).readAsDbl(n*t+r);e.setAttributeBasic(s,r,o)}}}setPointByVal(t,e){e.isEmpty()&&(0,s.t)(c);let i=e.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);let r=this.m_vertexAttributes.get(0);r.write(2*t,e.getX()),r.write(2*t+1,e.getY());for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),r=g.getComponentCount(s);for(let n=0;n<r;n++){let o=e.getAttributeAsDbl(s,n);this.m_vertexAttributes.get(i).writeAsDbl(t*r+n,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(t,e,i,r){(0,s.g)(0)}getPointByValAsArray(t,e,i,r){(0,s.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,i){let r=g.getComponentCount(t);i>=r&&(0,s.n)("");let n=this.m_description.getAttributeIndex(t);return n>=0?this.m_vertexAttributes.get(n).readAsDbl(e*r+i):g.getDefaultValue(t)}queryAttributeAsDbl(t,e,i,r){let n=g.getComponentCount(t);r<n&&(0,s.n)("");let o=this.m_description.getAttributeIndex(t);if(o>=0){let t=e*n,s=this.m_vertexAttributes.get(o);for(let e=0;e<n;e++)i[e]=s.readAsDbl(t+e)}else{let e=g.getDefaultValue(t);for(let t=0;t<n;t++)i[t]=e}}getAttributeAsInt(t,e,i){return Math.trunc(this.getAttributeAsDbl(t,e,i))}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}setAttribute(t,e,i,r){let n=g.getComponentCount(t);i>=n&&(0,s.n)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*n+i,r)}setAttributeFromArray(t,e,i,r){(e<0||e>=this.m_pointCount)&&(0,s.n)("");let n=g.getComponentCount(t);r!==n&&(0,s.n)(""),this.addAttribute(t);let o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);let a=this.m_vertexAttributes.get(o);for(let t=0;t<n;++t)a.writeAsDbl(e*n+t,i[t])}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,i){let s=this.m_vertexAttributes.get(0);
1s.write(2*t,e),s.write(2*t+1,i),this.notifyModifiedFlags(2001)}getXYZ(t){let e=this.m_vertexAttributes.get(0),i=r.h.getNAN();return i.x=e.read(2*t),i.y=e.read(2*t+1),this.m_description.hasAttribute(1)?i.z=this.m_vertexAttributes.get(1).read(t):i.z=g.getDefaultValue(1),i}setXYZ(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);let i=this.m_vertexAttributes.get(0);i.write(2*t,e.x),i.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o.J||t instanceof r.n?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){let i=n.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,i)),i}setAttributeBasic(t,e,i){this.setAttributeImpl(t,e,i)}setAttributeImpl(t,e,i){if(this.addAttribute(t),this.isEmpty())return;let s=!1,r=g.getComponentCount(t),n=this.getAttributeStreamRef(t),o=Number.isNaN(i);if(1===n.getPersistence())for(let t=e,a=this.m_pointCount*r;t<a;t+=r){let e=n.read(t);(o||e===i)&&Number.isNaN(e)||(n.write(t,i),s=!0)}else for(let t=e,o=this.m_pointCount*r;t<o;t+=r)n.readAsDbl(t)!==i&&(n.writeAsDbl(t,i),s=!0);s&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=!1,s=g.getComponentCount(t),r=this.getAttributeStreamRef(t);for(let t=0;t<s;t++)if(1===r.getPersistence())for(let t=0,n=this.m_pointCount*s;t<n;t++)Number.isNaN(r.read(t))&&(r.write(t,e),i=!0);else for(let t=0,n=this.m_pointCount*s;t<n;t++)Number.isNaN(r.readAsDbl(t))&&(r.writeAsDbl(t,e),i=!0);i&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,s.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||
1(0,s.t)(""),this.m_envelopeData=new r.k({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,s.t)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.t)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0);for(let e=2*i,s=2*n,r=0;e<s;e+=2,r++)o.queryPoint2D(e,t[r]);return n}queryCoordinates3D(t,e,i,r){let n=r<0?this.m_pointCount:r;if(n=Math.min(n,i+e),(i<0||n<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.t)(""),0===this.m_pointCount)return n;let o=this.getAttributeStreamRef(0),a=null,l=g.getDefaultValue(1),h=this.m_description.hasAttribute(1);h&&(a=this.getAttributeStreamRef(1));let m=0;for(let e=i;e<n;e++,m++)t[m].x=o.read(2*e),t[m].y=o.read(2*e+1),t[m].z=h?a.read(e):l;return n}clearAndSetDirtyFlagProtected(t,e){let i=0,s=t&~e;((i=this.m_flags)&(e|s))!==e&&(this.m_flags=i&~s|e)}getIsSimple(t,e){e[0]=0;let i=-1,s=this.m_flags,r=this.m_simpleTolerance;return!(1&s)&&(i=(14&s)>>1,e[0]=r,r<t&&(i=-1)),i}setIsSimple(t,e,i=!1){if(2===t?(0,s.g)(this.getGeometryType()===s.G.enumPolyline):1===t?(0,s.g)(this.getGeometryType()===s.G.enumMultiPoint||this.getGeometryType()===s.G.enumPolyline):3===t&&(0,s.g)(this.getGeometryType()===s.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let s=t<<1;i||(s|=16),this.clearAndSetDirtyFlagProtected(31,s),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();let 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)&&(0,s.s)("Cannot do shallow clone on unprepared geometry");let i=this.getGeometryType(),r=t.getGeometryType();(0,s.g)(i===r||i===s.G.enumPolygon&&r===s.G.enumPolyline,"failure in copyToUnchcked"),t.clearAccelerators(),t.m_description=this.m_description,t.m_vertexAttributes.destroyAndSetSize(0),t.m_envelopeData.releaseAttributes();let n=this.m_description.getAttributeCount(),o=new h;if(!this.m_vertexAttributes.empty()){o.destroyAndSetSize(n);for(let t=0;t<n;t++)if(this.m_vertexAttributes.get(t))if(e)o.set(t,this.m_vertexAttributes.get(t));else{let e=g.getComponentCount(this.m_description.getSemantics(t));o.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,t.m_envelopeData),t.m_flags=this.m_flags,t.m_simpleTolerance=this.m_simpleTolerance,i!==r){let e=[NaN];t.getIsSimple(0,e)>=3?t.setIsSimple(1,e[0]):t.setIsSimple(-1,0)}t.m_vertexAttributes.swap(o),o.destroyAndSetSize(0),t.m_pointCount=this.m_pointCount,t.hasDirtyFlag(32)?((0,s.g)(!e),t.m_reservedPointCount=-1):t.m_reservedPointCount=t.m_pointCount;try{this.copyToImpl(t,e)}catch(e){throw t.setEmpty(),e}t.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()){let t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,i,o){(t<0||t>=this.m_pointCount)&&(0,s.n)(""),(e<0||e>=this.m_pointCount)&&(0,s.n)(""),o.assignVertexDescription(this.m_description);let a=(0,n.d)(g.maxComponentCount(),NaN),l=(0,n.d)(g.maxComponentCount(),NaN),h=(0,r.o)(),m=0;for(let o=0;o<this.m_description.getAttributeCount();o++){let u=this.m_description.getSemantics(o),c=g.getInterpolation(u),d=g.getComponentCount(u),_=g.getDefaultValue(u);this.queryAttributeAsDbl(u,t,a,d),this.queryAttributeAsDbl(u,e,l,d),(0,s.g)(m+d<=r.O),(0,n.B)(c,a,l,h,m,d,i,_),m+=d}let u=o.getDescription().getTotalComponentCount();o.setX(h[0]),o.setY(h[1]),(0,n.a)(o.getAttributeArray(),h,0,2,u-2)}getShortestDistance(t,e){return n.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return n.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,s.t)(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;let e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){let e=(0,r.p)();(0,r.q)(t,this.m_description,e);let i=new h;i.destroyAndSetSize(t.getAttributeCount());for(let s=0;s<t.getAttributeCount();s++){let t=e[s];-1!==t?i.set(s,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}i.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}
1notifyModifiedAllImpl(){}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++){let i=this.m_description.getSemantics(e),s=0;if(null!==this.m_vertexAttributes.get(e)){let r=g.getComponentCount(i);(s=this.m_vertexAttributes.get(e).size()/r)<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*r,g.getDefaultValue(i)),s=t)}else this.m_vertexAttributes.set(e,(0,r.t)(i,t)),s=t;s<this.m_reservedPointCount&&(this.m_reservedPointCount=s)}}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);let e=this.updateXYImpl(t),i=new r.E({vd:this.m_description});i.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=g.getComponentCount(e),r=this.m_vertexAttributes.get(t);for(let t=0;t<s;t++){let o=new n.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){let i=r.readAsDbl(e*s+t);o.mergeCoordinate(i)}i.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new r.k({moveEnv:i}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){let e=o.J.constructEmpty(),i=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(i,0,this.m_pointCount),e}updateEnvelope3D(t){(0,s.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o.J?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,e){if(t<0&&(0,s.t)(""),0===t)return;let i=t=Math.ceil(t);if(this.m_reservedPointCount<i){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,(0,r.u)(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*i),i=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,(0,r.u)(0,i)):this.m_vertexAttributes.get(0).resize(2*i);for(let t=1;t<this.m_description.getAttributeCount();t++){let e=this.m_description.getSemantics(t),s=g.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(i*s):this.m_vertexAttributes.set(t,(0,r.u)(e,i))}this.reserveImplImpl(i,e),this.m_reservedPointCount=i}}reserveRounded(t){t<0&&(0,s.t)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,s.u)("")}}class _ extends d{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,e){t>this.getPointCount()&&(0,s.t)("invalid point index"),t<0&&(t=this.getPointCount());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(s).insert(o*t,e,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,s.t)(c),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());let i=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let s=0,n=this.m_description.getAttributeCount();s<n;s++){let n=this.m_description.getSemantics(s),o=r.V.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(s).insertAttributes(o*t,e,n,o*i);else{let e=r.V.getDefaultValue(n);this.m_vertexAttributes.get(s).insertRange(o*t,e,o,o*i)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.n)(""),t<0&&(t=this.getPointCount()),0===i)return;let n=e[0].getDescription();this.mergeVertexDescription(n);let o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,a=this.m_description.getAttributeCount();s<a;s++){let a=this.m_description.getSemantics(s),l=r.V.getComponentCount(a);if(this.m_vertexAttributes.get(s))if(n.hasAttribute(a))this.m_vertexAttributes.get(s).insertAttributesFromPoints(t*l,e,i,a,o*l);else{let e=r.V.getDefaultValue(a);this.m_vertexAttributes.get(s).insertRange(l*t,e,l*i,l*o)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,i){if((t>this.getPointCount()||i<0)&&(0,s.t)("invalid point index"),t<0&&(t=this.getPointCount()),0===i)return;let n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+i);for(let s=0,o=this.m_description.getAttributeCount();s<o;s++){let o=this.m_description.getSemantics(s),a=r.V.getComponentCount(o);if(this.m_vertexAttributes.get(s))if(0===o)this.m_vertexAttributes.get(s).insertRangeFromPoints(a*t,e,0,i,!0,a*n);else{let e=r.V.getDefaultValue(o);this.m_vertexAttributes.get(s).insertRange(a*t,e,a,a*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,s.n)("remove_points"),0!==e){for(let i=0,s=this.m_description.getAttributeCount();i<s;i++)if(this.m_vertexAttributes.get(i)){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s);this.m_vertexAttributes.get(i).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,i=this.m_description.getAttributeCount();e<i;e++)if(this.m_vertexAttributes.get(e)){let i=this.m_description.getSemantics(e),s=r.V.getComponentCount(i);this.m_vertexAttributes.get(e).eraseRange(s*t,s,s*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){let e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=r.V.getDefaultValue(i),n=r.V.getComponentCount(i);this.m_vertexAttributes.get(t).insertRange(n*e,s,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,e,i,n){let o=n<0?this.m_pointCount:n;if(o=Math.min(o,i+e),(i<0||o<i||this.m_pointCount>0&&i>=this.m_pointCount)&&(0,s.t)(""),0===this.m_pointCount)return o;let a=this.getAttributeStreamRef(0),l=null,h=r.V.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(l=this.getAttributeStreamRef(1));let u=0;for(let e=i;e<o;e++,u++)t[u].x=a.read(2*e),t[u].y=a.read(2*e+1),t[u].z=m?l.read(e):h;return o}queryAttributeAsInt(t,e,i,r){(0,s.g)(0)}add(t){t.isEmpty()&&(0,s.t)(c),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let i=new n.P(t,e);this.setXY(this.m_pointCount-1,i)}addXYZ(t,e,i){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);let s=new r.h;
1s.setCoords(t,e,i),this.setXYZ(this.m_pointCount-1,s)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,i){this===t&&(0,s.t)("Multi_point_impl.add");let n=i<0?t.getPointCount():i;if((e<0||e>t.getPointCount()||n<e)&&(0,s.t)(""),e===n)return;let o=t.getDescription();this.mergeVertexDescription(o);let a=n-e,l=this.m_pointCount;this.resizeNoInit(this.m_pointCount+a);for(let i=0,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=r.V.getComponentCount(s),h=this.getAttributeStreamRef(s);if(o.hasAttribute(s)){let i=t.getAttributeStreamRef(s);h.insertRangeFromStream(l*n,i,e*n,a*n,!0,1,l*n)}else{let t=r.V.getDefaultValue(s);h.insertRange(l*n,t,a*n,l*n)}}}addPoints2D(t,e,i,r){let n=e,o=r<0?n:r;if((n<0||i<0||i>n||o<i)&&(0,s.t)(""),i===o)return;n=o-i;let a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+n);let l=this.getAttributeStreamRef(0);for(let e=0;e<n;++e)l.writePoint2D(2*(a+e),t[i+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,i,r){let o=e,a=r<0?o:r;if((o<0||i<0||i>o||a<i)&&(0,s.t)(""),this.addAttribute(1),i===a)return;o=a-i;let l=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);let h=this.getAttributeStreamRef(0),m=new n.P;for(let e=0;e<o;e++)m.x=t[i+e].x,m.y=t[i+e].y,h.writePoint2D(2*(l+e),m);let u=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)u.write(l+e,t[i+e].z);this.notifyModifiedFlags(2001)}getGeometryType(){return s.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new _({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty()||t.isIdentity())return;let e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,s.b)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===s.G.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):(0,s.b)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){let t=this.createInstance();return this.copyTo(t),t}swap(t){(0,s.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}_.type=s.G.enumMultiPoint;class p{constructor(){this.m_EnvelopeType=5,this.envAabb=o.J.constructEmpty(),this.envRot=o.J.constructEmpty()}static constructEmpty(){return new p}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:f(t),y:P(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(f(t),P(t))}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let i=0;i<e;){if(!this.envRot.isEmpty()){for(let s=i;s<e;s++){let e=f(t[s]),i=P(t[s]);this.envRot.mergeNeCoords(e,i)}break}{let e=f(t[i]),s=P(t[i]);this.envRot.setCoords({x:e,y:s}),i++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(f(t),P(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){let e=this.envAabb.intersect(t.envAabb),i=this.envRot.intersect(t.envRot);return e&&!i&&this.envAabb.setEmpty(),i&&!e&&this.envRot.setEmpty(),e&&i}inflate(t){this.envAabb.inflateCoords(t,t);let e=t*(0,n.D)();this.envRot.inflateCoords(e,e),e<0&&p.st_reduceEmpty(this)}static st_reduceEmpty(t){let e=t.envAabb.isEmpty(),i=t.envRot.isEmpty();e&&!i?t.envRot.setEmpty():i&&!e&&t.envAabb.setEmpty()}}function f(t){return t.x-t.y}function P(t){return t.x+t.y}class y{constructor(){this.x=n.F.getNAN(),this.y=n.F.getNAN()}static getNAN(){return new y}static constructPoint2D(t){let e=new y;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){let i=new y;return i.x.set(t),i.y.set(e),i}static constructCoordsE(t,e){let i=new y;
1return i.setCoordsE(t,e),i}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 y).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(){let t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){let e=new y;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){let e=new y;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(){let t=this.length();0===t.value()?(this.x=n.G.clone(),this.y=n.H.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){let i=this.x.mulE(t).subThisE(this.y.mulE(e)),s=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),this}rotateReverse(t,e){let i=this.x.mulE(t).addThisE(this.y.mulE(e)),s=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(i),this.y.setE(s),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 n.P.construct(this.x.value(),this.y.value())}}class x{constructor(){this.a11=new n.F(1),this.a12=new n.F(0),this.a21=new n.F(0),this.a22=new n.F(1)}clone(){let t=new x;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){let e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),i=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),s=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),r=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=i,this.a21=s,this.a22=r,this}mulLeftThis(t){let e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){let t=this.det();if(0!==t.value()){let e=this.a22.divE(t),i=this.a12.negate().divThisE(t),s=this.a21.negate().divThisE(t),r=this.a11.divE(t);this.a11=e,this.a12=i,this.a21=s,this.a22=r}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=(0,n.b)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){let i=this.a12.clone();i.addThisE(this.a21),i.mulThisByPower2(.5);let s=new n.F(1),r=new n.F(0);if(i.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{let e=new n.F(1);if(this.a11.ne(this.a22)){let o=this.a11.subE(this.a22).divE(i);o.mulThisByPower2(.5);let a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(n.H)&&e.negateThis();let l=e.sqr().addThis(1).sqrtThis().invThis();r=e.mulE(l),s.setE(l);let h=e.mulE(i);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else r=(s=new n.F(1/Math.sqrt(2))).clone(),t[0]=this.a11.addE(i),t[1]=this.a22.subE(i)}e[0].x=s.toDouble(),e[0].y=r.toDouble(),e[1].x=r.negate().toDouble(),e[1].y=s.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,n.b)(t[0],t[0]=t[1]),e[1]=(0,n.b)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var v=r.V;function C(t,e){let i=t.getStartXY();if(i.equals(e.getStartXY())||i.equals(e.getEndXY()))return!0;let s=t.getEndXY();return!!s.equals(e.getStartXY())||!!s.equals(e.getEndXY())}function b(t,e){let i=t.calculateLowerLength2D();return!(i>e)&&(!!t.isLine()||(i=t.calculateUpperLength2D())<=e||0!==e&&t.calculateLength2D()<=e)}function E(t,e){let i=t.getEndXY().sub(t.getStartXY()).length(),s=t.calculateUpperLength2D()-i<=e[0];return e[0]*=.1,s}function S(t,e,i,r,o,a,l,h){let m=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),g=t,c=e,d=!1;m>
1u&&(c=(0,n.b)(g,g=c),r=(0,n.b)(i,i=r),u=(0,n.b)(m,m=u),d=!0);let _=0===i;{l[0]=+!!_;let t=g.getCoord2D(l[0]);h[0]=c.getClosestCoordinate(t,!1);let e=c.getCoord2D(h[0]);if(n.P.distance(t,e)<=o){let e=[.5,.75,.25,.1,.9],i=!0;for(let s=0;s<e.length;s++)if(t.assign(g.getCoord2D(e[s])),!c.isCloserThanDistance(t,new n.E(0,1),o)){i=!1;break}if(i)return d&&(h[0]=(0,n.b)(l[0],l[0]=h[0])),1}}if(m<=3*o)return 0;let p=(0,n.c)(Math.max(o/m,.1),0,.5),f=.01*o,P=0,y=0,x=p,v=-1,C=0,b=1/32;for(let t=0;;t++){(0,s.g)(t<4095);let e=_?p:1-p,i=g.getCoord2D(e),m=c.getClosestCoordinate(i,!1);if(m===r)return C;let u=c.getCoord2D(m),E=n.P.distance(i,u);if(0===t&&(v=E),E<=f?(b=.5,y=E,P=p):(x=p,v=E),Math.abs(y-v)>.1*f&&x-P>1e-16)p=(0,n.q)(P,x,b);else{if(l[C]=e,h[C]=m,d&&(h[C]=(0,n.b)(l[C],l[C]=h[C])),1===a||1===C)return 1===C&&l[0]>l[1]&&(l[1]=(0,n.b)(l[0],l[0]=l[1]),h[1]=(0,n.b)(h[0],h[0]=h[1])),C+1;C++,P=x,y=v,x=.8,v=-1,p=.8,b=1/32,f=10*o,t=0}}}function D(t,e,i,s,r,o,a,l,h){if((0,n.J)(i,0,1)&&(0,n.J)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let h=new y,m=(0,n.N)();if(t.queryDerivative(new n.F(i,m),h),h.isTrueZero()){let e=1===i?-1e-12:1e-12;t.queryDerivative(new n.F(i,m).add(e),h)}1===i&&h.negateThis();let u=new y;if(e.queryDerivative(new n.F(s,m),u),u.isTrueZero()){let t=1===i?-1e-12:1e-12;e.queryDerivative(new n.F(s,m).add(t),u)}1===s&&u.negateThis(),h.isZero()||h.normalize(),u.isZero()||u.normalize();let g=h.dotProduct(u),c=h.crossProduct(u);if(c.scaleError(3),g.ge(n.H)&&(c.isZero()||Math.abs(c.value())<Math.min(.01*r/Math.min(t.calculateUpperLength2D(),e.calculateUpperLength2D()),1e-10)))return S(t,e,i,s,r,o,a,l)}return 0}function w(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function A(t,e,i){t.m_XStart=e,t.m_YStart=i}function T(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function I(t,e,i){t.m_XEnd=e,t.m_YEnd=i}function M(t,e){var i,s;let n=new r.h;return e?(n.x=t.m_XEnd,n.y=t.m_YEnd):(n.x=t.m_XStart,n.y=t.m_YStart),i=t,s=e,n.z=i.m_description.hasZ()?i.m_attributes[s*(i.m_description.getTotalComponentCount()-2)]:v.getDefaultValue(1),n}function Y(t,e,i){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===i.x&&t.m_YEnd===i.y||(t.m_XEnd=i.x,t.m_YEnd=i.y,t.endPointModified()):t.m_XStart===i.x&&t.m_YStart===i.y||(t.m_XStart=i.x,t.m_YStart=i.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=i.z}function X(t,e,i){i.assignVertexDescription(t.m_description);let s=0===e?t.m_XStart:t.m_XEnd,r=0===e?t.m_YStart:t.m_YEnd;i.setXYCoords(s,r);for(let s=1;s<t.m_description.getAttributeCount();s++){let r=t.m_description.getSemantics(s);for(let s=0,n=v.getComponentCount(r);s<n;s++){let n=F(t,e,r,s);i.setAttributeBasic(r,s,n)}}}function q(t,e,i){var r;i.isEmpty()&&(0,s.u)(""),r=i.getXY(),e?t.m_XEnd===r.x&&t.m_YEnd===r.y||(t.m_XEnd=r.x,t.m_YEnd=r.y,t.endPointModified()):t.m_XStart===r.x&&t.m_YStart===r.y||(t.m_XStart=r.x,t.m_YStart=r.y,t.endPointModified());let n=i.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let s=1,r=n.getAttributeCount();s<r;s++){let r=n.getSemantics(s),o=v.getComponentCount(r);for(let s=0;s<o;
1s++)N(t,e,r,s,i.getAttributeAsDbl(r,s))}}function F(t,e,i,r){if((e<0||e>1)&&(0,s.n)(""),0===i)return(r<0||r>=2)&&(0,s.n)(""),0===e?0===r?t.m_XStart:t.m_YStart:0===r?t.m_XEnd:t.m_YEnd;let n=v.getComponentCount(i);(r<0||r>=n)&&(0,s.n)("");let o=t.m_description.getAttributeIndex(i);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+r]:v.getDefaultValue(i)}function N(t,e,i,r,n){if((e<0||e>1)&&(0,s.n)(""),0===i)return 0===e?0===r?t.m_XStart=n:1===r?t.m_YStart=n:(0,s.n)(""):1===e?0===r?t.m_XEnd=n:1===r?t.m_YEnd=n:(0,s.n)(""):(0,s.n)(""),void t.endPointModified();let o=v.getComponentCount(i);(r<0||r>=o)&&(0,s.n)("");let a=t.m_description.getAttributeIndex(i);a<0&&(t.addAttribute(i),a=t.m_description.getAttributeIndex(i)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+r]=n}function V(t,e){if(t===e)return;e.isEmpty()&&(0,s.u)("");let i=e.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let s=1,r=i.getAttributeCount();s<r;s++){let r=i.getSemantics(s),n=v.getComponentCount(r);for(let i=0;i<n;i++){let s=F(e,0,r,i);N(t,0,r,i,s),s=F(e,1,r,i),N(t,1,r,i,s)}}}function L(t){return t.absNorm()*(0,n.g)()}function R(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,n.g)()}function z(t,e,i){let s=new p;t.queryEnvelopeW(n.E.unit(),s);let r=new p;return e.queryEnvelopeW(n.E.unit(),r),r.inflate(i),!s.isIntersectingW(r)}function G(t,e,i){let s=(0,n.L)(t,i),r=(0,n.L)(e,i);s.sort((t,e)=>t.compare(e)),r.sort((t,e)=>t.compare(e));for(let t=0;t<3;t++){if(0>s[t].compare(r[t]))return -1;if(0!==s[t].compare(r[t]))return 1}return 0}var k=r.V;class B{constructor(t){if(t.copy)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:(0,r.j)(),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:(0,r.w)(),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=(0,r.j)());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:(0,r.w)(),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]);(0,s.c)("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=NaN}}setDefaultAttributeValues(){let t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,n.d)(2*t,NaN)),(0,n.a)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,n.a)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,s.b)("not implemented"),0}snapControlPoints3D(){return(0,s.b)("not implemented"),!1}setCoordsForIntersector3D(t,e,i){(0,s.b)("not implemented")}transformAttribute(t,e,i,r,n){(0,s.b)("")}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.l)(e,t);this.assignVertexDescription(i)}changeEndPoints(t,e){let i=t.getXY(),s=e.getXY();this.changeEndPoints2D(i,s);let r=t.getDescription();r!==this.getDescription()&&this.mergeVertexDescription(r),(r=e.getDescription())!==this.getDescription()&&this.mergeVertexDescription(r);for(let i=1,s=r.getAttributeCount();i<s;i++){let s=r.getSemantics(i),n=k.getComponentCount(s);for(let i=0;i<n;i++)N(this,0,s,i,t.getAttributeAsDbl(s,i)),N(this,1,s,i,e.getAttributeAsDbl(s,i))}}getStartXY(){return new n.P(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 M(this,0)}setStartXYZ(t){Y(this,0,t)}setStartXYZCoords(t,e,i){Y(this,0,r.h.construct(t,e,i))}queryStart(t){X(this,0,t)}setStart(t){q(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return F(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,s.g)(0),0}setStartAttribute(t,e,i){N(this,0,t,e,i)}setStartAttributesFromPoint(t,e){let i=t.getDescription();for(let s=e&&i.hasZ()?2:1,r=i.getAttributeCount();s<r;++s){let e=i.getSemantics(s),r=k.getComponentCount(e);for(let i=0;i<r;++i){let s=t.getAttributeAsDbl(e,i);this.setStartAttribute(e,i,s)}}}setEndAttributesFromPoint(t,e){let i=t.getDescription();for(let s=e&&i.hasZ()?2:1,r=i.getAttributeCount();s<r;++s){let e=i.getSemantics(s),r=k.getComponentCount(e);for(let i=0;i<r;++i){let s=t.getAttributeAsDbl(e,i);this.setEndAttribute(e,i,s)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,s.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,s.g)(0),0}getEndXY(){return new n.P(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 M(this,1)}setEndXYZ(t){Y(this,1,t)}setEndXYZCoords(t,e,i){Y(this,1,r.h.construct(t,e,i))}queryEnd(t){X(this,1,t)}setEnd(t){q(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return F(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,s.g)(0),Math.trunc(0)}setEndAttribute(t,e,i){N(this,1,t,e,i)}getDimension(){return 1}copyTo(t){this!==t&&(t.getGeometryType()!==this.getGeometryType()&&(0,s.t)(""),t.assignVertexDescription(this.m_description),t.m_attributes&&(0,n.a)(t.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,this.copyToImpl(t))}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){let i=n.E.constructEmpty();return i.vmin=F(this,0,t,e),i.vmax=i.vmin,i.mergeNeCoordinate(F(this,1,t,e)),i}calculateLength3D(t){return(0,s.g)(0),0}getCoord3D(t){return(0,s.g)(0),{}}getCoord2D(t){let e=n.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){return(0,s.g)(0),0}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),r=k.getComponentCount(s);for(let i=0;i<r;i++){let r=this.getAttributeAsDbl(t,s,i);e.setAttributeBasic(s,i,r)}}}isCloserThanDistance(t,e,i){let s=o.J.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,s),s.distance(t)>i)return!1;let r=this.getClosestCoordinateOnInterval(t,e,i);return!Number.isNaN(r)&&n.P.distance(t,this.getCoord2D(r))<=i}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){let t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t);for(let t=0,i=k.getComponentCount(e);t<i;t++){let i=F(this,0,e,t);N(this,0,e,t,F(this,1,e,t)),N(this,1,e,t,i)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,i,r){if(!e&&this.isIntersecting(t,0,!1)){if(null!==i||null!==r){let e=(0,n.d)(9,NaN),o=(0,n.d)(9,NaN),a=this.intersect(t,null,e,o,0);(0,s.g)(a<=9),0===a&&(0,s.c)(""),null!==i&&(i[0]=e[0]),null!==r&&(r[0]=o[0])}return 0}let o,a=Number.MAX_VALUE,l=-1,h=a;return o=this.getStartXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),(h=o.length())<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=0)),o=this.getEndXY(),l=t.getClosestCoordinate(o,!1),o.subThis(t.getCoord2D(l)),(h=o.length())<a&&(a=h,null!==r&&(r[0]=l),null!==i&&(i[0]=1)),o=t.getStartXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),(h=o.length())<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=0)),o=t.getEndXY(),l=this.getClosestCoordinate(o,!1),o.subThis(this.getCoord2D(l)),(h=o.length())<a&&(a=h,null!==i&&(i[0]=l),null!==r&&(r[0]=1)),a}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}
1static recalculateParentT(t,e,i){return(0,n.q)(t,e,i)}moveTo(t){let e=this.isClosed(),i=new a.T;i.setShift(t.sub(this.getStartXY())),this.applyTransformation(i),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,s.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){let i=(0,r.p)();(0,r.q)(e,t.m_description,i);let s=null,o=e.getTotalComponentCount()-2,a=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(o>0&&(s=(0,n.d)(2*o,NaN),(0,n.a)(s,e.getDefaultPointAttributes(),0,2,o),(0,n.a)(s,e.getDefaultPointAttributes(),o,2,o),null!==t.m_description))for(let r=1;r<e.getAttributeCount();r++){let n=i[r];if(-1!==n){let i=t.m_description.getPointAttributeOffset(n)-2,l=e.getPointAttributeOffset(r)-2,h=v.getComponentCount(e.getSemantics(r));for(let e=0;e<h;++e)s[l]=t.m_attributes[i],s[o+l]=t.m_attributes[a+i]}}t.m_attributes=s,t.m_description=e}(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;let e=(0,r.m)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.j)();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){this!==t&&(t.getGeometryType()!==this.getGeometryType()&&(0,s.t)("wrong geometry type"),t.m_description=(0,n.b)(this.m_description,this.m_description=t.m_description),t.m_XStart=(0,n.b)(this.m_XStart,this.m_XStart=t.m_XStart),t.m_YStart=(0,n.b)(this.m_YStart,this.m_YStart=t.m_YStart),t.m_XEnd=(0,n.b)(this.m_XEnd,this.m_XEnd=t.m_XEnd),t.m_YEnd=(0,n.b)(this.m_YEnd,this.m_YEnd=t.m_YEnd),t.m_attributes=(0,n.b)(this.m_attributes,this.m_attributes=t.m_attributes),this.swapImpl(t))}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;let i=void 0===e;if(i&&(e=0),this===t)return!0;if(this.m_description!==t.m_description||Math.abs(this.m_XStart-t.m_XStart)>e||Math.abs(this.m_XEnd-t.m_XEnd)>e||Math.abs(this.m_YStart-t.m_YStart)>e||Math.abs(this.m_YEnd-t.m_YEnd)>e)return!1;for(let i=0,s=2*(this.m_description.getTotalComponentCount()-2);i<s;i++)if(!(0,n.I)(this.m_attributes[i],t.m_attributes[i],e))return!1;return i?this.equalsImpl(t):this.equalsImplTol(t,e)}getImpl(){return this}setAttributeBasic(t,e,i){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,s.t)("");let t=new a.T,r=0===e?i:0,n=1===e?i:0;t.setShiftCoords(r,n),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,i),this.setEndAttribute(t,e,i)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let i=k.getComponentCount(t);for(let s=0;s<i;s++)Number.isNaN(this.getStartAttributeAsDbl(t,s))&&this.setStartAttribute(t,s,e),Number.isNaN(this.getEndAttributeAsDbl(t,s))&&this.setEndAttribute(t,s,e)}}B.s_maxMonotonicPartParams=8;class W extends l.G{constructor(t,e){super(),this.m_index=-1,this.gc=t,this.dim=e}next(){for(;!(this.m_index>=this.gc.getGeometryCount())&&(this.m_index++,this.m_index!==this.gc.getGeometryCount());){let 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 j{constructor(t){this.m_geoms=[],this.m_description=(0,r.j)(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,s.t)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===s.G.enumGeometryCollection)for(let e=0,i=t.getGeometryCount();e<i;e++)this.addGeometry(t.getGeometry(e));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)&&(0,s.t)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return s.G.enumGeometryCollection}getDimension(){let t=0;for(let 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(let 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;let e=(0,r.m)(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;let e=(0,r.r)(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){let t=(0,r.j)();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let i=new n.E,s=new n.E;for(let r of(s.setEmpty(),this.m_geoms))i=r.queryInterval(t,e),s.merge(i);return s}queryEnvelope(t){if(4===t.m_EnvelopeType){let e=new r.E;for(let i of(t.setEmpty(),t.assignVertexDescription(this.m_description),this.m_geoms))i.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){let e=new o.J;
1for(let i of(t.setEmpty(),this.m_geoms))i.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,s.b)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){let e=new o.J;for(let i of(t.setEmpty(),this.m_geoms))i.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,s.b)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(let e of this.m_geoms)e.applyTransformation(t);(0,s.b)("3d xform not impl")}transformAttribute(t,e,i,s,r){for(let n of this.m_geoms)n.transformAttribute(t,e,i,s,r)}createInstance(){return new j({vd:this.getDescription()})}copyTo(t){if(t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.t)(""),t!==this)for(let e of(t.m_geoms.length=0,t.assignVertexDescription(this.m_description),this.m_geoms))t.m_geoms.push(e.clone())}calculateArea2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){let t=new n.K(0);for(let e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,s.g)(0),0}getBoundary(){let t=this.createInstance();for(let e of this.m_geoms){let i=e.getBoundary();i&&t.m_geoms.push(i)}return t}clone(){return new j({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==s.G.enumGeometryCollection||this.m_description!==t.m_description||this.m_geoms.length!==t.m_geoms.length)return!1;for(let i=0;i<this.m_geoms.length;++i)if(!this.m_geoms[i].equals(t.m_geoms[i],e))return!1;return!0}swap(t){t.getGeometryType()!==s.G.enumGeometryCollection&&(0,s.t)(""),t!==this&&(this.m_geoms=(0,n.b)(t.m_geoms,t.m_geoms=this.m_geoms))}setAttributeBasic(t,e,i){for(let s of this.m_geoms)s.setAttributeBasic(t,e,i)}replaceNaNs(t,e){for(let i of this.m_geoms)i.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){let e=this.getDescription(),i=(0,r.l)(e,t);this.assignVertexDescription(i)}}function Z(t,e=-1){return new W(t,e)}j.type=s.G.enumGeometryCollection;class H extends B{constructor(t){super(t)}}class U extends H{isTrue3D(){return!0}constructor(t){super(t)}}function O(t,e,i){var s,r,o,a;s=e,r=t.getStartXY(),o=t.getEndXY(),a=i,(0,n.Z)(r,o,s,a)}function J(t,e){return(0,n.q)(t.m_XStart,t.m_XEnd,e)}function Q(t,e){return(0,n.q)(t.m_YStart,t.m_YEnd,e)}function K(t,e,i){.5>=e.value()?(0,n.a1)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,i):(0,n.a2)(2,y.constructPoint2D(t.getStartXY()),y.constructPoint2D(t.getEndXY()),e,i)}function $(t,e,i){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,t.afterCompletedModification()}function tt(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,n.b)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,n.b)(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,i=t.m_description.getTotalComponentCount()-2;e<i;e++)t.m_attributes[e+i]=(0,n.b)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+i])}}function te(t,e,i,s){let r=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(r++,!s))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(2==++r)return 2;if(!s)return 1}return e.isIntersectingPoint(t.getStartXY(),i,!0)||e.isIntersectingPoint(t.getEndXY(),i,!0)||t.isIntersectingPoint(e.getStartXY(),i,!0)||t.isIntersectingPoint(e.getEndXY(),i,!0)?4:s&&r?0:4*!!function(t,e){let i=tr(t,e.m_XStart,e.m_YStart),s=tr(t,e.m_XEnd,e.m_YEnd);if(i<0&&s<0||i>0&&s>0)return!1;let r=tr(e,t.m_XStart,t.m_YStart),n=tr(e,t.m_XEnd,t.m_YEnd);return(!(r<0)||!(n<0))&&(!(r>0)||!(n>0))&&(ta(t)>ta(e)?to(t,e):to(e,t))}(t,e)}function ti(t,e,i,s,r,o,a,l){null!==s&&(0,n.w)(s,2,NaN),null!==r&&(0,n.w)(r,2,NaN),null!==i&&(0,n.ab)(i,n.P,2);let h=function(t,e,i,s,r,o,a,l,h){let m=ts(t,e.getStartXY(),a,!1),u=ts(t,e.getEndXY(),a,!1),g=ts(e,t.getStartXY(),a,!1),c=ts(e,t.getEndXY(),a,!1),d=0,_=0;if(!Number.isNaN(m)){let i=!1;l&&(0,n.J)(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(d++,i=!0),i||(r&&(r[_]=m),o&&(o[_]=0),s&&s[_].setCoords(e.m_XStart,e.m_YStart),_++)}if(!Number.isNaN(u)){let i=!1;l&&(0,n.J)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,i=!0),i||(2>_&&(r&&(r[_]=u),o&&(o[_]=1),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(2!==_&&!Number.isNaN(g)&&(0!==m||0!==g)&&(0!==u||1!==g)){let a=!1;l&&(0,n.J)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getStartXY())&&(d++,a=!0),a||(i>_&&(r&&(r[_]=0),o&&(o[_]=g),s&&s[_].setCoords(t.m_XStart,t.m_YStart)),_++)}if(2!==_&&!Number.isNaN(c)&&(1!==m||0!==c)&&(1!==u||1!==c)){let a=!1;l&&(0,n.J)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(d++,a=!0),a||(i>_&&(r&&(r[_]=1),o&&(o[_]=c),s&&s[_].setCoords(e.m_XEnd,e.m_YEnd)),_++)}if(_>0)return h&&(o=(0,n.b)(r,r=o)),2===_&&i>=2&&r&&r[0]>r[1]&&(r[1]=(0,n.b)(r[0],r[0]=r[1]),o&&(o[1]=(0,n.b)(o[0],o[0]=o[1])),s&&(s[1]=(0,n.b)(s[0],s[0]=s[1]))),_;if(d>0)return 0;
1let p=function(t,e,i){let s=t.m_XEnd-t.m_XStart,r=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,l=o*r-s*a;if(0===l)return n.P.getNAN();let h=4*(0,n.N)()*(Math.abs(o*r)+Math.abs(s*a)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,g=o*u-m*a,c=4*(0,n.N)()*(Math.abs(o*u)+Math.abs(m*a)),d=g/l,_=Math.abs(l),p=(c*_+h*Math.abs(g))/(l*l)+(0,n.N)()*Math.abs(d);if(d<-p||d>1+p)return n.P.getNAN();let f=s*u-m*r,P=f/l,y=(4*(0,n.N)()*(Math.abs(s*u)+Math.abs(m*r))*_+h*Math.abs(f))/(l*l)+(0,n.N)()*Math.abs(P);if(P<-y||P>1+y)return n.P.getNAN();let x=(0,n.c)(d,0,1),v=(0,n.c)(P,0,1),C=n.P.getNAN();O(t,x,C);let b=n.P.getNAN();if(O(e,v,b),!i||n.P.distance(C,b)>i){let s=n.P.getNAN();(0,n.Z)(C,b,.5,s),x=t.getClosestCoordinate(s,!1),v=e.getClosestCoordinate(s,!1);let r=n.P.getNAN();O(t,x,r);let o=n.P.getNAN();if(O(e,v,o),r.subThis(o),r.length()>Math.max(i,(t.absNorm()+e.absNorm())*(0,n.g)()))return n.P.getNAN()}return new n.P(x,v)}(t,e,a);return Number.isNaN(p.x)?0:(s&&(s[0]=t.getCoord2D(p.x)),r&&(r[0]=p.x),o&&(o[0]=p.y),1)}(t,e,2,i,s,r,o,a,l);return s&&(s.length=h),r&&(r.length=h),i&&(i.length=h),h}function ts(t,e,i,s){let r=n.P.getNAN(),o=n.P.getNAN(),a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(r.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(r.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));let l=+!!a,h=+!a,m=n.P.getNAN();m.setSub(e,r);let u=m.length(),g=3*u*(0,n.N)();if(u<=Math.max(i,g))return s&&0===u?NaN:l;if(m.setSub(e,o),g=3*(u=m.length())*(0,n.N)(),u<=Math.max(i,g))return s&&0===u?NaN:h;m.setCoords(o.x-r.x,o.y-r.y);let c=m.length();if(c>0){let t=1/c;m.scale(t);let s=n.P.getNAN();s.setSub(e,r);let u=s.dotProduct(m),g=8*s.dotProductAbs(m)*(0,n.N)();m.leftPerpendicularThis();let _=s.dotProduct(m),p=8*s.dotProductAbs(m)*(0,n.N)(),f=Math.max(i,g);if(u<-f||u>c+f)return NaN;if(Math.abs(_)<=Math.max(i,p)){var d;let s=u*t;s=(0,n.c)(s,0,1);let m=n.P.getNAN();if(d=s,(0,n.Z)(r,o,d,m),n.P.distance(m,e)<=i){if(s<.5){if(n.P.distance(m,r)<=i&&n.P.distance(e,r)<=i)return l}else if(n.P.distance(m,o)<=i&&n.P.distance(e,o)<=i)return h;return a?1-s:s}}}return NaN}function tr(t,e,i){let s=n.P.getNAN();s.setCoords(e,i),s.subThis(t.getStartXY());let r=n.P.getNAN();r.setSub(t.getEndXY(),t.getStartXY());let o=r.crossProduct(s),a=4*(0,n.N)()*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?-1:+(o<-a)}function tn(t,e,i,s){let r=s?t.m_XStart:t.m_XEnd,o=s?t.m_YStart:t.m_YEnd,a=n.P.getNAN();return a.x=e.getEndX()-r,a.y=e.getEndY()-o,!(i.dotProduct(a)>3*(0,n.N)()*i.dotProductAbs(a))||(a.x=e.getStartX()-r,a.y=e.getStartY()-o,i.dotProduct(a)<=3*(0,n.N)()*i.dotProductAbs(a))}function to(t,e){let i=n.P.getNAN();return i.x=t.m_XEnd-t.m_XStart,i.y=t.m_YEnd-t.m_YStart,!!tn(t,e,i,!1)&&(i.negateThis(),!!tn(t,e,i,!0))}function ta(t){let e=t.m_XStart-t.m_XEnd,i=t.m_YStart-t.m_YEnd;return e*e+i*i}class tl{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&(0,s.n)("");let e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&(0,s.n)("");let e=+!t.parent.isClosedPath(t.pathIndex);t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,s.n)(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream
1=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&(0,s.n)(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,s.m)(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){let i;if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){let e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}i=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=i+1,this.m_currentPathIndex=i,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(i),this.m_segmentCount=this.getSegmentCount(i),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,s.n)("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&(0,s.n)(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;let e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!=(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&(0,s.n)(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&(0,s.n)(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class th{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,s.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){let t=new th;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0==--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,s.g)(this.uniqueUse())}setQuadTree(t){(0,s.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,s.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function tm(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon)&&!(20>t.getPointCount())}function tu(t){return!(t.isEmpty()||t.getGeometryType()!==s.G.enumPolyline&&t.getGeometryType()!==s.G.enumPolygon)&&!(20>t.getPointCount())}function tg(t){let e=t.getGeometryType();return e===s.G.enumEllipticArc?10:e===s.G.enumBezier?4:e===s.G.enumRationalBezier2?5:e===s.G.enumBezier2?2:void(0,s.c)("")}function tc(t){let e=31&t;return 4===e?10:2===e?4:8===e?5:2*(16===e)}function td(t,e,i,r){let o=4*(0,n.N)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,n.N)();if(1===t.getMaxDerivative()){(0,s.g)(i>0);let a=tP(t,0,e,(0,n.N)(),o);return r[0]=a.root,a.cRoots}let l,h=[],m=new n.E(e.vmin-o,e.vmax+o);h.push(new n.P(m.vmin,m.vmax));let u=0;for(let m=t.getMaxDerivative()-1;m>=0;m--){l=h,h=[];for(let g=0,c=l.length;g<c;g++){if(l[g][0]<l[g][1]){let c,d,_;if(m===t.getMaxDerivative()-1?{root:c,funcAtRoot:d,cRoots:_}=tP(t,m,n.E.construct(l[g][0],l[g][1]),a,.5*o):{root:c,funcAtRoot:d,cRoots:_}
1=function(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=t.getValue(e,l),m=i.vmax,u=t.getValue(e,m);if(h>=0&&u>=0||h<=0&&u<=0)return Math.abs(h)<Math.abs(u)?(a.funcAtRoot=h,a.root=l,a.cRoots=+(0===h)):(a.funcAtRoot=u,a.root=m,a.cRoots=+(0===u)),a;u<0&&(u=(0,n.b)(h,h=u),m=(0,n.b)(l,l=m));let g=.5*(l+m),c=Math.abs(m-l),d=c,_=t.getValue(e,g),p=t.getValue(e+1,g),f=4,P=1,y=0,x=0,v=1,C=0;for(;++C<100;){let i;C>32||0===p||2===v&&y>1||1===v&&f<4?(v=1,P>1&&P--):(v=2,x>1&&Math.abs(2*_)>Math.abs(c*p)&&P++),c=d;let s=!1;if(1===v)do{if(x>2){let t=16*Math.abs(c);if(.5*Math.abs(l-m)>t){let e=Math.min(l,m),s=Math.max(l,m);if(g===e){i=g,d=(g=e+t)-i;break}if(g===s){i=g,d=(g=s-t)-i;break}}}d=.5*(m-l),i=g,g=l+d,s=l===g||m===g}while(0);else for(;;){d=P*_/p,i=g,g-=d,s=g===i;let t=Math.min(l,m),e=Math.max(l,m);if(g<t){if(P>1){g=i,P--;continue}d=i-t,g=t}else if(g>e){if(P>1){g=i,P--;continue}d=i-e,g=e}break}if(s||Math.abs(d)<o){i!==g&&(_=t.getValue(e,g));break}_=t.getValue(e,g),p=t.getValue(e+1,g);let r=l,n=m;_<0?(h=_,l=g):(u=_,m=g),2===v&&(l===r&&m===n||x>1&&Math.abs(d)>=.5001*Math.abs(c))?y++:y=0,1===v?(f++,x=0):(f=0,x++)}return 100===C&&(0,s.c)("Root_finder iterations exceeded"),a.root=g,a.funcAtRoot=_,a.cRoots=1,a}(t,m,n.E.construct(l[g][0],l[g][1]),0,.5*o),1===_){if(0===m)u<i&&(l[g][0]<=e.vmin&&l[g][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),l[g][0]<=e.vmax&&l[g][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),r[u]=e.snapClip(c),u>0?r[u]-r[u-1]>o&&u++:u++);else{let t=n.P.getNAN();t[0]=l[g][0],t[1]=c,h.push(t);let e=n.P.getNAN();e[0]=c,e[1]=l[g][1],h.push(e)}continue}}h.push(l[g])}}return u}function t_(t,e,i,s,r,o){let a=(0,n.m)(n.F,2),l=tv(new n.F(t),new n.F(e),new n.F(i),s,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),l}function tp(t,e,i,s,r,o,a){let l=(0,n.m)(n.F,3),h=tC(new n.F(t),new n.F(e),new n.F(i),new n.F(s),r,o,l);return a[0]=l[0].value(),a[1]=l[1].value(),a[2]=l[2].value(),h}function tf(t,e,i,s,r,o,a,l){let h=(0,n.d)(i*i,NaN);h.fill(0),(0,n.a)(l,s,0,0,i);let m=(0,n.d)(i,NaN),u=(0,n.d)(i,NaN),g=(0,n.d)(i,NaN),c=t(l,i,e),d=0;for(d=0;d<100;d++){let s=c;for(let t=0;t<i;++t)u[t]=l[t];if(d%i==0){h.fill(0);for(let t=0;t<i;t++)h[t*i+t]=1}let a=0,_=0;for(let s=0;s<i;++s){for(let t=0;t<i;++t)m[t]=h[s*i+t];let n=c-(c=ty(t,e,l,m,r,o,i));n>a&&(_=s,a=n)}for(let t=0;t<i;t++)m[t]=l[t]-u[t],g[t]=l[t]+(l[t]-u[t]);let p=t(g,i,e);if(p<s&&2*(s-2*c+p)*(0,n.s)(s-c-a)<(0,n.s)(s-p)*a){c=ty(t,e,l,m,r,o,i);for(let t=0;t<i;++t)h[_*i+t]=h[(i-1)*i+t],h[(i-1)*i+t]=m[t]}if(s<=c)return t(l,i,e)}return c}function tP(t,e,i,r,o){let a={root:0,funcAtRoot:0,cRoots:0},l=i.vmin,h=i.vmax,m=0,u=Number.MAX_VALUE,g=t.getValue(e,l),c=t.getValue(e,h),d=0,_=0,p=0;if(g>=0&&c>=0||g<=0&&c<=0)return Math.abs(g)<Math.abs(c)?(a.funcAtRoot=g,a.root=l,a.cRoots=+(0===g)):(a.funcAtRoot=c,a.root=h,a.cRoots=+(0===c)),a;Math.abs(g)<Math.abs(c)&&(h=(0,n.b)(l,l=h),c=(0,n.b)(g,g=c)),m=l,d=g;let f=!0,P=0;for(;0!==c&&Math.abs(l-h)>r*Math.abs(h)+o;P++){let i=P>64;if(!i){_=g!==d&&c!==d?l*c*d/((g-c)*(g-d))+h*g*d/((c-g)*(c-d))+m*g*c/((d-g)*(d-c)):h-c*(h-l)/(c-g);let t=(3*l+h)/4;if(!(i=!(_>t&&_<h||_>h&&_<t))){let t=r*Math.abs(h)+o;if(f){let e=Math.abs(h-m);i=Math.abs(_-h)>=.5*e||e<t}else{let e=Math.abs(m-u);i=Math.abs(_-h)>=.5*e||e<t}}}if(i?(_=(l+h)/2,f=!0):f=!1,0===(p=t.getValue(e,_)))return a.root=_,a.funcAtRoot=p,a.cRoots=1,a;if(!i){let i=l-_,s=_-h;if(Math.abs(i)>10*Math.abs(s)){let i=h+3*s;for(let s=0;s<2;s++){let s=t.getValue(e,i);(0,n.e)(g)*(0,n.e)(s)>0?(l=i,g=s):i=(0,n.q)(l,h,.75)}}else if(Math.abs(s)>10*Math.abs(i)){let s=l-3*i;for(let i=0;i<2;++i){let i=t.getValue(e,s);(0,n.e)(c)*(0,n.e)(i)>0?(h=s,c=i):s=(0,n.q)(l,h,.25)}}}u=m,m=h,d=c,(0,n.e)(g)*(0,n.e)(p)<0?(h=_,c=p):(l=_,g=p),Math.abs(g)<Math.abs(c)&&(h=(0,n.b)(l,l=h),c=(0,n.b)(g,g=c)),128===P&&(0,s.c)("Root_finder iterations exceeded")}return a.root=h,a.funcAtRoot=c,a.cRoots=1,a}function ty(t,e,i,s,r,o,a){let l=s.slice(0,a),h=0;for(let t=0;t<a;t++)h+=s[t]*s[t];if((h=Math.sqrt(h))>0)for(let t=0;t<a;t++)l[t]/=h;let m=-1/0,u=1/0;{let t=(0,n.d)(a,0);for(let e=0;e<a;e++)t[e]=e;t.sort((t,e)=>{let i=Math.abs(l[t]),s=Math.abs(l[e]);return i<s?-1:+(i>s)});for(let e=0;e<a;e++){let s=t[e];if(0===l[s])continue;let a=(r[s]-i[s])/l[s],h=(o[s]-i[s])/l[s];h<a&&(h=(0,n.b)(a,a=h)),a>m&&(m=a),h<u&&(u=h)}}let g=0,c=(Math.abs(m)+Math.abs(u))*(0,n.N)()*100,d=(0,n.d)(a,NaN),_=l.slice();function p(s,r){for(let t=0;t<a;t++)d[t]=i[t]+s*_[t];return t(d,a,e)}c>
10&&(g=function(t,e,i,s,r,o){let a=(0,n.an)(),l=0,h=t(l,null),m=i,u=r,g=t(m,e),c=t(u,e);h>g&&(h=g,l=m),h>c&&(h=c,l=u);let d=m,_=u,p=g,f=c;p>f&&(p=(0,n.b)(f,f=p),_=(0,n.b)(d,d=_));let P=l-d,y=d-_,x=.5*Math.min(o,u-m),v=2*x,C,b=0;for(C=0;C<100&&!(u-m<=v);++C){let i=m+.5*(u-m),s=b>0;if(!s&&Math.abs(y)<=x&&(s=!0,b=3),!s){let t=l-d,e=l-_,i=t*(h-f),r=e*(h-p),n=e*r-t*i;(r=2*(r-i))>0&&(n=-n),0===(r=Math.abs(r))||Math.abs(n)>=Math.abs(r*y/2)||n<=r*(m-l)||n>=r*(u-l)?(s=!0,b=3):(y=P,P=n/r)}s&&(P=a*(y=l>=i?m-l:u-l),b--);let r=l+P;r<m+x?r=m+x:r>u-x&&(r=u-x);let n=t(r,e);n<h?(r>=l?(m=l,g=h):(u=l,c=h),_=d,d=l,l=r,f=p,p=h,h=n):(r<l?(m=r,g=n):(u=r,c=n),n<=p||d===l?(_=d,d=r,f=p,p=n):(n<=f||_===l||_===d)&&(_=r,f=n))}return l}(p,null,m,0,u,c));let f=p(g);for(let t=0;t<a;t++)i[t]=(0,n.c)(d[t],r[t],o[t]);return f}function tx(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setE(e.clone().negateThis().divThisE(t)),+!!i.containsCoordinate(s.value()))}function tv(t,e,i,s,r,o){if(0===t.value())return r?(o[0].set(1),+!!s.containsCoordinate(o[0].value())):tx(e,i,s,o[0]);if(r){let e=2;return o[0].set(1),o[1].setE(i).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),s.containsCoordinate(o[1].value())||(e=1),s.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,n.b)(o[0],o[0]=o[1])),e}let a=e.clone().sqrThis().subThisE(t.clone().mulThisE(i).mulThisE(n.ac));if(a.lt(n.H))return 0;let l=new n.F(e.value()>=0?1:-1),h=a.clone().sqrtThis(),m=new n.F(-.5).mulThisE(e.clone().addThisE(l.clone().mulThisE(h))),u=0;o[0].setE(m.divE(t));let g=new n.F(o[0].value()),c=new n.F(t.value()).mulE(g).addE(new n.F(e.value()).mulE(g).addE(new n.F(i.value())));return c.isZero()||tA(o[0],t,e,i,o[0]),s.containsCoordinate(o[0].value())&&u++,0!==h.value()&&0!==m.value()&&(o[u].assign(i.divE(m)),g.set(o[u].value()),c.assign(new n.F(t.value()).mulE(g).addE(new n.F(e.value()).mulE(g).addE(new n.F(i.value())))),c.isZero()||tA(o[u],t,e,i,o[u]),s.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,n.b)(o[0],o[0]=o[1]))),u}function tC(t,e,i,r,o,a,l){if(0===t.value())return tv(e,i,r,o,a,l);if(a){let i=1;l[0].set(1);let s=l.slice(i),a=tv(t,e.addE(t),r.negate(),o,!1,s);if(a>0){i+=a;for(let t=1;t<i;t++)l[t].eq(n.G)&&(l[i-1]=(0,n.b)(l[t],l[t]=l[i-1]),i--)}let h=l.slice(0,i);h.sort((t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));for(let t=0;t<i;++t)l[t]=h[t];return i}return function(t,e,i,r,o,a){let l=(0,n.m)(n.F,3),h=0,m=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(m.value())&&(l[0].setE(m),h=1);let u=(0,n.m)(n.F,2),g=tv(t.mul(3),e.mul(2),i,o,!1,u);if(g<0)return r.isZero()?-1:0;for(let t=0;t<g;t++)o.containsCoordinate(u[t].value())&&l[h++].setE(u[t]);(0,n.C)(l,0,h,(t,e)=>t.value()<e.value()?-1:+(t.value()>e.value()));let c=(0,n.m)(n.F,5);c[0].set(o.vmin);for(let t=0;t<h;t++)c[1+t].setE(l[t]);c[1+h].set(o.vmax);let d=h+2,_=1,p=0;{let s=c[0].clone();if(t.clone().mulThisE(s).addThisE(e).mulThisE(s).addThisE(i).mulThisE(s).addThisE(r).isZero()){let n=tE(t,e,i,r);s.setError(n.estimateError(s.value())),a[p]=s,p++,_++}}for(let n=_;n<d;n++){let l=c[n].clone(),h=t.clone().mulThisE(l).addThisE(e).mulThisE(l).addThisE(i).mulThisE(l).addThisE(r).isZero();if(h||!c[n].eq(c[n-1])){var f,P,y;if(h||(f=c[n-1].value(),P=c[n].value(),y=c[n-1].clone().addThisE(c[n]).divThisByPower2(2),tD(f,P,y.value(),tE(t,e,i,r),l,!1))){if(p>0&&l.eq(a[p-1]))continue;if(p>=3&&(0,s.c)("cubic_polynomial_solver_too_many_roots"),h){let s=tE(t,e,i,r);l.setError(s.estimateError(l.value()))}a[p]=l,p++}if(c[n].value()===o.vmax)break;h&&n++}}return p}(t,e,i,r,o,l)}function tb(t,e,i,r,o,a){return(a<e||e<0)&&(0,s.t)("nth_degree_real_roots"),function(t,e,i,s,r,o){let a=new tS(t,e,i,(0,n.N)()),l=0;if(2===a.truePower)l=tv(t[2],t[1],t[0],i,s,r);else if(1===a.truePower)l=tx(t[1],t[0],i,r[0]);else{if(0===a.truePower)return t[0].value()?0:-1;{let t=[];t.length=e,l=td(a,i,e,t);for(let e=0;e<l;e++)r[e].set(t[e])}}for(let t=0;t<l;t++)r[t].setError(a.getError(r[t].value()));return l}(t,e,i,r,o)}function tE(t,e,i,s){return{coef0:t.clone(),coef1:e.clone(),coef2:i.clone(),coef3:s.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){let e=Math.abs(t),i=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),s=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(s.isZero()){let e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));return e.isZero()?Math.pow(6*i/Math.abs(this.coef0.clone().mulThis(6).value(
1)),1/3):Math.sqrt(2*i/Math.abs(e.value()))}return i/Math.abs(s.value())}}}class tS{updateCoefs(t){let e;if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=0;for(let i=0,s=this.truePower-t;i<=s;++i){e.push(this.coefs[i+t].clone());let s=i+t,r=s--;for(let e=1;e<t;e++)r*=s--;e[i].mulThis(r)}this.curCoefs=e}constructor(t,e,i,s){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let i=this.coefs;0===t?i=this.coefs:(this.updateCoefs(t),i=this.curCoefs);let s=new n.K(0),r=1;for(let n=0,o=this.truePower-t;n<=o;++n)s.pe(r*i[n].value()),r*=e;return s.getResult()}getError(t){let e=Math.abs(t),i=new n.K(0),s=new n.F(1),r=new n.F(0);for(let t=0,n=this.power;t<=n;++t)r.addThisE(this.coefs[t].mulE(s)),i.pe(s.value()*this.coefs[t].eps()),s.mulThis(e);i.pe(r.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);let s=new n.F(1),r=new n.F(0);for(let i=0,n=this.truePower-e;i<=n;++i)r.addThisE(this.curCoefs[i].mulE(s)),s.mulThis(t);if(!r.isZero())return Math.pow(o*i.getResult()/Math.abs(r.value()),1/e)}return 0}}function tD(t,e,i,s,r,o){let a=t,l=e,h=l-a;if(!o){let i=s.calcF(t).value(),r=s.calcF(e).value();if((i>0||i>r)&&(l=(0,n.b)(a,a=l),r=(0,n.b)(i,i=r)),i>=0||r<=0)return!1}let m,u=!1,g=i,c=0;for(;c<100;c++){let t=s.calcF(g);if((m=s.calcDF(g)).isZero())return!1;if(!t.value()||c>3&&t.isZero()){u=!0;break}o||(0>t.value()?a=g:l=g);let e=t.value()/m.value(),i=g-e;o||(i>=a&&i<=l||i>=l&&i<=a)&&Math.abs(e)<=.5*h?(g=i,h=Math.abs(e)):(h=Math.abs(.5*(l-a)),g=.5*(a+l))}return!!u&&(r.set(g,s.estimateError(g)),!0)}class tw{constructor(t,e,i){this.coefs=(0,n.m)(n.F,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(i)}calcF(t){let e=new n.F(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){let e=new n.F(t);return n.F.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){let e=Math.abs(t),i=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),s=new n.F(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);return s.isZero()?Math.sqrt(i/Math.abs(this.coefs[0].value())):i/Math.abs(s.value())}}function tA(t,e,i,s,r){return tD(0,0,t.value(),new tw(e,i,s),r,!0)}var tT=r.V;class tI extends H{constructor(t){void 0===t||(0,n.O)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):(0,s.c)("unexpected constructor args")}getBoundary(){return i7(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,i){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(i),eW(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),eW(this)}getGeometryType(){return s.G.enumBezier2}queryEnvelope(t){if(2!==t.m_EnvelopeType)(0,s.b)("env type not impl");else{if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=e0(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[];eZ(this,e);let i=new n.P;for(let s of e)this.queryCoord2D(s,i),t.mergeNe(i)}}}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.m)(n.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}(0,s.g)(0)}createInstance(){return new tI({vd:this.m_description})}calculateLength2D(){return eH(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,i){let s=(0,n.m)(n.P,3);this.queryControlPoints(s),il(s,t,e,i)}queryCoord2DE(t,e){var i=this,s=t,r=e;let o=(0,n.m)(n.P,3);
1i.queryControlPoints(o),function(t,e,i){if(.5>=e.value()){let s=y.constructPoint2D(t[1]),r=new y;(0,n.a1)(2,y.constructPoint2D(t[0]),s,e,r);let o=new y;(0,n.a1)(2,s,y.constructPoint2D(t[2]),e,o);let a=new y;(0,n.a1)(2,r,o,e,a),i.setE(a)}else{let s=y.constructPoint2D(t[1]),r=new y;(0,n.a2)(2,y.constructPoint2D(t[0]),s,e,r);let o=new y;(0,n.a2)(2,s,y.constructPoint2D(t[2]),e,o);let a=new y;(0,n.a2)(2,r,o,e,a),i.setE(a)}}(o,s,r)}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){let e=(0,n.Q)(this.getStartX(),this.m_cp.x,t),i=(0,n.Q)(this.m_cp.x,this.getEndX(),t);return(0,n.Q)(e,i,t)}{let e=(0,n.R)(this.getStartX(),this.m_cp.x,t),i=(0,n.R)(this.m_cp.x,this.getEndX(),t);return(0,n.R)(e,i,t)}}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){let e=(0,n.Q)(this.getStartX(),this.m_cp.x,t),i=(0,n.Q)(this.m_cp.x,this.getEndX(),t);return(0,n.Q)(e,i,t)}{let e=(0,n.R)(this.getStartY(),this.m_cp.y,t),i=(0,n.R)(this.m_cp.y,this.getEndY(),t);return(0,n.R)(e,i,t)}}cut(t,e,i){let s=new ry;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=tT.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=tT.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){!function(t,e,i){var s,r,o;let a=(0,n.m)(n.P,4);t.queryControlPoints(a),s=a,r=e,o=i,0>r.value()&&r.set(0,r.eps()),r.value()>1&&r.set(1,r.eps()),o.setE(function(t,e,i){{let e=y.constructPoint2D(t[1]).subE(y.constructPoint2D(t[0])),s=new n.F(1).subE(i),r=y.constructPoint2D(t[2]).subE(y.constructPoint2D(t[1])),o=e.mulE(s).addE(r.mulE(i));return o.mulThisE(new n.F(2)),o}}(s,0,r))}(this,t,e)}cutBezierIgnoreAttributes(t,e,i){if((t<0||e>1||t>e)&&(0,s.t)("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return i.setStartXY(this.getStartXY()),i.m_cp.assign(this.m_cp),void i.setEndXY(this.getEndXY());let r=(0,n.m)(n.P,3);this.queryControlPoints(r),e9(r,t,e,r),i.constructPoints(r)}splitBezierIgnoreAttributes(t,e,i){(0,s.g)(0)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=tT.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.T)(o,a,l,r,tT.getDefaultValue(e))}getClosestCoordinate(t,e){return e2(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return e2(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.t)("");let i=ej(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)e6(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.m)(n.F,3),o=(0,n.m)(n.F,2),a=new n.E(0,1),l=0;if(t){if(r[0]=new n.F(this.getStartY()).sub(e),r[1]=new n.F(this.m_cp.y).subE(new n.F(this.getStartY())).mulThisByPower2(2),r[2]=new n.F(this.getStartY()).add(this.getEndY()).subE(new n.F(this.m_cp.y).mulThisByPower2(2)),l=tv(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.F(this.getStartX()).sub(e),r[1]=new n.F(this.m_cp.x).subE(new n.F(this.getStartX())).mulThisByPower2(2),r[2]=new n.F(this.getStartX()).add(this.getEndX()).subE(new n.F(this.m_cp.x).mulThisByPower2(2)),l=tv(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.U)(i,l);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return b(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=new o.J;this.queryEnvelope(t);let i=new n.E;return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,4);this.queryControlPoints(i),e9(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return eH(this,t,!0)}
1lengthToT(t){return function(t,e,i){let r=eH(t,1,!1);if(e<=0)return e;if(e>=r)return e-r+1;let o=[0];return 1!==td(new eB(t,e),n.E.unit(),1,o)&&(0,s.c)(""),o[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.m)(n.P,3);!function(t,e,i=!1){let s=(0,n.m)(n.P,3);t.queryControlPoints(s),io(s,e,i)}(this,e);let i=e[2],s=e[1],r=new n.P,o=i.y*s.x-i.x*s.y;r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60;let a=eK(this);return r.x+=(e[0].x-t.x)*a,r.y+=(e[0].y-t.y)*a,r}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?t.setCoords(0,0):!function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=8*Number.EPSILON*i}(this)?t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.t)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=ej(t),a=L(t),l=Math.min(a/t.calculateUpperLength2D(),1e-7),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),m=function(t,e,i,s,r){let o=!0,a=(0,n.m)(n.P,3);t.queryControlPoints(a);let l=+!o,h=a[1][l]-a[0][l],m=a[2][l]-a[0][l],u=t5(5,e,i,t=>{let e;if(t<=.5){let i=(0,n.Q)(0,h,t),s=(0,n.Q)(h,m,t);e=(0,n.Q)(i,s,t)}else{let i=(0,n.R)(0,h,t),s=(0,n.R)(h,m,t);e=(0,n.R)(i,s,t)}return e*eQ(a,1,t).length()},s,r);l=+(o=!1,!0),h=a[1][l]-a[0][l],m=a[2][l]-a[0][l];let g=t5(5,e,i,t=>{let e;if(t<=.5){let i=(0,n.Q)(0,h,t),s=(0,n.Q)(h,m,t);e=(0,n.Q)(i,s,t)}else{let i=(0,n.R)(0,h,t),s=(0,n.R)(h,m,t);e=(0,n.R)(i,s,t)}return e*eQ(a,1,t).length()},s,r);return new n.P(u,g)}(t,h,s,l,a);if(r.addThis(m),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)):t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,s.t)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){let e=(0,n.c)(t,0,1),i=eJ(this,1,e);return i.isZero()&&(i=eJ(this,2,e),1===e&&i.negateThis()),i}getDerivative(t){return eJ(this,1,(0,n.c)(t,0,1))}getCurvature(t){let e=eJ(this,1,t),i=eJ(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersecting(t,e,i){return 0!==rl(!1,this,t,e,i)}isIntersectingPoint(t,e,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;let s=new o.J;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){let i=ej(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.t)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){let e=[t];if(!E(this,e))return!1;let i=this.getEndXY().sub(this.getStartXY()),s=i.length(),r=this.getControlPoint1();return r.sub(this.getStartXY()),!(Math.abs(r.crossProduct(i))/s>e[0])}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return eK(this)}absNorm(){var t;return t=this,t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}queryEnvelopeW(t,e){let i=(0,n.m)(n.P,3);this.queryControlPoints(i),e4(i,t,e)}
1setSegmentFromCoords(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]),o=i[0].clone(),a=s;s>r&&(o=i[2].clone(),a=r);let l=!1;return a<=e&&0!==a&&(l=!0,t.setControlPoint1(o)),l}(this,t)}writeInBufferStream(t,e){let i=new Float64Array(2);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(2);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_cachedValues=null}needsSnapControlPoints(t){return function(t,e){if(!e)return!1;let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=n.P.sqrDistance(i[1],i[0]),r=n.P.sqrDistance(i[1],i[2]);i[0].clone();let o=s;return s>r&&(i[2].clone(),o=r),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return e6(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.Z)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&e6(t)}(this,t,e,i)}copyToImpl(t){t.m_cp.setCoordsPoint2D(this.m_cp),e1(t,e0(this))}reverseImpl(){}equalsImplTol(t,e){return!!this.m_cp.isEqualPoint2D(t.m_cp,e)}equalsImpl(t){return!!this.m_cp.equals(t.m_cp)}swapImpl(t){var e,i;t.m_cp=(0,n.b)(this.m_cp,this.m_cp=t.m_cp),e=this,(i=t).m_cachedValues=(0,n.b)(e.m_cachedValues,e.m_cachedValues=i.m_cachedValues)}afterCompletedModification(){eW(this)}intersect(t,e,i,s,r){return rg(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,s,r,o){let a=new p;if(function(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s),e4(s,e,i)}(t,n.E.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;let l=new n.P,h=e2(t,e,n.E.unit(),!1);return t.queryCoord2D(h,l),n.P.distance(l,e)<=r?(s&&(s[0]=h),1):0}(this,t,e.length,e,i)}endPointModified(){eW(this)}clearEndPointModified(){}}tI.type=s.G.enumBezier2;var tM=r.V;class tY extends H{constructor(t){return void 0===t||(0,n.O)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&(0,s.t)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,s.b)("unexpected constructor param"))}getBoundary(){return i7(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,i,s){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,1,s,1),t7(this)}constructWeights(t,e,i,s,r,n){this.dropAllAttributes(),this.setCpsAndWeights(t,e,i,s,r,n),t7(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),t7(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return s.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o.J){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;let e=eu(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i)}else{let e=[],i=(0,n.m)(n.P,3);this.queryControlPoints(i),et(i,this.m_weights,e);let s=new n.P;for(let i of e)this.queryCoord2D(i,s),t.mergeNe(s)}}}applyTransformation(t){if(t instanceof a.T){let e=(0,n.m)(n.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new tY({vd:this.m_description})}calculateLength2D(){return ee(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp):n.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){var i=this,s=t,r=e;let o=(0,n.m)(n.P,3);i.queryControlPoints(o);let a=[0,0,0];
1i.queryWeights(a),function(t,e,i,s){if(0===i.value())return s.setE(t[0]);if(1===i.value())return s.setE(t[2]);let r=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],l=new n.F,h=new n.F,m=new n.F;if(.5>=i.value()){let t=(0,n._)(r[0],r[1],i),e=(0,n._)(r[1],r[2],i);l.setE((0,n._)(t,e,i));let s=(0,n._)(o[0],o[1],i),u=(0,n._)(o[1],o[2],i);h.setE((0,n._)(s,u,i));let g=(0,n._)(a[0],a[1],i),c=(0,n._)(a[1],a[2],i);m.setE((0,n._)(g,c,i))}else{let t=(0,n.$)(r[0],r[1],i),e=(0,n.$)(r[1],r[2],i);l.setE((0,n.$)(t,e,i));let s=(0,n.$)(o[0],o[1],i),u=(0,n.$)(o[1],o[2],i);h.setE((0,n.$)(s,u,i));let g=(0,n.$)(a[0],a[1],i),c=(0,n.$)(a[1],a[2],i);m.setE((0,n.$)(g,c,i))}l.divThisE(m),h.divThisE(m);let u=new n.P(l.value(),h.value());ez([t[0].value(),t[1].value(),t[2].value()],u),s.x.set(u.x,l.eps()),s.y.set(u.y,h.eps())}([y.constructPoint2D(o[0]),y.constructPoint2D(o[1]),y.constructPoint2D(o[2])],[new n.F(a[0]),new n.F(a[1]),new n.F(a[2])],s,r)}queryCoord2DExtension(t,e,i){if(i){if(t<0)return void O(new rP({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void O(new rP({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}let s=(0,n.m)(n.P,3);this.queryControlPoints(s),eX(s,this.m_weights,t,e)}getCoordX(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,i){let s=new ry;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=tM.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=tM.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){var i=this,r=t,o=e;let a=(0,n.m)(n.P,3);i.queryControlPoints(a);let l=(0,n.d)(3,NaN);i.queryWeights(l),function(t,e,i,r){0>i.value()&&i.set(0,i.eps()),i.value()>1&&i.set(1,i.eps());let o=(0,n.m)(y,4);(function(t,e,i,r,o){let a=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,i,r,o){(0,s.g)(true);let a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=y.constructCoords(0,0)}let l=en(a,e,0,r),h=function(t,e,i){if(.5>=i.toDouble()){let e=(0,n._)(t[0],t[1],i),s=(0,n._)(t[1],t[2],i);return(0,n._)(e,s,i)}{let e=(0,n.$)(t[0],t[1],i),s=(0,n.$)(t[1],t[2],i);return(0,n.$)(e,s,i)}}(e,0,r),m=l.divE(h);o[0].setE(m);let u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],g=en([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,r).mul(2),c=h.sqr(),d=g.divE(c);o[1].setE(d)}(a,[new n.F(e[0]),new n.F(e[1]),new n.F(e[2])],1,r,o)})(t,e,0,i,o),r.setE(o[1])}(a,l,r,o)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.t)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");let r=(0,n.m)(n.P,3);this.queryControlPoints(r);let o=[0,0,0];ev(r,this.m_weights,t,e,r,o),i.setControlPointsAndWeights(r,o)}splitBezierIgnoreAttributes(t,e,i){}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=tM.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.T)(o,a,l,r,tM.getDefaultValue(e))}getClosestCoordinate(t,e){return ec(this,t,n.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,i=-1){return ec(this,t,e,!1,i)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.t)("");let i=t9(this),r=0;if(2===i.specialPointsCount())return 0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)eP(t[e].get());return r}
1intersectionWithAxis2D(t,e,i,s){i&&(i.length=9),s&&(s.length=9);let r=[,,,],o=(0,n.m)(n.F,2),a=new n.E(0,1),l=0,h=(0,n.m)(n.P,3);if(this.queryControlPoints(h),t){if(r[0]=new n.F(h[0].y).sub(e).mul(this.m_weights[0]),r[1]=new n.F(h[1].y).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.F(h[2].y).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=tv(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.F(h[0].x).sub(e).mul(this.m_weights[0]),r[1]=new n.F(h[1].x).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.F(h[2].x).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),l=tv(r[2],r[1],r[0],a,!1,o),i)for(let t=0;t<l;t++)i[t]=this.getCoordY(o[t].value());if(s)for(let t=0;t<l;t++)s[t]=o[t].value();else i&&(0,n.C)(i,0,l,n.X);return l}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[NaN,NaN],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return b(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o.J)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.J.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,3);this.queryControlPoints(i),ev(i,this.m_weights,t.vmin,t.vmax,i,[0,0,0]),e.setFromPoints(i,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp.isEqual(this.m_XStart,this.m_YStart),s=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp.setCoordsPoint2D(t):s&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return ee(this,t,!0)}lengthToT(t){return function(t,e,i){let r=ee(t,1,!1);if(e<=0)return e;if(e>=r)return e-r+1;let o=[0];return 1!==td(new el(t,e),n.E.unit(),1,o)&&(0,s.c)(""),o[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=function(t){let e=(0,n.m)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=eF(e);if(1===i){let e=(0,n.m)(n.P,3);io(t,e);let i=e[2].clone(),s=e[1].clone(),r=new n.P,o=i.y*s.x-i.x*s.y;return r.x=-(4*i.x+5*s.x)*o/60,r.y=-(4*i.y+5*s.y)*o/60,r}if(0===i)return new n.P(0,0);(0,s.g)(i>0);let r=t[1].sub(t[0]),o=t[2].sub(t[0]);if(i<1){let t=Math.sqrt(1-i),e=Math.sqrt(1+i),s=(r.y*o.x-r.x*o.y)*i/Math.pow(t*e,5)/12,n=Math.atan2(t,e),a=i*i,l=r.mul(2*(2+a)),h=o.mul(2*a-5),m=l.add(h).mul(i*t*e),u=o.sub(r.mul(2*a)).mul(6*n);return m.add(u).mul(s)}{let t=Math.sqrt(i-1),e=Math.sqrt(i+1),s=(r.y*o.x-r.x*o.y)*i/Math.pow(t*e,5)/12,n=Math.atanh(t/e),a=i*i,l=r.mul(4).sub(o.mul(5)),h=r.add(o).mul(2*a),m=l.add(h).mul(i*t*e),u=o.sub(r.mul(2*a)).mul(6*n);return m.add(u).mul(s)}}(e,i)}(this),i=eh(this);return e.x+=(this.getStartX()-t.x)*i,e.y+=(this.getStartY()-t.y)*i,e}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?t.setCoords(0,0):!function(t){if(0===t.m_weights[1])return!0;let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=8*Number.EPSILON*i}(this)?t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.t)("calculate_sub_weighted_centroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=t9(t),a=em(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),m=function(t,e,i,s,r){let o=!0,a=(0,n.m)(n.P,4),l=t5(5,e,i,e=>(ei(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()),s,r);o=!1;let h=t5(5,e,i,e=>(ei(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length()),s,r);return new n.P(l,h)}(t,h,s,l,a);if(r.addThis(m),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)):t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){let e=(0,n.m)(n.P,3);return this.queryControlPoints(e),ea(e,this.m_weights,t)}getDerivative(t){let e=(0,n.c)(t,0,1),i=(0,n.m)(n.P,4);return ei(this,1,e,i),i[1]}getCurvature(t){let e=(0,n.m)(n.P,4);ei(this,2,t,e);let i=e[1].sqrLength();return 0===i?NaN:(e[1].divThis(Math.sqrt(i)),e[1].crossProduct(e[2])/i)}isIntersecting(t,e,i){return!1}isIntersectingPoint(t,e,i){return!1}
1isIntersectingPoint3D(t,e,i,s,r=1){return!1}isMonotoneQuickAndDirty(){let t=(0,n.m)(n.P,3);return this.queryControlPoints(t),ef(t)}getMonotonicPartParams(t,e){let i=t9(this),r=i.specialPointsCount();if(!e)return i.specialPointsCount();t<r&&(0,s.t)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,n.b)(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){let e=[t];return!!E(this,e)&&function(t,e){let i=t.getEndXY().sub(t.getStartXY()),s=i.length(),r=t.getControlPoint1();return r.subThis(t.getStartXY()),!(Math.abs(r.crossProduct(i))/s>e)}(this,e[0])}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=[0,0,0];this.queryWeights(i),t.setControlPointsAndWeights(e,i)}calculateArea2DHelper(){return eh(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,s.g)(0),0}queryEnvelopeW(t,e){e_(this,t,e)}setSegmentFromCoords(t,e){let i=[0,0,0];this.queryWeights(i),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],i[0],i[1],i[2])}writeInBufferStream(t,e){let i=new Float64Array(5);return i[0]=this.m_cp.x,i[1]=this.m_cp.y,i[2]=this.m_weights[0],i[3]=this.m_weights[1],i[4]=this.m_weights[2],t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(5);t.queryRange(e,i.length,i,!0,1),this.m_cp.x=i[0],this.m_cp.y=i[1],this.m_weights[0]=i[2],this.m_weights[1]=i[3],this.m_weights[2]=i[4],this.m_cachedValues=null}snapControlPoints(t){let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]),r=e[0].clone(),o=i;i>s&&(r=e[2].clone(),o=s);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(r)),a}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.m)(n.P,3);this.queryControlPoints(e);let i=n.P.sqrDistance(e[1],e[0]),s=n.P.sqrDistance(e[1],e[2]);e[0].clone();let r=i;return i>s&&(e[2].clone(),r=s),r<=t&&0!==r}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return eP(this)}setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformInPlace(t.m_cp):(0,n.Z)(e,i,.5,t.m_cp),t.changeEndPoints2D(e,i),r&&eP(t)}(this,t,e,i)}copyToImpl(t){t.m_cp.setCoordsPoint2D(this.m_cp),t.m_weights[0]=this.m_weights[0],t.m_weights[1]=this.m_weights[1],t.m_weights[2]=this.m_weights[2],eg(t,eu(this))}reverseImpl(){this.m_weights[2]=(0,n.b)(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){if(!this.m_cp.equals(t.m_cp))return!1;for(let e=0;e<3;e++)if(this.m_weights[e]!==t.m_weights[e])return!1;return!0}equalsImplTol(t,e){if(!this.m_cp.isEqualPoint2D(t.m_cp,e))return!1;let i=(0,n.m)(n.P,3);this.queryControlPoints(i);let s=(0,n.m)(n.P,3);t.queryControlPoints(s);let o=[t.m_weights[0],t.m_weights[1],t.m_weights[2]];for(let t=0;t<3;t++){let n=new r.h;n.setCoordsPoint2DZ(i[t].mul(this.m_weights[t]),this.m_weights[t]);let a=new r.h;if(a.setCoordsPoint2DZ(s[t].mul(o[t]),o[t]),!n.isEqual(a,e))return!1}return!0}swapImpl(t){var e,i;t.m_cp=(0,n.b)(this.m_cp,this.m_cp=t.m_cp),t.m_weights=(0,n.b)(this.m_weights,this.m_weights=t.m_weights),e=this,(i=t).m_cachedValues=(0,n.b)(e.m_cachedValues,e.m_cachedValues=i.m_cachedValues)}afterCompletedModification(){t7(this)}intersect(t,e,i,s,r){return rg(!1,this,t,e,i,s,r)}
1intersectPoint(t,e,i){return function(t,e,i,r,o){let a=new p;if(e_(t,n.E.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;let l=t9(t),h=0,m=[],u=l.specialPoints[0];for(let i=1,r=l.specialPoints.length;i<r;++i){let r=l.specialPoints[i],o=function(t,e,i,s){let r={tmin:0,tmax:0,t:0,d:0,pt:n.P.getNAN().clone()},o=(0,n.d)(18,NaN),a=(0,n.m)(n.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);let l=[0,0,0];t.queryWeights(l);let h=[1,eF(l),1],m=eV(l,i),u=eV(l,s),g=td(new t8(a,h,new n.P(0,0)),n.E.construct(m,u),18,o);eX(a,h,m,r.pt),r.t=m,r.d=n.P.distance(r.pt,new n.P(0,0));let c=new n.P;eX(a,h,u,c);let d=n.P.distance(c,new n.P(0,0));d<r.d&&(r.d=d,r.t=u,r.pt.assign(c));for(let t=0;t<g;t++){eX(a,h,o[t],c);let e=n.P.distance(c,new n.P(0,0));e<r.d&&(r.d=e,r.t=eN(l,o[t]),r.pt.assign(c))}return r}(t,e,u,r);if(0===m.length)m.push(o);else if(o.t===o.tmin)(0,s.g)(m.at(-1).d<=o.d),m.at(-1).tmax=o.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,s.g)(m.at(-1).d>=o.d);let t=m.at(-1).tmin;m[m.length-1]=o,m.at(-1).tmin=t}else m.push(o);u=r}for(let t of m)if(t.d<=r){let e=t.t;i&&(i[h]=e),h++}return h}(this,t,e,i)}endPointModified(){t7(this)}clearEndPointModified(){}setCpsAndWeights(t,e,i,r,n,o){(r<=0||o<=0||n<0)&&(0,s.t)("weights"),(t.isNAN()||e.isNAN()||i.isNAN())&&(0,s.t)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=r,this.m_weights[1]=n,this.m_weights[2]=o,this.setEndXY(i)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}tY.type=s.G.enumRationalBezier2;class tX{static constructPoint2D(t){return new tX(n.M.constructDouble(t.x),n.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new n.M).setNAN(),void(this.y=(new n.M).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 n.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){let t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new tX(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new tX(this.x.add(t.x),this.y.add(t.y))}sub(t){return new tX(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}class tq{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map(t=>t.clone()),(0,s.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map(t=>t.clone()))):(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map(t=>t.clone()),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map(t=>t.clone()),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}fmSubThis(t,e){return(0,s.g)(0),this}addThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(t){return(0,s.g)(0),this}sub(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0(t){return(0,s.g)(0),this}subNumber0(t){return(0,s.g)(0),this}subShifted(t,e){let i=this.power(),s=t.power()+e,r=Math.min(this.power(),s),n=0;for(let i=e;i<=r;++i)this.m_elements[i].subThis(t.m_elements[n]),n++;if(s<=i)return this.updatePower(),this;this.m_elements.length=s+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=r+1;e<=s;++e)this.m_elements[e].subThis(t.m_elements[n++]);return this.updatePower(),this}subShiftedWithCoef(t,e,i){let s=this.power(),r=t.power()+i,n=Math.min(this.power(),r),o=0;for(let s=i;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o],e),o++;if(r<=s)return this.updatePower(),this;this.m_elements.length=r+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let i=n+1;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o++],e);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){let e=[];for(let i=0,s=this.power();i<=s;i++)for(let s=0,r=t.power();s<=r;s++){let r=this.m_elements[i].clone();r.mulThis(t.m_elements[s]),i+s<e.length?e[i+s].addThis(r):e.push(r)}this.m_elements=e}else for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,i=this.power();e<=i;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(t){return(0,s.g)(0),this}mulBigint0(t){return(0,s.g)(0),this}mulBigIntThis(t){return(0,s.g)(0),this}mulInt320(t){return(0,s.g)(0),this}div0(t){return(0,s.g)(0),this}absThis(){return(0,s.g)(0),this}div(t,e,i){if(this.power()<t.power())return i.assignCopy(this),void e.setZero();i.setZero(),e.setZero();let s=t.getElement(t.power()),r=this.clone(),o=r.power(),a=r.power()-t.power(),l=a;for(e.m_elements=(0,n.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){i.assignMove(r);break}if(o===r.power()){let i=r.getElement(r.power());i.divThis(s),r.subShiftedWithCoef(t,i,r.power()-t.power()),e.m_elements[l]=i.clone()}l--,o--}i.updatePower(),e.updatePower()}divThis(t){return(0,s.g)(0),this}subThis(t){let e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);let i=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let s=e+1;s<=i;++s)this.m_elements[s]=t.m_elements[s].clone(),this.m_elements[s].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(t,e){(0,s.g)(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){let e=this.power(),i=this.m_elements[e].clone();for(let s=e-1;s>=0;--s)i.mulThis(t),i.addThis(this.m_elements[s]);return i}equals(t){if(this===t)return!0;
1if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();let e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let i=t,s=this.power();i<=s;i++){let s=BigInt(i);for(let e=i-1,r=i-t;e>r;--e)s*=BigInt(e);e.m_elements[i-t].mulBigIntThis(s)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(n.M.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce((t,e)=>{let i=e.hiBitIndex();return t<i?i:t},0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}static evaluateCoefs(t,e,i){let s=t.power();i.construct0(t.getElement(0).evaluate(e));for(let r=1;r<=s;++r)i.addElement(t.getElement(r).evaluate(e));i.updatePower()}}class tF extends tq{constructor(t){super(void 0===t?{zeroCtor:n.M}:{...t,zeroCtor:n.M})}clone(){return new tF({copy:this})}absEvaluate(t){let e=this.power(),i=this.m_elements[e].clone();i.absThis();let s=t.clone();s.absThis();for(let t=e-1;t>=0;--t)i.mulThis(s),i.addThis(this.m_elements[t].abs());return i}}class tN extends tq{constructor(t){super(void 0===t?{zeroCtor:tF}:{...t,zeroCtor:tF})}clone(){return new tN({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let i=0;i<=e;++i)this.m_elements.push(new tF({coef0:t[i]}));return this.updatePower(),this}}function tV(t,e,i,r,o,a,l,h,m,u,g,c,d,_,p,f,P,y=!1){let x={polypoly1:new tN,polypoly2:new tN,polyX2:new tF,polyY2:new tF,polyX2Deriv:new tF,polyY2Deriv:new tF,polypolyX1:new tN,polypolyY1:new tN,polypolyX1Deriv:new tN,polypolyY1Deriv:new tN,lazyPolypolyD1:new tN,lazyPolypolyD1Deriv:new tN,lazyPolyD2:new tF,lazyPolyD2Deriv:null,polypoly11:new tN,polypoly12:new tN,tempPp:new tN,tempPp1:new tN,tempPp2:new tN,tempP:new tF,tempP1:new tF,tempP2:new tF};x.polyX2.construct(l,h),x.polyY2.construct(m,u),x.polypolyX1.constructFromMPValues(t,e),x.polypolyY1.constructFromMPValues(i,r),x.polypoly11.assignCopy(x.polypolyX1),x.polypoly12.assignCopy(x.polypolyY1),g&&(x.lazyPolyD2.construct(g,c),x.polypoly11.mulElementThis(x.lazyPolyD2),x.polypoly12.mulElementThis(x.lazyPolyD2)),o?(x.lazyPolypolyD1.constructFromMPValues(o,a),x.lazyPolypolyD1Deriv=new tN({copy:x.lazyPolypolyD1}),x.lazyPolypolyD1Deriv.derivative1This(),x.tempPp.assignCopy(x.lazyPolypolyD1),x.tempPp.mulElementThis(x.polyX2),x.polypoly11.subThis(x.tempPp),x.tempPp.assignCopy(x.lazyPolypolyD1),x.tempPp.mulElementThis(x.polyY2),x.polypoly12.subThis(x.tempPp)):(x.polypoly11.sub0This(x.polyX2),x.polypoly12.sub0This(x.polyY2)),x.polypolyX1Deriv.assignCopy(x.polypolyX1),x.polypolyX1Deriv.derivative1This(),x.polypolyY1Deriv.assignCopy(x.polypolyY1),x.polypolyY1Deriv.derivative1This(),o&&(x.polypolyX1Deriv.mulThis(x.lazyPolypolyD1),x.tempPp2.assignCopy(x.lazyPolypolyD1Deriv),x.tempPp2.mulThis(x.polypolyX1),x.polypolyX1Deriv.subThis(x.tempPp2),x.polypolyY1Deriv.mulThis(x.lazyPolypolyD1),x.tempPp2.assignCopy(x.lazyPolypolyD1Deriv),x.tempPp2.mulThis(x.polypolyY1),x.polypolyY1Deriv.subThis(x.tempPp2)),x.polyX2Deriv.assignCopy(x.polyX2),x.polyX2Deriv.derivative1This(),x.polyY2Deriv.assignCopy(x.polyY2),x.polyY2Deriv.derivative1This(),g&&((0,s.g)(null===x.lazyPolyD2Deriv),x.lazyPolyD2Deriv=new tF({copy:x.lazyPolyD2}),x.lazyPolyD2Deriv.derivative1This(),x.polyX2Deriv.mulThis(x.lazyPolyD2),x.tempP1.assignCopy(x.lazyPolyD2Deriv),x.tempP1.mulThis(x.polyX2),x.polyX2Deriv.subThis(x.tempP1),x.polyY2Deriv.mulThis(x.lazyPolyD2),x.tempP1.assignCopy(x.lazyPolyD2Deriv),x.tempP1.mulThis(x.polyY2),x.polyY2Deriv.subThis(x.tempP1)),x.polypoly1.assignCopy(x.polypoly11),x.polypoly1.mulElementThis(x.polyX2Deriv),x.tempPp.assignCopy(x.polypoly12),x.tempPp.mulElementThis(x.polyY2Deriv),x.polypoly1.addThis(x.tempPp),x.polypoly2.assignCopy(x.polypolyX1Deriv),x.polypoly2.mulElementThis(x.polyY2Deriv),x.tempPp.assignCopy(x.polypolyY1Deriv),x.tempPp.mulElementThis(x.polyX2Deriv),x.polypoly2.subThis(x.tempPp);let v=[],C=[];P||(P=[]),f||(f=[]),tW(x.polypoly11,x.polypoly12,x.tempP);let b=57,E=.25*Number.EPSILON,S=[],D=tj(x.tempP,d,p,E,b,S);if(D<0)return -1;for(let t=0;t<D;t++){tF.evaluateCoefs(x.polypoly11,n.M.constructDouble(S[t]),x.tempP1);let e=[],i=tj(x.tempP1,d,_,E,b,e);if(0!==i)if(tF.evaluateCoefs(x.polypoly12,n.M.constructDouble(S[t]),x.tempP2),i<0){(i=tj(x.tempP2,d,_,E,b,e))<0&&(0,s.c)("mp_curve_proximity");for(let s=0;s<i;s++)C.push((0,n.n)(e[s],S[t]))}else{let s=x.tempP2.absEvaluate(n.ae);s.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<i;r++){let i=x.tempP2.evaluate(n.M.constructDouble(e[r]));i.absThis(),i.lt(s)&&C.push((0,n.n)(e[r],S[t]))}}}D=C.length,tW(x.polypoly1,x.polypoly2,x.tempP),b=57,E=.25*Number.EPSILON;let w=[],A=tj(x.tempP,d,p,E,b,w);A<0&&(A=0);for(let t=0;t<A;t++){tF.evaluateCoefs(x.polypoly1,n.M.constructDouble(w[t]),x.tempP1);let e=[],i=tj(x.tempP1,d,_,E,b,e);if(0!==i)if(tF.evaluateCoefs(x.polypoly2,n.M.constructDouble(w[t]),x.tempP2),i<0){if((i=tj(x.tempP2,d,_,E,b,e))<0)continue;for(let s=0;s<i;
1s++)v.push((0,n.n)(e[s],w[t]))}else{let s=x.tempP2.absEvaluate(n.ae);s.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<i;r++){let i=x.tempP2.evaluate(n.M.constructDouble(e[r]));i.absThis(),i.lt(s)&&v.push((0,n.n)(e[r],w[t]))}}}if(A=v.length,0===D&&0===A)return 0;(v=v.concat(C)).sort((t,e)=>y?(0,n.X)(t.second,e.second):(0,n.X)(t.first,e.first));let T=(0,n.u)(v,(t,e)=>t.first===e.first&&t.second===e.second);for(let t of(v=v.slice(0,T),f.length=0,P.length=0,v))f.push(t.first),P.push(t.second);return(0,s.g)(f.length===P.length),P.length}function tL(t,e,i,s,r,o,a,l,h,m,u){let g={polyIntersect:new tF,polyX1:new tF,polyY1:new tF,polyX1Deriv:new tF,polyY1Deriv:new tF,lazyPolyD1:new tF,lazyPolyD1Deriv:new tF,tempP:new tF,tempP1:new tF,tempP2:new tF,polypoly1Proximity:new tN,polypoly2Proximity:new tN};g.polyX1.construct(t,e),g.polyY1.construct(i,s),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.polyIntersect.assignCopy(g.polyX1),g.polyIntersect.mulThis(g.polyX1),g.polyIntersect.mulElementThis(a[0]),g.tempP.assignCopy(g.polyY1),g.tempP.mulThis(g.polyY1),g.tempP.mulElementThis(a[1]),g.polyIntersect.addThis(g.tempP),r?(g.lazyPolyD1.construct(r,o),g.tempP.assignCopy(g.lazyPolyD1),g.tempP.mulThis(g.lazyPolyD1),g.tempP.mulElementThis(a[2]),g.polyIntersect.addThis(g.tempP)):g.polyIntersect.add0(a[2]);{let r=a[0].clone(),o=r.clone();o.sqrThis();let l=a[1].clone(),h=l.clone();h.sqrThis();let m=a[2].clone(),u=r.clone();u.subThis(l),g.polyX1.construct(t,e),g.polyX1Deriv.assignCopy(g.polyX1),g.polyX1Deriv.derivative1This(),g.polyY1.construct(i,s),g.polyY1Deriv.assignCopy(g.polyY1),g.polyY1Deriv.derivative1This(),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(h),g.tempP.mulElementThis(m),g.polypoly1Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(l.mul(u).mul(m).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1),g.tempP.mulElementThis(r.mul(h)),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1),g.tempP1.mulElementThis(o.mul(l)),g.tempP.addThis(g.tempP1),g.tempP.add0(u.mul(u).mul(m)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulElementThis(u.mul(r).mul(l).ldexpThis(1)),g.polypoly1Proximity.addElement(g.tempP),g.tempP.construct0(r.mul(u).mul(u)),g.polypoly1Proximity.addElement(g.tempP),g.polypoly1Proximity.updatePower(),g.tempP.construct0(n.ad),g.polypoly2Proximity.construct0(g.tempP),g.tempP.assignCopy(g.polyX1),g.tempP.mulThis(g.polyX1Deriv),g.tempP1.assignCopy(g.polyY1),g.tempP1.mulThis(g.polyY1Deriv),g.tempP.addThis(g.tempP1),g.tempP.mulElementThis(r.mul(l)),g.polypoly2Proximity.addElement(g.tempP),g.tempP.assignCopy(g.polyX1Deriv),g.tempP.mulElementThis(u.mul(r)),g.polypoly2Proximity.addElement(g.tempP),g.polypoly2Proximity.updatePower()}let c=[],d=[];u||(u=[]);let _=2*g.polyIntersect.power()+58,p=.5*Number.EPSILON,f=tj(g.polyIntersect,l,h,p,_,d);if(f<0)return -1;tW(g.polypoly1Proximity,g.polypoly2Proximity,g.tempP),_=2*g.tempP.power()+58;let P=tj(g.tempP,l,h,p,_,c);if(P<0&&(P=0),0===f&&0===P)return 0;let y=c.concat(d);u.length=y.length,(0,n.a)(u,y,0,0,y.length),(0,n.v)(u);let x=(0,n.u)(u,(t,e)=>0===(0,n.X)(t,e));return u.length=x,u.length}function tR(t,e,i,s){return t.isZero()?e.isZero()?-1:0:(s.setThis(e),s.negateThis(),s.divThis(t),i.isEmpty()||i.containsCoordinate(s.value())?1:0)}function tz(t,e,i,s,r,o,a){if(t.isZero())return o?(a[0].setInt32(1),+!!r.containsCoordinate(1)):tR(e,i,r,a[0]);if(o){let e=2;return a[0].setInt32(1),i.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(i.div(t)),r.containsCoordinate(a[1].value())||(e=1),r.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,n.b)(a[0],a[0]=a[1])),e}let l=e.clone();l.sqrThis();let h=t.clone();if(h.mulThis(i).ldexpThis(2).negateThis().addThis(l),h.LZ())return 0;let m=s+2,u=n.M.sqrt(h,m),g=u.clone();e.LZ()&&g.negateThis(),g.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let c=0;return a[0].setThis(g).divThis(n.M.constructAssign(t,m)).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[0].value(
1)))&&c++,u.isZero()||g.isZero()||(a[c].setThis(i).divThis(g).limitPrecisionThis(s),(r.isEmpty()||r.containsCoordinate(a[c].value()))&&c++,2===c&&a[0].gt(a[1])&&(a[1]=(0,n.b)(a[0],a[0]=a[1]))),c}function tG(t,e,i,r,o,a,l,h){if(t.isZero())return tz(e,i,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.b)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.C)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let s=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),s=1),m(tz(t,e,i,o,a,l,h.slice(1)),s)}if(l){let i=0;a.containsCoordinate(1)&&(h[0].setInt32(1),i=1);let s=e.add(t),n=r.negate(),l=t.add(s).add(n).isZero();return m(tz(t,s,n,o,a,l,h.slice(i)),i)}let u=new n.M,g=new n.M,c=new n.M,d=e.clone();if(d.isZero())g.setThis(i),g.divThis(t),c.setThis(r),g.divThis(t);else{d.divThis(t).divDoubleThis(3).negateThis();let s=e.clone();s.sqrThis();let n=t.clone();n.sqrThis(),g.setThis(t),g.mulThis(i).mulDoubleThis(3).subThis(s).divThis(n).divDoubleThis(3),c.setThis(s),c.mulThis(e),c.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(i).mulDoubleThis(9),c.subThis(u),u.setThis(n),u.mulThis(r).mulDoubleThis(27),c.addThis(u),c.divThis(n).divThis(t).divDoubleThis(27)}if(g.isZero()){let t=c.clone();return t.negateThis(),t.isZero()?h[0].setThis(d):h[0].setThis(n.M.cubicRoot(c,o).add(d)),tJ(a,o,h,1)}let _=c.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(g.clone()),u.sqrThis().mulThis(g).divDoubleThis(27),_.addThis(u),_.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(g),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(d),h[1].addThis(d),tJ(a,o,h,2);if(_.GZ())return _.setThis(n.M.sqrt(_,o+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.addThis(_),h[0].setThis(n.M.cubicRoot(u,o+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.subThis(_),h[0].addThis(n.M.cubicRoot(u,o+8)),h[0].addThis(d),tJ(a,o,h,1);u.setThis(g),u.divDoubleThis(3).negateThis(),(0,s.g)(u.GEZ());let p=n.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(d),p.addThis(d);let P=n.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),y=n.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),x=new tF({zeroCtor:n.M});x.construct0(r),x.addElement(i),x.addElement(e),x.addElement(t);let v=new tF({copy:x});v.derivative1This();let C=0,b=(0,n.m)(n.M,4);b[C++].setThis(P),f.gt(P)&&f.lt(y)&&b[C++].setThis(f),p.gt(P)&&p.lt(y)&&b[C++].setThis(p),b[C++].setThis(y);let E=3*o,S=52,D=Number.EPSILON;for(;S<E;)2*S<=E?(D*=D,S*=2):(D*=Number.EPSILON,S+=52);S+=2;let w=0,A=!1;for(let t=1;t<C;t++)if(tH(x,v,b[t-1],b[t],D,S,h[0])){w=1,A=t+1<C;break}if(!w)return 0;if(A){let t=new tF({zeroCtor:n.M,coef0:h[0]});t.negateThis(),t.addElement(n.ae);let e=new tF({zeroCtor:n.M}),i=new tF({zeroCtor:n.M});x.div(t,e,i),(0,s.g)(2===e.power()),(0,s.g)(0===i.power());let r=tz(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,h.slice(1));(0,s.g)(r>=0&&r<=2),w+=r}return tJ(a,o,h,w)}function tk(t,e,i,s,r,o,a,l,h){if(t.isZero())return tG(e,i,s,r,o,a,l,h);let m=(t,e)=>{if(t>0){let i=e+t;for(let t=1;t<i;t++)h[t].equals(h[0])&&(h[i-1]=(0,n.b)(h[t],h[t]=h[i-1]),i--);e=i}return(0,n.C)(h,0,e,(t,e)=>t.compare(e)),e};if(r.isZero()){let r=0;return a.containsCoordinate(0)&&(h[0].setInt32(0),r=1),m(tG(t,e,i,s,o,a,l,h.slice(r)),r)}let u=new tF({zeroCtor:n.M,coef0:r});if(u.addElement(s),u.addElement(i),u.addElement(e),u.addElement(t),l){let t=0;a.containsCoordinate(1)&&(h[0].setInt32(1),t=1);let e=new tF({zeroCtor:n.M,coef0:n.M.constructInt32(-1)});e.addElement(n.M.constructInt32(1));let i=new tF({zeroCtor:n.M}),s=new tF({zeroCtor:n.M});return u.div(e,i,s),m(tG(3===i.power()?i.getElement(3):n.ad.clone(),i.power()>=2?i.getElement(2):n.ad.clone(),i.power()>=1?i.getElement(1):n.ad.clone(),i.getElement(0),o,a,i.evaluate(n.ae).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);let e=tG(3===u.power()?u.getElement(3):n.ad.clone(),u.power()>=2?u.getElement(2):n.ad.clone(),u.power()>=1?u.getElement(1):n.ad.clone(),u.getElement(0),o,a,!1,h.slice(t));return e>0&&(t+=e),(0,n.C)(h,0,t,(t,e)=>t.compare(e)),t}let g=52,c=Number.EPSILON;for(;g<o;
1)2*g<=o?(c*=c,g*=2):(c*=Number.EPSILON,g+=52);g+=2;let d=tO(u),_=n.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return tU(u,a,c=(d.lt(_)?d:_).mul(n.M.constructDouble(c)).toDouble(),g,l,!1,h,4)}function tB(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function tW(t,e,i){let s=t.clone(),r=e.clone();for(tB(s),tB(r);0!==s.power()||0!==r.power();)!function(t,e){let i=t,s=e;s.power()>i.power()&&(s=(0,n.b)(i,i=s));let r=i.power()-s.power(),o=new tF({copy:i.getElement(i.power())});i.mulThis(s.getElement(s.power()));for(let t=0,e=i.power();t<e;t++)if(t>=r){let e=new tF({copy:s.getElement(t-r)});e.mulThis(o);let n=i.getElement(t).sub(e);i.setElement(t,n)}i.setElement(i.power(),i.getElement(i.power()).setZero()),i.updatePower(),tB(i)}(s,r);i.assignMove(s.getElement(0))}function tj(t,e,i,s,r,o){o.length=0;let a=t.power(),l=(0,n.m)(n.M,2*a+4),h=function(t,e,i,s,r,o,a){if(0===t.power())return t.isZero()?-1:0;let l=t.evaluate(n.M.constructInt32(1)).isZero();if(1===t.power()){let i=tR(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(s),1!==i?0:(o[0].limitPrecisionThis(s),1)}return 2===t.power()?tz(t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):3===t.power()?tG(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):4===t.power()?tk(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),s,e,l,o):tU(t,e,i,s,l,r,o,a)}(t,i||n.E.unit(),s,r,!1,l,l.length);if(h>0){o.length=0;for(let t=0;t<h;t++){let e=l[t].value();t>0&&e<=o.at(-1)||o.push(e)}return o.length}return h}function tZ(t,e,i){if((0,s.g)(i>=1),0===t.power())return t.isZero()?-1:0;let r=t.getElement(0);return r.negateThis(),r.divThis(t.getElement(1)),e[0].setThis(r),1}function tH(t,e,i,r,o,a,l){let h=i.clone(),m=r.clone();h.limitPrecisionThis(a),m.limitPrecisionThis(a);let u=t.evaluate(h);u.limitPrecisionThis(a+2);let g=t.evaluate(m);if(g.limitPrecisionThis(a+2),u.GEZ()&&g.GEZ()||u.LEZ()&&g.LEZ())return u.absLessAbs(g)?(l=h,u.isZero()):(l=m,g.isZero());let c=g.LZ();c&&(g=(0,n.b)(u,u=g),m=(0,n.b)(h,h=m));let d=c?m:h,_=c?h:m,p=h.add(m).ldexpThis(-1);p.limitPrecisionThis(a);let f=m.sub(h);f.limitPrecisionThis(a),f.absThis();let P=f.clone(),y=t.evaluate(p),x=e.evaluate(p),v=new tF({copy:t}),C=new tF({copy:e});{let i=Math.max(t.hiBitIndex(),e.hiBitIndex()),s=n.ae.clone();s.ldexpThis(-(a+2));for(let r=64;r<i;){v.limitPrecisionThis(r),C.limitPrecisionThis(r);let n=v.evaluate(p),o=C.evaluate(p),a=n.sub(y),l=o.sub(x);if(a.divThis(y).absThis().lt(s)&&(x.isZero()||l.divThis(x).absThis().lt(s)))break;v.assignCopy(t),C.assignCopy(e),r=Math.min(r+64,i)}y.limitPrecisionThis(a+2),x.limitPrecisionThis(a+2)}let b=4,E=1,S=0,D=0,w=1,A=n.M.constructDouble(.25*o),T=n.M.constructDouble(.5001),I=0;for(;++I<300;){if(I>32&&S>0||x.isZero()||2===w&&S>1||1===w&&b<4)w=1,E>1&&E--;else if(w=2,D>1){let t=f.mul(x);t.absThis(),t.ldexpThis(-3),t.absLessAbs(y)&&E++}f.setThis(P);let t=new n.M,e=!1;if(1===w)do{if(D>2){let e=f.clone();if(e.absThis(),e.ldexpThis(4),_.sub(d).ldexpThis(-1).gt(e)){if(p.equals(d)){t.setThis(p),p.setThis(d.add(e)),p.limitPrecisionThis(a),P.setThis(p.sub(t));break}if(p.equals(_)){t.setThis(p),p.setThis(_.sub(e)),p.limitPrecisionThis(a),P.setThis(p.sub(t));break}}}P.setThis(m.sub(h)),P.ldexpThis(-1),P.limitPrecisionThis(a),t.setThis(p),p.setThis(h.add(P)),p.limitPrecisionThis(a),p.lt(d)?p.setThis(d):p.gt(_)&&p.setThis(_),e=h.equals(p)||m.equals(p)}while(0);else for(;;){if(P.setThis(y.div(x)),P.limitPrecisionThis(a),1!==E&&P.mulDoubleThis(E),t.setThis(p),p.subThis(P),p.limitPrecisionThis(a),e=p.equals(t),p.lt(d)){if(E>1){p.setThis(t),E--;continue}P.setThis(t.sub(d)),p.setThis(d)}else if(p.gt(_)){if(E>1){p.setThis(t),E--;continue}P.setThis(t.sub(_)),p.setThis(_)}break}if(e||P.absLessAbs(A)){t.equals(p)||(y=v.evaluate(p)).limitPrecisionThis(a+2);break}(y=v.evaluate(p)).limitPrecisionThis(a+2),(x=C.evaluate(p)).limitPrecisionThis(a+2);let i=h.clone(),s=m.clone();y.LZ()?(u.setThis(y),h.setThis(p)):(g.setThis(y),m.setThis(p)),2===w&&(h.equals(i)&&m.equals(s)||D>1&&!P.absLessAbs(T.mul(f)))?S++:S=0,1===w?(b++,D=0):(b=0,D++)}return I>=300&&(0,s.c)("Root_finder iterations exceeded"),l.setThis(p),!0}function tU(t,e,i,r,o,a,l,h){(0,s.g)(i>0),(0,s.g)(h>=t.power());let m=[],u=[],g=new tF({zeroCtor:t.m_zeroCtor}),c=new tF({zeroCtor:t.m_zeroCtor}),d=new tF({zeroCtor:t.m_zeroCtor}),_=n.M.constructDouble(i),p=n.M.constructDouble(e.vmin),f=n.M.constructDouble(e.vmax),P=p.sub(_),y=f.add(_),x=tO(t),v=x.clone();if(v.negateThis(),P.lt(v))P.setThis(v.sub(_));else if(P.gt(x))return 0;if(y.gt(x))y.setThis(x.add(_));else if(y.lt(v))return 0;let C=t,b=null;if(o){let e=new tF({coef0:n.M.constructInt32(-1)});e.addElement(n.ae),C=b=new tF;let i=new tF,s=new tF;for(t.div(e,i,s),b.assignCopy(i);C.evaluate(n.ae).isZero();)C.div(e,i,s),b.assignCopy(i)}let E=!1;if(C.power()>0&&C.getElement(0).isZero())for(E=!0,b||(C=b=new tF({copy:C}));C.getElement(0).isZero();)b.shiftRight(1);let S=r+2*C.power()+2,D=i/Math.pow(2,C.power()+2),w=S;if(n.ad.gt(P)&&n.ad.lt(y)){for(let t=0,e=C.power();t<e;t++)if(C.getElement(t).isZero()){m.push(n.ad.clone());break}}for(let t=C.power()-1;t>0;t--)if(D*=2,S-=2,w-=2,C.power()-t!=1)if(C.power()-t!=2){c.assignMove(d),d.assignMove(C.derivative(t-1));let e=[];for(let t=0,i=u.length;t<i;++t)if(u[t].first.lte(u[t].second)){let i=new n.M;if(tH(c,g,u[t].first,u[t].second,D,S,i)){m.push(i);let s=i.sub(_);s.limitPrecisionThis(w),e.push((0,n.n)(u[t].first,s)),(s=i.add(_)).limitPrecisionThis(w),e.push((0,n.n)(s,u[t].second))}else e.push(u[t])}u=e,e=[],g.assignMove(c)}else{c.assignMove(C.derivative(t));
1let e=function(t,e,i,r){if(2>t.power())return tZ(t,i,r);(0,s.g)(r>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));let a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){let s=t.getElement(1);return s.negateThis(),s.divThis(t.getElement(2)),s.ldexpThis(-1),s.limitPrecisionThis(e),i[0].setThis(s),1}(0,s.g)(r>=2),o=n.M.sqrt(o,e+8);let l=t.getElement(1);l.negateThis();let h=l.clone();h.subThis(o),h.divThis(t.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(e);let m=l.clone();return m.addThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}(c,S,l,h);(0,s.g)(e>=0&&e<=2);for(let t=0;t<e;t++)l[t].gt(P)&&l[t].lt(y)&&!l[t].isZero()&&m.push(l[t].clone());if(m.length>1&&m.sort((t,e)=>t.compare(e)),m.length>0){let t=m[0].sub(_);t.limitPrecisionThis(w),u.push((0,n.n)(P.clone(),t));let e=1===m.length?y.clone():m[1].sub(_);(t=m[0].add(_)).limitPrecisionThis(w),e.limitPrecisionThis(w),u.push((0,n.n)(t,e)),m.length>1&&((e=2===m.length?y.clone():m[2].sub(_)).limitPrecisionThis(w),(t=m[1].add(_)).limitPrecisionThis(w),u.push((0,n.n)(t,e)),m.length>2&&((t=m[2].add(_)).limitPrecisionThis(w),u.push((0,n.n)(t,y.clone()))))}else u.push((0,n.n)(P.clone(),y.clone()));g.assignCopy(c),d.assignMove(C.derivative(t-1))}else c.assignMove(C.derivative(t)),1===tZ(c,l,h)&&(l[0].gt(P)&&l[0].lt(y)&&!l[0].isZero()&&m.push(l[0].clone()),g.assignMove(c),d.assignMove(C.derivative(t-1)));m.sort((t,e)=>t.compare(e)),0===u.length&&(g.assignMove(C.derivative(C.power())),g.isZero()||u.push((0,n.n)(P.clone(),y.clone())));let A=0,T=0,I=0,M=new n.M;for(;;){if(T<u.length){if(u[T].first.gt(u[T].second)){T++;continue}let t=!1;if(I<m.length&&m[I].lt(u[T].first)&&(t=!0),!t){tH(C,g,u[T].first,u[T].second,i,r,M)&&(M.lt(p)?l[A++].setThis(p):M.gt(f)?l[A++].setThis(f):l[A++].setThis(M)),T++;continue}}if(!(I<m.length))break;0!==I&&m[I-1].equals(m[I])||function(t,e,i,s,r){let o=t.evaluate(i);if(o.isZero())return!0;let a=n.M.constructDouble(.5*s),l=i.clone();l.subThis(a);let h=t.evaluate(l),m=i.clone();m.addThis(a);let u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ()||(o.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ()))return!0;let g=h.LEZ()&&u.LEZ(),c=h.GEZ()&&u.GEZ(),d=!1;return g?o.gt(h)&&o.gt(u)&&(d=!0):c&&o.lt(h)&&o.lt(u)&&(d=!0),!!d&&o.absThis().lt(n.M.constructDouble(1e-17))}(C,0,m[I],i)&&(M.setThis(m[I]),M.lt(p)?M.setThis(p):M.gt(f)&&M.setThis(f),0!==A&&l[A].equals(M)||l[A++].setThis(M)),I++}return E&&n.ad.gt(P)&&n.ad.lt(y)&&(l[A++].setThis(n.ad),(0,n.C)(l,0,A,(t,e)=>t.compare(e))),o&&n.ae.gt(P)&&n.ae.lt(y)&&(l[A++].setThis(n.ae),(0,n.C)(l,0,A,(t,e)=>t.compare(e))),A}function tO(t){let e=t.getElement(t.power());e.limitPrecisionThis(53);let i=n.ad.clone();for(let s=0,r=t.power();s<r;s++){let r=t.getElement(s);r.limitPrecisionThis(53),r.divThis(e).absThis(),r.gt(i)&&i.setThis(r)}return i.addThis(n.ae),i.mulThis(n.M.constructDouble(1+100*Number.EPSILON)),i}function tJ(t,e,i,s){let r=s;if(!t.isEmpty()){r=0;for(let e=0;e<s;++e)t.containsCoordinate(i[e].value())&&(r!==e&&i[r].setThis(i[e]),r++)}r>1&&(i[0].gt(i[1])&&(i[1]=(0,n.b)(i[0],i[0]=i[1])),r>2&&(i[0].gt(i[2])&&(i[2]=(0,n.b)(i[0],i[0]=i[2])),i[1].gt(i[2])&&(i[2]=(0,n.b)(i[1],i[1]=i[2]))));for(let t=0;t<r;++t)i[t].limitPrecisionThis(e);return r}let tQ=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],tK=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],t$=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],t0=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],t1=[[.024350292663424433,.048690957009139724],[.07299312
1178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],t2=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,44938096029209035e-20]];function t3(t,e,i,s){let r=.5*(s-i),o=i+r,a=new n.K(0);for(let i=0,s=Math.trunc(t/2);i<s;++i){let s,l;switch(t){case 4:s=tQ[i][0],l=tQ[i][1];break;case 8:s=tK[i][0],l=tK[i][1];break;case 16:s=t$[i][0],l=t$[i][1];break;case 32:s=t0[i][0],l=t0[i][1];break;case 64:s=t1[i][0],l=t1[i][1];break;case 128:s=t2[i][0],l=t2[i][1];break;default:throw Error("Quadrature_integral: invalid n")}let h=(0,n.aj)(-.5,s,o),m=(0,n.aj)(r,s,o);a.pe(e(h)*l),a.pe(e(m)*l)}return a.getResult()*r}function t4(t,e,i,s,r,n){return t5(t,e,i,n,s,r)}function t5(t,e,i,r,o,a){if(i<e&&(0,s.t)("xTo < xFrom"),i===e)return 0;let l=[0],h=Number.MAX_VALUE,m=[Number.MAX_VALUE],u=0,g=(0,n.d)(33,NaN),c=(0,n.d)(33,NaN),d=[0];g[0]=1;let _=0,p=0;for(let f=0;f<32;
1f++){if(u=function(t,e,i,s,r,o){let a=r;if(s)return o[0]=1,a=.5*(e-t)*(i(t)+i(e));let l=o[0],h=(e-t)/l,m=new n.K(0);for(let e=1;e<=o[0];++e){let s=(e-.5)*h;m.add(i(t+s))}return a=.5*(a+(e-t)*m.getResult()/l),o[0]*=2,a}(e,i,r,0===f,u,d),c[f]=u,f+1>=t){(function(t,e,i,s,r,o,a){let l=0,h=Math.abs(0-i[t]),m=(0,n.d)(e,NaN),u=(0,n.d)(e,NaN);for(let r=0;r<e;++r){let e=Math.abs(0-i[t+r]);e<h&&(l=r,h=e),m[r]=s[t+r],u[r]=s[t+r]}let g=0,c=0,d=0;o[0]=s[t+l],l--;for(let s=1;s<e;s++){for(let n=0;n<e-s;n++){if(0==(g=(c=i[t+n]-r)-(d=i[t+n+s]-r)))return!1;let e=(m[n+1]-u[n])/g;m[n]=c*e,u[n]=d*e}if(2*(l+1)<e-s){let t=l+1;a[0]=m[t]}else{let t=l;a[0]=u[t],l--}o[0]+=a[0]}return!0})(f+1-t,t,g,c,0,l,m)||(0,s.c)("polynomial_interpolation");let e=o*Math.abs(l[0])+a,i=Math.abs(h-l[0]);if(i<=e&&Math.abs(m[0])<=e){if(++_>1&&(i<=.1*p||0===p||_>2))return l[0]}else _=0;p=i,h=l[0]}c[f+1]=c[f],g[f+1]=.25*g[f]}return l[0]}class t6{constructor(){this.length=NaN,this.area=NaN,this.centroidX=NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}let t8=class{constructor(t,e,i){this.controlPoints=(0,n.L)(t,3),this.weights=[0,0,0],(0,n.a)(this.weights,e,0,0,3),this.point=i.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){let t=new n.P;eX(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return es(this.controlPoints,this.weights,1,e,i),2*t.sub(this.point).dotProduct(i[1])}if(1===t){let t=new n.P;eX(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return es(this.controlPoints,this.weights,2,e,i),2*(t.sub(this.point).dotProduct(i[2])+i[1].dotProduct(i[1]))}if(2===t){let t=new n.P;eX(this.controlPoints,this.weights,e,t);let i=(0,n.m)(n.P,4);return es(this.controlPoints,this.weights,3,e,i),2*(t.sub(this.point).dotProduct(i[3])+3*i[1].dotProduct(i[2]))}return 0}getError(t){return(0,s.g)(0),0}};function t7(t){t.m_cachedValues=null}function t9(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new t6,i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=[0,0,0];return t.queryWeights(s),et(i,s,e.specialPoints),eg(t,e),e}function et(t,e,i){if(0===e[1])return i.length=0,i.push(0),void i.push(1);let s=(0,n.m)(n.F,8);s[0].set(0);let r=1;{let i=new n.F(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new n.F(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.F(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.m)(n.F,2),h=tv(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.J)(l[t].value(),0,1)||(s[r]=l[t],r++)}{let i=new n.F(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new n.F(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=i.subE(o).addThisE(new n.F(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(i.mul(2));let l=(0,n.m)(n.F,2),h=tv(a,o,i,new n.E(0,1),!1,l);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.J)(l[t].value(),0,1)||(s[r]=l[t],r++)}if(s[r].set(1),++r>2){(0,n.C)(s,0,r,(t,e)=>(0,n.X)(t.value(),e.value()));let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),s[++t]=s[n],e=s[n].value(),i=1);r=++t}s[0].set(0),s[r-1].set(1),i.length=r;for(let t=0;t<r;t++)i[t]=s[t].value()}function ee(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+ee(t,1,!1)}if(t.isDegenerate(0))return 0;let r=1===e,o=t9(t);if(r&&!Number.isNaN(o.length))return o.length;let a=em(t),l=a/t.calculateUpperLength2D(),h=0,m=0;for(let i=1,r=o.specialPointsCount();i<r;i++){let r=o.specialPoints[i];if(h+=function(t,e,i,r,o){if(i===e)return 0;let a=(0,n.m)(n.P,3),l=[0,0,0];t.queryControlPoints(a),t.queryWeights(l);let h=[0,0,0],m=(0,n.m)(n.P,3);return ev(a,l,e,i,m,h),function t(e,i,r,o,a,l,h,m){for(;;){let u=n.P.distance(i[0],i[2]),g=n.P.distance(i[0],i[1])+n.P.distance(i[1],i[2]);if(g-u<=a+o*g)return e+(0,n.q)(u,g,.5);let c=(0,n.m)(n.P,4),d=t=>(es(i,r,1,t,c),c[1].length());if(0===h&&m<8){(0,s.g)(m<8);let u=d(0),c=d(1);l[0]+=2,u>c&&(c=(0,n.b)(u,u=c),i[2]=(0,n.b)(i[0],i[0]=i[2]),r[2]=(0,n.b)(r[0],r[0]=r[2]));let _=u/(u+c),p=1,f=g;for(;_<1/32&&f>=a+o*f;){let t=d(p/=4);l[0]++,_=u/(t+u);let e=new n.P;if(eX(i,r,.5*p,e),(f=n.P.distance(e,i[0]))<=a){let t=new n.P;eX(i,r,p,t),f+=n.P.distance(t,e)}}if(1!==p){let s=(0,n.m)(n.P,3),u=[0,0,0];ex(i,r,p,i,r,s,u),e=t(e,s,u,o,a,l,0,m+1),h++,m++;continue}}l[0]+=8;let _=t3(8,d,0,1);l[0]+=16;
1let p=t3(16,d,0,1);if(!(Math.abs(_-p)>a+o*g))return e+p;if(h<8&&m<9){let s=(0,n.m)(n.P,3),u=[0,0,0];ex(i,r,.5,i,r,s,u),e=t(e,s,u,o,a,l,h+1,m+1),h++,m++;continue}l[0]+=32;let f=t3(32,d,0,1);if(!(Math.abs(p-f)>a+o*g))return e+f;l[0]+=64;let P=t3(64,d,0,1);if(!(Math.abs(f-P)>a+o*g))return e+P;l[0]+=128;let y=t3(128,d,0,1);return e+y}}(0,m,h,r,o,[0],0,0)}(t,m,Math.min(e,r),l,a),e<=r)break;m=r}return r&&(o.length=h),h}function ei(t,e,i,s){let r=(0,n.m)(n.P,3);t.queryControlPoints(r);let o=[0,0,0];t.queryWeights(o),es(r,o,e,i,s)}function es(t,e,i,r,o){let a=[t[0],t[1],t[2]],l=[e[0],e[1],e[2]],h=(0,n.m)(n.P,4);!function(t,e,i,r,n){(0,s.g)(i>0);let o=[t[0].clone(),t[1].clone(),t[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}let a=er(o,e,0,r),l=eo(e,0,r),h=a.divide(l);if(n[0].assign(h),0===i)return;let m=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],g=l*l,c=er(u,m,0,r).mul(2).divide(g);if(n[1].assign(c),1===i)return;let d=eo(e,1,r),_=2*l*d,p=er(u,m,1,r).mul(2).sub(c.mul(_)).divide(g);if(n[2].assign(p),2===i)return;let f=er(u,m,2,r).mul(2),P=2*(d*d+l*eo(e,2,r)),y=f.sub(p.mul(_).mul(2)).sub(c.mul(P)).divide(g);n[3].assign(y),3!==i&&(0,s.c)("")}(a,l,i,r,h);for(let t=0;t<=i;t++)o[t].setCoords(h[t].x,h[t].y)}function er(t,e,i,r){if(0===i){if(r<=.5){let i=new n.P;(0,n.V)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.V)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.V)(2,i,s,r,o),o}{let i=new n.P;(0,n.W)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,i);let s=new n.P;(0,n.W)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,s);let o=new n.P;return(0,n.W)(2,i,s,r,o),o}}if(1===i){let i=t[1].mul(e[1]),s=i.sub(t[0].mul(e[0])).mul(1-r).add(t[2].mul(e[2]).sub(i).mul(r));return s.mulThis(2),s}if(2===i){let i=t[1].mul(e[1]),s=t[2].mul(e[2]).sub(i).sub(i.sub(t[0].mul(e[0])));return s.mulThis(2),s}(0,s.c)("")}function en(t,e,i,s){if(.5>=s.toDouble()){let i=new y;(0,n.a1)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new y;(0,n.a1)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new y;return(0,n.a1)(2,i,r,s,o),o}{let i=new y;(0,n.a2)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),s,i);let r=new y;(0,n.a2)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),s,r);let o=new y;return(0,n.a2)(2,i,r,s,o),o}}function eo(t,e,i){if(0===e){let e=(0,n.q)(t[0],t[1],i),s=(0,n.q)(t[1],t[2],i);return(0,n.q)(e,s,i)}return 1===e?2*((1-i)*(t[1]-t[0])+(t[2]-t[1])*i):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,s.c)("")}function ea(t,e,i){let s=(0,n.c)(i,0,1),r=(0,n.m)(n.P,4);if(es(t,e,3,s,r),r[1].isZero()){if(r[2].isZero())return r[3];{let t=r[2].clone();return 1===s&&t.negateThis(),t}}return r[1]}let el=class{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-ee(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}};function eh(t){let e=(0,n.m)(n.P,3),i=[0,0,0];return t.queryControlPoints(e),t.queryWeights(i),function(t,e){let i=eF(e);if(1===i)return e$(t);if(0===i)return 0;let r=[new n.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=r[1].crossProduct(r[2]);if(i<1){let t;(0,s.g)(i>0);let e=1-i;if(e<.01)t=-1/3+e*(2/15+e*(3/35+e*(16/315+e*(20/693+e*(16/1001+56/6435*e)))));else{let s=e*(1+i),r=Math.atan2(Math.sqrt(e),Math.sqrt(1+i));t=i*(.5*i-(0,n.ak)(s)*r)/s}return o*t}{let t=(i-1)*(i+1);return .25*i/Math.pow(t,1.5)*(-2*i*Math.sqrt(t)*o-4*r[1].y*r[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-r[1].x*r[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}(e,i)}function em(t){var e;return e=t.calculateUpperLength2D(),256*(0,n.N)()*e}function eu(t){return t.m_cachedValues}function eg(t,e){t.m_cachedValues=e}function ec(t,e,i,s,r){let o=(0,n.m)(n.P,3);t.queryControlPoints(o);let a=[0,0,0];t.queryWeights(a);let l=[0];return 1===ed(o,a,e,n.E.unit(),s,r,1,l)?l[0]:NaN}function ed(t,e,i,o,a,l,h,m){(0,s.w)(n.E.unit().contains(o)&&h>0,""),(l<0||Number.isNaN(l))&&(l=Number.MAX_VALUE);let u=[,,,];for(let e=0;e<3;++e)u[e]=t[e].sub(i);let g=eF(e),c=tX.constructPoint2D(u[0]),d=tX.constructPoint2D(u[1]),_=tX.constructPoint2D(u[2]),p=n.M.constructDouble(g),f=p.clone();f.ldexpThis(1);let P=c.dotProduct(d.sub(c)).mul(p),y=p.mul(p.addDouble(2)),x=_.sub(d.mul(y.ldexp(1))),v=d.sqrLength().mul(p.mul(p).ldexp(1)).add(c.sqrLength().mul(p.ldexp(2).subDouble(1))).add(c.dotProduct(x)),C=_.sub(d.mul(f)).add(c.mul(f.subDouble(1))),b=d.mul(p).sub(c).dotProduct(C).mulDouble(3),E=d.dotProduct(_).mul(p.subDouble(3).mul(p)).ldexp(1),S=d.sqrLength().mul(p.mul(p).ldexp(2)),D=c.sqrLength().mul(p.ldexp(2).subDouble(3)),w=c.dotProduct(_.sub(d.mul(p.mulDouble(3).subDouble(1)).mul(p))).ldexp(1),A=_.sqrLength().addThis(E).addThis(S).addThis(D).addThis(w),T=c.add(_).sub(d.mul(f)),I=p.subDouble(1),M=_.sub(c).dotProduct(T).mul(I),Y=new n.P(0,0),X=[],q=new n.P;eX(u,e,o.vmin,q);let F=n.P.distance(q,Y);if(F<=l&&X.push(new n.P(o.vmin,F)),o.vmin!==o.vmax&&(eX(u,e,o.vmax,q),(F=n.P.distance(q,Y))<=l&&X.push(new n.P(o.vmax,F))),o.width()>0){let t=u[2].isZero(),i=(0,n.m)(n.M,4),s=tk(M,A,b,v,P,58,o,t,i);for(let t=0;t<s;
1t++){if(!o.containsExclusiveCoordinate(i[t].toDouble()))continue;let s=i[t].toDouble();s=eN(e,s);let r=new n.P;eX(u,e,s,r),(F=n.P.distance(r,Y))<=l&&X.push(new n.P(s,F))}}if(a){(0,s.g)(o.equals(n.E.unit()));{eX(u,e,-1,q,!0);let t=new n.P;eX(u,e,0,t);let i=new rP({start:q,end:t}),s=i.getClosestCoordinate(Y,!0);s<1&&(q=i.getCoord2D(s),(F=n.P.distance(q,Y))<=l&&X.push(new n.P(s-1,F)))}{eX(u,e,2,q,!0);let t=new n.P;eX(u,e,o.vmax,t);let i=new rP({start:t,end:q}),s=i.getClosestCoordinate(Y,!0);s>0&&(q=i.getCoord2D(s),(F=n.P.distance(q,Y))<=l&&X.push(new n.P(1+s,F)))}}if(!X.length)return 0;X.sort((t,e)=>t.compare(e));let N=0,V=X[0].x;if(m[N++]=V,N<h){let t=(0,r.x)(u,4,!1).total(),e=X[0].y;for(let i=1,s=X.length;i<s;i++)if(X[i].y>e+t){X.length=i;break}X.sort((t,e)=>(0,n.X)(t.x,e.x)),N=0,m[N++]=X[0].x;for(let t=1,e=X.length;t<e;t++)X[t].x!==m[N-1]&&N<h&&(m[N++]=X[t].x)}return N}function e_(t,e,i){let s=(0,n.m)(n.P,3);t.queryControlPoints(s);let r=[0,0,0];t.queryWeights(r),ep(s,r,e,i)}function ep(t,e,i,s){if(i.equalsRange(0,1))return void s.setFromPoints(t,3);let r=(0,n.m)(n.P,3);ev(t,e,i.vmin,i.vmax,r,[0,0,0]),s.setFromPoints(r,3)}function ef(t){let e=(0,n.Y)(t[0].y,t[1].y),i=(0,n.Y)(t[1].y,t[2].y);if(e>=0&&i>=0||e<=0&&i<=0){let e=(0,n.Y)(t[0].x,t[1].x),i=(0,n.Y)(t[1].x,t[2].x);if(e>=0&&i>=0||e<=0&&i<=0)return!0}return!1}function eP(t){let e=(0,n.m)(n.P,3);t.queryControlPoints(e);let i=ey(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function ey(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.Y)(t[0][i],t[2][i]);s>0?(0>(0,n.Y)(t[0][i],t[1][i])&&(t[1][i]=t[0][i],e=!0),0>(0,n.Y)(t[1][i],t[2][i])&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.Y)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.Y)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function ex(t,e,i,o,a,l,h){(0,s.g)(i>=0&&i<=1&&o!==l&&a!==h),(0,s.g)(e[0]>0&&e[2]>0&&e[1]>=0);let m=[1,eF(e),1],u=eV(e,i),g=(0,n.L)(t,3),c=(0,n.m)(r.h,3);eI(g,m,c);let d=(0,n.m)(r.h,3),_=(0,n.m)(r.h,3);eL(c,u,o?d:null,l?_:null),eR(e,i,a,h);let p=ef(g);if(o){for(let t=0;t<3;++t)eY(d[t],o[t]);eG(g,o),p&&ey(o)}if(l){for(let t=0;t<3;++t)eY(_[t],l[t]);eG(g,l),p&&ey(l)}}function ev(t,e,i,o,a,l){if((0,s.g)(i>=0&&o<=1&&i<=o),i===o){let s=new n.P,r=eM(t,e,i,s);return ez(t,s),a[0].assign(s),a[1].assign(s),a[2].assign(s),l[0]=r,l[1]=r,void(l[2]=r)}if(0===i&&1===o)return a[0].assign(t[0]),a[1].assign(t[1]),a[2].assign(t[2]),l[0]=e[0],l[1]=e[1],void(l[2]=e[2]);let h=(0,n.m)(r.h,3);{let s=[1,eF(e),1],r=eV(e,i),n=eV(e,o);eI(t,s,h),eL(h,n,h,null),eL(h,r>=n?1:r/n,null,h)}let m=[0,0,0];eR(e,o,m,null),eR(m,i/o,null,m);let u=ef(t),g=(0,n.m)(n.P,3);eY(h[1],g[1]),eX(t,e,i,g[0]),eX(t,e,o,g[2]),eG(t,g);for(let t=0;t<3;++t)a[t].assign(g[t]),l[t]=m[t];u&&ey(a)}function eC(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==eS(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1))}function eb(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==eD(t,e,i,null,null,null,s,r??!1,!0,!1))}function eE(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==eA(t,e,i,null,null,null,s,r??!1,!0,!1))}function eS(t,e,i,r,o,a,l,h,m,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!=a)for(let t=0;t<s;t++)a.push(0);if(null!=r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let g=R(e,i);if(l=Math.max(l,g),e.isDegenerateToLineHelper(g)){let t=new rP({start:e.getStartXY(),end:e.getEndXY()}),s=ti(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(z(e,i,l))return 0;let c=(0,n.m)(n.P,3);e.queryControlPoints(c);let d=[0,0,0];e.queryWeights(d);let _=[1,eF(d),1],p=i.getEndXY().sub(i.getStartXY()),f=p.clone();f.leftPerpendicularThis();let P=c[0].clone(),y=c[1].clone(),x=c[2].clone(),v=y.sub(P),C=x.sub(P),b=x.sub(y),E=_[0],S=_[1],D=_[2],w=v.dotProduct(f)*(E*S),A=C.dotProduct(f)*(E*
1D),T=w,I=A-2*w,M=b.dotProduct(f)*(S*D)+A-A,Y=(0,n.d)(13,NaN),X=(0,n.d)(13,NaN),q=t_(M,I,T,n.E.unit(),!1,Y);q<0&&(Y[0]=0,Y[1]=1,q=2);let F=0;for(let t=0,e=F;t<q;++t){let s=new n.P;eX(c,_,Y[t+e],s),X[F]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(X[F]))<=l&&(Y[F]=Y[t+e],F++)}let N=(0,n.m)(n.P,3),V=(0,n.m)(n.P,3);if(e.queryControlPoints(V),V[0].subThis(i.getStartXY()),V[1].subThis(i.getStartXY()),V[2].subThis(i.getStartXY()),function(t,e,i,s=!1){let r=(0,n.m)(n.P,3);s?(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[1].subThis(r[0]),r[2].setCoordsPoint2D(t[2]),r[2].subThis(r[0]),r[0].setCoords(0,0)):(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[2].setCoordsPoint2D(t[2])),r[0].mulThis(e[0]),r[1].mulThis(e[1]),r[2].mulThis(e[2]),i[1].setCoords(r[1].x-r[0].x,r[1].y-r[0].y),i[2].setCoordsPoint2D(r[2].sub(r[1])),i[2].subThis(i[1]),i[1].x*=2,i[1].y*=2,i[0].setCoordsPoint2D(r[0])}(V,_,N,!1),Math.abs(p.x)>=Math.abs(p.y)){let t=p.y/p.x;M=N[2].y-N[2].x*t,I=N[1].y-N[1].x*t,T=N[0].y-N[0].x*t}else{let t=p.x/p.y;M=N[2].x-N[2].y*t,I=N[1].x-N[1].y*t,T=N[0].x-N[0].y*t}let L=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),G=[0,0];q=t_(M,I,T,n.E.unit(),L,G);for(let t=0,e=F;t<q;++t){Y[t+e]=G[t];let s=new n.P;eX(c,_,Y[t+e],s),X[F]=i.getClosestCoordinate(s,!1),n.P.distance(s,i.getCoord2D(X[F]))<=l&&(Y[F]=Y[t+e],F++)}(0,s.g)(F<Y.length+4);for(let t=0;t<F;t++)Y[t]=eN(d,Y[t]);q=e.intersectPoint(i.getStartXY(),G,l);for(let t=0;t<q;t++)Y[F]=G[t],X[F++]=0;q=e.intersectPoint(i.getEndXY(),G,l);for(let t=0;t<q;t++)Y[F]=G[t],X[F++]=1;q=i.intersectPoint(e.getStartXY(),G,l);for(let t=0;t<q;t++)X[F]=G[t],Y[F++]=0;q=i.intersectPoint(e.getEndXY(),G,l);for(let t=0;t<q;t++)X[F]=G[t],Y[F++]=1;return 0===F?0:rd(t,e,i,Y,X,F,r,o,a,l,h,m,u)}function eD(t,e,i,s,r,o,l,h,m,u){if(sY(i))return eS(t,e,new rP({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,m,u);let g=R(e,i);if(z(e,i,l=Math.max(l,g)))return 0;let c=[],d=[],_=(0,n.m)(n.P,4);{e.queryControlPoints(_);let t=(0,n.m)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(_,4,t);let o=(0,n.m)(n.M,3),h=(0,n.m)(n.M,3),m=(0,n.m)(n.M,3),u=[0,0,0];e.queryWeights(u),eT(t,u,o,h,m);let g=(0,n.m)(n.M,3);g[0].setDouble(i.getSemiMinorAxis()),g[0].sqrThis(),g[1].setDouble(i.getSemiMajorAxis()),g[1].sqrThis(),g[2].setThis(g[0]),g[2].mulThis(g[1]),g[2].negateThis();let p=tL(o,2,h,2,m,2,g,!0,n.E.unit(),n.E.unit(),c);if(p>0){let t=0;for(let s=0;s<p;s++){let r=new n.P;e.queryCoord2D(c[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(c[t]=c[s],d.push(o),t++)}c.length=t}}let p=[0,1];for(let t=0;t<2;t++){let s=0===t?i.getStartXY():i.getEndXY(),r=ec(e,s,n.E.unit(),!1,-1),o=new n.P;e.queryCoord2D(r,o),n.P.distance(s,o)<=l&&(c.push(r),d.push(p[t]))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(_[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(_[e[t]],r)<=l&&(c.push(p[t]),d.push(s))}}return rd(t,e,i,c,d,c.length,s,r,o,l,h,m,u)}function ew(t,e,i,r,o,a,l,h,m,u){let g=(0,n.m)(n.P,3);e.queryControlPoints(g);let c=(0,n.m)(n.P,3);if(i.queryControlPoints(c),0>G(g,c,3))return ew(t,i,e,r,a,o,l,h,m,!u);let d=R(e,i);if(e.isDegenerateToLineHelper(d)){let s=new rP({start:e.getStartXY(),end:e.getEndXY()}),n=eS(t,i,s,r,a,o,l,h,m,!u);if(o)for(let t=0;t<n;++t){let i=s.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(i,!1)}return n}if(i.isDegenerateToLineHelper(d)){let s=new rP({start:i.getStartXY(),end:i.getEndXY()}),n=eS(t,e,s,r,o,a,l,h,m,u);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(z(e,i,l=Math.max(l,d)))return 0;let _=(0,n.d)(3,NaN);e.queryWeights(_);let f=(0,n.d)(3,NaN);i.queryWeights(f);let P=[1,eF(_),1],y=[1,eF(f),1],x=new n.E(0,1),v=new n.E(0,1);{let t=p.constructEmpty();ep(g,P,new n.E(0,1),t);let e=p.constructEmpty();ep(c,y,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(eq(g,P,t,x),eq(c,y,t,v),x.isEmpty()||v.isEmpty())return 0;ev(g,P,x.vmin,x.vmax,g,P),ev(c,y,v.vmin,v.vmax,c,y)}}let C=rp(g,2,c,2,l);if(0===C)return 0;let b=[],E=[];if(-1===C){let t=(0,n.m)(n.M,3),e=(0,n.m)(n.M,3),i=(0,n.m)(n.M,3);eT(g,P,t,e,i);let s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);eT(c,y,s,r,o);let a=[],h=[],m=tV(t,2,e,2,i,2,s,2,r,2,o,2,!0,n.E.unit(),n.E.unit(),a,h);if(m>0)for(let t=0;t<m;t++){let e=new n.P;eX(c,y,h[t],e);let i=new n.P;eX(g,P,a[t],i),n.P.distance(i,e)<=l&&(b.push(a[t]),E.push(h[t]))}}for(let t=0;t<2;t++){let e,i,r;0===t?(e=g,i=c,r=y):(e=c,i=g,r=P);for(let o=0;o<2;o++){let a=0===o?0:e.length-1,h=new n.P,m=[0],u=ed(i,r,e[a],n.E.unit(),!1,-1,1,m);(0,s.g)(1===u),eX(i,r,m[0],h),n.P.distance(e[a],h)<=l&&(0===t?(b.push(+(0!==a)),E.push(m[0])):(E.push(+(0!==a)),b.pu
1sh(m[0])))}}if(0===b.length)return 0;if(!x.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=tY.recalculateParentT(x.vmin,x.vmax,b[t]);if(!v.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=tY.recalculateParentT(v.vmin,v.vmax,E[t]);for(let t=0;t<b.length;++t)b[t]=eN(_,b[t]);for(let t=0;t<E.length;++t)E[t]=eN(f,E[t]);return rd(t,e,i,b,E,b.length,r,o,a,l,h,m,u)}function eA(t,e,i,s,r,o,a,l,h,m){if(e.isLine())return ii(t,i,new rP({start:e.getStartXY(),end:e.getEndXY()}),s,o,r,a,l,h,!m);if(i.isLine())return eS(t,e,new rP({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,a,l,h,m);let u=R(e,i);if(z(e,i,a=Math.max(a,u)))return 0;let g=(0,n.m)(n.P,3);e.queryControlPoints(g);let c=(0,n.m)(n.P,3);i.queryControlPoints(c);let d=rp(g,2,c,2,a);if(0===d)return 0;let _=[],p=[];if(-1===d){let t=(0,n.m)(n.M,3),s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=[0,0,0];e.queryWeights(o),eT(g,o,t,s,r);let l=(0,n.m)(tX,3);ia(c,l);let h=tV(t,2,s,2,r,2,[l[0].x,l[1].x,l[2].x],2,[l[0].y,l[1].y,l[2].y],2,null,0,!0,n.E.unit(),n.E.unit(),_,p);if(h>0){let t=0;for(let s=0;s<h;s++){let r=new n.P;i.queryCoord2D(p[s],r);let o=new n.P;e.queryCoord2D(_[s],o),n.P.distance(o,r)<=a&&(_[t]=_[s],p[t]=p[s],t++)}_.length=t,p.length=t}}for(let t=0;t<2;t++){let s;s=0===t?g:c;for(let r=0;r<2;r++){let o,l=0===r?0:s.length-1,h=new n.P;0===t?(o=e2(i,s[l],n.E.unit(),!1),i.queryCoord2D(o,h)):(o=ec(e,s[l],n.E.unit(),!1,-1),e.queryCoord2D(o,h)),n.P.distance(s[l],h)<=a&&(0===t?(_.push(+(0!==l)),p.push(o)):(p.push(+(0!==l)),_.push(o)))}}return rd(t,e,i,_,p,_.length,s,r,o,a,l,h,m)}function eT(t,e,i,s,r){let o=n.M.constructDouble(e[0]),a=n.M.constructDouble(e[1]),l=n.M.constructDouble(e[2]);i[0].setDouble(t[0].x),i[0].mulThis(o),i[1].setDouble(t[1].x),i[1].mulThis(a),i[2].setDouble(t[2].x),i[2].mulThis(l),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),s[0].setDouble(t[0].y),s[0].mulThis(o),s[1].setDouble(t[1].y),s[1].mulThis(a),s[2].setDouble(t[2].y),s[2].mulThis(l),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),r[0].setDouble(e[0]),r[1].setDouble(e[1]),r[2].setThis(r[1]),r[2].ldexpThis(1),r[2].negateThis(),r[2].addThis(r[0]),r[2].addDoubleThis(e[2]),r[1].subThis(r[0]),r[1].ldexpThis(1)}function eI(t,e,i){for(let s=0;s<3;++s)i[s].setCoordsPoint2DZ(t[s].mul(e[s]),e[s])}function eM(t,e,i,s){let r,o,a;if(0===i)return s.assign(t[0]),e[0];if(1===i)return s.assign(t[2]),e[2];let l=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],h=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],m=[e[0],e[1],e[2]];if(i<=.5){let t=(0,n.Q)(l[0],l[1],i),e=(0,n.Q)(l[1],l[2],i);r=(0,n.q)(t,e,i);let s=(0,n.Q)(h[0],h[1],i),u=(0,n.Q)(h[1],h[2],i);o=(0,n.q)(s,u,i);let g=(0,n.Q)(m[0],m[1],i),c=(0,n.Q)(m[1],m[2],i);a=(0,n.Q)(g,c,i)}else{let t=(0,n.R)(l[0],l[1],i),e=(0,n.R)(l[1],l[2],i);r=(0,n.R)(t,e,i);let s=(0,n.R)(h[0],h[1],i),u=(0,n.R)(h[1],h[2],i);o=(0,n.R)(s,u,i);let g=(0,n.R)(m[0],m[1],i),c=(0,n.R)(m[1],m[2],i);a=(0,n.R)(g,c,i)}return r/=a,o/=a,s.setCoords(r,o),ez(t,s),a}function eY(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function eX(t,e,i,s,r){if(r){if(i<0)return void O(new rP({start:t[0],end:t[0].add(ea(t,e,0).getUnitVector())}),i,s);if(i>1)return void O(new rP({start:t[2],end:t[2].add(ea(t,e,1).getUnitVector())}),i-1,s)}eM(t,e,i,s)}function eq(t,e,i,s){s.setEmpty();let r=[];r.push(new n.E(0,1));let o=.5*Math.max(i.width(),i.height());for(;r.length;){let a=r.at(-1);r.pop();let l=new p;if(ep(t,e,a,l),l.isIntersectingW(i)){let t=Math.max(l.width(),l.height());if(i.containsW(l)||t<=o||1e-12>a.width())s.merge(a);else{let t=a.getCenter();r.push(n.E.construct(a.vmin,t)),r.push(n.E.construct(t,a.vmax))}}}}function eF(t){return t[1]/Math.sqrt(t[0]*t[2])}function eN(t,e){let i=Math.sqrt(t[2]/t[0]);return e/(0,n.q)(i,1,e)}function eV(t,e){let i=Math.sqrt(t[0]/t[2]);return e/(0,n.q)(i,1,e)}function eL(t,e,i,o){(0,s.g)(e>=0&&e<=1),(new r.h).setCoordsPoint3D(t[0]),(new r.h).setCoordsPoint3D(t[1]),(new r.h).setCoordsPoint3D(t[2]);let a=new r.h,l=new r.h,h=new r.h;(0,n.a0)(3,t[0],t[1],e,a),(0,n.a0)(3,t[1],t[2],e,l),(0,n.a0)(3,a,l,e,h);let m=t[2].clone();i&&(i[0].assign(t[0]),i[1].assign(a),i[2].assign(h)),o&&(o[0].assign(h),o[1].assign(l),o[2].assign(m))}
1function eR(t,e,i,r){let o=[t[0],t[1],t[2]];(0,s.g)(e>=0&&e<=1&&i!==r);let a=(0,n.q)(o[0],o[1],e),l=(0,n.q)(o[1],o[2],e),h=(0,n.q)(a,l,e);i&&(i[0]=o[0],i[1]=a,i[2]=h),r&&(r[0]=h,r[1]=l,r[2]=o[2])}function ez(t,e){let i=n.E.constructEmpty();i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e.x=(0,n.c)(e.x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e.y=(0,n.c)(e.y,i.vmin,i.vmax)}function eG(t,e){let i=new n.E;i.vmin=i.vmax=t[0].x,i.mergeNeCoordinate(t[1].x),i.mergeNeCoordinate(t[2].x),e[0].x=(0,n.c)(e[0].x,i.vmin,i.vmax),e[1].x=(0,n.c)(e[1].x,i.vmin,i.vmax),e[2].x=(0,n.c)(e[2].x,i.vmin,i.vmax),i.vmin=i.vmax=t[0].y,i.mergeNeCoordinate(t[1].y),i.mergeNeCoordinate(t[2].y),e[0].y=(0,n.c)(e[0].y,i.vmin,i.vmax),e[1].y=(0,n.c)(e[1].y,i.vmin,i.vmax),e[2].y=(0,n.c)(e[2].y,i.vmin,i.vmax)}class ek{constructor(){this.area=NaN,this.centroid_x=NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}class eB{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-eH(this.b,e,!1):0}getError(t){return(0,s.g)(0),0}}function eW(t){t.m_cachedValues=null}function ej(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new ek;return eZ(t,e.specialPoints),e1(t,e),e}function eZ(t,e){let i=(0,n.m)(n.P,3);t.queryControlPoints(i);let s=(0,n.m)(n.F,8);s[0].set(0);let r=1;{let t=(0,n.m)(n.F,3);!function(t,e,i=!1){let s=new n.F(t[1][0]).subE(new n.F(t[0][0]));e[1]=s.mul(2),e[2]=new n.F(t[2][0]).subE(new n.F(t[1][0])).subE(s),i?e[0].set(0):e[0].set(t[0][0])}(i,t,!1);let e=(0,n.m)(n.F,2),o=new n.E(0,1),a=tx(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.J)(e[t].value(),0,1)||(s[r]=e[t],r++)}{let t=(0,n.m)(n.F,3);!function(t,e,i=!1){let s=new n.F(t[1][1]).subE(new n.F(t[0][1]));e[1]=s.mul(2),e[2]=new n.F(t[2][1]).subE(new n.F(t[1][1])).subE(s),i?e[0].set(0):e[0].set(t[0][1])}(i,t,!1);let e=(0,n.m)(n.F,2),o=new n.E(0,1),a=tx(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.J)(e[t].value(),0,1)||(s[r]=e[t],r++)}if(s[r].set(1),++r>2){(0,n.C)(s,0,r,(t,e)=>t.value()-e.value());let t=0,e=s[0].value(),i=1;for(let n=1;n<r;n++)s[n].eq(s[n-1])?(e+=s[n].value(),i++):(i>1&&(e/=i,s[t].set(e)),s[++t]=s[n],e=s[n].value(),i=1);r=++t}s[0].set(0),s[r-1].set(1),e.length=r;for(let t=0;t<r;t++)e[t]=s[t].value()}function eH(t,e,i){let s=(0,n.m)(n.P,3);return t.queryControlPoints(s),function t(e,i,s){if(s){if(i<0)return i;if(i>1)return i-1+t(e,1,!1)}if(1===i)return eU(e);let r=(0,n.m)(n.P,3);return e7(e,i,r,null),eU(r)}(s,e,i)}function eU(t){if(t[0].equals(t[1]))return n.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return n.P.distance(t[0],t[2]);let e=n.P.distance(t[0],t[1])+n.P.distance(t[2],t[1]),i=n.P.distance(t[0],t[2]);if(e-i<=e*Number.EPSILON)return i;let s=(0,n.m)(n.P,3);io(t,s,!0);let r=4*((0,n.s)(s[2].x)+(0,n.s)(s[2].y)),o=2*(s[2].x*s[1].x+s[2].y*s[1].y),a=(0,n.s)(s[1].x)+(0,n.s)(s[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r))return 1e-14*Math.abs(a)>=Math.abs(o)?+Math.sqrt(a):2/(3*o)*(Math.pow(+o+a,1.5)-Math.pow(a,1.5));let l=o/r,h=a/r,m=h-l*l,u=1+l;if(0===m)return l>=0&&u>=0||l<=0&&u<=0?Math.abs(.5*Math.sqrt(r)*(u*u-l*l)):.5*Math.sqrt(r)*(u*u+l*l);let g=Math.sqrt(m+u*u),c=Math.sqrt(h);return .5*Math.sqrt(r)*(u*g-l*c+m*Math.log(Math.abs((u+g)/(l+c))))}function eO(t,e){let i=(0,n.c)(e,0,1),s=eQ(t,1,i);return s.isZero()&&(s=eQ(t,2,i)),s}function eJ(t,e,i){let s=(0,n.m)(n.P,3);return t.queryControlPoints(s),eQ(s,e,i)}function eQ(t,e,i){if(1===e){let e=t[1].sub(t[0]).mul(1-i).add(t[2].sub(t[1]).mul(i));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):n.P.construct(0,0)}function eK(t){let e=(0,n.m)(n.P,3);return t.queryControlPoints(e),e$(e)}function e$(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function e0(t){return t.m_cachedValues}function e1(t,e){t.m_cachedValues=e}function e2(t,e,i,r,o){(0,s.w)(n.E.unit().contains(i),"QuadraticBezierHelper::getClosestCoordinateSegment");let a=(0,n.m)(n.P,3);t.queryControlPoints(a);let l=Number.MAX_VALUE,h=[0],m=e3(a,e,h);if(i.containsCoordinate(h[0]))l=n.P.distance(e,m);else{h[0]=i.vmin,il(a,h[0],m),l=n.P.distance(m,e);let t=new n.P;il(a,i.vmax,t);let s=n.P.distance(t,e);l>s&&(m.setCoordsPoint2D(t),h[0]=i.vmax,l=s)}if(!r)return h[0];if(i.vmin<=0){let s=new n.P;t.queryCoord2DExtended(-1,s,!0);let r=new n.P;t.queryCoord2D(i.vmin,r);let o=new rP({start:s,end:r}),a=o.getClosestCoordinate(e,!0);
1if(a<1){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=a-1,m.assign(t))}}if(i.vmin>=1){let s=new n.P;t.queryCoord2DExtended(2,s,!0);let r=new n.P;t.queryCoord2D(i.vmax,r);let o=new rP({start:r,end:s}),a=o.getClosestCoordinate(e,!0);if(a>0){let t=o.getCoord2D(a),i=n.P.distance(t,e);i<l&&(l=i,h[0]=1+a,m.assign(t))}}return h[0]}function e3(t,e,i){let s=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(r),l=o.dotProduct(s)+2*r.dotProduct(r),h=3*r.dotProduct(s),m=s.dotProduct(s),u=(0,n.d)(3,NaN),g=tp(m,h,l,a,n.E.unit(),!1,u),c=t[0].clone(),d=0,_=n.P.sqrDistance(t[0],e),p=n.P.sqrDistance(t[2],e);p<_&&(d=1,c.assign(t[2]),_=p);for(let i=0;i<g;i++){let s=new n.P;il(t,u[i],s),(p=n.P.sqrDistance(s,e))<_&&(_=p,c.assign(s),d=u[i])}return i&&(i[0]=d),c}function e4(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,3);let s=(0,n.m)(n.P,3);e9(t,e.vmin,e.vmax,s),i.setFromPoints(s,3)}function e5(t,e,i){i.setEmpty();let s=[];s.push(new n.E(0,1));let r=.5*Math.max(e.width(),e.height());for(;s.length;){let o=s.at(-1);s.pop();let a=new p;if(e4(t,o,a),a.isIntersectingW(e)){let t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||1e-12>o.width())i.merge(o);else{let t=o.getCenter();s.push(n.E.construct(o.vmin,t)),s.push(n.E.construct(t,o.vmax))}}}}function e6(t){let e=(0,n.m)(n.P,3);t.queryControlPoints(e);let i=e8(e);return i&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),i}function e8(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.Y)(t[0][i],t[2][i]);s>0?(0>(0,n.Y)(t[0][i],t[1][i])&&(t[1][i]=t[0][i],e=!0),0>(0,n.Y)(t[1][i],t[2][i])&&(t[1][i]=t[2][i],e=!0)):s<0?((0,n.Y)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.Y)(t[1][i],t[2][i])>0&&(t[1][i]=t[2][i],e=!0)):t[1][i]!==t[0][i]&&(t[1][i]=t[0][i],e=!0)}return e}function e7(t,e,i,s){(new n.P).setCoordsPoint2D(t[0]),(new n.P).setCoordsPoint2D(t[1]),(new n.P).setCoordsPoint2D(t[2]);let r=new n.P,o=new n.P,a=new n.P;if((0,n.Z)(t[0],t[1],e,r),(0,n.Z)(t[1],t[2],e,o),(0,n.Z)(r,o,e,a),i&&(i[0].assign(t[0]),i[1].assign(r),i[2].assign(a)),s){let e=t[2];s[0].assign(a),s[1].assign(o),s[2].assign(e)}}function e9(t,e,i,s){if(e===i){let i=new n.P;return il(t,e,i),s[0]=i,s[1]=i,void(s[2]=i)}let r=(0,n.m)(n.P,3);e7(t,i,r,null),e7(r,e/i,null,r),il(t,e,r[0]),il(t,i,r[2]),s[0].setCoordsPoint2D(r[0]),s[1].setCoordsPoint2D(r[1]),s[2].setCoordsPoint2D(r[2])}function it(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==ii(t,e,i,null,null,null,s,r??!1,!0,!1))}function ie(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==is(t,e,i,null,null,null,s,r??!1,!0,!1))}function ii(t,e,i,r,o,a,l,h,m,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),i.isDegenerate(0)){let t=[0,0],s=e.intersectPoint(i.getStartXY(),t,l);if(s>0){if(null!==o)for(let e=0;e<s;e++)o.push(t[e]);if(null!==a)for(let t=0;t<s;t++)a.push(0);if(null!==r)for(let i=0;i<s;i++){let s=new n.P;e.queryCoord2D(t[i],s),r.push(s)}}return s}let g=R(e,i);if(l=Math.max(l,g),e.isDegenerateToLineHelper(g)){let t=new rP({start:e.getStartXY(),end:e.getEndXY()}),s=ti(t,i,r,o,a,l,h,u);if(o)for(let i=0;i<s;++i){let s=t.getCoord2D(o[i]);o[i]=e.getClosestCoordinate(s,!1)}return s}if(z(e,i,l))return 0;let c=tX.constructPoint2D(i.getStartXY()),d=tX.constructPoint2D(i.getEndXY()).sub(c),_=d.clone();_.leftPerpendicularThis();let p=tX.constructPoint2D(e.m_cp).sub(tX.constructPoint2D(e.getStartXY())),f=tX.constructPoint2D(e.getEndXY()).sub(tX.constructPoint2D(e.m_cp)),P=p.dotProduct(_).toDouble(),y=f.sub(p).dotProduct(_).toDouble(),x=(0,n.d)(12,NaN),v=(0,n.d)(12,NaN),C=function(t,e,i,s){let r=new n.F,o=tx(new n.F(t),new n.F(e),i,r);return s[0]=r.value(),o}(y,P,n.E.unit(),x);C<0&&(x[0]=0,x[1]=1,C=2);let b,E=0;for(let t=0,s=E;t<C;++t){let r=e.getCoord2D(x[t+s]);v[E]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(v[E]))<=l&&(x[E]=x[t+s],E++)}let S=(0,n.m)(n.P,3);e.queryControlPoints(S);{let t=(0,n.m)(tX,3);if(ia(S,t,!1),t[0]=t[0].sub(c),d.x.abs().gte(d.y.abs())){let e=d.y.div(d.x);y=t[2].y.sub(t[2].x.mul(e)).toDouble(),P=t[1].y.sub(t[1].x.mul(e)).toDouble(),b=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{let e=d.x.div(d.y);y=t[2].x.sub(t[2].y.mul(e)).toDouble(),P=t[1].x.sub(t[1].y.mul(e)).toDouble(),b=t[0].x.sub(t[0].y.mul(e)).toDouble()}}
1let D=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),w=[0,0];C=t_(y,P,b,n.E.unit(),D,w);for(let t=0,s=E;t<C;++t){x[t+s]=w[t];let r=e.getCoord2D(x[t+s]);v[E]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(v[E]))<=l&&(x[E]=x[t+s],E++)}(0,s.g)(E<x.length+4),C=e.intersectPoint(i.getStartXY(),w,l);for(let t=0;t<C;t++)x[E]=w[t],v[E++]=0;C=e.intersectPoint(i.getEndXY(),w,l);for(let t=0;t<C;t++)x[E]=w[t],v[E++]=1;C=i.intersectPoint(e.getStartXY(),w,l);for(let t=0;t<C;t++)v[E]=w[t],x[E++]=0;C=i.intersectPoint(e.getEndXY(),w,l);for(let t=0;t<C;t++)v[E]=w[t],x[E++]=0;return 0===E?0:rd(t,e,i,x,v,E,r,o,a,l,h,m,u)}function is(t,e,i,s,r,o,l,h,m,u){if(sY(i))return ii(t,e,new rP({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,m,u);let g=R(e,i);if(z(e,i,l=Math.max(l,g)))return 0;let c=[],d=[],_=(0,n.m)(n.P,3);{e.queryControlPoints(_);let t=(0,n.m)(n.P,3),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(_,3,t);let o=(0,n.m)(tX,3);ia(t,o);let h=[o[0].x,o[1].x,o[2].x],m=[o[0].y,o[1].y,o[2].y],u=(0,n.m)(n.M,3);u[0].setDouble(i.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(i.getSemiMajorAxis()),u[1].sqrThis(),u[2]=u[0],u[2].mul(u[1]),u[2].negate();let g=tL(h,2,m,2,null,0,u,!0,n.E.unit(),n.E.unit(),c);if(g>0){let t=0;for(let s=0;s<g;s++){let r=new n.P;e.queryCoord2D(c[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(c[t]=c[s],d.push(o),t++)}c.length=t}}let p=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];e3(_,e,s);let r=new n.P;il(_,s[0],r),n.P.distance(e,r)<=l&&(c.push(s[0]),d.push(p[t]))}for(let t=0;t<2;t++){let e=[0,2];{let s=i.getClosestCoordinate(_[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(_[e[t]],r)<=l&&(c.push(p[t]),d.push(s))}}return rd(t,e,i,c,d,c.length,s,r,o,l,h,m,u)}function ir(t,e,i,s,r,o,a,l,h,m){let u=(0,n.m)(n.P,3);e.queryControlPoints(u);let g=(0,n.m)(n.P,3);if(i.queryControlPoints(g),0>G(u,g,3))return ir(t,i,e,s,o,r,a,l,h,!m);let c=R(e,i);if(z(e,i,a=Math.max(a,c)))return 0;if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.m)(n.P,3);t.queryControlPoints(m);let u=(0,n.m)(n.P,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return i&&(i.length=0,i.push(m[0]),i.push(m[2])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.b)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.b)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[2]),h&&(i[1]=(0,n.b)(i[0],i[0]=i[1]))),!0)}(e,i,s,r,o,0,0,0,m))return 2;let d=new n.E(0,1),_=new n.E(0,1);{let t=new p;e4(u,n.E.unit(),t);let e=new p;e4(g,n.E.unit(),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(e5(u,t,d),e5(g,t,_),d.isEmpty()||_.isEmpty())return 0;e9(u,d.vmin,d.vmax,u),e9(g,_.vmin,_.vmax,g)}}let f=rp(u,2,g,2,a);if(0===f)return 0;let P=[],y=[];if(-1===f){let t=(0,n.m)(tX,3);ia(u,t);let e=[t[0].x,t[1].x,t[2].x],i=[t[0].y,t[1].y,t[2].y],s=(0,n.m)(tX,3);ia(g,s);let r=tV(e,2,i,2,null,0,[s[0].x,s[1].x,s[2].x],2,[s[0].y,s[1].y,s[2].y],2,null,0,!0,n.E.unit(),n.E.unit(),P,y,m);if(r>0){let t=0;for(let e=0;e<r;e++){let i=new n.P,s=new n.P;il(g,y[e],s),il(u,P[e],i),n.P.distance(i,s)<=a&&(P[t]=P[e],y[t]=y[e],t++)}P.length=t,y.length=t}}for(let t=0;t<2;t++){let e=0===t?u:g,i=0===t?g:u;for(let s=0;s<2;s++){let r=2*(0!==s),o=[0];e3(i,e[r],o);let l=new n.P;il(i,o[0],l),n.P.distance(e[r],l)<=a&&(0===t?(P.push(+(0!==r)),y.push(o[0])):(y.push(+(0!==r)),P.push(o[0])))}}if(0===P.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=tI.recalculateParentT(d.vmin,d.vmax,P[t]);if(!_.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=tI.recalculateParentT(_.vmin,_.vmax,y[t]);return rd(t,e,i,P,y,P.length,s,r,o,a,l,h,m)}function io(t,e,i=!1){let s=t[1].sub(t[0]);e[1].assign(s.mul(2)),e[2].assign(t[2].sub(t[1]).sub(s)),i?e[0].setCoords(0,0):e[0].assign(t[0])}function ia(t,e,i=!1){let s=tX.constructPoint2D(t[1]),r=s.sub(tX.constructPoint2D(t[0]));e[1]=r.mul(n.M.constructInt32(2)),e[2]=tX.constructPoint2D(t[2]).sub(s).sub(r),e[0]=i?new tX(n.ad,n.ad):tX.constructPoint2D(t[0])}function il(t,e,i,s){if(s){if(e<0)return void O(new rP({start:t[0],end:t[0].add(eO(t,0).getUnitVector())}),e,i);if(e>1)return void O(new rP({start:t[2],end:t[2].add(eO(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=t[1].clone(),r=new n.P;(0,n.V)(2,t[0],s,e,r);let o=new n.P;(0,n.V)(2,s,t[2],e,o);let a=new n.P;(0,n.V)(2,r,o,e,a),i.assign(a)}else{let s=t[1].clone(),r=new n.P;(0,n.W)(2,t[0],s,e,r);let o=new n.P;(0,n.W)(2,s,t[2],e,o);let a=new n.P;(0,n.W)(2,r,o,e,a),i.assign(a)}}var ih=r.V;class im extends H{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,n.O)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),(0,s.c)("unrecognized constructor params"),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return i7(this)}construct(t,e,i,s){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=s.x,this.m_YEnd=s.y,this.m_cp[0].assign(e),this.m_cp[1].assign(i),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){let e=(0,n.m)(n.P,4);e[0].assign(t[0]),e[3].assign(t[2]),(0,n.Z)(t[0],t[1],2/3,e[1]),(0,n.Z)(t[1],t[2],1/3,e[2]),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),(0,n.a0)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,n.a0)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),V(this,t)}getGeometryType(){return s.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,s.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;let e=iC(this);if(null!==e){let i=new n.P;for(let s of e.specialPoints)this.queryCoord2D(s,i),t.mergeNe(i);return}let i=(0,n.m)(n.F,8),r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=iQ(r,i),a=new n.P;for(let e=1;e<o-1;e++)this.queryCoord2D(i[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){let e=(0,n.m)(n.P,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void iE(this)}(0,s.g)(0)}createInstance(){return new im({vd:this.m_description})}calculateLength2D(){return ix(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return n.P.distance(this.getStartXY(),this.m_cp[0])+n.P.distance(this.m_cp[0],this.m_cp[1])+n.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}
1queryCoord2DExtends(t,e,i){let s=(0,n.m)(n.P,4);this.queryControlPoints(s),iq(s,t,e,i)}queryCoord2DE(t,e){var i=this,s=t,r=e;let o=(0,n.m)(n.P,4);i.queryControlPoints(o),function(t,e,i){if(.5>=e.value()){let s=new y;(0,n.a1)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,s);let r=new y;(0,n.a1)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,r);let o=new y;(0,n.a1)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);let a=new y;(0,n.a1)(2,s,r,e,a);let l=new y;(0,n.a1)(2,r,o,e,l),(0,n.a1)(2,a,l,e,i)}else{let s=new y;(0,n.a2)(2,y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),e,s);let r=new y;(0,n.a2)(2,y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),e,r);let o=new y;(0,n.a2)(2,y.constructPoint2D(t[2]),y.constructPoint2D(t[3]),e,o);let a=new y;(0,n.a2)(2,s,r,e,a);let l=new y;(0,n.a2)(2,r,o,e,l),(0,n.a2)(2,a,l,e,i)}}(o,s,r)}getCoordX(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.x}let e=(0,n.q)(this.getStartX(),this.m_cp[0].x,t),i=(0,n.q)(this.m_cp[0].x,this.m_cp[1].x,t),s=(0,n.q)(this.m_cp[1].x,this.getEndX(),t),r=(0,n.q)(e,i,t),o=(0,n.q)(i,s,t);return(0,n.q)(r,o,t)}getCoordY(t){if(t<0||t>1){let e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.y}let e=(0,n.q)(this.getStartY(),this.m_cp[0].y,t),i=(0,n.q)(this.m_cp[0].y,this.m_cp[1].y,t),s=(0,n.q)(this.m_cp[1].y,this.getEndY(),t),r=(0,n.q)(e,i,t),o=(0,n.q)(i,s,t);return(0,n.q)(r,o,t)}cut(t,e,i){let s=new ry;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,r),s)return;r.assignVertexDescription(this.m_description);let n=this.m_description.getAttributeCount();if(n>1){for(let e=1;e<n;e++){let i=this.m_description.getSemantics(e),s=ih.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<n;t++){let i=this.m_description.getSemantics(t),s=ih.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}}queryDerivative(t,e){iN(this,t,e)}cutBezierIgnoreAttributes(t,e,i){(t<0||e>1||t>e)&&(0,s.t)("Cubic_bezier.cut_bezier_ignore_attributes");let r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=(0,n.m)(n.P,4);iX(r,t,e,o),i.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,i){this===e&&this===i&&(0,s.t)("Cubic_bezier.split_bezier_ignore_attributes");let r=(0,n.m)(n.P,4);this.queryControlPoints(r);let o=(0,n.m)(n.P,4),a=(0,n.m)(n.P,4);iY(r,t,o,a),e&&e.setControlPoints(o),i&&i.setControlPoints(a)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.getStartAttributeAsDbl(e,i),r=this.getEndAttributeAsDbl(e,i),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,l=ih.getInterpolation(e);return(0,n.T)(l,s,r,a,ih.getDefaultValue(e))}getClosestCoordinate(t,e){let i=[NaN];return iJ(this,t,n.E.unit(),e,-1,1,i),i[0]}getClosestCoordinateOnInterval(t,e,i=-1){let s=[NaN];return 0===iJ(this,t,e,!1,i,1,s)?NaN:s[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,s.t)("");let i=iv(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let r=0;(0,s.g)(t.length>=i.specialPointsCount()-1);for(let s=1,n=i.specialPointsCount();s<n;++s)this.queryCut(i.specialPoints[s-1],i.specialPoints[s],t[r],e),r++;for(let e=0;e<r;++e)iT(t[e].get());return r}intersectionWithAxis2D(t,e,i,s){let r=(0,n.m)(n.P,4);return this.queryControlPoints(r),function(t,e,i,s,r){let o=(0,n.m)(n.F,4),a=(0,n.m)(n.F,3),l=new n.E(0,1),h=0;if(e){if(iP(t,o,!1),h=tC(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;iq(t,a[e].value(),i),s[e]=i.x}}else if(ip(t,o,!1),h=tC(o[3],o[2],o[1],o[0].sub(i),l,!1,a),s)for(let e=0;e<h;e++){let i=new n.P;iq(t,a[e].value(),i),s[e]=i.y}if(r)for(let t=0;t<h;t++)r[t]=a[t].value();else s&&(0,n.C)(s,0,h,n.X);return h}(r,t,e,i,s)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0],r=this.intersectionWithAxis2D(!0,t,i,null);return(0,s.g)(2!==r),-1===r?e:i[0]}isCurve(){return!0}isDegenerate(t){return b(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,s.g)(0)}clone(t){let e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t=o.J.constructEmpty();this.queryEnvelope(t);let i=n.E.constructEmpty();return 0===e?t.queryIntervalX(i):t.queryIntervalY(i),i}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=(0,n.m)(n.P,4);this.queryControlPoints(i),iX(i,t.vmin,t.vmax,i),e.setFromPoints(i,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;let i=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),s=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),r=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),n=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),i?this.m_cp[0].setCoordsPoint2D(t):s&&this.m_cp[0].setCoordsPoint2D(e),n?this.m_cp[1].setCoordsPoint2D(e):r&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return ix(this,t,!0)}
1lengthToT(t){return function(t,e,i){let r=ix(t,1,!1);if(e<=0)return e;if(e>=r)return e-r+1;let o=[0];return 1!==td(new i$(t,e),n.E.unit(),1,o)&&(0,s.c)(""),o[0]}(this,t)}calculateWeightedAreaCentroid2D(t){let e=(0,n.m)(n.P,4);ic(this,e);let i=e[3],s=e[2],r=e[1],o=new n.P;o.x=(5*i.x*i.x*(7*s.y+16*r.y)+i.x*(-35*i.y*s.x+40*s.x*s.y-80*i.y*r.x+140*s.x*r.y+112*r.x*r.y)-2*(i.y*(20*s.x*s.x+70*s.x*r.x+56*r.x*r.x)-7*(4*s.x+5*r.x)*(-s.y*r.x+s.x*r.y)))/840,o.y=(-5*i.y*i.y*(7*s.x+16*r.x)+i.y*(5*i.x*(7*s.y+16*r.y)-4*(10*s.x*s.y+35*s.y*r.x+28*r.x*r.y))+2*(-7*(4*s.y+5*r.y)*(s.y*r.x-s.x*r.y)+i.x*(20*s.y*s.y+70*s.y*r.y+56*r.y*r.y)))/840;let a=iA(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){let t=new n.P;return this.isDegenerate(0)?t.setCoords(0,0):!function(t){let e=n.P.distance(t.getStartXY(),t.getEndXY()),i=t.calculateUpperLength2D();return i-e<=8*Number.EPSILON*i}(this)?t.assign(function(t,e,i){void 0===i&&(i=e,e=0);let r=new n.P;if(e<0||i>1)return r.setNAN(),r;if(e>i&&(0,s.t)("calculate_sub_weightedCentroid"),e===i||t.isDegenerate(0))return r.setCoords(0,0),r;let o=iv(t),a=ig(t),l=a/t.calculateUpperLength2D(),h=e,m=0;for(let t=1,i=o.specialPointsCount();t<i;t++)if(e<o.specialPoints[t]){m=t-1;break}r.setCoords(0,0);for(let e=m+1,s=o.specialPointsCount();e<s;e++){let s=Math.min(o.specialPoints[e],i),m=function(t,e,i,s,r){let o=!0,a=t5(5,e,i,e=>{let i=iw(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()},s,r);o=!1;let l=t5(5,e,i,e=>{let i=iw(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*i.length()},s,r);return new n.P(a,l)}(t,h,s,l,a);if(r.addThis(m),h=s,i<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)):t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&(0,s.t)("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){let e=(0,n.m)(n.P,4);return this.queryControlPoints(e),iF(e,t)}getDerivative(t){let e=(0,n.m)(n.P,4);return this.queryControlPoints(e),iD(e,1,t)}getCurvature(t){let e=iw(this,1,t),i=iw(this,2,t),s=e.sqrLength();return 0===s?NaN:(e.divThis(Math.sqrt(s)),e.crossProduct(i)/s)}isIntersectingPoint(t,e,i){if(i&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;let s=new o.J;if(this.queryLooseEnvelope(s),s.inflateCoords(e,e),!s.contains(t))return!1;let r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}isMonotoneQuickAndDirty(){let t=(0,n.m)(n.P,4);return this.queryControlPoints(t),function(t){let e=(0,n.Y)(t[0].y,t[1].y),i=(0,n.Y)(t[1].y,t[2].y),s=(0,n.Y)(t[2].y,t[3].y);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0){let e=(0,n.Y)(t[0].x,t[1].x),i=(0,n.Y)(t[1].x,t[2].x),s=(0,n.Y)(t[2].x,t[3].x);if(e>=0&&i>=0&&s>=0||e<=0&&i<=0&&s<=0)return!0}return!1}(t)}getMonotonicPartParams(t,e){let i=iv(this),r=i.specialPointsCount();if((0,s.g)(B.s_maxMonotonicPartParams>=r),!e)return i.specialPointsCount();t<r&&(0,s.t)("");for(let t=0;t<r;t++)e[t]=i.specialPoints[t];return r}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,n.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){let t=new n.F;return iS(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){let e=this.getEndXY().sub(this.getStartXY()),i=e.length(),s=.1*t,r=this.getControlPoint1();r.subThis(this.getStartXY());let n=Math.abs(r.crossProduct(e))/i;return!(n>s)&&((r=this.getControlPoint2()).subThis(this.getStartXY()),!((n=Math.abs(r.crossProduct(e))/i)>s))}copyIgnoreAttributes(t){let e=(0,n.m)(n.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return iA(this)}absNorm(){var t;return t=this,t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}queryEnvelopeW(t,e){iZ(this,t,e)}
1setSegmentFromCoords(t,e){!function(t,e,i){if((0,s.g)(i>=2),2===i){let s=new n.P;(0,n.Z)(e[0],e[i-1],1/3,s);let r=new n.P;return(0,n.Z)(e[0],e[i-1],2/3,r),t.construct(e[0],s,r,e[i-1])}let r=e[0],o=e[i-1],a=[0,0],l=iJ(t,r,n.E.unit(),!1,NaN,2,a),h=[0,0],m=iJ(t,o,n.E.unit(),!1,NaN,2,h),u=[];for(let s=0;s<l;s++)for(let l=0;l<m;l++){let m=a[s],g=h[l],c=(s,a)=>{let l=(0,n.d)(i-2,NaN),h=()=>{let t=0;for(let s=1,r=i-1;s<r;s++){let i=t+=n.P.distance(e[s-1],e[s]);l[s-1]=i}t+=n.P.distance(e[i-2],e[i-1]);for(let e=1,s=i-1;e<s;e++)l[e-1]/=t},u=!1,c=!1;{let e=new ry;m<=g?(t.queryCut(m,g,e,!0),s.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())):(t.queryCut(g,m,e,!0),s.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())),r.equals(s)&&(u=!0),o.equals(a)&&(c=!0)}h();let d=Number.MAX_VALUE,_=s.clone(),p=a.clone();for(let t=0;t<5;t++)d=i0(!0,!1,r,_,p,o,u,c,l,i-2,e,i);for(let t=0;t<30;t++){let t=_.clone();p.clone();let s=i0(!0,!0,r,_,p,o,u,c,l,i-2,e,i);if(d<=s&&t.equals(_)&&t.equals(p))break;d=s}h();let f=!1,P=Number.EPSILON,y=s.clone(),x=a.clone();for(let t=0;t<30;t++){let t=y.clone();x.clone();let s=i0(f,!0,r,y,x,o,u,c,l,i-2,e,i);if(P<=s&&t.equals(y)&&t.equals(x))break;f=!0,P=s}return P<d?(s.assign(y),a.assign(x)):(s.assign(_),a.assign(p),P=d),P},d=new n.P,_=new n.P,p=[c(d,_),n.P.distance(r,d)+n.P.distance(d,_)+n.P.distance(_,o),d.x,d.y,_.x,_.y];u.splice(u.length,0,...p)}let g=u[0],c=u[1],d=0;for(let t=6;t<u.length;t+=6)u[t]<g&&(g=u[t],c=u[t+1],d=t);let _=d;for(let t=0;t<u.length;t+=6)t!==d&&u[t+1]<c&&Math.abs(g-u[t])<10*g&&(c=u[t+1],_=t);t.construct(r,new n.P(u[_+2],u[_+3]),new n.P(u[_+4],u[_+5]),o)}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(4);return this.writeInBuffer_(i),t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){let i=new Float64Array(4);t.queryRange(e,i.length,i,!0,1),this.readFromBuffer_(i)}readFromBuffer_(t){this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){let e=(0,n.m)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return(s||r)&&this.setControlPoints(e),s||r}needsSnapControlPoints(t){if(!t)return!1;let e=(0,n.m)(n.P,4);this.queryControlPoints(e);let i=(e,i,s)=>{let r=!1;return n.P.sqrDistance(e,s)<=t&&(r=!e.equals(s),e.setCoordsPoint2D(s),n.P.sqrDistance(i,s)<=t&&(r||=!i.equals(s),i.setCoordsPoint2D(s))),r},s=i(e[1],e[2],e[0]),r=i(e[2],e[1],e[3]);return s||r}calculateSpecialPointsForCracking(t,e){return function(t,e,i){i.length=0;{let e=new n.F;iS(t,e);let s=new y;if(iN(t,e,s),s.isZero())return e.isZero()||e.eq(new n.F(1))?0:(i.push(e.value()),1)}let s=(0,n.m)(n.F,4);id(t,s,!0);let r=(0,n.m)(n.F,4);i_(t,r,!0);let o=(0,n.m)(n.F,6),a=s[3].negate().mulE(r[1]).addE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),l=s[3].negate().mulE(r[1]).subE(s[2].mulE(r[2]).mul(2)).addE(s[1].mulE(r[3])),h=s[2].mulE(s[2]).subE(r[2].mulE(r[2]));o[0]=r[1].mulE(r[1]).mulE(a).addE(s[1].mulE(s[1]).mulE(l)).addE(s[1].mulE(r[1]).mulE(h).mul(2)).mul(6),o[1]=s[2].mulE(r[1]).subE(s[1].mulE(r[2])).mulE(s[2].mulE(s[2]).addE(s[1].mulE(s[3]).mul(2)).addE(r[2].mulE(r[2])).addE(r[1].mulE(r[3]).mul(2))).mul(24);let m=s[1].mulE(r[2]).mulE(r[2]).mulE(r[3]),u=s[2].mulE(s[2]).mulE(s[3]).mulE(r[1]).subE(m).mul(156),g=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),c=s[3].mulE(r[1]).subE(s[1].mulE(r[3])),d=s[1].mulE(s[3]).mulE(c).addE(r[1].mulE(r[3]).mulE(g)).mul(72),_=r[1].mulE(r[3]).subE(s[1].mulE(s[3])),p=s[2].mulE(r[2]).mulE(_).mul(120),f=s[1].mulE(s[2]).mulE(s[2]).mulE(r[3]),P=s[3].mulE(r[1]).mulE(r[2]).mulE(r[2]).subE(f).mul(36);o[2]=u.addE(d).addE(p).addE(P);let x=s[2].mulE(s[3]).mulE(s[3]).mulE(r[1]).subE(s[1].mulE(r[2]).mulE(r[3]).mulE(r[3])).mul(360),v=s[2].mulE(r[2]).mulE(s[2].mulE(s[3]).subE(r[2].mulE(r[3]))).addE(s[3].mulE(r[2]).mulE(r[2]).mulE(r[2])).subE(s[2].mulE(s[2]).mulE(s[2]).mulE(r[3])).mul(24),C=s[2].mulE(r[1]).mulE(r[3]).mulE(r[3]).subE(s[1].mulE(s[3]).mulE(s[3]).mulE(r[2])).mul(72),b=s[3].mulE(r[3]).mulE(r[1].mulE(r[2]).subE(s[1].mulE(s[2]))).mul(288);o[3]=x.addE(v).addE(C).addE(b),o[4]=r[3].mulE(r[3]).addE(s[3].mulE(s[3])).mulE(s[3].mulE(r[1]).subE(s[1].mulE(r[3]))).mul(270).addE(s[3].mulE(r[2]).subE(s[2].mulE(r[3]))).mulE(s[2].mulE(s[3]).addE(r[2].mulE(r[3]))).mul(180),o[5]=s[3].mulE(r[2]).subE(s[2].mulE(r[3])).mulE(s[3].mulE(s[3]).addE(r[3].mulE(r[3]))).mul(216);let E=(0,n.m)(n.F,5),S=tb(o,5,new n.E(0,1),!1,E,5);if(S>0){let s=Math.abs(t.getCurvature(0)),r=0,o=Math.abs(t.getCurvature(1));(o>s||!Number.isFinite(o))&&(r=1);for(let e=0;e<S;e++){let i=Math.abs(t.getCurvature(E[e].value()));t.getCoord2D(E[e].value()),(i>s||!Number.isFinite(i))&&(s=i,r=E[e].value())}if((!Number.isFinite(s)||1/s<e)&&!(0,n.J)(r,0,1)){let e=t.getCoord2D(r);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return i.push(r),1}}return 0}(this,t,e)}ensureXYMonotone(){return iT(this)}
1setCoordsForIntersector(t,e,i){!function(t,e,i,s){if(e.isEqual(t.m_XStart,t.m_YStart)&&i.isEqual(t.m_XEnd,t.m_YEnd))return;let r=!!s&&t.isMonotoneQuickAndDirty(),o=new a.T,l=(0,n.m)(n.P,3);l[0].setCoords(t.m_XStart,t.m_YStart),l[2].setCoords(t.m_XEnd,t.m_YEnd);let h=new n.P;h.setSub(l[2],l[0]),h.leftPerpendicularThis(),l[1].setAdd(l[0],h);let m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(i),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(l,m)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,n.Z)(e,i,1/3,t.m_cp[0]),(0,n.Z)(e,i,2/3,t.m_cp[1])),t.changeEndPoints2D(e,i),r&&iT(t)}(this,t,e,i)}copyToImpl(t){t.m_cp[0].assign(this.m_cp[0]),t.m_cp[1].assign(this.m_cp[1]),ib(t,iC(this))}reverseImpl(){this.m_cp[1]=(0,n.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){return!!this.m_cp[0].equals(t.m_cp[0])&&!!this.m_cp[1].equals(t.m_cp[1])}equalsImplTol(t,e){return!!this.m_cp[0].isEqualPoint2D(t.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(t.m_cp[1],e)}swapImpl(t){var e,i;t.m_cp[0]=(0,n.b)(this.m_cp[0],this.m_cp[0]=t.m_cp[0]),t.m_cp[1]=(0,n.b)(this.m_cp[1],this.m_cp[1]=t.m_cp[1]),e=this,(i=t).m_cachedValues=(0,n.b)(e.m_cachedValues,e.m_cachedValues=i.m_cachedValues)}afterCompletedModification(){iE(this)}isIntersecting(t,e,i){return 0!==rl(!1,this,t,e,i)}intersect(t,e,i,s,r){return rg(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){return function(t,e,i,r,o){let a=new p;if(iZ(t,n.E.unit(),a),a.inflate(r),!a.isIntersectingPoint2D(e))return 0;let l=iv(t),h=0,m=l.specialPoints[0],u=[];for(let i=1,r=l.specialPoints.length;i<r;++i){let r=l.specialPoints[i],o=function(t,e,i,s){let r=(0,n.d)(18,NaN),o=(0,n.m)(n.P,4);t.queryControlPoints(o);let a=td(new iU(o,e),n.E.construct(i,s),18,r),l=new n.P;t.queryCoord2D(i,l);let h=i,m=n.P.distance(l,e),u=new n.P;t.queryCoord2D(s,u);let g=n.P.distance(u,e);g<m&&(m=g,h=s,l.assign(u));for(let i=0;i<a;i++){t.queryCoord2D(r[i],u);let s=n.P.distance(u,e);s<m&&(m=s,h=r[i],l.assign(u))}return{tmin:i,tmax:s,t:h,d:m,pt:l.clone()}}(t,e,m,r);if(0===u.length)u.push(o);else if(o.t===o.tmin)(0,s.g)(u.at(-1).d<=o.d),u.at(-1).tmax=o.tmax;else if(u.at(-1).t===u.at(-1).tmax){(0,s.g)(u.at(-1).d>=o.d);let t=u.at(-1).tmin;u[u.length-1]=o,u.at(-1).tmin=t}else u.push(o);m=r}for(let t of u)if(t.d<=r){let e=t.t;i&&(h>=i.length&&(0,s.n)(""),i[h]=e),h++}return h}(this,t,e,i)}endPointModified(){iE(this)}clearEndPointModified(){}}im.type=s.G.enumBezier;class iu{constructor(){this.length=NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function ig(t){var e;return e=t.calculateUpperLength2D(),256*(0,n.N)()*e}function ic(t,e,i=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),i?e[0].setCoords(0,0):e[0]=t.getStartXY()}function id(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),ip(s,e,i)}function i_(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),iP(s,e,i)}function ip(t,e,i){let s=t[1].x;s-=t[0].x,s*=3;let r=t[2].x;r-=t[1].x,r*=3;let n=t[3].x;n-=t[0].x,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].x)}function iP(t,e,i){let s=t[1].y;s-=t[0].y,s*=3;let r=t[2].y;r-=t[1].y,r*=3;let n=t[3].y;n-=t[0].y,n-=r,r-=s,e[3].setWithEps(n),e[2].setWithEps(r),e[1].setWithEps(s),i?e[0].set(0):e[0].set(t[0].y)}function iy(t,e,i=!1){let s=(0,n.m)(tX,4);s[0].assignPoint2D(t[0]),s[1].assignPoint2D(t[1]),s[2].assignPoint2D(t[2]),s[3].assignPoint2D(t[3]),e[1].setCoords(s[1].x.sub(s[0].x),s[1].y.sub(s[0].y)),e[1].mulThis(n.M.constructInt32(3)),e[2].setCoords(s[2].x.sub(s[1].x),s[2].y.sub(s[1].y)),e[2].mulThis(n.M.constructInt32(3)),e[3]=s[3].sub(s[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),i?e[0].setCoords(n.ad,n.ad):e[0]=s[0].clone()}function ix(t,e,i){if(i){if(e<0)return e;if(e>1)return e-1+ix(t,1,!1)}if(t.isDegenerate(0))return 0;let r=1===e,o=iv(t);if(r&&!Number.isNaN(o.length)&&!Number.isNaN(o.length))return o.length;let a=ig(t),l=a/t.calculateUpperLength2D(),h=0,m=0;for(let i=1,r=o.specialPointsCount();i<r;i++){let r=o.specialPoints[i];
1if(h+=function(t,e,i,r,o){if(i===e)return 0;let a=(0,n.m)(n.P,4);t.queryControlPoints(a);let l=(0,n.m)(n.P,4);return iX(a,e,i,l),function t(e,i,r,o,a,l,h){for(;;){let m=n.P.distance(i[0],i[3]),u=n.P.distance(i[0],i[1])+n.P.distance(i[1],i[2])+n.P.distance(i[2],i[3]);if(u-m<=o+r*u)return e+(0,n.q)(m,u,.5);let g=t=>iD(i,1,t).length();if(0===l){(0,s.g)(h<8);let m=g(0),c=g(1);a[0]+=2,m>c&&(c=(0,n.b)(m,m=c),i[3]=(0,n.b)(i[0],i[0]=i[3]),i[2]=(0,n.b)(i[1],i[1]=i[2]));let d=m/(m+c),_=1,p=u;for(;d<1/32&&p>=32*(o+r*p);){let t=g(_/=4);a[0]++,d=m/(t+m);let e=new n.P;if(iq(i,.5*_,e),(p=n.P.distance(e,i[0]))<=o){let t=new n.P;iq(i,_,t),p+=n.P.distance(t,e)}}if(1!==_){let s=(0,n.m)(n.P,4);iY(i,_,i,s),e=t(e,s,r,o,a,0,h+1),l++,h++;continue}}a[0]+=8;let c=t3(8,g,0,1);a[0]+=16;let d=t3(16,g,0,1),_=Math.abs(c-d)>o+r*u;if(!_)return e+d;if(l<3){let s=(0,n.m)(n.P,4);iY(i,.5,i,s),e=t(e,s,r,o,a,l+1,h+1),l++,h++;continue}a[0]+=32;let p=t3(32,g,0,1);if(!(_=Math.abs(d-p)>o+r*u))return e+p;a[0]+=64;let f=t3(64,g,0,1);if(!(_=Math.abs(p-f)>o+r*u))return e+f;a[0]+=128;let P=t3(128,g,0,1);return _=Math.abs(f-P)>o+r*u,e+P}}(0,l,r,o,[0],0,0)}(t,m,Math.min(e,r),l,a),e<=r)break;m=r}return r&&(o.length=h),h}function iv(t){if(t.m_cachedValues)return t.m_cachedValues;let e=new iu,i=(0,n.m)(n.F,8),s=(0,n.m)(n.P,4);t.queryControlPoints(s);let r=iQ(s,i);e.specialPoints=[];for(let t=0;t<r;t++)e.specialPoints.push(i[t].value());return ib(t,e),e}function iC(t){return t.m_cachedValues}function ib(t,e){t.m_cachedValues=e}function iE(t){t.m_cachedValues=null}function iS(t,e){let i=(0,n.m)(n.F,4);id(t,i,!0);let r=(0,n.m)(n.F,4);i_(t,r,!0);let o=i[3].clone(),a=i[2].clone(),l=i[1].clone(),h=r[3].clone(),m=r[2].clone(),u=r[1].clone(),g=a.mulE(l).addE(m.mulE(u)).mul(4),c=a.mulE(a).mul(8).addE(o.mulE(l).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),d=o.mulE(a).addE(h.mulE(m)).mul(36),_=o.mulE(o).addE(h.mulE(h)).mul(36),p=(0,n.m)(n.F,3),f=tC(_,d,c,g,new n.E(0,1),!1,p);if((0,s.g)(f<=3),f>0){let i=iw(t,1,0).sqrLength(),s=iw(t,1,1).sqrLength(),r=i;e.set(0),r<s&&(r=s,e.set(1));for(let i=0;i<f;i++){let s=iw(t,1,p[i].value()).sqrLength();s<r&&(r=s,e=p[i])}}}function iD(t,e,i){let s=new n.P;return function(t,e,i,s){if(1===e){let e=1-i,r=t[1].sub(t[0]),n=t[2].sub(t[1]),o=t[3].sub(t[2]),a=r.mul(e*e).add(n.mul(2*e*i)).add(o.mul(i*i));s.assign(a.mul(3))}else if(2===e){let e=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),n=e.mul(1-i).add(r.mul(i));s.assign(n.mul(6))}else if(3===e){let e=t[2].sub(t[1]),i=t[3].sub(e.mul(3)).sub(t[0]);s.assign(i.mul(6))}else s.setCoords(0,0)}(t,e,i,s),s}function iw(t,e,i){let s=(0,n.m)(n.P,4);return t.queryControlPoints(s),iD(s,e,i)}function iA(t){let e=t.m_cp[0].sub(t.getStartXY()),i=t.m_cp[1].sub(t.m_cp[0]),s=t.getEndXY().sub(t.getStartXY());return e.mulThis(3),i.mulThis(3),s.subThis(i),i.subThis(e),(3*s.x*(2*i.y+5*e.y)-3*s.y*(2*i.x+5*e.x)+10*(i.x*e.y-i.y*e.x))/60}function iT(t){let e=(0,n.m)(n.P,4);t.queryControlPoints(e);let i=iI(e);return i&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),i}function iI(t){let e=!1;for(let i=0;i<2;i++){let s=(0,n.Y)(t[0][i],t[3][i]);s>0?(0>(0,n.Y)(t[0][i],t[1][i])&&(t[1][i]=t[0][i],e=!0),0>(0,n.Y)(t[1][i],t[3][i])&&(t[1][i]=t[3][i],e=!0),0>(0,n.Y)(t[0][i],t[2][i])&&(t[2][i]=t[0][i],e=!0),0>(0,n.Y)(t[2][i],t[3][i])&&(t[2][i]=t[3][i],e=!0),0>(0,n.Y)(t[1][i],t[2][i])&&(t[2][i]=t[1][i],e=!0)):s<0?((0,n.Y)(t[0][i],t[1][i])>0&&(t[1][i]=t[0][i],e=!0),(0,n.Y)(t[1][i],t[3][i])>0&&(t[1][i]=t[3][i],e=!0),(0,n.Y)(t[0][i],t[2][i])>0&&(t[2][i]=t[0][i],e=!0),(0,n.Y)(t[2][i],t[3][i])>0&&(t[2][i]=t[3][i],e=!0),(0,n.Y)(t[1][i],t[2][i])>0&&(t[2][i]=t[1][i],e=!0)):t[1][i]===t[0][i]&&t[2][i]===t[0][i]||(t[1][i]=t[0][i],t[2][i]=t[0][i],e=!0)}return e}function iM(t,e,i){let s=new n.P,r=new n.P,o=new n.P,a=new n.P,l=new n.P;e<=.5?((0,n.V)(2,t[0],t[1],e,s),(0,n.V)(2,t[1],t[2],e,r),(0,n.V)(2,t[2],t[3],e,o),(0,n.V)(2,s,r,e,a),(0,n.V)(2,r,o,e,l),(0,n.V)(2,a,l,e,i)):((0,n.W)(2,t[0],t[1],e,s),(0,n.W)(2,t[1],t[2],e,r),(0,n.W)(2,t[2],t[3],e,o),(0,n.W)(2,s,r,e,a),(0,n.W)(2,r,o,e,l),(0,n.W)(2,a,l,e,i))}function iY(t,e,i,r){(0,s.g)(e>=0&&e<=1);let o=new n.P,a=new n.P,l=new n.P,h=new n.P,m=new n.P,u=new n.P;e<=.5?((0,n.V)(2,t[0],t[1],e,o),(0,n.V)(2,t[1],t[2],e,a),(0,n.V)(2,t[2],t[3],e,l),(0,n.V)(2,o,a,e,h),(0,n.V)(2,a,l,e,m),(0,n.V)(2,h,m,e,u)):((0,n.W)(2,t[0],t[1],e,o),(0,n.W)(2,t[1],t[2],e,a),(0,n.W)(2,t[2],t[3],e,l),(0,n.W)(2,o,a,e,h),(0,n.W)(2,a,l,e,m),(0,n.W)(2,h,m,e,u));let g=t[3].clone();i&&(i[0].assign(t[0]),i[1].assign(o),i[2].assign(h),i[3].assign(u)),r&&(r[0].assign(u),r[1].assign(m),r[2].assign(l),r[3].assign(g))}function iX(t,e,i,r){if((0,s.g)(e>=0&&i<=1&&e<=i),e===i){let i=new n.P;return iq(t,e,i),r[0].assign(i),r[1].assign(i),r[2].assign(i),void r[3].assign(i)}if(0===e&&1===i){for(let e=0;e<4;++e)r[e].assign(t[e]);return}let o=(0,n.m)(n.P,4);iY(t,i,o,null),iY(o,i>0?e/i:0,null,o),iq(t,e,o[0]),iq(t,i,o[3]),r[0].setCoordsPoint2D(o[0]),r[1].setCoordsPoint2D(o[1]),r[2].setCoordsPoint2D(o[2]),r[3].setCoordsPoint2D(o[3])}function iq(t,e,i,s){if(s){if(e<0)return void O(new rP({start:t[0],end:t[0].add(iF(t,0).getUnitVector())}),e,i);if(e>1)return void O(new rP({start:t[3],end:t[3].add(iF(t,1).getUnitVector())}),e-1,i)}if(e<=.5){let s=new n.P;(0,n.V)(2,t[0],t[1],e,s);let r=new n.P;(0,n.V)(2,t[1],t[2],e,r);let o=new n.P;(0,n.V)(2,t[2],t[3],e,o);let a=new n.P;(0,n.V)(2,s,r,e,a);let l=new n.P;(0,n.V)(2,r,o,e,l),(0,n.V)(2,a,l,e,i)}else{let s=new n.P;(0,n.W)(2,t[0],t[1],e,s);let r=new n.P;(0,n.W)(2,t[1],t[2],e,r);let o=new n.P;(0,n.W)(2,t[2],t[3],e,o);let a=new n.P;(0,n.W)(2,s,r,e,a);let l=new n.P;(0,n.W)(2,r,o,e,l),(0,n.W)(2,a,l,e,i)}}function iF(t,e){let i=(0,n.c)(e,0,1),s=iD(t,1,i);return s.isZero()&&((s=iD(t,2,i)).isZero()?s=iD(t,3,i):1===i&&s.negateThis()),s}function iN(t,e,i){var s,r,o;let a=(0,n.m)(n.P,4);t.queryControlPoints(a),s=a,r=e,o=i,0>r.value()&&r.set(0,r.eps()),r.value()>
11&&r.set(1,r.eps()),o.setE(function(t,e,i){let s=[y.constructPoint2D(t[0]),y.constructPoint2D(t[1]),y.constructPoint2D(t[2]),y.constructPoint2D(t[3])],r=new y;return function(t,e,i,s){{let e=n.G.subE(i),r=e.sqr(),o=i.sqr(),a=t[1].subE(t[0]).mulE(r).addE(t[2].subE(t[1]).mulE(new n.F(2).mulE(e).mulE(i))).addE(t[3].subE(t[2]).mulE(o));s.setE(a.mulE(new n.F(3)))}}(s,0,i,r),r}(s,0,r))}function iV(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==iG(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1))}function iL(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==ik(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1))}function iR(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==iW(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1))}function iz(t,e,i,s,r){if(r){if(0!==rm(e,i))return t?4:2}else if(C(e,i))return 1;return 4*(0!==ij(t,e,i,null,null,null,s,r??!1,!0,!1))}function iG(t,e,i,s,r,o,a,l,h,m){if(null!==r&&(r.length=0),null!=o&&(o.length=0),null!==s&&(s.length=0),i.isDegenerate(0)){let t=[0,0,0],l=e.intersectPoint(i.getStartXY(),t,a);if(l>0){if(null!==r)for(let e=0;e<l;e++)r.push(t[e]);if(null!==o)for(let t=0;t<l;t++)o.push(0);if(null!=s)for(let i=0;i<l;i++){let r=new n.P;e.queryCoord2D(t[i],r),s.push(r)}}return l}let u=R(e,i);if(z(e,i,a=Math.max(a,u)))return 0;let g=(0,n.m)(n.P,4);ic(e,g);let c=i.getEndXY();c.subThis(i.getStartXY());let d=c.clone();d.leftPerpendicularThis();let _=3*g[3].dotProduct(d),p=2*g[2].dotProduct(d),f=g[1].dotProduct(d),P=(0,n.d)(15,NaN),y=(0,n.d)(15,NaN),x=t_(_,p,f,n.E.unit(),!1,P);x<0&&(P[0]=0,P[1]=1,x=2);let v,C=0;for(let t=0,s=C;t<x;++t){let r=e.getCoord2D(P[t+s]);y[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(y[C]))<=a&&(P[C]=P[t+s],C++)}if(g[0].subThis(i.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){let t=c.y/c.x;_=g[3].y-g[3].x*t,p=g[2].y-g[2].x*t,f=g[1].y-g[1].x*t,v=g[0].y-g[0].x*t}else{let t=c.x/c.y;_=g[3].x-g[3].y*t,p=g[2].x-g[2].y*t,f=g[1].x-g[1].y*t,v=g[0].x-g[0].y*t}let b=e.getEndXY().equals(i.getStartXY())||e.getEndXY().equals(i.getEndXY()),E=[0,0,0];x=tp(_,p,f,v,n.E.unit(),b,E);for(let t=0,s=C;t<x;++t){P[t+s]=E[t];let r=e.getCoord2D(P[t+s]);y[C]=i.getClosestCoordinate(r,!1),n.P.distance(r,i.getCoord2D(y[C]))<=a&&(P[C]=P[t+s],C++)}x=e.intersectPoint(i.getStartXY(),E,a);for(let t=0;t<x;t++)P[C]=E[t],y[C++]=0;x=e.intersectPoint(i.getEndXY(),E,a);for(let t=0;t<x;t++)P[C]=E[t],y[C++]=1;return 0!==i.intersectPoint(e.getStartXY(),E,a)&&(y[C]=E[0],P[C++]=0),0!==i.intersectPoint(e.getEndXY(),E,a)&&(y[C]=E[0],P[C++]=1),0===C?0:rd(t,e,i,P,y,C,s,r,o,a,l,h,m)}function ik(t,e,i,s,r,o,l,h,m,u){if(sY(i))return iG(t,e,new rP({start:i.getStartXY(),end:i.getEndXY()}),s,r,o,l,h,m,u);let g=R(e,i);if(z(e,i,l=Math.max(l,g)))return 0;let c=[],d=[],_=[],p=(0,n.m)(n.P,4);{e.queryControlPoints(p);let t=(0,n.m)(n.P,4),s=new a.T;i.canonicToWorldTransformation(s);let r=new a.T;r.setInvert(s),r.transformPoints2D(p,4,t);let o=(0,n.m)(tX,4);iy(t,o);let h=[o[0].x,o[1].x,o[2].x,o[3].x],m=[o[0].y,o[1].y,o[2].y,o[3].y],u=(0,n.m)(n.M,3);u[0].setDouble(i.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(i.getSemiMajorAxis()),u[1].sqrThis(),u[2].setThis(u[0]),u[2].mulThis(u[1]),u[2].negateThis();let g=tL(h,3,m,3,null,0,u,!0,n.E.unit(),n.E.unit(),d);if(g>0){let t=0;for(let s=0;s<g;s++){let r=new n.P;e.queryCoord2D(d[s],r);let o=i.getClosestCoordinate(r,!1),a=new n.P;i.queryCoord2D(o,a),n.P.distance(r,a)<=l&&(c.push(r.clone()),d[t]=d[s],_.push(o),t++)}d.length=t,c.length=t}}let f=[0,1];for(let t=0;t<2;t++){let e=0===t?i.getStartXY():i.getEndXY(),s=[0];iO(p,e,n.E.unit(),!1,-1,1,s);let r=new n.P;iq(p,s[0],r),n.P.distance(e,r)<=l&&(d.push(s[0]),_.push(f[t]),c.push(r.clone()))}for(let t=0;t<2;t++){let e=[0,3];{let s=i.getClosestCoordinate(p[e[t]],!1),r=new n.P;i.queryCoord2D(s,r),n.P.distance(p[e[t]],r)<=l&&(d.push(f[t]),_.push(s),c.push(r.clone()))}}return rd(t,e,i,d,_,d.length,s,r,o,l,h,m,u)}function iB(t,e,i,r,o,a,l,h,m,u){let g=(0,n.m)(n.P,4);e.queryControlPoints(g);let c=(0,n.m)(n.P,4);if(i.queryControlPoints(c),0>G(g,c,4))return iB(t,i,e,r,a,o,l,h,m,!u);let d=R(e,i);if(z(e,i,l=Math.max(l,d)))return 0;
1if(function(t,e,i,s,r,o,a,l,h){let m=(0,n.m)(n.P,4);t.queryControlPoints(m);let u=(0,n.m)(n.P,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return i&&(i.length=0,i.push(m[0]),i.push(m[3])),s&&(s.length=0,s.push(0),s.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(s&&(s.length=0,s.push(0),s.push(1),h&&(s[1]=(0,n.b)(s[0],s[0]=s[1]))),r&&(r.length=0,r.push(1),r.push(0),h&&(r[1]=(0,n.b)(r[0],r[0]=r[1]))),i&&(i.length=0,i.push(m[0]),i.push(m[3]),h&&(i[1]=(0,n.b)(i[0],i[0]=i[1]))),!0)}(e,i,r,o,a,0,0,0,u))return 2;let _=new n.E(0,1),f=new n.E(0,1);{let t=new p;iH(g,new n.E(0,1),t);let e=new p;iH(c,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(iK(g,t,_),iK(c,t,f),_.isEmpty()||f.isEmpty())return 0;iX(g,_.vmin,_.vmax,g),iX(c,f.vmin,f.vmax,c)}}let P=rp(g,3,c,3,l);if(0===P)return 0;let y=[],x=[],v=[],C=!1;if(-1===P){let t=(0,n.m)(tX,4);iy(g,t);let e=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y],s=(0,n.m)(tX,4);iy(c,s);let r=[],o=[],a=tV(e,3,i,3,null,0,[s[0].x,s[1].x,s[2].x,s[3].x],3,[s[0].y,s[1].y,s[2].y,s[3].y],3,null,0,!0,n.E.unit(),n.E.unit(),r,o);if(a>0)for(let t=0;t<a;t++){let e=new n.P;iq(c,o[t],e);let i=new n.P;iq(g,r[t],i),n.P.distance(i,e)<=l&&(y.push(i.clone()),v.push(o[t]),x.push(r[t]))}else -1===a&&(C=!0)}for(let t=0;t<2;t++){let e=0===t?g:c,i=0===t?c:g;for(let s=0;s<2;s++){let r=3*(0!==s),o=[0];iO(i,e[r],n.E.unit(),!1,-1,1,o);let a=new n.P;iq(i,o[0],a),n.P.distance(e[r],a)<=l&&(0===t?(x.push(+(0!==r)),v.push(o[0])):(v.push(+(0!==r)),x.push(o[0])),y.push(a.clone()))}}if(0===x.length&&C){let t=e.calculateUpperLength2D()>i.calculateUpperLength2D();{let r=[0,0];if(2===function(t,e,i=!1){let s,r,o,a=(0,n.m)(n.P,4);t.queryControlPoints(a);let l=(0,n.m)(tX,4);iy(a,l,!0);let h=l[3].x.isZero(),m=l[3].y.isZero();if(h||m)if(h&&!m){if(l[2].x.isZero())return 0;s=l[1].x.div(l[2].x).negate(),r=l[2].y.div(l[3].y),o=l[1].y.div(l[3].y)}else{if(h||!m||l[2].y.isZero())return 0;s=l[1].y.div(l[2].y).negate(),r=l[2].x.div(l[3].x),o=l[1].x.div(l[3].x)}else{l[2].x.divThis(l[3].x),l[1].x.divThis(l[3].x),l[2].y.divThis(l[3].y),l[1].y.divThis(l[3].y);let t=l[2].x.sub(l[2].y);if(t.isZero())return 0;s=l[1].x.sub(l[1].y).div(t).negate(),r=l[2].x.clone(),o=l[1].x.clone()}if(!i&&s.abs().value()>2)return 0;let u=[0,0],g=t.getStartXY().equals(t.getEndXY()),c=t_(1,-s.toDouble(),s.add(r).mul(s).add(o).toDouble(),n.E.unit(),g,u);if(0===c)return 0;if(u[0]>=0&&u[0]<=1){let t=s.toDouble()-u[0];if(i||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.b)(e[0],e[0]=e[1])),2}if(2===c&&u[1]>=0&&u[1]<=1){let t=s.toDouble()-u[1];if(i||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.b)(e[0],e[0]=e[1])),2}return 0}(t?e:i,r,!0)&&((0,s.g)(n.E.unit().containsCoordinate(r[0])),!n.E.unit().containsCoordinate(r[1]))){let e=new n.P;iq(t?g:c,r[0],e);let i=[0,0];1===iO(t?c:g,e,n.E.unit(),!1,-1,2,i)&&(y.push(e.clone()),x.push(t?r[0]:i[0]),v.push(t?i[0]:r[0]))}}}if(0===x.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=im.recalculateParentT(_.vmin,_.vmax,x[t]);if(!f.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=im.recalculateParentT(f.vmin,f.vmax,v[t]);return rd(t,e,i,x,v,x.length,r,o,a,l,h,m,u)}function iW(t,e,i,r,o,a,l,h,m,u){let g=R(e,i);if(i.isDegenerateToLineHelper(g)){let s=new rP({start:i.getStartXY(),end:i.getEndXY()}),n=iG(t,e,s,r,o,a,l,h,m,u);if(a)for(let t=0;t<n;++t){let e=s.getCoord2D(a[t]);a[t]=i.getClosestCoordinate(e,!1)}return n}if(z(e,i,l=Math.max(l,g)))return 0;let c=(0,n.m)(n.P,4);e.queryControlPoints(c);let d=(0,n.m)(n.P,3);i.queryControlPoints(d);let _=new n.E(0,1),f=new n.E(0,1),P=[0,0,0];i.queryWeights(P);let y=[1,eF(P),1];{let t=new p;iH(c,new n.E(0,1),t);let e=new p;ep(d,y,new n.E(0,1),e);let i=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*l),e.inflate(3*l),!t.intersectW(e))return 0;if(t.maxDim()<.1*i){if(iK(c,t,_),eq(d,y,t,f),_.isEmpty()||f.isEmpty())return 0;iX(c,_.vmin,_.vmax,c),ev(d,y,f.vmin,f.vmax,d,y)}}let x=rp(c,3,d,2,l);if(0===x)return 0;let v=[],C=[],b=[];if(-1===x){let t=(0,n.m)(tX,4);iy(c,t);let e=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y],s=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);eT(d,y,s,r,o);let a=[],h=[],m=tV(s,2,r,2,o,2,e,3,i,3,null,0,!0,n.E.unit(),n.E.unit(),h,a);if(m>0)for(let t=0;t<m;t++){let e=new n.P;iq(c,a[t],e);let i=new n.P;eX(d,y,h[t],i),n.P.distance(e,i)<=l&&(v.push(e.clone()),C.push(a[t]),b.push(h[t]))}}for(let t=0;t<2;t++){let e,i;0===t?(e=c,i=d):(i=c,e=d);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t){let t=ed(i,y,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),eX(i,y,a[0],h)}else{let t=iO(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),iq(i,a[0],h)}
1n.P.distance(e[o],h)<=l&&(0===t?(C.push(+(0!==o)),b.push(a[0])):(b.push(+(0!==o)),C.push(a[0])),v.push(h.clone()))}}if(0===C.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=im.recalculateParentT(_.vmin,_.vmax,C[t]);if(!f.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=tY.recalculateParentT(f.vmin,f.vmax,b[t]);for(let t=0;t<b.length;++t)b[t]=eN(P,b[t]);return rd(t,e,i,C,b,C.length,r,o,a,l,h,m,u)}function ij(t,e,i,r,o,a,l,h,m,u){let g=R(e,i);if(z(e,i,l=Math.max(l,g)))return 0;let c=(0,n.m)(n.P,4);e.queryControlPoints(c);let d=(0,n.m)(n.P,3);i.queryControlPoints(d);let _=rp(c,3,d,2,l);if(0===_)return 0;let p=[],f=[],P=[];if(-1===_){let t=(0,n.m)(tX,4);iy(c,t);let s=[t[0].x,t[1].x,t[2].x,t[3].x],r=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,n.m)(tX,3);ia(d,o);let a=tV([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,s,3,r,3,null,0,!0,n.E.unit(),n.E.unit(),P,f);if(a>0){let t=0;for(let s=0;s<a;s++){let r=new n.P;e.queryCoord2D(f[s],r);let o=new n.P;i.queryCoord2D(P[s],o),n.P.distance(r,o)<=l&&(p.push(r.clone()),f[t]=f[s],P[t]=P[s],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,i;0===t?(e=c,i=d):(i=c,e=d);for(let r=0;r<2;r++){let o=0===r?0:e.length-1,a=[0],h=new n.P;if(0===t)e3(i,e[o],a),il(i,a[0],h);else{let t=iO(i,e[o],n.E.unit(),!1,-1,1,a);(0,s.g)(1===t),iq(i,a[0],h)}n.P.distance(e[o],h)<=l&&(0===t?(f.push(+(0!==o)),P.push(a[0])):(P.push(+(0!==o)),f.push(a[0])),p.push(h.clone()))}}return rd(t,e,i,f,P,f.length,r,o,a,l,h,m,u)}function iZ(t,e,i){let s=(0,n.m)(n.P,4);t.queryControlPoints(s),iH(s,e,i)}function iH(t,e,i){if(e.equalsRange(0,1))return void i.setFromPoints(t,4);let s=(0,n.m)(n.P,4);iX(t,e.vmin,e.vmax,s),i.setFromPoints(s,4)}class iU{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{let t=new n.P;iq(this.controlPoints,e,t);let i=iD(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(i)}case 1:{let t=new n.P;iq(this.controlPoints,e,t);let i=iD(this.controlPoints,1,e),s=iD(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(s)+i.dotProduct(i))}case 2:{let t=new n.P;iq(this.controlPoints,e,t);let i=iD(this.controlPoints,1,e),s=iD(this.controlPoints,2,e),r=iD(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(r)+3*i.dotProduct(s))}case 3:{let t=iD(this.controlPoints,1,e),i=iD(this.controlPoints,2,e),s=iD(this.controlPoints,3,e);return 2*(4*t.dotProduct(s)+3*i.sqrLength())}case 4:{let t=iD(this.controlPoints,2,e),i=iD(this.controlPoints,3,e);return 2*(10*t.dotProduct(i))}case 5:{let t=iD(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(t){return 0}}function iO(t,e,i,o,a,l,h){(0,s.w)(n.E.unit().contains(i)&&l>0,"getClosestCoordinate"),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);let m=[],u=new n.P;iq(t,i.vmin,u);let g=n.P.distance(u,e);if(g<=a&&m.push(new n.P(i.vmin,g)),i.vmin!==i.vmax&&(iq(t,i.vmax,u),(g=n.P.distance(u,e))<=a&&m.push(new n.P(i.vmax,g))),i.width()>0){let s=(0,n.d)(18,NaN),r=td(new iU(t,e),i,18,s);for(let i=0;i<r;i++)iq(t,s[i],u),(g=n.P.distance(u,e))>a||m.push(new n.P(s[i],g))}if(o){(0,s.g)(i.equals(n.E.unit()));{iq(t,-1,u,!0);let i=new n.P;iq(t,0,i);let s=new rP({start:u,end:i}),r=s.getClosestCoordinate(e,!0);r<1&&(u.assign(s.getCoord2D(r)),(g=n.P.distance(u,e))<=a&&m.push(new n.P(r-1,g)))}{iq(t,2,u,!0);let s=new n.P;iq(t,i.vmax,s);let r=new rP({start:s,end:u}),o=r.getClosestCoordinate(e,!0);o>0&&(u.assign(r.getCoord2D(o)),(g=n.P.distance(u,e))<=a&&m.push(new n.P(1+o,g)))}}if(!m.length)return 0;m.sort((t,e)=>t.compare(e));let c=0,d=m[0].x;if(h[c++]=d,c<l){let e=(0,r.x)(t,4,!1).total(),i=m[0].y;for(let t=1,s=m.length;t<s;t++)if(m[t].y>i+e){m.length=t;break}m.sort((t,e)=>(0,n.X)(t.x,e.x)),c=0,h[c++]=m[0].x;for(let t=1,e=m.length;t<e;t++)m[t].x!==h[c-1]&&c<l&&(h[c++]=m[t].x)}return c}function iJ(t,e,i,s,r,o,a){let l=(0,n.m)(n.P,4);return t.queryControlPoints(l),iO(l,e,i,s,r,o,a)}function iQ(t,e){e[0].set(0);let i=1,r=(0,n.m)(n.F,4);ip(t,r,!0);let o=(0,n.m)(n.F,4);iP(t,o,!0);{let t=r[3].mul(3),s=r[2].mul(2),o=r[1].clone(),a=(0,n.m)(n.F,2),l=tv(t,s,o,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.J)(a[t].value(),0,1)||(e[i]=a[t],i++)}
1{let t=o[3].mul(3),s=o[2].mul(2),r=o[1].clone(),a=(0,n.m)(n.F,2),l=tv(t,s,r,new n.E(0,1),!1,a);l<0&&(l=0);for(let t=0;t<l;t++)(0,n.J)(a[t].value(),0,1)||(e[i]=a[t],i++)}if(i+=function(t,e,i){let s=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),r=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,n.m)(n.F,2),l=tv(o,r,s,new n.E(0,1),!1,a);l<0&&(l=0);let h=0;for(let t=0;t<l;t++)(0,n.J)(a[t].value(),0,1)||(i[h].setE(a[t]),h++);return h}(r,o,e.slice(i)),e[i].set(1),++i>2){(0,n.C)(e,0,i,(t,e)=>{let i=t.value(),s=e.value();return i<s?-1:+(i>s)});let s=0,r=e[0].clone(),o=0,a=(t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1))*(0,n.N)(),l=new n.P;iM(t,e[0].value(),l);for(let h=1;h<i;h++){let i=new n.P;if(iM(t,e[h].value(),i),e[h].eq(r)||i.isEqualPoint2D(l,a)){if(0!==s){if(0===e[h].eps())r.setE(e[h]),o=0;else if(0!==o){let t=(0,n.s)(1/e[h].eps()),i=1/o,s=t+i;r.set((e[h].value()*t+r.value()*i)/s),o=1/s,r.setError(Math.sqrt(o))}e[s].setE(r),iM(t,r.value(),l)}}else e[++s].setE(e[h]),r.setE(e[h]),iM(t,r.value(),l),o=(0,n.s)(e[h].eps())}i=++s}return 1===i&&(i=2,e[1].set(1)),(0,s.g)(0===e[0].value()),(0,s.g)(1===e[i-1].value(
1)),i}function iK(t,e,i){i.setEmpty();let s=[];s.push(new n.E(0,1));let r=.5*Math.max(e.width(),e.height());for(;s.length;){let o=s.at(-1);s.pop();let a=new p;if(iH(t,o,a),a.isIntersectingW(e)){let t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||1e-12>o.width())i.merge(o);else{let t=o.getCenter();s.push(n.E.construct(o.vmin,t)),s.push(n.E.construct(t,o.vmax))}}}}class i${constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-ix(this.b,e,!1):0}getError(t){return 0}}function i0(t,e,i,s,r,o,a,l,h,m,u,g){let c=0,d=0,_=0,p=0,f=0,P=0,y=0;for(let e=1,a=g-1;e<a;e++){let a,l,m,g,x,v,C=-1,b=h[e-1];t&&(e>2?(b=(0,n.c)(2*h[e-2]-h[e-3],0,1),h[e-1]=b):2===e&&b<=h[0]&&(b=h[0]));for(let c=0;c<11&&(m=(l=(a=h[e-1])*a)*a,v=(x=(g=1-a)*g)*g,t)&&!(1e-12>Math.abs(a-C))&&10!==c;c++){let t=i.x-2*s.x+r.x,m=i.x-3*s.x+3*r.x-o.x,g=i.y-2*s.y+r.y,c=i.y-3*s.y+3*r.y-o.y,d=i.x-s.x-2*t*a+m*l,_=-u[e].x+i.x*v+a*(3*s.x*x+a*(3*r.x-3*r.x*a+o.x*a)),p=i.y-s.y-2*g*a+c*l,f=-u[e].y+i.y*v+a*(3*s.y*x+a*(3*r.y-3*r.y*a+o.y*a));C=a;let P=a- -6*(d*_+p*f)/(6*(3*(0,n.s)(d)-(-2*t+2*m*a)*_)+6*(3*(0,n.s)(p)-(-2*g+2*c*a)*f));h[e-1]=(0,n.c)(P,e>1?h[e-2]:0,1)}c+=3*l*x*x,d+=3*m*v,_+=3*l*l*x;let E=-(v*i.x+m*o.x-u[e].x);p+=E*a*x,f+=E*l*g;let S=-(v*i.y+m*o.y-u[e].y);P+=S*a*x,y+=S*l*g}if(e){let t=c*_-d*d;Math.abs(t)>=1e-12*(Math.abs(c*_)+Math.abs(d*d))+1e-10?(a||(s.x=(p*_-f*d)/t,s.y=(P*_-y*d)/t),l||(r.x=(c*f-d*p)/t,r.y=(c*y-d*P)/t)):((0,n.Z)(i,o,.3,s),(0,n.Z)(i,o,.6,r))}let x=0;for(let t=1,e=g-1;t<e;t++){let e=h[t-1],a=1-e,l=i.mul((0,n.af)(a)),m=s.mul(3*e*a*a),g=r.mul(3*e*e*a),c=o.mul((0,n.af)(e));x+=l.add(m).add(g).add(c).sub(u[t]).sqrLength()}return x}function i1(t,e,i,s){let r=t.getPathStart(e),o=t.getPathEnd(e);if(o-r<3)return;let a=2*r,l=n.P.getNAN();i.queryPoint2D(a,l);let h=l.x,m=l.y,u=n.P.getNAN();i.queryPoint2D(a+2,u);let g=n.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)i.queryPoint2D(t,g),s.pe((g.x-l.x)*(u.y-m)),l.setCoordsPoint2D(u),u.setCoordsPoint2D(g);s.pe((h-l.x)*(u.y-m))}var i2=r.V;class i3{static toSegType(t){let e=0;switch(t){case s.G.enumLine:e=1;break;case s.G.enumBezier:e=2;break;case s.G.enumEllipticArc:e=4;break;case s.G.enumRationalBezier2:e=8;break;case s.G.enumBezier2:e=16;break;default:(0,s.c)("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class i4 extends d{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.m_curveData=null,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?s.G.enumPolygon:s.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,s.g)(this.m_bPolygon);let e=this.getPathIndexFromPointIndex(t),i=this.getPathStart(e);if(i===t)return;let r=this.getPathEnd(e);(t>=r||t<i)&&(0,s.t)("change_ring_start_point");for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){let s=this.m_description.getSemantics(e),n=i2.getComponentCount(s);this.m_vertexAttributes.get(e).rotate(i*n,t*n,r*n)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(i,t,r),this.m_curveData.m_segmentParamIndex.rotate(i,t,r))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return+!!this.m_bFillRule}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;let t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);let e=new r.y(t),i=new n.K(0),s=new n.K(0);if(0!==this.m_pointCount){let r=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){let t=new tl({parent:this});for(t.stripAttributes();t.nextPath();){s.reset();let n=t.getPathIndex();
1i1(this,n,r,s),function(t,e,i){for(;e.hasNextSegment();){let t=e.nextCurve();if(null===t)break;i.pe(2*t.calculateArea2DHelper())}}(0,t,s);let o=.5*s.getResult();i.add(o),e.write(n,o)}}else for(let n=0;n<t;n++){s.reset(),i1(this,n,r,s);let t=.5*s.getResult();i.add(t),e.write(n,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=i.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0,e=this.getPathCount();for(let i=0;i<e;i++)8&this.m_pathFlags.read(i)&&t++;return t}getHashCodeImpl(){return(0,s.g)(0),0}equalsImpl(t){let e=this.getPathCount();if(e!==t.getPathCount())return!1;let i=this.hasNonLinearSegments();if(i!==t.hasNonLinearSegments()||i&&(this.m_curveData.m_curveCount!==t.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==t.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(t.m_paths,0,e+1)||this.m_bFillRule!==t.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(t.m_pathFlags,0,e))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(t.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let e=0,i=this.getPointCount();e<i;e++){let i=this.m_curveData.m_segmentFlags.read(e);if(!i4.isNonLinearSegmentFlag(i))continue;let s=this.m_curveData.m_segmentParamIndex.read(e),r=t.m_curveData.m_segmentParamIndex.read(e),o=tc(i);for(let e=0;e<o;e++){let i=this.m_curveData.m_segmentParams.read(s+e),o=t.m_curveData.m_segmentParams.read(r+e);if(!(0,n.a3)(i,o))return!1}}}return!0}equalsImplTol(t,e){let i=this.getPathCount();if(i!==t.getPathCount())return!1;let s=this.hasNonLinearSegments();if(s!==t.hasNonLinearSegments()||s&&(this.m_curveData.m_curveCount!==t.m_curveData.m_curveCount||this.m_curveData.m_bezierCount!==t.m_curveData.m_bezierCount)||this.m_paths&&!this.m_paths.equals(t.m_paths,0,i+1)||this.m_bFillRule!==t.m_bFillRule||!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(t.m_pathFlags,0,i))return!1;if(!s)return!0;if(!this.m_curveData.m_segmentFlags.equals(t.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;let r=this.querySegmentIterator(),n=t.querySegmentIterator();for(;r.nextPath();){if(!n.nextPath())return!1;for(;r.hasNextSegment();){let t=r.nextCurve(),i=n.nextCurve();if(!(t&&i&&t.equals(i,e))){if(!t&&!i)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=(0,r.z)(1,0),this.m_pathFlags=(0,r.D)(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){t.m_bPathStarted=!1,t.m_bFillRule=this.m_bFillRule,this.m_paths?t.m_paths=e?this.m_paths:this.m_paths.clone():t.m_paths=null,this.m_pathFlags?t.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():t.m_pathFlags=null,this.m_curveData&&(t.m_curveData||(t.m_curveData=new i3),t.m_curveData.assignCopy(this.m_curveData),t.m_curveData.m_curveCount=0,t.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?t.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():t.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?t.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():t.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?t.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():t.m_curveData.m_segmentParams=null)),t.hasDirtyFlag(512)||(t.m_cachedLength2D=this.m_cachedLength2D),t.m_cachedRingAreas2D=null,t.hasDirtyFlag(1024)||(t.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(t.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}
1calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;let t=this.querySegmentIterator(),e=new n.K(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(t){let e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),i=new n.K(0);for(;e.hasNextSegment();)i.add(e.nextSegment().calculateLength2D());return i.getResult()}calculateLength3D(t){return(0,s.g)(0),0}calculatePathLength3D(t,e){return(0,s.g)(0),0}copyTo(t){(0,s.h)(t.getGeometryType())||(0,s.t)(""),this!==t&&super.copyTo(t)}swap(t){(0,s.g)(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,i=this.getPathCount();e<i;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&(0,s.t)("Multi_path_impl::add");for(let i=0,s=t.getPathCount();i<s;i++)this.addPath(t,i,!e)}addPath(t,e,i){this.insertPath(-1,t,e,i)}addPathPoint2D(t,e,i){this.insertPath2D(-1,t,0,e,i)}addPathMultiPoint(t,e,i,s){i<0&&(i=t.getPointCount()-e),this.insertPointsFromMultipoint(-1,0,t,e,i,s)}addSegmentsFromPath(t,e,i,r,n){if(this===t&&(0,s.t)("Multi_path_impl.add_segments_from_path"),n||0!==this.getPathCount()||(n=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||i<0||r<0||i+r>t.getSegmentCountPath(e))&&(0,s.n)("add_segments_from_path"),0===r)return;let o=t.getPathStart(e),a=t.isClosedPath(e)&&i+r===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let l=r,h=o+i,m=h+1;n&&(l++,m--),!n&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(h)&&(t.getXY(h).equals(this.getXY(this.m_pointCount-1))||(0,s.t)("add_segments_from_path: start point mismatch"));let u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange(),n){if(0===l)return;this.m_paths.add(this.m_pointCount);let i=t.m_pathFlags.read(e);this.m_bPolygon&&(i|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,i),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);let g=a?l-1:l;for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e),s=i2.getComponentCount(i),r=t.m_description.getAttributeIndex(i);if(g>0){if(r<0||!t.m_vertexAttributes.get(r)){let t=i2.getDefaultValue(i);this.m_vertexAttributes.get(e).insertRange(s*u,t,g*s,s*u),a&&this.m_vertexAttributes.get(e).insertRange(s*u+g*s,t,s,s*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(s*u,t.m_vertexAttributes.get(r),s*m,g*s,!0,s,s*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(s*(u+g),t.m_vertexAttributes.get(r),s*o,s,!0,s,s*(u+g))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let i=0,s=h;i<r;i++)e+=tc(t.m_curveData.m_segmentFlags.read(s)),s++;if(e>0){this.initSegmentData(e);let i=h,s=u-!n,o=0;for(let e=0;e<r;e++){let e=t.m_curveData.m_segmentFlags.read(i);if(this.m_curveData.m_segmentFlags.write(s,e),i4.isNonLinearSegmentFlag(e)){o++;let r=t.m_curveData.m_segmentParamIndex.read(i),n=tc(e);this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<n;e++){let e=t.m_curveData.m_segmentParams.read(r);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,r++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(s,-1);s++,i++}this.modifyCurveCounter(o)}}if(a){let t=this.getPathCount()-1,e=this.getPathStart(t),i=this.getPathEnd(t)-1,s=this.getXY(e),r=this.getXY(i);s.isEqualPoint2D(r)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&(0,s.t)("");let e=this.getPathSize(t);if(0===e)return;let i=this.getPathStart(t),r=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=i,s=new this.m_segmentBufferCTor,n=!1;for(let i=0;i<e;i++,t++){let e=this.m_curveData.m_segmentFlags.read(t);if(!i4.isNonLinearSegmentFlag(e))continue;n=!0,this.querySegment(t,s,!0),s.get().reverse();let i=this.m_curveData.m_segmentParamIndex.read(t);
1s.get().writeInBufferStream(this.m_curveData.m_segmentParams,i)}if(n){let t=+!r;this.m_curveData.m_segmentFlags.reverseRange(i,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(i,e-t,1)}}let n=+!!r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++)if(this.m_vertexAttributes.get(t)){let s=this.m_description.getSemantics(t),r=i2.getComponentCount(s);this.m_vertexAttributes.get(t).reverseRange(r*(i+n),r*(e-n),r)}let o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){let e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,s.t)("");let i=this.getPathStart(t),r=this.getPathSize(t);for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),s=i2.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*i,s*r,s*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=i,s=i+r;e<s;e++){let i=this.m_curveData.m_segmentFlags.read(e);i4.isNonLinearSegmentFlag(i)&&(this.incCurveType(i,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(i,r,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(i,r,this.m_pointCount)}for(let i=t+1;i<=e;i++){let t=this.m_paths.read(i);this.m_paths.write(i-1,t-r)}if(this.m_pathFlags)for(let i=t+1;i<=e;i++){let t=this.m_pathFlags.read(i);this.m_pathFlags.write(i-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=r,this.m_reservedPointCount-=r,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,i,n){this===e&&(0,s.t)("Multi_path_impl::insert_path");let o=this.getPathCount();if(!n&&e.hasNonLinearSegmentsPath(i))return t=this.insertPath(t,e,i,!0),this.reversePath(t),t;i>=e.getPathCount()&&(0,s.t)(""),t>o&&(0,s.t)(""),t<0&&(t=o),i<0&&(i=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());let a=e.getPathStart(i),l=e.getPathSize(i);if(0===l)return this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount,m=e.isClosedPath(i)&&!n?1:0;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let u=t<o?this.getPathStart(t):h;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=e.getDescription().getAttributeIndex(i),r=i2.getComponentCount(i);if(s>=0&&e.m_vertexAttributes.get(s))0!==m&&this.m_vertexAttributes.get(t).insertRangeFromStream(u*r,e.m_vertexAttributes.get(s),r*a,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((u+m)*r,e.m_vertexAttributes.get(s),r*(a+m),r*(l-m),n,r,r*(h+m));else{let e=i2.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(u*r,e,r*l,r*h)}}let g=h+l;this.m_paths.add(g);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=e.getPathFlagsStreamRef().read(i);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),e.hasNonLinearSegments()){this.initSegmentData(0);let t=a,i=0;for(let s=0;s<l;s++)i+=tc(e.m_curveData.m_segmentFlags.read(t)),t++;if(i>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=(0,r.D)(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=(0,r.z)(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(u,1,l,h),this.m_curveData.m_segmentParamIndex.insertRange(u,-1,l,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+i):this.m_curveData.m_segmentParams=(0,r.F)(i),t=a;let s=u,n=0;for(let i=0;i<l;i++){let i=e.m_curveData.m_segmentFlags.read(t);if(i4.isNonLinearSegmentFlag(i)){this.m_curveData.m_segmentFlags.write(s,i),this.m_curveData.m_segmentParamIndex.write(s,this.m_curveData.m_curveParamWritePoint);let r=tc(i),o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;
1t++){let t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(i,1)}t++,s++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,i,r,n){let o=this.getPathCount();(t>o||i<0)&&(0,s.t)(""),t<0&&(t=o),this.m_bPathStarted=!1;let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),0===r&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();let l=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*l,e,i,r,n,2*a);else{let t=i2.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*l,t,2*r,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=i2.getComponentCount(e),s=i2.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(l*i,s,i*r,i*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+r)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,r,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,i,r,n){let o=e.getImpl(),a=this.getPathCount();(t>a||i<0)&&(0,s.t)("");let l=r<0?o.getPointCount()-i:r;if(l>o.getPointCount()&&(0,s.t)(""),i>=o.getPointCount()&&(0,s.t)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===l)return void this.insertPath2D(t,null,0,0,!0);let h=this.m_pointCount;this.resizeImpl(this.m_pointCount+l),this.verifyAllStreamsAfterSizeChange();let m=t<a?this.getPathStart(t):h;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),r=i2.getComponentCount(e);if(s>=0){let s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(m*r,s,r*i,r*l,n,r,r*h)}else{let i=i2.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(m*r,i,r*l,r*h)}}this.m_paths.add(h+l);for(let e=a;e>=t+1;e--){let t=this.m_paths.read(e-1);this.m_paths.write(e,t+l)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let u=0;this.m_bPolygon&&(u|=1),this.m_pathFlags.write(t,u),this.notifyModifiedFlags(2001)}insertPoints(t,e,i,r,n,o,a){if(this===i&&(0,s.t)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),r<0&&(r=i.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>=i.getPathCount()||o>i.getPathSize(r))&&(0,s.n)(""),!o)return;if(this.mergeVertexDescription(i.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=i.m_pathFlags.read(r);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));let l=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();let h=this.getPathStart(t),m=h+e;o<0&&(o=i.getPathSize(r));let u=i.getPathStart(r),g=u+o;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=i2.getComponentCount(s),c=i.m_description.getAttributeIndex(s);if(c<0||!i.m_vertexAttributes.get(c)){let e=i2.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*m,e,g*r,r*l)}else this.m_vertexAttributes.get(t)?.insertRangeFromStream(r*(h+e),i.m_vertexAttributes.get(c),r*(u+n),o*r,a,r,r*l)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,o,l),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,o,l),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,i,r,n,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||r<0)&&(0,s.n)(""),!n)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));let a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let l=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(l+e),i,r,n,o,2*a);for(let t=1,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=i2.getComponentCount(i),r=i2.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange((l+e)*s,r,s*n,s*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(l+e,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(l+e,-1,n,a),e>0&&this.isNonLinearSegment(l+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(l+e-1),-1),this.m_curveData.m_segmentFlags.write(l+e-1,1),this.m_curveData.m_segmentParamIndex.write(l+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++)this.m_paths.write(e,this.m_paths.read(e)+n);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,i,r,n,o){let a=i.getImpl(),l=this.getPathCount();t<0&&(t=this.getPathCount());let h=a.getPointCount();if((r<0||r>h)&&(0,s.n)(""),(n<0||r+n>h)&&(n=h-r),e<0&&(e=t<l?this.getPathSize(t):0),(t>l||t<l&&e>this.getPathSize(t)||t===l&&e>0||n<0)&&(0,s.n)(""),!n)return;this.mergeVertexDescription(a.getDescription()),t===l&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));let m=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),this.verifyAllStreamsAfterSizeChange();let u=this.getPathStart(t),g=u+e,c=0+n;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){let i=this.m_description.getSemantics(t),s=i2.getComponentCount(i);if(0>a.getDescription().getAttributeIndex(i)){let e=i2.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(s*g,e,c*s,s*m);continue}let l=a.getAttributeStreamRef(i);this.m_vertexAttributes.get(t).insertRangeFromStream(s*(u+e),l,s*(0+r),n*s,o,s,s*m)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(u+e,1,n,m),this.m_curveData.m_segmentParamIndex.insertRange(u+e,-1,n,m),e>0&&this.isNonLinearSegment(u+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(u+e-1),-1),this.m_curveData.m_segmentFlags.write(u+e-1,1),this.m_curveData.m_segmentParamIndex.write(u+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,i=this.getPathCount();e<=i;e++){let t=this.m_paths.read(e);this.m_paths.write(e,t+n)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.n)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,l=this.m_vertexAttributes.get(0);if(a===n)this.m_paths.write(t+1,n+1),l.writePoint2D(2*a,i);else{l.insert(2*a,i,2*n);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=i2.getComponentCount(e),s=i2.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(i*a,s,i,i*n)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1;e<=r;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,i){let r=this.getPathCount();t<0&&(t=r),(t>r||t<r&&e>this.getPathSize(t))&&(0,s.n)(""),t===r&&this.addPathPoint2D(null,0,!0);let n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();let o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===n)this.m_paths.write(t+1,n+1),this.setPointByVal(a,i);else{let e=i.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){let s=this.m_description.getSemantics(t),r=i2.getComponentCount(s);if(e.hasAttribute(s))this.m_vertexAttributes.get(t).insertAttributes(r*a,i,s,r*n);else{let e=i2.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(r*a,e,r,r*n)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,n));for(let e=t+1;e<=r;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){let i=this.getPathCount();t<0&&(t=i-1),(t>=i||e>=this.getPathSize(t))&&(0,s.n)("Multi_path.remove_point");let r=this.getPathStart(t),n=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,s.n)("Multi_path.remove_point");let o=r+e;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),i=i2.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*o,i,i*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParam
1s();let e=0;if(o>r&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{let i=this.getPathEnd(t);n&&r+1<i&&this.isNonLinearSegment(i-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(i-1),-1),this.m_curveData.m_segmentFlags.write(i-1,1),this.m_curveData.m_segmentParamIndex.write(i-1,-1),e+=1)}this.isNonLinearSegment(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=i;e>=t+1;e--){let t=this.m_paths.read(e);this.m_paths.write(e,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let i=this.getPathStart(t),s=this.getPathEnd(t);i<s;i++)i4.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(i))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);let i=this.getPathCount(),s=i4.getPathIndexFromPointIndexImpl(this.m_paths,i,t,e);return this.m_currentPathIndex=s,s}startPathCoords(t,e){this.startPathPoint(new r.P({x:t,y:e}))}startPath(t){this.startPathPoint(new r.P({pt:t}))}startPath3D(t){this.startPathPoint(new r.P({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,i){this.startPathPoint(new r.P({x:t,y:e,z:i}))}startPathPoint(t){let e;t.isEmpty()&&(0,s.t)("");let i=t.getDescription();if(this.m_description!==i){this.mergeVertexDescription(i);let s=new r.P({vd:this.m_description});t.copyCommonAttributesTo(s),e=s}else e=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,e):(this.insertPoint(-1,-1,e),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=(0,r.z)(2),this.m_paths.write(0,0),this.m_pathFlags=(0,r.D)(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);let e=this.m_pointCount,i=this.m_paths.size()-1,s=e+t;this.m_paths.write(i,s),this.resizeImpl(s),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){let t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{let i=(0,r.o)(),s=new r.P({vd:this.m_description,attribBuffer:i,initDefaultValues:!0});s.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);let e=(0,r.l)(this.m_description,(0,r.w)()),i=(0,r.o)(),s=new r.P({vd:e,attribBuffer:i,initDefaultValues:!0});s.setXYZ(t),this.setPointByVal(this.m_pointCount-1,s),this.finishLineTo()}lineTo3DCoords(t,e,i){this.lineTo3D(new r.h(t,e,i))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());let e=(0,r.o)(),i=new r.P({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(i),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&(0,s.c)("");let e=this.getPathCount();if(t>e&&(0,s.t)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,s.c)("");let i=this.m_pointCount,r=this.getPathStart(t),n=this.getPathEnd(t);if(n-r!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){let e=this.m_description.getSemantics(t),s=i2.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(s*n,this.m_vertexAttributes.get(t),s*r,s,!0,1,s*i)}for(let i=e;i>t;i--){let t=this.m_paths.read(i);this.m_paths.write(i,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(n,1,1,i),this.m_curveData.m_segmentParamIndex.insertRange(n,-1,1,i)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,s.c)(""),t>this.getPathCount()&&(0,s.t)(""),this.m_pathFlags||(0,s.c)(""),this.m_pathFlags.clearBits(t,1)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&(0,s.c)(""),this.isEmpty())return;this.m_pathFlags||(0,s.c)("");let t=0,e=this.getPathCount();for(let i=0;i<e;i++)this.isClosedPath(i)&&(this.getPathSize(i)>0?t++:this.m_pathFlags.clearBits(i,1));if(0===t)return;let i=this.hasNonLinearSegments(),n=0,o=this.getPathCount(),a=this.m_description.getAttributeCount(),l=Array(a),h=null,m=null;for(let e=0;e<o;++e){let s=this.getPathStart(e),o=this.getPathSize(e),u=this.isClosedPath(e);if(o>0){let e=s+n;for(let i=0;i<a;i++)if(this.m_vertexAttributes.get(i)){let n=this.m_description.getSemantics(i),a=i2.getComponentCount(n);if(!l[i]){let e=a*(this.m_pointCount+t),s=(0,r.u)(n,e);l[i]=s}l[i].writeRange(e*a,o*a,this.m_vertexAttributes.get(i),s*a,!0,1),u&&l[i].writeRange((e+o)*a,a,this.m_vertexAttributes.get(i),s*a,!0,1)}if(i){if(null===h){let e=this.m_pointCount+t;h=(0,r.D)(e),m=(0,r.z)(e)}h.writeRange(e,o,this.m_curveData.m_segmentFlags,s,!0,1),m.writeRange(e,o,this.m_curveData.m_segmentParamIndex,s,!0,1),u&&(h.write(e+o,1),m.write(e+o,-1))}}this.m_paths.write(e,s+n),u&&(this.m_pathFlags.clearBits(e,1),++n)}this.m_paths.write(o,this.m_pointCount+t),this.m_pathFlags.clearBits(o,1);for(let t=0;t<a;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,l[t]);i&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,s.t)("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);let e=this.m_pathFlags.read(t);if(1&e||this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){let e=this.getPathEnd(t)-1,i=this.m_curveData.m_segmentFlags.read(e);1!==i&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==i&&(this.incCurveType(i,-1),this.modifyCurveCounter(-1)))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&(0,s.t)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,s.t)("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());let i=e.getStartXY(),r=this.getPathEnd(t)-1;i.equals(this.getXY(r))||(0,s.t)("close_path_with_segment: start point mismatch");let n=e.getGeometryType();if(n===s.G.enumLine)return void this.closePathWithLine(t);{let t=tg(e);this.initSegmentData(t);let i=i3.toSegType(n),s=this.m_curveData.m_segmentFlags.read(r);if(s!==i)this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParam
1s,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(i,1),1!==s?this.incCurveType(s,-1):this.modifyCurveCounter(1);else{let t=this.m_curveData.m_segmentParamIndex.read(r);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(r,i)}}let i=this.m_pathFlags.read(t);1&i||this.m_pathFlags.write(t,1|i),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,i=this.m_paths.size()-1;e<i;e++){if(this.isClosedPath(e))continue;let i=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|i),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;let e=this.getPathStart(t),i=this.getPathEnd(t)-1;if(e>i)return!1;let s=this.getXY(e),r=this.getXY(i);return s.isEqualPoint2D(r)}isClosedPathIn3D(t){return(0,s.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),i=this.getPathEnd(t);e<i;e++)if(i4.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;let i=0===this.m_pointCount;if(t instanceof o.J)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{let i=t.getDescription(),s=(0,r.o)(),n=new r.P({vd:i,attribBuffer:s,initDefaultValues:!1});for(let i=0;i<4;i++){let s=e?4-i-1:i;t.queryCornerByVal(s,n),0===i?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,i&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||(0,s.t)("add_path_from_closedSegment: segment must be closed"),e){let e=t.getReversed(),i=new r.P;e.queryStart(i),this.startPathPoint(i),this.closeLastPathWithSegment(e)}else{let e=new r.P;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){let i=t.getDescription();this.mergeVertexDescription(i);let n=(0,r.o)(),o=new r.P({vd:i,attribBuffer:n,initDefaultValues:!1}),a=t.getGeometryType();if(a===s.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(o),this.startPathPoint(o)),t.queryEnd(o),this.lineToPoint(o);else{let i=!1;if((e||this.isEmptyImpl())&&(i=!0),!i&&(t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,s.t)("add_segment: start point mismatch")),i&&(t.queryStart(o),this.startPathPoint(o)),this.beforeNewSegment(1),t.queryEnd(o),o.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,o);else{let t=(0,r.o)(),e=new r.P({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});o.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}let n=tg(t);this.initSegmentData(n),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=n;let l=i3.toSegType(a);this.incCurveType(l,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,l)}}addSegment(t,e,i){i?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,i,r){for(let e=t;e<i-1;e++)this.isClosedPath(e)&&(0,s.t)("cannot interpolate across closed paths");let n=this.m_description.getAttributeCount();if(1===n)return;let o=this.calculateSubLength2D(t,e,i,r);if(0!==o)for(let s=1;s<n;s++){let n=this.m_description.getSemantics(s);this.interpolateAttributesSemanticsImpl(n,t,e,i,r,o)}}interpolateAttributesSemantics(t,e,i,r,n){if(0===t)return;this.hasAttribute(t)||(0,s.t)("does not have the given attribute"),2===i2.getInterpolation(t)&&(0,s.t)("angular interpolation");for(let t=e;t<r-1;t++)this.isClosedPath(t)&&(0,s.t)("cannot interpolate across closed paths");let o=this.calculateSubLength2D(e,i,r,n);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,i,r,n,o)}interpolateAttributesPath(t,e,i){let s=this.m_description.getAttributeCount();if(1===s||e===i)return;
1let r=this.calculatePathSubLength2D(t,e,i);for(let n=1;n<s;n++){let s=this.m_description.getSemantics(n);this.interpolateAttributesSemanticsPathImpl(s,t,e,i,r)}}interpolateAttributesSemanticsPath(t,e,i,r){if(0===t)return;this.hasAttribute(t)||(0,s.t)("does not have the given attribute"),2===i2.getInterpolation(t)&&(0,s.t)("angular interpolation");let n=this.calculatePathSubLength2D(e,i,r);0!==n&&this.interpolateAttributesSemanticsPathImpl(t,e,i,r,n)}interpolateAttributesSemanticsImpl(t,e,i,s,r,o){let a=this.querySegmentIterator(),l=this.getPathStart(e)+i,h=this.getPathStart(s)+r,m=i2.getComponentCount(t),u=(0,n.d)(i2.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,l,u,m);let g=(0,n.d)(i2.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,g,m);let c=(0,n.d)(i2.maxComponentCount(),NaN);(0,n.a)(c,u,0,0,m);let d=0,_=i2.getDefaultValue(t),p=i2.getInterpolation(t);a.resetToVertex(l,e);do if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===h)return;this.setAttributeFromArray(t,a.getStartPointIndex(),c,m),a.previousSegment();do{let e=a.nextSegment();if(a.getEndPointIndex()===h)return;d+=e.calculateLength2D(),(0,n.B)(p,u,g,c,0,m,d/o,_),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),c,m)}while(a.hasNextSegment())}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,i,s,r){let o=this.querySegmentIterator(),a=i2.getInterpolation(t),l=this.getPathStart(e)+i,h=this.getPathStart(e)+s;if(h===l)return;let m=i2.getComponentCount(t),u=(0,n.d)(i2.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,l,u,m);let g=(0,n.d)(i2.maxComponentCount(),NaN);this.queryAttributeAsDbl(t,h,g,m);let c=new n.K(0);o.resetToVertex(l,e),o.setCirculator(this.isClosedPath(e));let d=i2.getDefaultValue(t),_=(0,n.d)(i2.maxComponentCount(),NaN);(0,n.a)(_,u,0,0,m);let p=0===r,f=.5;do{let e=o.nextSegment();if(this.setAttributeFromArray(t,o.getStartPointIndex(),_,m),!p){let t=e.calculateLength2D();c.pe(t),f=c.getResult()/r}(0,n.B)(a,u,g,_,0,m,f,d)}while(o.getEndPointIndex()!==h)}querySegment(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.t)("get_segment"),this.getSegmentFromPath(r,n,e,i)}getSegment(t,e){let i=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,i,e),i.releaseSegment()}getSegmentType(t){let e=this.getPathIndexFromPointIndex(t),i=t-this.getPathStart(e);return i>=this.getSegmentCountPath(e)&&(0,s.t)("get_segment"),this.getSegmentTypeFromPath(e,i)}getSegmentFromPath(t,e,i,n){let o=this.getPathStart(t)+e,a=this.getSegmentFlagsStreamRef(),l=1;switch(a&&(l=31&a.read(o)),l){case 1:i.createLine();break;case 2:i.createCubicBezier();break;case 4:i.createEllipticArc();break;case 8:i.createQuadraticRationalBezier();break;case 16:i.createQuadraticBezier();break;default:(0,s.c)("")}let h=i.get(),m,u=null;if(n?(u=(0,r.j)(),h.assignVertexDescription(u)):h.assignVertexDescription(this.m_description),m=o===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):o+1,w(h,this.getXY(o)),T(h,this.getXY(m)),!n)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){let e=this.m_description.getSemantics(t),i=i2.getComponentCount(e);for(let t=0;t<i;t++){let i=this.getAttributeAsDbl(e,o,t);h.setStartAttribute(e,t,i);let s=this.getAttributeAsDbl(e,m,t);h.setEndAttribute(e,t,s)}}if(i4.isNonLinearSegmentFlag(l)){let t=this.m_curveData.m_segmentParamIndex.read(o);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments()||0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let i=0,s=this.getPointCount();i<s;i++)if(4===this.m_curveData.m_segmentFlags.read(i)){var e;let s=this.m_curveData.m_segmentParamIndex.read(i);(e=this.m_curveData.m_segmentParams,e.readPoint2D(s+4)).isNAN()&&(this.m_curveData.m_segmentFlags.write(i,1),this.m_curveData.m_segmentParamIndex.write(i,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,e,i,r=!1){let o={iSegment:-1},a=r?o:{iSegment:-1,tSegment:0};if(i.setEmpty(),this.isEmpty()||((t<0||t>=this.getPathCount())&&(0,s.t)("query_point_along_path"),e<0))return o;let l=this.getPathSize(t);if(0===l)return o;if(1===l)return this.getPointByVal(this.getPathStart(t),i),a.tSegment=0,o.iSegment=this.getPathStart(t),o;let h=this.querySegmentIteratorAtVertex(this.getPathStart(t)),m=new n.K(0);for(;h.hasNextSegment();){let t=h.nextSegment(),s=t.calculateLength2D(),r=m.getResult();if(m.add(s),m.getResult()>=e){let n=e-r;n>s&&(n=s);let l=t.lengthToT(n);return t.queryCoord(l,i),a.tSegment=l,o.iSegment=h.getStartPointIndex(),o}}if(this.isClosedPath(t)){let e=this.getPathStart(t);return this.getPointByVal(e,i),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}
1{let e=this.getPathEnd(t)-1;return this.getPointByVal(e,i),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2):(a.tSegment=0,o.iSegment=this.getPathStart(t)),o}}queryPointsAlongPath(t,e,i,r,o,a){{let t=0;for(let n=0;n<e;++n)r&&r[n].setEmpty(),o&&(o[n]=-1),a&&(a[n]=0),t>i[n]&&(0,s.t)("query_points_along"),t=i[n]}let l=this.getPathSize(t);if(0===e||0===l)return 0;if(1===l){let e=this.getPathStart(t);return r&&this.getPointByVal(e,r[0]),a&&(a[0]=0),o&&(o[0]=e),1}let h=this.getPathStart(t),m=new n.K(0),u=this.querySegmentIteratorAtVertex(h),g=0,c=0,d=i[0];for(;u.hasNextSegment();){let t=u.nextSegment(),s=t.calculateLength2D(),n=m.getResult();for(m.add(s);m.getResult()>=d;){let l=d-n;l>s&&(l=s);let h=t.lengthToT(l);if(r&&t.queryCoord(h,r[c]),a&&(a[c]=h),o&&(o[c]=u.getStartPointIndex()),c++,d=i[++g],g===e)return c}}if(this.isClosedPath(t)){let e=this.getPathStart(t);r&&this.getPointByVal(e,r[c]),a&&(a[c]=0),o&&(o[c]=e),c++}else if(this.getPathSize(t)>1){let e=this.getPathEnd(t)-2;r&&this.getPointByVal(e+1,r[c]),a&&(a[c]=1),o&&(o[c]=e),c++}return c}queryPointsAlong(t,e,i,r,o){{let n=0;for(let a=0;a<t;++a)i&&i[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),n>e[a]&&(0,s.t)("query_points_along"),n=e[a]}if(0===t)return 0;let a=new n.K(0),l=this.querySegmentIterator(),h=-1,m=0,u=0,g=e[0];for(;l.nextPath();)for(;l.hasNextSegment();){h=l.getPathIndex();let s=l.nextSegment(),n=s.calculateLength2D(),c=a.getResult();for(a.add(n);a.getResult()>=g;){let a=g-c;a>n&&(a=n);let h=s.lengthToT(a);if(i&&s.queryCoord(h,i[u]),o&&(o[u]=h),r&&(r[u]=l.getStartPointIndex()),u++,g=e[++m],m===t)return u}}if(h<0)return 0;if(this.isClosedPath(h)){let t=this.getPathStart(h);i&&this.getPointByVal(t,i[u]),o&&(o[u]=0),r&&(r[u]=t),u++}else if(this.getPathSize(h)>1){let t=this.getPathEnd(h)-2;i&&this.getPointByVal(t+1,i[u]),o&&(o[u]=1),r&&(r[u]=t),u++}return u}querySegmentIterator(){return new tl({parent:this})}querySegmentIteratorAtVertex(t){return new tl({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,i){if(e instanceof r.E&&(0,s.g)(0,"not implemented for Envelope"),e instanceof r.n&&(0,s.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,s.t)(""),this.isEmpty())return void e.setEmpty();let n=this.getAttributeStreamRef(0),a=o.J.constructEmpty();a.setEmpty();for(let e=2*this.getPathStart(t),i=2*this.getPathEnd(t);e<i;){let t=i-e;(0,s.g)(!(1&t)),a.mergePointsInterleaved(n,e/2,t/2),e+=t}if(e.setCoords({env2D:a}),this.hasNonLinearSegmentsPath(t)){let r=this.querySegmentIterator();if(r.resetToPath(t),r.nextPath())for(;r.hasNextSegment();){let t=r.nextCurve();if(!t)break;{let s=o.J.constructEmpty();i?t.queryEnvelope(s):t.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}else(0,s.g)(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams||this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;let t=tc(4)*this.m_curveData.m_arcCount+tc(2)*this.m_curveData.m_bezierCount+tc(8)*this.m_curveData.m_rbezier2Count+tc(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,i=this.getPointCount();e<i;e++){let i=this.m_curveData.m_segmentFlags.read(e);i4.isNonLinearSegmentFlag(i)&&(t+=tc(i))}let e=(0,r.F)(t),i=0;for(let t=0,s=this.getPointCount();t<s;t++){let s=this.m_curveData.m_segmentFlags.read(t);if(i4.isNonLinearSegmentFlag(s)){let r=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,i);let n=tc(s);for(let t=0;t<n;t++)e.write(i,this.m_curveData.m_segmentParams.read(r)),i++,r++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=i}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(t){(0,s.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=(0,r.z)(0),this.m_pathFlags=(0,r.D)(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,+!!this.m_bPolygon))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=(0,r.z)(0),this.m_pathFlags=(0,r.D)(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,+!!this.m_bPolygon)))}clone(){let t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new i5(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParam
1s:null}setSegmentData(t,e,i,s){this.m_curveData||(this.m_curveData=new i3),this.m_curveData.m_segmentFlags=i,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=s}static getPathIndexFromPointIndexImpl(t,e,i,r){if(r>=0&&r<e){if(i>=t.read(r)){if(i<t.read(r+1))return r;r++}else r--;if(r>=0&&r<e&&i>=t.read(r)&&i<t.read(r+1))return r}if(e<5){for(let s=0;s<e;s++)if(i<t.read(s+1))return s;(0,s.k)("")}let n=0,o=e-1;for(;o>n;){let e=n+(o-n>>1);if(i<t.read(e))o=e-1;else{if(!(i>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(t){(0,s.g)(t>=0&&t<this.getPathCount());let e=this.getAttributeStreamRef(0),i=this.getPathEnd(t),r=this.getPathStart(t),o=-1,a=new n.P;a.y=-1/0,a.x=-1/0;for(let t=r+0;t<i;t++){let i=e.readPoint2D(2*t);-1===a.compare(i)&&(o=t,a.setCoordsPoint2D(i))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,s.t)("apply_transformation"),this.isEmpty()||t.isIdentity())return;let i=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let s,r;return e<0?(s=0,r=this.m_pointCount):(s=this.getPathStart(e),r=this.getPathEnd(e)),i.applyTransformation(t,2*s,r-s),void this.notifyModifiedFlags(2001)}let r=new this.m_segmentBufferCTor,o=this.getPathCount(),a=e<0?0:e;do{let s=this.getPathStart(a),o=this.getPathEnd(a),l=this.isClosedPath(a),h=i.readPoint2D(2*s);if(!this.hasNonLinearSegmentsPath(a)){i.applyTransformation(t,2*s,o-s);continue}let m=n.P.getNAN();for(let e=s;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){let n=l&&e+1===o;n&&i.writePoint2D(2*s,h),this.getSegmentBuffer(e,r,!0),r.get().applyTransformation(t);let a=this.m_curveData.m_segmentParamIndex.read(e);r.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),i.writePoint2D(2*e,r.get().getStartXY()),n&&i.writePoint2D(2*s,r.get().getEndXY());continue}let n=2*e;i.queryPoint2D(n,m),t.transformInPlace(m),i.writePoint2D(n,m)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,i,r){let n=this.getPathStart(t)+e,o=this.getPathStart(i)+r;(o<n||n<0||o>this.getPointCount()-1)&&(0,s.m)("");let a=this.querySegmentIterator(),l=0;a.resetToVertex(n,t);do{for(;a.hasNextSegment();){let t=a.nextSegment();if(a.getStartPointIndex()===o)break;l+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return l}calculatePathSubLength2D(t,e,i){let r=this.getPathStart(t)+e,n=this.getPathStart(t)+i;(r<0||n>this.getPointCount()-1)&&(0,s.m)("");let o=this.querySegmentIterator();if(r>n&&(this.isClosedPath(t)||(0,s.t)("cannot iterate across an open path"),o.setCirculator(!0)),r===n)return 0;let a=0,l=0;o.resetToVertex(r,t);do l+=a,a=o.nextSegment().calculateLength2D();while(o.getStartPointIndex()!==n);return l}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){let e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){let i=o.J.constructEmpty(),s=this.querySegmentIterator();for(;s.nextPath();)for(;s.hasNextSegment();){let r=s.nextCurve();if(!r)break;t?r.queryEnvelope(i):r.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&(0,s.t)("Multi_path_impl::add");let i=this.getPathCount();for(let s=0,r=t.getPathCount();s<r;s++)this.addPath(t,s,!e),this.openPathAndDuplicateStartVertex(i),i++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,i){let r=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(r);n>=this.getSegmentCountPath(r)&&(0,s.t)("getSegmentBuffer"),this.getSegmentFromPath(r,n,e,i)}getSegmentTypeFromPath(t,e){let i=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef(),n=1;switch(r&&(n=31&r.read(i)),n){case 1:return s.G.enumLine;case 2:return s.G.enumBezier;case 4:return s.G.enumEllipticArc;case 8:return s.G.enumRationalBezier2;case 16:return s.G.enumBezier2;default:(0,s.c)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,i=this.getPathCount();e<i;e++){let i=this.getPathStart(e),r=this.getPathEnd(e),o=r-i;for(let e=i;e<r;e++){let r=31&this.m_curveData.m_segmentFlags.read(e);if(1===r)continue;2!==r&&(0,s.b)("ensure_xy_monotone_segments");let a=(e-i+1)%o+i,l=this.m_curveData.m_segmentParamIndex.read(e),h=(0,n.m)(n.P,4);h[0]=this.getXY(e),h[3]=this.getXY(a),h[1].x=this.m_curveData.m_segmentParam
1s.read(l),h[1].y=this.m_curveData.m_segmentParams.read(l+1),h[2].x=this.m_curveData.m_segmentParams.read(l+2),h[2].y=this.m_curveData.m_segmentParams.read(l+3),iI(h)&&(t=!0,this.m_curveData.m_segmentParams.write(l,h[1].x),this.m_curveData.m_segmentParams.write(l+1,h[1].y),this.m_curveData.m_segmentParams.write(l+2,h[2].x),this.m_curveData.m_segmentParams.write(l+3,h[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new th),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);let e=(0,r.G)(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new th),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);let e=(0,r.H)(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(i4.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new i3),i4.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new i3),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new i3);let e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=(0,r.D)(e,1),this.m_curveData.m_segmentParamIndex=(0,r.z)(e,-1));let i=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=(0,r.F)(i):i!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(i,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(t){null===this.m_curveData&&(this.m_curveData=new i3),this.m_curveData.m_curveParamWritePoint=t}updateOGCFlagsHelper(){let t=this.getPathCount();if(0===t)return;let e=this.m_pathFlags,i=0;for(let s=0;s<t;s++){let t=this.m_cachedRingAreas2D.read(s);0===i&&(i=(0,n.e)(t)),t*i>0||0===i?e.setBits(s,8):e.clearBits(s,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(t,e,i){(t<0||t>=this.getPointCount())&&(0,s.t)("Multi_path_impl.replace_segment"),(0,s.g)(e.isCurve());let o=this.getPathIndexFromPointIndex(t),a=this.getPathStart(o),l=(t-a+1)%this.getPathSize(o)+a;{let i=this.getXY(t),r=this.getXY(l),n=!i.isEqualPoint2D(e.getStartXY())||!r.isEqualPoint2D(e.getEndXY());(0,s.g)(!n)}let h=e.getDescription();this.mergeVertexDescription(h);let m=(0,n.d)(32,NaN),u=new r.P({vd:h,attribBuffer:m,initDefaultValues:!1}),g=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),c=tc(g),d=tg(e),_,p=!1;c>=d?((0,s.g)(null!==this.m_curveData),p=!0,_=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(d),p=!1,_=this.m_curveData.m_curveParamWritePoint);let f=e.getGeometryType(),P=i3.toSegType(f);i||(e.queryStart(u),this.setPointByVal(t,u),e.queryEnd(u),this.setPointByVal(l,u)),this.m_curveData.m_segmentParamIndex.write(t,1!==P?_:-1),this.m_curveData.m_segmentFlags.write(t,P),1!==P&&e.writeInBufferStream(this.m_curveData.m_segmentParams,_),p||(this.m_curveData.m_curveParamWritePoint+=d),g!==P&&(this.incCurveType(g,-1),this.incCurveType(P,1),this.modifyCurveCounter(1===g?1:-1))}setAttributeImpl(t,e,i){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,s.t)("");let t=new a.T,r=0===e?i:0;t.setShiftCoords(r,+(0!==e)),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,i)}}i4.st_totalCurveCount=0;class i5{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o.J(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){let t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;let t=this.m_qtIter.next();if(-1===t)return null;let e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){let t=this.m_segIter.nextSegment(),e=o.J.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class i6 extends i4{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=ry):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ry,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ry):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ry,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=ry,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,s.c)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=ry)}getBoundary(){return i7(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return i6.type}getDimension(){return 1}createInstance(){return new i6({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}i6.type=s.G.enumPolyline;var i8=s.G;function i7(t,e){let i=t.getGeometryType();if(i===i8.enumPolygon){let e=new i6({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(i===i8.enumPolyline)return i9(t.getImpl(),e,!1).boundary;if(i===i8.enumEnvelope){let e=new i6({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,s.f)(i)){let e=new _({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){let i=new r.P;e.reserve(2),t.queryStart(i),e.add(i),t.queryEnd(i),e.add(i)}return e}if(i===i8.enumGeometryCollection){let i=null;for(let s=0,r=t.getGeometryCount();s<r;s++){let r=i7(t.getGeometry(s),e);null!==r&&(null===i&&(i=t.createInstance()),i.addGeometry(r))}return i}if((0,s.e)(i))return new r.P({vd:t.getDescription()});(0,s.b)("")}function i9(t,e,i){let s=null;if(i||(s=new _({vd:t.getDescription()})),!t.isEmpty()){let e=new r.A(0);for(let i=0,s=t.getPathCount();i<s;i++)if(t.getPathSize(i)>0&&!t.isClosedPathInXYPlane(i)){let s=t.getPathStart(i);e.add(s);let r=t.getPathEnd(i)-1;e.add(r)}if(e.size()>0){let o=new r.B,a=t.getAttributeStreamRef(0);o.sort(e,0,e.size(),{userSort(t,e,i){let s=n.P.getNAN(),r=n.P.getNAN();i.sort(t,e,(t,e)=>(a.queryPoint2D(2*t,s),a.queryPoint2D(2*e,r),s.compare(r)))},getValue:t=>a.read(2*t+1)});let l=a.readPoint2D(2*e.read(0)),h=0,m=1,u=new r.P;for(let t=1,s=e.size();t<s;t++){let s=a.readPoint2D(2*e.read(t));if(s.isEqualPoint2D(l))e.read(h)>e.read(t)?(e.write(h,(0,n.j)()),h=t):e.write(t,(0,n.j)()),m++;else{if(1&m){if(i)return{bNotEmpty:!0,boundary:new _({})}}else e.write(h,(0,n.j)());l=s,h=t,m=1}}if(1&m){if(i)return{bNotEmpty:!0,boundary:new _({})}}else e.write(h,(0,n.j)());if(!i){e.sort(0,e.size());for(let i=0,r=e.size();i<r&&e.read(i)!==(0,n.j)();i++)t.getPointByVal(e.read(i),u),s.add(u)}}}return i?{bNotEmpty:!1,boundary:new _({})}:{bNotEmpty:!1,boundary:s}}let st=n.a4/180,se=180/n.a4;function si(t){let e,i=t;return(e=i)>=-360&&e<720?e<0?e+=360:e>=360&&(e-=360):(e=(0,n.o)(e,360))<0&&(e+=360),(i=e)>180&&(i-=360),i}function ss(t){return t*st}function sr(t){return t*se}function sn(t){let e=(0,n.a8)(),i=t;return i>=-e&&i<2*e?(i<0&&(i+=e),i>=e&&(i-=e)):(i=(0,n.o)(i,e))<0&&(i+=e),i}function so(t){let e=(0,n.a5)(),i=t;return i>-e&&i<=e||(i=sn(i))>e&&(i-=(0,n.a8)()),i}function sa(t,e){return si(e-t)}var sl=r.V;class sh extends H{constructor(t){if(void 0===t||(0,n.O)(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new n.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new n.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return i7(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}constructCircleRadius(t,e,i=!1){return this.constructEllipse(t,1,e,0,i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,i=!1){let s=n.P.distance(t,e);
1return this.constructEllipticArcEndPointsCenter(e,e,s,1,0,!0,i,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,i=!1){let s=n.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(s,t,i),this}constructLineEllipticArc(t,e){return sM(this,t,e,1),this}constructLineCircularArc(t,e){return sM(this,t,e,0),this}constructEllipse(t,e,i,s,r=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);let o=new n.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(s),l=Math.sin(s);return o.rotateDirect(a,l),o.addThis(i),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,s,!0,r,i),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){let t=new a.T;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{let t=new a.T;this.canonicToWorldTransformation(t);let i=t.clone();i.invertPreciseThis(),i.scale(e,e),i.multiply(t),this.applyTransformation(i)}}constructEnclosingCircle(t,e,i=!1){return function(t,e,i,r){0===i&&(0,s.t)("construct_enclosing_circle");let o=[0,0,0],a=function(t,e,i,s){let r=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&u(t,e)}(e,r),function(t,e,i,s,r){let o=0,a=[0,0,0],l=0,h=0;for(let r=0;r<3;++r){let m=!1;for(;h<i;){let i=t.at(e[h]),u=1;if(3===o?u=n.P.inCircleRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]),i):2===o?u=n.P.inCircleRobust3Point(t.at(s[0]),t.at(s[1]),i):1===o&&i.equals(t.at(s[0]))&&(u=0),u<=0){if(u<0&&r+1<3){e[l]=(0,n.b)(e[h],e[h]=e[l]);for(let t=0;t<o;t++)if(s[t]===e[h]){a[t]=h;break}l++}h++;continue}m=!0;let g=0;for(let t=0;t<o;t++)a[t]>h&&(s[g]=s[t],a[g]=a[t],g++);s[o=g]=e[h],a[o]=h,++o<3?h=l:(1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.b)(s[0],s[0]=s[2]),a[2]=(0,n.b)(a[0],a[0]=a[2])),h++)}if(!m)break;if(r+1<3){l=0;let i=!1;for(let t=0;t<o;t++)for(let e=t+1;e<o;e++)a[t]>a[e]&&(a[e]=(0,n.b)(a[t],a[t]=a[e]),s[e]=(0,n.b)(s[t],s[t]=s[e]),i=!0);for(let t=0;t<o;t++)e[a[t]]=(0,n.b)(e[t],e[t]=e[a[t]]),a[t]=t;i&&3===o&&1===n.P.orientationRobust(t.at(s[0]),t.at(s[1]),t.at(s[2]))&&(s[2]=(0,n.b)(s[0],s[0]=s[2]),a[2]=(0,n.b)(a[0],a[0]=a[2]))}h=o}return o}(t,r,e,i)}(e,i,o);if(1===a)t.constructCircleRadius(0,e[o[0]],r);else if(2===a){let i=n.P.lerp(e[o[0]],e[o[1]],.5),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i);t.constructCircleRadius(Math.max(s,a),i,r)}else if(3===a){let i=n.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),s=n.P.distance(e[o[0]],i),a=n.P.distance(e[o[1]],i),l=n.P.distance(e[o[2]],i);t.constructCircleRadius(Math.max(s,a,l),i,r)}else(0,s.c)("unexpected")}(this,t,e,i),this}constructThreePointCircle(t,e,i,s=!1){if(t.equals(e)||e.equals(i)||t.equals(i)){let r=t.clone(),n=e.clone(),o=i.clone();return r.equals(n)&&n.assign(o),this.constructTwoPointCircle(r,n,s)}{let r=n.P.calculateCircleCenterFromThreePoints(t,e,i);if(!r.isFinite()||!Number.isFinite(n.P.distance(t,r))){let s=n.P.distance(t,e),r=n.P.distance(t,i);this.constructLineCircularArc(t,s>=r?e:i)}return this.constructCircleCenterAndPoint(r,t,s)}}constructCircularArcThreePoint(t,e,i){let s=new n.F(t.x),r=new n.F(e.x),o=new n.F(i.x),a=new n.F(t.y),l=new n.F(e.y),h=new n.F(i.y),m=new n.F(.5),u=r.subE(s),g=l.subE(a),c=o.subE(s),d=h.subE(a),_=u.mulE(d).subThisE(g.mulE(c));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!g.isZero())return sM(this,t,e,0),this;{let s=t.clone().addThis(e).mulThis(.5).addThis(i).mulThis(.5),r=i.sub(s).length();this.constructEllipticArcEndPointsCenter(t,e,r,1,0,!0,!1,s),this.m_interior.assign(i)}return this.setProjectionBehavior(0),this}let p=u.sqr().addThisE(g.sqr()).mulThisE(m),f=c.sqr().addThisE(d.sqr()).mulThisE(m),P=p.mulE(d).subThisE(f.mulE(g)),y=u.mulE(f).subThisE(c.mulE(p));P.divThisE(_),y.divThisE(_);let x=P.sqr().addThisE(y.sqr());x.sqrtThis();let v=P.addE(s),C=y.addE(a),b=t.x-v.value(),E=t.y-C.value(),S=Math.atan2(E,b);b=e.x-v.value();let D=Math.atan2(E=e.y-C.value(),b);b=i.x-v.value();let w=Math.atan2(E=i.y-C.value(),b),A=w-2*(0,n.a5)();for(;A<S;)A+=2*(0,n.a5)();let T=D-2*(0,n.a5)();for(;T<A;)T+=2*(0,n.a5)();let I=w+2*(0,n.a5)();for(;I>S;)I-=2*(0,n.a5)();let M,Y=D+2*(0,n.a5)();for(;Y>I;)Y-=2*(0,n.a5)();M=T-S<S-Y?T-S:Y-S;
1let X=new n.P(v.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,x.value(),1,0,Math.abs(M)>(0,n.a5)(),M>0,X),this.m_interior.assign(i),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,i,s){return this.constructEllipticArcGeneral(t,1,e,i,s,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,i,s,r,n,o){return sI(this,t,e,i,s,r,n,o)}constructEllipticArcEndPointsCenter(t,e,i,s,r,n,o,a){return sI(this,t,e,i,s,r,n,o,a)}constructEllipticArcGeneral(t,e,i,s,r,o){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);let a=so(o),l=Math.cos(a),h=Math.sin(a),m=new n.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=n.P.getNAN(),g=so(s);u.x=m.x*Math.cos(g),u.y=m.y*Math.sin(g),u.rotateDirect(l,h),u.addThis(i);let c=(0,n.ag)(r,(0,n.a8)()),d=c;Math.abs(d)===(0,n.a8)()&&(d=0);let _=n.P.getNAN();return _.x=m.x*Math.cos(g+d),_.y=m.y*Math.sin(g+d),_.rotateDirect(l,h),_.addThis(i),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(c)>(0,n.a5)(),c>0,i)}constructEllipticArcAsNURB(t,e,i,r){return(r>=1||r<0)&&(0,s.t)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,s.t)("construct_elliptic_arc_as_NURB: control_point"),sH([t,e,i],r*r,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,sQ(this),this.afterCompletedModification(),t!==this&&V(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!E(this,[t])&&sY(this)}isDegenerateToLine(){return sY(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){let e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return n.P.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!sz(this)}isMajor(){return sk(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return s.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.J.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=sl.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}else 2===t.m_EnvelopeType?s1(this,n.E.unit(),t):(0,s.b)("3d not impl")}applyTransformation(t){sF(this,t,!1)}createInstance(){return new sh}calculateLength2D(){var t=this,e=0,i=1;if(sY(t))return+n.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-i))*t.m_semiMajorAxis;let s=sX(t,e);return sX(t,i)-s}queryCoord2D(t,e){if(sY(this)){var i,s;i=this.getStartXY(),s=this.getEndXY(),(0,n.Z)(i,s,t,e)}else if(0===t)e.assign(n.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(n.P.construct(this.m_XEnd,this.m_YEnd));else{let i=sS(this,t),s=new n.P(this.m_semiMajorAxis*Math.cos(i),this.getSemiMinorAxis()*Math.sin(i));s.rotateDirect(this.m_cosr,this.m_sinr),s.addThis(this.m_center),e.assign(s)}}
1queryCoord2DE(t,e){!function(t,e,i){if(sY(t))K(new rP({start:t.getStartXY(),end:t.getEndXY()}),e,i);else if(0===e.value())i.set(t.getStartXY());else if(1===e.value())i.set(t.getEndXY());else{let s=new n.F;sD(t,e,s);let r=new n.F,o=new n.F;n.F.st_cosAndSin(s,r,o);let a=y.constructCoordsE(new n.F(t.m_semiMajorAxis).mulThisE(r),new n.F(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),l=new n.F(t.m_rotation);n.F.st_cosAndSin(l,r,o),a.rotateDirect(r,o),a.addThisE(y.constructPoint2D(t.m_center)),i.setE(a)}}(this,t,e)}getCoordX(t){let e=new n.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){let e=new n.P;return this.queryCoord2D(t,e),e.y}cut(t,e,i){let s=new ry;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createEllipticArc(),o=0===t&&1===e;if(o&&!s)return void this.copyTo(r);let a=n.P.getNAN();this.queryCoord2D(t,a);let l=n.P.getNAN();if(this.queryCoord2D(e,l),!o){if(a.equals(l))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&l.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),(o=0===t&&1===e)&&!s)return void this.copyTo(r)}if(r.m_center.assign(this.m_center),r.m_semiMajorAxis=this.m_semiMajorAxis,r.m_minorMajorRatio=this.m_minorMajorRatio,r.m_interior.assign(this.m_interior),r.m_rotation=this.m_rotation,r.m_cosr=this.m_cosr,r.m_sinr=this.m_sinr,r.m_sweepAngle=this.m_sweepAngle,r.m_startAngle=this.m_startAngle,r.m_bits=this.m_bits,A(r,a.x,a.y),I(r,l.x,l.y),o)return void sV(r,sw(this));r.m_startAngle=sS(this,t),r.m_sweepAngle=sS(this,e)-r.m_startAngle,r.m_startAngle=sx(r.m_startAngle),sG(r,Math.abs(r.m_sweepAngle)>(0,n.a5)()),r.assignVertexDescription(this.m_description),sQ(r),sb(r);let h=this.m_description.getAttributeCount();if(h>1){for(let e=1;e<h;e++){let i=this.m_description.getSemantics(e),s=sl.getComponentCount(i);for(let e=0;e<s;e++){let s=this.getAttributeAsDbl(t,i,e);r.setStartAttribute(i,e,s)}}for(let t=1;t<h;t++){let i=this.m_description.getSemantics(t),s=sl.getComponentCount(i);for(let t=0;t<s;t++){let s=this.getAttributeAsDbl(e,i,t);r.setEndAttribute(i,t,s)}}}r.afterCompletedModification()}queryDerivative(t,e){!function(t,e,i){if(sY(t))i.setE(y.constructPoint2D(t.getEndXY()).subE(y.constructPoint2D(t.getStartXY())));else{let s=new n.F;sD(t,e,s);let r=new y;if(r.setCoordsE(new n.F(t.m_semiMajorAxis).negate().mulE((new n.F).setSin(s)),new n.F(t.getSemiMinorAxis()).mulE((new n.F).setCos(s))),t.m_rotation){let e=new n.F(t.m_rotation);r.rotateDirect((new n.F).setCos(e),(new n.F).setSin(e))}r.scaleThis(new n.F(t.getSweepAngle())),i.setE(r)}}(this,t,e)}cutArcIgnoreAttributes(t,e,i){let s=0===t&&1===e,r=new n.P;this.queryCoord2D(t,r);let o=new n.P;this.queryCoord2D(e,o),s||(r.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(s=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&r.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),s=0===t&&1===e)),i.m_center.assign(this.m_center),i.m_semiMajorAxis=this.m_semiMajorAxis,i.m_minorMajorRatio=this.m_minorMajorRatio,i.m_interior.assign(this.m_interior),i.m_rotation=this.m_rotation,i.m_cosr=this.m_cosr,i.m_sinr=this.m_sinr,i.m_sweepAngle=this.m_sweepAngle,i.m_startAngle=this.m_startAngle,i.m_bits=this.m_bits,A(i,r.x,r.y),I(i,o.x,o.y),s?sV(i,sw(this)):(i.m_startAngle=sS(this,t),i.m_sweepAngle=sS(this,e)-i.m_startAngle,i.m_startAngle=sx(i.m_startAngle),sG(i,Math.abs(i.m_sweepAngle)>Math.PI),sQ(i),i.afterCompletedModification())}changeEndPoints2D(t,e){sT(this,t,e,!1)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,i);if(1===t)return this.getEndAttributeAsDbl(e,i);let s=this.calculateLength2D(),r=s>0?this.tToLength(t)/s:0,o=sl.getInterpolation(e),a=this.getStartAttributeAsDbl(e,i),l=this.getEndAttributeAsDbl(e,i);return(0,n.T)(o,a,l,r,sl.getDefaultValue(e))}getClosestCoordinate(t,e){return s2(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,i=-1){return s2(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,s.t)("");let i=this.getSemiAxes(),r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),o=r+(0,n.a5)(),a=(0,n.d)(3,NaN),l=0;if(a[0]=sE(this,r),a[0]>0&&a[0]<1&&l++,a[1]=sE(this,o),a[1]>
10&&a[1]<1&&(a[l]=a[1],l++),0===l)return 0;a[l]=1,l++,(0,s.g)(t.length>=l);let h=0;for(let i=0;i<l;i++){let s=a[i];this.queryCut(h,s,t[i],e),h=s}return l}getMonotonicParts(t,e){if(t.length<4&&(0,s.t)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;let i=this.getSemiAxes(),r=(0,n.d)(4,NaN);r[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r[1]=r[0]+(0,n.a5)(),r[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),r[3]=r[2]+(0,n.a5)();let o=(0,n.d)(5,NaN),a=0;for(let t=0;t<4;t++)o[a]=sE(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,n.U)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,s.g)(t.length>=a);let l=0;for(let i=0;i<a;i++){let s=o[i];this.queryCut(l,s,t[i],e),l=s}return a}intersectionWithAxis2D(t,e,i,s){let r,o;if(sY(this))return new rP({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,i,s);let a=new n.F(e),l=this.getSemiAxes();if(t){if(e>this.m_center.y+l.x||e<this.m_center.y-l.x)return 0;r=new n.F(l.x).mulThis(this.m_sinr),o=new n.F(l.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+l.x||e<this.m_center.x-l.x)return 0;r=new n.F(l.x).mulThis(this.m_cosr),o=new n.F(l.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}let h=r.sqr(),m=o.sqr(),u=h.addE(m),g=o.mulE(a).mulThis(-2),c=a.sqr().subThisE(h),d=g.sqr().subThisE(u.mulE(c).mulThis(4)),_=r.mulE(a).mulThis(-2),p=a.sqr().subThisE(m),f=_.sqr().subThisE(u.mulE(p).mulThis(4)),P=d.eps()*Math.abs(f.value())<=f.eps()*Math.abs(d.value());P?r.isZero()&&(P=!1):o.isZero()&&(P=!0),P||(g.setE(_),c.setE(p));let y=(0,n.m)(n.F,2),x=tv(u,g,c,n.E.construct(-1,1),!1,y);if(0===x)return 0;let v=[0,0],C=0;for(let t=0;t<x;t++){let e=new n.F,i=new n.F;P?(e.setE(y[t]),i.setE(a.subE(o.mulE(y[t])).divThisE(r))):(i.setE(y[t]),e.setE(a.subE(r.mulE(y[t])).divThisE(o)));let s=sE(this,Math.atan2(e.value(),i.value()));s>=0&&s<=1&&(v[C]=s,C++)}return 0===(x=C)?0:(2===x&&v[0]>v[1]&&(v[1]=(0,n.b)(v[0],v[0]=v[1])),s&&(0,n.a)(s,v,0,0,x),i&&(i[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),x>1&&(i[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!s&&i[0]>i[1]&&(i[1]=(0,n.b)(i[0],i[0]=i[1])))),x)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;let i=[0,0];return -1===this.intersectionWithAxis2D(!0,t,i,null)?e:i[0]}isCurve(){return!0}isDegenerate(t){return b(this,t)}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new n.E(0,1),t):(0,s.b)("3d not impl")}clone(t){let e=new sh;return this.copyTo(e),e}queryInterval(t,e){if(0===t){let t;if(sY(this))return 0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY());let i=this.getSemiAxes(),s=(t=0===e?Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr):Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr))+Math.PI,r=[0,0];r[0]=sE(this,t),r[1]=sE(this,s);let o=0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY()),a=new n.P;for(let t=0;t<2;t++){let i=r[t];i>0&&i<1&&(this.queryCoord2D(i,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){let i=new n.E(0,1);if(i.intersect(t),i.isEmpty())return void e.setEmpty();if(sY(this))return e.setCoords(this.getCoord2D(i.vmin)),void e.mergeNe(this.getCoord2D(i.vmax));let s=this.getCoord2D(i.vmin),r=this.getCoord2D(i.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*i.width()<=n.l){let t=n.P.lerp(s,r,.5),i=t.sub(this.m_center);return i.normalize(),t=t.add(i.mul(.5*n.P.distance(s,r))),e.setCoords(s),e.mergeNe(r),void e.mergeNe(t)}s1(this,i,e)}tToLength(t){return sY(this)?t*n.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:sX(this,t)}parametricAngleToT(t){return sE(this,t)}tToParametricAngle(t){return sS(this,t)}lengthToT(t){if(sY(this)){let e=n.P.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){let e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return function(t,e){if(sY(t)){let i=n.P.distance(t.getStartXY(),t.getEndXY());return 0===i?0:e/i}if(1===t.m_minorMajorRatio){let i=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===i?0:e/i}if(0===e)return 0;let i=t.getSweepAngle();if(0===i)return .5;let s=sA(t),r=(0,n.a7)(),o=sq(t);i<0&&(e=-e);let a=e/t.m_semiMajorAxis+o,l=(0,n.aa)(a,s.e2,s.completeE);return l-=r,(l-=t.getStartAngle())/i}(this,t)}calculateWeightedAreaCentroid2D(t){if(sY(this)){let t=new n.P;return t.setCoords(0,0),t}let e=sJ(this),i=this.getStartXY().sub(this.m_center),s=this.getEndXY().sub(this.m_center),r=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,l=new n.P;l.x=r*o*(r*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,l.y=r*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+r*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;let h=s.add(i).mul(s.crossProduct(i)/6);return l.x-=h.x,l.y-=h.y,l.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){let t=new n.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(sY(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,i=this.m_startAngle+this.m_sweepAngle;if(i<e){let t=e;e=i,i=t}let s=Math.sin(e),r=Math.sin(i),o=Math.cos(e),a=Math.cos(i);if(1===this.m_minorMajorRatio){let e=this.getSemiMajorAxis(),i=e*e;t.setCoords(i*(r-s),i*(o-a))}else{let e=this.getSemiMajorAxis(),i=this.getSemiMinorAxis(),n=e*e,l=i*i,h=e*i,m=n-l,u=m/l,g=m/n,c=Math.sqrt(u),d=Math.sqrt(g),_=.5*h*(Math.asinh(c*r)/c+r*Math.sqrt(1+u*r*r))-.5*h*(Math.asinh(c*s)/c+s*Math.sqrt(1+u*s*s)),p=-.5*h*(Math.asin(d*a)/d+a*Math.sqrt(1-g*a*a))- -.5*h*(Math.asin(d*o)/d+o*Math.sqrt(1-g*o
1*o));t.setCoords(_,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,i){if(i&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!sY(this)){let i=n.P.distance(t,this.m_center),s=this.getSemiAxes();if(i<s.x-e||i>s.y+e)return!1}let s=this.getClosestCoordinate(t,!1),r=new n.P;return this.queryCoord2D(s,r),n.P.distance(r,t)<=e}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getTangent(t){if(sY(this))return this.getEndXY().sub(this.getStartXY());{let e=sS(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}getDerivative(t){if(sY(this))return this.getEndXY().sub(this.getStartXY());{let e=sS(this,t),i=new n.P;return i.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&i.rotateDirect(this.m_cosr,this.m_sinr),i.scale(this.getSweepAngle()),i}}normalizeAfterEndpointChange(){return!!sB(this)&&(sY(this)?(sW(this),!1):sj(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){let e=new n.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){let e=new n.P(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}getCurvature(t){let e=sS(this,t),i=new n.P,s=this.getSemiMinorAxis();i.setCoords(-this.m_semiMajorAxis*Math.sin(e),s*Math.cos(e));let r=new n.P;r.setCoords(-this.m_semiMajorAxis*Math.cos(e),-s*Math.sin(e)),this.m_rotation&&(i.rotateDirect(this.m_cosr,this.m_sinr),r.rotateDirect(this.m_cosr,this.m_sinr));let o=i.sqrLength();if(0===o)return NaN;let a=Math.sqrt(o);return i.divThis(a),i.crossProduct(r)/o}getMonotonicPartParams(t,e){let i=(0,n.d)(6,NaN);i[0]=0;let r=1;if(this.isDegenerateToLine())i[1]=1,r=2;else{let t=this.getSemiAxes(),e=(0,n.d)(4,NaN);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=(0,n.a6)());for(let t=0;t<4;t++){let s=sE(this,e[t]);s>0&&s<1&&(i[r]=s,r++)}r>2&&(0,n.U)(i,r),i[r]=1,r++}if(e){t<r&&(0,s.t)("");for(let t=0;t<r;t++)e[t]=i[t]}return r}calculateLowerLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());return this.isDegenerateToLine()?t:Math.max(Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis(),t)}calculateUpperLength2D(){let t=n.P.distance(this.getStartXY(),this.getEndXY());return this.isDegenerateToLine()?t:Math.max(Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis(),t)}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return sY(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,sL(t)}calculateArea2DHelper(){return sJ(this)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),sY(this))return;let i=this.getSemiAxes(),s=(0,n.d)(8,NaN);{let t=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),e=t+Math.PI,r=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),n=r+Math.PI;s[0]=sE(this,t),s[1]=sE(this,e),s[2]=sE(this,r),s[3]=sE(this,n)}{let t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,r=Math.atan2(-i.y*t,i.x*e),n=r+Math.PI,o=Math.atan2(i.y*e,i.x*t),a=o+Math.PI;s[4]=sE(this,r),s[5]=sE(this,n),s[6]=sE(this,o),s[7]=sE(this,a)}let r=n.P.getNAN();for(let i=0;i<8;i++){let n=s[i];
1t.containsExclusiveCoordinate(n)&&(this.queryCoord2D(n,r),e.mergeNe(r))}}setSegmentFromCoords(t,e){!function(t,e,i){let s=0===t.projectionBehavior();if(i<=2)return sM(t,e[0],e[i-1],+!s);if(s){t.constructCircularArcThreePoint(e[0],e[i-1],e[Math.trunc(i/2)]);let s=new n.P;return t.queryCoord2D(.5,s),t.m_interior.setCoordsPoint2D(s)}let r=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),l=t.getCenter(),h=[,,,,];h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];let m=[,,,,];m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];let u=Math.trunc(i<5?1:(i+4)/5),g=(0,n.m)(sh,4),c=(0,n.d)(4,NaN),d=0;for(let t=0;t<4;t++){g[t].constructEllipticArcEndPointsCenter(e[0],e[i-1],r,o,a,h[t],m[t],l),c[t]=0;let s=0;for(let r=u;r<i-1;r+=u){let i=g[t].getClosestCoordinate(e[r],!1);c[t]+=n.P.sqrDistance(g[t].getCoord2D(i),e[r]),s++}c[t]/=s,c[t]<c[d]&&(d=t)}t.assignCopy(g[d])}(this,t,e)}writeInBufferStream(t,e){let i=new Float64Array(10);return i[0]=this.m_bits,i[1]=this.m_semiMajorAxis,i[2]=this.m_minorMajorRatio,i[3]=this.m_rotation,i[4]=this.m_center.x,i[5]=this.m_center.y,i[6]=this.m_sweepAngle,i[7]=this.m_startAngle,i[8]=this.m_interior.x,i[9]=this.m_interior.y,t.writeRangeFromArray(e,i.length,i,!0,1),e+i.length}readFromBufferStream(t,e){let i=new Float64Array(10);t.queryRange(e,i.length,i,!0,1),this.m_bits=i[0],this.m_semiMajorAxis=i[1],this.m_minorMajorRatio=i[2],this.m_rotation=i[3],this.m_center.x=i[4],this.m_center.y=i[5],this.m_sweepAngle=i[6],this.m_startAngle=i[7],this.m_interior.x=i[8],this.m_interior.y=i[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,s.c)("should not1; be called"),0}ensureXYMonotone(){if(sY(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return sM(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;let t=(0,n.m)(n.P,3),e=sZ(this,t);if(ey(t)){let i=!1;if(0===this.projectionBehavior()){let s=new o.J;s.setCoords({pt:t[0]}),s.mergeNe(t[2]);let r=new n.P;r.setSub(t[2],t[0]),r.leftPerpendicularThis(),r.normalize(),r.scale(n.P.distance(t[2],t[0]));let a=n.P.lerp(t[2],t[0],.5),l=a.sub(r),h=a.add(r);s.clipLine(l,h);let m=n.P.getClosestCoordinate(l,h,t[1],!1);t[1]=n.P.lerp(l,h,m);let u=t[2].sub(t[1]),g=t[0].sub(t[1]),c=u.crossProduct(g),d=u.dotProduct(g);e=(0,n.a7)()-Math.abs(.5*Math.atan2(c,d)),i=!0}return sH(t,e*e,null,i,this),!0}return!1}setCoordsForIntersector(t,e,i){sT(this,t,e,i)}getInteriorPoint(){return this.m_interior.clone()}copyToImpl(t){t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,sV(t,sw(this))}reverseImpl(){sR(this,!sz(this)),sb(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&sQ(this)}equalsImpl(t){if(this.m_bits!==t.m_bits||this.m_semiMajorAxis!==t.m_semiMajorAxis||this.m_minorMajorRatio!==t.m_minorMajorRatio||!(this.m_center.isEqualPoint2D(t.m_center)||this.m_center.isNAN()&&t.m_center.isNAN())||this.m_rotation!==t.m_rotation||!this.m_interior.equals(t.m_interior))return!1;let e=t.m_sweepAngle;if(this.m_sweepAngle!==e)return!1;let i=t.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){if(this.m_bits!==t.m_bits)return!1;if(this.m_center.isNAN()&&t.m_center.isNAN())return!0;if(this.m_center.isNAN()!==t.m_center.isNAN()||!this.getSemiAxes().isEqualPoint2D(t.getSemiAxes(),e)||!this.m_center.isEqualPoint2D(t.m_center,e))return!1;let i=Math.abs(si((this.m_rotation-t.m_rotation)*se)*st),s=Math.abs((0,n.a5)()-i),r=Math.min(i,s);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;let o=this.getCoord2D(.5),a=t.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}swapImpl(t){var e,i;this.m_center=(0,n.b)(t.m_center,t.m_center=this.m_center),this.m_semiMajorAxis=(0,n.b)(t.m_semiMajorAxis,t.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,n.b)(t.m_minorMajorRatio,t.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,n.b)(t.m_interior,t.m_interior=this.m_interior),this.m_rotation=(0,n.b)(t.m_rotation,t.m_rotation=this.m_rotation),this.m_cosr=(0,n.b)(t.m_cosr,t.m_cosr=this.m_cosr),this.m_sinr=(0,n.b)(t.m_sinr,t.m_sinr=this.m_sinr),this.m_sweepAngle=(0,n.b)(t.m_sweepAngle,t.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,n.b)(t.m_startAngle,t.m_startAngle=this.m_startAngle),this.m_bits=(0,n.b)(t.m_bits,t.m_bits=this.m_bits),e=this,(i=t).m_cachedValues=(0,n.b)(e.m_cachedValues,e.m_cachedValues=i.m_cachedValues)}afterCompletedModification(){sW(this),sL(this)}intersect(t,e,i,s,r){return rg(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){if(e.length<2&&(0,s.n)(""),sY(this))return new rP({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,i);{let e=n.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+i||e<this.getSemiMinorAxis()-i)return 0}let r=this.getClosestCoordinate(t,!1),o=n.P.getNAN();return this.queryCoord2D(r,o),n.P.distance(o,t)<=i?(0,n.J)(r,0,1)&&(this.queryCoord2D(+(0===r),o),n.P.distance(o,t)<=i)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==rl(!1,this,t,e,i)}endPointModified(){this.m_bits|=8,sL(this)}clearEndPointModified(){sW(this)}}sh.type=s.G.enumEllipticArc;class sm extends i4{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=ry):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=ry,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ry):t.envelope?(0,s.b)("envelope constructor not impl"):(0,s.c)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=ry)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return i7(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return sm.type}getDimension(){return 2}createInstance(){return new sm({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function su(t,e,i,s,r,o){return new sc(0,0,0,null,!1,(0,n.i)()).densifyEx(t,e,i,s,!1,o)}function sg(t,e,i,r,o,a,l,h,m){let u,g=t.getGeometryType();if(a&&(a.length=0,l.length=0),h&&(h.length=0),g===s.G.enumEllipticArc&&(t.isDegenerateToLine()||t.isDegenerate(0)))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(t.getEndXY()),l.push(NaN),l.push(NaN),l.push(NaN)),h&&(h.push(0),h.push(1)),1;let c=(0,n.d)(9,NaN);if(o)u=t.getMonotonicPartParams(c.length,c),c.length=u,u=sd(t,i,c);else{if(u=2,c[0]=0,c[1]=1,g===sh.type){let e=t.getSweepAngle();e>.9*Math.PI&&(Math.min(3,Math.trunc(e/(2*Math.PI/3)+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,u=4):(c[0]=0,c[1]=.5,c[2]=1,u=3))}else(0,s.g)(g===tY.type);c.length=u}if(2===u&&r&&(c[1]=.5,c.push(1),u=3),a){let e=new ry,i=1;for(;i<u;){let r=c[i-1],h=c[i];t.queryCut(r,h,e,!0);let m=(0,n.m)(n.P,3),d=[1,1,1];if(g===s.G.enumEllipticArc){let t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){let t=(h-r)/3;c.splice(i,0,r+t),c.splice(i+1,0,r+2*t),u+=2;continue}d[1]=sZ(t,m)}else{let t=e.get();t.queryControlPoints(m),t.queryWeights(d)}o&&ey(m),1===i&&(a.push(m[0].clone()),l.push(d[0])),a.push(m[1].clone()),a.push(m[2].clone()),l.push(d[1]),l.push(d[2]),i++}}return h&&(h.length=u,(0,n.a)(h,c,0,0,u)),u-1}sm.type=s.G.enumPolygon;class sc{static constructDefault(t){return new sc(0,0,0,t,!1,(0,n.i)())}constructor(t,e,i,o,a,l){this.m_segmentBuffer=null,this.m_dummyPoint=new r.P,this.m_progressCounter=0,this.m_progressTracker=o,this.m_bSetDensifyFlag=a,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=i>(0,n.a7)()?(0,n.a7)():i,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=l,(0,s.w)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,i,r,o,a){return this.m_maxLength=e,this.m_maxDeviation=i,this.m_maxAngle=r>(0,n.a7)()?(0,n.a7)():r,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,s.w)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||1>t.getDimension())return t;let e=t.getGeometryType();return(0,s.o)(e)?t:(0,s.h)(e)?this.densifyMultiPath(t):(0,s.f)(e)?this.densifySegmentImpl(t):e===s.G.enumEnvelope?this.densifyEnvelope(t):void(0,s.c)("")}densifySegmentEx(t,e,i,r,n){let o=t.getGeometryType();if(!(this.m_maxLength>
10||this.m_bOnlyCurveDensify&&o!==s.G.enumLine)&&(!r||i))return void(e?o===s.G.enumLine?e.addSegment(t,i):(i&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(i&&n.push(0),n.push(1)));if(o===s.G.enumBezier)return void this.densifyCubicBezier(t,e,i,r,n);if(o===s.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,i,r,n);if(o===s.G.enumBezier2)return void this.densifyBezier2(t,e,i,r,n);if(o===s.G.enumEllipticArc&&!t.isLine()&&.25>t.getMinorMajorRatio())return void this.densifyEllipticArc(t,e,i,r,n);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,i,r,n)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=t.getImpl().querySegmentIterator();for(;i.nextPath();){let t=!0;for(;i.hasNextSegment();){let s=i.nextSegment(),r=i.isClosingSegment();this.densifySegmentEx(s,e,t,r,null),r&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){let e=new i6({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){let e=new sm({vd:t.getDescription()});e.addEnvelope(t,!1);let i=o.J.constructEmpty();t.queryEnvelope(i);let s=i.width(),r=i.height();return!(this.m_maxLength>0)||s<=this.m_maxLength&&r<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;let e=t.createInstance();e.getGeometryType()===s.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());let i=e.getImpl(),r=t.getImpl(),o=r.getAttributeStreamRef(0),a=new rP;for(let t=0,s=r.getPathCount();t<s;t++){let s=r.isClosedPath(t);if(0===r.getPathSize(t))continue;let l=r.getPathStart(t),h=o.readPoint2D(2*l),m=h.clone();i.startPath(h);for(let s=l+1,h=r.getPathEnd(t);s<h;s++){let t=o.readPoint2D(2*s),r=n.P.distance(m,t);if(r>this.m_maxLength){let e,s,o,l=Math.ceil(r/this.m_maxLength);l>(0,n.i)()&&(l=(0,n.i)());let h=1/l;0>m.compare(t)?(a.setStartXY(m),a.setEndXY(t),e=0,s=1):(a.setStartXY(t),a.setEndXY(m),e=l-2,s=-1);for(let t=0,r=l-1;t<r;t++,e+=s){this.progress_(),o=h*(e+1);let t=new n.P;a.queryCoord2D(o,t),i.lineTo(t),this.m_bSetDensifyFlag&&i.setAttribute(10,i.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),m.assign(t)}if(s){let t=n.P.distance(m,h);if(t>this.m_maxLength){let e,s,r,o=Math.ceil(t/this.m_maxLength);o>(0,n.i)()&&(o=(0,n.i)());let l=1/o;0>m.compare(h)?(a.setStartXY(m),a.setEndXY(h),e=0,s=1):(a.setStartXY(h),a.setEndXY(m),e=o-2,s=-1);let u=new n.P(0,0);for(let t=0,n=o-1;t<n;t++,e+=s)this.progress_(),r=l*(e+1),a.queryCoord2D(r,u),i.lineTo(u),this.m_bSetDensifyFlag&&i.setAttribute(10,i.getPointCount()-1,0,1)}i.closePathWithLine()}}return e}densifySegmentByLength(t,e,i,r,o,a){(0,s.g)(t.getGeometryType()!==s.G.enumBezier);let l=t.getStartXY().compare(t.getEndXY());0===l&&e<1&&(t.getGeometryType()===s.G.enumEllipticArc?l=0>t.getSweepAngle()?1:-1:(0,s.b)("densify segment by length"));let h=0;if(r&&(i?(t.queryStart(this.m_dummyPoint),i.startPathPoint(this.m_dummyPoint)):a.push(0),++h),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new ry);let s=Math.ceil(1/e);s>(0,n.i)()&&(s=(0,n.i)()),e=1/s,this.m_segmentBuffer.create(t.getGeometryType());let r,o,m,u=t;l<0?(r=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),r=s-2,o=-1,u=this.m_segmentBuffer.get());let g=s-1;for(let t=0;t<g;t++,r+=o)m=e*(r+1),i?(u.queryCoord(m,this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&i.setAttribute(10,i.getPointCount()-1,0,1)):a.push(l>0?1-m:m),this.progress_();m=1,h+=g}(!o||o&&r&&h<2)&&(i?(t.queryEnd(this.m_dummyPoint),i.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,i,s,r){let o=new im,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());if(0===h&&l>0){let e=(0,n.m)(n.P,4);t.queryControlPoints(e),0===(h=e[1].compare(e[2]))&&(h=e[1].compare(e[0]))}h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=[],g=[],c=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),d=!0,_=0;if(h>
10)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),g.push(0);u.length;){this.progress_();let t=u.at(-1),o=g.at(-1),l=t[4].x,h=t[4].y;if(o<c&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),c=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=c.mul(1-i).add(p.mul(i)),P=t[3];t[1]=s,t[2]=c,t[3]=f,t[4].setCoords(l,e);let y=[f,p,m,P,new n.P(e,h)];u.push(y),g[g.length-1]=o+1,g.push(o+1)}else u.pop(),g.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.queryCoord(l,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==l&&0!==l&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(1-l),++m)}else for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),g.push(0);u.length;){this.progress_();let t=u.at(-1),o=g.at(-1),l=t[4].x,h=t[4].y;if(o<c&&this.bezierNeedsSplit(t)){d&&(_=a.findMinDeriv(),d=!1);let e=.5*(l+h);Math.abs(_-e)<.4*(h-l)&&(e=_);let i=(e-l)/(h-l),s=t[0].mul(1-i).add(t[1].mul(i)),r=t[1].mul(1-i).add(t[2].mul(i)),m=t[2].mul(1-i).add(t[3].mul(i)),c=s.mul(1-i).add(r.mul(i)),p=r.mul(1-i).add(m.mul(i)),f=c.mul(1-i).add(p.mul(i)),P=t[0];t[0]=f,t[1]=p,t[2]=m,t[4].setCoords(e,h);let y=[P,s,c,f,new n.P(l,e)];u.push(y),g[g.length-1]=o+1,g.push(o+1)}else u.pop(),g.pop(),(u.length>0||!s||s&&i&&m<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h),++m)}}densifyRationalBezier2(t,e,i,s,r){let o=new tY,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),g=new tY,c=[],d=[];for(c.push(new n.E(0,1)),d.push(0);c.length;){this.progress_();let t=c.at(-1).clone(),o=d.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,g,t.vmin,t.vmax)){let e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new n.E(e,t.vmax))):(c.at(-1).vmin=e,c.push(new n.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1)}else if(c.pop(),d.pop(),c.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyBezier2(t,e,i,s,r){let o=new tI,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=0),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),g=new tI,c=[],d=[];for(c.push(new n.E(0,1)),d.push(0);c.length;){this.progress_();let t=c.at(-1).clone(),o=d.at(-1);if(o<u&&this.bezier2NeedsSplit(a,g,t.vmin,t.vmax)){let e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new n.E(e,t.vmax))):(c.at(-1).vmin=e,c.push(new n.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1)}else if(c.pop(),d.pop(),c.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}densifyEllipticArc(t,e,i,s,r){let o=new sh,a=t,l=t.calculateUpperLength2D(),h=t.getStartXY().compare(t.getEndXY());0===h&&l>0&&(h=+!t.isClockwise()),h>0&&(t.copyTo(o),o.reverse(),a=o);let m=0;i&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++m);let u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),g=new sh,c=[],d=[];for(c.push(new n.E(0,1)),d.push(0);c.length;){this.progress_();let t=c.at(-1).clone(),o=d.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,g,t.vmin,t.vmax)){let e=t.getCenter();h>0?(c.at(-1).vmax=e,c.push(new n.E(e,t.vmax))):(c.at(-1).vmin=e,c.push(new n.E(t.vmin,e))),d[d.length-1]=o+1,d.push(o+1)}else if(c.pop(),d.pop(),c.length>0||!s||s&&i&&m<2){let i=h>0?t.vmin:t.vmax;e?(a.queryCoord(i,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==i&&0!==i&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(h>0?1-i:i),++m}}}calculateLengthSubdivisionStep(t,e){let i=t.calculateUpperLength2D();if(!t.isCurve())return i?e/i:1;
1if(t.getGeometryType()===s.G.enumEllipticArc){if(t.isCircular()||t.isDegenerate(0)||t.isDegenerateToLine()){let t=e/i;return t<this.m_minStep&&(t=this.m_minStep),t}return e/i*t.getSemiAxes().y/t.getSemiAxes().x}t.getGeometryType()===s.G.enumBezier&&(0,s.b)(""),(0,s.b)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===s.G.enumEllipticArc){if(t.isDegenerate(0)||t.isDegenerateToLine())return 1;{let i=t.getSemiMajorAxis(),s=Math.PI/2;1-e/i>0&&(s=Math.min(Math.PI/2,Math.abs(4*Math.sqrt(e/i*.5))));let r=(s=Math.max(s,2*Math.PI/this.m_maxSegmentsPerCurve))*i;return this.calculateLengthSubdivisionStep(t,r)}}(0,s.b)("")}calculateAngularSubdivisionStep(t,e){return t.isCurve()?t.getGeometryType()===s.G.enumEllipticArc?t.isDegenerate(0)||t.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*t.getSemiMinorAxis()):void(0,s.b)(""):1}rationalBezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.m)(n.P,3);e.queryControlPoints(o);let a=[0,0,0];return e.queryWeights(a),!r&&this.m_maxDeviation>0&&(r=!sc.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!sc.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),r}bezier2NeedsSplit(t,e,i,s){t.cutBezierIgnoreAttributes(i,s,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;let o=(0,n.m)(n.P,3);return e.queryControlPoints(o),!r&&this.m_maxDeviation>0&&(r=!sc.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!sc.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),r}ellipticArcNeedsSplit(t,e,i,s){t.cutArcIgnoreAttributes(i,s,e);let r=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(r=!0,!0):(!r&&this.m_maxDeviation>0&&(r=!sc.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!sc.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),r)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&n.P.distance(t[0],t[1])+n.P.distance(t[1],t[2])+n.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!sc.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!sc.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){let i=t[3].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();if(s.leftPerpendicularThis(),s.normalize(),Math.max(Math.abs(s.dotProduct(t[0].sub(t[1]))),Math.abs(s.dotProduct(t[0].sub(t[2]))))<=e){let e=new n.P;iq(t,.5,e,!1);let s=e.sub(t[0]).dotProduct(i);return s>=0&&s<=i.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));let i=t[3].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}{let s=t[2].sub(t[1]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,i){if(0===e[1])return!1;let s=t[2].sub(t[0]);if(s.sqrLength()>0){let e=s.clone();if(e.leftPerpendicularThis(),e.normalize(),Math.abs(e.dotProduct(t[0].sub(t[1])))<=i){let e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=i*i}static checkRationalBezier2MaxAngle(t,e,i){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);let s=t[2].sub(t[0]);s.normalize();{let e=t[1].sub(t[0]),r=e.dotProduct(s);if(r<0||e.length()*i>r)return!1}return!0}static checkBezier2MaxDeviation(t,e){let i=t[2].sub(t[0]);if(i.sqrLength()>0){let s=i.clone();if(s.leftPerpendicularThis(),s.normalize(),Math.abs(s.dotProduct(t[0].sub(t[1])))<=e){let e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);let i=t[2].sub(t[0]);i.normalize();{let s=t[1].sub(t[0]),r=s.dotProduct(i);if(r<0||s.length()*e>r)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){let i=t.getEndXY().sub(t.getStartXY()),r=[0,0];
1if(1===function(t,e,i){(0,s.g)(!sY(t));let r=new a.T;r.setRotateAngle(-t.getAxisXRotation());let o=new n.P;r.queryTransform(e,o);let l=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),h=l+(0,n.a5)(),m=sE(t,l),u=sE(t,h);u<m&&(u=(0,n.b)(m,m=u));let g=0;return m>=0&&m<=1&&(i[g++]=m),u>=0&&u<=1&&(i[g++]=u),g}(t,i,r)){let i=t.getCoord2D(r[0]),s=n.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),i),o=new n.P;return(0,n.Z)(t.getStartXY(),t.getEndXY(),s,o),n.P.distance(i,o)<=e}}let i=t.getCoord2D(.5),r=new n.P;return(0,n.Z)(t.getEndXY(),t.getStartXY(),.5,r),n.P.distance(i,r)<=e}static checkEllipticArcMaxAngle(t,e){let i=t.getTangent(0),s=t.getTangent(1),r=i.dotProduct(s);return!(r<0)&&!(i.length()*s.length()*e>r)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==s.G.enumEllipticArc||t.isCircular())}}function sd(t,e,i){let s=i.length;if(e<=0||s<=2)return s;let r=0,o=(0,n.d)(s-1,NaN);for(let e=1;e<s;e++){let s=t.tToLength(i[e]);o[e-1]=s-r,r=s}for(;o.length>1;){let t=o.findIndex(t=>t<=2*e);if(-1===t)break;let s=t+1,r=t+1;if(t>0){let e=t-1;(r===o.length||o[e]>o[r])&&(r=e,s--)}o[r]+=o[t],o.splice(t,1),i.splice(s,1)}return i.length}function s_(t,e,i,s,r,l,h,m){let u=e.clone();u.dropAllAttributes();let g=(t,e,i,s)=>(e&&(t&&e.push(s.getStartXY()),e.push(n.P.getNAN()),e.push(n.P.getNAN()),e.push(s.getEndXY())),i&&(t&&i.push(0),i.push(1)),1);if(u.isDegenerateToLine()||u.isDegenerate(0))return g(t,l,h,e);let c=u.getStartXY(),d=u.getEndXY(),_=u.getSemiAxes(),p=new a.T;if(u.isCircular())p.setIdentity();else{let t=u.getAxisXRotation();p.setScaleCoords(1,u.getMinorMajorRatio()),p.rotateAngle(t)}let f=u.getCenter();p.shift(f);let P=p.clone();P.invertThis(),u.applyTransformation(P);let y=u.getSweepAngle();if(0===y)return g(t,l,h,e);let x=o.J.constructEmpty();x.setCoords({center:f,width:2*_.x,height:2*_.x});let v=.05*x.calculateToleranceFromEnvelope(),C=4*Math.pow(Math.max(i/_.x,v/_.x)/.0741,1/6);C=Math.min(C,Math.PI/2);let b=sn(u.getStartAngle()),E=y>0?Math.floor(b/C):Math.ceil(b/C);E*=C;let S=y>0?C:-C;E+S===b&&(E+=S);let D=4/3*Math.tan(Math.abs(C)/4);y>0&&(D=-D),h&&t&&h.push(0);let w=C/Math.abs(y),A=(E-b)/y,T=c.clone(),I=new n.P;u.queryCoord2D(0,I);let M=I.clone(),Y=1-.01*w,X=0,q=0;for(;A<1;){let i;(A+=w,q>0&&A<Y)?i=D:(A>=Y&&(A=1),i=4/3*Math.tan(Math.abs((A-q)*y)/4),y>0&&(i=-i)),u.queryCoord2D(A,I);let o=new n.P;p.queryTransform(I,o);let a=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(a,o),1!==A&&(n.P.distance(T,o)<=2*s||n.P.distance(o,d)<=2*s))continue;T.setCoordsPoint2D(o);let m=(0,n.m)(n.P,4);m[0].assign(M),m[3].assign(I),m[1].rightPerpendicularOther(M),m[1].scaleAddThis(i,M),m[2].leftPerpendicularOther(I),m[2].scaleAddThis(i,I),p.transformPoints2D(m,3,m),m[3].assign(o),0===q&&m[0].setCoordsPoint2D(c),1===A&&m[3].setCoordsPoint2D(d),r&&iI(m);let g=!0;for(let t=1;t<4;t++)if(!m[t].isEqualPoint2D(m[0])){g=!1;break}g||(h&&h.push(a),l&&(0===q&&t&&l.push(m[0].clone()),l.push(m[1].clone()),l.push(m[2].clone()),l.push(m[3].clone())),X++),q=A,M.setCoordsPoint2D(I)}return X}function sp(t,e,i,s,r,a,l,h){e.clone().dropAllAttributes();let m=new o.J;e.queryLooseEnvelope(m);let u=Math.max(i,.05*m.calculateToleranceFromEnvelope());l&&t&&l.push(0);let g=0,c=(0,n.m)(n.P,3);e.queryControlPoints(c);let d=[0,0,0];e.queryWeights(d);let _=[],p=(0,n.d)(9,NaN),f=0;r?(f=e.getMonotonicPartParams(p.length,p),p.length=f,f=sd(e,s,p)):(p.length=2,f=2,p[0]=0,p[1]=1);let P=0,y=t;for(let t=1;t<f;t++){let e=p[t];for(_.length=0,_.push(e),_.push(P);_.length>1;){let t=_.at(-1);_.pop();let e=_.at(-1),i=(0,n.m)(n.P,3),s=[0,0,0];ev(c,d,t,e,i,s);let r=(0,n.m)(n.P,4),o=function(t,e,i){let s=eF(e),r=[1,s,1],o=4*s/(3*(1+s));i[0].assign(t[0]),i[3].assign(t[2]),(0,n.Z)(t[0],t[1],o,i[1]),(0,n.Z)(t[2],t[1],o,i[2]),new im({cp:i}),new tY({points:t,weight:s});let a=0,l=.1,h=0;for(let e=0;e<9;e++,l+=.1){let e=new n.P;eX(t,r,l,e);let s=new n.P;iq(i,l,s);let o=n.P.sqrDistance(e,s);o>a&&(a=o,h=l)}{let e=new n.P;eX(t,r,h,e);let s=[0];iO(i,e,n.E.unit(),!1,-1,1,s);let o=new n.P;return iq(i,s[0],o),Math.sqrt(a=n.P.sqrDistance(e,o))}}(i,s,r),h=_.length>16;u>=o||h?(l.push(e),a&&(y&&(a.push(r[0]),y=!1),a.push(r[1]),a.push(r[2]),a.push(r[3])),g++):(_.push(.5*(t+e)),_.push(t))}P=e}return g}class sf{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?n.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function sP(t,e){return t.convertToCanonic(e)}function sy(t,e,i,s){let r=t.m_startAngle,o=t.m_sweepAngle;
1for(;r>(0,n.a5)();)r-=2*(0,n.a5)();for(;r<=-(0,n.a5)();)r+=2*(0,n.a5)();if(!Number.isNaN(e)){for(;e>(0,n.a5)();)e-=2*(0,n.a5)();for(;e<=-(0,n.a5)();)e+=2*(0,n.a5)();!i&&e>r&&(e-=2*(0,n.a5)()),i&&e<r&&(e+=2*(0,n.a5)()),1e-12>Math.abs(o=e-r)&&!s&&(o=i?2*(0,n.a5)():-2*(0,n.a5)()),Math.abs(o)>2*(0,n.a5)()-1e-12&&s&&(o=0)}Math.abs(o)>2*(0,n.a5)()-1e-12&&(o=o>=0?2*(0,n.a5)():-2*(0,n.a5)(),t.setEndXY(t.getStartXY())),1e-12>Math.abs(o)&&(o=0,t.setEndXY(t.getStartXY())),s=Math.abs(o)<=(0,n.a5)(),o&&(i=o>0),t.m_startAngle=sx(r),t.m_sweepAngle=o,sG(t,!s),sR(t,i)}function sx(t){let e=t,i=!1;return e<=-(0,n.a5)()?(e+=(0,n.a8)(),i=!0):e>(0,n.a5)()&&(e-=(0,n.a8)(),i=!0),e<=-(0,n.a5)()?((e=(0,n.o)(e,(0,n.a8)()))<=-(0,n.a5)()&&(e+=(0,n.a8)()),i=!0):e>(0,n.a5)()&&((e=(0,n.o)(e,(0,n.a8)()))>(0,n.a5)()&&(e-=(0,n.a8)()),i=!0),i&&(e>(0,n.a5)()||e<=-(0,n.a5)())&&(e=(0,n.a5)()),e}function sv(t,e,i){let s=i.getSemiAxes(),r=new n.P(s.x*Math.cos(t[0]),s.y*Math.sin(t[0]));return r=i.convertFromCanonic(r),n.P.sqrDistance(r,i.getStartXY())}function sC(t,e,i){let s=i.getSemiAxes(),r=t[0]+i.getStartAngle(),o=new n.P(s.x*Math.cos(r),s.y*Math.sin(r));return o=i.convertFromCanonic(o),n.P.sqrDistance(o,i.getEndXY())}function sb(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);let e=t.getStartXY(),i=t.getEndXY(),s=e.equals(i),r=sk(t),o=sz(t),a=t.projectionBehavior();if(s){let i=t.convertToCanonic(e),s=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=s.x,i.y/=s.y,t.m_startAngle=sx(Math.atan2(i.y,i.x)),t.m_sweepAngle=r?o?(0,n.a8)():-(0,n.a8)():0}else{var l,h;let s=t.convertToCanonic(e),m=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=m.x,s.y/=m.y;let u=t.convertToCanonic(i);u.x/=m.x,u.y/=m.y,t.m_startAngle=Math.atan2(s.y,s.x),t.m_sweepAngle=n.P.calculateAngle(s,u),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,n.a8)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,n.a8)()),t.m_startAngle=sx(t.m_startAngle);let g=sv([t.m_startAngle],1,t);if((g=Math.sqrt(g))>.25*L(t)){let e=t.m_startAngle-1e-4,i=t.m_startAngle+1e-4,s=[0];l=[t.m_startAngle],tf(sv,t,1,l,[e],[i],1e-14,s),t.m_startAngle=sx(s[0])}if((g=Math.sqrt(g=sC([t.m_sweepAngle],1,t)))>.25*L(t)){let e=t.m_sweepAngle-1e-4,i=t.m_sweepAngle+1e-4,s=[0];h=[t.m_sweepAngle],tf(sC,t,1,h,[e],[i],1e-14,s),t.m_sweepAngle=s[0]}let c=Math.abs(t.m_sweepAngle)>(0,n.a5)();if(sG(t,c),r!==c&&!r&&Math.abs(t.m_sweepAngle)>1.5*(0,n.a5)()||0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void sM(t,e,i,a)}}function sE(t,e){return(function(t,e){let i=new n.E(t.getStartAngle(),t.getEndAngle());i.normalize();let s=(0,n.a8)(),r=(0,n.o)(e,s);if(r<i.vmin){let t=r+s;for(;t<i.vmin;)t+=s;return i.containsCoordinate(t)?t:i.vmin-r<t-i.vmax?r:t}if(r>i.vmax){let t=r-s;for(;t>i.vmax;)t-=s;return i.containsCoordinate(t)||i.vmin-t<r-i.vmax?t:r}return r}(t,e)-t.getStartAngle())/t.getSweepAngle()}function sS(t,e){return t.m_startAngle+e*t.m_sweepAngle}function sD(t,e,i){i.assign(new n.F(t.m_startAngle).addE(e.mulE(new n.F(t.m_sweepAngle))))}function sw(t){return t.m_cachedValues}function sA(t){var e;if(t.m_cachedValues)return t.m_cachedValues;let i={e2:0,completeE:0};return e=t,i.e2=1-(0,n.s)(e.m_minorMajorRatio),i.completeE=(0,n.ah)(i.e2),t.m_cachedValues=i,i}function sT(t,e,i,r){if(!e.isEqual(t.m_XStart,t.m_YStart)||!i.isEqual(t.m_XEnd,t.m_YEnd)){if(sY(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y,sQ(t),void t.afterCompletedModification();if(r&&Math.abs(t.getSweepAngle())<=1.01*(0,n.a7)()){let s=(0,n.m)(n.P,3),r=sZ(t,s);if(ef(s)){if(s[0].assign(e),s[2].assign(i),ey(s),0===t.projectionBehavior()){let e=0,i=2;n.P.sqrDistance(s[1],s[0])<n.P.sqrDistance(s[1],s[2])&&(i=(0,n.b)(e,e=i));let r=s[i].sub(s[e]),o=r.length();r.divThis(o);let a=s[1].sub(s[e]),l=a.length(),h=a.dotProduct(r)/l,m=a.crossProduct(r)/l,u=new n.P;(0,n.Z)(s[e],s[i],.5,u);let g=.5*o/m*(0,n.c)(1-h,0,1),c=s[1].side(s[e],s[i]),d=r.clone();c?d.leftPerpendicularThis():d.rightPerpendicularThis();let _=u.sub(d.mul(g));t.constructCircularArcThreePoint(s[0],s[2],_)}else sH(s,r*r,null,!1,t);return}}
10===t.projectionBehavior()?function(t,e,i,s){let r=t.getStartXY(),o=t.getEndXY(),l=r.equals(o),h=e.equals(i);if(!l&&!h){let s=new a.T;s.setShiftCoords(-t.m_XStart,-t.m_YStart);let l=n.P.distance(e,i),h=n.P.distance(r,o),m=l/h;s.scale(m,m);let u=o.sub(r);u.divThis(h);let g=i.sub(e);g.divThis(l);let c=u.crossProduct(g),d=g.dotProduct(u);return s.rotate(d,c),s.shiftCoords(e.x,e.y),sF(t,s,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=i.x,t.m_YEnd=i.y}let m=new n.P;if(t.queryCoord2D(.5,m),h){if(l){let s=t.m_center.add(e.sub(r));t.constructEllipticArcEndPointsCenter(e,i,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),s),t.setProjectionBehavior(0)}else if(t.isMajor()){let s=m.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,i,s)}else t.constructCircularArcThreePoint(e,i,e);return}let u=e.add(i).mul(.5),g=i.sub(e);g.rightPerpendicularThis();let c=u.add(g),d=n.P.getClosestCoordinate(u,c,t.getCenter(),!0),_=new n.P;(0,n.Z)(u,c,d,_);let p=n.P.distance(e,_);t.constructEllipticArcEndPointsCenter(e,i,p,1,0,!0,!t.isClockwise(),_),t.setProjectionBehavior(0)}(t,e,i):function t(e,i,r,o){let l=e.getStartXY(),h=e.getEndXY(),m=l.equals(h),u=i.equals(r);if(!m&&!u){let t=new a.T;return t.initializeFromTwoPoints(l,h,i,r),sF(e,t,!0),e.m_XStart=i.x,e.m_YStart=i.y,e.m_XEnd=r.x,e.m_YEnd=r.y,e.endPointModified(),void e.normalizeAfterEndpointChange()}if(!e.isMajor())return void sM(e,i,r,1);if(m&&u){let t=e.m_center.add(i.sub(l));return void e.constructEllipticArcEndPointsCenter(i,r,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),t)}if(!m){let t=.5*((0,n.a8)()-Math.abs(e.getSweepAngle())),s=(e.getSweepAngle()+t*(0,n.e)(e.getSweepAngle()))/e.getSweepAngle(),o=new n.P;e.queryCoord2D(s,o),e.constructEllipticArcEndPointsCenter(o,o,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.getCenter());let a=e.getCenter().add(i.sub(o));return void e.constructEllipticArcEndPointsCenter(i,r,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),a)}let g=n.P.sqrDistance(i,r),c=.25,d=.75;if(g<n.P.sqrDistance(e.getCoord2D(.25),e.getCoord2D(.75))){let t=[0],i=td(new sf(e,g),n.E.construct(0,.25),1,t);i>0&&((0,s.g)(1===i),c=t[0],d=1-t[0])}let _=e.getCoord2D(c),p=e.getCoord2D(d);(0,s.g)(!_.equals(p)),e.constructEllipticArcEndPointsCenter(_,p,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.m_center),t(e,i,r)}(t,e,i)}}function sI(t,e,i,s,r,n,o,a,l){return t.m_bits=0,t.m_rotation=n,w(t,e),T(t,i),t.m_cosr=Math.cos(n),t.m_sinr=Math.sin(n),sG(t,o),sR(t,a),void 0!==l?t.m_center.assign(l):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=s,t.m_minorMajorRatio=r,sj(t,void 0===l)}function sM(t,e,i,s){t.m_bits=0,t.m_rotation=0,w(t,e),T(t,i),t.m_interior.assign(e.add(i).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,sG(t,!1),sR(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(s),t.afterCompletedModification()}function sY(t){return t.m_center.isNAN()}function sX(t,e){if(0===e)return 0;let i=sA(t),s=sS(t,e),r=(0,n.a7)(),o=sq(t),a=(0,n.a9)(s+r,i.e2,i.completeE);return Math.abs(t.m_semiMajorAxis*(a-o))}function sq(t){let e=sA(t);return(0,n.a9)(t.getStartAngle()+(0,n.a7)(),e.e2,e.completeE)}function sF(t,e,i){if(2===e.m_TransformationType)return void(0,s.g)(0);if((0,s.g)(!sB(t)),e.isIdentity())return;sL(t);let r=n.P.getNAN();r.x=t.m_XStart,r.y=t.m_YStart,e.transformInPlace(r);let o=n.P.getNAN();if(o.x=t.m_XEnd,o.y=t.m_YEnd,e.transformInPlace(o),sY(t))return t.m_XStart=r.x,t.m_YStart=r.y,t.m_XEnd=o.x,void(t.m_YEnd=o.y);let a=t.m_center.clone();if(e.transformInPlace(a),i||e.isUniformNoRotation()){let i=sz(t);if(e.isReflective()&&(i=!i),0===t.projectionBehavior()){if(!r.equals(o)){let i=t.m_interior.clone();return e.transformInPlace(i),void t.constructCircularArcThreePoint(r,o,i)}return void sN(t,r,o,a,i,!1)}let s=new n.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(s);let l=Math.atan2(s.y,s.x),h=t.getSemiAxes();e.transformWithoutTranslateInPlace(h);let m=t.m_center.clone();return e.transformInPlace(m),void t.constructEllipticArcEndPointsCe
1nter(r,o,h.x,h.y/h.x,l,t.isMajor(),i,m)}{{let i=[,,,,];!function(t,e){let i=new n.F(t.m_cosr).sqrThis(),s=new n.F(t.m_sinr).sqrThis(),r=new n.F(t.m_minorMajorRatio),o=new n.F(1/t.m_minorMajorRatio),a=r.mulE(i).addThisE(o.mulE(s)),l=r.subE(o).mulThis(2*t.m_cosr*t.m_sinr),h=r.mulE(s).addThisE(o.mulE(i));e[0]=a,e[1]=l,e[2]=h,e[3]=new n.F(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,i);let s=new x;if(s.a11.setE(i[0]),s.a12.setE(i[1]),s.a12.mulThisByPower2(.5),s.a21.setE(s.a12),s.a22.setE(i[2]),!s.det().isZero()){let l=new x;if(l.a11.set(e.xx),l.a12.set(e.xy),l.a21.set(e.yx),l.a22.set(e.yy),l.invertThis()){let h=l.clone();h.transposeThis();let m=s.clone();if(m.mulThis(l),m.mulLeftThis(h),!m.det().isZero()){let s=(0,n.m)(n.F,4);s[0].setE(m.a11),s[1].setE(m.a12),s[1].mulThisByPower2(2),s[2].setE(m.a22),s[3].setE(i[3]);let l=n.P.getNAN(),h=function(t,e){let i=new x;i.a11.setE(t[0]),i.a12=n.F.st_mulByPower2(t[1],.5),i.a21.setE(i.a12),i.a22.setE(t[2]);let s=[n.P.getNAN(),n.P.getNAN()],r=[new n.F,new n.F];i.eigenSymmetric(r,s);let o=t[3].clone();return o.negateThis(),o.invThis(),r[0].mulThisE(o),r[1].mulThisE(o),r[0].sqrtThis().invThis(),r[1].sqrtThis().invThis(),e.x=r[0].toDouble(),e.y=r[1].toDouble(),Math.atan2(s[0].y,s[0].x)}(s,l),u=sz(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(r,o,l.x,l.y/l.x,h,t.isMajor(),u,a)}}}}let i=[n.P.getNAN(),n.P.getNAN(),n.P.getNAN()];i[0].setCoords(t.getSemiMajorAxis(),0),i[0].rotateDirect(t.m_cosr,t.m_sinr),i[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),i[1].rotateDirect(t.m_cosr,t.m_sinr),i[2].setCoords(0,t.getSemiMinorAxis()),i[2].rotateDirect(t.m_cosr,t.m_sinr);let s=t.isClockwise();s&&(i[2]=(0,n.b)(i[0],i[0]=i[2])),e.transformWithoutTranslateArray(i,3,i),e.isReflective()&&(s=!s);let l=new n.P(0,0),h=t.createInstance();sH(i,.5,l,!1,h),t.constructEllipticArcEndPointsCenter(r,o,h.getSemiMajorAxis(),h.getMinorMajorRatio(),h.getAxisXRotation(),t.isMajor(),!s,a)}}function sN(t,e,i,s,r,n){let o=.5*(s.sub(e).length()+s.sub(i).length());t.m_center.assign(s),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x),sy(t,Math.atan2(i.y-t.m_center.y,i.x-t.m_center.x),r,n);let a=t.constructEllipticArcEndPointsCenter(e,i,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,s);return t.setProjectionBehavior(0),a}function sV(t,e){t.m_cachedValues=e}function sL(t){t.m_cachedValues=null}function sR(t,e){t.m_bits=-2&t.m_bits|!!e}function sz(t){return!!(1&t.m_bits)}function sG(t,e){t.m_bits=-3&t.m_bits|!!e<<1}function sk(t){return!!(2&t.m_bits)}function sB(t){return!!(8&t.m_bits)}function sW(t){t.m_bits&=-9}function sj(t,e){sW(t);let i=t.getStartXY(),r=t.getEndXY(),o=!1,a=sk(t),l=sz(t),h=t.projectionBehavior(),m=i.equals(r),u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,s.k)("NAN minor major ratio and non-zero major axis")),u||=e?m:t.m_center.isNAN())return sM(t,i,r,h),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);let g=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(m){let e=t.convertToCanonic(i);e.x/=g.x,e.y/=g.y;let s=Math.sqrt((0,n.s)(e.x)+(0,n.s)(e.y));if(o=1!==s,t.m_semiMajorAxis*=s,g.mulThis(s),t.m_startAngle=sx(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(i),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=l?(0,n.a8)():-(0,n.a8)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;let e=new y;e.setWithEps(t.getStartXY(),8),e.subThisE((new y).setWithEps(t.m_center,8));let i=new n.F;i.setWithEps(t.m_rotation,8);let s=new n.F,r=new n.F;n.F.st_cosAndSin(i,s,r),e.rotateReverse(s,r);let o=new y;o.setWithEps(t.getEndXY()),o.subThisE(y.constructPoint2D(t.m_center)),o.rotateReverse(s,r);let a=new n.F;a.setWithEps(t.m_semiMajorAxis,8);let l=a.clone(),h=new n.F;h.setWithEps(t.m_minorMajorRatio),l.mulThisE(h),e.x.divThisE(a),e.y.divThisE(l),o.x.divThisE(a),o.y.divThisE(l);let m=e.x.sqr().addThisE(e.y.sqr()).subThisE(n.G),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(n.G);return!m.isZero()||!u.isZero()}(t);if(!e){let s=t.convertToCanonic(i);s.x/=g.x,s.y/=g.y;let o=new n.P(1,0);t.m_startAngle=n.P.calculateAngle(o,s);let a=t.convertToCanonic(r);a.x/=g.x,a.y/=g.y,t.m_sweepAngle=n.P.calculateAngle(s,a),e=!sO(t)}if(e){o=!0;let e=i.sub(r).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let s=(0,n.s)(e.x/g.x)+(0,n.s)(e.y/g.y);s>1&&(s=Math.sqrt(s),t.m_semiMajorAxis*=s,g.mulThis(s));let h=new n.P(0,0);{let t=g.x*g.x,i=g.y*g.y,s=t*e.y*e.y+i*e.x*e.x,r=t*i-s;if(r>0){let t=Math.sqrt(r/s);h.setCoords(g.x*e.y/g.y,-g.y*e.x/g.x),h.mulThis(t),a===l&&h.negateThis()}}{let e=new n.P(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(i.add(r).mulThis(.5)),t.m_center.assign(e)}}if(sb(t),!sO(t))return sM(t,i,r,h),!0}return sQ(t),t.afterCompletedModification(),o}function sZ(t,e){(0,s.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);let i=t.getSemiMajorAxis(),r=t.getSemiMinorAxis();if(0===i)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),1;if(0===r)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=n.P.lerp(e[0],e[2],.5),1;let o=t.getSweepAngle(),a=t.getStartAngle(),l=a+o,h=new n.P(-i*Math.sin(a),r*Math.cos(a)),m=new n.P(-i*Math.sin(l),r*Math.cos(l));h.normalize(),m.normalize(),h.rotateDirect(t.m_cosr,t.m_sinr),m.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);let u=h.crossProduct(m);return e[1].assign(h.mul(e[1].crossProduct(m)/u)),e[1].addThis(e[0]),Math.cos(.5*o)}function sH(t,e,i,r,o){if(r){let i=Math.sqrt(e),s=(0,n.s)(.5)+2*i*.25+(0,n.s)(.5),r=t[0].mul((0,n.s)(.5)).add(t[1].mul(2*i*.25)).add(t[2].mul((0,n.s)(.5))).divThis(s);return o.constructCircularArcThreePoint(t[0],t[2],r),!0}let a=t[0].sub(t[1]),l=t[2].sub(t[1]),h=a.crossProduct(l),m=a.dotProduct(l);(0,s.g)(e<=1),(0,s.g)(e>0);let u=.5/(1-e),g=a.sqrLength(),c=l.sqrLength(),d=(0,n.s)(h),_=a.sub(l).sqrLength();if(0===d||m<=-Math.sqrt(g)*Math.sqrt(c))return sM(o,t[0],t[2],1),!1;let p=[0,0],f=new n.E;f.setInfinite();let P=t_(2*d,-(_/e+4*m),2*(1-e)/e,f,!1,p);if(0===P)return sM(o,t[0],t[2],1),!1;1===P&&(p[1]=p[0]);let y=Math.sqrt(u/p[0]),x=Math.sqrt(u/p[1]),v=.5/e,C=v-c*p[0],b=v
1-g*p[0];Math.abs(C)>Math.abs(b)?b=m*p[0]-v+1:C=m*p[0]-v+1;let E=a.mul(C).add(l.mul(b)),S=E.norm(1)<1e-15*y?0:Math.atan2(E.y,E.x)+Math.PI,D=a.add(l),w=i?i.clone():t[1].add(D.mul(u)),A=t[0].sub(w),T=t[2].sub(w),I=0>A.crossProduct(T);return new sh,o.constructEllipticArcEndPointsCenter(t[0],t[2],y,x/y,S,!1,!I,w)}function sU(t,e,i,s,r){return sH(t,e,i,s,r)}function sO(t){let e=!1;{let i=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));i.rotateDirect(t.m_cosr,t.m_sinr),i.addThis(t.m_center),e=n.P.distance(t.getStartXY(),i)>L(t)}let i=!1;if(!e){let e=new n.P(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center),i=n.P.distance(t.getEndXY(),e)>L(t)}return!e&&!i}function sJ(t){if(sY(t)||t.isDegenerate(0))return 0;let e=t.m_semiMajorAxis,i=t.getSemiMinorAxis(),s=e*e+i*i,r=t.getStartAngle(),n=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,l=t.m_sinr,h=1,m=0;t.m_rotation&&(h=(a-l)*(a+l),m=2*a*l);let u=((-.5*(n-r)+.25*h*(2*Math.cos(n+r)*Math.sin(n-r)))*i+-2*Math.sin(.5*(n+r))*Math.sin(.5*(n-r))*a*o)*e/s,g=0;return t.m_rotation&&(g=-2*Math.sin(n+r)*Math.sin(n-r)*.125*m-i*o/s*(2*Math.cos(.5*(n+r))*Math.sin(.5*(n-r)))*l),s*(u+g)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function sQ(t){t.queryCoord2D(.5,t.m_interior)}function sK(t,e,i,s,r){if(r){if(0!==rm(e,i))return 2}else if(C(e,i))return 1;return 4*(0!==s$(t,e,i,null,null,null,s,void 0!==r&&r,!0,!1))}function s$(t,e,i,r,o,a,l,h,m,u){if(sY(e))return ti(new rP({start:e.getStartXY(),end:e.getEndXY()}),i,r,o,a,l,h,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0);let g=R(e,i);if(z(e,i,l=Math.max(g,l)))return 0;let c=i.getStartXY();c.subThis(e.m_center);let d=i.getEndXY();d.subThis(e.m_center),c.rotateReverse(e.m_cosr,e.m_sinr),d.rotateReverse(e.m_cosr,e.m_sinr);let _=d.clone();_.subThis(c);let p=e.m_semiMajorAxis,f=1/p,P=e.getSemiMinorAxis(),y=1/P,x=_.clone();x.leftPerpendicularThis();let v=Math.atan2(P*x.y,p*x.x),C=(0,n.d)(16,NaN),b=(0,n.d)(16,NaN),E=0,S=[v,v+Math.PI];for(let t=0;t<2;++t){let s=sE(e,S[t]);if(s>=0&&s<=1){C[E]=s;let t=e.getCoord2D(C[E]);b[E]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(b[E]))<=l&&E++}}let D=c.x*f,w=c.y*y,A=_.x*f,T=_.y*y,I=t_(A*A+T*T,2*(D*A+w*T),D*D+w*w-1,n.E.unit(),!1,b);(0,s.g)(I>=0);for(let t=0;t<I;t++){let s=_.mul(b[t]).add(c);s.x*=f,s.y*=y;let r=sE(e,Math.atan2(s.y,s.x));if(r>=0&&r<=1){C[E]=r;let t=e.getCoord2D(r);b[E]=i.getClosestCoordinate(t,!1),n.P.distance(t,i.getCoord2D(b[E]))<=l&&E++}}(0,s.g)(E<C.length+4);let M=(0,n.d)(16,NaN);I=e.intersectPoint(i.getStartXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=M[t],b[E]=0;I=e.intersectPoint(i.getEndXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=M[t],b[E]=1;I=i.intersectPoint(e.getStartXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=0,b[E]=M[t];I=i.intersectPoint(e.getEndXY(),M,l);for(let t=0;t<I;t++,E++)C[E]=1,b[E]=M[t];return 0===E?0:rd(t,e,i,C,b,E,r,o,a,l,h,m,u)}function s0(t,e,i,r,o,a,l,h,m,u){if(sY(e))return s$(t,i,new rP({start:e.getStartXY(),end:e.getEndXY()}),r,a,o,l,h,m,!0);if(sY(i))return s$(t,e,new rP({start:i.getStartXY(),end:i.getEndXY()}),r,o,a,l,h,m,u);l=Math.max(l,R(e,i));let g=!1;{let t=e.getSemiAxes(),r=e.getCenter(),u=i.getSemiAxes(),c=i.getCenter(),d=n.P.distance(c,r),_=t.x+u.x;if(d>_+l)return 0;if(t.y>u.x){if(d+u.x+l<t.y)return 0}else if(u.y>t.x&&d+t.x+l<u.y)return 0;if(m&&!h){let r=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),n=1===i.m_minorMajorRatio&&i.isClosed()&&i.isMajor();if(r&&n&&(g=!0,d<=_)&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+d)return(0,s.g)(!o&&!a),1}}if(!g&&z(e,i,l))return 0;let c=[],d=[],_=sg(e,0,0,!1,!1,c,d,null),p=[],f=[],P=sg(i,0,0,!1,!1,p,f,null);if(1===_&&1===P){let t=new tY({points:c,weights:d}),s=new tY({points:p,weights:f}),g=[],_=[],P=ew(!1,t,s,r,null===o?null:g,null===a?null:_,l,h,m,u);if(P>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let r=0;r<P;++r){if(o)if((0,n.J)(g[r],0,1))o.push(g[r]);else{let i=t.tToLength(g[r]),s=e.lengthToT(i);o.push(s)}if(a)if((0,n.J)(_[r],0,1))a.push(_[r]);else{let t=s.tToLength(_[r]),e=i.lengthToT(t);a.push(e)}}}return P}let y=[],x=[],v=0,C=m&&!h;for(let t=0;t<_;t++){let s=new tY({points:c.slice(2*t,2*t+3),weights:d.slice(2*t,2*t+3)}),r=0;for(let o=0;o<P;o++){x.length<=o&&x.push(new tY({points:p.slice(2*o,2*o+3),weights:f.slice(2*o,2*o+3)}));let a=[],h=[],m=C?null:a,u=C?null:h,g=ew(!1,s,x[o],null,m,u,l,!1,C,!1);if(g>0&&C)return 1;for(let l=0;l<g;++l){if(0===a[l]&&0===t)a[l]=0;else if(1===a[l]&&t===_-1)a[l]=1;else{let t=s.tToLength(a[l])+v,i=e.lengthToT(t);a[l]=i}if(0===h[l]&&0===o)h[l]=0;else if(1===h[l]&&o===P-1)h[l]=1;else{let t=x[o].tToLength(h[l])+r,e=i.lengthToT(t);h[l]=e}y.push((0,n.n)(a[l],h[l]))}r+=x[o].calculateLength2D()}v+=s.calculateLength2D()}if(0===y.length)return 0;if(h&&(y=y.filter(t=>!(0,n.J)(t.first,0,1)||!(0,n.J)(t.second,0,1)||!e.getCoord2D(t.first).equals(i.getCoord2D(t.second)))),m)return y.length;let b=[],E=[];for(let t of y)b.push(t.first),E.push(t.second);return rd(t,e,i,b,E,b.length,r,o,a,l,h,m,u)}function s1(t,e,i){if(i.setCoords(t.getCoord2D(e.vmin)),i.mergeNe(t.getCoord2D(e.vmax)),sY(t))return;let s=t.getSemiAxes(),r=[0,0,0,0];{let e=Math.atan2(-s.y*t.m_sinr,s.x*t.m_cosr),i=e+Math.PI,n=Math.atan2(s.y*t.m_cosr,s.x*t.m_sinr),o=n+Math.PI;r[0]=sE(t,e),r[1]=sE(t,i),r[2]=sE(t,n),r[3]=sE(t,o)}let o=new n.P;for(let s=0;s<4;s++){let n=r[s];
1e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,o),i.mergeNe(o))}}function s2(t,e,i,r,o){if(0===t.m_semiMajorAxis)return i.vmin;let a=n.P.getNAN();t.queryCoord2D(i.vmin,a);let l=n.P.getNAN();if(t.queryCoord2D(i.vmax,l),sY(t))return new rP({start:a,end:l}).getClosestCoordinate(e,r);let h=sP(t,e);if(a=sP(t,a),l=sP(t,l),1===t.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;let e=sE(t,Math.atan2(h.y,h.x));return r||i.containsCoordinate(e)?e:n.P.distance(h,a)<=n.P.distance(h,l)?i.vmin:i.vmax}let m=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),g=(m-u)*(m+u),c=(0,n.s)(g),d=h.x,_=h.y,p=(0,n.s)(u*_),f=u*g*_*2,P=[new n.F(p),new n.F(f),new n.F(c-(0,n.s)(m*d)-p),new n.F(-f),new n.F(-c)],y=(0,n.m)(n.F,4),x=tb(P,4,new n.E(-1,1),!1,y,4),v=i.vmin,C=n.P.sqrDistance(h,a);{let t=n.P.sqrDistance(h,l);t<C&&(v=i.vmax,C=t)}(0,s.g)(!r);let b=(0,n.d)(8,NaN);for(let e=0;e<x;++e){let i=y[e].value(),s=Math.sqrt(1-i*i),r=Math.atan2(i,s),n=Math.atan2(i,-s);b[2*e]=sE(t,r),b[2*e+1]=sE(t,n)}b=b.slice(0,2*x),(0,n.v)(b);for(let s=0,r=2*x;s<r;++s)if(b[s]>i.vmin&&b[s]<i.vmax){let i=n.P.sqrDistance(e,t.getCoord2D(b[s]));C>i&&(C=i,v=b[s])}return v}function s3(t,e,i){return t.m_semiMajorAxis===e.m_semiMajorAxis&&t.isMajor()!==e.isMajor()&&!!t.m_center.equals(e.m_center)&&t.m_sinr===e.m_sinr&&t.m_cosr===e.m_cosr&&t.m_minorMajorRatio===e.m_minorMajorRatio&&(i?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}var s4=r.V;let s5=-1;class s6{constructor(t){this.m_shape=t}userSort(t,e,i){this.m_shape.sortVerticesSimpleByYHelper(i,t,e)}getValue(t){return this.m_shape.getY(t)}}class s8{constructor(t){void 0!==t.parent?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==s5;){for(;this.m_path!==s5;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==s5)return this.m_vertex;if(this.m_bOneGeom||(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===s5))break;this.m_bSkipMultiPoints&&!(0,s.h)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return s5}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){let t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==s5&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return s5}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==s5?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==s5&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):s5}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,i,s,r,n,o,a,l){return new s8({parent:t,geometry:e,path:i,vertex:s,firstVertex:r,index:n,bSkipMultiPoints:o,selection:a,bOneGeom:l})}}class s7{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class s9{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){let e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){let e=this.m_pathIndexList.newElement(),i=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,i),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),i>=this.m_pathAreas.length){let t=Math.trunc(i<16?16:3*i/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[i]=0,this.m_pathLengths[i]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){let e=this.m_vertexIndexList.newElement(),i=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,i),t<0){if(i>=this.m_vertices.getPointCount()){let t=Math.trunc(i<16?16:3*i/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream
1=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[i]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);let e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let t=0,i=this.m_indices.length;t<i;t++){if(t===this.m_selectionIndex)continue;let i=this.m_indices[t];null!==i&&i.size()>e&&i.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,1),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,i,s){this.m_hasForceSetEnvelope=0;let r=e!==s5?this.getPrevVertex(e):this.getLastVertex(t),n=r!==s5?this.getNextVertex(r):s5,o=this.newVertex(null===i?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==i&&this.m_vertices.setPointByVal(a,i),this.setPathToVertex(o,t),this.setNextVertex(o,n),this.setPrevVertex(o,r),n!==s5&&this.setPrevVertex(n,o),r!==s5&&this.setNextVertex(r,o);let l=this.isClosedPath(t),h=this.getFirstVertex(t);e===s5&&this.setLastVertex(t,o),e===h&&(l&&s&&h!==s5||this.setFirstVertex(t,o)),l&&n===s5&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);let m=this.getGeometryFromPath(t);return this.setGeometryVertexCount(m,this.getPointCount(m)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new r.P({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(i,t,e),i}addPoint_(t,e){let i=this.createGeometry(s.G.enumMultiPoint,t.getDescription());return this.appendPoint(i,t,e),i}appendMultiPath_(t,e){if(e.isEmpty())return;let i=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+i.getPointCount()),this.m_verticesMp.addPoints(e,0,i.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);let s=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+i.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+i.getPathCount());for(let e=0,r=i.getPathCount();e<r;e++){if(0===i.getPathSize(e))continue;let r=this.insertPath(t,s5);this.setClosedPath(r,i.isClosedPath(e));for(let t=i.getPathStart(e),n=i.getPathEnd(e);t<n;t++){let e=this.insertVertex_(r,s5,null,!1);if(s){let s=this.getVertexIndex(e);if(1&i.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{let e=new ry;i.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}i.isStrongPathStart(e)&&this.setStrongPathStart(r,!0),i.isStrongPathEnd(e)&&this.setStrongPathEnd(r,!0)}}addMultiPath(t,e){let i=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===s.G.enumPolygon&&this.setFillRule(i,t.getFillRule()),this.appendMultiPath(i,t,e),i}appendMultiPathPolyline(t,e,i){let s=e.getImpl(),r=null!==this.m_segments||null!==s.get
1SegmentFlagsStreamRef(),n=new o.J;e.queryEnvelope(n);{let n=i.clone(),o=s.getPointCount(),a=s.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(n,0,s.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;let i=s.queryLimitedSegmentIterator(n),a=-1,l=-100,h=-1,m=0,u=-1,g=s5,c=!1,d=i.nextSegment();if(null!==d)for(;;d=i.nextSegment()){let n=null===d,o=null!==d?i.getPathIndex():a,_=null!==d?i.getStartPointIndex():l;if(n||(a===o&&l+1===_?m++:n=!0),n){if(-1!==u){let t=-1,i=-1;if(m===h){this.setClosedPath(g,c);let r=s.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r-u),this.m_verticesMp.addPoints(e,u,r),i=s.getPathSize(a),t=r-1}else if(!c||l+1<s.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp.addPoints(e,u,l+2),i=l-u+2,t=l;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l+2-u),this.m_verticesMp?.addPoints(e,u,l+1),t=l,i=l-u+1;let r=s.getPathStart(a);this.m_verticesMp.addPoints(e,r,r+1),i+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,n=u;e<i;e++,n++){let e=this.insertVertex_(g,s5,null,!1);if(r){let i=this.getVertexIndex(e);if(1&s.getSegmentFlags(n)||n>t)this.setSegmentToIndex(i,null);else{let t=new ry;s.getSegmentBuffer(n,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(null===d)break;m=1,u=_,a!==o?(g=this.insertPath(t,s5),this.setClosedPath(g,!1),h=s.getSegmentCountPath(o),c=s.isClosedPath(o),a=o):g=this.insertPath(t,s5)}l=_}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,i){let r=e.getImpl(),a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef(),l=o.J.constructEmpty();e.queryEnvelope(l),(0,s.g)(i.isIntersecting(l)&&!i.containsEnvelope(l));let h=o.J.construct(-1/0,i.ymin,1/0,i.ymax),m=o.J.construct(i.xmin,-1/0,i.xmax,1/0),u=r.getAccelerators();if(u&&u.getQuadTree()){let t=u.getQuadTree(),e=t.getIntersectionCount(h,0,0);e>t.getIntersectionCount(m,0,e+1)&&(m=(0,n.b)(h,h=m))}else h.height()>m.width()&&(m=(0,n.b)(h,h=m));let g=[],c=r.queryLimitedSegmentIterator(h),d=-1,_=-100,p=-1,f=0,P=-1,y=-1,x=s5,v=!0,C=c.nextSegment();if(null!==C)for(;;C=c.nextSegment()){let i=null===C,l=null!==C?c.getPathIndex():d,h=null!==C?c.getStartPointIndex():_;if(i||(l===d?_+1===h?f++:i=!0:(i=d>=0,d<0&&(d=l,p=r.getSegmentCountPath(d),P=h,x=s5,f=1))),i){if(0!==g.length||p!==f){for(let{first:i,second:n}of(0!==g.length&&g[0].first===P||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,P,P+1),-1===y&&(y=P),x===s5&&(x=this.insertPath(t,s5),this.setClosedPath(x,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(x,s5,null,!1)),g)){-1===y&&(y=i);let o=-1,l=-1,h=i+n-1;if(n===p){let t=h+1;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h,(0,s.g)(1===g.length)}else if(h+1<r.getPathEnd(d)){let t=h+2;l=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+l),this.m_verticesMp.addPoints(e,i,t),o=h}else{let t=r.getPathStart(d),s=+(t!==y),n=h+1;l=n-i+s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(n-i)+s),this.m_verticesMp.addPoints(e,i,n),o=h,s>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),x===s5&&(x=this.insertPath(t,s5),this.setClosedPath(x,!0));for(let t=0,e=i;t<l;t++,e++){let t=this.insertVertex_(x,s5,null,!1);if(a){let i=this.getVertexIndex(t);if(1&r.getSegmentFlags(e)||e>o)this.setSegmentToIndex(i,null);else{let t=new ry;r.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(i,t.releaseSegment())}}}}if(0===g.length||g.at(-1).first+g.at(-1).second!==P+f){let t=P+f;t===e.getPathEnd(d)&&(t=e.getPathStart(d)),y!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(x,s5,null,!1))}}g.length=0,v=!0,l!==d&&(d=l,p=r.getSegmentCountPath(d),x=s5,y=-1),P=h,f=1}if(!C)break;{let t=o.J.constructEmpty();C.queryLooseEnvelope(t),m.isIntersecting(t)?(v?g.push((0,n.n)(h,1)):g.at(-1).second++,v=!1):v=!0}_=h}}appendMultiPath(t,e,i){if(void 0===i)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;let r=e.getGeometryType()===s.G.enumPolygon,n=o.J.constructEmpty();e.queryEnvelope(n),i.isIntersecting(n)&&(!i.containsEnvelope(n)&&e.getPointCount()>10?r?this.appendMultiPathPolygon(t,e,i):this.appendMultiPathPolyline(t,e,i):this.appendMultiPath_(t,e))}appendPoint(t,e,i){if(e.isEmpty()||void 0!==i&&!i.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream
1=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);let s=this.insertPath(t,s5);this.insertVertex_(s,s5,null,!1)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());let i=this.insertPath(t,s5);for(let t=0,s=e.getPointCount();t<s;t++)this.insertVertex_(i,s5,null,!1)}appendMultiPoint(t,e,i){if(void 0===i)return void this.appendMultiPoint_(t,e);let s=e.getAttributeStreamRef(0),r=0;for(let t=0,n=e.getPointCount();t<n;t++){let e=s.readPoint2D(2*t);i.contains(e)&&r++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+r);let n=-1,o=-1,a=0;for(let t=0,r=e.getPointCount();t<r;t++){let r=s.readPoint2D(2*t);i.contains(r)?(-1===n&&(n=t,o=t),o++):n>=0&&(this.m_verticesMp.addPoints(e,n,o-n),n=-1,a++)}if(n>0&&(this.m_verticesMp.addPoints(e,n,o-n),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+r);let l=this.insertPath(t,s5);for(let t=0,r=e.getPointCount();t<r;t++){let e=s.readPoint2D(2*t);i.contains(e)&&this.insertVertex_(l,s5,null,!1)}}splitSegmentForward(t,e,i,r,n){let o=this.getNextVertex(t);o===s5&&(0,s.t)("Edit_shape.split_segment_forward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=this.getVertexIndex(h),g=this.getNextVertex(h),c=e.getResultSegment(i,t),d=null;if(c.getGeometryType()!==s.G.enumLine&&(d=c.clone()).dropAllAttributes(),0===t&&(c.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(h,a,e.getResultSegmentStartPointRank(i,t),e.getResultSegmentStartPointWeight(i,t),n)),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,t)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,t)),m){let s=e.getResultSegmentSegmentParentage(i,t),r=e.getResultSegmentStartPointIsBreak(i,t);this.setSegmentParentageAndBreak(h,s,r)}if(c.queryEnd(a),t<r-1){this.setSegmentToIndex(u,d);let s=this.insertVertex(l,g,a);this.setWeight(s,e.getResultSegmentEndPointWeight(i,t)),this.setRank(s,e.getResultSegmentEndPointRank(i,t)),this.select(s),h=s}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(i,t),e.getResultSegmentEndPointWeight(i,t),n);let s=e.getResultSegmentEndPointIsBreak(i,t);this.setSegmentParentageBreakVertex(o,s),this.setSegmentToIndex(u,d)}}}splitSegmentBackward(t,e,i,r,n){let o=this.getNextVertex(t);o===s5&&(0,s.t)("Edit_shape.split_segment_backward_");let a=this.getHelperPoint(),l=this.getPathFromVertex(t),h=t,m=this.hasSegmentParentage();for(let t=0,r=e.getResultSegmentCount(i);t<r;t++){let u=r-t-1,g=this.getVertexIndex(h),c=this.getNextVertex(h),d=e.getResultSegment(i,u),_=null;if(d.getGeometryType()!==s.G.enumLine&&((_=d.clone()).reverse(),_.dropAllAttributes()),0===t&&(d.queryEnd(a),this.setSegmentToIndex(g,null),this.setPointEx(h,a,e.getResultSegmentEndPointRank(i,u),e.getResultSegmentEndPointWeight(i,u),n),this.setSegmentParentageAndBreak(h,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))),d.getGeometryType()===s.G.enumLine?this.setSegmentToIndex(g,null):this.setSegmentToIndex(g,_),this.setSegmentRank(h,e.getResultSegmentInteriorRank(i,u)),this.setSegmentWeight(h,e.getResultSegmentInteriorWeight(i,u)),d.queryStart(a),t<r-1){let t=this.insertVertex(l,c,a);this.setWeight(t,e.getResultSegmentStartPointWeight(i,u)),this.setRank(t,e.getResultSegmentStartPointRank(i,u)),this.select(t),h=t,m&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(i,u),e.getResultSegmentEndPointIsBreak(i,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(i,u),e.getResultSegmentStartPointWeight(i,u),n)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}allocateIndex(t=!0){if(this.m_deletedIndices.length){let e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?(0,r.z)(0,-1):(0,r.z)(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){let t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return(0,r.z)(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,i){let s=this.getNextVertex(t),r=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,r),this.setPrevVertex(r,t),this.setNextVertex(e,s),this.setPrevVertex(s,e),this.m_segments){let t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let i=this.getSegmentParentage(e),s=this.getSegmentParentage(t);-1===i&&-1===s||(s=(0,n.b)(i,i=s),this.setSegmentParentageAndBreak(t,s),this.setSegmentParentageAndBreak(e,i))}if(i){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e),n=[!1],o=this.insertClosedPath(i,s5,s,this.getFirstVertex(e),n);n[0]&&this.setFirstVertex(e,r);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return s5}sortVerticesSimpleByYHelper(t,e,i){t.sort(e,i,(t,e)=>{let i=this.compareVerticesSimpleY(t,e);if(0===i){let s=this.getPathInternalIndexFromVertex(t),r=this.getPathInternalIndexFromVertex(e);i=s<r?-1:+(s>r)}return i})}sortVerticesSimpleByYHelper3D(t,e,i){(0,s.g)(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream
1=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_forceSetEnvelope=r.n.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=n.P.getNAN(),this.m_workPoint2_2D=n.P.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=s5,this.m_lastGeometry=s5,this.m_vertexIndexList=new r.S(5),this.m_pathIndexList=new r.S(8),this.m_geometryIndexList=new r.S(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new r.B,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o.J(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);let e=this.hasCurves(),i=o.J.constructEmpty(),s=this.queryVertexIterator(),r=!0;for(let t=s.next();t!==s5;t=s.next()){if(r?i.merge(this.getXY(t)):i.mergeNe(this.getXY(t)),e){let e=this.getSegment(t);if(null!==e){let t=o.J.constructEmpty();e.queryLooseEnvelope(t),i.mergeEnvelope2D(t)}}r=!1}return i}getEnvelope3D(t){return(0,s.g)(0),r.n.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,s.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){let i=t.getGeometryType();if((0,s.h)(i))return this.addMultiPath(t,e);if(i===s.G.enumMultiPoint)return this.addMultiPoint(t,e);if(i===s.G.enumPoint)return this.addPoint_(t,e);if(i===s.G.enumEnvelope){let i=new sm;return i.addEnvelope(t,!1),this.addMultiPath(i,e)}(0,s.t)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());let i=e.getGeometryType();(0,s.h)(i)?this.appendMultiPath(t,e):i!==s.G.enumMultiPoint?(0,s.t)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);let i=this.queryVertexIterator();for(let t=i.next();t!==s5;t=i.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(s.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=s5,i=-1,r=-1;for(let n=this.getFirstGeometry();n!==s5;)if(t!==s.G.enumUnknown&&this.getGeometryType(n)!==t)n=this.getNextGeometry(n);else{if(e===s5){e=n,i=this.getPathCount(e),r=this.getPointCount(e),n=this.getNextGeometry(n);continue}for(let t=this.getFirstPath(n);t!==s5;t=this.getNextPath(t))this.setPathGeometry(t,e);i+=this.getPathCount(n),r+=this.getPointCount(n);let t=this.getLastPath(e),s=this.getFirstPath(n);t!==s5?this.setNextPath(t,s):this.setFirstPath(e,s),s!==s5&&(this.setPrevPath(s,t),this.setLastPath(e,this.getLastPath(n))),this.setFirstPath(n,s5),this.setLastPath(n,s5);let o=n;n=this.getNextGeometry(n),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==s5&&(this.setGeometryVertexCount(e,r),this.setGeometryPathCount(e,i),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let i=this.m_geometryIndexList.getField(t,2);i&=-0x8000001,i|=0x8000000*(1===e),this.m_geometryIndexList.setField(t,2,i)}getFillRule(t){return 0x8000000&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let i=this.m_geometryIndexList.getField(t,2);!!(0x4000000&i)!==e&&(i&=-0x4000001,i|=0x4000000*!!e,this.m_geometryIndexList.setField(t,2,i))}getGeometryModified(t){return!!(0x4000000&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){let i=this.getPathFromVertex(t),s=this.getGeometryFromPath(i);this.setGeometryModified(s,e)}getGeometryModifiedWithVertex(t){let e=this.getPathFromVertex(t),i=this.getGeometryFromPath(e);return this.getGeometryModified(i)}swapGeometry(t,e){let i=this.getFirstPath(t),s=this.getFirstPath(e),r=this.getLastPath(t),n=this.getLastPath(e);for(let i=this.getFirstPath(t);i!==s5;i=this.getNextPath(i))this.setPathGeometry(i,e);for(let i=this.getFirstPath(e);i!==s5;i=this.getNextPath(i))this.setPathGeometry(i,t);this.setFirstPath(t,s),this.setFirstPath(e,i),this.setLastPath(t,n),this.setLastPath(e,r);let o=this.getPointCount(t),a=this.getPathCount(t),l=this.getPointCount(e),h=this.getPathCount(e);this.setGeometryVertexCount(t,l),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,h),this.setGeometryPathCount(e,a);let m=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,m)}addPathFromMultiPath(t,e,i){let r=this.createGeometry(i?s.G.enumPolygon:s.G.enumPolyline,t.getDescription()),n=t.getImpl();if(2>t.getPathSize(e))return r;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),n.getPathEnd(e)),this.m_xyStream
1=this.m_vertices.getAttributeStreamRef(0);let o=this.insertPath(r,s5);this.setClosedPath(o,n.isClosedPath(e)||i);let a=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef();for(let t=n.getPathStart(e),i=n.getPathEnd(e);t<i;t++){let e=this.insertVertex_(o,s5,null,!1);if(a){let i=this.getVertexIndex(e);if(1&n.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{let e=new ry;n.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}return n.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),n.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),r}getGeometry(t){let e=this.getGeometryType(t),i=function(t,e){let i,n=e;switch(n||(n=(0,s.o)(t)?(0,r.w)():(0,r.j)()),t){case s.G.enumPoint:i=new r.P({vd:n});break;case s.G.enumLine:i=new rP({vd:n});break;case s.G.enumBezier:i=new im({vd:n});break;case s.G.enumEllipticArc:i=new sh({vd:n});break;case s.G.enumRationalBezier2:i=new tY({vd:n});break;case s.G.enumBezier2:i=new tI({vd:n});break;case s.G.enumEnvelope:i=new r.E({vd:n});break;case s.G.enumMultiPoint:i=new _({vd:n});break;case s.G.enumPolyline:i=new i6({vd:n});break;case s.G.enumPolygon:i=new sm({vd:n});break;case s.G.enumMultipatch:(0,s.b)("multipatch not impl");break;case s.G.enumGeometryCollection:i=new j({vd:n});break;default:(0,s.t)("Geometry.create")}return i}(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return i;if((0,s.h)(e)){let e=i.getImpl(),s=this.getPathCount(t),o=(0,r.z)(s+1),a=(0,r.D)(s+1,0),l=i.getDescription(),h=this.hasCurves();for(let i=0,h=l.getAttributeCount();i<h;i++){let h=l.getSemantics(i),m=s4.getComponentCount(h),u=(0,r.t)(h,n),g=this.m_vertices.getAttributeStreamRef(h),c=0,d=0,_=0;for(let e=this.getFirstPath(t);e!==s5;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&a.setBits(d,t);let i=this.getPathSize(e);if(o.write(d++,_),_+=i,0===h){let t;for(let i=this.getFirstVertex(e);c<_;i=this.getNextVertex(i),c++){let e=this.getVertexIndex(i);t=g.readPoint2D(2*e),u.writePoint2D(2*c,t)}}else for(let t=this.getFirstVertex(e);c<_;t=this.getNextVertex(t),c++){let e=this.getVertexIndex(t);for(let t=0;t<m;t++){let i=g.readAsDbl(e*m+t);u.writeAsDbl(c*m+t,i)}}}e.setAttributeStreamRef(h,u),o.write(s,n)}if(e.setPathFlagsStreamRef(a),e.setPathStreamRef(o),e.notifyModifiedFlags(65535),h){let i=0,s=0;for(let r=this.getFirstPath(t);r!==s5;r=this.getNextPath(r)){i+=this.getPathSize(r);for(let t=this.getFirstVertex(r);s<i;t=this.getNextVertex(t)){let i=this.getSegment(t);null!==i&&i.isCurve()&&e.replaceSegment(s,i,!0),s++}}}}else if(e===s.G.enumMultiPoint){let e=i.getImpl(),s=i.getDescription();e.reserve(n),e.resizeNoInit(n);for(let i=0,r=s.getAttributeCount();i<r;i++){let r=s.getSemantics(i),n=s4.getComponentCount(r),o=e.getAttributeStreamRef(r),a=this.m_vertices.getAttributeStreamRef(r),l=0,h=this.getFirstPath(t),m=this.getPathSize(h);for(let t=this.getFirstVertex(h);l<m;t=this.getNextVertex(t),l++){let e=this.getVertexIndex(t);for(let t=0;t<n;t++){let i=a.readAsDbl(e*n+t);o.writeAsDbl(l*n+t,i)}}e.setAttributeStreamRef(r,o)}e.notifyModifiedFlags(65535)}else(0,s.c)("getGeometry");return i}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==s.G.enumMultiPoint&&(0,s.t)("get_point_geometry_only");let i=this.getPointCount(t);if(i>1&&(0,s.t)("get_point_geometry_only"),0===i)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();let r=this.getFirstPath(t),n=this.getFirstVertex(r);this.queryPoint(n,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==s5;e=this.removePath(e));let e=this.getPrevGeometry(t),i=this.getNextGeometry(t);return e!==s5?this.setNextGeometry(e,i):this.m_firstGeometry=i,i!==s5?this.setPrevGeometry(i,e):this.m_lastGeometry=e,this.freeGeometry(t),i}createGeometry(t,e){void 0===e&&(e=(0,r.j)());let i=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new _({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===s5?this.m_firstGeometry=i:(this.setPrevGeometry(i,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,i)),this.m_lastGeometry=i,i}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 0xffffff&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,i){let s=this.m_geometryIndices[e],r=this.getGeometryIndex(t);r>=s.size()&&s.resize(Math.max(1.25*r,16),-1),s.write(r,i)}getGeometryUserIndex(t,e){let i=this.getGeometryIndex(t),s=this.m_geometryIndices[e];return i<s.size()?s.read(i):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=(0,r.z)(0),t;this.m_geometryIndices.push((0,r.z)(0));let t=this.m_geometryIndices.length-1;return(0,s.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==s5;t=this.getNextGeometry(t))if(!(0,s.h)(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(t,e,i,r,o){let a=t*t,l=0,h=this.hasCurves(),m=this.hasSegmentParentage();for(let t=o===s5?this.getFirstGeometry():o;t!==s5;
1t=o===s5?this.getNextGeometry(t):s5){let o=this.getGeometryType(t);if(!(0,s.h)(o)||i&&o!==s.G.enumPolygon)continue;let u=this.getGeometryType(t)===s.G.enumPolygon,g=this.getGeometryModified(t);for(let i=this.getFirstPath(t);i!==s5;){let o=0;for(let e=this.getFirstVertex(i);o<Math.trunc(this.getPathSize(i)/2);){let u=this.getNextVertex(e);if(u===s5)break;let c=this.getXY(e),d=this.getXY(u),_=n.P.sqrDistance(c,d),p=!0;do if(_<=a){if(h){let t=this.getSegment(e);if(null!==t){let e=t.calculateLength2D();if((_=e*e)>a)break}}if(0===_?0===l&&(l=-1):l=1,u!==this.getLastVertex(i)){let i=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(u));if(this.transferAllDataToTheVertex(u,e),this.removeVertex(u,!1),r&&!g&&(this.setGeometryModified(t,!0),g=!0),m&&e!==u){this.setSegmentParentageBreakVertex(e,i);let t=this.getNextVertex(e);(0,s.g)(t!==s5),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}p=!1}while(0);p&&(e=this.getNextVertex(e)),o++}let c=this.getFirstVertex(i);for(let e=this.isClosedPath(i)?c:this.getLastVertex(i);this.getPathSize(i)>0;){let s=this.getPrevVertex(e);if(s===s5)break;{let o=this.getXY(s),u=this.getXY(e),d=n.P.sqrDistance(o,u),_=!0;do if(d<=a){if(h){let t=this.getSegment(s);if(null!==t){let e=t.calculateLength2D();if((d=e*e)>a)break}}0===d?0===l&&(l=-1):l=1;let n=m&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(s));this.removeVertex(s,!0),r&&!g&&(this.setGeometryModified(t,!0),g=!0),m&&s!==e&&(n||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),c===s&&(c=this.getFirstVertex(i)),_=!1}while(0);if(_&&(e=this.getPrevVertex(e))===c)break}}let d=this.getPathSize(i),_=e&&d<(u?3:2);_&&u&&2===d&&h&&(_=!this.pathHasCurves(i)),_?(i=this.removePath(i),0===l&&(l=-1),r&&!g&&(this.setGeometryModified(t,!0),g=!0)):i=this.getNextPath(i)}}return l}filterClosePoints3D(t,e,i,r,n,o){return(0,s.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==s5;e=this.getNextGeometry(e))if((0,s.h)(this.getGeometryType(e)))for(let i=this.getFirstPath(e);i!==s5;){let e=this.getPathSize(i);if(0===e)return!0;let s=this.getFirstVertex(i);for(let i=0;i<e;i++){let e=this.getNextVertex(s);if(e===s5)break;let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i);if(null!==r){if(r.calculateLowerLength2D()<=t&&(r.calculateUpperLength2D()<=t||r.calculateLength2D()<=t))return!0}else{let s=this.getVertexIndex(e);if(this.m_vertices.getShortestDistance(i,s)<=t)return!0}s=e}i=this.getNextPath(i)}return!1}hasDegenerateSegments3D(t,e){return(0,s.g)(0),!1}transferAllDataToTheVertex(t,e){let i=this.getVertexIndex(t),s=this.getVertexIndex(e);if(this.m_weights){let t=this.getWeightWithIndex(i);this.setWeightWithIndex(s,t)}if(this.m_ranks){let t=this.getRankWithIndex(i);this.setRankWithIndex(s,t)}if(this.m_segmentWeights){let t=this.getSegmentWeightWithIndex(i);this.setSegmentWeightWithIndex(s,t)}if(this.m_segmentRanks){let t=this.getSegmentRankWithIndex(i);this.setSegmentRankWithIndex(s,t)}for(let i=0,s=this.m_indices.length;i<s;i++)if(i!==this.m_selectionIndex&&null!==this.m_indices[i]){let s=this.getUserIndex(t,i);-1!==s&&this.setUserIndex(e,i,s)}let r=this.selected(t);r!==this.selected(e)&&(r?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,i,r,n){let o=0,a=this.getNextVertex(t);a===s5&&(0,s.t)("");let l=this.getVertexIndex(t),h=this.getVertexIndex(a),m=this.getSegmentFromIndex(l),u=this.m_vertices.getShortestDistance(l,h),g=this.getPathFromVertex(t),c=this.m_bHasAttributes;c&&m&&(u=m.calculateLength2D());let d=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,s=0,n=s5;for(let p=0;p<i;p++){let i=e[p];if(t<i&&i<1){let e=m.cut(t,i);if(null!==r&&(p>0&&e.setStartXY(r[p-1]),e.setEndXY(r[p]),e.normalizeAfterEndpointChange(),s=p),c){let t=u>0?m.calculateSubLengthFromStart(i)/u:0;this.m_vertices.interpolateTwoVertices(l,h,t,_)}_.setXY(e.getEndXY()),n=this.insertVertex(g,a,_),o++;let f=this.getPrevVertex(n),P=this.getVertexIndex(f);this.setSegmentToIndex(P,e),-1!==d&&this.setSegmentParentageAndBreak(n,d,!1),t=i}}if(n!==s5){let e=m.cut(t,1);null!==r&&(e.setStartXY(r[s]),e.normalizeAfterEndpointChange());let i=this.getVertexIndex(n);this.setSegmentToIndex(i,e)}}else{let t=0;for(let s=0;s<i;s++){let i=e[s];if(t<i&&i<1){this.m_vertices.interpolateTwoVertices(l,h,i,_);let t=this.insertVertex(g,a,_);o++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=i}}return o}splitSegment(t,e,i,s=null){return this.splitSegmentAxisAware(t,e,i,s,-1)}snapControlPoints(t,e,i){this.getNextVertex(t)===s5&&(0,s.t)("");let r=t,n=!1;for(let t=0;t<e;++t){let t=this.getVertexIndex(r),e=this.getSegmentFromIndex(t);if(e){let t=e.snapControlPoints(i);n||=t}r=this.getNextVertex(r)}return n}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0,i=this.queryVertexIteratorOnSelection();for(let s=i.next();s!==s5;s=i.next()){let i=this.getVertexIndex(s),r=this.getSegmentFromIndex(i);r&&(e|=!!r.snapControlPoints(t))}return 0!==e}
1calculateSubLength2D(t,e,i){return(0,s.g)(0),0}setPoint(t,e,i){if(this.setPointOnly(t,e),null!==this.m_segments){let s=this.getVertexIndex(t),r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXY(e.getXY()),r.normalizeAfterEndpointChange(),i&&r.ensureXYMonotone());let n=this.getPrevVertex(t);if(n!==s5){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!==s&&(s.setEndXY(e.getXY()),s.normalizeAfterEndpointChange(),i&&s.ensureXYMonotone())}}}setPointEx(t,e,i,s,r){this.setPoint(t,e,r);let n=this.getVertexIndex(t);this.setWeightWithIndex(n,s),this.setRankWithIndex(n,i)}setPointOnly(t,e){let i=this.getVertexIndex(t);this.m_vertices.setPointByVal(i,e)}setPointOnlyEx(t,e,i,r){(0,s.g)(0)}queryPoint(t,e){let i=this.getVertexIndex(t);this.m_vertices.getPointByVal(i,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);null!==r&&(r.setStartXYCoords(e,i),r.normalizeAfterEndpointChange());let n=this.getPrevVertex(t);if(n!==s5){let t=this.getVertexIndex(n),s=this.getSegmentFromIndex(t);null!=s&&(s.setEndXYCoords(e,i),s.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,i){let s=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(s,e,i),null!==this.m_segments){let r=this.getSegmentFromIndex(s);if(null!==r){let t=r.getEndXY();r.setCoordsForIntersector(new n.P(e,i),t,!1),r.ensureXYMonotone()}let o=this.getPrevVertex(t);if(o!==s5){let t=this.getVertexIndex(o),s=this.getSegmentFromIndex(t);if(null!==s){let t=s.getStartXY();s.setCoordsForIntersector(t,new n.P(e,i),!1),s.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){let i=this.getVertexIndex(t);return this.m_vertices.queryXY(i,e)}getXY(t){let e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}static setSegDefault(t,e,i){(0,s.g)(0)}setXYZ(t,e,i){(0,s.g)(0)}setXYZCoords(t,e,i,r){(0,s.g)(0)}queryXYZ(t,e){(0,s.g)(0)}getXYZ(t){return(0,s.g)(0),r.h.getNAN()}getXYZWithIndex(t){return(0,s.g)(0),r.h.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,s.g)(0)}getAttributeAsDbl(t,e,i){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),i)}queryAttributeAsDbl(t,e,i,r){(0,s.g)(0)}setAttribute(t,e,i,r){(0,s.g)(0)}setAttributeInt(t,e,i,r){(0,s.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,s.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){let e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(t,e){return(0,s.g)(0),!1}setWeight(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_weights){if(i)return;this.m_weights=(0,r.F)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_weights.size()){if(i)return;this.m_weights.resize(s+1,1)}this.m_weights.write(s,e)}setWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_weights){if(i)return;this.m_weights=(0,r.F)(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(i)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;let e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return 1;let e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.z)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(s+1,1)}this.m_ranks.write(s,e)}setRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_ranks){if(i)return;this.m_ranks=(0,r.z)(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(i)return;this.m_ranks.resize(t+1,1)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.F)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(s+1,1)}this.m_segmentWeights.write(s,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null==this.m_segmentWeights){if(i)return;this.m_segmentWeights=(0,r.F)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(i)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;let e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return s9.st_defaultRank;let e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?s9.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.z)(this.m_vertices.getPointCount(),1)}let s=this.getVertexIndex(t);if(s>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(s+1,1)}this.m_segmentRanks.write(s,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);let i=1===e;if(null===this.m_segmentRanks){if(i)return;this.m_segmentRanks=(0,r.z)(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(i)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}setUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);if(s.size()<=r){if(-1===i)return;s.resize(this.m_vertices.getPointCount(),-1)}s.write(r,i)}getUserIndex(t,e){let i=this.getVertexIndex(t),s=this.m_indices[e];return i<s.size()?s.read(i):-1}addToUserIndex(t,e,i){let s=this.m_indices[e],r=this.getVertexIndex(t);s.size()<=r&&s.resize(this.m_vertices.getPointCount(),-1);let n=s.read(r);s.write(r,n+i)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=(0,n.i)()),t}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));let t=this.m_indices.length-1;return(0,s.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,i){let s=this.m_indices[e],r=s.size();for(let e=this.getFirstPath(t);e!==s5;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let n=0,o=this.getPathSize(e);n<o;n++,t=this.getNextVertex(t)){let e=this.getVertexIndex(t);e<r&&s.write(e,i)}}}fillUserIndexForSelection(t,e){(0,s.g)(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){let e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,i=!1){let s=this.getNextVertex(t);if(s===s5)return!1;if(!this.m_bHasAttributes||i){let i=this.getXY(t);e.setStartXY(i);let r=this.getXY(s);e.setEndXY(r)}else{let i=new r.P({vd:this.getVertexDescription()});this.queryPoint(t,i),e.setStart(i),this.queryPoint(s,i),e.setEnd(i)}return!0}
1queryLineConnector3D(t,e,i=!1){return(0,s.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,s.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;let e=this.getFirstVertex(t);if(e===s5)return!1;let i=this.getPathSize(t),r=e;for(let t=0;t<i;t++,r=this.getNextVertex(r)){let t=this.getSegment(r);if(null!==t&&t.getGeometryType()!==s.G.enumLine)return!0}return!1}insertPath(t,e){let i=s5;e!==s5?(t!==this.getGeometryFromPath(e)&&(0,s.t)(""),i=this.getPrevPath(e)):i=this.getLastPath(t);let r=this.newPath(t);return e!==s5&&this.setPrevPath(e,r),this.setNextPath(r,e),this.setPrevPath(r,i),i!==s5?this.setNextPath(i,r):this.setFirstPath(t,r),e===s5&&this.setLastPath(t,r),this.setGeometryPathCount(t,this.getPathCount(t)+1),r}removePath(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);return e!==s5?this.setNextPath(e,i):this.setFirstPath(s,i),i!==s5?this.setPrevPath(i,e):this.setLastPath(s,e),this.clearPath(t),this.setGeometryPathCount(s,this.getPathCount(s)-1),this.freePath(t),i}clearPath(t){let e=this.getFirstVertex(t);if(e!==s5){let i=e;for(let e=0,s=this.getPathSize(t);e<s;e++){let t=i;i=this.getNextVertex(i),this.freeVertex(t)}let s=this.getGeometryFromPath(t);this.setGeometryVertexCount(s,this.getPointCount(s)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){let i=this.getFirstVertex(t),s=this.getLastVertex(t);if(e){this.setNextVertex(s,i),this.setPrevVertex(i,s);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}else{this.setNextVertex(s,s5),this.setPrevVertex(i,s5);let t=this.getVertexIndex(s);this.setSegmentToIndex(t,null)}}let i=(1|this.getPathFlags(t))-1;this.setPathFlags(t,!!e|i)}closeAllPaths(t){(0,s.g)(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){let i=(8|this.getPathFlags(t))-8;this.setPathFlags(t,i|8*!!e)}setStrongPathEnd(t,e){let i=(16|this.getPathFlags(t))-16;this.setPathFlags(t,i|16*!!e)}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){let i=(2|this.getPathFlags(t))-2;this.setPathFlags(t,i|2*!!e)}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];let e=this.getFirstVertex(t);if(e===s5)return 0;let i=this.getXY(e),r=new n.K(0),o=this.getPathSize(t);if(o>2){let t=i.clone(),s=t.x,a=t.y,l=this.getNextVertex(e),h=this.getXY(l);l=this.getNextVertex(l);let m=n.P.getNAN();for(let e=2;e<o;e++,l=this.getNextVertex(l))this.queryXY(l,m),r.pe((m.x-t.x)*(h.y-a)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);r.pe((s-t.x)*(h.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){let e=this.getSegment(t);if(null===e||e.getGeometryType()===s.G.enumLine)continue;let i=2*e.calculateArea2DHelper();r.pe(i)}}this.setRingAreaValid(t,!0);let a=.5*r.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,i){let s=this.m_pathindices[e],r=this.getPathIndex(t);s.size()<this.m_pathAreas.length&&s.resize(this.m_pathAreas.length,-1),s.write(r,i)}getPathUserIndex(t,e){let i=this.getPathIndex(t),s=this.m_pathindices[e];return i<s.size()?s.read(i):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());let t=this.m_pathindices.length-1;return(0,s.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,i){let s=this.m_pathindices[e],r=s.size();for(let e=this.getFirstPath(t);e!==s5;e=this.getNextPath(e)){let t=this.getPathIndex(e);t<r&&s.write(t,i)}}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,i){if(i===s5&&(0,s.t)(""),e===i)return;let r=this.getNextPath(i),n=this.getPrevPath(i),o=this.getGeometryFromPath(i);n===s5?this.setFirstPath(o,r):this.setNextPath(n,r),r===s5?this.setLastPath(o,n):this.setPrevPath(r,n),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(i)),this.setGeometryPathCount(o,this.getPathCount(o)-1),n=e===s5?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(i,n),this.setNextPath(i,e),e===s5?this.setLastPath(t,i):this.setPrevPath(e,i),n===s5?this.setFirstPath(t,i):this.setNextPath(n,i),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(i)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(i,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,s5,this.getHelperPoint(),!1)}insertVertex(t,e,i){return this.insertVertex_(t,e,i,!0)}removeVertex(t,e){let i=this.getPathFromVertex(t),s=this.getPrevVertex(t),r=this.getNextVertex(t);s!==s5&&this.setNextVertex(s,r);let n=this.getPathSize(i);if(t===this.getFirstVertex(i)&&this.setFirstVertex(i,n>1?r:s5),r!==s5&&this.setPrevVertex(r,s),t===this.getLastVertex(i)&&this.setLastVertex(i,n>1?s:s5),this.hasCurves()&&s!==s5&&r!==s5){let i=this.getVertexIndex(t),n=this.getVertexIndex(s),o=this.getVertexIndex(r);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(i,null)}else{let t=this.getSegmentFromIndex(i);if(this.setSegmentToIndex(i,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}this.setPathSize(i,n-1);let o=this.getGeometryFromPath(i);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),r}removeVertices(t,e){(0,s.g)(t!==e);let i=this.getPathFromVertex(t),r=this.getPrevVertex(t),n=this.getPrevVertex(e);r!==s5&&this.setNextVertex(r,e);let o=this.getPathSize(i),a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,r),this.setPrevVertex(t,s5),this.setNextVertex(n,s5);let l=0,h=t,m=this.getFirstVertex(i),u=!1;for(;;){let t=this.getNextVertex(h);if(u||=m===h,this.freeVertex(h),l++,h===n)break;h=t}o-=l,u&&this.setFirstVertex(i,o>0?e:s5),this.setPathSize(i,o);let g=this.getGeometryFromPath(i);this.setGeometryVertexCount(g,this.getPointCount(g)-l)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(t,e){return this.insertVertex_(t,s5,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,s.c)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==s5;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==s5;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let i=0,s=this.getPathSize(e);i<s;i++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=s5){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=s5){let i=s5,r=s5,n=s5,o=s5,a=0,l=!1;for(i=e!==s5?e:this.getFirstGeometry();i!==s5;i=this.getNextGeometry(i))if(!t||(0,s.h)(this.getGeometryType(i))){for(r=this.getFirstPath(i);r!==s5;r=this.getNextPath(r))if(o=n=this.getFirstVertex(r),a=0,n!==s5){l=!0;break}if(l||e!==s5)break}return l||(i=s5),s8.create_(this,i,r,n,o,a,t,!1,e!==s5)}queryVertexIteratorOnSelection(t=s5){return this.m_selection?s8.create_(this,t,s5,s5,s5,-1,!1,!0,t!==s5):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,s.g)(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;let e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=s5,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(t,e){return(0,s.g)(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,i=this.m_segments.length;e<i;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,i,s,r){s?this.splitSegmentForward(t,e,i,!0,r):this.splitSegmentBackward(t,e,i,!0,r)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){let e=this.getVertexIndex(t);
1return this.getSegmentFromIndex(e)}return null}isCurve(t){return(0,s.g)(0),!1}querySegment(t,e,i=!0,s=!1){let r=this.getNextVertex(t);if(r===s5)return!1;let n=this.getSegment(t);if(!n)return!i&&(this.queryLineConnector(t,e.createLine(),s),!0);if(e.copyFrom(n,!0),s)return!0;if(this.m_vertexDescription.getAttributeCount()>1){let i=this.getHelperPoint();this.queryPoint(t,i),e.get().setStart(i),this.queryPoint(r,i),e.get().setEnd(i)}return!0}getSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(t,e){return(0,s.g)(0),!1}reverseRingInternal(t){let e=this.hasCurves(),i=this.hasSegmentParentage(),s=null,r=-1,n=t;if(e){let t=this.getVertexIndex(n);s=this.getAndClearSegmentFromIndex(t)}i&&(r=this.getSegmentParentage(n));do{let t=this.getPrevVertex(n),o=this.getNextVertex(n);if(this.setNextVertex(n,t),this.setPrevVertex(n,o),e){let t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);s&&s.reverse(),this.setSegmentToIndex(t,s),s=e}if(i){let t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,r),r=t}n=o}while(n!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){let e=this.getPrevPath(t),i=this.getNextPath(t),s=this.getGeometryFromPath(t);e!==s5?this.setNextPath(e,i):this.setFirstPath(s,i),i!==s5?this.setPrevPath(i,e):this.setLastPath(s,e),this.setFirstVertex(t,s5),this.setLastVertex(t,s5),this.freePath(t)}insertClosedPath(t,e,i,s,r){let n=this.insertPath(t,s5),o=0,a=i;for(r[0]=!1;;){a===s&&(r[0]=!0),this.setPathToVertex(a,n),o++;let t=this.getNextVertex(a);if(t===i)break;a=t}return this.setClosedPath(n,!0),this.setPathSize(n,o),r[0]&&(i=s),this.setFirstVertex(n,i),this.setLastVertex(n,this.getPrevVertex(i)),this.setRingAreaValid(n,!1),n}findVertex2D(t,e){return(0,s.g)(0),0}findVertex3D(t,e,i){return(0,s.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}removeVertexInternal(t,e){let i=this.getPrevVertex(t),s=this.getNextVertex(t);if(i!==s5&&this.setNextVertex(i,s),s!==s5&&this.setPrevVertex(s,i),this.hasCurves()&&i!==s5&&s!==s5){let r=this.getVertexIndex(t),n=this.getVertexIndex(i),o=this.getVertexIndex(s);if(e){let t=this.getSegmentFromIndex(n);if(null!==t){let e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,null)}else{let t=this.getSegmentFromIndex(r);if(this.setSegmentToIndex(r,null),null!==t){let e=this.m_vertices.getXY(n);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,t)}}return this.freeVertex(t),s}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){let i=(4|this.getPathFlags(t))-4;this.setPathFlags(t,i|4*!!e)}compareVerticesSimpleY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,s.g)(0)}sortVerticesSimpleByY(t,e,i){this.m_bucketSort.sort(t,e,i,new s6(this))}sortVerticesSimpleByX(t,e,i){(0,s.g)(0)}sortVerticesSimpleByY3D(t,e,i){(0,s.g)(0)}snapVertexForPoleClipping(t,e){let i=this.getPrevVertex(t);i!==s5&&this.replaceCurveWithLine(i),this.getNextVertex(t)!==s5&&this.replaceCurveWithLine(t);let s=new n.P;this.queryXY(t,s),s.y=e,this.setXY(t,s)}setSegmentParentageAndBreak(t,e,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.j)()>>1),e<<=1,e|=!!i),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,s.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,s.g)(e<=(0,n.j)()>>1),e<<=1,e|=!!this.getSegmentParentageBreakVertex(t)),this.setUserIndex(t,this.m_segmentParentageIndex,e)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return -1;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){return new s7(-1!==this.m_segmentParentageIndex?this.get
1SegmentParentage(t):-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let i=this.getUserIndex(t,this.m_segmentParentageIndex);i<0||!!(1&i)!==e&&(e?i|=1:i&=(0,n.j)()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,i))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;let e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){let e=this.getPrevVertex(t);return e!==s5&&this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return -1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function rt(t){if(t.isEmpty())return new sm({vd:t.getDescription()});let e=t.getImpl(),i=e.getPointCount();if(i<=2){if(1===i||e.getXY(0).equals(e.getXY(1))){let t=new r.P({vd:e.getDescription()});return e.getPointByVal(0,t),t}{let t=new r.P,i=new i6({vd:e.getDescription()});return e.getPointByVal(0,t),i.startPathPoint(t),e.getPointByVal(1,t),i.lineToPoint(t),i}}let s=e.getAttributeStreamRef(0),o=new rn({stream:s,n:i}),a=1,l=s.readPoint2D(0),h=new n.P;for(;a<i&&s.queryPoint2D(a<<1,h).equals(l);)a++;if(o.m_treeHull.addElement(0),a<i){o.m_treeHull.addBiggestElement(a);let t=new n.P;for(let i=a+1;i<e.getPointCount();i++){s.queryPoint2D(i<<1,t);let e=o.treeHull(t);-1!==e&&o.m_treeHull.setElement(e,i)}}let m=e.getDescription(),u=m.getAttributeCount()>1,g=o.m_treeHull.size(),c=null;if(g>=2){let t=(c=g>=3?new sm({vd:m}):new i6({vd:m})).getImpl();t.reserve(o.m_treeHull.size()),t.addPathPoint2D(null,0,!0);let i=new n.P;for(let n=o.m_treeHull.getFirst();-1!==n;n=o.m_treeHull.getNext(n))if(u){let i=new r.P;e.getPointByVal(o.m_treeHull.getElement(n),i),t.insertPoint(0,-1,i)}else s.queryPoint2D(o.m_treeHull.getElement(n)<<1,i),t.insertPoint2D(0,-1,i)}else if(u){let t=new r.P({vd:m});e.getPointByVal(o.m_treeHull.getElement(o.m_treeHull.getFirst()),t),c=t}else{let t=s.readPoint2D(o.m_treeHull.getElement(o.m_treeHull.getFirst())<<1);c=new r.P(t)}return c}function re(t,e,i){if(e<=262144)return function(t,e,i){let s=new r.A(0);for(let t=0;t<e;t++)s.add(t);r.B.sortEx(s,0,e,{userSort(e,i,s){s.sort(e,i,(e,i)=>t[e].compareX(t[i]))},getValue:e=>t[e].x});let o=0;t:for(let r=0;r<e;++r){let e=s.read(r);for(;o>=2;){let a=i[o-2],l=i[o-1];if(t[l].equals(t[e])){s.write(r,-1);continue t}if(!(function(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x>0?-1:0;if(0===s.y)return r.y>0?1:r.y<0?-1:0;let o=s.crossProduct(r),a=4*Number.EPSILON*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}(t[a],t[l],t[e])>=0)){l===s.read(r-1)&&s.write(r-1,-1);break}o--}i[o++]=e,2===o&&t[e].equals(t[i[0]])&&(s.write(1,-1),o--)}let a=o+1;t:for(let r=e-2;r>=0;--r){let e=s.read(r);if(!(e<0)){for(;o>=a;){let s=i[o-2],r=i[o-1];if(t[r].equals(t[e]))continue t;if(!(function(t,e,i){let s=e.sub(t),r=i.sub(e);if(0===s.x)return r.x<0?-1:0;if(0===s.y)return r.y>0?-1:+(r.y<0);let o=s.crossProduct(r),a=4*Number.EPSILON*(Math.abs(r.x*s.y)+Math.abs(r.y*s.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,i)}(t[s],t[r],t[e])>=0))break;o--}if(0!==r){let s=i[o-1];i[o++]=e,t[e].equals(t[s])&&o--}}}return o>1&&t[i[0]].equals(t[i[o-1]])&&o--,o}(t,e,i);(0,s.g)(0);let o=new rn({points:t,n:e}),a=1,l=t[0].clone();for(;a<e&&t[a].equals(l);)a++;if(o.m_treeHull.addElement(0),a<e){o.m_treeHull.addBiggestElement(a);for(let i=a+1;i<e;i++){let e=t[i],s=o.treeHull(e);-1!==s&&o.m_treeHull.setElement(s,i)}}let h=0;for(let t=o.m_treeHull.getFirst();-1!==t;t=o.m_treeHull.getNext(t))i[h++]=o.m_treeHull.getElement(t);return h}function ri(t,e,i){let s=t.getImpl(),r=s.getPathStart(e),o=s.getPathEnd(e),a=!s.isClosedPath(e)&&s.isClosedPathInXYPlane(e),l=s.getAttributeStreamRef(0),h=2*r,m=2*o;if(a&&(m-=2),m-h<6)return!0;let u=l.readPoint2D(h),g=l.readPoint2D(h+2),c=l.readPoint2D(h+4);if(!(0>n.P.orientationRobust(g,c,u)))return!1;let d=g.clone(),_=new n.P;for(let t=h+6;t<m;t+=2)if(_.assign(g),g.assign(c),l.queryPoint2D(t,c),!(0>
1n.P.orientationRobust(g,c,u))||!(0>n.P.orientationRobust(d,c,u))||!(0>n.P.orientationRobust(g,c,_)))return!1;return!0}function rs(t,e,i,r,o){if(i.setNAN(),r.setCoords(1,0),o.setCoords(0,0),t.isEmpty())return;if(t.getGeometryType()===s.G.enumPoint)return void i.assign(t.getXY());let a=t.getPointCount();if(2===a){let e=t.getXY(0),s=t.getXY(1);i.assign(e.add(s).mul(.5));let n=s.sub(e);r=ro(n),o.setCoords(.5*n.length(),0)}else{let l=Number.MAX_VALUE,h=[0,1,0,0],m=new n.ai(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);h[0]<a;++h[0],ra(m,0,a)){let u;h[1]===h[0]&&(++h[1],ra(m,1,a));for(let e=1;;++e){for(;;){let i=function(t,e,i,r,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,s.t)("")}return n.P.orientationRobustEx(t,e,i,r)}(t.getXY(m.get(0,0)),t.getXY(m.get(0,1)),t.getXY(m.get(e,0)),t.getXY(m.get(e,1)),2^e);if(i>0||(++h[e],ra(m,e,a),0===i))break}if(3===e)break;h[e+1]<h[e]&&(h[e+1]=h[e],m.set(e+1,0,m.get(e,0)),m.set(e+1,1,m.get(e,1)))}let g=t.getXY(m.get(0,0)).add(t.getXY(m.get(2,0))).mul(.5),c=ro(t.getXY(m.get(0,1)).sub(t.getXY(m.get(0,0)))),d=new n.P;if(d.x=Math.max(0,c.dotProduct(t.getXY(m.get(1,0)).sub(t.getXY(m.get(3,0))))),d.y=Math.max(0,c.crossProduct(t.getXY(m.get(0,0)).sub(t.getXY(m.get(2,0))))),e?(u=d.x*d.y)<l:(u=d.y)<l){l=u;let e=t.getXY(m.get(1,0)),s=t.getXY(m.get(3,0)),n=e.add(s).mul(.5).sub(g);i.assign(g.add(c.mul(c.dotProduct(n)))),r.assign(c),o.assign(d)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,n.b)(o.x,o.x=o.y),r.leftPerpendicularThis())}r.y<0?r.negateThis():0===r.y&&(r.x=1)}s9.st_defaultRank=1;class rr{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,s.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,s.g)(0),!1}get_vertex_handle_p(){return(0,s.g)(0),0}get_vertex_handle_q(){return(0,s.g)(0),0}get_current_support(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}intialize_(){return(0,s.g)(0),!1}increment_(){return(0,s.g)(0),!1}increment_q_(){return(0,s.g)(0),!1}increment_p_(){return(0,s.g)(0),!1}parallel_edge_with_q_support_(){return(0,s.g)(0),!1}parallel_edge_with_p_support_(){return(0,s.g)(0),!1}done_(){return(0,s.g)(0),!1}}class rn{nullGetXY(t){return(0,s.c)("m_getXY is null"),{}}nullDeleteNode(t){(0,s.c)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new r.T,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=s5,void(this.m_pathHandle=s5)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=s5,void(this.m_pathHandle=s5)):void(0,s.m)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new s9,this.m_geometryHandle=this.m_shape.createGeometry(s.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,s5),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,s.g)(0),new n.P}deleteNodeShape(t){let e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){(0,s.g)(0)}addGeometry(t){if(t.isEmpty())return;let e=t.getGeometryType();if(e===s.G.enumGeometryCollection)for(let e=0,i=t.getGeometryCount();e<i;e++)this.addGeometry(t.getGeometry(e));else(0,s.i)(e)?this.addMultiVertexGeometry(t):(0,s.f)(e)?this.addSegment(t):e===s.G.enumEnvelope?this.addEnvelope(t):e===s.G.enumPoint?this.addPoint(t):(0,s.t)("Convex_hull: geometry not supported")}getBoundingGeometry(){let t=new r.P,e=this.m_treeHull.getFirst(),i=new sm({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return i;i.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),i.startPathPoint(t);for(let s=this.m_treeHull.getNext(e);-1!==s;s=this.m_treeHull.getNext(s))this.m_shape.queryPoint(this.m_treeHull.getElement(s),t),i.lineToPoint(t);return i}getAntipodalPairsIterator(){return(0,s.g)(0),new rr(this)}getXY(t){return(0,s.g)(0),new n.P}getXYWithIndex(t){return(0,s.g)(0),new n.P}getFirst(){return(0,s.g)(0),0}getLast(){return(0,s.g)(0),0}getNext(t){return(0,s.g)(0),0}getPrev(t){return(0,s.g)(0),0}getVertexIndex(t){return(0,s.g)(0),0}getPointCount(){return(0,s.g)(0),0}addMultiVertexGeometry(t){let e=new r.P,i=t.getImpl(),s=new n.P;for(let r=0;r<t.getPointCount();r++){i.queryXY(r,s);let n=this.addPoint2D(s);if(-1!==n){t.getPointByVal(r,e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(n,i)}}}addEnvelope(t){let e=new r.P;for(let i=0;i<4;i++){let s=new n.P;t.queryCorner(i,s);let r=this.addPoint2D(s);if(-1!==r){t.queryCornerByVal(i,e);let s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}addSegment(t){let e=new r.P,i=t.getStartXY(),s=this.addPoint2D(i);if(-1!==s){t.queryStart(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(s,i)}let n=t.getEndXY(),o=this.addPoint2D(n);if(-1!==o){t.queryEnd(e);let i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(o,i)}}addPoint(t){let e=t.getXY(),i=this.addPoint2D(e);if(-1!==i){let e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(i,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return this.m_treeHull.addElement(-4);if(1===this.m_treeHull.size()){let i=this.m_treeHull.getElement(this.m_treeHull.getFirst()),s=this.m_shape.getXY(i);return t.equals(s)||(e=this.m_treeHull.addBiggestElement(-5)),e}return this.treeHull(t)}treeHull(t){let e=-1;do{let i=this.m_treeHull.getFirst(),s=this.m_treeHull.getLast(),r=this.m_treeHull.getElement(i),o=this.m_treeHull.getElement(s),a=this.m_getXY(r),l=this.m_getXY(o),h=n.P.orientationRobust
1(l,t,a);if(h<0){e=this.m_treeHull.addBiggestElement(-1);let r=this.treeHullWalkBackward(t,s,i);r!==i&&this.treeHullWalkForward(t,i,this.m_treeHull.getPrev(r));break}if(h>0){let r=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),l=this.m_treeHull.getLast(),h=-1,m=-1,u=-1;for(;o!==this.m_treeHull.getPrev(l);){m=this.m_treeHull.getElement(r);let e=this.m_getXY(m);n.P.orientationRobust(e,t,a)>0?(l=r,r=this.m_treeHull.getLeft(r)):(o=r,r=this.m_treeHull.getRight(r))}r=l,h=o,m=this.m_treeHull.getElement(r),u=this.m_treeHull.getElement(h);let g=this.m_getXY(m),c=this.m_getXY(u);if(h!==i&&!(0>n.P.orientationRobust(c,t,g)))break;e=this.m_treeHull.addElementAtPosition(h,r,-2,!0,!1),this.treeHullWalkForward(t,r,s),this.treeHullWalkBackward(t,h,i);break}{let r=function(t,e,i){let s=-1;return s=e.y===i.y?0:e.x===i.x?1:Math.abs(e.x-i.x)>=Math.abs(e.y-i.y)?0:1,e[s]<i[s]?t[s]<e[s]?-1:+(i[s]<t[s]):e[s]<t[s]?-1:+(t[s]<i[s])}(t,l,a);if(-1===r){let r=this.m_treeHull.getPrev(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,r,i)}else if(1===r){let r=this.m_treeHull.getNext(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addElementAtPosition(-1,r,-3,!0,!1),this.treeHullWalkForward(t,r,s)}break}}while(0);return e}treeHullWalkForward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getNext(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(0>n.P.orientationRobust(i,t,a))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getNext(s),this.m_deleteNode(l)}return s}treeHullWalkBackward(t,e,i){if(e===i)return i;let s=e,r=this.m_treeHull.getElement(s),o=this.m_treeHull.getPrev(s),a=this.m_getXY(r);for(;s!==i&&this.m_treeHull.size()>2;){let e=this.m_treeHull.getElement(o),i=this.m_getXY(e);if(0>n.P.orientationRobust(a,t,i))break;let l=s;s=o,r=e,a.assign(i),o=this.m_treeHull.getPrev(s),this.m_deleteNode(l)}return s}}function ro(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function ra(t,e,i){t.inc(e,0)===i&&t.set(e,0,0),t.inc(e,1)===i&&t.set(e,1,0)}function rl(t,e,i,s,r){return rh(t,!1,e,i,s,r)}function rh(t,e,i,r,n,o){let a=i.getGeometryType(),l=r.getGeometryType(),h=Math.max(n,R(i,r));if(a===s.G.enumLine&&l===s.G.enumLine)return te(i,r,h,o);let m=i,u=r,g=i.getStartXY(),c=i.getEndXY();if(g.compare(c)>0&&(m=i.clone().reverse()),g=r.getStartXY(),c=r.getEndXY(),g.compare(c)>0&&(u=r.clone().reverse()),e){if(i.equals(r))return 2;if((0,s.g)(i.isCurve()||r.isCurve()),i.getStartXY().equals(r.getStartXY())&&D(i,r,0,0,h,2,[0,0],[0,0])||i.getEndXY().equals(r.getEndXY())&&D(i,r,1,1,h,2,[0,0],[0,0])||i.getStartXY().equals(r.getEndXY())&&D(i,r,0,1,h,2,[0,0],[0,0])||i.getEndXY().equals(r.getStartXY())&&D(i,r,1,0,h,2,[0,0],[0,0])||0)return 4}switch(a){case s.G.enumLine:switch(l){case s.G.enumEllipticArc:return sK(t,u,m,h,o);case s.G.enumBezier:return iV(t,u,m,h,o);case s.G.enumRationalBezier2:return eC(t,u,m,h,o);case s.G.enumBezier2:return it(t,u,m,h,o);default:(0,s.c)("")}break;case s.G.enumEllipticArc:switch(l){case s.G.enumLine:return sK(t,m,u,h,o);case s.G.enumEllipticArc:var d=m,_=u;if(o){if(0!==rm(d,_))return 2}else if(C(d,_))return 1;return 4*(0!==s0(t,d,_,null,null,null,h,void 0!==o&&o,!0,!1));case s.G.enumBezier:return iL(t,u,m,h,o);case s.G.enumRationalBezier2:return eb(t,u,m,h,o);case s.G.enumBezier2:return ie(t,u,m,h,o);default:(0,s.c)("")}break;case s.G.enumBezier:switch(l){case s.G.enumLine:return iV(t,m,u,h,o);case s.G.enumEllipticArc:return iL(t,m,u,h,o);case s.G.enumBezier:var p=m,f=u;if(o){if(0!==rm(p,f))return 2}else if(C(p,f))return 1;return 4*(0!==iB(t,p,f,null,null,null,h,void 0!==o&&o,!0,!1));case s.G.enumRationalBezier2:return iR(t,m,u,h,o);case s.G.enumBezier2:return iz(t,m,u,h,o);default:(0,s.c)("")}break;case s.G.enumRationalBezier2:switch(l){case s.G.enumLine:return eC(t,m,u,h,o);case s.G.enumEllipticArc:return eb(t,m,u,h,o);case s.G.enumBezier:return iR(t,u,m,h,o);case s.G.enumRationalBezier2:var P=m,y=u;if(o){let e=rm(P,y);if(0!==e){if(t){if(1===e){if(P.m_weights[0]===y.m_weights[0]&&P.m_weights[1]===y.m_weights[1]&&P.m_weights[2]===y.m_weights[2])return 2}else if(P.m_weights[0]===y.m_weights[2]&&P.m_weights[1]===y.m_weights[1]&&P.m_weights[2]===y.m_weights[0])return 2;return 4}return 2}}else if(C(P,y))return 1;
1return 4*(0!==ew(t,P,y,null,null,null,h,void 0!==o&&o,!0,!1));case s.G.enumBezier2:return eE(t,m,u,h,o);default:(0,s.c)("")}break;case s.G.enumBezier2:switch(l){case s.G.enumLine:return it(t,m,u,h,o);case s.G.enumEllipticArc:return ie(t,m,u,h,o);case s.G.enumBezier:return iz(t,u,m,h,o);case s.G.enumRationalBezier2:return eE(t,u,m,h,o);case s.G.enumBezier2:var x=m,v=u;if(o){if(0!==rm(x,v))return 2}else if(C(x,v))return 1;return 4*(0!==ir(t,x,v,null,null,null,h,o??!1,!0,!1));default:(0,s.c)("")}break;default:(0,s.c)("")}}function rm(t,e,i=!0){if(!i&&!ru(t,e))return 0;let r=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){if(r)return 1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier)return t.getControlPoint1().equals(e.getControlPoint1())&&t.getControlPoint2().equals(e.getControlPoint2())?1:0;if(i===s.G.enumEllipticArc)return+!!s3(t,e,!1);if(i===s.G.enumRationalBezier2){if(t.getControlPoint1().equals(e.getControlPoint1())&&t.getStandardFormWeight()===e.getStandardFormWeight())return 1}else if(i===s.G.enumBezier2&&t.getControlPoint1().equals(e.getControlPoint1()))return 1;return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){if(r)return -1;let i=t.getGeometryType();if(i!==e.getGeometryType())return 0;if(i===s.G.enumBezier)return t.getControlPoint1().equals(e.getControlPoint2())&&t.getControlPoint2().equals(e.getControlPoint1())?-1:0;if(i===s.G.enumEllipticArc)return s3(t,e,!0),-1;if(i===s.G.enumRationalBezier2){if(t.getControlPoint1().equals(e.getControlPoint1())&&t.getStandardFormWeight()===e.getStandardFormWeight())return -1}else if(i===s.G.enumBezier2&&t.getControlPoint1().equals(e.getControlPoint1()))return -1}return 0}function ru(t,e){let i=t.getGeometryType();return i===e.getGeometryType()&&(i!==s.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function rg(t,e,i,r,n,o,a){!n&&o&&(0,s.t)("");let l=e.getGeometryType(),h=i.getGeometryType(),m=Math.max(a,R(e,i));if(r&&(r.length=0),n&&(n.length=0),o&&(o.length=0),l===s.G.enumLine&&h===s.G.enumLine)return ti(e,i,r,n,o,m,!1,!1);let u=e,g=i,c=e.getStartXY(),d=e.getEndXY(),_=!1,p=!1;c.compare(d)>0&&(u=e.clone(!0).reverse(),_=!0),c=i.getStartXY(),d=i.getEndXY(),c.compare(d)>0&&(g=i.clone(!0).reverse(),p=!0);let f=0;switch(l){case s.G.enumLine:switch(h){case s.G.enumEllipticArc:f=s$(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumBezier:f=iG(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=eS(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumBezier2:f=ii(t,g,u,r,o,n,m,!1,!1,!0);break;default:(0,s.c)("")}break;case s.G.enumEllipticArc:switch(h){case s.G.enumLine:f=s$(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumEllipticArc:f=s0(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=ik(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=eD(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumBezier2:f=is(t,g,u,r,o,n,m,!1,!1,!0);break;default:(0,s.c)("")}break;case s.G.enumRationalBezier2:switch(h){case s.G.enumLine:f=eS(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumEllipticArc:f=eD(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=iW(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=ew(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=eA(t,u,g,r,n,o,m,!1,!1,!1);break;default:(0,s.c)("")}break;case s.G.enumBezier2:switch(h){case s.G.enumLine:f=ii(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumEllipticArc:f=is(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=ij(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumRationalBezier2:f=eA(t,g,u,r,o,n,m,!1,!1,!0);break;case s.G.enumBezier2:f=ir(t,u,g,r,n,o,m,!1,!1,!1);break;default:(0,s.c)("")}break;case s.G.enumBezier:switch(h){case s.G.enumLine:f=iG(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumEllipticArc:f=ik(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier:f=iB(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumRationalBezier2:f=iW(t,u,g,r,n,o,m,!1,!1,!1);break;case s.G.enumBezier2:f=ij(t,u,g,r,n,o,m,!1,!1,!1);break;default:(0,s.c)("")}break;default:(0,s.c)("")}if(_){if(n){for(let t=0;t<f;t++)n[t]=1-n[t];n.reverse()}r&&r.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function rc(t,e,i){return e===i?0:(e>i&&(i=(0,n.b)(e,e=i)),t.cut(e,i,!0).calculateUpperLength2D())}
1function rd(t,e,i,s,r,o,a,l,h,m,u,g,c){if(!o)return 0;let d=(t,e)=>{for(let i=0;i<o;++i){let s=e[i];if((0,n.J)(s,0,1)){s=(0,n.al)(s);continue}let r=t.getCoord2D(s);s<.5?r.equals(t.getStartXY())&&rc(t,0,s)<=L(t)&&(e[i]=0):r.equals(t.getEndXY())&&rc(t,s,1)<=L(t)&&(e[i]=1)}};d(e,s),d(i,r),function(t,e,i,s,r){let o=[],a=[],l=[];for(let h=0;h<r;h++)o.push(t.calculateSubLengthFromStart(i[h])),a.push(e.calculateSubLengthFromStart(s[h])),(0,n.J)(i[h],0,1)&&(0,n.J)(s[h],0,1)&&t.getCoord2D(i[h]).equals(e.getCoord2D(s[h]))&&l.push(h);if(0===l.length||l.length===r)return;l.sort((t,e)=>i[t]<i[e]?-1:i[t]>i[e]?1:s[t]<s[e]?-1:+(s[t]>s[e]));let h=-1;for(let m of l){if(h>=0&&i[m]===i[h]&&i[m]===i[h]){h=m;continue}h=m;let l=[];l.length=r;for(let t=0;t<l.length;++t)l[t]=t;l.sort((t,e)=>{let i=o[m],s=a[m],r=o[t]-i,n=a[t]-s,l=r*r+n*n,h=o[e]-i,u=a[e]-s,g=h*h+u*u;return l<g?-1:+(l>g)});for(let o=0;o<r;o++){let r=l[o];if(r===m||i[r]===i[m]&&s[r]===s[m]||(0,n.J)(i[r],0,1)&&(0,n.J)(s[r],0,1))continue;let a=(i,s,r,o)=>{let a=new y,l=new n.F;l.setWithEps(1);let h=new n.F;h.set(s,l.eps()),t.queryCoord2DE(h,a);let m=new y;t.queryCoord2DE(new n.F(i),m);let u=!1;return a.eq(m)&&(h.set(o,l.eps()),e.queryCoord2DE(h,a),e.queryCoord2DE(new n.F(r),m),u=a.eq(m)),!u},h=n.P.getNAN();t.queryCoord2D(i[r],h);let u=n.P.getNAN();if(e.queryCoord2D(s[r],u),0===n.P.distance(h,u)&&a(i[m],i[r],s[m],s[r]))break;let g=new n.E(s[r],s[m]);g.normalizeNoNAN();let c=new n.E(i[r],i[m]);c.normalizeNoNAN();let d=-1,_=1/0,p=1/0,f=i[r];h.assign(t.getCoord2D(f));for(let o=0;o<5;o++){let o=e.getClosestCoordinateOnInterval(h,g,-1);u.assign(e.getCoord2D(o));let l=n.P.distance(h,u);if((f=t.getClosestCoordinateOnInterval(u,c,-1))===i[m]&&o===s[m]){d=1;break}h.assign(t.getCoord2D(f));let P=n.P.distance(u,h);if(!(P<p&&l<_)){d=0;break}if(0===P&&0===l){a(i[m],i[r],s[m],s[r])?(i[r]=f,s[r]=o,d=0):d=1;break}p=P,_=l}if(-1===d&&(d=(0,n.J)(i[r],0,1)||(0,n.J)(s[r],0,1)?0:1),1!==d)break;i[r]=i[m],s[r]=s[m]}}}(e,i,s,r,o);let _=[];for(let t=0;t<o;t++)_.push(t);let p=(t,e)=>c?(0,n.am)(r[t],s[t],r[e],s[e]):(0,n.am)(s[t],r[t],s[e],r[e]);if(_.length>1){_.sort(p);let t=Math.max(L(e),L(i)),o=0;for(let a=1,l=_.length;a<l;a++){let l=s[_[o]],h=s[_[a]],m=r[_[o]],u=r[_[a]];if(l!==h||m!==u)if(!(rc(e,l,h)<=t&&rc(i,m,u)<=t)||(0,n.J)(l,0,1)&&(0,n.J)(m,0,1)||(0,n.J)(h,0,1)&&(0,n.J)(u,0,1))_[++o]=_[a];else{let t=n.P.distance(e.getCoord2D(l),i.getCoord2D(m)),s=n.P.distance(e.getCoord2D(h),i.getCoord2D(u));if(t<=s)continue;if(s<t){_[o]=_[a];continue}}}if(_.length=o+1,1===_.length&&0!==_[0]&&(s[0]=s[_[0]],r[0]=r[_[0]],_[0]=0),_.length>2){let t=n.E.constructEmpty(),o=n.E.constructEmpty();t.setCoords(s[_[0]],s[_.at(-1)]),o.setCoords(r[_[0]],r[_.at(-1)]);let a=!0;for(let e=1,i=_.length-1;e<i;e++)if(!t.containsCoordinate(s[_[e]])||!o.containsCoordinate(r[_[e]])){a=!1;break}if(a){let s=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let r=0;r<s.length;r++){let l=(0,n.q)(t.vmin,t.vmax,s[r]),h=e.getCoord2D(l);if(!i.isCloserThanDistance(h,o,m)){a=!1;break}l=(0,n.q)(o.vmin,o.vmax,s[r]);let u=i.getCoord2D(l);if(!e.isCloserThanDistance(u,t,m)){a=!1;break}}}a&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t&&D(e,i,s[0],r[0],m,1,[0],[0])&&(_.push(1),s[1]=0,r[1]=0,_.sort(p)),u&&1===_.length){let t=!0;for(let o=0,a=_.length;o<a;o++)if(!((0,n.J)(s[_[o]],0,1)&&(0,n.J)(r[_[o]],0,1))||0!==n.P.distance(e.getCoord2D(s[_[o]]),i.getCoord2D(r[_[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,i=_.length;t<i;t++){if(l&&l.push(s[_[t]]),h&&h.push(r[_[t]]),a){let i=n.P.getNAN();e.queryCoord2D(s[_[t]],i),a.push(i)}f++}return f}function r_(t,e,i,s,r,o,a,l,h){if((0,n.J)(i,0,1)&&(0,n.J)(s,0,1)&&0===n.P.distance(t.getCoord2D(i),e.getCoord2D(s))){let m=new y,u=Number.EPSILON;if(t.queryDerivative(new n.F(i,u),m),m.isTrueZero()){let e=1===i?-1e-12:1e-12;t.queryDerivative(new n.F(i,u).add(e),m)}1===i&&m.negateThis();let g=new y;if(e.queryDerivative(new n.F(s,u),g),g.isTrueZero()){let t=1===i?-1e-12:1e-12;e.queryDerivative(new n.F(s,u).add(t),g)}1===s&&g.negateThis(),m.isZero()||m.normalize(),g.isZero()||g.normalize();let c=m.dotProduct(g),d=m.crossProduct(g);
1if(d.scaleError(3),c.ge(n.H)&&(d.isZero()||Math.abs(d.value())<(h?.001:Math.min(.01*r/Math.min(t.calculateUpperLength2D(),e.calculateUpperLength2D()),1e-10))))return S(t,e,i,s,r,o,a,l)}return 0}function rp(t,e,i,r,o){let a=-1,l=-1,h=-1,m=-1;{let s=[0,e],n=[e,0],o=[0,r],u=[r,0];for(let e=0;e<2&&-1===a;++e)for(let r=0;r<2;++r)if(t[s[e]].equals(i[o[r]])){a=s[e],l=n[e],h=o[r],m=u[r];break}}if(-1===a){let s=new p;s.setFromPoints(t,e+1);let n=new p;return n.setFromPoints(i,r+1),n.inflate(o),s.isIntersectingW(n)?-1:0}{let u=(0,n.d)(e+1,NaN),g=re(t,e+1,u);(0,s.g)(g>1);let c=0,d=0;for(let t=0;t<g;++t)a===u[t]&&(d=t,c++),l===u[t]&&c++;if(2!==c)return -1;let _=(0,n.d)(r+1,NaN),p=re(i,r+1,_);(0,s.g)(p>1),c=0;let f=0;for(let t=0;t<p;++t)h===_[t]&&(f=t,c++),m===_[t]&&c++;if(2!==c)return -1;let P=t[u[(d+g-1)%g]],y=t[u[(d+1)%g]],x=i[_[(f+p-1)%p]],v=i[_[(f+1)%p]],C=t[a],b=[P,y,x,v],E=[0,1,2,3];E.sort((t,e)=>n.P.compareVectorsOrigin(C,b[t],b[e]));let S=E[0];for(let t=1;t<4;t++){if(E[t]!==(S+1)%4)return -1;S=E[t]}{let t=P.sub(C),e=v.sub(C),i=e.dotProduct(t);if(i>0){let s=Math.abs(Math.atan2(e.crossProduct(t),i)),r=s*t.length(),n=s*e.length();if(r<=o||n<=o)return -1}}{let t=y.sub(C),e=x.sub(C),i=e.dotProduct(t);if(i>0){let s=Math.abs(Math.atan2(e.crossProduct(t),i)),r=s*t.length(),n=s*e.length();if(r<=o||n<=o)return -1}}return 1}}var rf=r.V;class rP extends U{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}calculateLowerLength3D(){return(0,s.g)(0),0}calculateUpperLength3D(){return(0,s.g)(0),0}changeEndPoints3D(t,e){(0,s.g)(0)}getClosestCoordinate3D(t,e,i){return(0,s.g)(0),0}getBoundary(){return i7(this)}getAttributeAsDbl(t,e,i){if(0===e)return 0===i?J(this,t):Q(this,t);let s=rf.getInterpolation(e),r=this.getStartAttributeAsDbl(e,i),o=this.getEndAttributeAsDbl(e,i);return(0,n.T)(s,r,o,t,rf.getDefaultValue(e))}constructFromCoords(t,e,i,s){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(i,s)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}construct3D(t,e){(0,s.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return rP.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);let e=o.J.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){let i=this.m_description.getSemantics(e);for(let s=rf.getComponentCount(i);e<s;e++){let e=this.queryInterval(i,0);t.setIntervalEnvelope(i,0,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,F(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,F(this,1,1,0))):(0,s.b)("env type not impl")}applyTransformation(t){(0,s.g)(t instanceof a.T);let e=new n.P;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new rP({vd:this.m_description})}calculateLength2D(){return Math.sqrt(ta(this))}calculateLength3D(t){return(0,s.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryCoord2D(t,e){return O(this,t,e)}queryCoord3D(t,e){(0,s.g)(0)}getCoordZ(t){let e=this.getStartZ(),i=this.getEndZ();return(0,n.q)(e,i,t)}queryCoord2DE(t,e){K(this,t,e)}getCoordX(t){return J(this,t)}getCoordY(t){return Q(this,t)}cut(t,e,i){let s=new ry;return this.queryCut(t,e,s,i),s.releaseSegment()}queryCut(t,e,i,s){let r=i.createLine();s&&r.assignVertexDescription(this.m_description);let o=n.P.getNAN();if(O(this,t,o),r.setStartXYCoords(o.x,o.y),O(this,e,o),r.setEndXYCoords(o.x,o.y),!s)for(let i=1,s=this.m_description.getAttributeCount();i<s;i++){let s=this.m_description.getSemantics(i),n=rf.getComponentCount(s);for(let i=0;i<n;i++){let n=this.getAttributeAsDbl(t,s,i);r.setStartAttribute(s,i,n);let o=this.getAttributeAsDbl(e,s,i);r.setEndAttribute(s,i,o)}}}queryDerivative(t,e){let i=y.constructPoint2D(this.getStartXY()),s=y.constructPoint2D(this.getEndXY());e.setCoordsE(s.x.subE(i.x),s.y.subE(i.y))}getClosestCoordinate(t,e){return n.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}
1getClosestCoordinateOnInterval(t,e,i=-1){let s=new n.P;this.queryCoord2D(e.vmin,s);let r=new n.P;this.queryCoord2D(e.vmax,r);let o=n.P.getClosestCoordinate(s,r,t,!1);return B.recalculateParentT(e.vmin,e.vmax,o)}intersectionOfYMonotonicWithAxisX(t,e){let i=this.m_YEnd-this.m_YStart;if(!i)return t===this.m_YEnd?e:NaN;let s=(t-this.m_YStart)/i,r=J(this,s);return 1===s&&(r=this.m_XEnd),r}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){let e=this.m_XStart-this.m_XEnd,i=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+i*i)<=t}isDegenerate3D(t,e){return(0,s.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){let e=new rP;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){let e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){let e=new n.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){let e=n.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){let e=new n.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,i){return ts(this,t,e,i)>=0}isIntersectingPoint3D(t,e,i,r,n=1){return(0,s.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,s.t)(""),e[0]=0,e[1]=1),2}intersectionWithAxis2D(t,e,i,s){if(t){let t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;let r=(e-this.m_YStart)/t;return r<0||r>1?0:(i&&(i[0]=J(this,r)),s&&(s[0]=r),1)}{let t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;let r=(e-this.m_XStart)/t;return r<0||r>1?0:(i&&(i[0]=Q(this,r)),s&&(s[0]=r),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let i=(0,n.c)(t.vmin,0,1),s=new n.P;return this.queryCoord2D(i,s),e.setCoords({pt:s}),i=(0,n.c)(t.vmax,0,1),this.queryCoord2D(i,s),void e.mergeNe(s)}(0,s.b)("3d dst not impl")}orientBottomUp(){tt(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){let e=this.getStartXYZ();e.z*=t;let i=this.getEndXYZ();return i.z*=t,e.norm(1)+i.norm(1)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(t,e){$(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,s.g)(0),0}readFromBufferStream(t,e){(0,s.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,i){$(this,t,e)}static isIntersectingLineLine(t,e,i,s){return te(t,e,i,s)}static isIntersectingLineLine_(t,e,i,s){return te(t,e,i,s)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,i,s,r){return rg(!1,this,t,e,i,s,r)}intersectPoint(t,e,i){e.length<1&&(0,s.n)("");let r=ts(this,t,i,!1);return r>=0?(e&&(e[0]=r),1):0}isIntersecting(t,e,i){return 0!==rl(!1,this,t,e,i)}}rP.type=s.G.enumLine;class ry{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new rP,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,s.c)("bad constructor params"))}assignCopy(t){return t instanceof ry?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof ry){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,s.c)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,s.g)(0)}createImpl(t){switch(t){case s.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new rP,this.m_mask|=1,this.m_active=1);break;case s.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new sh,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case s.G.enumBezier:4&this.m_mask||(this.m_curves=new im,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case s.G.enumBezier2:8&this.m_mask||(this.m_curves=new tI,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case s.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new tY,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,s.t)("")}}create(t){t===s.G.enumLine?this.createLine():t===s.G.enumEllipticArc?this.createEllipticArc():t===s.G.enumBezier?this.createCub
1icBezier():t===s.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===s.G.enumBezier2?this.createQuadraticBezier():(0,s.t)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,s.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(s.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(s.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(s.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(s.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(s.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){let t;if(this.m_seg=null,0===this.m_active&&(0,s.c)("releaseSegment"),1&this.m_active){let t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,s.c)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof ry?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,s.b)("seg comparison not yet impl"),!1)}}}}]); 2//# sourceMappingURL=377d7967.9bc69679ec48d9ff.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.