/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{asinClamped as t,deg2rad as n,rad2deg as o}from"../../../core/mathUtils.js";import{getReferenceEllipsoid as e}from"../../../geometry/ellipsoidUtils.js";import r from"../../../geometry/Point.js";function u(t,n,o){if(null==n.longitude||null==n.latitude||null==o.longitude||null==o.latitude)throw new Error("Invalid points: no lon/lat");return i(t,n.longitude,n.latitude,o.longitude,o.latitude)}function i(o,e,r,u,i){const s=n(r),l=n(i),a=s-l,c=n(e)-n(u),d=Math.sin(a/2),h=Math.sin(c/2),m=2*t(Math.sqrt(d*d+Math.cos(s)*Math.cos(l)*h*h))*o;return Math.round(1e4*m)/1e4}function s(t,n,o){const i=n.spatialReference,s=e(i),l=new r(n.x,t.y,i),a=new r(o.x,t.y,i),c=new r(t.x,n.y,i),d=new r(t.x,o.y,i);return{lon:u(s.radius,l,a),lat:u(s.radius,c,d)}}function l(e,r,u){const i=r/u,s=n(e),l=Math.sin(i/2),a=Math.cos(s),c=2*t(Math.sqrt(l*l/(a*a)));return o(c)}function a(t,n){let o=t/15;return n||(o=Math.round(o)),o}function c(t,n){const o=t?.[0];if(null==o)return null;n||(n={hours:0,minutes:0,seconds:0}),n.hours=a(o,!0);const e=n.hours%1;n.hours-=e,n.minutes=60*e;const r=n.minutes%1;return n.minutes-=r,n.seconds=Math.round(60*r),n}export{i as getGreatCircleDistance,u as getGreatCircleDistanceFromPoints,s as getGreatCircleSpanAt,l as getLonDeltaForDistance,a as longitudeToTimezone,c as positionToTimezoneInfo};
