/* tail.DateTime #DEF 0.5.2 @ https://github.com/pytesNET/tail.select */
!function(e){"function"==typeof define&&define.amd?define(function(){return e(window)}):(void 0===window.tail&&(window.tail={}),window.tail.select=e(window),"undefined"!=typeof jQuery&&(jQuery.fn.tailselect=function(e){var t,i=[];return this.each(function(){!1!==(t=tail.select(this,e))&&i.push(t)}),1===i.length?i[0]:0!==i.length&&i}),"undefined"!=typeof MooTools&&Element.implement({tailselect:function(e){return new tail.select(this,e)}}))}(function(e){"use strict";var r=e,d=e.document;function u(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className||"")}function a(e,t){return new RegExp("\\b"+t+"\\b").test(e.className||t)||(e.className+=" "+t),e}function c(e,t,i){return(i=new RegExp("\\b("+t+")\\b"))&&i.test(e.className||"")&&(e.className=e.className.replace(i,"")),e}function n(e,t,i){if(CustomEvent&&CustomEvent.name)var s=new CustomEvent(t,i);else(s=d.createEvent("CustomEvent")).initCustomEvent(t,!!i.bubbles,!!i.cancelable,i.detail);return e.dispatchEvent(s)}function h(e,t){if(Object.assign)return Object.assign({},e,t||{});var i=new Object;for(var s in e)i[s]=s in t?t[s]:e[s];return i}function b(e,t){var i=d.createElement(e);return i.className=t&&t.join?t.join(" "):t||"",i}var p,f=function(e,t){if((e="string"==typeof e?d.querySelectorAll(e):e)instanceof NodeList||e instanceof HTMLCollection||e instanceof Array){for(var i=[],s=e.length,n=0;n',this.search.children[0].placeholder=this.__.search,this.search.children[0].addEventListener("input",function(e){t.query.call(t,2i.offsetHeight+i.scrollTop?i.scrollBy(0,o.top+2*o.height-(i.offsetHeight+i.scrollTop)):o.top-o.heighte.clientHeight?e.clientHeight:t,this.con.search&&(i=e.querySelector(".dropdown-search").clientHeight),this.dropdown.parentElement.removeChild(e);var n=this.select.getBoundingClientRect(),l=r.innerHeight-(n.top+n.height),o=ll;return!0===this.con.openAbove||!1!==this.con.openAbove&&o?(o=!0,t=Math.min(t,n.top-10),a(this.select,"open-top")):(o=!1,t=Math.min(t,l-10),c(this.select,"open-top")),s&&(this.dropdown.style.maxHeight=t+"px",s.style.maxHeight=t-i-2+"px"),this},query:function(e,t){for(var i,s,n,l,o,r,a=b("DIV","dropdown-inner"),c=this,h=e?"finder":"walker",d=this.con,u="getAttribute",p=e?[e,t]:[d.sortItems,d.sortGroups];i=this.options[h].apply(this.options,p);){if(!n||n&&n[u]("data-group")!==i.group){if(!((s=(d.cbLoopGroup||this.cbGroup).call(this,i.group,e,a))instanceof Element))break;(n=s).setAttribute("data-group",i.group),a.appendChild(n)}if(null!==(l=(d.cbLoopItem||this.cbItem).call(this,i,n,e,a))){if(!1===l)break;l.setAttribute("data-key",i.key),l.setAttribute("data-group",i.group),l.addEventListener("click",function(e){if(!this.hasAttribute("data-key"))return!1;var t=this[u]("data-key"),i=this[u]("data-group")||"#";c.options.toggle.call(c.options,t,i)&&(!1!==c.con.stayOpen||c.con.multiple||c.close.call(c,c.con.animate))}),n.appendChild(l)}}var f=a.querySelectorAll("*[data-key]").length;0==f&&(this.con.cbEmpty||function(e){var t=b("SPAN","dropdown-empty");t.innerText=this.__.empty,e.appendChild(t)}).call(this,a,e),0'+e+"",this.con.multiple&&this.con.multiLimit==1/0&&this.con.multiSelectAll&&(i=b("BUTTON","tail-none"),s=b("BUTTON","tail-all"),i.innerText=this.__.none,i.addEventListener("click",function(e){e.preventDefault();var t=this.parentElement.parentElement.getAttribute("data-group");l.options.all.call(l.options,"unselect",t)}),s.innerText=this.__.all,s.addEventListener("click",function(e){e.preventDefault();var t=this.parentElement.parentElement.getAttribute("data-group");l.options.all.call(l.options,"select",t)}),n.children[0].appendChild(i),n.children[0].appendChild(s))),n},cbItem:function(e,t,i){var s=b("LI","dropdown-option"+(e.selected?" selected":"")+(e.disabled?" disabled":""));return i&&0$1"):s.innerText=e.value,this.con.descriptions&&e.description&&(s.innerHTML+=''+e.description+""),s},update:function(e){return this.updateLabel().updateContainer(e).updatePin(e).updateCSV(e)},updateLabel:function(e){if(this.container==this.label&&0'+(e=(this.__[e]||e).replace(":limit",i.multiLimit))+"",t=i.multiShowLimit&&i.multiLimit<1/0,i.multiple&&i.multiShowCount&&(e=(e=':c'+e).replace(":c",s+(t?" / "+i.multiLimit:""))),this.label.innerHTML=e,this},updateContainer:function(e){if(!this.container||!this.con.multiContainer)return this;var t="[data-group='"+e.group+"'][data-key='"+e.key+"']";if(this.container.querySelector(t))return e.selected||this.container.removeChild(this.container.querySelector(t)),this;if(e.selected){var s=this,i=b("DIV","select-handle");i.innerText=e.value,i.setAttribute("data-key",e.key),i.setAttribute("data-group",e.group),i.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();var t=this.getAttribute("data-key"),i=this.getAttribute("data-group");s.options.unselect.call(s.options,t,i)}),this.container.appendChild(i)}return this},updatePin:function(e){var t=this.dropdown.querySelector(".dropdown-inner ul"),i="li[data-key='"+e.key+"'][data-group='"+e.group+"']";if(!this.con.multiPinSelected||!t)return this;if(i=this.dropdown.querySelector(i),e.selected)t.insertBefore(i,t.children[0]);else{for(var s=this.dropdown.querySelector("ul[data-group='"+e.group+"']"),n=this.options[e.index-1],l=!1;n.group==e.group&&!(l=s.querySelector("li[data-key='"+n.key+"']"));)n=this.options[n.index-1];l&&l.nextElementSibling?s.insertBefore(i,l.nextElementSibling):s.appendChild(i)}return this},updateCSV:function(e){if(!this.csvInput||!this.con.csvOutput)return this;for(var t=[],i=this.options.selected.length,s=0;s=n.multiLimit)&&(e.selected=!1),!e.selected||!n.deselect||e.hasAttribute("selected")&&0!=n.multiLimit||(e.selected=!1,e.parentElement.selectedIndex=-1),e.hasAttribute("data-description")){var l=b("SPAN");l.innerHTML=e.getAttribute("data-description"),e.setAttribute("data-description",l.innerHTML)}return this[this.length++]=this.items[s][i]={key:i,value:e.text,index:this.length-1,description:e.getAttribute("data-description")||null,group:s,option:e,optgroup:"#"!=s?this.groups[s]:void 0,selected:e.selected,disabled:e.disabled},e.selected&&this.select(this.items[s][i]),e.disabled&&this.disable(this.items[s][i]),!t||this.self.callback(this[this.length-1],"rebuild")},add:function(e,t,i,s,n,l,o){if(e instanceof Object){for(var r in e)this.add(r,e[r].value,e[r].group,e[r].selected,e[r].disabled,e[r].description,!1);return this.self.query()}if(this.get(e,i))return!1;if("#"!==(i="string"==typeof i?i:"#")&&!(i in this.groups)){var a=b("OPTGROUP");a.label=i,a.setAttribute("data-select-optgroup","add"),this.element.appendChild(a),this.items[i]={},this.groups[i]=a}var c=this.self.con;(!c.multiple&&0=c.multiLimit)&&(s=!1),n=!!n;var h=d.createElement("OPTION");return h.value=e,h.selected=s,h.disabled=n,h.innerText=t,h.setAttribute("data-select-option","add"),l.length&&0.+?";i+="|(\\s+\\w+(\\s*=\\s*(?:\\\".*?\\\"|'.*?'))?)+>[^<]*("+e+")[^<]*)<\\/option>"}else i="