/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/maybe","../../core/quantityUtils","../../core/unitUtils","../../chunks/earcut","../../chunks/vec3","../../chunks/vec3f64","../../geometry/projection","../../geometry/support/plane","../../geometry/support/triangle","../../geometry/support/vectorStacks","./measurementUtils"],(function(e,t,n,r,o,c,a,l,u,i,s,f){"use strict";function p(e,t=m()){return d(e,t)}function g(e,t=m()){return d(e,t,!1)}function d(e,o,p=e.hasZ){const g=f.computeEuclideanMeasurementSR(e.spatialReference),d=r.areaUnitFromSpatialReference(g);if(t.isNone(d))return null;const m=(e,t)=>!(t.length<2)&&(c.set(e,t[0],t[1],p&&t[2]||0),!0);let P=0;for(const t of e.rings){if(t.length<3)continue;const{positionsWorldCoords:n}=o;for(;n.length<t.length;)n.push(a.create());const r=h;for(let o=0;o<3;o++){if(!m(r,t[o]))return null;if(!l.projectVectorToVector(r,e.spatialReference,n[o],g))return null}if(c.exactEquals(n[0],n[1])||c.exactEquals(n[0],n[2])||c.exactEquals(n[1],n[2]))continue;const f=u.fromPoints(n[0],n[1],n[2],u.wrap()),p=c.copy(s.sv3d.get(),n[0]);for(let e=0;e<3;e++)u.projectPointLocal(f,p,n[e],n[e]);for(let o=3;o<t.length;o++){if(!m(r,t[o]))return null;l.projectVectorToVector(r,e.spatialReference,n[o],g),u.projectPointLocal(f,p,n[o],n[o])}const d=y(n);for(let e=0;e<d.length;e+=3)P+=i.areaPoints2d(n[d[e]],n[d[e+1]],n[d[e+2]])}return n.createArea(P,d)}const h=a.create();function m(){return{positionsWorldCoords:[]}}function y(e){return o.earcut(P(e),[],2)}function P(e){const t=new Float64Array(2*e.length);for(let n=0;n<e.length;++n){const r=e[n],o=2*n;t[o+0]=r[0],t[o+1]=r[1]}return t}e.computeEuclideanPlanarArea=d,e.createEuclideanPlanarAreaCache=m,e.euclideanHorizontalPlanarArea=g,e.euclideanPlanarArea=p,e.triangulate=y,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
