/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{zeroSquareMeters as t,toUnit as e,createScalar as a,zeroMeters as n,zeroDegrees as r,createAngle as i,createLength as o,createArea as s}from"../../../../core/quantity.js";import{makeQuantityParser as u,parseLongitude as f,formatLongitudeDecimalDegreesForInputMode as c,parseLatitude as l,formatLatitudeDecimalDegreesForInputMode as m,sanitizeAngle as p}from"./parsingAndFormattingUtils.js";import{TooltipField as g}from"./TooltipField.js";import{TooltipFieldElevation as d}from"./TooltipFieldElevation.js";import{TooltipFieldOrientation as h}from"./TooltipFieldOrientation.js";import{TooltipFieldSize as b}from"./TooltipFieldSize.js";import{getNormalizedDirection as I}from"../../../support/angularMeasurementUtils.js";function v(t){const a=t=>t.inputUnitInfos.angle.unit,n=t=>t.sketchOptions.values.effectiveDirectionMode;return new g({name:"direction",actual:r,parse:u({createQuantity:(t,e)=>i(t,a(e),"geographic"),sanitize:p}),format:(t,e)=>{const a=n(e),r=I(t,a);switch(a){case"absolute":return e.formatters.direction(r);case"relative":return e.formatters.directionRelative(r);case"relative-bilateral":return e.formatters.directionRelativeBilateral(r)}},formatForInputMode:(t,r)=>{const i=I(t,n(r));return r.formatters.scalar(e(i,a(r)))},suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>{const e=n(t),{absolute:a,relative:r}=t.messages.sketch.direction;switch(e){case"absolute":return a;case"relative":case"relative-bilateral":return r}},...t})}function y(t){const a=t=>t.inputUnitInfos.length.unit;return new g({name:t?.name??"distance",actual:n,parse:u({createQuantity:(t,e)=>o(Math.max(t,0),a(e))}),format:(t,e)=>e.formatters.length(t),formatForInputMode:(t,n)=>n.formatters.scalar(e(t,a(n))),suffix:t=>t.inputUnitInfos.length.abbreviation,title:t=>t.messages.sketch.distance,...t})}function U(t){const a=t=>t.inputUnitInfos.length.unit;return new g({name:t?.name??"radius",actual:n,parse:u({createQuantity:(t,e)=>o(Math.max(t,0),a(e))}),format:(t,e)=>e.formatters.length(t),formatForInputMode:(t,n)=>n.formatters.scalar(e(t,a(n))),suffix:t=>t.inputUnitInfos.length.abbreviation,title:t=>t.messages.sketch.radius,...t})}function w(t){return y({format:(t,e)=>e.formatters.totalLength(t),title:t=>t.messages.sketch.totalLength,readOnly:!0,...t})}function x(t){return y({...t})}function F(t){const e=t=>t.inputUnitInfos.length.unit;return y({...t,parse:u({createQuantity:(t,a)=>o(t,e(a))}),format:(t,e)=>e.formatters.lengthRelative(t)})}function M(t){return new d(t)}function k(t){return new h(t)}function j(t){return new b(t)}function Q(t){return q("scale",{name:"scale",actual:null,parse:u({createQuantity:t=>a(Math.abs(t))}),...t})}function D(a){const n=t=>t.inputUnitInfos.area.unit;return new g({name:"area",actual:t,parse:u({createQuantity:(t,e)=>s(t,n(e))}),format:(t,e)=>e.formatters.area(t),formatForInputMode:(t,a)=>a.formatters.scalar(e(t,n(a))),suffix:t=>t.inputUnitInfos.area.abbreviation,title:t=>t.messages.sketch.area,readOnly:!0,...a})}function O(t){return new g({name:"x",actual:r,parse:f,format:(t,e)=>e.formatters.longitudeDecimalDegrees(t),formatForInputMode:t=>c(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.longitude,...t})}function T(t){return new g({name:"y",actual:r,parse:l,format:(t,e)=>e.formatters.latitudeDecimalDegrees(t),formatForInputMode:t=>m(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.latitude,...t})}function R(t){return q("x",{name:"x",...t})}function z(t){return q("y",{name:"y",...t})}function L(t){return new g({actual:a(0),parse:u({createQuantity:t=>a(t)}),format:(t,e)=>e.formatters.scalar(t),formatForInputMode:(t,e)=>e.formatters.scalar(t),title:t=>t.messages.sketch.scale,...t})}function q(t,e){return L({title:e=>e.messages.sketch[t],...e})}export{D as makeAreaField,v as makeDirectionField,x as makeDistanceField,M as makeElevationField,T as makeLatitudeField,y as makeLengthField,O as makeLongitudeField,k as makeOrientationField,U as makeRadiusField,F as makeRelativeDistanceField,L as makeScalarField,Q as makeScaleField,j as makeSizeField,w as makeTotalLengthField,R as makeXField,z as makeYField};
