"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react/jsx-runtime"),r=require("react"),u=require("@material-ui/core"),i=require("lodash"),n=require("classnames"),a=require("../../../../../utils/getIsImperial.js"),s=require("./RadiusInput.module.css.js"),l=require("../../../../../../../utils/index.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=d(e),c=d(n);exports.RadiusInput=function(e){var n=e.radius,d=e.editable,f=e.isLassoActive,m=void 0!==f&&f,v=e.isSatellite,p=void 0!==v&&v,b=e.onChange,g=e["data-testid"],h=void 0===g?"RadiusInput":g,I=e.className,j=r.useState(""),q=o.default(j,2),x=q[0],N=q[1],R=r.useState(!1),S=o.default(R,2),F=S[0],k=S[1],y=r.useState(!1),E=o.default(y,2),M=E[0],_=E[1],A=r.useMemo((function(){return a.getIsImperial()}),[]),C=r.useMemo((function(){return i.debounce((function(e){return b(e)}),1500)}),[b]),L=r.useRef(C);L.current=C,r.useEffect((function(){return function(){return L.current.cancel()}}),[]),r.useEffect((function(){if(!M){var e=A?n:l.convertValue(n,"length","mi","km",3);N(function(e){return Number.isInteger(e)?String(e):e.toFixed(2)}(Number(e)))}}),[A,n,M]);var P=A?"mi":"km",T=!d||m;return t.jsxs("div",{className:c.default(s.radiusInput,p&&s.satellite,T&&s.disabled,I),children:[t.jsxs(u.InputLabel,{htmlFor:"radius-input",className:s.label,children:["Radius (",P,"):"]}),t.jsx(u.TextField,{id:"radius-input","data-testid":"".concat(h,"_input"),type:"number",value:x,disabled:T,onChange:function(e){if(!(r=null===(t=e.nativeEvent)||void 0===t?void 0:t.data)||!["e","E","+","-"].includes(r)){var t,r,u=e.target.value;N(u);var i=function(e){if(""===e)return!0;var t=Number(e);return Number.isFinite(t)&&t>=0}(u);if(k(!i),i&&""!==u){var n=A?+u:l.convertValue(+u,"length","km","mi",3);C(Number(n))}}},onFocus:function(){return _(!0)},onBlur:function(){L.current.flush(),_(!1)},error:F,className:s.field,"aria-label":"Radius in ".concat(A?"miles":"kilometers"),"aria-invalid":F,inputProps:{lang:"en-US"}})]})};
//# sourceMappingURL=RadiusInput.js.map
