"use strict";
/**
 * Creates a draggable band from a list of items
 * @copyright S. Derdeyn 2018
 * @license MIT
 */var dragBand={init:function(e,t,n){var r=e,o=0<=t?t:null,l=(n=n||{}).leftScroller,c=n.rightscroller,i=n.scrollstep||50,s=n.elasticWidth||100,f=n.hideScrollerMargin||20,a=!0,d=!1,u=null,v=P(r.children[0],r).x,h=0,y=0,m=0,p=(setInterval(function(){if(a){var e=O(r).x;m=10*(e-y),y=e}},100),r.children.length),L=b(),E=r.parentElement.offsetLeft,g=r.parentElement.offsetWidth-L,x=o;function T(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];x=e,t&&k(z(e)),function(e){for(var t=0;t<p;t++)r.children[t].classList.remove("selected"),t==e&&r.children[t].classList.add("selected")}(x)}function b(){for(var e=0,t=0;t<p;t++)e+=r.children[t].offsetWidth;return r.style.width="".concat(e,"px"),e}function k(e){a&&(v=Math.min(E,Math.max(g,e)),r.style.left="".concat(v,"px"),r.classList.toggle("smooth",!(d=!1)),w(v))}function w(e){l&&(l.style.opacity=M(e)?"1":"0",l.style.pointerEvents=M(e)?"all":"none"),c&&(c.style.opacity=W(e)?"1":"0",c.style.pointerEvents=W(e)?"all":"none")}function M(e){return!(E-f<e)}function W(e){return!(e<g+f)}function B(e){return e.changedTouches?e.changedTouches[0]:e}function D(e){a&&(d||(e.type,u=B(e).clientX,r.classList.toggle("smooth",!(d=!0))))}function S(e){if(a&&(e.type,d)){var t=B(e).clientX-u,n=(j(t),v+(h=t));k(v=n+.125*m),u=null}}function X(e){if(a&&d){var t=Math.round(B(e).clientX-u),n=v+t,o=E+s,l=g-s;n<=o&&l<n&&(r.style.left="".concat(n,"px"),w(n))}}T(x),document.body.addEventListener("mousemove",X,!1),document.body.addEventListener("touchmove",X,!1),r.addEventListener("mousedown",D,!1),r.addEventListener("touchstart",D,!1),document.body.addEventListener("mouseup",S,!1),document.body.addEventListener("touchend",S,!1),window.addEventListener("resize",function(e){L=b(),E=r.parentElement.offsetLeft,g=r.parentElement.offsetWidth-L,k(z(x))},!1),r.addEventListener("wheel",function(e){a&&(k(v-j(e.deltaY)*i),e.preventDefault())},!1);for(var I=function(t){Y=r.children[t].getElementsByTagName("*");for(var e=0;e<Y.length;e++)Y[e].addEventListener("click",function(e){if(50<=Math.abs(h))return e.preventDefault(),!1;T(t,!0),this.blur()},!0)},N=0;N<p;N++){var Y;I(N)}function z(e){if(null===e)return v;var t=r.children[e],n=P(t,r).x;return-n+t.offsetWidth/2}function O(e){for(var t=0,n=0;e;){if("BODY"==e.tagName){var o=e.scrollLeft||document.documentElement.scrollLeft,l=e.scrollTop||document.documentElement.scrollTop;t+=e.offsetLeft-o+e.clientLeft,n+=e.offsetTop-l+e.clientTop}else t+=e.offsetLeft-e.scrollLeft+e.clientLeft,n+=e.offsetTop-e.scrollTop+e.clientTop;e=e.offsetParent}return{x:t,y:n}}function P(e,t){var n=O(t),o=O(e);return{x:o.x-n.x,y:o.y-n.y}}function j(e){return e?e<0?-1:1:0}return l&&l.addEventListener("click",function(e){M(v)&&k(v+i)},!0),c&&c.addEventListener("click",function(e){M(v)&&k(v-i)},!0),{selectItem:T,setScrollingEnabled:function(e){(a=e)?(l&&(l.style.display="block"),c&&(c.style.display="block")):(r.style.left=0,l&&(l.style.display="none"),c&&(c.style.display="none")),T(x)}}}};