/*! For license information please see app.f0f8091d.js.LICENSE.txt */ (self.webpackChunkkimai=self.webpackChunkkimai||[]).push([[524],{424:function(e){window,e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(i,s,function(t){return e[t]}.bind(null,s));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(t,n,i){void 0===t&&(t=null),void 0===n&&(n=null),void 0===i&&(i="en-US"),this.dateInstance="object"==typeof n&&null!==n?n.parse(t instanceof e?t.clone().toJSDate():t):"string"==typeof n?e.parseDateTime(t,n,i):t?e.parseDateTime(t):e.parseDateTime(new Date),this.lang=i}return e.parseDateTime=function(t,n,i){if(void 0===n&&(n="YYYY-MM-DD"),void 0===i&&(i="en-US"),!t)return new Date(NaN);if(t instanceof Date)return new Date(t);if(t instanceof e)return t.clone().toJSDate();if(/^-?\d{10,}$/.test(t))return e.getDateZeroTime(new Date(Number(t)));if("string"==typeof t){for(var s=[],r=null;null!=(r=e.regex.exec(n));)"\\"!==r[1]&&s.push(r);if(s.length){var o={year:null,month:null,shortMonth:null,longMonth:null,day:null,value:""};s[0].index>0&&(o.value+=".*?");for(var a=0,l=Object.entries(s);ae.getTime()&&this.timestamp()=e.getTime()&&this.timestamp()e.getTime()&&this.timestamp()<=t.getTime();case"[]":return this.timestamp()>=e.getTime()&&this.timestamp()<=t.getTime()}},e.prototype.isBefore=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":return e.getTime()>this.getTime();case"day":case"days":return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()>new Date(this.getFullYear(),this.getMonth(),this.getDate()).getTime();case"month":case"months":return new Date(e.getFullYear(),e.getMonth(),1).getTime()>new Date(this.getFullYear(),this.getMonth(),1).getTime();case"year":case"years":return e.getFullYear()>this.getFullYear()}throw new Error("isBefore: Invalid unit!")},e.prototype.isSameOrBefore=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":return e.getTime()>=this.getTime();case"day":case"days":return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()>=new Date(this.getFullYear(),this.getMonth(),this.getDate()).getTime();case"month":case"months":return new Date(e.getFullYear(),e.getMonth(),1).getTime()>=new Date(this.getFullYear(),this.getMonth(),1).getTime()}throw new Error("isSameOrBefore: Invalid unit!")},e.prototype.isAfter=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":return this.getTime()>e.getTime();case"day":case"days":return new Date(this.getFullYear(),this.getMonth(),this.getDate()).getTime()>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();case"month":case"months":return new Date(this.getFullYear(),this.getMonth(),1).getTime()>new Date(e.getFullYear(),e.getMonth(),1).getTime();case"year":case"years":return this.getFullYear()>e.getFullYear()}throw new Error("isAfter: Invalid unit!")},e.prototype.isSameOrAfter=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":return this.getTime()>=e.getTime();case"day":case"days":return new Date(this.getFullYear(),this.getMonth(),this.getDate()).getTime()>=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();case"month":case"months":return new Date(this.getFullYear(),this.getMonth(),1).getTime()>=new Date(e.getFullYear(),e.getMonth(),1).getTime()}throw new Error("isSameOrAfter: Invalid unit!")},e.prototype.isSame=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":return this.getTime()===e.getTime();case"day":case"days":return new Date(this.getFullYear(),this.getMonth(),this.getDate()).getTime()===new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();case"month":case"months":return new Date(this.getFullYear(),this.getMonth(),1).getTime()===new Date(e.getFullYear(),e.getMonth(),1).getTime()}throw new Error("isSame: Invalid unit!")},e.prototype.add=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":this.setSeconds(this.getSeconds()+e);break;case"day":case"days":this.setDate(this.getDate()+e);break;case"month":case"months":this.setMonth(this.getMonth()+e)}return this},e.prototype.subtract=function(e,t){switch(void 0===t&&(t="seconds"),t){case"second":case"seconds":this.setSeconds(this.getSeconds()-e);break;case"day":case"days":this.setDate(this.getDate()-e);break;case"month":case"months":this.setMonth(this.getMonth()-e)}return this},e.prototype.diff=function(e,t){switch(void 0===t&&(t="seconds"),t){default:case"second":case"seconds":return this.getTime()-e.getTime();case"day":case"days":return Math.round((this.timestamp()-e.getTime())/864e5);case"month":case"months":}},e.prototype.format=function(t,n){if(void 0===n&&(n="en-US"),"object"==typeof t)return t.output(this.clone().toJSDate());for(var i="",s=[],r=null;null!=(r=e.regex.exec(t));)"\\"!==r[1]&&s.push(r);if(s.length){s[0].index>0&&(i+=t.substring(0,s[0].index));for(var o=0,a=Object.entries(s);o1&&n.isAfter(t)&&n.setMonth(n.getMonth()-(this.options.numberOfMonths-1)),this.calendars[0]=n.clone()):(t.setDate(1),this.calendars[0]=t.clone())}},t.prototype.bindEvents=function(){document.addEventListener("click",this.onClick.bind(this),!0),this.ui=document.createElement("div"),this.ui.className=l.litepicker,this.ui.style.display="none",this.ui.addEventListener("mouseenter",this.onMouseEnter.bind(this),!0),this.ui.addEventListener("mouseleave",this.onMouseLeave.bind(this),!1),this.options.autoRefresh?(this.options.element instanceof HTMLElement&&this.options.element.addEventListener("keyup",this.onInput.bind(this),!0),this.options.elementEnd instanceof HTMLElement&&this.options.elementEnd.addEventListener("keyup",this.onInput.bind(this),!0)):(this.options.element instanceof HTMLElement&&this.options.element.addEventListener("change",this.onInput.bind(this),!0),this.options.elementEnd instanceof HTMLElement&&this.options.elementEnd.addEventListener("change",this.onInput.bind(this),!0)),this.options.parentEl?this.options.parentEl instanceof HTMLElement?this.options.parentEl.appendChild(this.ui):document.querySelector(this.options.parentEl).appendChild(this.ui):this.options.inlineMode?this.options.element instanceof HTMLInputElement?this.options.element.parentNode.appendChild(this.ui):this.options.element.appendChild(this.ui):document.body.appendChild(this.ui),this.updateInput(),this.init(),"function"==typeof this.options.setup&&this.options.setup.call(this,this),this.render(),this.options.inlineMode&&this.show()},t.prototype.updateInput=function(){if(this.options.element instanceof HTMLInputElement){var e=this.options.startDate,t=this.options.endDate;if(this.options.singleMode&&e)this.options.element.value=e.format(this.options.format,this.options.lang);else if(!this.options.singleMode&&e&&t){var n=e.format(this.options.format,this.options.lang),i=t.format(this.options.format,this.options.lang);this.options.elementEnd instanceof HTMLInputElement?(this.options.element.value=n,this.options.elementEnd.value=i):this.options.element.value=""+n+this.options.delimiter+i}e||t||(this.options.element.value="",this.options.elementEnd instanceof HTMLInputElement&&(this.options.elementEnd.value=""))}},t.prototype.isSamePicker=function(e){return e.closest("."+l.litepicker)===this.ui},t.prototype.shouldShown=function(e){return!e.disabled&&(e===this.options.element||this.options.elementEnd&&e===this.options.elementEnd)},t.prototype.shouldResetDatePicked=function(){return this.options.singleMode||2===this.datePicked.length},t.prototype.shouldSwapDatePicked=function(){return 2===this.datePicked.length&&this.datePicked[0].getTime()>this.datePicked[1].getTime()},t.prototype.shouldCheckLockDays=function(){return this.options.disallowLockDaysInRange&&2===this.datePicked.length},t.prototype.onClick=function(e){var t=e.target;if(e.target.shadowRoot&&(t=e.composedPath()[0]),t&&this.ui)if(this.shouldShown(t))this.show(t);else if(t.closest("."+l.litepicker)||!this.isShowning()){if(this.isSamePicker(t))if(this.emit("before:click",t),this.preventClick)this.preventClick=!1;else{if(t.classList.contains(l.dayItem)){if(e.preventDefault(),t.classList.contains(l.isLocked))return;if(this.shouldResetDatePicked()&&(this.datePicked.length=0),this.datePicked[this.datePicked.length]=new a.DateTime(t.dataset.time),this.shouldSwapDatePicked()){var n=this.datePicked[1].clone();this.datePicked[1]=this.datePicked[0].clone(),this.datePicked[0]=n.clone()}return this.shouldCheckLockDays()&&c.rangeIsLocked(this.datePicked,this.options)&&(this.emit("error:range",this.datePicked),this.datePicked.length=0),this.render(),this.emit.apply(this,r(["preselect"],r(this.datePicked).map(function(e){return e.clone()}))),void(this.options.autoApply&&(this.options.singleMode&&this.datePicked.length?(this.setDate(this.datePicked[0]),this.hide()):this.options.singleMode||2!==this.datePicked.length||(this.setDateRange(this.datePicked[0],this.datePicked[1]),this.hide())))}if(t.classList.contains(l.buttonPreviousMonth)){e.preventDefault();var i=0,s=this.options.switchingMonths||this.options.numberOfMonths;if(this.options.splitView){var o=t.closest("."+l.monthItem);i=c.findNestedMonthItem(o),s=1}return this.calendars[i].setMonth(this.calendars[i].getMonth()-s),this.gotoDate(this.calendars[i],i),void this.emit("change:month",this.calendars[i],i)}if(t.classList.contains(l.buttonNextMonth))return e.preventDefault(),i=0,s=this.options.switchingMonths||this.options.numberOfMonths,this.options.splitView&&(o=t.closest("."+l.monthItem),i=c.findNestedMonthItem(o),s=1),this.calendars[i].setMonth(this.calendars[i].getMonth()+s),this.gotoDate(this.calendars[i],i),void this.emit("change:month",this.calendars[i],i);t.classList.contains(l.buttonCancel)&&(e.preventDefault(),this.hide(),this.emit("button:cancel")),t.classList.contains(l.buttonApply)&&(e.preventDefault(),this.options.singleMode&&this.datePicked.length?this.setDate(this.datePicked[0]):this.options.singleMode||2!==this.datePicked.length||this.setDateRange(this.datePicked[0],this.datePicked[1]),this.hide(),this.emit("button:apply",this.options.startDate,this.options.endDate))}}else this.hide()},t.prototype.showTooltip=function(e,t){var n=this.ui.querySelector("."+l.containerTooltip);n.style.visibility="visible",n.innerHTML=t;var i=this.ui.getBoundingClientRect(),s=n.getBoundingClientRect(),r=e.getBoundingClientRect(),o=r.top,a=r.left;if(this.options.inlineMode&&this.options.parentEl){var c=this.ui.parentNode.getBoundingClientRect();o-=c.top,a-=c.left}else o-=i.top,a-=i.left;o-=s.height,a-=s.width/2,a+=r.width/2,n.style.top=o+"px",n.style.left=a+"px",this.emit("tooltip",n,e)},t.prototype.hideTooltip=function(){this.ui.querySelector("."+l.containerTooltip).style.visibility="hidden"},t.prototype.shouldAllowMouseEnter=function(e){return!this.options.singleMode&&!e.classList.contains(l.isLocked)},t.prototype.shouldAllowRepick=function(){return this.options.elementEnd&&this.options.allowRepick&&this.options.startDate&&this.options.endDate},t.prototype.isDayItem=function(e){return e.classList.contains(l.dayItem)},t.prototype.onMouseEnter=function(e){var t=this,n=e.target;if(this.isDayItem(n)&&this.shouldAllowMouseEnter(n)){if(this.shouldAllowRepick()&&(this.triggerElement===this.options.element?this.datePicked[0]=this.options.endDate.clone():this.triggerElement===this.options.elementEnd&&(this.datePicked[0]=this.options.startDate.clone())),1!==this.datePicked.length)return;var i=this.ui.querySelector("."+l.dayItem+'[data-time="'+this.datePicked[0].getTime()+'"]'),s=this.datePicked[0].clone(),r=new a.DateTime(n.dataset.time),o=!1;if(s.getTime()>r.getTime()){var c=s.clone();s=r.clone(),r=c.clone(),o=!0}if(Array.prototype.slice.call(this.ui.querySelectorAll("."+l.dayItem)).forEach(function(e){var n=new a.DateTime(e.dataset.time),i=t.renderDay(n);n.isBetween(s,r)&&i.classList.add(l.isInRange),e.className=i.className}),n.classList.add(l.isEndDate),o?(i&&i.classList.add(l.isFlipped),n.classList.add(l.isFlipped)):(i&&i.classList.remove(l.isFlipped),n.classList.remove(l.isFlipped)),this.options.showTooltip){var u=r.diff(s,"day")+1;if("function"==typeof this.options.tooltipNumber&&(u=this.options.tooltipNumber.call(this,u)),u>0){var d=this.pluralSelector(u),h=u+" "+(this.options.tooltipText[d]?this.options.tooltipText[d]:"["+d+"]");this.showTooltip(n,h);var p=window.navigator.userAgent,m=/(iphone|ipad)/i.test(p),f=/OS 1([0-2])/i.test(p);m&&f&&n.dispatchEvent(new Event("click"))}else this.hideTooltip()}}},t.prototype.onMouseLeave=function(e){e.target,this.options.allowRepick&&(!this.options.allowRepick||this.options.startDate||this.options.endDate)&&(this.datePicked.length=0,this.render())},t.prototype.onInput=function(e){var t=this.parseInput(),n=t[0],i=t[1],s=this.options.format;if(this.options.elementEnd?n instanceof a.DateTime&&i instanceof a.DateTime&&n.format(s)===this.options.element.value&&i.format(s)===this.options.elementEnd.value:this.options.singleMode?n instanceof a.DateTime&&n.format(s)===this.options.element.value:n instanceof a.DateTime&&i instanceof a.DateTime&&""+n.format(s)+this.options.delimiter+i.format(s)===this.options.element.value){if(i&&n.getTime()>i.getTime()){var r=n.clone();n=i.clone(),i=r.clone()}this.options.startDate=new a.DateTime(n,this.options.format,this.options.lang),i&&(this.options.endDate=new a.DateTime(i,this.options.format,this.options.lang)),this.updateInput(),this.render();var o=n.clone(),l=0;(this.options.elementEnd?n.format(s)===e.target.value:e.target.value.startsWith(n.format(s)))||(o=i.clone(),l=this.options.numberOfMonths-1),this.emit("selected",this.getStartDate(),this.getEndDate()),this.gotoDate(o,l)}},t}(o.Calendar);t.Litepicker=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findNestedMonthItem=function(e){for(var t=e.parentNode.childNodes,n=0;ny&&((p=document.createElement("option")).value=String(e.getFullYear()),p.text=String(e.getFullYear()),p.selected=!0,p.disabled=!0,g.appendChild(p)),h=y;h>=v;h-=1){p=document.createElement("option");var b=new o.DateTime(new Date(h,0,1,0,0,0));p.value=String(h),p.text=String(h),p.disabled=this.options.minDate&&b.isBefore(new o.DateTime(this.options.minDate),"year")||this.options.maxDate&&b.isAfter(new o.DateTime(this.options.maxDate),"year"),p.selected=e.getFullYear()===h,g.appendChild(p)}if(e.getFullYear()W");for(var D=1;D<=7;D+=1){var S=3+this.options.firstDay+D,x=document.createElement("div");x.innerHTML=this.weekdayName(S),x.title=this.weekdayName(S,"long"),E.appendChild(x)}var O=document.createElement("div");O.className=a.containerDays;var L=this.calcSkipDays(i);this.options.showWeekNumbers&&L&&O.appendChild(this.renderWeekNumber(i));for(var C=0;C1&&1===this.datePicked.length){var s=this.options.minDays-1,r=this.datePicked[0].clone().subtract(s,"day"),c=this.datePicked[0].clone().add(s,"day");e.isBetween(r,this.datePicked[0],"(]")&&t.classList.add(a.isLocked),e.isBetween(this.datePicked[0],c,"[)")&&t.classList.add(a.isLocked)}if(this.options.maxDays&&1===this.datePicked.length){var u=this.options.maxDays;r=this.datePicked[0].clone().subtract(u,"day"),c=this.datePicked[0].clone().add(u,"day"),e.isSameOrBefore(r)&&t.classList.add(a.isLocked),e.isSameOrAfter(c)&&t.classList.add(a.isLocked)}return this.options.selectForward&&1===this.datePicked.length&&e.isBefore(this.datePicked[0])&&t.classList.add(a.isLocked),this.options.selectBackward&&1===this.datePicked.length&&e.isAfter(this.datePicked[0])&&t.classList.add(a.isLocked),l.dateIsLocked(e,this.options,this.datePicked)&&t.classList.add(a.isLocked),this.options.highlightedDays.length&&this.options.highlightedDays.filter(function(t){return t instanceof Array?e.isBetween(t[0],t[1],"[]"):t.isSame(e,"day")}).length&&t.classList.add(a.isHighlighted),t.tabIndex=t.classList.contains("is-locked")?-1:0,this.emit("render:day",t,e),t},t.prototype.renderFooter=function(){var e=document.createElement("div");if(e.className=a.containerFooter,this.options.footerHTML?e.innerHTML=this.options.footerHTML:e.innerHTML='\n \n \n \n ",this.options.singleMode){if(1===this.datePicked.length){var t=this.datePicked[0].format(this.options.format,this.options.lang);e.querySelector("."+a.previewDateRange).innerHTML=t}}else if(1===this.datePicked.length&&e.querySelector("."+a.buttonApply).setAttribute("disabled",""),2===this.datePicked.length){t=this.datePicked[0].format(this.options.format,this.options.lang);var n=this.datePicked[1].format(this.options.format,this.options.lang);e.querySelector("."+a.previewDateRange).innerHTML=""+t+this.options.delimiter+n}return this.emit("render:footer",e),e},t.prototype.renderWeekNumber=function(e){var t=document.createElement("div"),n=e.getWeek(this.options.firstDay);return t.className=a.weekNumber,t.innerHTML=53===n&&0===e.getMonth()?"53 / 1":n,t},t.prototype.renderTooltip=function(){var e=document.createElement("div");return e.className=a.containerTooltip,e},t.prototype.weekdayName=function(e,t){return void 0===t&&(t="short"),new Date(1970,0,e,12,0,0,0).toLocaleString(this.options.lang,{weekday:t})},t.prototype.calcSkipDays=function(e){var t=e.getDay()-this.options.firstDay;return t<0&&(t+=7),t},t}(r.LPCore);t.Calendar=c},function(e,t,n){"use strict";var i,s=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,i=arguments.length;n',nextMonth:'',reset:'\n \n \n '},tooltipText:{one:"day",other:"days"}},n.options=r(r({},n.options),t.element.dataset),Object.keys(n.options).forEach(function(e){"true"!==n.options[e]&&"false"!==n.options[e]||(n.options[e]="true"===n.options[e])});var i=r(r({},n.options.dropdowns),t.dropdowns),s=r(r({},n.options.buttonText),t.buttonText),o=r(r({},n.options.tooltipText),t.tooltipText);n.options=r(r({},n.options),t),n.options.dropdowns=r({},i),n.options.buttonText=r({},s),n.options.tooltipText=r({},o),n.options.elementEnd||(n.options.allowRepick=!1),n.options.lockDays.length&&(n.options.lockDays=a.DateTime.convertArray(n.options.lockDays,n.options.lockDaysFormat)),n.options.highlightedDays.length&&(n.options.highlightedDays=a.DateTime.convertArray(n.options.highlightedDays,n.options.highlightedDaysFormat));var l=n.parseInput(),c=l[0],u=l[1];n.options.startDate&&(n.options.singleMode||n.options.endDate)&&(c=new a.DateTime(n.options.startDate,n.options.format,n.options.lang)),c&&n.options.endDate&&(u=new a.DateTime(n.options.endDate,n.options.format,n.options.lang)),c instanceof a.DateTime&&!isNaN(c.getTime())&&(n.options.startDate=c),n.options.startDate&&u instanceof a.DateTime&&!isNaN(u.getTime())&&(n.options.endDate=u),!n.options.singleMode||n.options.startDate instanceof a.DateTime||(n.options.startDate=null),n.options.singleMode||n.options.startDate instanceof a.DateTime&&n.options.endDate instanceof a.DateTime||(n.options.startDate=null,n.options.endDate=null);for(var d=0;dwindow.innerHeight,c=t.top+r-n.height>=n.height;l&&c&&(o=t.top+r-n.height)}if(/left|right/.test(i[0])||i[1]&&"auto"!==i[1]&&/left|right/.test(i[1]))a=/left|right/.test(i[0])?t[i[0]]+s:t[i[1]]+s,"right"!==i[0]&&"right"!==i[1]||(a-=n.width);else{a=t.left+s,l=t.left+n.width>window.innerWidth;var u=t.right+s-n.width>=0;l&&u&&(a=t.right+s-n.width)}return{left:a,top:o}},t}(o.EventEmitter);t.LPCore=c},function(e,t,n){"use strict";var i,s="object"==typeof Reflect?Reflect:null,r=s&&"function"==typeof s.apply?s.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};i=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var l=10;function c(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,n,i){var s,r,o,a;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),o=r[t]),void 0===o)o=r[t]=n,++e._eventsCount;else if("function"==typeof o?o=r[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,a=l,console&&console.warn&&console.warn(a)}return e}function d(){for(var e=[],t=0;t0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)r(l,this,t);else{var c=l.length,u=f(l,c);for(n=0;n=0;r--)if(n[r]===t||n[r].listener===t){o=n[r].listener,s=r;break}if(s<0)return this;0===s?n.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(e,t,n){(t=n(9)(!1)).push([e.i,':root{--litepicker-container-months-color-bg: #fff;--litepicker-container-months-box-shadow-color: #ddd;--litepicker-footer-color-bg: #fafafa;--litepicker-footer-box-shadow-color: #ddd;--litepicker-tooltip-color-bg: #fff;--litepicker-month-header-color: #333;--litepicker-button-prev-month-color: #9e9e9e;--litepicker-button-next-month-color: #9e9e9e;--litepicker-button-prev-month-color-hover: #2196f3;--litepicker-button-next-month-color-hover: #2196f3;--litepicker-month-width: calc(var(--litepicker-day-width) * 7);--litepicker-month-weekday-color: #9e9e9e;--litepicker-month-week-number-color: #9e9e9e;--litepicker-day-width: 38px;--litepicker-day-color: #333;--litepicker-day-color-hover: #2196f3;--litepicker-is-today-color: #f44336;--litepicker-is-in-range-color: #bbdefb;--litepicker-is-locked-color: #9e9e9e;--litepicker-is-start-color: #fff;--litepicker-is-start-color-bg: #2196f3;--litepicker-is-end-color: #fff;--litepicker-is-end-color-bg: #2196f3;--litepicker-button-cancel-color: #fff;--litepicker-button-cancel-color-bg: #9e9e9e;--litepicker-button-apply-color: #fff;--litepicker-button-apply-color-bg: #2196f3;--litepicker-button-reset-color: #909090;--litepicker-button-reset-color-hover: #2196f3;--litepicker-highlighted-day-color: #333;--litepicker-highlighted-day-color-bg: #ffeb3b}.show-week-numbers{--litepicker-month-width: calc(var(--litepicker-day-width) * 8)}.litepicker{font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;font-size:0.8em;display:none}.litepicker button{border:none;background:none}.litepicker .container__main{display:-webkit-box;display:-ms-flexbox;display:flex}.litepicker .container__months{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;background-color:var(--litepicker-container-months-color-bg);border-radius:5px;-webkit-box-shadow:0 0 5px var(--litepicker-container-months-box-shadow-color);box-shadow:0 0 5px var(--litepicker-container-months-box-shadow-color);width:calc(var(--litepicker-month-width) + 10px);-webkit-box-sizing:content-box;box-sizing:content-box}.litepicker .container__months.columns-2{width:calc((var(--litepicker-month-width) * 2) + 20px)}.litepicker .container__months.columns-3{width:calc((var(--litepicker-month-width) * 3) + 30px)}.litepicker .container__months.columns-4{width:calc((var(--litepicker-month-width) * 4) + 40px)}.litepicker .container__months.split-view .month-item-header .button-previous-month,.litepicker .container__months.split-view .month-item-header .button-next-month{visibility:visible}.litepicker .container__months .month-item{padding:5px;width:var(--litepicker-month-width);-webkit-box-sizing:content-box;box-sizing:content-box}.litepicker .container__months .month-item-header{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;font-weight:500;padding:10px 5px;text-align:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--litepicker-month-header-color)}.litepicker .container__months .month-item-header div{-webkit-box-flex:1;-ms-flex:1;flex:1}.litepicker .container__months .month-item-header div>.month-item-name{margin-right:5px}.litepicker .container__months .month-item-header div>.month-item-year{padding:0}.litepicker .container__months .month-item-header .reset-button{color:var(--litepicker-button-reset-color)}.litepicker .container__months .month-item-header .reset-button>svg{fill:var(--litepicker-button-reset-color)}.litepicker .container__months .month-item-header .reset-button *{pointer-events:none}.litepicker .container__months .month-item-header .reset-button:hover{color:var(--litepicker-button-reset-color-hover)}.litepicker .container__months .month-item-header .reset-button:hover>svg{fill:var(--litepicker-button-reset-color-hover)}.litepicker .container__months .month-item-header .button-previous-month,.litepicker .container__months .month-item-header .button-next-month{visibility:hidden;text-decoration:none;padding:3px 5px;border-radius:3px;-webkit-transition:color 0.3s, border 0.3s;transition:color 0.3s, border 0.3s;cursor:default}.litepicker .container__months .month-item-header .button-previous-month *,.litepicker .container__months .month-item-header .button-next-month *{pointer-events:none}.litepicker .container__months .month-item-header .button-previous-month{color:var(--litepicker-button-prev-month-color)}.litepicker .container__months .month-item-header .button-previous-month>svg,.litepicker .container__months .month-item-header .button-previous-month>img{fill:var(--litepicker-button-prev-month-color)}.litepicker .container__months .month-item-header .button-previous-month:hover{color:var(--litepicker-button-prev-month-color-hover)}.litepicker .container__months .month-item-header .button-previous-month:hover>svg{fill:var(--litepicker-button-prev-month-color-hover)}.litepicker .container__months .month-item-header .button-next-month{color:var(--litepicker-button-next-month-color)}.litepicker .container__months .month-item-header .button-next-month>svg,.litepicker .container__months .month-item-header .button-next-month>img{fill:var(--litepicker-button-next-month-color)}.litepicker .container__months .month-item-header .button-next-month:hover{color:var(--litepicker-button-next-month-color-hover)}.litepicker .container__months .month-item-header .button-next-month:hover>svg{fill:var(--litepicker-button-next-month-color-hover)}.litepicker .container__months .month-item-weekdays-row{display:-webkit-box;display:-ms-flexbox;display:flex;justify-self:center;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;color:var(--litepicker-month-weekday-color)}.litepicker .container__months .month-item-weekdays-row>div{padding:5px 0;font-size:85%;-webkit-box-flex:1;-ms-flex:1;flex:1;width:var(--litepicker-day-width);text-align:center}.litepicker .container__months .month-item:first-child .button-previous-month{visibility:visible}.litepicker .container__months .month-item:last-child .button-next-month{visibility:visible}.litepicker .container__months .month-item.no-previous-month .button-previous-month{visibility:hidden}.litepicker .container__months .month-item.no-next-month .button-next-month{visibility:hidden}.litepicker .container__days{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;justify-self:center;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;text-align:center;-webkit-box-sizing:content-box;box-sizing:content-box}.litepicker .container__days>div,.litepicker .container__days>a{padding:5px 0;width:var(--litepicker-day-width)}.litepicker .container__days .day-item{color:var(--litepicker-day-color);text-align:center;text-decoration:none;border-radius:3px;-webkit-transition:color 0.3s, border 0.3s;transition:color 0.3s, border 0.3s;cursor:default}.litepicker .container__days .day-item:hover{color:var(--litepicker-day-color-hover);-webkit-box-shadow:inset 0 0 0 1px var(--litepicker-day-color-hover);box-shadow:inset 0 0 0 1px var(--litepicker-day-color-hover)}.litepicker .container__days .day-item.is-today{color:var(--litepicker-is-today-color)}.litepicker .container__days .day-item.is-locked{color:var(--litepicker-is-locked-color)}.litepicker .container__days .day-item.is-locked:hover{color:var(--litepicker-is-locked-color);-webkit-box-shadow:none;box-shadow:none;cursor:default}.litepicker .container__days .day-item.is-in-range{background-color:var(--litepicker-is-in-range-color);border-radius:0}.litepicker .container__days .day-item.is-start-date{color:var(--litepicker-is-start-color);background-color:var(--litepicker-is-start-color-bg);border-top-left-radius:5px;border-bottom-left-radius:5px;border-top-right-radius:0;border-bottom-right-radius:0}.litepicker .container__days .day-item.is-start-date.is-flipped{border-top-left-radius:0;border-bottom-left-radius:0;border-top-right-radius:5px;border-bottom-right-radius:5px}.litepicker .container__days .day-item.is-end-date{color:var(--litepicker-is-end-color);background-color:var(--litepicker-is-end-color-bg);border-top-left-radius:0;border-bottom-left-radius:0;border-top-right-radius:5px;border-bottom-right-radius:5px}.litepicker .container__days .day-item.is-end-date.is-flipped{border-top-left-radius:5px;border-bottom-left-radius:5px;border-top-right-radius:0;border-bottom-right-radius:0}.litepicker .container__days .day-item.is-start-date.is-end-date{border-top-left-radius:5px;border-bottom-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px}.litepicker .container__days .day-item.is-highlighted{color:var(--litepicker-highlighted-day-color);background-color:var(--litepicker-highlighted-day-color-bg)}.litepicker .container__days .week-number{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;color:var(--litepicker-month-week-number-color);font-size:85%}.litepicker .container__footer{text-align:right;padding:10px 5px;margin:0 5px;background-color:var(--litepicker-footer-color-bg);-webkit-box-shadow:inset 0px 3px 3px 0px var(--litepicker-footer-box-shadow-color);box-shadow:inset 0px 3px 3px 0px var(--litepicker-footer-box-shadow-color);border-bottom-left-radius:5px;border-bottom-right-radius:5px}.litepicker .container__footer .preview-date-range{margin-right:10px;font-size:90%}.litepicker .container__footer .button-cancel{background-color:var(--litepicker-button-cancel-color-bg);color:var(--litepicker-button-cancel-color);border:0;padding:3px 7px 4px;border-radius:3px}.litepicker .container__footer .button-cancel *{pointer-events:none}.litepicker .container__footer .button-apply{background-color:var(--litepicker-button-apply-color-bg);color:var(--litepicker-button-apply-color);border:0;padding:3px 7px 4px;border-radius:3px;margin-left:10px;margin-right:10px}.litepicker .container__footer .button-apply:disabled{opacity:0.7}.litepicker .container__footer .button-apply *{pointer-events:none}.litepicker .container__tooltip{position:absolute;margin-top:-4px;padding:4px 8px;border-radius:4px;background-color:var(--litepicker-tooltip-color-bg);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.25);box-shadow:0 1px 3px rgba(0,0,0,0.25);white-space:nowrap;font-size:11px;pointer-events:none;visibility:hidden}.litepicker .container__tooltip:before{position:absolute;bottom:-5px;left:calc(50% - 5px);border-top:5px solid rgba(0,0,0,0.12);border-right:5px solid transparent;border-left:5px solid transparent;content:""}.litepicker .container__tooltip:after{position:absolute;bottom:-4px;left:calc(50% - 4px);border-top:4px solid var(--litepicker-tooltip-color-bg);border-right:4px solid transparent;border-left:4px solid transparent;content:""}\n',""]),t.locals={showWeekNumbers:"show-week-numbers",litepicker:"litepicker",containerMain:"container__main",containerMonths:"container__months",columns2:"columns-2",columns3:"columns-3",columns4:"columns-4",splitView:"split-view",monthItemHeader:"month-item-header",buttonPreviousMonth:"button-previous-month",buttonNextMonth:"button-next-month",monthItem:"month-item",monthItemName:"month-item-name",monthItemYear:"month-item-year",resetButton:"reset-button",monthItemWeekdaysRow:"month-item-weekdays-row",noPreviousMonth:"no-previous-month",noNextMonth:"no-next-month",containerDays:"container__days",dayItem:"day-item",isToday:"is-today",isLocked:"is-locked",isInRange:"is-in-range",isStartDate:"is-start-date",isFlipped:"is-flipped",isEndDate:"is-end-date",isHighlighted:"is-highlighted",weekNumber:"week-number",containerFooter:"container__footer",previewDateRange:"preview-date-range",buttonCancel:"button-cancel",buttonApply:"button-apply",containerTooltip:"container__tooltip"},e.exports=t},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n,i,s,r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var a=(n=o,i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),"/*# ".concat(s," */")),l=o.sources.map(function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")});return[r].concat(l).concat([a]).join("\n")}return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n}).join("")},t.i=function(e,n,i){"string"==typeof e&&(e=[[null,e,""]]);var s={};if(i)for(var r=0;rthis.options.endDate.getTime()&&(this.options.endDate=this.options.startDate.clone(),this.options.startDate=new s.DateTime(e,this.options.format,this.options.lang)),this.updateInput())},r.Litepicker.prototype.setDateRange=function(e,t,n){void 0===n&&(n=!1),this.triggerElement=void 0;var i=new s.DateTime(e,this.options.format,this.options.lang),r=new s.DateTime(t,this.options.format,this.options.lang);(this.options.disallowLockDaysInRange?o.rangeIsLocked([i,r],this.options):o.dateIsLocked(i,this.options,[i,r])||o.dateIsLocked(r,this.options,[i,r]))&&!n?this.emit("error:range",[i,r]):(this.setStartDate(i),this.setEndDate(r),this.options.inlineMode&&this.render(),this.updateInput(),this.emit("selected",this.getStartDate(),this.getEndDate()))},r.Litepicker.prototype.gotoDate=function(e,t){void 0===t&&(t=0);var n=new s.DateTime(e);n.setDate(1),this.calendars[t]=n.clone(),this.render()},r.Litepicker.prototype.setLockDays=function(e){this.options.lockDays=s.DateTime.convertArray(e,this.options.lockDaysFormat),this.render()},r.Litepicker.prototype.setHighlightedDays=function(e){this.options.highlightedDays=s.DateTime.convertArray(e,this.options.highlightedDaysFormat),this.render()},r.Litepicker.prototype.setOptions=function(e){delete e.element,delete e.elementEnd,delete e.parentEl,e.startDate&&(e.startDate=new s.DateTime(e.startDate,this.options.format,this.options.lang)),e.endDate&&(e.endDate=new s.DateTime(e.endDate,this.options.format,this.options.lang));var t=i(i({},this.options.dropdowns),e.dropdowns),n=i(i({},this.options.buttonText),e.buttonText),r=i(i({},this.options.tooltipText),e.tooltipText);this.options=i(i({},this.options),e),this.options.dropdowns=i({},t),this.options.buttonText=i({},n),this.options.tooltipText=i({},r),!this.options.singleMode||this.options.startDate instanceof s.DateTime||(this.options.startDate=null,this.options.endDate=null),this.options.singleMode||this.options.startDate instanceof s.DateTime&&this.options.endDate instanceof s.DateTime||(this.options.startDate=null,this.options.endDate=null);for(var o=0;o'),null!==e.url){if(n+='"}this.createFromClickEvent(e,n)}createFromClickEvent(e,t){const n=this.getContextMenuElement();n.classList.contains("action-dropdown")||n.classList.add("action-dropdown"),n.innerHTML=t,n.style.position="fixed",n.style.top=e.clientY+"px",n.style.left=e.clientX+"px";const i=e=>{e.target.classList.contains("dropdown-toggle")||e.target.classList.contains("dropdown-divider")||(n.classList.remove("d-block"),n.classList.contains("d-none")||n.classList.add("d-none"),n.removeEventListener("click",i),document.removeEventListener("click",i))};n.addEventListener("click",i),document.addEventListener("click",i),n.classList.remove("d-none"),n.classList.contains("d-block")||n.classList.add("d-block")}static createForDataTable(e){[].slice.call(document.querySelectorAll(e)).map(e=>{null!==e.querySelector("td.actions div.dropdown-menu")&&e.addEventListener("contextmenu",t=>{let n=t.target;for(;null!==n;){const e=n.tagName.toUpperCase();if("TH"===e||"TABLE"===e||"BODY"===e)return;if("TR"===e)break;n=n.parentNode}if(null===n||!n.matches("table.dataTable tbody tr"))return;const s=n.querySelector("td.actions div.dropdown-menu");if(null===s)return;t.preventDefault();new i(e.dataset.contextMenu).createFromClickEvent(t,s.innerHTML)})})}}},4028:function(e,t,n){n(4975),n(5366),n.g.KimaiPaginatedBoxWidget=n(4100).A,n.g.KimaiReloadPageWidget=n(5170).A,n.g.KimaiColor=n(9997).A,n.g.KimaiStorage=n(5247).A},4100:function(e,t,n){"use strict";n.d(t,{A:function(){return s}});var i=n(2758);class s{constructor(e){this.selector=e;const t=document.querySelector(this.selector);if(void 0!==t.dataset.reload){this.events=t.dataset.reload.split(" ");const e=()=>{let e=null;e=void 0!==document.querySelector(this.selector).dataset.reloadHref?document.querySelector(this.selector).dataset.reloadHref:document.querySelector(this.selector+" ul.pagination li.active a").href,this.loadPage(e)};for(const t of this.events)document.addEventListener(t,e)}document.body.addEventListener("click",e=>{let t=e.target;t.matches(this.selector+" a.pagination-link")||(t=t.parentNode),t.matches(this.selector+" a.pagination-link")&&(e.preventDefault(),this.loadPage(t.href))})}static create(e){return new s(e)}loadPage(e){const t=this.selector;document.dispatchEvent(new CustomEvent("kimai.reloadContent",{detail:this.selector}));const n=()=>{document.dispatchEvent(new Event("kimai.reloadedContent"))};window.kimai.getPlugin("fetch").fetch(e).then(e=>{e.text().then(e=>{const s=document.createElement("div");s.innerHTML=e,document.querySelector(t).replaceWith(this._makeScriptExecutable(s.firstElementChild)),i.A.createForDataTable(t+" table.dataTable"),n()})}).catch(()=>{window.kimai.getPlugin("alert").error("Failed loading selected page"),n()})}_makeScriptExecutable(e){if(void 0!==e.tagName&&"SCRIPT"===e.tagName){const t=document.createElement("script");t.text=e.innerHTML,e.parentNode.replaceChild(t,e)}else for(const t of e.childNodes)this._makeScriptExecutable(t);return e}}},4975:function(e,t,n){"use strict";n.r(t)},5170:function(e,t,n){"use strict";n.d(t,{A:function(){return i}});class i{constructor(e,t){const n=()=>{t?document.location.reload():this._loadPage(document.location)};for(const t of e.split(" "))document.addEventListener(t,n)}static create(e,t){return null==t&&(t=!1),new i(e,t)}_showOverlay(){document.dispatchEvent(new CustomEvent("kimai.reloadContent",{detail:"div.page-wrapper"}))}_hideOverlay(){document.dispatchEvent(new Event("kimai.reloadedContent"))}_loadPage(e){this._showOverlay(),window.kimai.getPlugin("fetch").fetch(e).then(e=>{e.text().then(e=>{const t=document.createElement("div");t.innerHTML=e;const n=t.querySelector("section.content");document.querySelector("section.content").replaceWith(n),document.dispatchEvent(new Event("kimai.reloadPage")),this._hideOverlay()})}).catch(()=>{this._hideOverlay(),document.location=e})}}},5247:function(e,t,n){"use strict";n.d(t,{A:function(){return i}});class i{static set(e,t){window.localStorage.setItem(e,JSON.stringify(t))}static get(e){let t=window.localStorage.getItem(e);return null==t?null:JSON.parse(t)}static remove(e){window.localStorage.removeItem(e)}}},5366:function(e,t,n){"use strict";var i=n(8097);class s{constructor(e){this._translations=e}get(e){return this._translations[e]}has(e){return e in this._translations}}class r{constructor(e){this._configurations=e}get(e){return this._configurations[e]}has(e){return e in this._configurations}isRTL(){return"rtl"===this.get("direction")}getLanguage(){return this.get("locale").replace("_","-")}is24Hours(){return!!this.get("twentyFourHours")}getFirstDayOfWeek(e=!0){void 0===e&&(e=!0);let t=this.get("first_dow_iso");return e||(t%=7),t}}class o{init(){}getId(){return null}setContainer(e){if(!(e instanceof a))throw new Error("Plugin was given an invalid KimaiContainer");this._core=e}getContainer(){return this._core}getConfiguration(e){return this.getContainer().getConfiguration().get(e)}getConfigurations(){return this.getContainer().getConfiguration()}getDateUtils(){return this.getPlugin("date")}getPlugin(e){return this.getContainer().getPlugin(e)}getTranslation(){return this.getContainer().getTranslation()}translate(e){return this.getTranslation().get(e)}escape(e){return this.getPlugin("escape").escapeForHtml(e)}trigger(e,t=null){this.getPlugin("event").trigger(e,t)}fetch(e,t={}){return this.getPlugin("fetch").fetch(e,t)}fetchForm(e,t={},n=null){n=n||e.getAttribute("action");const i=e.getAttribute("method").toUpperCase();if("GET"===i){const i=this.getPlugin("form").convertFormDataToQueryString(e,{},!0);n=n+(n.includes("?")?"&":"?")+i,t={method:"GET",...t}}else"POST"===i&&(t={method:"POST",body:new FormData(e),...t});return this.fetch(n,t)}isMobile(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)<576}}class a{constructor(e,t){if(!(e instanceof r))throw new Error("Configuration needs to a KimaiConfiguration instance");if(this._configuration=e,!(t instanceof s))throw new Error("Configuration needs to a KimaiTranslation instance");this._translation=t,this._plugins=[]}registerPlugin(e){if(!(e instanceof o))throw new Error("Invalid plugin given, needs to be a KimaiPlugin instance");return e.setContainer(this),this._plugins.push(e),e}getPlugin(e){for(let t of this._plugins)if(null!==t.getId()&&t.getId()===e)return t;throw new Error("Unknown plugin: "+e)}getPlugins(){return this._plugins}getTranslation(){return this._translation}getConfiguration(){return this._configuration}getUser(){return this.getPlugin("user")}}class l extends o{constructor(e){super(),this.dataAttribute=e}getId(){return"datatable-column-visibility"}init(){let e=document.querySelector("["+this.dataAttribute+"]");if(null!==e){this._id=e.getAttribute(this.dataAttribute),this._modal=document.getElementById("modal_"+this._id),this._modal.addEventListener("show.bs.modal",()=>{this._evaluateCheckboxes()}),this._modal.querySelector("button[data-type=save]").addEventListener("click",()=>{this._saveVisibility()}),this._modal.querySelector("button[data-type=reset]").addEventListener("click",e=>{this._resetVisibility(e.currentTarget)}),this._modal.querySelectorAll("input[name=datatable_profile]").forEach(e=>{e.addEventListener("change",()=>{const t=this._modal.getElementsByTagName("form")[0];this.fetchForm(t,{},e.getAttribute("data-href")).then(()=>{localStorage.setItem("kimai_profile",e.getAttribute("value")),document.location.reload()}).catch(()=>{t.setAttribute("action",e.getAttribute("data-href")),t.submit()})})});for(let e of this._modal.querySelectorAll("form input[type=checkbox]"))e.addEventListener("change",()=>{this._changeVisibility(e.getAttribute("name"),e.checked)})}}_evaluateCheckboxes(){const e=this._modal.getElementsByTagName("form")[0],t=document.getElementsByClassName("datatable_"+this._id)[0];for(let n of t.getElementsByTagName("th")){const t=n.getAttribute("data-field");if(null===t)continue;const i=e.querySelector("input[name="+t+"]");null!==i&&(i.checked="none"!==window.getComputedStyle(n).display)}}_saveVisibility(){const e=this._modal.getElementsByTagName("form")[0];this.fetchForm(e).then(()=>{document.location.reload()}).catch(()=>{e.submit()})}_resetVisibility(e){const t=this._modal.getElementsByTagName("form")[0];this.fetchForm(t,{},e.getAttribute("formaction")).then(()=>{document.location.reload()}).catch(()=>{t.setAttribute("action",e.getAttribute("formaction")),t.submit()})}_changeVisibility(e,t){for(const n of document.getElementsByClassName("datatable_"+this._id)){let i=null;for(let s of n.getElementsByClassName("col_"+e)){if(null===i){let e="-none",n="d-table-cell";t||(e="-table-cell",n="d-none"),i="",s.classList.forEach(function(t,n,s){-1===t.indexOf(e)&&(i+=" "+t)}),-1===i.indexOf(n)&&(i+=" "+n)}s.className=i}}}}var c=n(9336);class u extends o{init(){[].slice.call(document.querySelectorAll('[data-toggle="tooltip"]')).map(function(e){return new c.m_(e)});[...document.querySelectorAll(".offcanvas")].map(e=>new c.go(e));this.getContainer().getPlugin("form").activateForm("div.page-wrapper form"),this._registerModalAutofocus("#remote_form_modal"),this.overlay=null,document.addEventListener("kimai.reloadContent",e=>{if(null!==this.overlay)return;let t="div.page-wrapper";void 0!==e.detail&&null!==e.detail&&(t=e.detail);const n=document.createElement("div");n.innerHTML='
',this.overlay=n.firstElementChild,document.querySelector(t).append(this.overlay)}),document.addEventListener("kimai.reloadedContent",()=>{null!==this.overlay&&(this.overlay.remove(),this.overlay=null)})}_registerModalAutofocus(e){if(this.isMobile())return;const t=document.querySelector(e);null!==t&&t.addEventListener("shown.bs.modal",()=>{const e=t.querySelector("form");let n=e.querySelectorAll("[autofocus]");n.length<1&&(n=e.querySelectorAll("input[type=text],input[type=date],textarea,select")),n.length>0&&n[0].focus()})}}var d=n(424);n(8214);class h extends o{supportsForm(e){return!1}activateForm(e){}destroyForm(e){}}class p extends h{constructor(e){super(),this._selector=e}init(){window.disableLitepickerStyles=!0,this._pickers=[]}supportsForm(e){return!0}activateForm(e){const t=this.getConfigurations().getFirstDayOfWeek(!1),n=this.getConfigurations().getLanguage();let i={buttonText:{previousMonth:'',nextMonth:'',apply:this.translate("confirm"),cancel:this.translate("cancel")}};const s=[].slice.call(e.querySelectorAll(this._selector)).map(e=>(void 0===e.dataset.format&&console.log("Trying to bind litepicker to an element without data-format attribute"),void 0!==e.hasAttribute("min")&&(i={...i,minDate:e.getAttribute("min")}),void 0!==e.hasAttribute("max")&&(i={...i,maxDate:e.getAttribute("max")}),i={...i,format:e.dataset.format,showTooltip:!1,element:e,lang:n,autoRefresh:!0,firstDay:t,setup:t=>{t.on("preselect",(e,n)=>{t._wasPreselected=!0}),t.on("selected",(n,i)=>{void 0!==t._wasPreselected&&(e.dispatchEvent(new Event("change",{bubbles:!0})),delete t._wasPreselected)}),void 0!==t.backdrop&&document.body.appendChild(t.backdrop)}},[e,new d.Litepicker(this.prepareOptions(i))]));this._pickers=this._pickers.concat(s)}prepareOptions(e){return{...e,plugins:["mobilefriendly"]}}destroyForm(e){[].slice.call(e.querySelectorAll(this._selector)).map(e=>{for(let t=0;t{this.reloadDatatable()};for(let e of t.split(" "))document.addEventListener(e,n);document.addEventListener("pagination-change",n),document.addEventListener("filter-change",n)}registerContextMenu(e){f.A.createForDataTable(e)}reloadDatatable(){const e=this.getContainer().getPlugin("toolbar").getSelector(),t=document.querySelector(e),n=e=>{const t=document.createElement("div");t.innerHTML=e;const n=t.querySelector(this._contentArea);document.querySelector(this._contentArea).replaceWith(n),this.registerContextMenu(this._selector),document.dispatchEvent(new Event("kimai.reloadedContent"))};document.dispatchEvent(new CustomEvent("kimai.reloadContent",{detail:this._contentArea})),null!==t?this.fetchForm(t).then(e=>{e.text().then(n)}).catch(()=>{t.submit()}):this.fetch(document.location).then(e=>{e.text().then(n)}).catch(()=>{document.location.reload()})}}class v extends o{constructor(e,t){super(),this._formSelector=e,this._actionClass=t}getId(){return"toolbar"}init(){const e=this.getSelector();this._registerPagination(e),this._registerSortableTables(e),this._registerAlternativeSubmitActions(e,this._actionClass),[].slice.call(document.querySelectorAll(e+" input")).map(t=>{t.addEventListener("change",t=>{switch(t.target.id){case"order":case"orderBy":case"page":break;default:document.querySelector(e+" input#page").value=1}}),this.triggerChange()}),[].slice.call(document.querySelectorAll(e+" select")).map(t=>{t.addEventListener("change",t=>{let n=!0;switch(t.target.id){case"customer":null!==document.querySelector(e+" select#project")&&(n=!1);break;case"project":null!==document.querySelector(e+" select#activity")&&(n=!1)}document.querySelector(e+" input#page").value=1,n&&this.triggerChange()})})}_registerAlternativeSubmitActions(e,t){document.addEventListener("click",function(n){let i=n.target;for(;null!==i&&"function"==typeof i.matches&&!i.matches("body");){if(i.classList.contains(t)){const t=document.querySelector(e);if(null===t)return;const s=t.getAttribute("action"),r=t.getAttribute("method");void 0!==i.dataset.target&&(t.target=i.dataset.target),t.action=i.href,void 0!==i.dataset.method&&(t.method=i.dataset.method),t.submit(),t.target="",t.action=s,t.method=r,n.preventDefault(),n.stopPropagation()}i=i.parentNode}})}_registerSortableTables(e){document.body.addEventListener("click",t=>{if(!t.target.matches("th.sortable"))return;let n="DESC",i=t.target.dataset.order;t.target.classList.contains("sorting_desc")&&(n="ASC"),document.querySelector(e+" #orderBy").value=i,document.querySelector(e+" #order").value=n,document.querySelector(e+" #orderBy").dispatchEvent(new Event("change")),document.querySelector(e+" #order").dispatchEvent(new Event("change")),document.dispatchEvent(new Event("filter-change"))})}_registerPagination(e){document.body.addEventListener("click",t=>{if(!(t.target.matches("ul.pagination li a")||null!==t.target.parentNode&&t.target.parentNode.matches("ul.pagination li a")))return;let n=document.querySelector(e+" input#page");if(null===n)return;let i=t.target;i.matches("a")||(i=i.parentNode),t.preventDefault(),t.stopPropagation();let s=i.href.split("/"),r=s[s.length-1];return/\d/.test(r)||(r=1),n.value=r,n.dispatchEvent(new Event("change")),document.dispatchEvent(new Event("pagination-change")),!1})}triggerChange(){document.dispatchEvent(new Event("toolbar-change"))}getSelector(){return this._formSelector}}class y extends o{getId(){return"api"}_headers(){const e=new Headers;return e.append("Content-Type","application/json"),e}get(e,t,n,i){if(void 0!==t){const n=new URLSearchParams(t).toString();""!==n&&(e=e+(e.includes("?")?"&":"?")+n)}void 0===i&&(i=e=>{this.handleError("An error occurred",e)}),this.fetch(e,{method:"GET",headers:this._headers()}).then(e=>{e.json().then(e=>{n(e)})}).catch(e=>{i(e)})}post(e,t,n,i){void 0===i&&(i=e=>{this.handleError("action.update.error",e)}),this.fetch(e,{method:"POST",body:this._parseData(t),headers:this._headers()}).then(e=>{e.json().then(e=>{n(e)})}).catch(e=>{i(e)})}patch(e,t,n,i){void 0===i&&(i=e=>{this.handleError("action.update.error",e)}),this.fetch(e,{method:"PATCH",body:this._parseData(t),headers:this._headers()}).then(e=>{204===e.statusCode?n():e.json().then(e=>{n(e)})}).catch(e=>{i(e)})}delete(e,t,n){void 0===n&&(n=e=>{this.handleError("action.delete.error",e)}),this.fetch(e,{method:"DELETE",headers:this._headers()}).then(()=>{t()}).catch(e=>{n(e)})}_parseData(e){return"object"==typeof e?JSON.stringify(e):e}handleError(e,t){if(void 0===t.headers)return;const n=t.headers.get("content-type");n&&-1!==n.indexOf("application/json")?t.json().then(n=>{let i=n.message;if(400===t.status&&n.errors){let e=[""+i+""];if(n.errors.errors)for(let t of n.errors.errors)e.push(t);if(n.errors.children)for(let t in n.errors.children){let i=n.errors.children[t];if(void 0!==i.errors&&i.errors.length>0)for(let t of i.errors)e.push(t)}e.length>0&&(i=e)}this.getPlugin("alert").error(e,i)}):t.text().then(()=>{const n="["+t.statusCode+"] "+t.statusText;this.getPlugin("alert").error(e,n)})}}class b extends o{addClickHandler(e,t,n){document.body.addEventListener("click",i=>{let s=i.target;for(;null!==s;){const t=s.tagName.toUpperCase();if("BODY"===t)return;if(s.matches(e))break;if("A"===t||"BUTTON"===t||"INPUT"===t||"LABEL"===t)return;for(let e of n)if(s.matches(e))return;s=s.parentNode}if(null===s)return;if(s.isContentEditable||s.parentNode.isContentEditable)return;if(!s.matches(e))return;for(let e of n)if(s.matches(e))return;i.preventDefault(),i.stopPropagation();let r=s.dataset.href;null==r&&(r=s.href),null!=r&&""!==r&&t(r)})}}class _ extends b{constructor(e){super(),this._selector=e}init(){this.addClickHandler(this._selector,function(e){window.location=e},[])}}class w extends b{constructor(e,t){super(),this._selector=e,this._stopSelector=t}getId(){return"modal"}init(){this._isDirty=!1;const e=this._getModalElement();null!==e&&(e.addEventListener("hide.bs.modal",t=>{if(this._isDirty){if(null===e.querySelector(".modal-body .remote_modal_is_dirty_warning")){const t=this.translate("modal.dirty"),n=document.createElement("div");n.innerHTML='

'+t+"

",e.querySelector(".modal-body").prepend(n.firstElementChild)}t.preventDefault()}else this._isDirty=!1,document.dispatchEvent(new Event("modal-hide"))}),e.addEventListener("hidden.bs.modal",()=>{this.getContainer().getPlugin("form").destroyForm(this._getFormIdentifier()),e.querySelector(".modal-body").replaceWith("")}),e.addEventListener("show.bs.modal",()=>{document.dispatchEvent(new Event("modal-show"))}),this.addClickHandler(this._selector,e=>{this.openUrlInModal(e)},this._stopSelector))}_getModal(){return c.aF.getOrCreateInstance(this._getModalElement())}openUrlInModal(e,t){const n=new Headers;n.append("X-Requested-With","Kimai-Modal"),this.fetch(e,{method:"GET",redirect:"follow",headers:n}).then(t=>{if(t.ok)return t.text().then(e=>{this._openFormInModal(e)});window.location=e}).catch(n=>{null==t?window.location=e:t(n)})}_getFormIdentifier(){return"#remote_form_modal .modal-content form"}_getModalElement(){return document.getElementById("remote_form_modal")}_makeScriptExecutable(e){if(void 0!==e.tagName&&"SCRIPT"===e.tagName){const t=document.createElement("script");t.text=e.innerHTML,e.parentNode.replaceChild(t,e)}else for(const t of e.childNodes)this._makeScriptExecutable(t);return e}_openFormInModal(e){const t=this._getFormIdentifier();let n=this._getModalElement();const i=document.createElement("div");i.innerHTML=e;const s=this._makeScriptExecutable(i.querySelector("#form_modal .modal-content"));if(null!==s){let e=n.querySelector(".modal-dialog"),r=i.querySelector(".modal-dialog").classList.contains("modal-lg");r&&!e.classList.contains("modal-lg")&&e.classList.toggle("modal-lg"),!r&&e.classList.contains("modal-lg")&&e.classList.toggle("modal-lg"),n.querySelector(".modal-content").replaceWith(s),[].slice.call(n.querySelectorAll('[data-bs-dismiss="modal"]')).map(e=>{e.addEventListener("click",()=>{this._isDirty=!1,this._getModal().hide()})}),this.getContainer().getPlugin("form").activateForm(t)}let r=i.querySelector("div.alert");null!==r&&n.querySelector(".modal-body").prepend(r);const o=document.querySelector(t);o.addEventListener("change",()=>{this._isDirty=!0}),o.addEventListener("submit",this._getEventHandler()),this._getModal().show()}_getEventHandler(){return void 0===this.eventHandler&&(this.eventHandler=e=>{const t=e.target;if(void 0!==t.target&&""!==t.target)return!0;const n=document.querySelector(this._getFormIdentifier()+" button[type=submit]");n.textContent=n.textContent+" …",n.disabled=!0;const i=t.dataset.formEvent,s=this.getContainer().getPlugin("event");e.preventDefault(),e.stopPropagation();const r=new Headers;r.append("X-Requested-With","Kimai-Modal");const o={headers:r};this.fetchForm(t,o).then(e=>{e.text().then(e=>{const t=document.createElement("div");t.innerHTML=e;let r=!1,o=!1,a=!1;n.textContent=n.textContent.replace(" …",""),n.disabled=!1;const l=t.querySelector("#form_modal .modal-content");null!==l&&(r=null!==l.querySelector(".is-invalid"),r||(r=null!==l.querySelector(".invalid-feedback")),o=null!==l.querySelector("ul.list-unstyled li.text-danger"),a=null!==t.querySelector("div.alert-danger")),r||o||a?this._openFormInModal(e):(s.trigger(i),this._isDirty=!1,this._getModal().hide())})}).catch(e=>{let i=t.dataset.msgError;null!=i&&""!==i||(i="action.update.error");this.getContainer().getPlugin("alert").error(i,e.message),setTimeout(()=>{n.textContent=n.textContent.replace(" …",""),n.disabled=!1},1500)})}),this.eventHandler}}class k extends o{constructor(){super(),this._selector=".ticktac-menu",this._selectorEmpty=".ticktac-menu-empty",this._favIconUrl=null}getId(){return"active-records"}init(){if(null===document.querySelector(this._selector))return;const e=()=>{this.reloadActiveRecords()};document.addEventListener("kimai.timesheetUpdate",e),document.addEventListener("kimai.timesheetDelete",e),document.addEventListener("kimai.activityUpdate",e),document.addEventListener("kimai.activityDelete",e),document.addEventListener("kimai.projectUpdate",e),document.addEventListener("kimai.projectDelete",e),document.addEventListener("kimai.customerUpdate",e),document.addEventListener("kimai.customerDelete",e),this._updateBrowserTitle=!!this.getConfiguration("updateBrowserTitle");const t=()=>{this._updateDuration()};this._updatesHandler=setInterval(t,1e4),document.addEventListener("kimai.timesheetUpdate",t),document.addEventListener("kimai.reloadedContent",t)}_updateDuration(){const e=document.querySelectorAll('[data-since]:not([data-since=""])');if(this._updateBrowserTitle&&this._changeFavicon(e.length>0),0===e.length)return void(this._updateBrowserTitle&&(void 0===document.body.dataset.title?this._updateBrowserTitle=!1:document.title=document.body.dataset.title));const t=this.getDateUtils();let n=[];for(const i of e){const e=t.formatDuration(i.dataset.since);void 0!==i.dataset.replacer&&null!==i.dataset.title&&"?"!==e&&n.push(e),i.textContent=e}0!==n.length&&this._updateBrowserTitle&&(document.title=n.shift())}_setEntries(e){const t=e.length>0;for(let e of document.querySelectorAll(this._selectorEmpty))e.style.display=t?"none":"inline-block";for(let n of document.querySelectorAll(this._selector)){if(n.style.display=t?"inline-block":"none",!t)for(let e of n.querySelectorAll("[data-since]"))e.dataset.since="";const i=n.querySelector(".ticktac-stop");t?(i&&(i.accesskey="s"),this._replaceInNode(n,e[0])):i&&(i.accesskey=null)}this._updateDuration()}_replaceInNode(e,t){const n=this.getDateUtils(),i=e.querySelectorAll("[data-replacer]");for(let s of i){const i=s.dataset.replacer;"url"===i?s.dataset.href=e.dataset.href.replace("000",t.id):"activity"===i?s.innerText=t.activity.name:"project"===i?s.innerText=t.project.name:"customer"===i?s.innerText=t.project.customer.name:"duration"===i&&(s.dataset.since=t.begin,s.innerText=n.formatDuration(t.duration))}}reloadActiveRecords(){const e=this.getContainer().getPlugin("api"),t=document.querySelector(this._selector).dataset.api;e.get(t,{},e=>{this._setEntries(e)})}_changeFavicon(e){const t=document.createElement("canvas"),n=document.getElementById("favicon");null===this._favIconUrl&&(this._favIconUrl=n.href);const i=n.cloneNode(!0);if(t.getContext&&i){const s=window.devicePixelRatio,r=document.createElement("img");t.height=t.width=16*s,r.onload=function(){const r=t.getContext("2d");if(r.drawImage(this,0,0,t.width,t.height),e){const e=5.5*s;r.fillStyle="rgb(182,57,57)",r.fillRect(t.width/2-e/2,t.height/2-e/2,e,e)}i.href=t.toDataURL("image/png"),n.remove(),document.head.appendChild(i)},r.src=this._favIconUrl}}}class T extends o{getId(){return"event"}trigger(e,t=null){if(""!==e)for(const n of e.split(" ")){let e=new Event(n);null!==t&&(e=new CustomEvent(n,{detail:t})),document.dispatchEvent(e)}}}class E extends o{constructor(e){super(),this._selector=e}init(){document.addEventListener("click",e=>{let t=e.target;for(;null!==t&&"function"==typeof t.matches&&!t.matches("body");){if(t.classList.contains(this._selector)){const n=t.dataset;let i=n.href;i||(i=t.getAttribute("href")),void 0!==n.question?this.getContainer().getPlugin("alert").question(n.question,e=>{e&&this._callApi(i,n)}):this._callApi(i,n),e.preventDefault(),e.stopPropagation()}t=t.parentNode}})}_callApi(e,t){const n=t.method,i=t.event,s=this.getContainer().getPlugin("api"),r=this.getContainer().getPlugin("event"),o=(this.getContainer().getPlugin("alert"),()=>{r.trigger(i),document.dispatchEvent(new CustomEvent("kimai.reloadedContent"))}),a=e=>{let n="action.update.error";void 0!==t.msgError&&(n=t.msgError),document.dispatchEvent(new CustomEvent("kimai.reloadedContent")),s.handleError(n,e)};let l={};if(void 0!==t.payload&&(l=t.payload),document.dispatchEvent(new CustomEvent("kimai.reloadContent")),"PATCH"===n)s.patch(e,l,o,a);else if("POST"===n){let t={};s.post(e,t,o,a)}else"DELETE"===n?s.delete(e,o,a):"GET"===n&&s.get(e,l,o,a)}}class D extends o{getId(){return"alert"}error(e,t){const n=this.getTranslation();n.has(e)&&(e=n.get(e)),e=e.replace("%reason%",""),void 0===t&&(t=null),null!==t&&(n.has(t)&&(t=n.get(t)),Array.isArray(t)&&(t=t.join("
")));const i="alert_global_error",s=document.getElementById(i);null!==s&&c.aF.getOrCreateInstance(s).hide();const r='\n
\n ";this._showModal(r)}warning(e){this._show("warning",e)}success(e){this._toast("success",e)}info(e){this._show("info",e)}_showModal(e){const t=document.body,n=document.createElement("template");n.innerHTML=e.trim();const i=n.content.firstChild;t.appendChild(i);const s=new c.aF(i);i.addEventListener("hidden.bs.modal",function(){t.removeChild(i)}),s.show()}_show(e,t){const n=this.getTranslation();n.has(t)&&(t=n.get(t));const i='\n \n ";this._showModal(i)}_mapClass(e){return"info"===e||"success"===e||"warning"===e||"danger"===e?e:"error"===e?"danger":"primary"}_toast(e,t){const n=this.getTranslation();n.has(t)&&(t=n.get(t));let i='';"success"===e?i='':"warning"===e?i='':"danger"!==e&&"error"!==e||(i='');const s='',r=document.getElementById("toast-container"),o=document.createElement("template");o.innerHTML=s.trim();const a=o.content.firstChild;r.appendChild(a);const l=new c.y8(a);a.addEventListener("hidden.bs.toast",function(){r.removeChild(a)}),l.show()}question(e,t){const n=this.getTranslation();n.has(e)&&(e=n.get(e));const i=this._mapClass("info"),s='\n \n ",r=document.body,o=document.createElement("template");o.innerHTML=s.trim();const a=o.content.firstChild;r.appendChild(a),a.querySelector(".question-confirm").addEventListener("click",()=>{t(!0)}),a.querySelector(".question-cancel").addEventListener("click",()=>{t(!1)});const l=new c.aF(a);a.addEventListener("hidden.bs.modal",()=>{r.removeChild(a)}),l.show()}}function S(e,t){e.split(/\s+/).forEach(e=>{t(e)})}class x{constructor(){this._events={}}on(e,t){S(e,e=>{const n=this._events[e]||[];n.push(t),this._events[e]=n})}off(e,t){var n=arguments.length;0!==n?S(e,e=>{if(1===n)return void delete this._events[e];const i=this._events[e];void 0!==i&&(i.splice(i.indexOf(t),1),this._events[e]=i)}):this._events={}}trigger(e,...t){var n=this;S(e,e=>{const i=n._events[e];void 0!==i&&i.forEach(e=>{e.apply(n,t)})})}}const O=e=>(e=e.filter(Boolean)).length<2?e[0]||"":1==I(e)?"["+e.join("")+"]":"(?:"+e.join("|")+")",L=e=>{if(!A(e))return e.join("");let t="",n=0;const i=()=>{n>1&&(t+="{"+n+"}")};return e.forEach((s,r)=>{s!==e[r-1]?(i(),t+=s,n=1):n++}),i(),t},C=e=>{let t=Array.from(e);return O(t)},A=e=>new Set(e).size!==e.length,M=e=>(e+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),I=e=>e.reduce((e,t)=>Math.max(e,N(t)),0),N=e=>Array.from(e).length,P=e=>{if(1===e.length)return[[e]];let t=[];const n=e.substring(1);return P(n).forEach(function(n){let i=n.slice(0);i[0]=e.charAt(0)+i[0],t.push(i),i=n.slice(0),i.unshift(e.charAt(0)),t.push(i)}),t},F=[[0,65535]];let j,R;const $={},H={"/":"⁄∕",0:"߀",a:"ⱥɐɑ",aa:"ꜳ",ae:"æǽǣ",ao:"ꜵ",au:"ꜷ",av:"ꜹꜻ",ay:"ꜽ",b:"ƀɓƃ",c:"ꜿƈȼↄ",d:"đɗɖᴅƌꮷԁɦ",e:"ɛǝᴇɇ",f:"ꝼƒ",g:"ǥɠꞡᵹꝿɢ",h:"ħⱨⱶɥ",i:"ɨı",j:"ɉȷ",k:"ƙⱪꝁꝃꝅꞣ",l:"łƚɫⱡꝉꝇꞁɭ",m:"ɱɯϻ",n:"ꞥƞɲꞑᴎлԉ",o:"øǿɔɵꝋꝍᴑ",oe:"œ",oi:"ƣ",oo:"ꝏ",ou:"ȣ",p:"ƥᵽꝑꝓꝕρ",q:"ꝗꝙɋ",r:"ɍɽꝛꞧꞃ",s:"ßȿꞩꞅʂ",t:"ŧƭʈⱦꞇ",th:"þ",tz:"ꜩ",u:"ʉ",v:"ʋꝟʌ",vy:"ꝡ",w:"ⱳ",y:"ƴɏỿ",z:"ƶȥɀⱬꝣ",hv:"ƕ"};for(let e in H){let t=H[e]||"";for(let n=0;ne.normalize(t),z=e=>Array.from(e).reduce((e,t)=>e+B(t),""),B=e=>(e=V(e).toLowerCase().replace(q,e=>$[e]||""),V(e,"NFC"));const W=e=>{const t={},n=(e,n)=>{const i=t[e]||new Set,s=new RegExp("^"+C(i)+"$","iu");n.match(s)||(i.add(M(n)),t[e]=i)};for(let t of function*(e){for(const[t,n]of e)for(let e=t;e<=n;e++){let t=String.fromCharCode(e),n=z(t);n!=t.toLowerCase()&&(n.length>3||0!=n.length&&(yield{folded:n,composed:t,code_point:e}))}}(e))n(t.folded,t.folded),n(t.folded,t.composed);return t},U=e=>{const t=W(e),n={};let i=[];for(let e in t){let s=t[e];s&&(n[e]=C(s)),e.length>1&&i.push(M(e))}i.sort((e,t)=>t.length-e.length);const s=O(i);return R=new RegExp("^"+s,"u"),n},Y=(e,t=1)=>(t=Math.max(t,e.length-1),O(P(e).map(e=>((e,t=1)=>{let n=0;return e=e.map(e=>(j[e]&&(n+=e.length),j[e]||e)),n>=t?L(e):""})(e,t)))),Z=(e,t=!0)=>{let n=e.length>1?1:0;return O(e.map(e=>{let i=[];const s=t?e.length():e.length()-1;for(let t=0;t{for(const n of t){if(n.start!=e.start||n.end!=e.end)continue;if(n.substrs.join("")!==e.substrs.join(""))continue;let t=e.parts;const i=e=>{for(const n of t){if(n.start===e.start&&n.substr===e.substr)return!1;if(1!=e.length&&1!=n.length){if(e.startn.start)return!0;if(n.starte.start)return!0}}return!1};if(!(n.parts.filter(i).length>0))return!0}return!1};class K{parts;substrs;start;end;constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let n=new K,i=JSON.parse(JSON.stringify(this.parts)),s=i.pop();for(const e of i)n.add(e);let r=t.substr.substring(0,e-s.start),o=r.length;return n.add({start:s.start,end:s.start+o,length:o,substr:r}),n}}const J=e=>{var t;void 0===j&&(j=U(t||F)),e=z(e);let n="",i=[new K];for(let t=0;t0){a=a.sort((e,t)=>e.length()-t.length());for(let e of a)G(e,i)||i.push(e)}else if(t>0&&1==l.size&&!l.has("3")){n+=Z(i,!1);let e=new K;const t=i[0];t&&e.add(t.last()),i=[e]}}return n+=Z(i,!0),n},X=(e,t)=>{if(e)return e[t]},Q=(e,t)=>{if(e){for(var n,i=t.split(".");(n=i.shift())&&(e=e[n]););return e}},ee=(e,t,n)=>{var i,s;return e?(e+="",null==t.regex||-1===(s=e.search(t.regex))?0:(i=t.string.length/e.length,0===s&&(i+=.5),i*n)):0},te=(e,t)=>{var n=e[t];if("function"==typeof n)return n;n&&!Array.isArray(n)&&(e[t]=[n])},ne=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},ie=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e(t=z(t+"").toLowerCase())?1:t>e?-1:0;class se{items;settings;constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,n){if(!e||!e.length)return[];const i=[],s=e.split(/\s+/);var r;return n&&(r=new RegExp("^("+Object.keys(n).map(M).join("|")+"):(.*)$")),s.forEach(e=>{let n,s=null,o=null;r&&(n=e.match(r))&&(s=n[1],e=n[2]),e.length>0&&(o=this.settings.diacritics?J(e)||null:M(e),o&&t&&(o="\\b"+o)),i.push({string:e,regex:o?new RegExp(o,"iu"):null,field:s})}),i}getScoreFunction(e,t){var n=this.prepareSearch(e,t);return this._getScoreFunction(n)}_getScoreFunction(e){const t=e.tokens,n=t.length;if(!n)return function(){return 0};const i=e.options.fields,s=e.weights,r=i.length,o=e.getAttrFn;if(!r)return function(){return 1};const a=1===r?function(e,t){const n=i[0].field;return ee(o(t,n),e,s[n]||1)}:function(e,t){var n=0;if(e.field){const i=o(t,e.field);!e.regex&&i?n+=1/r:n+=ee(i,e,1)}else ne(s,(i,s)=>{n+=ee(o(t,s),e,i)});return n/r};return 1===n?function(e){return a(t[0],e)}:"and"===e.options.conjunction?function(e){var i,s=0;for(let n of t){if((i=a(n,e))<=0)return 0;s+=i}return s/n}:function(e){var i=0;return ne(t,t=>{i+=a(t,e)}),i/n}}getSortFunction(e,t){var n=this.prepareSearch(e,t);return this._getSortFunction(n)}_getSortFunction(e){var t,n=[];const i=this,s=e.options,r=!e.query&&s.sort_empty?s.sort_empty:s.sort;if("function"==typeof r)return r.bind(this);const o=function(t,n){return"$score"===t?n.score:e.getAttrFn(i.items[n.id],t)};if(r)for(let t of r)(e.query||"$score"!==t.field)&&n.push(t);if(e.query){t=!0;for(let e of n)if("$score"===e.field){t=!1;break}t&&n.unshift({field:"$score",direction:"desc"})}else n=n.filter(e=>"$score"!==e.field);return n.length?function(e,t){var i,s;for(let r of n){if(s=r.field,i=("desc"===r.direction?-1:1)*ie(o(s,e),o(s,t)))return i}return 0}:null}prepareSearch(e,t){const n={};var i=Object.assign({},t);if(te(i,"sort"),te(i,"sort_empty"),i.fields){te(i,"fields");const e=[];i.fields.forEach(t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),n[t.field]="weight"in t?t.weight:1}),i.fields=e}return{options:i,query:e.toLowerCase().trim(),tokens:this.tokenize(e,i.respect_word_boundaries,n),total:0,items:[],weights:n,getAttrFn:i.nesting?Q:X}}search(e,t){var n,i,s=this;i=this.prepareSearch(e,t),t=i.options,e=i.query;const r=t.score||s._getScoreFunction(i);e.length?ne(s.items,(e,s)=>{n=r(e),(!1===t.filter||n>0)&&i.items.push({score:n,id:s})}):ne(s.items,(e,t)=>{i.items.push({score:1,id:t})});const o=s._getSortFunction(i);return o&&i.items.sort(o),i.total=i.items.length,"number"==typeof t.limit&&(i.items=i.items.slice(0,t.limit)),i}}const re=e=>null==e?null:oe(e),oe=e=>"boolean"==typeof e?e?"1":"0":e+"",ae=e=>(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),le=(e,t)=>{var n;return function(i,s){var r=this;n&&(r.loading=Math.max(r.loading-1,0),clearTimeout(n)),n=setTimeout(function(){n=null,r.loadedSearches[i]=!0,e.call(r,i,s)},t)}},ce=(e,t,n)=>{var i,s=e.trigger,r={};for(i of(e.trigger=function(){var n=arguments[0];if(-1===t.indexOf(n))return s.apply(e,arguments);r[n]=arguments},n.apply(e,[]),e.trigger=s,t))i in r&&s.apply(e,r[i])},ue=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},de=(e,t,n,i)=>{e.addEventListener(t,n,i)},he=(e,t)=>!!t&&(!!t[e]&&1===(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0)),pe=(e,t)=>{const n=e.getAttribute("id");return n||(e.setAttribute("id",t),t)},me=e=>e.replace(/[\\"']/g,"\\$&"),fe=(e,t)=>{t&&e.append(t)},ge=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},ve=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(ye(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},ye=e=>"string"==typeof e&&e.indexOf("<")>-1,be=(e,t)=>{var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)},_e=(e,t)=>{Object.assign(e.style,t)},we=(e,...t)=>{var n=Te(t);(e=Ee(e)).map(e=>{n.map(t=>{e.classList.add(t)})})},ke=(e,...t)=>{var n=Te(t);(e=Ee(e)).map(e=>{n.map(t=>{e.classList.remove(t)})})},Te=e=>{var t=[];return ge(e,e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))}),t.filter(Boolean)},Ee=e=>(Array.isArray(e)||(e=[e]),e),De=(e,t,n)=>{if(!n||n.contains(e))for(;e&&e.matches;){if(e.matches(t))return e;e=e.parentNode}},Se=(e,t=0)=>t>0?e[e.length-1]:e[0],xe=(e,t)=>{if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n},Oe=(e,t)=>{ge(t,(t,n)=>{null==t?e.removeAttribute(n):e.setAttribute(n,""+t)})},Le=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},Ce=(e,t)=>{if(null===t)return;if("string"==typeof t){if(!t.length)return;t=new RegExp(t,"i")}const n=e=>3===e.nodeType?(e=>{var n=e.data.match(t);if(n&&e.data.length>0){var i=document.createElement("span");i.className="highlight";var s=e.splitText(n.index);s.splitText(n[0].length);var r=s.cloneNode(!0);return i.appendChild(r),Le(s,i),1}return 0})(e):((e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach(e=>{n(e)})})(e),0);n(e)},Ae="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey";var Me={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,refreshThrottle:300,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}};function Ie(e,t){var n=Object.assign({},Me,t),i=n.dataAttr,s=n.labelField,r=n.valueField,o=n.disabledField,a=n.optgroupField,l=n.optgroupLabelField,c=n.optgroupValueField,u=e.tagName.toLowerCase(),d=e.getAttribute("placeholder")||e.getAttribute("data-placeholder");if(!d&&!n.allowEmptyOption){let t=e.querySelector('option[value=""]');t&&(d=t.textContent)}var h={placeholder:d,options:[],optgroups:[],items:[],maxItems:null};return"select"===u?(()=>{var t,u=h.options,d={},p=1;let m=0;var f=e=>{var t=Object.assign({},e.dataset),n=i&&t[i];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t},g=(e,t)=>{var i=re(e.value);if(null!=i&&(i||n.allowEmptyOption)){if(d.hasOwnProperty(i)){if(t){var l=d[i][a];l?Array.isArray(l)?l.push(t):d[i][a]=[l,t]:d[i][a]=t}}else{var c=f(e);c[s]=c[s]||e.textContent,c[r]=c[r]||i,c[o]=c[o]||e.disabled,c[a]=c[a]||t,c.$option=e,c.$order=c.$order||++m,d[i]=c,u.push(c)}e.selected&&h.items.push(i)}};h.maxItems=e.hasAttribute("multiple")?null:1,ge(e.children,e=>{var n,i,s;"optgroup"===(t=e.tagName.toLowerCase())?((s=f(n=e))[l]=s[l]||n.getAttribute("label")||"",s[c]=s[c]||p++,s[o]=s[o]||n.disabled,s.$order=s.$order||++m,h.optgroups.push(s),i=s[c],ge(n.children,e=>{g(e,i)})):"option"===t&&g(e)})})():(()=>{const t=e.getAttribute(i);if(t)h.options=JSON.parse(t),ge(h.options,e=>{h.items.push(e[r])});else{var o=e.value.trim()||"";if(!n.allowEmptyOption&&!o.length)return;const t=o.split(n.delimiter);ge(t,e=>{const t={};t[s]=e,t[r]=e,h.options.push(t)}),h.items=t}})(),Object.assign({},Me,h,t)}var Ne=0;class Pe extends(function(e){return e.plugins={},class extends e{constructor(){super(...arguments),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,n){e.plugins[t]={name:t,fn:n}}initializePlugins(e){var t,n;const i=this,s=[];if(Array.isArray(e))e.forEach(e=>{"string"==typeof e?s.push(e):(i.plugins.settings[e.name]=e.options,s.push(e.name))});else if(e)for(t in e)e.hasOwnProperty(t)&&(i.plugins.settings[t]=e[t],s.push(t));for(;n=s.shift();)i.require(n)}loadPlugin(t){var n=this,i=n.plugins,s=e.plugins[t];if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');i.requested[t]=!0,i.loaded[t]=s.fn.apply(n,[n.plugins.settings[t]||{}]),i.names.push(t)}require(e){var t=this,n=t.plugins;if(!t.plugins.loaded.hasOwnProperty(e)){if(n.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');t.loadPlugin(e)}return n.loaded[e]}}}(x)){constructor(e,t){var n;super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isReadOnly=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.refreshTimeout=null,Ne++;var i=ve(e);if(i.tomselect)throw new Error("Tom Select already initialized on this element");i.tomselect=this,n=(window.getComputedStyle&&window.getComputedStyle(i,null)).getPropertyValue("direction");const s=Ie(i,t);this.settings=s,this.input=i,this.tabIndex=i.tabIndex||0,this.is_select_tag="select"===i.tagName.toLowerCase(),this.rtl=/rtl/i.test(n),this.inputId=pe(i,"tomselect-"+Ne),this.isRequired=i.required,this.sifter=new se(this.options,{diacritics:s.diacritics}),s.mode=s.mode||(1===s.maxItems?"single":"multi"),"boolean"!=typeof s.hideSelected&&(s.hideSelected="multi"===s.mode),"boolean"!=typeof s.hidePlaceholder&&(s.hidePlaceholder="multi"!==s.mode);var r=s.createFilter;"function"!=typeof r&&("string"==typeof r&&(r=new RegExp(r)),r instanceof RegExp?s.createFilter=e=>r.test(e):s.createFilter=e=>this.settings.duplicates||!this.options[e]),this.initializePlugins(s.plugins),this.setupCallbacks(),this.setupTemplates();const o=ve("
"),a=ve("
"),l=this._render("dropdown"),c=ve('
'),u=this.input.getAttribute("class")||"",d=s.mode;var h;if(we(o,s.wrapperClass,u,d),we(a,s.controlClass),fe(o,a),we(l,s.dropdownClass,d),s.copyClassesToDropdown&&we(l,u),we(c,s.dropdownContentClass),fe(l,c),ve(s.dropdownParent||o).appendChild(l),ye(s.controlInput)){h=ve(s.controlInput);ge(["autocorrect","autocapitalize","autocomplete","spellcheck"],e=>{i.getAttribute(e)&&Oe(h,{[e]:i.getAttribute(e)})}),h.tabIndex=-1,a.appendChild(h),this.focus_node=h}else s.controlInput?(h=ve(s.controlInput),this.focus_node=h):(h=ve(""),this.focus_node=a);this.wrapper=o,this.dropdown=l,this.dropdown_content=c,this.control=a,this.control_input=h,this.setup()}setup(){const e=this,t=e.settings,n=e.control_input,i=e.dropdown,s=e.dropdown_content,r=e.wrapper,o=e.control,a=e.input,l=e.focus_node,c={passive:!0},u=e.inputId+"-ts-dropdown";Oe(s,{id:u}),Oe(l,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":u});const d=pe(l,e.inputId+"-ts-control"),h="label[for='"+(e=>e.replace(/['"\\]/g,"\\$&"))(e.inputId)+"']",p=document.querySelector(h),m=e.focus.bind(e);if(p){de(p,"click",m),Oe(p,{for:d});const t=pe(p,e.inputId+"-ts-label");Oe(l,{"aria-labelledby":t}),Oe(s,{"aria-labelledby":t})}if(r.style.width=a.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-");we([r,i],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&Oe(a,{multiple:"multiple"}),t.placeholder&&Oe(n,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+M(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=le(t.load,t.loadThrottle)),de(i,"mousemove",()=>{e.ignoreHover=!1}),de(i,"mouseenter",t=>{var n=De(t.target,"[data-selectable]",i);n&&e.onOptionHover(t,n)},{capture:!0}),de(i,"click",t=>{const n=De(t.target,"[data-selectable]");n&&(e.onOptionSelect(t,n),ue(t,!0))}),de(o,"click",t=>{var i=De(t.target,"[data-ts-item]",o);i&&e.onItemSelect(t,i)?ue(t,!0):""==n.value&&(e.onClick(),ue(t,!0))}),de(l,"keydown",t=>e.onKeyDown(t)),de(n,"keypress",t=>e.onKeyPress(t)),de(n,"input",t=>e.onInput(t)),de(l,"blur",t=>e.onBlur(t)),de(l,"focus",t=>e.onFocus(t)),de(n,"paste",t=>e.onPaste(t));const f=t=>{const s=t.composedPath()[0];if(!r.contains(s)&&!i.contains(s))return e.isFocused&&e.blur(),void e.inputState();s==n&&e.isOpen?t.stopPropagation():ue(t,!0)},g=()=>{e.isOpen&&e.positionDropdown()};de(document,"mousedown",f),de(window,"scroll",g,c),de(window,"resize",g,c),this._destroy=()=>{document.removeEventListener("mousedown",f),window.removeEventListener("scroll",g),window.removeEventListener("resize",g),p&&p.removeEventListener("click",m)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,de(a,"invalid",()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())}),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,a.disabled?e.disable():a.readOnly?e.setReadOnly(!0):e.enable(),e.on("change",this.onChange),we(a,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),ge(t,e=>{this.registerOptionGroup(e)})}setupTemplates(){var e=this,t=e.settings.labelField,n=e.settings.optgroupLabelField,i={optgroup:e=>{let t=document.createElement("div");return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'
'+t(e[n])+"
",option:(e,n)=>"
"+n(e[t])+"
",item:(e,n)=>"
"+n(e[t])+"
",option_create:(e,t)=>'
Add '+t(e.input)+"
",no_results:()=>'
No results found
',loading:()=>'
',not_loading:()=>{},dropdown:()=>"
"};e.settings.render=Object.assign({},i,e.settings.render)}setupCallbacks(){var e,t,n={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in n)(t=this.settings[n[e]])&&this.on(e,t)}sync(e=!0){const t=this,n=e?Ie(t.input,{delimiter:t.settings.delimiter}):t.settings;t.setupOptions(n.options,n.optgroups),t.setValue(n.items||[],!0),t.lastQuery=null}onClick(){var e=this;if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus();e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){be(this.input,"input"),be(this.input,"change")}onPaste(e){var t=this;t.isInputHidden||t.isLocked?ue(e):t.settings.splitOn&&setTimeout(()=>{var e=t.inputValue();if(e.match(t.settings.splitOn)){var n=e.trim().split(t.settings.splitOn);ge(n,e=>{re(e)&&(this.options[e]?t.addItem(e):t.createItem(e))})}},0)}onKeyPress(e){var t=this;if(!t.isLocked){var n=String.fromCharCode(e.keyCode||e.which);return t.settings.create&&"multi"===t.settings.mode&&n===t.settings.delimiter?(t.createItem(),void ue(e)):void 0}ue(e)}onKeyDown(e){var t=this;if(t.ignoreHover=!0,t.isLocked)9!==e.keyCode&&ue(e);else{switch(e.keyCode){case 65:if(he(Ae,e)&&""==t.control_input.value)return ue(e),void t.selectAll();break;case 27:return t.isOpen&&(ue(e,!0),t.close()),void t.clearActiveItems();case 40:if(!t.isOpen&&t.hasOptions)t.open();else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1);e&&t.setActiveOption(e)}return void ue(e);case 38:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1);e&&t.setActiveOption(e)}return void ue(e);case 13:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),ue(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&ue(e));case 37:return void t.advanceSelection(-1,e);case 39:return void t.advanceSelection(1,e);case 9:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),ue(e)),t.settings.create&&t.createItem()&&ue(e)));case 8:case 46:return void t.deleteSelection(e)}t.isInputHidden&&!he(Ae,e)&&ue(e)}}onInput(e){if(this.isLocked)return;const t=this.inputValue();this.lastValue!==t&&(this.lastValue=t,""!=t?(this.refreshTimeout&&window.clearTimeout(this.refreshTimeout),this.refreshTimeout=((e,t)=>t>0?window.setTimeout(e,t):(e.call(null),null))(()=>{this.refreshTimeout=null,this._onInput()},this.settings.refreshThrottle)):this._onInput())}_onInput(){const e=this.lastValue;this.settings.shouldLoad.call(this,e)&&this.load(e),this.refreshOptions(),this.trigger("type",e)}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,n=t.isFocused;if(t.isDisabled||t.isReadOnly)return t.blur(),void ue(e);t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),n||t.trigger("focus"),t.activeItems.length||(t.inputState(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this;if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1;var n=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")};t.settings.create&&t.settings.createOnBlur?t.createItem(null,n):n()}}}onOptionSelect(e,t){var n,i=this;t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?i.createItem(null,()=>{i.settings.closeAfterSelect&&i.close()}):void 0!==(n=t.dataset.value)&&(i.lastQuery=null,i.addItem(n),i.settings.closeAfterSelect&&i.close(),!i.settings.hideSelected&&e.type&&/click/.test(e.type)&&i.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var n=this;return!n.isLocked&&"multi"===n.settings.mode&&(ue(e),n.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this;if(!t.canLoad(e))return;we(t.wrapper,t.settings.loadingClass),t.loading++;const n=t.loadCallback.bind(t);t.settings.load.call(t,e,n)}loadCallback(e,t){const n=this;n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.clearActiveOption(),n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||ke(n.wrapper,n.settings.loadingClass),n.trigger("load",e,t)}preload(){var e=this.wrapper.classList;e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input;t.value!==e&&(t.value=e,be(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){ce(this,t?[]:["change"],()=>{this.clear(t),this.addItems(e,t)})}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var n,i,s,r,o,a,l=this;if("single"!==l.settings.mode){if(!e)return l.clearActiveItems(),void(l.isFocused&&l.inputState());if("click"===(n=t&&t.type.toLowerCase())&&he("shiftKey",t)&&l.activeItems.length){for(a=l.getLastActive(),(s=Array.prototype.indexOf.call(l.control.children,a))>(r=Array.prototype.indexOf.call(l.control.children,e))&&(o=s,s=r,r=o),i=s;i<=r;i++)e=l.control.children[i],-1===l.activeItems.indexOf(e)&&l.setActiveItemClass(e);ue(t)}else"click"===n&&he(Ae,t)||"keydown"===n&&he("shiftKey",t)?e.classList.contains("active")?l.removeActiveItem(e):l.setActiveItemClass(e):(l.clearActiveItems(),l.setActiveItemClass(e));l.inputState(),l.isFocused||l.focus()}}setActiveItemClass(e){const t=this,n=t.control.querySelector(".last-active");n&&ke(n,"last-active"),we(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),ke(e,"active")}clearActiveItems(){ke(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,Oe(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),Oe(e,{"aria-selected":"true"}),we(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return;const n=this.dropdown_content,i=n.clientHeight,s=n.scrollTop||0,r=e.offsetHeight,o=e.getBoundingClientRect().top-n.getBoundingClientRect().top+s;o+r>i+s?this.scroll(o-i+r,t):o{e.setActiveItemClass(t)}))}inputState(){var e=this;e.control.contains(e.control_input)&&(Oe(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&Oe(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var e=this;e.isDisabled||e.isReadOnly||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout(()=>{e.ignoreFocus=!1,e.onFocus()},0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField;return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,n,i=this,s=this.getSearchOptions();if(i.settings.score&&"function"!=typeof(n=i.settings.score.call(i,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');return e!==i.lastQuery?(i.lastQuery=e,t=i.sifter.search(e,Object.assign(s,{score:n})),i.currentResults=t):t=Object.assign({},i.currentResults),i.settings.hideSelected&&(t.items=t.items.filter(e=>{let t=re(e.id);return!(t&&-1!==i.items.indexOf(t))})),t}refreshOptions(e=!0){var t,n,i,s,r,o,a,l,c,u;const d={},h=[];var p=this,m=p.inputValue();const f=m===p.lastQuery||""==m&&null==p.lastQuery;var g=p.search(m),v=null,y=p.settings.shouldOpen||!1,b=p.dropdown_content;f&&(v=p.activeOption)&&(c=v.closest("[data-group]")),s=g.items.length,"number"==typeof p.settings.maxOptions&&(s=Math.min(s,p.settings.maxOptions)),s>0&&(y=!0);const _=(e,t)=>{let n=d[e];if(void 0!==n){let e=h[n];if(void 0!==e)return[n,e.fragment]}let i=document.createDocumentFragment();return n=h.length,h.push({fragment:i,order:t,optgroup:e}),[n,i]};for(t=0;t0&&(u=u.cloneNode(!0),Oe(u,{id:a.$id+"-clone-"+n,"aria-selected":null}),u.classList.add("ts-cloned"),ke(u,"active"),p.activeOption&&p.activeOption.dataset.value==s&&c&&c.dataset.group===r.toString()&&(v=u)),l.appendChild(u),""!=r&&(d[r]=i)}}var w;p.settings.lockOptgroupOrder&&h.sort((e,t)=>e.order-t.order),a=document.createDocumentFragment(),ge(h,e=>{let t=e.fragment,n=e.optgroup;if(!t||!t.children.length)return;let i=p.optgroups[n];if(void 0!==i){let e=document.createDocumentFragment(),n=p.render("optgroup_header",i);fe(e,n),fe(e,t);let s=p.render("optgroup",{group:i,options:e});fe(a,s)}else fe(a,t)}),b.innerHTML="",fe(b,a),p.settings.highlight&&(w=b.querySelectorAll("span.highlight"),Array.prototype.forEach.call(w,function(e){var t=e.parentNode;t.replaceChild(e.firstChild,e),t.normalize()}),g.query.length&&g.tokens.length&&ge(g.tokens,e=>{Ce(b,e.regex)}));var k=e=>{let t=p.render(e,{input:m});return t&&(y=!0,b.insertBefore(t,b.firstChild)),t};if(p.loading?k("loading"):p.settings.shouldLoad.call(p,m)?0===g.items.length&&k("no_results"):k("not_loading"),(l=p.canCreate(m))&&(u=k("option_create")),p.hasOptions=g.items.length>0||l,y){if(g.items.length>0){if(v||"single"!==p.settings.mode||null==p.items[0]||(v=p.getOption(p.items[0])),!b.contains(v)){let e=0;u&&!p.settings.addPrecedence&&(e=1),v=p.selectable()[e]}}else u&&(v=u);e&&!p.isOpen&&(p.open(),p.scrollToOption(v,"auto")),p.setActiveOption(v)}else p.clearActiveOption(),e&&p.isOpen&&p.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const n=this;if(Array.isArray(e))return n.addOptions(e,t),!1;const i=re(e[n.settings.valueField]);return null!==i&&!n.options.hasOwnProperty(i)&&(e.$order=e.$order||++n.order,e.$id=n.inputId+"-opt-"+e.$order,n.options[i]=e,n.lastQuery=null,t&&(n.userOptions[i]=t,n.trigger("option_add",i,e)),i)}addOptions(e,t=!1){ge(e,e=>{this.addOption(e,t)})}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=re(e[this.settings.optgroupValueField]);return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var n;t[this.settings.optgroupValueField]=e,(n=this.registerOptionGroup(t))&&this.trigger("optgroup_add",n,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const n=this;var i,s;const r=re(e),o=re(t[n.settings.valueField]);if(null===r)return;const a=n.options[r];if(null==a)return;if("string"!=typeof o)throw new Error("Value must be set in option data");const l=n.getOption(r),c=n.getItem(r);if(t.$order=t.$order||a.$order,delete n.options[r],n.uncacheValue(o),n.options[o]=t,l){if(n.dropdown_content.contains(l)){const e=n._render("option",t);Le(l,e),n.activeOption===l&&n.setActiveOption(e)}l.remove()}c&&(-1!==(s=n.items.indexOf(r))&&n.items.splice(s,1,o),i=n._render("item",t),c.classList.contains("active")&&we(i,"active"),Le(c,i)),n.lastQuery=null}removeOption(e,t){const n=this;e=oe(e),n.uncacheValue(e),delete n.userOptions[e],delete n.options[e],n.lastQuery=null,n.trigger("option_remove",e),n.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const n={};ge(this.options,(e,i)=>{t(e,i)&&(n[i]=e)}),this.options=this.sifter.items=n,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const n=re(e);if(null===n)return null;const i=this.options[n];if(null!=i){if(i.$div)return i.$div;if(t)return this._render("option",i)}return null}getAdjacent(e,t,n="option"){var i;if(!e)return null;i="item"==n?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]");for(let n=0;n0?i[n+1]:i[n-1];return null}getItem(e){if("object"==typeof e)return e;var t=re(e);return null!==t?this.control.querySelector(`[data-value="${me(t)}"]`):null}addItems(e,t){var n=this,i=Array.isArray(e)?e:[e];const s=(i=i.filter(e=>-1===n.items.indexOf(e)))[i.length-1];i.forEach(e=>{n.isPending=e!==s,n.addItem(e,t)})}addItem(e,t){ce(this,t?[]:["change","dropdown_close"],()=>{var n,i;const s=this,r=s.settings.mode,o=re(e);if((!o||-1===s.items.indexOf(o)||("single"===r&&s.close(),"single"!==r&&s.settings.duplicates))&&null!==o&&s.options.hasOwnProperty(o)&&("single"===r&&s.clear(t),"multi"!==r||!s.isFull())){if(n=s._render("item",s.options[o]),s.control.contains(n)&&(n=n.cloneNode(!0)),i=s.isFull(),s.items.splice(s.caretPos,0,o),s.insertAtCaret(n),s.isSetup){if(!s.isPending&&s.settings.hideSelected){let e=s.getOption(o),t=s.getAdjacent(e,1);t&&s.setActiveOption(t)}s.isPending||s.settings.closeAfterSelect||s.refreshOptions(s.isFocused&&"single"!==r),0!=s.settings.closeAfterSelect&&s.isFull()?s.close():s.isPending||s.positionDropdown(),s.trigger("item_add",o,n),s.isPending||s.updateOriginalInput({silent:t})}(!s.isPending||!i&&s.isFull())&&(s.inputState(),s.refreshState())}})}removeItem(e=null,t){const n=this;if(!(e=n.getItem(e)))return;var i,s;const r=e.dataset.value;i=xe(e),e.remove(),e.classList.contains("active")&&(s=n.activeItems.indexOf(e),n.activeItems.splice(s,1),ke(e,"active")),n.items.splice(i,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(r)&&n.removeOption(r,t),i{}){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{});var n,i=this,s=i.caretPos;if(e=e||i.inputValue(),!i.canCreate(e))return t(),!1;i.lock();var r=!1,o=e=>{if(i.unlock(),!e||"object"!=typeof e)return t();var n=re(e[i.settings.valueField]);if("string"!=typeof n)return t();i.setTextboxValue(),i.addOption(e,!0),i.setCaret(s),i.addItem(n),t(e),r=!0};return n="function"==typeof i.settings.create?i.settings.create.call(this,e,o):{[i.settings.labelField]:e,[i.settings.valueField]:e},r||o(n),!0}refreshItems(){var e=this;e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this;e.refreshValidityState();const t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);const i=e.wrapper.classList;var s;i.toggle("focus",e.isFocused),i.toggle("disabled",e.isDisabled),i.toggle("readonly",e.isReadOnly),i.toggle("required",e.isRequired),i.toggle("invalid",!e.isValid),i.toggle("locked",n),i.toggle("full",t),i.toggle("input-active",e.isFocused&&!e.isInputHidden),i.toggle("dropdown-active",e.isOpen),i.toggle("has-options",(s=e.options,0===Object.keys(s).length)),i.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this;e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this;var n,i;const s=t.input.querySelector('option[value=""]');if(t.is_select_tag){const r=[],o=t.input.querySelectorAll("option:checked").length;function a(e,n,i){return e||(e=ve('")),e!=s&&t.input.append(e),r.push(e),(e!=s||o>0)&&(e.selected=!0),e}t.input.querySelectorAll("option:checked").forEach(e=>{e.selected=!1}),0==t.items.length&&"single"==t.settings.mode?a(s,"",""):t.items.forEach(e=>{if(n=t.options[e],i=n[t.settings.labelField]||"",r.includes(n.$option)){a(t.input.querySelector(`option[value="${me(e)}"]:not(:checked)`),e,i)}else n.$option=a(n.$option,e,i)})}else t.input.value=t.getValue();t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,Oe(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),_e(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),_e(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,n=t.isOpen;e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.inputState()),t.isOpen=!1,Oe(t.focus_node,{"aria-expanded":"false"}),_e(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),n&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,i=t.left+window.scrollX;_e(this.dropdown,{width:t.width+"px",top:n+"px",left:i+"px"})}}clear(e){var t=this;if(t.items.length){var n=t.controlChildren();ge(n,e=>{t.removeItem(e,!0)}),t.inputState(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,n=t.caretPos,i=t.control;i.insertBefore(e,i.children[n]||null),t.setCaret(n+1)}deleteSelection(e){var t,n,i,s,r,o=this;t=e&&8===e.keyCode?-1:1,n={start:(r=o.control_input).selectionStart||0,length:(r.selectionEnd||0)-(r.selectionStart||0)};const a=[];if(o.activeItems.length)s=Se(o.activeItems,t),i=xe(s),t>0&&i++,ge(o.activeItems,e=>a.push(e));else if((o.isFocused||"single"===o.settings.mode)&&o.items.length){const e=o.controlChildren();let i;t<0&&0===n.start&&0===n.length?i=e[o.caretPos-1]:t>0&&n.start===o.inputValue().length&&(i=e[o.caretPos]),void 0!==i&&a.push(i)}if(!o.shouldDelete(a,e))return!1;for(ue(e,!0),void 0!==i&&o.setCaret(i);a.length;)o.removeItem(a.pop());return o.inputState(),o.positionDropdown(),o.refreshOptions(!1),!0}shouldDelete(e,t){const n=e.map(e=>e.dataset.value);return!(!n.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(n,t))}advanceSelection(e,t){var n,i,s=this;s.rtl&&(e*=-1),s.inputValue().length||(he(Ae,t)||he("shiftKey",t)?(i=(n=s.getLastActive(e))?n.classList.contains("active")?s.getAdjacent(n,e,"item"):n:e>0?s.control_input.nextElementSibling:s.control_input.previousElementSibling)&&(i.classList.contains("active")&&s.removeActiveItem(n),s.setActiveItemClass(i)):s.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active");if(t)return t;var n=this.control.querySelectorAll(".active");return n?Se(n,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(e=this.isReadOnly||this.isDisabled){this.isLocked=e,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(e){this.focus_node.tabIndex=e?-1:this.tabIndex,this.isDisabled=e,this.input.disabled=e,this.control_input.disabled=e,this.setLocked()}setReadOnly(e){this.isReadOnly=e,this.input.readOnly=e,this.control_input.readOnly=e,this.setLocked()}destroy(){var e=this,t=e.revertSettings;e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,ke(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var n,i;const s=this;if("function"!=typeof this.settings.render[e])return null;if(!(i=s.settings.render[e].call(this,t,ae)))return null;if(i=ve(i),"option"===e||"option_create"===e?t[s.settings.disabledField]?Oe(i,{"aria-disabled":"true"}):Oe(i,{"data-selectable":""}):"optgroup"===e&&(n=t.group[s.settings.optgroupValueField],Oe(i,{"data-group":n}),t.group[s.settings.disabledField]&&Oe(i,{"data-disabled":""})),"option"===e||"item"===e){const n=oe(t[s.settings.valueField]);Oe(i,{"data-value":n}),"item"===e?(we(i,s.settings.itemClass),Oe(i,{"data-ts-item":""})):(we(i,s.settings.optionClass),Oe(i,{role:"option",id:t.$id}),t.$div=i,s.options[n]=t)}return i}_render(e,t){const n=this.render(e,t);if(null==n)throw"HTMLElement expected";return n}clearCache(){ge(this.options,e=>{e.$div&&(e.$div.remove(),delete e.$div)})}uncacheValue(e){const t=this.getOption(e);t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,n){var i=this,s=i[t];i[t]=function(){var t,r;return"after"===e&&(t=s.apply(i,arguments)),r=n.apply(i,arguments),"instead"===e?r:("before"===e&&(t=s.apply(i,arguments)),t)}}}const Fe=e=>"boolean"==typeof e?e?"1":"0":e+"",je=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},Re=e=>"string"==typeof e&&e.indexOf("<")>-1;const $e=e=>"string"==typeof e&&e.indexOf("<")>-1;const He=(e,t,n,i)=>{e.addEventListener(t,n,i)},qe=e=>"string"==typeof e&&e.indexOf("<")>-1,Ve=(e,t)=>{((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(t,(t,n)=>{null==t?e.removeAttribute(n):e.setAttribute(n,""+t)})};const ze=e=>"string"==typeof e&&e.indexOf("<")>-1;const Be=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))}),t.filter(Boolean)},We=e=>(Array.isArray(e)||(e=[e]),e);const Ue=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(Ye(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},Ye=e=>"string"==typeof e&&e.indexOf("<")>-1,Ze=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))}),t.filter(Boolean)},Ge=e=>(Array.isArray(e)||(e=[e]),e);const Ke=(e,t,n,i)=>{e.addEventListener(t,n,i)};const Je=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},Xe=(e,t,n,i)=>{e.addEventListener(t,n,i)},Qe=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(et(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},et=e=>"string"==typeof e&&e.indexOf("<")>-1;const tt=e=>{var t=[];return((e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)})(e,e=>{"string"==typeof e&&(e=e.trim().split(/[\t\n\f\r\s]/)),Array.isArray(e)&&(t=t.concat(e))}),t.filter(Boolean)},nt=e=>(Array.isArray(e)||(e=[e]),e);Pe.define("change_listener",function(){var e,t,n,i;e=this.input,t="change",n=()=>{this.sync()},e.addEventListener(t,n,i)}),Pe.define("checkbox_options",function(e){var t=this,n=t.onOptionSelect;t.settings.hideSelected=!1;const i=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},e);var s=function(e,t){t?(e.checked=!0,i.uncheckedClassNames&&e.classList.remove(...i.uncheckedClassNames),i.checkedClassNames&&e.classList.add(...i.checkedClassNames)):(e.checked=!1,i.checkedClassNames&&e.classList.remove(...i.checkedClassNames),i.uncheckedClassNames&&e.classList.add(...i.uncheckedClassNames))},r=function(e){setTimeout(()=>{var t=e.querySelector("input."+i.className);t instanceof HTMLInputElement&&s(t,e.classList.contains("selected"))},1)};t.hook("after","setupTemplates",()=>{var e=t.settings.render.option;t.settings.render.option=(n,r)=>{var o=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(Re(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(e.call(t,n,r)),a=document.createElement("input");i.className&&a.classList.add(i.className),a.addEventListener("click",function(e){je(e)}),a.type="checkbox";const l=null==(c=n[t.settings.valueField])?null:Fe(c);var c;return s(a,!!(l&&t.items.indexOf(l)>-1)),o.prepend(a),o}}),t.on("item_remove",e=>{var n=t.getOption(e);n&&(n.classList.remove("selected"),r(n))}),t.on("item_add",e=>{var n=t.getOption(e);n&&r(n)}),t.hook("instead","onOptionSelect",(e,i)=>{if(i.classList.contains("selected"))return i.classList.remove("selected"),t.removeItem(i.dataset.value),t.refreshOptions(),void je(e,!0);n.call(t,e,i),r(i)})}),Pe.define("clear_button",function(e){const t=this,n=Object.assign({className:"clear-button",title:"Clear All",html:e=>`
`},e);t.on("initialize",()=>{var e=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if($e(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(n.html(n));e.addEventListener("click",e=>{t.isLocked||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())}),t.control.appendChild(e)})}),Pe.define("drag_drop",function(){var e=this;if("multi"!==e.settings.mode)return;var t=e.lock,n=e.unlock;let i,s=!0;e.hook("after","setupTemplates",()=>{var t=e.settings.render.item;e.settings.render.item=(n,r)=>{const o=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(qe(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(t.call(e,n,r));Ve(o,{draggable:"true"});const a=e=>{e.preventDefault(),o.classList.add("ts-drag-over"),l(o,i)},l=(e,t)=>{var n,i,s;void 0!==t&&(((e,t)=>{do{var n;if(e==(t=null==(n=t)?void 0:n.previousElementSibling))return!0}while(t&&t.previousElementSibling);return!1})(t,o)?(i=t,null==(s=(n=e).parentNode)||s.insertBefore(i,n.nextSibling)):((e,t)=>{var n;null==(n=e.parentNode)||n.insertBefore(t,e)})(e,t))};return He(o,"mousedown",e=>{s||((e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())})(e),e.stopPropagation()}),He(o,"dragstart",e=>{i=o,setTimeout(()=>{o.classList.add("ts-dragging")},0)}),He(o,"dragenter",a),He(o,"dragover",a),He(o,"dragleave",()=>{o.classList.remove("ts-drag-over")}),He(o,"dragend",()=>{var t;document.querySelectorAll(".ts-drag-over").forEach(e=>e.classList.remove("ts-drag-over")),null==(t=i)||t.classList.remove("ts-dragging"),i=void 0;var n=[];e.control.querySelectorAll("[data-value]").forEach(e=>{if(e.dataset.value){let t=e.dataset.value;t&&n.push(t)}}),e.setValue(n)}),o}}),e.hook("instead","lock",()=>(s=!1,t.call(e))),e.hook("instead","unlock",()=>(s=!0,n.call(e)))}),Pe.define("dropdown_header",function(e){const t=this,n=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'
'+e.title+'×
'},e);t.on("initialize",()=>{var e=(e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(ze(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)})(n.html(n)),i=e.querySelector("."+n.closeClass);i&&i.addEventListener("click",e=>{((e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())})(e,!0),t.close()}),t.dropdown.insertBefore(e,t.dropdown.firstChild)})}),Pe.define("caret_position",function(){var e=this;e.hook("instead","setCaret",t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach((n,i)=>{i{if(!e.isFocused)return;const n=e.getLastActive(t);if(n){const i=((e,t)=>{if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n})(n);e.setCaret(t>0?i+1:i),e.setActiveItem(),((e,...t)=>{var n=Be(t);(e=We(e)).map(e=>{n.map(t=>{e.classList.remove(t)})})})(n,"last-active")}else e.setCaret(e.caretPos+t)})}),Pe.define("dropdown_input",function(){const e=this;e.settings.shouldOpen=!0,e.hook("before","setup",()=>{e.focus_node=e.control,((e,...t)=>{var n=Ze(t);(e=Ge(e)).map(e=>{n.map(t=>{e.classList.add(t)})})})(e.control_input,"dropdown-input");const t=Ue('