/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{S as e}from"../../../chunks/SimpleGeometryCursor.js";import{G as t}from"../../../chunks/GeometryCursor.js";import{d as n,c as r,G as s}from"../../../chunks/Geometry.js";import{P as o,d as i}from"../../../chunks/Point2D.js";import{M as m}from"../../../chunks/MultiPathImpl.js";import{Envelope2D as u}from"../../../chunks/Envelope2D.js";import{c,f as a}from"../../../chunks/Envelope.js";import{ax as p}from"../../../chunks/SpatialReference.js";class l{getOperatorType(){return 10003}supportsCurves(){return!0}accelerateGeometry(e,t,n){return!1}canAccelerateGeometry(e){return!1}executeMany(e,t,n,r){return new y(e,t,n,r)}execute(t,r,s,o){const i=new e([t]),m=new e([r]),u=this.executeMany(i,m,s,o).next();return u||n("null output"),u}}function h(e,t,n,r){const o=e.getDimension(),i=t.getDimension();if(o!==i)return o>i?e:t;if(e.isEmpty())return t;if(t.isEmpty())return e;const m=new u,a=new u,l=new u;e.queryEnvelope(m),t.queryEnvelope(a),l.setCoords({env2D:m}),l.mergeEnvelope2D(a);const h=c(n,l,!0),y=e.getGeometryType(),g=t.getGeometryType();return y===s.enumPoint&&g===s.enumPoint?f(e,t,h):y===s.enumPoint&&g===s.enumMultiPoint?d(t,e,h):y===s.enumMultiPoint&&g===s.enumPoint?d(e,t,h):p(e,t,n,r)}function f(e,t,n,r){const s=a(n),i=s*s,u=e.getXY(),c=t.getXY(),p=new m({vd:e.getDescription()});return o.sqrDistance(u,c)>i&&(p.add(e),p.add(t)),p}function d(e,t,n,r){const s=e.getImpl().getAttributeStreamRef(0),o=e.getPointCount(),m=t.getXY(),c=e.createInstance(),p=a(n),l=new u;if(e.queryEnvelope(l),l.inflateCoords(p,p),l.contains(m)){const n=p*p;let r=!1;const u=i(o,!1);for(let e=0;e<o;e++){const t=s.read(2*e),o=s.read(2*e+1),i=t-m.x,c=o-m.y;i*i+c*c<=n&&(r=!0,u[e]=!0)}if(r)for(let t=0;t<o;t++)u[t]||c.addPoints(e,t,t+1);else c.addPoints(e,0,o),c.add(t)}else c.addPoints(e,0,o),c.add(t);return c}class y extends t{m_inputGeoms;m_progressTracker;m_spatialReference;m_rightGeom;m_index;m_bEmpty;constructor(e,t,n,s){super(),this.m_progressTracker=s,this.m_index=-1,this.m_inputGeoms=e,this.m_spatialReference=n,this.m_rightGeom=t.next(),this.m_bEmpty=!this.m_rightGeom,r(this.m_rightGeom)}tock(){return!0}getRank(){return 1}next(){if(this.m_bEmpty)return null;const e=this.m_inputGeoms.next();return e?(r(e),this.m_index=this.m_inputGeoms.getGeometryID(),h(e,this.m_rightGeom,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}}const g=new l;function _(e,t,n){return g.execute(e,t,n,null)}function G(t,n,r){const s=g.executeMany(new e(t),new e([n]),r,null);return Array.from(s)}function x(){return g.supportsCurves()}export{_ as execute,G as executeMany,x as supportsCurves};
