"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&(t=n+Math.floor(t/this.props.step-n/this.props.step)*this.props.step)}else t=Math.floor(t);return this.updateValue(e,t)}},{key:"updateValue",value:function(e,t){var n,r=parseFloat(t.toFixed(10)),i=r;return this.props.range?(0===this.handleIndex?rthis.value[1]&&(r=this.value[1]):r>this.props.max?r=this.props.max:rthis.props.max&&(r=this.props.max),i=r,this.props.onChange&&this.props.onChange({originalEvent:e,value:i})),i}},{key:"componentWillUnmount",value:function(){this.unbindDragListeners(),this.unbindTouchListeners()}},{key:"renderHandle",value:function(e,n,i){var s=this,o=t.classNames("p-slider-handle",{"p-slider-handle-start":0===i,"p-slider-handle-end":1===i,"p-slider-handle-active":this.handleIndex===i});return r.default.createElement("span",{onMouseDown:function(e){return s.onMouseDown(e,i)},onTouchStart:function(e){return s.onTouchStart(e,i)},onKeyDown:function(e){return s.onKeyDown(e,i)},tabIndex:this.props.tabIndex,className:o,style:{transition:this.dragging?"none":null,left:null!==e&&e+"%",bottom:n&&n+"%"},role:"slider","aria-valuemin":this.props.min,"aria-valuemax":this.props.max,"aria-valuenow":e||n,"aria-labelledby":this.props.ariaLabelledBy})}},{key:"renderRangeSlider",value:function(){var e=this.value,t="horizontal"===this.props.orientation,n=100*(e[0]this.props.max?100:e[1]-this.props.min)/(this.props.max-this.props.min),s=t?this.renderHandle(n,null,0):this.renderHandle(null,n,0),o=t?this.renderHandle(i,null,1):this.renderHandle(null,i,1);return r.default.createElement(r.default.Fragment,null,r.default.createElement("span",{className:"p-slider-range",style:t?{left:n+"%",width:i-n+"%"}:{bottom:n+"%",height:i-n+"%"}}),s,o)}},{key:"renderSingleSlider",value:function(){var e,t=this.value;e=tthis.props.max?100:100*(t-this.props.min)/(this.props.max-this.props.min);var n="horizontal"===this.props.orientation?{width:e+"%"}:{height:e+"%"},i="horizontal"===this.props.orientation?this.renderHandle(e,null,null):this.renderHandle(null,e,null);return r.default.createElement(r.default.Fragment,null,r.default.createElement("span",{className:"p-slider-range",style:n}),i)}},{key:"render",value:function(){var e=this,n=t.classNames("p-slider p-component",this.props.className,{"p-disabled":this.props.disabled,"p-slider-horizontal":"horizontal"===this.props.orientation,"p-slider-vertical":"vertical"===this.props.orientation}),i=this.props.range?this.renderRangeSlider():this.renderSingleSlider();return r.default.createElement("div",{id:this.props.id,ref:function(t){return e.el=t},style:this.props.style,className:n,onClick:this.onBarClick},i)}}])&&h(f.prototype,y),b&&h(f,b),Object.defineProperty(f,"prototype",{writable:!1}),E}();L={id:null,value:null,min:0,max:100,orientation:"horizontal",step:null,range:!1,style:null,className:null,disabled:!1,tabIndex:0,ariaLabelledBy:null,onChange:null,onSlideEnd:null},(b="defaultProps")in(y=E)?Object.defineProperty(y,b,{value:L,enumerable:!0,configurable:!0,writable:!0}):y[b]=L,exports.Slider=E;