/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import e from"../Dictionary.js";import{StringEnum as n}from"../enum.js";import{ArcadeExecutionError as t}from"../executionError.js";import{B as r,s as o,J as i,C as l,j as a,F as s,K as f}from"../../chunks/languageUtils.js";import{getMetersPerVerticalUnitForSR as c,segmentLength3d as u}from"../functions/centroid.js";import{measureToCoordinate as m,pointToCoordinate as p,distanceToCoordinate as d}from"../functions/measures.js";import{getMetersPerUnitForSR as g}from"../../core/units.js";import w from"../../geometry/Geometry.js";import y from"../../geometry/Point.js";import h from"../../geometry/Polyline.js";import{isArray as v,isNumber as j}from"../../support/guards.js";function P(e,n,o){if(r(e,2,2,n,o),e[0]instanceof w&&e[1]instanceof w);else if(e[0]instanceof w&&null===e[1]);else if(e[1]instanceof w&&null===e[0]);else if(null!==e[0]||null!==e[1])throw new t(n,"InvalidParameter",o)}function x(e){if("polygon"!==e.type&&"polyline"!==e.type&&"extent"!==e.type)return 0;let n=1;if(e.spatialReference.vcsWkid||e.spatialReference.latestVcsWkid){n=c(e.spatialReference)/g(e.spatialReference)}let t=0;if("polyline"===e.type)for(const r of e.paths)for(let e=1;e<r.length;e++)t+=u(r[e],r[e-1],n);else if("polygon"===e.type)for(const r of e.rings){for(let e=1;e<r.length;e++)t+=u(r[e],r[e-1],n);(r[0][0]!==r[r.length-1][0]||r[0][1]!==r[r.length-1][1]||void 0!==r[0][2]&&r[0][2]!==r[r.length-1][2])&&(t+=u(r[0],r[r.length-1],n))}else"extent"===e.type&&(t+=2*u([e.xmin,e.ymin,0],[e.xmax,e.ymin,0],n),t+=2*u([e.xmin,e.ymin,0],[e.xmin,e.ymax,0],n),t*=2,t+=4*Math.abs(i(e.zmax,0)*n-i(e.zmin,0)*n));return t}const I=(n,o,i)=>{if(i=l(i),r(i,2,2,n,o),null===i[0])return null;let c=i[0];if((v(i[0])||a(i[0]))&&(c=s(i[0],n.spatialReference)),null===c)return null;if(!(c instanceof w))throw new t(n,"InvalidParameter",o);if(!(c instanceof h))throw new t(n,"InvalidParameter",o);if(!j(i[1]))throw new t(n,"InvalidParameter",o);const u=m(c,i[1]);return u?e.convertObjectToArcadeDictionary(u,f(n),!1,!0):null},R=(n,o,i)=>{if(i=l(i),r(i,2,2,n,o),null===i[0])return null;let c=i[0];if((v(i[0])||a(i[0]))&&(c=s(i[0],n.spatialReference)),null===c)return null;if(!(c instanceof w))throw new t(n,"InvalidParameter",o);if(!(c instanceof h))throw new t(n,"InvalidParameter",o);const u=i[1];if(null===u)return null;if(!(u instanceof y))throw new t(n,"InvalidParameter",o);const m=p(c,u);return m?e.convertObjectToArcadeDictionary(m,f(n),!1,!0):null},b=(n,o,i)=>{if(i=l(i),r(i,2,2,n,o),null===i[0])return null;let c=i[0];if((v(i[0])||a(i[0]))&&(c=s(i[0],n.spatialReference)),null===c)return null;if(!(c instanceof w))throw new t(n,"InvalidParameter",o);if(!(c instanceof h))throw new t(n,"InvalidParameter",o);if(!j(i[1]))throw new t(n,"InvalidParameter",o);const u=d(c,i[1]);return u?e.convertObjectToArcadeDictionary(u,f(n),!1,!0):null},k=new n(["geodesic","great-elliptic","loxodrome","normal-section","shape-preserving"]);function D(e){return null==e?"geodesic":k.get(o(e))}const A=new n(["geometric","labelPoint"]);function O(e){return null==e?"geometric":A.get(o(e))}const T=new n(["round","bevel","miter","square"]);function z(e){return null==e?"round":T.lookup(o(e))??"round"}export{P as commonRelationsCheck,b as distanceToCoordinateFunc,I as measureToCoordinateFunc,x as planarLength3D,R as pointToCoordinateFunc,O as toCentroidAlgorithm,D as toCurveType,z as toOffsetJoinType};
