(function(n){"use strict";typeof define=="function"&&define.amd?define(["jquery"],n):typeof exports=="object"?module.exports=n(require("jquery")):n(jQuery)})(function(n){"use strict";function o(){var n=document.createElement("input");return n.setAttribute("type","range"),n.type!=="text"}function l(n,t){var i=Array.prototype.slice.call(arguments,2);return setTimeout(function(){return n.apply(null,i)},t)}function a(n,t){return t=t||100,function(){if(!n.debouncing){var i=Array.prototype.slice.apply(arguments);n.lastReturnVal=n.apply(window,i);n.debouncing=!0}return clearTimeout(n.debounceTimeout),n.debounceTimeout=setTimeout(function(){n.debouncing=!1},t),n.lastReturnVal}}function v(n){return n&&(n.offsetWidth===0||n.offsetHeight===0||n.open===!1)}function y(n){for(var i=[],t=n.parentNode;v(t);)i.push(t),t=t.parentNode;return i}function e(n,t){function s(n){typeof n.open!="undefined"&&(n.open=n.open?!1:!0)}var r=y(n),f=r.length,e=[],o=n[t],i,u;if(f){for(i=0;i<f;i++)e[i]=r[i].style.cssText,r[i].style.setProperty?r[i].style.setProperty("display","block","important"):r[i].style.cssText+=";display: block !important",r[i].style.height="0",r[i].style.overflow="hidden",r[i].style.visibility="hidden",s(r[i]);for(o=n[t],u=0;u<f;u++)r[u].style.cssText=e[u],s(r[u])}return o}function u(n,t){var i=parseFloat(n);return Number.isNaN(i)?t:i}function f(n){return n.charAt(0).toUpperCase()+n.substr(1)}function t(t,u){if(this.$window=n(window),this.$document=n(document),this.$element=n(t),this.options=n.extend({},c,u),this.polyfill=this.options.polyfill,this.orientation=this.$element[0].getAttribute("data-orientation")||this.options.orientation,this.onInit=this.options.onInit,this.onSlide=this.options.onSlide,this.onSlideEnd=this.options.onSlideEnd,this.DIMENSION=r.orientation[this.orientation].dimension,this.DIRECTION=r.orientation[this.orientation].direction,this.DIRECTION_STYLE=r.orientation[this.orientation].directionStyle,this.COORDINATE=r.orientation[this.orientation].coordinate,this.polyfill&&h)return!1;this.identifier="js-"+i+"-"+s++;this.startEvent=this.options.startEvent.join("."+this.identifier+" ")+"."+this.identifier;this.moveEvent=this.options.moveEvent.join("."+this.identifier+" ")+"."+this.identifier;this.endEvent=this.options.endEvent.join("."+this.identifier+" ")+"."+this.identifier;this.toFixed=(this.step+"").replace(".","").length-1;this.$fill=n('<div class="'+this.options.fillClass+'" />');this.$handle=n('<div class="'+this.options.handleClass+'" />');this.$range=n('<div class="'+this.options.rangeClass+" "+this.options[this.orientation+"Class"]+'" id="'+this.identifier+'" />').insertAfter(this.$element).prepend(this.$fill,this.$handle);this.$element.css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",opacity:"0"});this.handleDown=n.proxy(this.handleDown,this);this.handleMove=n.proxy(this.handleMove,this);this.handleEnd=n.proxy(this.handleEnd,this);this.init();var f=this;this.$window.on("resize."+this.identifier,a(function(){l(function(){f.update(!1,!1)},300)},20));this.$document.on(this.startEvent,"#"+this.identifier+":not(."+this.options.disabledClass+")",this.handleDown);this.$element.on("change."+this.identifier,function(n,t){if(!t||t.origin!==f.identifier){var i=n.target.value,r=f.getPositionFromValue(i);f.setPosition(r)}})}Number.isNaN=Number.isNaN||function(n){return typeof n=="number"&&n!==n};var i="rangeslider",s=0,h=o(),c={polyfill:!0,orientation:"horizontal",rangeClass:"rangeslider",disabledClass:"rangeslider--disabled",horizontalClass:"rangeslider--horizontal",verticalClass:"rangeslider--vertical",fillClass:"rangeslider__fill",handleClass:"rangeslider__handle",startEvent:["mousedown","touchstart","pointerdown"],moveEvent:["mousemove","touchmove","pointermove"],endEvent:["mouseup","touchend","pointerup"]},r={orientation:{horizontal:{dimension:"width",direction:"left",directionStyle:"left",coordinate:"x"},vertical:{dimension:"height",direction:"top",directionStyle:"bottom",coordinate:"y"}}};return t.prototype.init=function(){this.update(!0,!1);this.onInit&&typeof this.onInit=="function"&&this.onInit()},t.prototype.update=function(n,t){n=n||!1;n&&(this.min=u(this.$element[0].getAttribute("min"),0),this.max=u(this.$element[0].getAttribute("max"),100),this.value=u(this.$element[0].value,Math.round(this.min+(this.max-this.min)/2)),this.step=u(this.$element[0].getAttribute("step"),1));this.handleDimension=e(this.$handle[0],"offset"+f(this.DIMENSION));this.rangeDimension=e(this.$range[0],"offset"+f(this.DIMENSION));this.maxHandlePos=this.rangeDimension-this.handleDimension;this.grabPos=this.handleDimension/2;this.position=this.getPositionFromValue(this.value);this.$element[0].disabled?this.$range.addClass(this.options.disabledClass):this.$range.removeClass(this.options.disabledClass);this.setPosition(this.position,t)},t.prototype.handleDown=function(n){this.$document.on(this.moveEvent,this.handleMove);this.$document.on(this.endEvent,this.handleEnd);if(!((" "+n.target.className+" ").replace(/[\n\t]/g," ").indexOf(this.options.handleClass)>-1)){var t=this.getRelativePosition(n),r=this.$range[0].getBoundingClientRect()[this.DIRECTION],i=this.getPositionFromNode(this.$handle[0])-r,u=this.orientation==="vertical"?this.maxHandlePos-(t-this.grabPos):t-this.grabPos;this.setPosition(u);t>=i&&t<i+this.handleDimension&&(this.grabPos=t-i)}},t.prototype.handleMove=function(n){n.preventDefault();var t=this.getRelativePosition(n),i=this.orientation==="vertical"?this.maxHandlePos-(t-this.grabPos):t-this.grabPos;this.setPosition(i)},t.prototype.handleEnd=function(n){if(n.preventDefault(),this.$document.off(this.moveEvent,this.handleMove),this.$document.off(this.endEvent,this.handleEnd),this.$element.trigger("change",{origin:this.identifier}),this.onSlideEnd&&typeof this.onSlideEnd=="function")this.onSlideEnd(this.position,this.value)},t.prototype.cap=function(n,t,i){return n<t?t:n>i?i:n},t.prototype.setPosition=function(n,t){var i,r;if(t===undefined&&(t=!0),i=this.getValueFromPosition(this.cap(n,0,this.maxHandlePos)),r=this.getPositionFromValue(i),this.$fill[0].style[this.DIMENSION]=r+this.grabPos+"px",this.$handle[0].style[this.DIRECTION_STYLE]=r+"px",this.setValue(i),this.position=r,this.value=i,t&&this.onSlide&&typeof this.onSlide=="function")this.onSlide(r,i)},t.prototype.getPositionFromNode=function(n){for(var t=0;n!==null;)t+=n.offsetLeft,n=n.offsetParent;return t},t.prototype.getRelativePosition=function(n){var t=f(this.COORDINATE),r=this.$range[0].getBoundingClientRect()[this.DIRECTION],i=0;return typeof n["page"+t]!="undefined"?i=n["client"+t]:typeof n.originalEvent["client"+t]!="undefined"?i=n.originalEvent["client"+t]:n.originalEvent.touches&&n.originalEvent.touches[0]&&typeof n.originalEvent.touches[0]["client"+t]!="undefined"?i=n.originalEvent.touches[0]["client"+t]:n.currentPoint&&typeof n.currentPoint[this.COORDINATE]!="undefined"&&(i=n.currentPoint[this.COORDINATE]),i-r},t.prototype.getPositionFromValue=function(n){var t;return t=(n-this.min)/(this.max-this.min),Number.isNaN(t)?0:t*this.maxHandlePos},t.prototype.getValueFromPosition=function(n){var t,i;return t=n/(this.maxHandlePos||1),i=this.step*Math.round(t*(this.max-this.min)/this.step)+this.min,Number(i.toFixed(this.toFixed))},t.prototype.setValue=function(n){(n!==this.value||this.$element[0].value==="")&&this.$element.val(n).trigger("input",{origin:this.identifier})},t.prototype.destroy=function(){this.$document.off("."+this.identifier);this.$window.off("."+this.identifier);this.$element.off("."+this.identifier).removeAttr("style").removeData("plugin_"+i);this.$range&&this.$range.length&&this.$range[0].parentNode.removeChild(this.$range[0])},n.fn[i]=function(r){var u=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=n(this),f=e.data("plugin_"+i);f||e.data("plugin_"+i,f=new t(this,r));typeof r=="string"&&f[r].apply(f,u)})},"rangeslider.js is available in jQuery context e.g $(selector).rangeslider(options);"})