define(["require","exports","tslib","react","../constants","../FormElementOuter","../numberSliderUtilities","react-range","../utils","../../BrowserUtils","../common"],function(e,t,M,F,S,I,R,T,D,B,j){"use strict";var O;Object.defineProperty(t,"__esModule",{value:!0}),F=M.__importStar(F),I=M.__importDefault(I);t.default=function(e){var r=e.component,t=e.element,n=F.useMemo(function(){return R.getProcessedNumberFormat(t.format)},[]),a=F.useState(F.useMemo(function(){return t.value=R.getInitialNumberSliderValues(t.value,n),t.value},[])),o=a[0],u=a[1],e=F.useState(t.value),i=e[0],s=e[1],a=r.props,l=a.host,c=a.name,d=F.useCallback(function(e){e instanceof T.Range&&(e=e.thumbRefs[0].current),j.renderFocus(e,c,l)},[]),m=n.lowerBound,f=n.upperBound,e=n.precision,p=t.showMinMaxLabels,v=t.manualEntry,g=n.step,x=t.showTickMarks,x=0<g&&x;0===g&&(g=1/Math.pow(10,e));function y(e){e=_(e),A(e),(Array.isArray(O)||e[0]===m&&e[1]===f)&&(!Array.isArray(O)||e[0]===O[0]&&e[1]===O[1])||(t.value=O=e,l.post("changed",{name:c,value:t.value}))}function b(e){r.autoInput=!0}function h(e){return e.target.select()}function _(e){return[e[0]<m?m:e[0]>f?f:e[0],e[1]>f?f:e[1]<m?m:e[1]].sort(function(e,t){return e-t})}function E(e,t,n,a,r,o){return F.default.createElement("div",{style:{position:"absolute",top:t,color:r=void 0===r?"#fff":r,fontWeight:"bold",fontSize:"14px",fontFamily:"Arial,Helvetica Neue,Helvetica,sans-serif",padding:"4px",borderRadius:"5px",backgroundColor:o=void 0===o?"#197dc8":o,left:n,right:a,whiteSpace:"nowrap"}},e)}var k=!r.enabled,N={currency:n.currency,customDisplayFormat:n.customDisplayFormat,format:n.displayFormat,fractionalDigits:e,locale:l.deriveLocale()},a=l.renderText(t.tooltip),e=[t.type,D.makeSafeClassName(c)],w=F.useMemo(function(){return D.throttle(function(e){l.post("dragged",{name:c,value:e})})},[]),C=function(e,t){var n=o.slice(),e=""!==e?Number(e):NaN;isNaN(e)?A(n):(0===t?(e=e<m?m:e)>n[1]&&(e=n[1]):(e=f<e?f:e)<n[0]&&(e=n[0]),n[t]=e,y(n))},A=function(e){u(e),s(e)};return F.default.createElement(I.default,{className:e.join(" "),component:r,element:t,errorClassName:S.CssClasses.ERROR},!B.isIE()&&F.default.createElement("div",{className:"slider-container",title:a},F.default.createElement(T.Range,{draggableTrack:!0,step:g,min:m,max:f,values:o,onChange:function(e){e=_(e),A(e),Array.isArray(t.value)&&e[0]===t.value[0]&&e[1]===t.value[1]||(t.value=e,w(t.value))},onFinalChange:y,renderMark:function(e){var t=e.props,n=e.index,e=m+n*g,n=f<e,e=e>o[0]&&e<o[1]?"#197dc8":"#ccc";return x&&!n&&F.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"16px",width:"2px",backgroundColor:e})}))},renderTrack:function(e){var t=e.props,e=e.children;return F.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"6px",margin:"50px 0px 24px",width:"100%",background:T.getTrackBackground({values:o,colors:["#ccc","#197dc8","#ccc"],min:m,max:f,rtl:!1})})}),!1!==p&&E(l.formatNumber(m,N,!0),"20px","-12px",void 0,"#333","#fff"),!1!==p&&E(l.formatNumber(f,N,!0),"20px",void 0,"-12px","#333","#fff"),e)},renderThumb:function(e){var t=e.props,n=e.value,a=e.index,r=f-m,e=n-m,n=e<r/10?"0":"auto",e=9*r/10<e?"0":"auto";return F.default.createElement("div",M.__assign({},t,{style:M.__assign(M.__assign({},t.style),{height:"24px",width:"24px",borderRadius:"12px",backgroundColor:"#197dc8",display:"flex",justifyContent:"center",alignItems:"center",boxShadow:"0px 2px 4px #AAA",outline:"none"})}),E(l.formatNumber(o[a],N,!0),"-32px",n,e))},disabled:k,ref:d})),!1!==v||B.isIE()?F.default.createElement("div",{className:"inputs"},i.map(function(e,a){return F.default.createElement("span",null,0===a?l.renderText("@common-start"):l.renderText("@common-end"),F.default.createElement("input",{key:a,type:"number",disabled:k,min:0===a?m:o[0],max:0===a?o[1]:f,step:g,title:e+"",value:e,onBlur:function(e){C(e.target.value,a)},onChange:function(e){return t=e,n=a,(e=i.slice())[n]=t.target.value,s(e),void(r.autoInput&&C(t.target.value,n));var t,n},onKeyDown:function(e){return t=a,(e=e).stopPropagation(),r.autoInput=!1,void("Enter"===e.key?C(i[t]+"",t):"Escape"===e.key&&A(o.slice()));var t},onMouseDown:b,onFocus:h,ref:0===a&&B.isIE()?d:void 0}))})):null)}});