// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["exports","../Dictionary","../executionError","../../chunks/languageUtils","../../core/maybe"],function(x,N,f,r,X){function D(a){if(!1===r.isString(a))throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.InvalidParameter,null);return a}function H(a,b){b=10**b;return Math.round(a*b)/b}function y(a){const b=parseFloat(a.toString().replace(Math.trunc(a).toString(),"0"))*Math.sign(a);return 0>a?{fraction:b,integer:Math.ceil(a)}:{fraction:b,integer:Math.floor(a)}}function z(a,b){switch(a){case h.north:return"SHORT"=== b?"N":"North";case h.east:return"SHORT"===b?"E":"East";case h.south:return"SHORT"===b?"S":"South";case h.west:return"SHORT"===b?"W":"West"}}function I(a,b){return a-Math.floor(a/b)*b}function J(a){switch(a){case e.truncated_degrees:case e.decimal_degrees:return 360;case e.radians:return Y;case e.gradians:return 400;case e.seconds:return 1296E3;case e.fractional_degree_minutes:return 60;case e.fractional_minute_seconds:return 60;default:throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError, null,{reason:"unsupported evaluations"});}}function O(a){switch(a.toUpperCase().trim()){case "NORTH":case "NORTHAZIMUTH":case "NORTH AZIMUTH":return g.north_azimuth;case "POLAR":return g.polar;case "QUADRANT":return g.quadrant;case "SOUTH":case "SOUTHAZIMUTH":case "SOUTH AZIMUTH":return g.south_azimuth}throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"unsupported directionType"});}function P(a){switch(a.toUpperCase().trim()){case "D":case "DD":case "DECIMALDEGREE":case "DECIMAL DEGREE":case "DEGREE":case "DECIMALDEGREES":case "DECIMAL DEGREES":case "DEGREES":return e.decimal_degrees; case "DMS":case "DEGREESMINUTESSECONDS":case "DEGREES MINUTES SECONDS":return e.degrees_minutes_seconds;case "R":case "RAD":case "RADS":case "RADIAN":case "RADIANS":return e.radians;case "G":case "GON":case "GONS":case "GRAD":case "GRADS":case "GRADIAN":case "GRADIANS":return e.gradians}throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"unsupported units"});}function Q(a,b,c){let d=null;switch(b){case e.decimal_degrees:d=w(a,3600);break;case e.seconds:d=a;break;case e.gradians:d= w(a,3240);break;case e.radians:d=w(a,R);break;default:throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"unexpected evaluation"});}switch(c){case e.decimal_degrees:return E(d,3600);case e.seconds:return d;case e.gradians:return E(d,3240);case e.radians:return d/R;default:throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"unexpected evaluation"});}}function F(a){X.assertIsSome(a);switch(a){case e.decimal_degrees:case e.truncated_degrees:case e.degrees_minutes_seconds:return e.decimal_degrees; case e.gradians:return e.gradians;case e.fractional_degree_minutes:return e.fractional_degree_minutes;case e.radians:return e.radians;case e.seconds:case e.fractional_minute_seconds:return e.seconds}}function Z(a){switch(r.toNumber(a)){case 1:return{first:h.north,second:h.east};case 2:return{first:h.south,second:h.east};case 3:return{first:h.south,second:h.west};case 4:return{first:h.north,second:h.west}}return null}function S(a){switch(a.toUpperCase().trim()){case "N":case "NORTH":return h.north; case "E":case "EAST":return h.east;case "S":case "SOUTH":return h.south;case "W":case "WEST":return h.west}return null}function A(a){a=parseFloat(a);if(r.isNumber(a)){if(isNaN(a))throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"invalid conversion"});return a}throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"invalid conversion"});}function K(a,b,c){const d=c===g.quadrant;let l=null;var m=null;let n=0;var k=0;k=0;if(d){if(2>a.length)throw new f.ArcadeExecutionError(null, f.ExecutionErrorCodes.LogicError,null,{reason:"conversion error"});k=1;(m=Z(r.toString(a[a.length-1])))?(l=m.first,m=m.second):(n=1,l=S(r.toString(a[0])),m=S(r.toString(a[a.length-1])));if(null===l||null===m)throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"invalid conversion"});}switch(b){case e.decimal_degrees:case e.radians:case e.gradians:if(0===a.length)break;return d?q.createFromAngleMeridianAndDirection(t.createFromAngleAndUnits(A(a[n]),F(b)),l,m):q.createFromAngleAndDirection(t.createFromAngleAndUnits(A(a[n]), F(b)),c);case e.degrees_minutes_seconds:k=a.length-k-n;if(3===k)return a=t.createFromDegreesMinutesSeconds(A(a[n]),A(a[n+1]),A(a[n+2])),d?q.createFromAngleMeridianAndDirection(a,l,m):q.createFromAngleAndDirection(a,c);if(1===k)return a=A(a[n]),a=v.numberToDms(a),a=t.createFromDegreesMinutesSeconds(a.m_degrees,a.m_minutes,a.m_seconds),d?q.createFromAngleMeridianAndDirection(a,l,m):q.createFromAngleAndDirection(a,c)}throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"invalid conversion"}); }function aa(a){const b=new Set([" ","-","/","'",'"',"\\","^","\u00b0",T,"\t","\r","\n","*"]);let c="";for(let d=0;d""!==d)}function L(a,b,c){const d={padding:0,rounding:0,newpos:b};let l=!1;for(;b(b,c,d)=>{d=d||14;return+a(b,c).toFixed(d)},ba=(a,b)=> a+b,ca=(a,b)=>a-b,da=(a,b)=>a*b,ea=(a,b)=>a/b,M=(a,b,c)=>G(ba)(a,b,c),w=(a,b,c)=>G(da)(a,b,c),E=(a,b,c)=>G(ea)(a,b,c),Y=2*Math.PI,R=648E3/Math.PI,T=String.fromCharCode(7501);var h;(function(a){a[a.north=0]="north";a[a.east=1]="east";a[a.south=2]="south";a[a.west=3]="west"})(h||={});var e;(function(a){a[a.decimal_degrees=1]="decimal_degrees";a[a.seconds=2]="seconds";a[a.degrees_minutes_seconds=3]="degrees_minutes_seconds";a[a.radians=4]="radians";a[a.gradians=5]="gradians";a[a.truncated_degrees=6]= "truncated_degrees";a[a.fractional_degree_minutes=7]="fractional_degree_minutes";a[a.fractional_minute_seconds=8]="fractional_minute_seconds"})(e||={});var g;(function(a){a[a.north_azimuth=1]="north_azimuth";a[a.polar=2]="polar";a[a.quadrant=3]="quadrant";a[a.south_azimuth=4]="south_azimuth"})(g||={});var U;(function(a){a[a.meridian=0]="meridian";a[a.direction=1]="direction"})(U||={});class v{constructor(a,b,c){this.m_degrees=a;this.m_minutes=b;this.m_seconds=c}getField(a){switch(a){case e.decimal_degrees:case e.truncated_degrees:return this.m_degrees; case e.fractional_degree_minutes:return this.m_minutes;case e.seconds:case e.fractional_minute_seconds:return this.m_seconds;default:throw new f.ArcadeExecutionError(null,f.ExecutionErrorCodes.LogicError,null,{reason:"unexpected evaluation"});}}static secondsToDMS(a){const b=y(a).fraction;a=y(a).integer;const c=Math.floor(a/3600);a-=3600*c;const d=Math.floor(a/60);return new v(c,d,a-60*d+b)}static numberToDms(a){var b=y(a).fraction;a=y(a).integer;const c=w(y(100*b).fraction,100);b=y(100*b).integer; return new v(a,b,c)}format(a,b){b=H(this.m_seconds,b);let c=this.m_minutes,d=this.m_degrees;if(a===e.seconds||a===e.fractional_minute_seconds)60<=b&&(b-=60,++c),60<=c&&(c=0,++d),360<=d&&(d=0);else if(a===e.fractional_degree_minutes)b=0,c=30<=this.m_seconds?this.m_minutes+1:this.m_minutes,d=this.m_degrees,60<=c&&(c=0,++d),360<=d&&(d=0);else if(a===e.decimal_degrees||a===e.truncated_degrees)a=E(this.m_seconds,3600),b=E(this.m_minutes,60),d=Math.round(this.m_degrees+b+a),b=c=0;return new v(d,c,b)}static dmsToSeconds(a, b,c){return 3600*a+60*b+c}}class fa{constructor(a,b,c){this.meridian=a;this.angle=b;this.direction=c}fetchAzimuth(a){return a===U.meridian?this.meridian:this.direction}}class q{constructor(a){this._angle=a}static createFromAngleAndDirection(a,b){return new q(new t(q._convertDirectionFormat(a.extractAngularUnits(e.seconds),b,g.north_azimuth)))}getAngle(a){const b=this._angle.extractAngularUnits(e.seconds);switch(a){case g.north_azimuth:case g.south_azimuth:case g.polar:return new t(q._convertDirectionFormat(b, g.north_azimuth,a));case g.quadrant:return a=q.secondsNorthAzimuthToQuadrant(b),new t(a.angle)}}getMeridian(a){const b=this._angle.extractAngularUnits(e.seconds);switch(a){case g.north_azimuth:return h.north;case g.south_azimuth:return h.south;case g.polar:return h.east;case g.quadrant:return q.secondsNorthAzimuthToQuadrant(b).meridian}}getDirection(a){const b=this._angle.extractAngularUnits(e.seconds);switch(a){case g.north_azimuth:return h.east;case g.south_azimuth:return h.west;case g.polar:return h.north; case g.quadrant:return q.secondsNorthAzimuthToQuadrant(b).direction}}static secondsNorthAzimuthToQuadrant(a){const b=324E3>=a||972E3<=a?h.north:h.south;return new fa(b,b===h.north?Math.min(1296E3-a,a):Math.abs(a-648E3),648E3a?1296E3+a: a}}class t{constructor(a){this._seconds=a}static createFromAngleAndUnits(a,b){return new t(Q(a,b,e.seconds))}extractAngularUnits(a){return Q(this._seconds,e.seconds,F(a))}static createFromDegreesMinutesSeconds(a,b,c){return new t(M(M(w(a,3600),w(b,60)),c))}}class V{constructor(a,b,c,d){this.view=a;this.angle=b;this.merdian=c;this.direction=d;this._formattedDms=this._dms=null}static createFromStringAndBearing(a,b,c){return new V(a,b.getAngle(c),b.getMeridian(c),b.getDirection(c))}fetchAngle(){return this.angle}fetchMeridian(){return this.merdian}fetchDirection(){return this.direction}fetchView(){return this.view}fetchDms(){null=== this._dms&&this._calculateDms();return this._dms}fetchFormattedDms(){null===this._formattedDms&&this._calculateDms();return this._formattedDms}_calculateDms(){var a=null;let b=e.truncated_degrees,c=0;for(a=0;aG(ca)(a,b,c);x.preciseMultiply=w;Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});