@contributte/datagrid 0.0.0-20251215-dbad96a → 0.0.0-20251215-ec83b9f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,6 @@ export class InlinePlugin implements DatagridPlugin {
11
11
  if (!payload._datagrid_name || payload._datagrid_name !== datagrid.name) return;
12
12
 
13
13
  if (payload._datagrid_inline_edited || payload._datagrid_inline_edit_cancel) {
14
- const trigger = datagrid.el.querySelector('.datagrid-inline-edit-trigger');
15
-
16
14
  if (payload._datagrid_inline_edited) {
17
15
  let rows = datagrid.el.querySelectorAll<HTMLTableCellElement>(
18
16
  `tr[data-id='${payload._datagrid_inline_edited}'] > td`
@@ -20,10 +18,9 @@ export class InlinePlugin implements DatagridPlugin {
20
18
 
21
19
  rows.forEach(row => {
22
20
  row.classList.add("edited");
23
- })
21
+ });
24
22
  }
25
23
 
26
- trigger?.classList.remove("hidden");
27
24
  return;
28
25
  }
29
26
 
@@ -37,11 +34,6 @@ export class InlinePlugin implements DatagridPlugin {
37
34
  }
38
35
  }
39
36
 
40
- if (payload._datagrid_inline_editing) {
41
- datagrid.el.querySelector<HTMLElement>(".datagrid-inline-edit-trigger")
42
- ?.classList.add("hidden");
43
- }
44
-
45
37
  datagrid.el.querySelectorAll<HTMLElement>(".datagrid-inline-edit input").forEach(inputEl => {
46
38
  inputEl.addEventListener("keydown", e => {
47
39
  if (!isEnter(e)) return;
@@ -4,7 +4,7 @@ const t=t=>{"loading"===document.readyState?document.addEventListener("DOMConten
4
4
  *
5
5
  * This file is part of the Nette Framework (https://nette.org)
6
6
  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
7
- */var b=(m||(m=1,v.exports=function(){class t{filled(t,e,i){return""!==i&&!1!==i&&null!==i&&(!Array.isArray(i)||i.length>0)&&(!(i instanceof FileList)||i.length>0)}blank(t,e,i){return!this.filled(t,e,i)}valid(t,e){return e.validateControl(t,void 0,!0)}equal(t,e,i){if(void 0===e)return null;let n=t=>"number"==typeof t||"string"==typeof t?""+t:!0===t?"1":"",r=Array.isArray(i)?i:[i],s=Array.isArray(e)?e:[e];t:for(let t of r){for(let e of s)if(n(t)===n(e))continue t;return!1}return r.length>0}notEqual(t,e,i){return void 0===e?null:!this.equal(t,e,i)}minLength(t,e,i){return(i="number"==typeof i?i.toString():i).length>=e}maxLength(t,e,i){return(i="number"==typeof i?i.toString():i).length<=e}length(t,e,i){return i="number"==typeof i?i.toString():i,(null===(e=Array.isArray(e)?e:[e,e])[0]||i.length>=e[0])&&(null===e[1]||i.length<=e[1])}email(t,e,i){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(i)}url(t,e,i,n){return/^[a-z\d+.-]+:/.test(i)||(i="https://"+i),!!/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(i)&&(n.value=i,!0)}regexp(t,e,i){let n="string"==typeof e&&e.match(/^\/(.*)\/([imu]*)$/);try{return n&&new RegExp(n[1],n[2].replace("u","")).test(i)}catch{return null}}pattern(t,e,i,n,r){if("string"!=typeof e)return null;try{let t;try{t=new RegExp("^(?:"+e+")$",r?"ui":"u")}catch{t=new RegExp("^(?:"+e+")$",r?"i":"")}return i instanceof FileList?Array.from(i).every(e=>t.test(e.name)):t.test(i)}catch{return null}}patternCaseInsensitive(t,e,i){return this.pattern(t,e,i,null,!0)}numeric(t,e,i){return/^[0-9]+$/.test(i)}integer(t,e,i,n){return!!/^-?[0-9]+$/.test(i)&&(n.value=parseFloat(i),!0)}float(t,e,i,n){return i=i.replace(/ +/g,"").replace(/,/g,"."),!!/^-?[0-9]*\.?[0-9]+$/.test(i)&&(n.value=parseFloat(i),!0)}min(t,e,i){return Number.isFinite(e)&&(i=parseFloat(i)),i>=e}max(t,e,i){return Number.isFinite(e)&&(i=parseFloat(i)),i<=e}range(t,e,i){return Array.isArray(e)?"time"===t.type&&e[0]>e[1]?i>=e[0]||i<=e[1]:(null===e[0]||this.min(t,e[0],i))&&(null===e[1]||this.max(t,e[1],i)):null}submitted(t){return t.form["nette-submittedBy"]===t}fileSize(t,e,i){return Array.from(i).every(t=>t.size<=e)}mimeType(t,e,i){let n=[];(e=Array.isArray(e)?e:[e]).forEach(t=>n.push("^"+t.replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$"));let r=new RegExp(n.join("|"));return Array.from(i).every(t=>!t.type||r.test(t.type))}image(t,e,i){return this.mimeType(t,e??["image/gif","image/png","image/jpeg","image/webp"],i)}static(t,e){return e}}class e{formErrors=[];validators=new t;#t={};#e={};#i=new WeakMap;#n(t,e){let i=t.elements.namedItem(e);return i instanceof RadioNodeList?i[0]:i}#r(t){let e=t.form.elements.namedItem(t.name);return e instanceof RadioNodeList?Array.from(e):[e]}#s(t){"loading"!==document.readyState?t.call(this):document.addEventListener("DOMContentLoaded",t)}getValue(t){return t instanceof HTMLInputElement?"radio"===t.type?this.#r(t).find(t=>t.checked)?.value??null:"file"===t.type?t.files:"checkbox"===t.type?t.name.endsWith("[]")?this.#r(t).filter(t=>t.checked).map(t=>t.value):t.checked:t.value.trim():t instanceof HTMLSelectElement?t.multiple?Array.from(t.selectedOptions,t=>t.value):t.selectedOptions[0]?.value??null:t instanceof HTMLTextAreaElement?t.value:t instanceof RadioNodeList?this.getValue(t[0]):null}getEffectiveValue(t,e=!1){let i=this.getValue(t);if(i===t.getAttribute("data-nette-empty-value")&&(i=""),e&&void 0===this.#t[t.name]){this.#t[t.name]=!0;let e={value:i};this.validateControl(t,void 0,!0,e),i=e.value,delete this.#t[t.name]}return i}validateControl(t,e,i=!1,n,r){e??=JSON.parse(t.getAttribute("data-nette-rules")??"[]"),n??={value:this.getEffectiveValue(t)},r??=!this.validateRule(t,":filled",null,n);for(let s of e){let e=s.op.match(/(~)?([^?]+)/),o=s.control?this.#n(t.form,s.control):t;if(s.neg=!!e[1],s.op=e[2],s.condition=!!s.rules,!o)continue;if(r&&!s.condition&&":filled"!==s.op)continue;let a=this.validateRule(o,s.op,s.arg,t===o?n:void 0);if(null!==a)if(s.neg&&(a=!a),s.condition&&a){if(!this.validateControl(t,s.rules,i,n,":blank"!==s.op&&r))return!1}else if(!s.condition&&!a){if(this.isDisabled(o))continue;if(!i){let e=Array.isArray(s.arg)?s.arg:[s.arg],i=s.msg.replace(/%(value|\d+)/g,(i,n)=>this.getValue("value"===n?o:t.form.elements.namedItem(e[n].control)));this.addError(o,i)}return!1}}return!0}validateForm(t,e=!1){let i,n=t.form??t;if(this.formErrors=[],null!==t.getAttribute("formnovalidate")){let e=JSON.parse(t.getAttribute("data-nette-validation-scope")??"[]");if(!e.length)return this.showFormErrors(n,[]),!0;i=new RegExp("^("+e.join("-|")+"-)")}for(let t of n.elements)if(t.willValidate&&t.validity.badInput)return t.reportValidity(),!1;for(let t of n.elements)if(t.getAttribute("data-nette-rules")&&(!i||t.name.replace(/]\[|\[|]|$/g,"-").match(i))&&!this.isDisabled(t)&&!this.validateControl(t,void 0,e)&&!this.formErrors.length)return!1;let r=!this.formErrors.length;return this.showFormErrors(n,this.formErrors),r}isDisabled(t){return"radio"===t.type?this.#r(t).every(t=>t.disabled):t.disabled}addError(t,e){this.formErrors.push({element:t,message:e})}showFormErrors(t,e){let i,n=[];for(let t of e)n.indexOf(t.message)<0&&(n.push(t.message),i??=t.element);n.length&&this.showModal(n.join("\n"),()=>{i?.focus()})}showModal(t,e){let i=document.createElement("dialog");if(!i.showModal)return alert(t),void e();let n=document.createElement("style");n.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";let r=document.createElement("button");r.innerText="OK",r.onclick=()=>{i.remove(),e()},i.setAttribute("class","netteFormsModal"),i.innerText=t+"\n\n",i.append(n,r),document.body.append(i),i.showModal()}validateRule(t,e,i,n){if(t.validity.badInput)return":filled"===e;n??={value:this.getEffectiveValue(t,!0)};let r=":"===e.charAt(0)?e.substring(1):e;r=r.replace("::","_").replaceAll("\\","");let s=Array.isArray(i)?i:[i];return s=s.map(e=>{if(e?.control){let i=this.#n(t.form,e.control);return i===t?n.value:this.getEffectiveValue(i,!0)}return e}),"valid"===r&&(s[0]=this),this.validators[r]?this.validators[r](t,Array.isArray(i)?s:s[0],n.value,n):null}toggleForm(t,e){this.#e={};for(let i of Array.from(t.elements))i.getAttribute("data-nette-rules")&&this.toggleControl(i,void 0,null,!e);for(let t in this.#e)this.toggle(t,this.#e[t].state,this.#e[t].elem,e)}toggleControl(t,e,i=null,n=!1,r,s){e??=JSON.parse(t.getAttribute("data-nette-rules")??"[]"),r??={value:this.getEffectiveValue(t)},s??=!this.validateRule(t,":filled",null,r);let o,a=!1;for(let l of e){let e=l.op.match(/(~)?([^?]+)/),c=l.control?this.#n(t.form,l.control):t;if(l.neg=!!e[1],l.op=e[2],l.condition=!!l.rules,c&&(!s||l.condition||":filled"===l.op)){if(o=i,!1!==i){if(o=this.validateRule(c,l.op,l.arg,t===c?r:void 0),null===o)continue;l.neg&&(o=!o),l.condition||(i=o)}if(l.condition&&this.toggleControl(t,l.rules,o,n,r,":blank"!==l.op&&s)||l.toggle){a=!0,n&&this.#r(c).filter(t=>!this.#i.has(t)).forEach(e=>{e.addEventListener("change",e=>this.toggleForm(t.form,e)),this.#i.set(e,null)});for(let e in l.toggle??{})this.#e[e]??={elem:t,state:!1},this.#e[e].state||=l.toggle[e]?!!o:!o}}}return a}toggle(t,e,i,n){/^\w[\w.:-]*$/.test(t)&&(t="#"+t),Array.from(document.querySelectorAll(t)).forEach(t=>t.hidden=!e)}compactCheckboxes(t,e){let i={};for(let n of t.elements)n instanceof HTMLInputElement&&"checkbox"===n.type&&n.name.endsWith("[]")&&n.checked&&!n.disabled&&(e.delete(n.name),i[n.name]??=[],i[n.name].push(n.value));for(let t in i)e.set(t.substring(0,t.length-2),i[t].join(","))}initForm(t){"get"===t.method&&t.hasAttribute("data-nette-compact")&&t.addEventListener("formdata",e=>this.compactCheckboxes(t,e.formData)),Array.from(t.elements).some(t=>t.getAttribute("data-nette-rules"))&&(this.toggleForm(t),t.noValidate||(t.noValidate=!0,t.addEventListener("submit",e=>{this.validateForm(e.submitter||t)||(e.stopImmediatePropagation(),e.preventDefault())}),t.addEventListener("reset",()=>{setTimeout(()=>this.toggleForm(t))})))}initOnLoad(){this.#s(()=>{Array.from(document.forms).forEach(t=>this.initForm(t))})}}let i={"á":"a","ä":"a","č":"c","ď":"d","é":"e","ě":"e","í":"i","ľ":"l","ň":"n","ó":"o","ô":"o","ř":"r","š":"s","ť":"t","ú":"u","ů":"u","ý":"y","ž":"z"};function n(t){t=t.toLowerCase();let e="";for(let n=0;n<t.length;n++){let r=i[t.charAt(n)];e+=r||t.charAt(n)}return e.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var r="3.5.3";let s=new e;return s.version=r,s.webalize=n,s}()),v.exports),y=g(b);function _(t){return"Enter"===t.key}function w(){return null!=w?w:{}}function E(t,e=200){let i=null,n=!1;return(...r)=>{n||(i&&clearTimeout(i),i=setTimeout(()=>{const e=t(...r);var i;"object"==typeof(i=e)&&"function"==typeof i.then&&(n=!0,e.finally(()=>{n=!1}))},e))}}function A(t,e){t.split(/\s+/).forEach(t=>{e(t)})}class S{constructor(){this._events={}}on(t,e){A(t,t=>{const i=this._events[t]||[];i.push(e),this._events[t]=i})}off(t,e){var i=arguments.length;0!==i?A(t,t=>{if(1===i)return void delete this._events[t];const n=this._events[t];void 0!==n&&(n.splice(n.indexOf(e),1),this._events[t]=n)}):this._events={}}trigger(t,...e){var i=this;A(t,t=>{const n=i._events[t];void 0!==n&&n.forEach(t=>{t.apply(i,e)})})}}const k=t=>(t=t.filter(Boolean)).length<2?t[0]||"":1==T(t)?"["+t.join("")+"]":"(?:"+t.join("|")+")",C=t=>{if(!D(t))return t.join("");let e="",i=0;const n=()=>{i>1&&(e+="{"+i+"}")};return t.forEach((r,s)=>{r!==t[s-1]?(n(),e+=r,i=1):i++}),n(),e},O=t=>{let e=Array.from(t);return k(e)},D=t=>new Set(t).size!==t.length,x=t=>(t+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),T=t=>t.reduce((t,e)=>Math.max(t,L(e)),0),L=t=>Array.from(t).length,I=t=>{if(1===t.length)return[[t]];let e=[];const i=t.substring(1);return I(i).forEach(function(i){let n=i.slice(0);n[0]=t.charAt(0)+n[0],e.push(n),n=i.slice(0),n.unshift(t.charAt(0)),e.push(n)}),e},M=[[0,65535]];let F,N;const j={},P={"/":"⁄∕",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 t in P){let e=P[t]||"";for(let i=0;i<e.length;i++){let n=e.substring(i,i+1);j[n]=t}}const H=new RegExp(Object.keys(j).join("|")+"|[̀-ͯ·ʾʼ]","gu"),q=(t,e="NFKD")=>t.normalize(e),R=t=>Array.from(t).reduce((t,e)=>t+B(e),""),B=t=>(t=q(t).toLowerCase().replace(H,t=>j[t]||""),q(t,"NFC"));const V=t=>{const e={},i=(t,i)=>{const n=e[t]||new Set,r=new RegExp("^"+O(n)+"$","iu");i.match(r)||(n.add(x(i)),e[t]=n)};for(let e of function*(t){for(const[e,i]of t)for(let t=e;t<=i;t++){let e=String.fromCharCode(t),i=R(e);i!=e.toLowerCase()&&(i.length>3||0!=i.length&&(yield{folded:i,composed:e,code_point:t}))}}(t))i(e.folded,e.folded),i(e.folded,e.composed);return e},z=t=>{const e=V(t),i={};let n=[];for(let t in e){let r=e[t];r&&(i[t]=O(r)),t.length>1&&n.push(x(t))}n.sort((t,e)=>e.length-t.length);const r=k(n);return N=new RegExp("^"+r,"u"),i},W=(t,e=1)=>(e=Math.max(e,t.length-1),k(I(t).map(t=>((t,e=1)=>{let i=0;return t=t.map(t=>(F[t]&&(i+=t.length),F[t]||t)),i>=e?C(t):""})(t,e)))),Y=(t,e=!0)=>{let i=t.length>1?1:0;return k(t.map(t=>{let n=[];const r=e?t.length():t.length()-1;for(let e=0;e<r;e++)n.push(W(t.substrs[e]||"",i));return C(n)}))},K=(t,e)=>{for(const i of e){if(i.start!=t.start||i.end!=t.end)continue;if(i.substrs.join("")!==t.substrs.join(""))continue;let e=t.parts;const n=t=>{for(const i of e){if(i.start===t.start&&i.substr===t.substr)return!1;if(1!=t.length&&1!=i.length){if(t.start<i.start&&t.end>i.start)return!0;if(i.start<t.start&&i.end>t.start)return!0}}return!1};if(!(i.parts.filter(n).length>0))return!0}return!1};class U{parts;substrs;start;end;constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(t){t&&(this.parts.push(t),this.substrs.push(t.substr),this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(t,e){let i=new U,n=JSON.parse(JSON.stringify(this.parts)),r=n.pop();for(const t of n)i.add(t);let s=e.substr.substring(0,t-r.start),o=s.length;return i.add({start:r.start,end:r.start+o,length:o,substr:s}),i}}const X=t=>{void 0===F&&(F=z(M)),t=R(t);let e="",i=[new U];for(let n=0;n<t.length;n++){let r=t.substring(n).match(N);const s=t.substring(n,n+1),o=r?r[0]:null;let a=[],l=new Set;for(const t of i){const e=t.last();if(!e||1==e.length||e.end<=n)if(o){const e=o.length;t.add({start:n,end:n+e,length:e,substr:o}),l.add("1")}else t.add({start:n,end:n+1,length:1,substr:s}),l.add("2");else if(o){let i=t.clone(n,e);const r=o.length;i.add({start:n,end:n+r,length:r,substr:o}),a.push(i)}else l.add("3")}if(a.length>0){a=a.sort((t,e)=>t.length()-e.length());for(let t of a)K(t,i)||i.push(t)}else if(n>0&&1==l.size&&!l.has("3")){e+=Y(i,!1);let t=new U;const n=i[0];n&&t.add(n.last()),i=[t]}}return e+=Y(i,!0),e},Q=(t,e)=>{if(t)return t[e]},G=(t,e)=>{if(t){for(var i,n=e.split(".");(i=n.shift())&&(t=t[i]););return t}},J=(t,e,i)=>{var n,r;return t?(t+="",null==e.regex||-1===(r=t.search(e.regex))?0:(n=e.string.length/t.length,0===r&&(n+=.5),n*i)):0},Z=(t,e)=>{var i=t[e];if("function"==typeof i)return i;i&&!Array.isArray(i)&&(t[e]=[i])},tt=(t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},et=(t,e)=>"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=R(t+"").toLowerCase())>(e=R(e+"").toLowerCase())?1:e>t?-1:0;class it{items;settings;constructor(t,e){this.items=t,this.settings=e||{diacritics:!0}}tokenize(t,e,i){if(!t||!t.length)return[];const n=[],r=t.split(/\s+/);var s;return i&&(s=new RegExp("^("+Object.keys(i).map(x).join("|")+"):(.*)$")),r.forEach(t=>{let i,r=null,o=null;s&&(i=t.match(s))&&(r=i[1],t=i[2]),t.length>0&&(o=this.settings.diacritics?X(t)||null:x(t),o&&e&&(o="\\b"+o)),n.push({string:t,regex:o?new RegExp(o,"iu"):null,field:r})}),n}getScoreFunction(t,e){var i=this.prepareSearch(t,e);return this._getScoreFunction(i)}_getScoreFunction(t){const e=t.tokens,i=e.length;if(!i)return function(){return 0};const n=t.options.fields,r=t.weights,s=n.length,o=t.getAttrFn;if(!s)return function(){return 1};const a=1===s?function(t,e){const i=n[0].field;return J(o(e,i),t,r[i]||1)}:function(t,e){var i=0;if(t.field){const n=o(e,t.field);!t.regex&&n?i+=1/s:i+=J(n,t,1)}else tt(r,(n,r)=>{i+=J(o(e,r),t,n)});return i/s};return 1===i?function(t){return a(e[0],t)}:"and"===t.options.conjunction?function(t){var n,r=0;for(let i of e){if((n=a(i,t))<=0)return 0;r+=n}return r/i}:function(t){var n=0;return tt(e,e=>{n+=a(e,t)}),n/i}}getSortFunction(t,e){var i=this.prepareSearch(t,e);return this._getSortFunction(i)}_getSortFunction(t){var e,i=[];const n=this,r=t.options,s=!t.query&&r.sort_empty?r.sort_empty:r.sort;if("function"==typeof s)return s.bind(this);const o=function(e,i){return"$score"===e?i.score:t.getAttrFn(n.items[i.id],e)};if(s)for(let e of s)(t.query||"$score"!==e.field)&&i.push(e);if(t.query){e=!0;for(let t of i)if("$score"===t.field){e=!1;break}e&&i.unshift({field:"$score",direction:"desc"})}else i=i.filter(t=>"$score"!==t.field);return i.length?function(t,e){var n,r;for(let s of i){if(r=s.field,n=("desc"===s.direction?-1:1)*et(o(r,t),o(r,e)))return n}return 0}:null}prepareSearch(t,e){const i={};var n=Object.assign({},e);if(Z(n,"sort"),Z(n,"sort_empty"),n.fields){Z(n,"fields");const t=[];n.fields.forEach(e=>{"string"==typeof e&&(e={field:e,weight:1}),t.push(e),i[e.field]="weight"in e?e.weight:1}),n.fields=t}return{options:n,query:t.toLowerCase().trim(),tokens:this.tokenize(t,n.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:n.nesting?G:Q}}search(t,e){var i,n,r=this;n=this.prepareSearch(t,e),e=n.options,t=n.query;const s=e.score||r._getScoreFunction(n);t.length?tt(r.items,(t,r)=>{i=s(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:r})}):tt(r.items,(t,e)=>{n.items.push({score:1,id:e})});const o=r._getSortFunction(n);return o&&n.items.sort(o),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n}}const nt=t=>null==t?null:rt(t),rt=t=>"boolean"==typeof t?t?"1":"0":t+"",st=t=>(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ot=(t,e)=>{var i;return function(n,r){var s=this;i&&(s.loading=Math.max(s.loading-1,0),clearTimeout(i)),i=setTimeout(function(){i=null,s.loadedSearches[n]=!0,t.call(s,n,r)},e)}},at=(t,e,i)=>{var n,r=t.trigger,s={};for(n of(t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return r.apply(t,arguments);s[i]=arguments},i.apply(t,[]),t.trigger=r,e))n in s&&r.apply(t,s[n])},lt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},ct=(t,e,i,n)=>{t.addEventListener(e,i,n)},dt=(t,e)=>!!e&&(!!e[t]&&1===(e.altKey?1:0)+(e.ctrlKey?1:0)+(e.shiftKey?1:0)+(e.metaKey?1:0)),ut=(t,e)=>{const i=t.getAttribute("id");return i||(t.setAttribute("id",e),e)},ht=t=>t.replace(/[\\"']/g,"\\$&"),pt=(t,e)=>{e&&t.append(e)},ft=(t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},gt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(mt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},mt=t=>"string"==typeof t&&t.indexOf("<")>-1,vt=(t,e)=>{var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)},bt=(t,e)=>{Object.assign(t.style,e)},yt=(t,...e)=>{var i=wt(e);(t=Et(t)).map(t=>{i.map(e=>{t.classList.add(e)})})},_t=(t,...e)=>{var i=wt(e);(t=Et(t)).map(t=>{i.map(e=>{t.classList.remove(e)})})},wt=t=>{var e=[];return ft(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Et=t=>(Array.isArray(t)||(t=[t]),t),At=(t,e,i)=>{if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}},St=(t,e=0)=>e>0?t[t.length-1]:t[0],kt=(t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i},Ct=(t,e)=>{ft(e,(e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)})},Ot=(t,e)=>{t.parentNode&&t.parentNode.replaceChild(e,t)},Dt=(t,e)=>{if(null===e)return;if("string"==typeof e){if(!e.length)return;e=new RegExp(e,"i")}const i=t=>3===t.nodeType?(t=>{var i=t.data.match(e);if(i&&t.data.length>0){var n=document.createElement("span");n.className="highlight";var r=t.splitText(i.index);r.splitText(i[0].length);var s=r.cloneNode(!0);return n.appendChild(s),Ot(r,n),1}return 0})(t):((t=>{1!==t.nodeType||!t.childNodes||/(script|style)/i.test(t.tagName)||"highlight"===t.className&&"SPAN"===t.tagName||Array.from(t.childNodes).forEach(t=>{i(t)})})(t),0);i(t)},xt="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey";var Tt={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:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(t){return t.length>0},render:{}};function Lt(t,e){var i=Object.assign({},Tt,e),n=i.dataAttr,r=i.labelField,s=i.valueField,o=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,c=i.optgroupValueField,d=t.tagName.toLowerCase(),u=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!u&&!i.allowEmptyOption){let e=t.querySelector('option[value=""]');e&&(u=e.textContent)}var h={placeholder:u,options:[],optgroups:[],items:[],maxItems:null};return"select"===d?(()=>{var e,d=h.options,u={},p=1;let f=0;var g=t=>{var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},m=(t,e)=>{var n=nt(t.value);if(null!=n&&(n||i.allowEmptyOption)){if(u.hasOwnProperty(n)){if(e){var l=u[n][a];l?Array.isArray(l)?l.push(e):u[n][a]=[l,e]:u[n][a]=e}}else{var c=g(t);c[r]=c[r]||t.textContent,c[s]=c[s]||n,c[o]=c[o]||t.disabled,c[a]=c[a]||e,c.$option=t,c.$order=c.$order||++f,u[n]=c,d.push(c)}t.selected&&h.items.push(n)}};h.maxItems=t.hasAttribute("multiple")?null:1,ft(t.children,t=>{var i,n,r;"optgroup"===(e=t.tagName.toLowerCase())?((r=g(i=t))[l]=r[l]||i.getAttribute("label")||"",r[c]=r[c]||p++,r[o]=r[o]||i.disabled,r.$order=r.$order||++f,h.optgroups.push(r),n=r[c],ft(i.children,t=>{m(t,n)})):"option"===e&&m(t)})})():(()=>{const e=t.getAttribute(n);if(e)h.options=JSON.parse(e),ft(h.options,t=>{h.items.push(t[s])});else{var o=t.value.trim()||"";if(!i.allowEmptyOption&&!o.length)return;const e=o.split(i.delimiter);ft(e,t=>{const e={};e[r]=t,e[s]=t,h.options.push(e)}),h.items=e}})(),Object.assign({},Tt,h,e)}var It=0;let Mt=class extends(function(t){return t.plugins={},class extends t{constructor(){super(...arguments),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(e,i){t.plugins[e]={name:e,fn:i}}initializePlugins(t){var e,i;const n=this,r=[];if(Array.isArray(t))t.forEach(t=>{"string"==typeof t?r.push(t):(n.plugins.settings[t.name]=t.options,r.push(t.name))});else if(t)for(e in t)t.hasOwnProperty(e)&&(n.plugins.settings[e]=t[e],r.push(e));for(;i=r.shift();)n.require(i)}loadPlugin(e){var i=this,n=i.plugins,r=t.plugins[e];if(!t.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');n.requested[e]=!0,n.loaded[e]=r.fn.apply(i,[i.plugins.settings[e]||{}]),n.names.push(e)}require(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]}}}(S)){constructor(t,e){var i;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,It++;var n=gt(t);if(n.tomselect)throw new Error("Tom Select already initialized on this element");n.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(n,null)).getPropertyValue("direction");const r=Lt(n,e);this.settings=r,this.input=n,this.tabIndex=n.tabIndex||0,this.is_select_tag="select"===n.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=ut(n,"tomselect-"+It),this.isRequired=n.required,this.sifter=new it(this.options,{diacritics:r.diacritics}),r.mode=r.mode||(1===r.maxItems?"single":"multi"),"boolean"!=typeof r.hideSelected&&(r.hideSelected="multi"===r.mode),"boolean"!=typeof r.hidePlaceholder&&(r.hidePlaceholder="multi"!==r.mode);var s=r.createFilter;"function"!=typeof s&&("string"==typeof s&&(s=new RegExp(s)),s instanceof RegExp?r.createFilter=t=>s.test(t):r.createFilter=t=>this.settings.duplicates||!this.options[t]),this.initializePlugins(r.plugins),this.setupCallbacks(),this.setupTemplates();const o=gt("<div>"),a=gt("<div>"),l=this._render("dropdown"),c=gt('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",u=r.mode;var h;if(yt(o,r.wrapperClass,d,u),yt(a,r.controlClass),pt(o,a),yt(l,r.dropdownClass,u),r.copyClassesToDropdown&&yt(l,d),yt(c,r.dropdownContentClass),pt(l,c),gt(r.dropdownParent||o).appendChild(l),mt(r.controlInput)){h=gt(r.controlInput);ft(["autocorrect","autocapitalize","autocomplete","spellcheck"],t=>{n.getAttribute(t)&&Ct(h,{[t]:n.getAttribute(t)})}),h.tabIndex=-1,a.appendChild(h),this.focus_node=h}else r.controlInput?(h=gt(r.controlInput),this.focus_node=h):(h=gt("<input/>"),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 t=this,e=t.settings,i=t.control_input,n=t.dropdown,r=t.dropdown_content,s=t.wrapper,o=t.control,a=t.input,l=t.focus_node,c={passive:!0},d=t.inputId+"-ts-dropdown";Ct(r,{id:d}),Ct(l,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d});const u=ut(l,t.inputId+"-ts-control"),h="label[for='"+(t=>t.replace(/['"\\]/g,"\\$&"))(t.inputId)+"']",p=document.querySelector(h),f=t.focus.bind(t);if(p){ct(p,"click",f),Ct(p,{for:u});const e=ut(p,t.inputId+"-ts-label");Ct(l,{"aria-labelledby":e}),Ct(r,{"aria-labelledby":e})}if(s.style.width=a.style.width,t.plugins.names.length){const e="plugin-"+t.plugins.names.join(" plugin-");yt([s,n],e)}(null===e.maxItems||e.maxItems>1)&&t.is_select_tag&&Ct(a,{multiple:"multiple"}),e.placeholder&&Ct(i,{placeholder:e.placeholder}),!e.splitOn&&e.delimiter&&(e.splitOn=new RegExp("\\s*"+x(e.delimiter)+"+\\s*")),e.load&&e.loadThrottle&&(e.load=ot(e.load,e.loadThrottle)),ct(n,"mousemove",()=>{t.ignoreHover=!1}),ct(n,"mouseenter",e=>{var i=At(e.target,"[data-selectable]",n);i&&t.onOptionHover(e,i)},{capture:!0}),ct(n,"click",e=>{const i=At(e.target,"[data-selectable]");i&&(t.onOptionSelect(e,i),lt(e,!0))}),ct(o,"click",e=>{var n=At(e.target,"[data-ts-item]",o);n&&t.onItemSelect(e,n)?lt(e,!0):""==i.value&&(t.onClick(),lt(e,!0))}),ct(l,"keydown",e=>t.onKeyDown(e)),ct(i,"keypress",e=>t.onKeyPress(e)),ct(i,"input",e=>t.onInput(e)),ct(l,"blur",e=>t.onBlur(e)),ct(l,"focus",e=>t.onFocus(e)),ct(i,"paste",e=>t.onPaste(e));const g=e=>{const r=e.composedPath()[0];if(!s.contains(r)&&!n.contains(r))return t.isFocused&&t.blur(),void t.inputState();r==i&&t.isOpen?e.stopPropagation():lt(e,!0)},m=()=>{t.isOpen&&t.positionDropdown()};ct(document,"mousedown",g),ct(window,"scroll",m,c),ct(window,"resize",m,c),this._destroy=()=>{document.removeEventListener("mousedown",g),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),p&&p.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",t.wrapper),t.sync(!1),e.items=[],delete e.optgroups,delete e.options,ct(a,"invalid",()=>{t.isValid&&(t.isValid=!1,t.isInvalid=!0,t.refreshState())}),t.updateOriginalInput(),t.refreshItems(),t.close(!1),t.inputState(),t.isSetup=!0,a.disabled?t.disable():a.readOnly?t.setReadOnly(!0):t.enable(),t.on("change",this.onChange),yt(a,"tomselected","ts-hidden-accessible"),t.trigger("initialize"),!0===e.preload&&t.preload()}setupOptions(t=[],e=[]){this.addOptions(t),ft(e,t=>{this.registerOptionGroup(t)})}setupTemplates(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:t=>{let e=document.createElement("div");return e.className="optgroup",e.appendChild(t.options),e},optgroup_header:(t,e)=>'<div class="optgroup-header">'+e(t[i])+"</div>",option:(t,i)=>"<div>"+i(t[e])+"</div>",item:(t,i)=>"<div>"+i(t[e])+"</div>",option_create:(t,e)=>'<div class="create">Add <strong>'+e(t.input)+"</strong>&hellip;</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"};t.settings.render=Object.assign({},n,t.settings.render)}setupCallbacks(){var t,e,i={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(t in i)(e=this.settings[i[t]])&&this.on(t,e)}sync(t=!0){const e=this,i=t?Lt(e.input,{delimiter:e.settings.delimiter}):e.settings;e.setupOptions(i.options,i.optgroups),e.setValue(i.items||[],!0),e.lastQuery=null}onClick(){var t=this;if(t.activeItems.length>0)return t.clearActiveItems(),void t.focus();t.isFocused&&t.isOpen?t.blur():t.focus()}onMouseDown(){}onChange(){vt(this.input,"input"),vt(this.input,"change")}onPaste(t){var e=this;e.isInputHidden||e.isLocked?lt(t):e.settings.splitOn&&setTimeout(()=>{var t=e.inputValue();if(t.match(e.settings.splitOn)){var i=t.trim().split(e.settings.splitOn);ft(i,t=>{nt(t)&&(this.options[t]?e.addItem(t):e.createItem(t))})}},0)}onKeyPress(t){var e=this;if(!e.isLocked){var i=String.fromCharCode(t.keyCode||t.which);return e.settings.create&&"multi"===e.settings.mode&&i===e.settings.delimiter?(e.createItem(),void lt(t)):void 0}lt(t)}onKeyDown(t){var e=this;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&lt(t);else{switch(t.keyCode){case 65:if(dt(xt,t)&&""==e.control_input.value)return lt(t),void e.selectAll();break;case 27:return e.isOpen&&(lt(t,!0),e.close()),void e.clearActiveItems();case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){let t=e.getAdjacent(e.activeOption,1);t&&e.setActiveOption(t)}return void lt(t);case 38:if(e.activeOption){let t=e.getAdjacent(e.activeOption,-1);t&&e.setActiveOption(t)}return void lt(t);case 13:return void(e.canSelect(e.activeOption)?(e.onOptionSelect(t,e.activeOption),lt(t)):(e.settings.create&&e.createItem()||document.activeElement==e.control_input&&e.isOpen)&&lt(t));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return void(e.settings.selectOnTab&&(e.canSelect(e.activeOption)&&(e.onOptionSelect(t,e.activeOption),lt(t)),e.settings.create&&e.createItem()&&lt(t)));case 8:case 46:return void e.deleteSelection(t)}e.isInputHidden&&!dt(xt,t)&&lt(t)}}onInput(t){if(this.isLocked)return;const e=this.inputValue();this.lastValue!==e&&(this.lastValue=e,""!=e?(this.refreshTimeout&&window.clearTimeout(this.refreshTimeout),this.refreshTimeout=((t,e)=>e>0?window.setTimeout(t,e):(t.call(null),null))(()=>{this.refreshTimeout=null,this._onInput()},this.settings.refreshThrottle)):this._onInput())}_onInput(){const t=this.lastValue;this.settings.shouldLoad.call(this,t)&&this.load(t),this.refreshOptions(),this.trigger("type",t)}onOptionHover(t,e){this.ignoreHover||this.setActiveOption(e,!1)}onFocus(t){var e=this,i=e.isFocused;if(e.isDisabled||e.isReadOnly)return e.blur(),void lt(t);e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.preload(),i||e.trigger("focus"),e.activeItems.length||(e.inputState(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())}onBlur(t){if(!1!==document.hasFocus()){var e=this;if(e.isFocused){e.isFocused=!1,e.ignoreFocus=!1;var i=()=>{e.close(),e.setActiveItem(),e.setCaret(e.items.length),e.trigger("blur")};e.settings.create&&e.settings.createOnBlur?e.createItem(null,i):i()}}}onOptionSelect(t,e){var i,n=this;e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?n.createItem(null,()=>{n.settings.closeAfterSelect&&n.close()}):void 0!==(i=e.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect&&n.close(),!n.settings.hideSelected&&t.type&&/click/.test(t.type)&&n.setActiveOption(e)))}canSelect(t){return!!(this.isOpen&&t&&this.dropdown_content.contains(t))}onItemSelect(t,e){var i=this;return!i.isLocked&&"multi"===i.settings.mode&&(lt(t),i.setActiveItem(e,t),!0)}canLoad(t){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(t)}load(t){const e=this;if(!e.canLoad(t))return;yt(e.wrapper,e.settings.loadingClass),e.loading++;const i=e.loadCallback.bind(e);e.settings.load.call(e,t,i)}loadCallback(t,e){const i=this;i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(t,e),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||_t(i.wrapper,i.settings.loadingClass),i.trigger("load",t,e)}preload(){var t=this.wrapper.classList;t.contains("preloaded")||(t.add("preloaded"),this.load(""))}setTextboxValue(t=""){var e=this.control_input;e.value!==t&&(e.value=t,vt(e,"update"),this.lastValue=t)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(t,e){at(this,e?[]:["change"],()=>{this.clear(e),this.addItems(t,e)})}setMaxItems(t){0===t&&(t=null),this.settings.maxItems=t,this.refreshState()}setActiveItem(t,e){var i,n,r,s,o,a,l=this;if("single"!==l.settings.mode){if(!t)return l.clearActiveItems(),void(l.isFocused&&l.inputState());if("click"===(i=e&&e.type.toLowerCase())&&dt("shiftKey",e)&&l.activeItems.length){for(a=l.getLastActive(),(r=Array.prototype.indexOf.call(l.control.children,a))>(s=Array.prototype.indexOf.call(l.control.children,t))&&(o=r,r=s,s=o),n=r;n<=s;n++)t=l.control.children[n],-1===l.activeItems.indexOf(t)&&l.setActiveItemClass(t);lt(e)}else"click"===i&&dt(xt,e)||"keydown"===i&&dt("shiftKey",e)?t.classList.contains("active")?l.removeActiveItem(t):l.setActiveItemClass(t):(l.clearActiveItems(),l.setActiveItemClass(t));l.inputState(),l.isFocused||l.focus()}}setActiveItemClass(t){const e=this,i=e.control.querySelector(".last-active");i&&_t(i,"last-active"),yt(t,"active last-active"),e.trigger("item_select",t),-1==e.activeItems.indexOf(t)&&e.activeItems.push(t)}removeActiveItem(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),_t(t,"active")}clearActiveItems(){_t(this.activeItems,"active"),this.activeItems=[]}setActiveOption(t,e=!0){t!==this.activeOption&&(this.clearActiveOption(),t&&(this.activeOption=t,Ct(this.focus_node,{"aria-activedescendant":t.getAttribute("id")}),Ct(t,{"aria-selected":"true"}),yt(t,"active"),e&&this.scrollToOption(t)))}scrollToOption(t,e){if(!t)return;const i=this.dropdown_content,n=i.clientHeight,r=i.scrollTop||0,s=t.offsetHeight,o=t.getBoundingClientRect().top-i.getBoundingClientRect().top+r;o+s>n+r?this.scroll(o-n+s,e):o<r&&this.scroll(o,e)}scroll(t,e){const i=this.dropdown_content;e&&(i.style.scrollBehavior=e),i.scrollTop=t,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(_t(this.activeOption,"active"),Ct(this.activeOption,{"aria-selected":null})),this.activeOption=null,Ct(this.focus_node,{"aria-activedescendant":null})}selectAll(){const t=this;if("single"===t.settings.mode)return;const e=t.controlChildren();e.length&&(t.inputState(),t.close(),t.activeItems=e,ft(e,e=>{t.setActiveItemClass(e)}))}inputState(){var t=this;t.control.contains(t.control_input)&&(Ct(t.control_input,{placeholder:t.settings.placeholder}),t.activeItems.length>0||!t.isFocused&&t.settings.hidePlaceholder&&t.items.length>0?(t.setTextboxValue(),t.isInputHidden=!0):(t.settings.hidePlaceholder&&t.items.length>0&&Ct(t.control_input,{placeholder:""}),t.isInputHidden=!1),t.wrapper.classList.toggle("input-hidden",t.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var t=this;t.isDisabled||t.isReadOnly||(t.ignoreFocus=!0,t.control_input.offsetWidth?t.control_input.focus():t.focus_node.focus(),setTimeout(()=>{t.ignoreFocus=!1,t.onFocus()},0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())}getSearchOptions(){var t=this.settings,e=t.sortField;return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(t){var e,i,n=this,r=this.getSearchOptions();if(n.settings.score&&"function"!=typeof(i=n.settings.score.call(n,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');return t!==n.lastQuery?(n.lastQuery=t,e=n.sifter.search(t,Object.assign(r,{score:i})),n.currentResults=e):e=Object.assign({},n.currentResults),n.settings.hideSelected&&(e.items=e.items.filter(t=>{let e=nt(t.id);return!(e&&-1!==n.items.indexOf(e))})),e}refreshOptions(t=!0){var e,i,n,r,s,o,a,l,c,d;const u={},h=[];var p=this,f=p.inputValue();const g=f===p.lastQuery||""==f&&null==p.lastQuery;var m=p.search(f),v=null,b=p.settings.shouldOpen||!1,y=p.dropdown_content;g&&(v=p.activeOption)&&(c=v.closest("[data-group]")),r=m.items.length,"number"==typeof p.settings.maxOptions&&(r=Math.min(r,p.settings.maxOptions)),r>0&&(b=!0);const _=(t,e)=>{let i=u[t];if(void 0!==i){let t=h[i];if(void 0!==t)return[i,t.fragment]}let n=document.createDocumentFragment();return i=h.length,h.push({fragment:n,order:e,optgroup:t}),[i,n]};for(e=0;e<r;e++){let t=m.items[e];if(!t)continue;let r=t.id,a=p.options[r];if(void 0===a)continue;let l=rt(r),d=p.getOption(l,!0);for(p.settings.hideSelected||d.classList.toggle("selected",p.items.includes(l)),s=a[p.settings.optgroupField]||"",i=0,n=(o=Array.isArray(s)?s:[s])&&o.length;i<n;i++){s=o[i];let t=a.$order,e=p.optgroups[s];void 0===e?s="":t=e.$order;const[n,l]=_(s,t);i>0&&(d=d.cloneNode(!0),Ct(d,{id:a.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),_t(d,"active"),p.activeOption&&p.activeOption.dataset.value==r&&c&&c.dataset.group===s.toString()&&(v=d)),l.appendChild(d),""!=s&&(u[s]=n)}}var w;p.settings.lockOptgroupOrder&&h.sort((t,e)=>t.order-e.order),a=document.createDocumentFragment(),ft(h,t=>{let e=t.fragment,i=t.optgroup;if(!e||!e.children.length)return;let n=p.optgroups[i];if(void 0!==n){let t=document.createDocumentFragment(),i=p.render("optgroup_header",n);pt(t,i),pt(t,e);let r=p.render("optgroup",{group:n,options:t});pt(a,r)}else pt(a,e)}),y.innerHTML="",pt(y,a),p.settings.highlight&&(w=y.querySelectorAll("span.highlight"),Array.prototype.forEach.call(w,function(t){var e=t.parentNode;e.replaceChild(t.firstChild,t),e.normalize()}),m.query.length&&m.tokens.length&&ft(m.tokens,t=>{Dt(y,t.regex)}));var E=t=>{let e=p.render(t,{input:f});return e&&(b=!0,y.insertBefore(e,y.firstChild)),e};if(p.loading?E("loading"):p.settings.shouldLoad.call(p,f)?0===m.items.length&&E("no_results"):E("not_loading"),(l=p.canCreate(f))&&(d=E("option_create")),p.hasOptions=m.items.length>0||l,b){if(m.items.length>0){if(v||"single"!==p.settings.mode||null==p.items[0]||(v=p.getOption(p.items[0])),!y.contains(v)){let t=0;d&&!p.settings.addPrecedence&&(t=1),v=p.selectable()[t]}}else d&&(v=d);t&&!p.isOpen&&(p.open(),p.scrollToOption(v,"auto")),p.setActiveOption(v)}else p.clearActiveOption(),t&&p.isOpen&&p.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(t,e=!1){const i=this;if(Array.isArray(t))return i.addOptions(t,e),!1;const n=nt(t[i.settings.valueField]);return null!==n&&!i.options.hasOwnProperty(n)&&(t.$order=t.$order||++i.order,t.$id=i.inputId+"-opt-"+t.$order,i.options[n]=t,i.lastQuery=null,e&&(i.userOptions[n]=e,i.trigger("option_add",n,t)),n)}addOptions(t,e=!1){ft(t,t=>{this.addOption(t,e)})}registerOption(t){return this.addOption(t)}registerOptionGroup(t){var e=nt(t[this.settings.optgroupValueField]);return null!==e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)}addOptionGroup(t,e){var i;e[this.settings.optgroupValueField]=t,(i=this.registerOptionGroup(e))&&this.trigger("optgroup_add",i,e)}removeOptionGroup(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(t,e){const i=this;var n,r;const s=nt(t),o=nt(e[i.settings.valueField]);if(null===s)return;const a=i.options[s];if(null==a)return;if("string"!=typeof o)throw new Error("Value must be set in option data");const l=i.getOption(s),c=i.getItem(s);if(e.$order=e.$order||a.$order,delete i.options[s],i.uncacheValue(o),i.options[o]=e,l){if(i.dropdown_content.contains(l)){const t=i._render("option",e);Ot(l,t),i.activeOption===l&&i.setActiveOption(t)}l.remove()}c&&(-1!==(r=i.items.indexOf(s))&&i.items.splice(r,1,o),n=i._render("item",e),c.classList.contains("active")&&yt(n,"active"),Ot(c,n)),i.lastQuery=null}removeOption(t,e){const i=this;t=rt(t),i.uncacheValue(t),delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)}clearOptions(t){const e=(t||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const i={};ft(this.options,(t,n)=>{e(t,n)&&(i[n]=t)}),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(t,e){return this.items.indexOf(e)>=0}getOption(t,e=!1){const i=nt(t);if(null===i)return null;const n=this.options[i];if(null!=n){if(n.$div)return n.$div;if(e)return this._render("option",n)}return null}getAdjacent(t,e,i="option"){var n;if(!t)return null;n="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]");for(let i=0;i<n.length;i++)if(n[i]==t)return e>0?n[i+1]:n[i-1];return null}getItem(t){if("object"==typeof t)return t;var e=nt(t);return null!==e?this.control.querySelector(`[data-value="${ht(e)}"]`):null}addItems(t,e){var i=this,n=Array.isArray(t)?t:[t];const r=(n=n.filter(t=>-1===i.items.indexOf(t)))[n.length-1];n.forEach(t=>{i.isPending=t!==r,i.addItem(t,e)})}addItem(t,e){at(this,e?[]:["change","dropdown_close"],()=>{var i,n;const r=this,s=r.settings.mode,o=nt(t);if((!o||-1===r.items.indexOf(o)||("single"===s&&r.close(),"single"!==s&&r.settings.duplicates))&&null!==o&&r.options.hasOwnProperty(o)&&("single"===s&&r.clear(e),"multi"!==s||!r.isFull())){if(i=r._render("item",r.options[o]),r.control.contains(i)&&(i=i.cloneNode(!0)),n=r.isFull(),r.items.splice(r.caretPos,0,o),r.insertAtCaret(i),r.isSetup){if(!r.isPending&&r.settings.hideSelected){let t=r.getOption(o),e=r.getAdjacent(t,1);e&&r.setActiveOption(e)}r.isPending||r.settings.closeAfterSelect||r.refreshOptions(r.isFocused&&"single"!==s),0!=r.settings.closeAfterSelect&&r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",o,i),r.isPending||r.updateOriginalInput({silent:e})}(!r.isPending||!n&&r.isFull())&&(r.inputState(),r.refreshState())}})}removeItem(t=null,e){const i=this;if(!(t=i.getItem(t)))return;var n,r;const s=t.dataset.value;n=kt(t),t.remove(),t.classList.contains("active")&&(r=i.activeItems.indexOf(t),i.activeItems.splice(r,1),_t(t,"active")),i.items.splice(n,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(s)&&i.removeOption(s,e),n<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:e}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",s,t)}createItem(t=null,e=()=>{}){3===arguments.length&&(e=arguments[2]),"function"!=typeof e&&(e=()=>{});var i,n=this,r=n.caretPos;if(t=t||n.inputValue(),!n.canCreate(t))return e(),!1;n.lock();var s=!1,o=t=>{if(n.unlock(),!t||"object"!=typeof t)return e();var i=nt(t[n.settings.valueField]);if("string"!=typeof i)return e();n.setTextboxValue(),n.addOption(t,!0),n.setCaret(r),n.addItem(i),e(t),s=!0};return i="function"==typeof n.settings.create?n.settings.create.call(this,t,o):{[n.settings.labelField]:t,[n.settings.valueField]:t},s||o(i),!0}refreshItems(){var t=this;t.lastQuery=null,t.isSetup&&t.addItems(t.items),t.updateOriginalInput(),t.refreshState()}refreshState(){const t=this;t.refreshValidityState();const e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);const n=t.wrapper.classList;var r;n.toggle("focus",t.isFocused),n.toggle("disabled",t.isDisabled),n.toggle("readonly",t.isReadOnly),n.toggle("required",t.isRequired),n.toggle("invalid",!t.isValid),n.toggle("locked",i),n.toggle("full",e),n.toggle("input-active",t.isFocused&&!t.isInputHidden),n.toggle("dropdown-active",t.isOpen),n.toggle("has-options",(r=t.options,0===Object.keys(r).length)),n.toggle("has-items",t.items.length>0)}refreshValidityState(){var t=this;t.input.validity&&(t.isValid=t.input.validity.valid,t.isInvalid=!t.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(t={}){const e=this;var i,n;const r=e.input.querySelector('option[value=""]');if(e.is_select_tag){const s=[],o=e.input.querySelectorAll("option:checked").length;function a(t,i,n){return t||(t=gt('<option value="'+st(i)+'">'+st(n)+"</option>")),t!=r&&e.input.append(t),s.push(t),(t!=r||o>0)&&(t.selected=!0),t}e.input.querySelectorAll("option:checked").forEach(t=>{t.selected=!1}),0==e.items.length&&"single"==e.settings.mode?a(r,"",""):e.items.forEach(t=>{if(i=e.options[t],n=i[e.settings.labelField]||"",s.includes(i.$option)){a(e.input.querySelector(`option[value="${ht(t)}"]:not(:checked)`),t,n)}else i.$option=a(i.$option,t,n)})}else e.input.value=e.getValue();e.isSetup&&(t.silent||e.trigger("change",e.getValue()))}open(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.isOpen=!0,Ct(t.focus_node,{"aria-expanded":"true"}),t.refreshState(),bt(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),bt(t.dropdown,{visibility:"visible",display:"block"}),t.focus(),t.trigger("dropdown_open",t.dropdown))}close(t=!0){var e=this,i=e.isOpen;t&&(e.setTextboxValue(),"single"===e.settings.mode&&e.items.length&&e.inputState()),e.isOpen=!1,Ct(e.focus_node,{"aria-expanded":"false"}),bt(e.dropdown,{display:"none"}),e.settings.hideSelected&&e.clearActiveOption(),e.refreshState(),i&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;bt(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}}clear(t){var e=this;if(e.items.length){var i=e.controlChildren();ft(i,t=>{e.removeItem(t,!0)}),e.inputState(),t||e.updateOriginalInput(),e.trigger("clear")}}insertAtCaret(t){const e=this,i=e.caretPos,n=e.control;n.insertBefore(t,n.children[i]||null),e.setCaret(i+1)}deleteSelection(t){var e,i,n,r,s,o=this;e=t&&8===t.keyCode?-1:1,i={start:(s=o.control_input).selectionStart||0,length:(s.selectionEnd||0)-(s.selectionStart||0)};const a=[];if(o.activeItems.length)r=St(o.activeItems,e),n=kt(r),e>0&&n++,ft(o.activeItems,t=>a.push(t));else if((o.isFocused||"single"===o.settings.mode)&&o.items.length){const t=o.controlChildren();let n;e<0&&0===i.start&&0===i.length?n=t[o.caretPos-1]:e>0&&i.start===o.inputValue().length&&(n=t[o.caretPos]),void 0!==n&&a.push(n)}if(!o.shouldDelete(a,t))return!1;for(lt(t,!0),void 0!==n&&o.setCaret(n);a.length;)o.removeItem(a.pop());return o.inputState(),o.positionDropdown(),o.refreshOptions(!1),!0}shouldDelete(t,e){const i=t.map(t=>t.dataset.value);return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,e))}advanceSelection(t,e){var i,n,r=this;r.rtl&&(t*=-1),r.inputValue().length||(dt(xt,e)||dt("shiftKey",e)?(n=(i=r.getLastActive(t))?i.classList.contains("active")?r.getAdjacent(i,t,"item"):i:t>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(n.classList.contains("active")&&r.removeActiveItem(i),r.setActiveItemClass(n)):r.moveCaret(t))}moveCaret(t){}getLastActive(t){let e=this.control.querySelector(".last-active");if(e)return e;var i=this.control.querySelectorAll(".active");return i?St(i,t):void 0}setCaret(t){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(t=this.isReadOnly||this.isDisabled){this.isLocked=t,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(t){this.focus_node.tabIndex=t?-1:this.tabIndex,this.isDisabled=t,this.input.disabled=t,this.control_input.disabled=t,this.setLocked()}setReadOnly(t){this.isReadOnly=t,this.input.readOnly=t,this.control_input.readOnly=t,this.setLocked()}destroy(){var t=this,e=t.revertSettings;t.trigger("destroy"),t.off(),t.wrapper.remove(),t.dropdown.remove(),t.input.innerHTML=e.innerHTML,t.input.tabIndex=e.tabIndex,_t(t.input,"tomselected","ts-hidden-accessible"),t._destroy(),delete t.input.tomselect}render(t,e){var i,n;const r=this;if("function"!=typeof this.settings.render[t])return null;if(!(n=r.settings.render[t].call(this,e,st)))return null;if(n=gt(n),"option"===t||"option_create"===t?e[r.settings.disabledField]?Ct(n,{"aria-disabled":"true"}):Ct(n,{"data-selectable":""}):"optgroup"===t&&(i=e.group[r.settings.optgroupValueField],Ct(n,{"data-group":i}),e.group[r.settings.disabledField]&&Ct(n,{"data-disabled":""})),"option"===t||"item"===t){const i=rt(e[r.settings.valueField]);Ct(n,{"data-value":i}),"item"===t?(yt(n,r.settings.itemClass),Ct(n,{"data-ts-item":""})):(yt(n,r.settings.optionClass),Ct(n,{role:"option",id:e.$id}),e.$div=n,r.options[i]=e)}return n}_render(t,e){const i=this.render(t,e);if(null==i)throw"HTMLElement expected";return i}clearCache(){ft(this.options,t=>{t.$div&&(t.$div.remove(),delete t.$div)})}uncacheValue(t){const e=this.getOption(t);e&&e.remove()}canCreate(t){return this.settings.create&&t.length>0&&this.settings.createFilter.call(this,t)}hook(t,e,i){var n=this,r=n[e];n[e]=function(){var e,s;return"after"===t&&(e=r.apply(n,arguments)),s=i.apply(n,arguments),"instead"===t?s:("before"===t&&(e=r.apply(n,arguments)),e)}}};const Ft=t=>"boolean"==typeof t?t?"1":"0":t+"",Nt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},jt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Pt=t=>"string"==typeof t&&t.indexOf("<")>-1;const $t=(t,e,i,n)=>{t.addEventListener(e,i,n)},Ht=t=>"string"==typeof t&&t.indexOf("<")>-1,qt=(t,e)=>{((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(e,(e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)})};const Rt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Bt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Vt=t=>(Array.isArray(t)||(t=[t]),t);const zt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Wt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},Wt=t=>"string"==typeof t&&t.indexOf("<")>-1,Yt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Kt=t=>(Array.isArray(t)||(t=[t]),t);const Ut=(t,e,i,n)=>{t.addEventListener(e,i,n)};const Xt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},Qt=(t,e,i,n)=>{t.addEventListener(e,i,n)},Gt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Jt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},Jt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Zt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},te=t=>(Array.isArray(t)||(t=[t]),t);Mt.define("change_listener",function(){var t,e,i,n;t=this.input,e="change",i=()=>{this.sync()},t.addEventListener(e,i,n)}),Mt.define("checkbox_options",function(t){var e=this,i=e.onOptionSelect;e.settings.hideSelected=!1;const n=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},t);var r=function(t,e){e?(t.checked=!0,n.uncheckedClassNames&&t.classList.remove(...n.uncheckedClassNames),n.checkedClassNames&&t.classList.add(...n.checkedClassNames)):(t.checked=!1,n.checkedClassNames&&t.classList.remove(...n.checkedClassNames),n.uncheckedClassNames&&t.classList.add(...n.uncheckedClassNames))},s=function(t){setTimeout(()=>{var e=t.querySelector("input."+n.className);e instanceof HTMLInputElement&&r(e,t.classList.contains("selected"))},1)};e.hook("after","setupTemplates",()=>{var t=e.settings.render.option;e.settings.render.option=(i,s)=>{var o=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(jt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(t.call(e,i,s)),a=document.createElement("input");n.className&&a.classList.add(n.className),a.addEventListener("click",function(t){Nt(t)}),a.type="checkbox";const l=null==(c=i[e.settings.valueField])?null:Ft(c);var c;return r(a,!!(l&&e.items.indexOf(l)>-1)),o.prepend(a),o}}),e.on("item_remove",t=>{var i=e.getOption(t);i&&(i.classList.remove("selected"),s(i))}),e.on("item_add",t=>{var i=e.getOption(t);i&&s(i)}),e.hook("instead","onOptionSelect",(t,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void Nt(t,!0);i.call(e,t,n),s(n)})}),Mt.define("clear_button",function(t){const e=this,i=Object.assign({className:"clear-button",title:"Clear All",html:t=>`<div class="${t.className}" title="${t.title}">&#10799;</div>`},t);e.on("initialize",()=>{var t=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Pt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(i.html(i));t.addEventListener("click",t=>{e.isLocked||(e.clear(),"single"===e.settings.mode&&e.settings.allowEmptyOption&&e.addItem(""),t.preventDefault(),t.stopPropagation())}),e.control.appendChild(t)})}),Mt.define("drag_drop",function(){var t=this;if("multi"!==t.settings.mode)return;var e=t.lock,i=t.unlock;let n,r=!0;t.hook("after","setupTemplates",()=>{var e=t.settings.render.item;t.settings.render.item=(i,s)=>{const o=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Ht(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(e.call(t,i,s));qt(o,{draggable:"true"});const a=t=>{t.preventDefault(),o.classList.add("ts-drag-over"),l(o,n)},l=(t,e)=>{var i,n,r;void 0!==e&&(((t,e)=>{do{var i;if(t==(e=null==(i=e)?void 0:i.previousElementSibling))return!0}while(e&&e.previousElementSibling);return!1})(e,o)?(n=e,null==(r=(i=t).parentNode)||r.insertBefore(n,i.nextSibling)):((t,e)=>{var i;null==(i=t.parentNode)||i.insertBefore(e,t)})(t,e))};return $t(o,"mousedown",t=>{r||((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(t),t.stopPropagation()}),$t(o,"dragstart",t=>{n=o,setTimeout(()=>{o.classList.add("ts-dragging")},0)}),$t(o,"dragenter",a),$t(o,"dragover",a),$t(o,"dragleave",()=>{o.classList.remove("ts-drag-over")}),$t(o,"dragend",()=>{var e;document.querySelectorAll(".ts-drag-over").forEach(t=>t.classList.remove("ts-drag-over")),null==(e=n)||e.classList.remove("ts-dragging"),n=void 0;var i=[];t.control.querySelectorAll("[data-value]").forEach(t=>{if(t.dataset.value){let e=t.dataset.value;e&&i.push(e)}}),t.setValue(i)}),o}}),t.hook("instead","lock",()=>(r=!1,e.call(t))),t.hook("instead","unlock",()=>(r=!0,i.call(t)))}),Mt.define("dropdown_header",function(t){const e=this,i=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:t=>'<div class="'+t.headerClass+'"><div class="'+t.titleRowClass+'"><span class="'+t.labelClass+'">'+t.title+'</span><a class="'+t.closeClass+'">&times;</a></div></div>'},t);e.on("initialize",()=>{var t=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Rt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(i.html(i)),n=t.querySelector("."+i.closeClass);n&&n.addEventListener("click",t=>{((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(t,!0),e.close()}),e.dropdown.insertBefore(t,e.dropdown.firstChild)})}),Mt.define("caret_position",function(){var t=this;t.hook("instead","setCaret",e=>{"single"!==t.settings.mode&&t.control.contains(t.control_input)?(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach((i,n)=>{n<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)}):e=t.items.length,t.caretPos=e}),t.hook("instead","moveCaret",e=>{if(!t.isFocused)return;const i=t.getLastActive(e);if(i){const n=((t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i})(i);t.setCaret(e>0?n+1:n),t.setActiveItem(),((t,...e)=>{var i=Bt(e);(t=Vt(t)).map(t=>{i.map(e=>{t.classList.remove(e)})})})(i,"last-active")}else t.setCaret(t.caretPos+e)})}),Mt.define("dropdown_input",function(){const t=this;t.settings.shouldOpen=!0,t.hook("before","setup",()=>{t.focus_node=t.control,((t,...e)=>{var i=Yt(e);(t=Kt(t)).map(t=>{i.map(e=>{t.classList.add(e)})})})(t.control_input,"dropdown-input");const e=zt('<div class="dropdown-input-wrap">');e.append(t.control_input),t.dropdown.insertBefore(e,t.dropdown.firstChild);const i=zt('<input class="items-placeholder" tabindex="-1" />');i.placeholder=t.settings.placeholder||"",t.control.append(i)}),t.on("initialize",()=>{t.control_input.addEventListener("keydown",e=>{switch(e.keyCode){case 27:return t.isOpen&&(((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(e,!0),t.close()),void t.clearActiveItems();case 9:t.focus_node.tabIndex=-1}return t.onKeyDown.call(t,e)}),t.on("blur",()=>{t.focus_node.tabIndex=t.isDisabled?-1:t.tabIndex}),t.on("dropdown_open",()=>{t.control_input.focus()});const e=t.onBlur;var i,n,r,s;t.hook("instead","onBlur",i=>{if(!i||i.relatedTarget!=t.control_input)return e.call(t)}),i=t.control_input,n="blur",r=()=>t.onBlur(),i.addEventListener(n,r,s),t.hook("before","close",()=>{t.isOpen&&t.focus_node.focus({preventScroll:!0})})})}),Mt.define("input_autogrow",function(){var t=this;t.on("initialize",()=>{var e=document.createElement("span"),i=t.control_input;e.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",t.wrapper.appendChild(e);for(const t of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])e.style[t]=i.style[t];var n=()=>{e.textContent=i.value,i.style.width=e.clientWidth+"px"};n(),t.on("update item_add item_remove",n),Ut(i,"input",n),Ut(i,"keyup",n),Ut(i,"blur",n),Ut(i,"update",n)})}),Mt.define("no_backspace_delete",function(){var t=this,e=t.deleteSelection;this.hook("instead","deleteSelection",i=>!!t.activeItems.length&&e.call(t,i))}),Mt.define("no_active_items",function(){this.hook("instead","setActiveItem",()=>{}),this.hook("instead","selectAll",()=>{})}),Mt.define("optgroup_columns",function(){var t=this,e=t.onKeyDown;t.hook("instead","onKeyDown",i=>{var n,r,s,o;if(!t.isOpen||37!==i.keyCode&&39!==i.keyCode)return e.call(t,i);t.ignoreHover=!0,o=((t,e)=>{for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}})(t.activeOption,"[data-group]"),n=((t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i})(t.activeOption,"[data-selectable]"),o&&(o=37===i.keyCode?o.previousSibling:o.nextSibling)&&(r=(s=o.querySelectorAll("[data-selectable]"))[Math.min(s.length-1,n)])&&t.setActiveOption(r)})}),Mt.define("remove_button",function(t){const e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},t);var i=this;if(e.append){var n='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+((e.title+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")+'">')+e.label+"</a>";i.hook("after","setupTemplates",()=>{var t=i.settings.render.item;i.settings.render.item=(e,r)=>{var s=Gt(t.call(i,e,r)),o=Gt(n);return s.appendChild(o),Qt(o,"mousedown",t=>{Xt(t,!0)}),Qt(o,"click",t=>{i.isLocked||(Xt(t,!0),i.isLocked||i.shouldDelete([s],t)&&(i.removeItem(s),i.refreshOptions(!1),i.inputState()))}),s}})}}),Mt.define("restore_on_backspace",function(t){const e=this,i=Object.assign({text:t=>t[e.settings.labelField]},t);e.on("item_remove",function(t){if(e.isFocused&&""===e.control_input.value.trim()){var n=e.options[t];n&&e.setTextboxValue(i.text.call(e,n))}})}),Mt.define("virtual_scroll",function(){const t=this,e=t.canLoad,i=t.clearActiveOption,n=t.loadCallback;var r,s,o={},a=!1,l=[];if(t.settings.shouldLoadMore||(t.settings.shouldLoadMore=()=>{if(r.clientHeight/(r.scrollHeight-r.scrollTop)>.9)return!0;if(t.activeOption){var e=t.selectable();if(Array.from(e).indexOf(t.activeOption)>=e.length-2)return!0}return!1}),!t.settings.firstUrl)throw"virtual_scroll plugin requires a firstUrl() method";t.settings.sortField=[{field:"$order"},{field:"$score"}];const c=e=>!("number"==typeof t.settings.maxOptions&&r.children.length>=t.settings.maxOptions)&&!(!(e in o)||!o[e]),d=(e,i)=>t.items.indexOf(i)>=0||l.indexOf(i)>=0;t.setNextUrl=(t,e)=>{o[t]=e},t.getUrl=e=>{if(e in o){const t=o[e];return o[e]=!1,t}return t.clearPagination(),t.settings.firstUrl.call(t,e)},t.clearPagination=()=>{o={}},t.hook("instead","clearActiveOption",()=>{if(!a)return i.call(t)}),t.hook("instead","canLoad",i=>i in o?c(i):e.call(t,i)),t.hook("instead","loadCallback",(e,i)=>{if(a){if(s){const i=e[0];void 0!==i&&(s.dataset.value=i[t.settings.valueField])}}else t.clearOptions(d);n.call(t,e,i),a=!1}),t.hook("after","refreshOptions",()=>{const e=t.lastValue;var i;c(e)?(i=t.render("loading_more",{query:e}))&&(i.setAttribute("data-selectable",""),s=i):e in o&&!r.querySelector(".no-results")&&(i=t.render("no_more_results",{query:e})),i&&(((t,...e)=>{var i=Zt(e);(t=te(t)).map(t=>{i.map(e=>{t.classList.add(e)})})})(i,t.settings.optionClass),r.append(i))}),t.on("initialize",()=>{l=Object.keys(t.options),r=t.dropdown_content,t.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},t.settings.render),r.addEventListener("scroll",()=>{t.settings.shouldLoadMore.call(t)&&c(t.lastValue)&&(a||(a=!0,t.load.call(t,t.lastValue)))})})});class ee{constructor(t){this.datepicker=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initDatepicker(t)}),this.initDatepicker(t),!0}initDatepicker(t){const e=t.el.querySelectorAll("input[data-provide='datepicker']");e.length>=1&&this.datepicker.initDatepickers(Array.from(e),t)}}class ie{constructor(t){this.nette=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initNetteForms(t)}),this.initNetteForms(t),!0}initNetteForms(t){var e,i;const n=null!==(i=null!==(e=this.nette)&&void 0!==e?e:w().Nette)&&void 0!==i?i:null;n&&t.el.querySelectorAll("form").forEach(t=>n.initForm(t))}}class ne{constructor(t){this.selectpicker=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initSelectpicker(t)}),this.initSelectpicker(t),!0}initSelectpicker(t){const e=t.el.querySelectorAll("select.selectpicker");e.length>=1&&this.selectpicker.initSelectpickers(Array.from(e),t)}}class re{constructor(t){this.sortable=t}onDatagridInit(t){return t.ajax.addEventListener("before",t=>{}),this.sortable.initSortable(t),t.ajax.addEventListener("success",({detail:{payload:e}})=>{if(e._datagrid_sort){for(const i in e._datagrid_sort){const n=e._datagrid_sort[i],r=t.el.querySelector(`#datagrid-sort-${i}`);r&&(r.setAttribute("href",n),r.setAttribute("data-href",n))}this.sortable.initSortable(t)}if(e._datagrid_tree){const i=t.el.querySelector(`.datagrid-tree-item[data-id='${e._datagrid_tree}'] .datagrid-tree-item-children`);if(i&&e.snippets){i.classList.add("loaded");for(const t in e.snippets){const n=e.snippets[t],r=(new DOMParser).parseFromString(n,"text/html").firstElementChild;if(r){const e=document.createElement("div");e.id=t,e.classList.add("datagrid-tree-item"),e.setAttribute("data-id",t),r.hasAttribute("has-children")&&e.classList.add("has-children"),i.append(e)}}}this.sortable.initSortableTree(t)}}),!0}}class se{onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initPerPage(t),this.initChange(t)}),this.initPerPage(t),this.initChange(t),!0}initPerPage(t){t.el.querySelectorAll("select[data-autosubmit-per-page]").forEach(e=>{e.addEventListener("change",()=>{var i,n;let r=null===(i=e.parentElement)||void 0===i?void 0:i.querySelector("input[type=submit]");if(r||(r=null===(n=e.parentElement)||void 0===n?void 0:n.querySelector("button[type=submit]")),!(r instanceof HTMLElement))return;const s=r.closest("form");s&&t.ajax.submitForm(s)})})}initChange(t){t.el.querySelectorAll("[data-autosubmit]").forEach(e=>{const i=e.closest("form");i&&"true"!==e.dataset.listenersAttached&&(e.dataset.listenersAttached="true",e instanceof HTMLSelectElement?e.addEventListener("change",()=>t.ajax.submitForm(i)):e instanceof HTMLInputElement&&(e.hasAttribute("data-autosubmit-change")&&e.addEventListener("change",E(()=>t.ajax.submitForm(i))),e.addEventListener("keyup",E(e=>{if(_(e)||!function(t,e,i){const n=1===t.key.length?t.key.charCodeAt(0):0;return n>=e&&n<=i}(e,9,40)&&!function(t){return 2===t.key.length&&t.key.startsWith("F")}(e))return t.ajax.submitForm(i)}))))})}}class oe{onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.init(t)}),this.init(t)}init(t){let e=null;t.el.addEventListener("click",t=>{if(t.target instanceof HTMLElement&&t.target.classList.contains("col-checkbox")&&(e=t.target,t.shiftKey&&e)){const t=e.closest("tr");if(!t)return;const i=e.closest("tr");if(!i)return;const n=i.closest("tbody");if(!n)return;const r=Array.from(n.querySelectorAll("tr")),[s,o]=[i.rowIndex,t.rowIndex].sort();r.slice(s,o+1).forEach(t=>{const e=t.querySelector('.col-checkbox input[type="checkbox"]');e&&(e.checked=!0)})}});const i=Array.from(t.el.querySelectorAll(`input[data-check='${t.name}']:not([data-check-all])`)),n=t.el.querySelector(`input[data-check='${t.name}'][data-check-all]`),r=t.el.querySelector("select[name='group_action[group_action]']"),s=document.querySelectorAll(".row-group-actions *[type='submit']"),o=document.querySelector(".datagrid-selected-rows-count");return[...i,n].forEach(e=>{e&&e.addEventListener("change",()=>{if(e.hasAttribute("data-check-all")){if(t.name!==e.getAttribute("data-check-all"))return;if(i.forEach(t=>t.checked=e.checked),s.forEach(t=>t.disabled=!e.checked),r&&(r.disabled=!e.checked),o){const t=i.length;o.innerText=`${e.checked?t:0}/${t}`}return}n&&(n.checked=i.every(t=>t.checked));const a=i.filter(t=>t.checked),l=a.length>=1;s.forEach(t=>t.disabled=!l),r&&(r.disabled=!l),o&&(o.innerText=`${a.length}/${i.length}`)})}),!0}}const ae="data-datagrid-confirm";class le{constructor(){this.modalId="datagridConfirmModal",this.messageBoxId="datagridConfirmMessage",this.confirmButtonId="datagridConfirmOk"}onDatagridInit(t){this.datagrid=t;return t.el.querySelectorAll(`[${ae}]:not(.ajax)`).forEach(t=>t.addEventListener("click",e=>this.handleClick(t,e))),t.ajax.addEventListener("interact",e=>{const i=e.detail.element;t.el.contains(i)&&this.handleClick(i,e)}),!0}handleClick(t,e){const i=this.getConfirmationMessage(t);if(!i)return;e.preventDefault(),e.stopPropagation();const n=this.getElement(this.modalId);n?this.showModalConfirm(n,i,t,e):window.confirm(i)&&this.executeConfirmedAction(t,e)}getConfirmationMessage(t){var e,i,n;return null!==(n=null!==(e=t.getAttribute(ae))&&void 0!==e?e:null===(i=t.closest("a"))||void 0===i?void 0:i.getAttribute(ae))&&void 0!==n?n:null}showModalConfirm(t,e,i,n){if("undefined"==typeof bootstrap)return void(window.confirm(e)&&this.executeConfirmedAction(i,n));const r=this.getElement(this.messageBoxId),s=this.getElement(this.confirmButtonId);if(!r||!s)return void(window.confirm(e)&&this.executeConfirmedAction(i,n));r.textContent=e;const o=s.cloneNode(!0);s.parentNode.replaceChild(o,s),o.addEventListener("click",()=>{var e;null===(e=bootstrap.Modal.getInstance(t))||void 0===e||e.hide(),this.executeConfirmedAction(i,n)},{once:!0});(bootstrap.Modal.getInstance(t)||new bootstrap.Modal(t)).show()}executeConfirmedAction(t,e){var i,n;const r=e instanceof CustomEvent&&e.detail&&"object"==typeof e.detail?e.detail:null,s=t.classList.contains("ajax");if(t instanceof HTMLAnchorElement&&t.href&&s){if("undefined"==typeof naja)return;if(r&&"string"==typeof r.method&&"string"==typeof r.url){const t={...r.options,history:!1};naja.makeRequest(r.method,r.url,null!==(i=r.payload)&&void 0!==i?i:null,t)}else{const e=null!==(n=t.getAttribute("data-naja-method"))&&void 0!==n?n:"GET";naja.makeRequest(e,t.href,null,{history:!1})}}else this.triggerNativeInteraction(t)}getElement(t){return document.getElementById(t)}triggerNativeInteraction(t){const e=t.getAttribute(ae);null!==e&&t.removeAttribute(ae);try{t.click()}finally{null!==e&&t.setAttribute(ae,e)}}}const ce="data-datagrid-editable-url";class de{onDatagridInit(t){return t.ajax.addEventListener("success",e=>{this.initEditableCells(t)}),this.initEditableCells(t),!0}initEditableCells(t){t.el.querySelectorAll(`[${ce}]`).forEach(e=>{e.addEventListener("click",i=>{var n,r,s,o;if(!(e instanceof HTMLAnchorElement||e.classList.contains("datagrid-inline-edit")||e.classList.contains("editing"))){e.classList.add("editing");const i=e.innerHTML.replace(/<\/?br>/g,"\n").trim(),a=(null!==(n=e.getAttribute("data-datagrid-editable-value"))&&void 0!==n?n:i).trim();e.setAttribute("originalValue",i),e.setAttribute("valueToEdit",a);const l=null!==(r=e.getAttribute("data-datagrid-editable-type"))&&void 0!==r?r:"text";let c;switch(l){case"textarea":e.innerHTML=`<textarea rows="${function(t){var e;const i=t.style.padding?parseInt(t.style.padding.replace(/[^-\d\.]/g,""),10):0,n=t.getBoundingClientRect().height,r=Math.round(parseFloat(null!==(e=t.style.lineHeight)&&void 0!==e?e:"0"));return Math.round((n-2*i)/r)}(e)}">${a}</textarea>`,c=e.querySelector("textarea");break;case"select":e.innerHTML=null!==(s=e.getAttribute("data-datagrid-editable-element"))&&void 0!==s?s:"",c=e.querySelector("select"),c.querySelectorAll(`option[value='${a}']`).forEach(t=>t.setAttribute("selected","true"));break;default:e.innerHTML=`<input type='${l}' />`,c=e.querySelector("input"),c.setAttribute("value",a)}c.focus();const d=JSON.parse(null!==(o=e.getAttribute("data-datagrid-editable-attrs"))&&void 0!==o?o:"{}");for(const t in d){const e=d[t];c.setAttribute(t,e)}e.classList.remove("edited");const u=async n=>{var r,s,o;let c=n.value;if(c!==a)try{const i=await t.ajax.request({url:null!==(r=e.getAttribute(ce))&&void 0!==r?r:"",method:"POST",data:{value:c}});"select"===l?e.innerHTML=n instanceof HTMLSelectElement&&null!==(o=null===(s=n.options[n.selectedIndex])||void 0===s?void 0:s.text)&&void 0!==o?o:c:(i._datagrid_editable_new_value&&(c=i._datagrid_editable_new_value),e.innerHTML=c),e.classList.add("edited")}catch(t){e.innerHTML=i,e.classList.add("edited-error")}else e.innerHTML=i;e.classList.remove("editing")};e.querySelectorAll("input, textarea, select").forEach(t=>{t instanceof HTMLSelectElement||t.addEventListener("blur",()=>u(t)),t.addEventListener("keydown",n=>{if(_(n))return n.stopPropagation(),n.preventDefault(),u(t);(function(t){return"Escape"===t.key})(n)&&(n.stopPropagation(),n.preventDefault(),e.classList.remove("editing"),e.innerHTML=i)}),t instanceof HTMLSelectElement&&t.addEventListener("change",()=>u(t))})}})})}}class ue{onInit(t){}onDatagridInit(t){return t.ajax.addEventListener("success",({detail:{payload:e}})=>{var i,n;if(e._datagrid_name&&e._datagrid_name===t.name){if(e._datagrid_inline_edited||e._datagrid_inline_edit_cancel){const i=t.el.querySelector(".datagrid-inline-edit-trigger");if(e._datagrid_inline_edited){t.el.querySelectorAll(`tr[data-id='${e._datagrid_inline_edited}'] > td`).forEach(t=>{t.classList.add("edited")})}return void(null==i||i.classList.remove("hidden"))}if(e._datagrid_inline_adding){const e=t.el.querySelector(".datagrid-row-inline-add");e&&(e.classList.remove("datagrid-row-inline-add-hidden"),null===(i=e.querySelector("input:not([readonly]), textarea:not([readonly])"))||void 0===i||i.focus())}e._datagrid_inline_editing&&(null===(n=t.el.querySelector(".datagrid-inline-edit-trigger"))||void 0===n||n.classList.add("hidden")),t.el.querySelectorAll(".datagrid-inline-edit input").forEach(t=>{t.addEventListener("keydown",e=>{var i,n;if(_(e))return e.stopPropagation(),e.preventDefault(),null===(n=null===(i=t.closest("tr"))||void 0===i?void 0:i.querySelector(".col-action-inline-edit [name='inline_edit[submit]']"))||void 0===n?void 0:n.click()})}),t.el.querySelectorAll(".datagrid-inline-add input").forEach(t=>{t.addEventListener("keydown",e=>{var i,n;if(_(e))return e.stopPropagation(),e.preventDefault(),null===(n=null===(i=t.closest("tr"))||void 0===i?void 0:i.querySelector(".col-action-inline-edit [name='inline_add[submit]']"))||void 0===n?void 0:n.click()})}),t.el.querySelectorAll("[data-datagrid-cancel-inline-add]").forEach(t=>{t.addEventListener("mouseup",e=>{if(0===e.button){e.stopPropagation(),e.preventDefault();const i=t.closest(".datagrid-row-inline-add");i&&i.classList.add("datagrid-row-inline-add-hidden")}})})}}),!0}}class he{onDatagridInit(t){return t.el.querySelectorAll("[data-toggle-detail-grid]").forEach(e=>{if(e.getAttribute("data-toggle-detail-grid")!==t.name)return;const i=e.getAttribute("data-toggle-detail");e.addEventListener("click",n=>{const r=t.el.querySelector(`.item-detail-${t.name}-id-${i}`);e.closest("tr"),r&&(r.classList.add("datagrid--content-row"),r.classList.toggle("is-active")),t.ajax.addEventListener("before",e=>{e.detail.params.url.includes(`do=${t.name}-getItemDetail`)&&e.detail.params.url.includes(`grid-id=${i}`)&&(e.stopPropagation(),e.preventDefault())})})}),t.ajax.addEventListener("success",({detail:{payload:e}})=>{var i;e._datagrid_redraw_item_id&&e._datagrid_redraw_item_class&&(null===(i=t.el.querySelector(`tr[data-id='${e._datagrid_redraw_item_id}']`))||void 0===i||i.setAttribute("class",e._datagrid_redraw_item_class))}),!0}}class pe{onDatagridInit(t){return t.ajax.addEventListener("before",t=>{}),t.ajax.addEventListener("success",({detail:{payload:t}})=>{var e,i;if(t._datagrid_tree){const n=t._datagrid_tree,r=document.querySelector(`.datagrid-tree-item[data-id="${n}"]`),s=document.querySelector(`.datagrid-tree-item[data-id="${n}"] .datagrid-tree-item-children`);if(s){if(s.classList.contains("showed")){if(s.innerHTML="",s.classList.remove("showed"),r){const t=r.querySelector("a.chevron");t&&(t.style.transform="rotate(0deg)")}return}if(s.classList.add("showed"),r){const t=r.querySelector("a.chevron");t&&(t.style.transform="rotate(90deg)")}const n=t.snippets;for(const t in n){const r=n[t],o=(new DOMParser).parseFromString(r,"text/html").querySelector("[data-id]"),a=null!==(e=null==o?void 0:o.getAttribute("data-id"))&&void 0!==e?e:"",l=`\n<div class="datagrid-tree-item" class='${null!==(i=null==o?void 0:o.hasAttribute("data-has-children"))&&void 0!==i&&i?"has-children":""}' id="${t}" data-id="${a}">${r}</div>`;s.innerHTML=l}}}}),!0}}
7
+ */var b=(m||(m=1,v.exports=function(){class t{filled(t,e,i){return""!==i&&!1!==i&&null!==i&&(!Array.isArray(i)||i.length>0)&&(!(i instanceof FileList)||i.length>0)}blank(t,e,i){return!this.filled(t,e,i)}valid(t,e){return e.validateControl(t,void 0,!0)}equal(t,e,i){if(void 0===e)return null;let n=t=>"number"==typeof t||"string"==typeof t?""+t:!0===t?"1":"",r=Array.isArray(i)?i:[i],s=Array.isArray(e)?e:[e];t:for(let t of r){for(let e of s)if(n(t)===n(e))continue t;return!1}return r.length>0}notEqual(t,e,i){return void 0===e?null:!this.equal(t,e,i)}minLength(t,e,i){return(i="number"==typeof i?i.toString():i).length>=e}maxLength(t,e,i){return(i="number"==typeof i?i.toString():i).length<=e}length(t,e,i){return i="number"==typeof i?i.toString():i,(null===(e=Array.isArray(e)?e:[e,e])[0]||i.length>=e[0])&&(null===e[1]||i.length<=e[1])}email(t,e,i){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(i)}url(t,e,i,n){return/^[a-z\d+.-]+:/.test(i)||(i="https://"+i),!!/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(i)&&(n.value=i,!0)}regexp(t,e,i){let n="string"==typeof e&&e.match(/^\/(.*)\/([imu]*)$/);try{return n&&new RegExp(n[1],n[2].replace("u","")).test(i)}catch{return null}}pattern(t,e,i,n,r){if("string"!=typeof e)return null;try{let t;try{t=new RegExp("^(?:"+e+")$",r?"ui":"u")}catch{t=new RegExp("^(?:"+e+")$",r?"i":"")}return i instanceof FileList?Array.from(i).every(e=>t.test(e.name)):t.test(i)}catch{return null}}patternCaseInsensitive(t,e,i){return this.pattern(t,e,i,null,!0)}numeric(t,e,i){return/^[0-9]+$/.test(i)}integer(t,e,i,n){return!!/^-?[0-9]+$/.test(i)&&(n.value=parseFloat(i),!0)}float(t,e,i,n){return i=i.replace(/ +/g,"").replace(/,/g,"."),!!/^-?[0-9]*\.?[0-9]+$/.test(i)&&(n.value=parseFloat(i),!0)}min(t,e,i){return Number.isFinite(e)&&(i=parseFloat(i)),i>=e}max(t,e,i){return Number.isFinite(e)&&(i=parseFloat(i)),i<=e}range(t,e,i){return Array.isArray(e)?"time"===t.type&&e[0]>e[1]?i>=e[0]||i<=e[1]:(null===e[0]||this.min(t,e[0],i))&&(null===e[1]||this.max(t,e[1],i)):null}submitted(t){return t.form["nette-submittedBy"]===t}fileSize(t,e,i){return Array.from(i).every(t=>t.size<=e)}mimeType(t,e,i){let n=[];(e=Array.isArray(e)?e:[e]).forEach(t=>n.push("^"+t.replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$"));let r=new RegExp(n.join("|"));return Array.from(i).every(t=>!t.type||r.test(t.type))}image(t,e,i){return this.mimeType(t,e??["image/gif","image/png","image/jpeg","image/webp"],i)}static(t,e){return e}}class e{formErrors=[];validators=new t;#t={};#e={};#i=new WeakMap;#n(t,e){let i=t.elements.namedItem(e);return i instanceof RadioNodeList?i[0]:i}#r(t){let e=t.form.elements.namedItem(t.name);return e instanceof RadioNodeList?Array.from(e):[e]}#s(t){"loading"!==document.readyState?t.call(this):document.addEventListener("DOMContentLoaded",t)}getValue(t){return t instanceof HTMLInputElement?"radio"===t.type?this.#r(t).find(t=>t.checked)?.value??null:"file"===t.type?t.files:"checkbox"===t.type?t.name.endsWith("[]")?this.#r(t).filter(t=>t.checked).map(t=>t.value):t.checked:t.value.trim():t instanceof HTMLSelectElement?t.multiple?Array.from(t.selectedOptions,t=>t.value):t.selectedOptions[0]?.value??null:t instanceof HTMLTextAreaElement?t.value:t instanceof RadioNodeList?this.getValue(t[0]):null}getEffectiveValue(t,e=!1){let i=this.getValue(t);if(i===t.getAttribute("data-nette-empty-value")&&(i=""),e&&void 0===this.#t[t.name]){this.#t[t.name]=!0;let e={value:i};this.validateControl(t,void 0,!0,e),i=e.value,delete this.#t[t.name]}return i}validateControl(t,e,i=!1,n,r){e??=JSON.parse(t.getAttribute("data-nette-rules")??"[]"),n??={value:this.getEffectiveValue(t)},r??=!this.validateRule(t,":filled",null,n);for(let s of e){let e=s.op.match(/(~)?([^?]+)/),o=s.control?this.#n(t.form,s.control):t;if(s.neg=!!e[1],s.op=e[2],s.condition=!!s.rules,!o)continue;if(r&&!s.condition&&":filled"!==s.op)continue;let a=this.validateRule(o,s.op,s.arg,t===o?n:void 0);if(null!==a)if(s.neg&&(a=!a),s.condition&&a){if(!this.validateControl(t,s.rules,i,n,":blank"!==s.op&&r))return!1}else if(!s.condition&&!a){if(this.isDisabled(o))continue;if(!i){let e=Array.isArray(s.arg)?s.arg:[s.arg],i=s.msg.replace(/%(value|\d+)/g,(i,n)=>this.getValue("value"===n?o:t.form.elements.namedItem(e[n].control)));this.addError(o,i)}return!1}}return!0}validateForm(t,e=!1){let i,n=t.form??t;if(this.formErrors=[],null!==t.getAttribute("formnovalidate")){let e=JSON.parse(t.getAttribute("data-nette-validation-scope")??"[]");if(!e.length)return this.showFormErrors(n,[]),!0;i=new RegExp("^("+e.join("-|")+"-)")}for(let t of n.elements)if(t.willValidate&&t.validity.badInput)return t.reportValidity(),!1;for(let t of n.elements)if(t.getAttribute("data-nette-rules")&&(!i||t.name.replace(/]\[|\[|]|$/g,"-").match(i))&&!this.isDisabled(t)&&!this.validateControl(t,void 0,e)&&!this.formErrors.length)return!1;let r=!this.formErrors.length;return this.showFormErrors(n,this.formErrors),r}isDisabled(t){return"radio"===t.type?this.#r(t).every(t=>t.disabled):t.disabled}addError(t,e){this.formErrors.push({element:t,message:e})}showFormErrors(t,e){let i,n=[];for(let t of e)n.indexOf(t.message)<0&&(n.push(t.message),i??=t.element);n.length&&this.showModal(n.join("\n"),()=>{i?.focus()})}showModal(t,e){let i=document.createElement("dialog");if(!i.showModal)return alert(t),void e();let n=document.createElement("style");n.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";let r=document.createElement("button");r.innerText="OK",r.onclick=()=>{i.remove(),e()},i.setAttribute("class","netteFormsModal"),i.innerText=t+"\n\n",i.append(n,r),document.body.append(i),i.showModal()}validateRule(t,e,i,n){if(t.validity.badInput)return":filled"===e;n??={value:this.getEffectiveValue(t,!0)};let r=":"===e.charAt(0)?e.substring(1):e;r=r.replace("::","_").replaceAll("\\","");let s=Array.isArray(i)?i:[i];return s=s.map(e=>{if(e?.control){let i=this.#n(t.form,e.control);return i===t?n.value:this.getEffectiveValue(i,!0)}return e}),"valid"===r&&(s[0]=this),this.validators[r]?this.validators[r](t,Array.isArray(i)?s:s[0],n.value,n):null}toggleForm(t,e){this.#e={};for(let i of Array.from(t.elements))i.getAttribute("data-nette-rules")&&this.toggleControl(i,void 0,null,!e);for(let t in this.#e)this.toggle(t,this.#e[t].state,this.#e[t].elem,e)}toggleControl(t,e,i=null,n=!1,r,s){e??=JSON.parse(t.getAttribute("data-nette-rules")??"[]"),r??={value:this.getEffectiveValue(t)},s??=!this.validateRule(t,":filled",null,r);let o,a=!1;for(let l of e){let e=l.op.match(/(~)?([^?]+)/),c=l.control?this.#n(t.form,l.control):t;if(l.neg=!!e[1],l.op=e[2],l.condition=!!l.rules,c&&(!s||l.condition||":filled"===l.op)){if(o=i,!1!==i){if(o=this.validateRule(c,l.op,l.arg,t===c?r:void 0),null===o)continue;l.neg&&(o=!o),l.condition||(i=o)}if(l.condition&&this.toggleControl(t,l.rules,o,n,r,":blank"!==l.op&&s)||l.toggle){a=!0,n&&this.#r(c).filter(t=>!this.#i.has(t)).forEach(e=>{e.addEventListener("change",e=>this.toggleForm(t.form,e)),this.#i.set(e,null)});for(let e in l.toggle??{})this.#e[e]??={elem:t,state:!1},this.#e[e].state||=l.toggle[e]?!!o:!o}}}return a}toggle(t,e,i,n){/^\w[\w.:-]*$/.test(t)&&(t="#"+t),Array.from(document.querySelectorAll(t)).forEach(t=>t.hidden=!e)}compactCheckboxes(t,e){let i={};for(let n of t.elements)n instanceof HTMLInputElement&&"checkbox"===n.type&&n.name.endsWith("[]")&&n.checked&&!n.disabled&&(e.delete(n.name),i[n.name]??=[],i[n.name].push(n.value));for(let t in i)e.set(t.substring(0,t.length-2),i[t].join(","))}initForm(t){"get"===t.method&&t.hasAttribute("data-nette-compact")&&t.addEventListener("formdata",e=>this.compactCheckboxes(t,e.formData)),Array.from(t.elements).some(t=>t.getAttribute("data-nette-rules"))&&(this.toggleForm(t),t.noValidate||(t.noValidate=!0,t.addEventListener("submit",e=>{this.validateForm(e.submitter||t)||(e.stopImmediatePropagation(),e.preventDefault())}),t.addEventListener("reset",()=>{setTimeout(()=>this.toggleForm(t))})))}initOnLoad(){this.#s(()=>{Array.from(document.forms).forEach(t=>this.initForm(t))})}}let i={"á":"a","ä":"a","č":"c","ď":"d","é":"e","ě":"e","í":"i","ľ":"l","ň":"n","ó":"o","ô":"o","ř":"r","š":"s","ť":"t","ú":"u","ů":"u","ý":"y","ž":"z"};function n(t){t=t.toLowerCase();let e="";for(let n=0;n<t.length;n++){let r=i[t.charAt(n)];e+=r||t.charAt(n)}return e.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}var r="3.5.3";let s=new e;return s.version=r,s.webalize=n,s}()),v.exports),y=g(b);function _(t){return"Enter"===t.key}function w(){return null!=w?w:{}}function E(t,e=200){let i=null,n=!1;return(...r)=>{n||(i&&clearTimeout(i),i=setTimeout(()=>{const e=t(...r);var i;"object"==typeof(i=e)&&"function"==typeof i.then&&(n=!0,e.finally(()=>{n=!1}))},e))}}function A(t,e){t.split(/\s+/).forEach(t=>{e(t)})}class S{constructor(){this._events={}}on(t,e){A(t,t=>{const i=this._events[t]||[];i.push(e),this._events[t]=i})}off(t,e){var i=arguments.length;0!==i?A(t,t=>{if(1===i)return void delete this._events[t];const n=this._events[t];void 0!==n&&(n.splice(n.indexOf(e),1),this._events[t]=n)}):this._events={}}trigger(t,...e){var i=this;A(t,t=>{const n=i._events[t];void 0!==n&&n.forEach(t=>{t.apply(i,e)})})}}const k=t=>(t=t.filter(Boolean)).length<2?t[0]||"":1==T(t)?"["+t.join("")+"]":"(?:"+t.join("|")+")",C=t=>{if(!D(t))return t.join("");let e="",i=0;const n=()=>{i>1&&(e+="{"+i+"}")};return t.forEach((r,s)=>{r!==t[s-1]?(n(),e+=r,i=1):i++}),n(),e},O=t=>{let e=Array.from(t);return k(e)},D=t=>new Set(t).size!==t.length,x=t=>(t+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),T=t=>t.reduce((t,e)=>Math.max(t,L(e)),0),L=t=>Array.from(t).length,I=t=>{if(1===t.length)return[[t]];let e=[];const i=t.substring(1);return I(i).forEach(function(i){let n=i.slice(0);n[0]=t.charAt(0)+n[0],e.push(n),n=i.slice(0),n.unshift(t.charAt(0)),e.push(n)}),e},M=[[0,65535]];let F,N;const j={},P={"/":"⁄∕",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 t in P){let e=P[t]||"";for(let i=0;i<e.length;i++){let n=e.substring(i,i+1);j[n]=t}}const H=new RegExp(Object.keys(j).join("|")+"|[̀-ͯ·ʾʼ]","gu"),q=(t,e="NFKD")=>t.normalize(e),R=t=>Array.from(t).reduce((t,e)=>t+B(e),""),B=t=>(t=q(t).toLowerCase().replace(H,t=>j[t]||""),q(t,"NFC"));const V=t=>{const e={},i=(t,i)=>{const n=e[t]||new Set,r=new RegExp("^"+O(n)+"$","iu");i.match(r)||(n.add(x(i)),e[t]=n)};for(let e of function*(t){for(const[e,i]of t)for(let t=e;t<=i;t++){let e=String.fromCharCode(t),i=R(e);i!=e.toLowerCase()&&(i.length>3||0!=i.length&&(yield{folded:i,composed:e,code_point:t}))}}(t))i(e.folded,e.folded),i(e.folded,e.composed);return e},z=t=>{const e=V(t),i={};let n=[];for(let t in e){let r=e[t];r&&(i[t]=O(r)),t.length>1&&n.push(x(t))}n.sort((t,e)=>e.length-t.length);const r=k(n);return N=new RegExp("^"+r,"u"),i},W=(t,e=1)=>(e=Math.max(e,t.length-1),k(I(t).map(t=>((t,e=1)=>{let i=0;return t=t.map(t=>(F[t]&&(i+=t.length),F[t]||t)),i>=e?C(t):""})(t,e)))),Y=(t,e=!0)=>{let i=t.length>1?1:0;return k(t.map(t=>{let n=[];const r=e?t.length():t.length()-1;for(let e=0;e<r;e++)n.push(W(t.substrs[e]||"",i));return C(n)}))},K=(t,e)=>{for(const i of e){if(i.start!=t.start||i.end!=t.end)continue;if(i.substrs.join("")!==t.substrs.join(""))continue;let e=t.parts;const n=t=>{for(const i of e){if(i.start===t.start&&i.substr===t.substr)return!1;if(1!=t.length&&1!=i.length){if(t.start<i.start&&t.end>i.start)return!0;if(i.start<t.start&&i.end>t.start)return!0}}return!1};if(!(i.parts.filter(n).length>0))return!0}return!1};class U{parts;substrs;start;end;constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(t){t&&(this.parts.push(t),this.substrs.push(t.substr),this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(t,e){let i=new U,n=JSON.parse(JSON.stringify(this.parts)),r=n.pop();for(const t of n)i.add(t);let s=e.substr.substring(0,t-r.start),o=s.length;return i.add({start:r.start,end:r.start+o,length:o,substr:s}),i}}const X=t=>{void 0===F&&(F=z(M)),t=R(t);let e="",i=[new U];for(let n=0;n<t.length;n++){let r=t.substring(n).match(N);const s=t.substring(n,n+1),o=r?r[0]:null;let a=[],l=new Set;for(const t of i){const e=t.last();if(!e||1==e.length||e.end<=n)if(o){const e=o.length;t.add({start:n,end:n+e,length:e,substr:o}),l.add("1")}else t.add({start:n,end:n+1,length:1,substr:s}),l.add("2");else if(o){let i=t.clone(n,e);const r=o.length;i.add({start:n,end:n+r,length:r,substr:o}),a.push(i)}else l.add("3")}if(a.length>0){a=a.sort((t,e)=>t.length()-e.length());for(let t of a)K(t,i)||i.push(t)}else if(n>0&&1==l.size&&!l.has("3")){e+=Y(i,!1);let t=new U;const n=i[0];n&&t.add(n.last()),i=[t]}}return e+=Y(i,!0),e},Q=(t,e)=>{if(t)return t[e]},G=(t,e)=>{if(t){for(var i,n=e.split(".");(i=n.shift())&&(t=t[i]););return t}},J=(t,e,i)=>{var n,r;return t?(t+="",null==e.regex||-1===(r=t.search(e.regex))?0:(n=e.string.length/t.length,0===r&&(n+=.5),n*i)):0},Z=(t,e)=>{var i=t[e];if("function"==typeof i)return i;i&&!Array.isArray(i)&&(t[e]=[i])},tt=(t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},et=(t,e)=>"number"==typeof t&&"number"==typeof e?t>e?1:t<e?-1:0:(t=R(t+"").toLowerCase())>(e=R(e+"").toLowerCase())?1:e>t?-1:0;class it{items;settings;constructor(t,e){this.items=t,this.settings=e||{diacritics:!0}}tokenize(t,e,i){if(!t||!t.length)return[];const n=[],r=t.split(/\s+/);var s;return i&&(s=new RegExp("^("+Object.keys(i).map(x).join("|")+"):(.*)$")),r.forEach(t=>{let i,r=null,o=null;s&&(i=t.match(s))&&(r=i[1],t=i[2]),t.length>0&&(o=this.settings.diacritics?X(t)||null:x(t),o&&e&&(o="\\b"+o)),n.push({string:t,regex:o?new RegExp(o,"iu"):null,field:r})}),n}getScoreFunction(t,e){var i=this.prepareSearch(t,e);return this._getScoreFunction(i)}_getScoreFunction(t){const e=t.tokens,i=e.length;if(!i)return function(){return 0};const n=t.options.fields,r=t.weights,s=n.length,o=t.getAttrFn;if(!s)return function(){return 1};const a=1===s?function(t,e){const i=n[0].field;return J(o(e,i),t,r[i]||1)}:function(t,e){var i=0;if(t.field){const n=o(e,t.field);!t.regex&&n?i+=1/s:i+=J(n,t,1)}else tt(r,(n,r)=>{i+=J(o(e,r),t,n)});return i/s};return 1===i?function(t){return a(e[0],t)}:"and"===t.options.conjunction?function(t){var n,r=0;for(let i of e){if((n=a(i,t))<=0)return 0;r+=n}return r/i}:function(t){var n=0;return tt(e,e=>{n+=a(e,t)}),n/i}}getSortFunction(t,e){var i=this.prepareSearch(t,e);return this._getSortFunction(i)}_getSortFunction(t){var e,i=[];const n=this,r=t.options,s=!t.query&&r.sort_empty?r.sort_empty:r.sort;if("function"==typeof s)return s.bind(this);const o=function(e,i){return"$score"===e?i.score:t.getAttrFn(n.items[i.id],e)};if(s)for(let e of s)(t.query||"$score"!==e.field)&&i.push(e);if(t.query){e=!0;for(let t of i)if("$score"===t.field){e=!1;break}e&&i.unshift({field:"$score",direction:"desc"})}else i=i.filter(t=>"$score"!==t.field);return i.length?function(t,e){var n,r;for(let s of i){if(r=s.field,n=("desc"===s.direction?-1:1)*et(o(r,t),o(r,e)))return n}return 0}:null}prepareSearch(t,e){const i={};var n=Object.assign({},e);if(Z(n,"sort"),Z(n,"sort_empty"),n.fields){Z(n,"fields");const t=[];n.fields.forEach(e=>{"string"==typeof e&&(e={field:e,weight:1}),t.push(e),i[e.field]="weight"in e?e.weight:1}),n.fields=t}return{options:n,query:t.toLowerCase().trim(),tokens:this.tokenize(t,n.respect_word_boundaries,i),total:0,items:[],weights:i,getAttrFn:n.nesting?G:Q}}search(t,e){var i,n,r=this;n=this.prepareSearch(t,e),e=n.options,t=n.query;const s=e.score||r._getScoreFunction(n);t.length?tt(r.items,(t,r)=>{i=s(t),(!1===e.filter||i>0)&&n.items.push({score:i,id:r})}):tt(r.items,(t,e)=>{n.items.push({score:1,id:e})});const o=r._getSortFunction(n);return o&&n.items.sort(o),n.total=n.items.length,"number"==typeof e.limit&&(n.items=n.items.slice(0,e.limit)),n}}const nt=t=>null==t?null:rt(t),rt=t=>"boolean"==typeof t?t?"1":"0":t+"",st=t=>(t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ot=(t,e)=>{var i;return function(n,r){var s=this;i&&(s.loading=Math.max(s.loading-1,0),clearTimeout(i)),i=setTimeout(function(){i=null,s.loadedSearches[n]=!0,t.call(s,n,r)},e)}},at=(t,e,i)=>{var n,r=t.trigger,s={};for(n of(t.trigger=function(){var i=arguments[0];if(-1===e.indexOf(i))return r.apply(t,arguments);s[i]=arguments},i.apply(t,[]),t.trigger=r,e))n in s&&r.apply(t,s[n])},lt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},ct=(t,e,i,n)=>{t.addEventListener(e,i,n)},dt=(t,e)=>!!e&&(!!e[t]&&1===(e.altKey?1:0)+(e.ctrlKey?1:0)+(e.shiftKey?1:0)+(e.metaKey?1:0)),ut=(t,e)=>{const i=t.getAttribute("id");return i||(t.setAttribute("id",e),e)},ht=t=>t.replace(/[\\"']/g,"\\$&"),pt=(t,e)=>{e&&t.append(e)},ft=(t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)},gt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(mt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},mt=t=>"string"==typeof t&&t.indexOf("<")>-1,vt=(t,e)=>{var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!1),t.dispatchEvent(i)},bt=(t,e)=>{Object.assign(t.style,e)},yt=(t,...e)=>{var i=wt(e);(t=Et(t)).map(t=>{i.map(e=>{t.classList.add(e)})})},_t=(t,...e)=>{var i=wt(e);(t=Et(t)).map(t=>{i.map(e=>{t.classList.remove(e)})})},wt=t=>{var e=[];return ft(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Et=t=>(Array.isArray(t)||(t=[t]),t),At=(t,e,i)=>{if(!i||i.contains(t))for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}},St=(t,e=0)=>e>0?t[t.length-1]:t[0],kt=(t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i},Ct=(t,e)=>{ft(e,(e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)})},Ot=(t,e)=>{t.parentNode&&t.parentNode.replaceChild(e,t)},Dt=(t,e)=>{if(null===e)return;if("string"==typeof e){if(!e.length)return;e=new RegExp(e,"i")}const i=t=>3===t.nodeType?(t=>{var i=t.data.match(e);if(i&&t.data.length>0){var n=document.createElement("span");n.className="highlight";var r=t.splitText(i.index);r.splitText(i[0].length);var s=r.cloneNode(!0);return n.appendChild(s),Ot(r,n),1}return 0})(t):((t=>{1!==t.nodeType||!t.childNodes||/(script|style)/i.test(t.tagName)||"highlight"===t.className&&"SPAN"===t.tagName||Array.from(t.childNodes).forEach(t=>{i(t)})})(t),0);i(t)},xt="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey";var Tt={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:'<input type="text" autocomplete="off" size="1" />',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(t){return t.length>0},render:{}};function Lt(t,e){var i=Object.assign({},Tt,e),n=i.dataAttr,r=i.labelField,s=i.valueField,o=i.disabledField,a=i.optgroupField,l=i.optgroupLabelField,c=i.optgroupValueField,d=t.tagName.toLowerCase(),u=t.getAttribute("placeholder")||t.getAttribute("data-placeholder");if(!u&&!i.allowEmptyOption){let e=t.querySelector('option[value=""]');e&&(u=e.textContent)}var h={placeholder:u,options:[],optgroups:[],items:[],maxItems:null};return"select"===d?(()=>{var e,d=h.options,u={},p=1;let f=0;var g=t=>{var e=Object.assign({},t.dataset),i=n&&e[n];return"string"==typeof i&&i.length&&(e=Object.assign(e,JSON.parse(i))),e},m=(t,e)=>{var n=nt(t.value);if(null!=n&&(n||i.allowEmptyOption)){if(u.hasOwnProperty(n)){if(e){var l=u[n][a];l?Array.isArray(l)?l.push(e):u[n][a]=[l,e]:u[n][a]=e}}else{var c=g(t);c[r]=c[r]||t.textContent,c[s]=c[s]||n,c[o]=c[o]||t.disabled,c[a]=c[a]||e,c.$option=t,c.$order=c.$order||++f,u[n]=c,d.push(c)}t.selected&&h.items.push(n)}};h.maxItems=t.hasAttribute("multiple")?null:1,ft(t.children,t=>{var i,n,r;"optgroup"===(e=t.tagName.toLowerCase())?((r=g(i=t))[l]=r[l]||i.getAttribute("label")||"",r[c]=r[c]||p++,r[o]=r[o]||i.disabled,r.$order=r.$order||++f,h.optgroups.push(r),n=r[c],ft(i.children,t=>{m(t,n)})):"option"===e&&m(t)})})():(()=>{const e=t.getAttribute(n);if(e)h.options=JSON.parse(e),ft(h.options,t=>{h.items.push(t[s])});else{var o=t.value.trim()||"";if(!i.allowEmptyOption&&!o.length)return;const e=o.split(i.delimiter);ft(e,t=>{const e={};e[r]=t,e[s]=t,h.options.push(e)}),h.items=e}})(),Object.assign({},Tt,h,e)}var It=0;let Mt=class extends(function(t){return t.plugins={},class extends t{constructor(){super(...arguments),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(e,i){t.plugins[e]={name:e,fn:i}}initializePlugins(t){var e,i;const n=this,r=[];if(Array.isArray(t))t.forEach(t=>{"string"==typeof t?r.push(t):(n.plugins.settings[t.name]=t.options,r.push(t.name))});else if(t)for(e in t)t.hasOwnProperty(e)&&(n.plugins.settings[e]=t[e],r.push(e));for(;i=r.shift();)n.require(i)}loadPlugin(e){var i=this,n=i.plugins,r=t.plugins[e];if(!t.plugins.hasOwnProperty(e))throw new Error('Unable to find "'+e+'" plugin');n.requested[e]=!0,n.loaded[e]=r.fn.apply(i,[i.plugins.settings[e]||{}]),n.names.push(e)}require(t){var e=this,i=e.plugins;if(!e.plugins.loaded.hasOwnProperty(t)){if(i.requested[t])throw new Error('Plugin has circular dependency ("'+t+'")');e.loadPlugin(t)}return i.loaded[t]}}}(S)){constructor(t,e){var i;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,It++;var n=gt(t);if(n.tomselect)throw new Error("Tom Select already initialized on this element");n.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(n,null)).getPropertyValue("direction");const r=Lt(n,e);this.settings=r,this.input=n,this.tabIndex=n.tabIndex||0,this.is_select_tag="select"===n.tagName.toLowerCase(),this.rtl=/rtl/i.test(i),this.inputId=ut(n,"tomselect-"+It),this.isRequired=n.required,this.sifter=new it(this.options,{diacritics:r.diacritics}),r.mode=r.mode||(1===r.maxItems?"single":"multi"),"boolean"!=typeof r.hideSelected&&(r.hideSelected="multi"===r.mode),"boolean"!=typeof r.hidePlaceholder&&(r.hidePlaceholder="multi"!==r.mode);var s=r.createFilter;"function"!=typeof s&&("string"==typeof s&&(s=new RegExp(s)),s instanceof RegExp?r.createFilter=t=>s.test(t):r.createFilter=t=>this.settings.duplicates||!this.options[t]),this.initializePlugins(r.plugins),this.setupCallbacks(),this.setupTemplates();const o=gt("<div>"),a=gt("<div>"),l=this._render("dropdown"),c=gt('<div role="listbox" tabindex="-1">'),d=this.input.getAttribute("class")||"",u=r.mode;var h;if(yt(o,r.wrapperClass,d,u),yt(a,r.controlClass),pt(o,a),yt(l,r.dropdownClass,u),r.copyClassesToDropdown&&yt(l,d),yt(c,r.dropdownContentClass),pt(l,c),gt(r.dropdownParent||o).appendChild(l),mt(r.controlInput)){h=gt(r.controlInput);ft(["autocorrect","autocapitalize","autocomplete","spellcheck"],t=>{n.getAttribute(t)&&Ct(h,{[t]:n.getAttribute(t)})}),h.tabIndex=-1,a.appendChild(h),this.focus_node=h}else r.controlInput?(h=gt(r.controlInput),this.focus_node=h):(h=gt("<input/>"),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 t=this,e=t.settings,i=t.control_input,n=t.dropdown,r=t.dropdown_content,s=t.wrapper,o=t.control,a=t.input,l=t.focus_node,c={passive:!0},d=t.inputId+"-ts-dropdown";Ct(r,{id:d}),Ct(l,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d});const u=ut(l,t.inputId+"-ts-control"),h="label[for='"+(t=>t.replace(/['"\\]/g,"\\$&"))(t.inputId)+"']",p=document.querySelector(h),f=t.focus.bind(t);if(p){ct(p,"click",f),Ct(p,{for:u});const e=ut(p,t.inputId+"-ts-label");Ct(l,{"aria-labelledby":e}),Ct(r,{"aria-labelledby":e})}if(s.style.width=a.style.width,t.plugins.names.length){const e="plugin-"+t.plugins.names.join(" plugin-");yt([s,n],e)}(null===e.maxItems||e.maxItems>1)&&t.is_select_tag&&Ct(a,{multiple:"multiple"}),e.placeholder&&Ct(i,{placeholder:e.placeholder}),!e.splitOn&&e.delimiter&&(e.splitOn=new RegExp("\\s*"+x(e.delimiter)+"+\\s*")),e.load&&e.loadThrottle&&(e.load=ot(e.load,e.loadThrottle)),ct(n,"mousemove",()=>{t.ignoreHover=!1}),ct(n,"mouseenter",e=>{var i=At(e.target,"[data-selectable]",n);i&&t.onOptionHover(e,i)},{capture:!0}),ct(n,"click",e=>{const i=At(e.target,"[data-selectable]");i&&(t.onOptionSelect(e,i),lt(e,!0))}),ct(o,"click",e=>{var n=At(e.target,"[data-ts-item]",o);n&&t.onItemSelect(e,n)?lt(e,!0):""==i.value&&(t.onClick(),lt(e,!0))}),ct(l,"keydown",e=>t.onKeyDown(e)),ct(i,"keypress",e=>t.onKeyPress(e)),ct(i,"input",e=>t.onInput(e)),ct(l,"blur",e=>t.onBlur(e)),ct(l,"focus",e=>t.onFocus(e)),ct(i,"paste",e=>t.onPaste(e));const g=e=>{const r=e.composedPath()[0];if(!s.contains(r)&&!n.contains(r))return t.isFocused&&t.blur(),void t.inputState();r==i&&t.isOpen?e.stopPropagation():lt(e,!0)},m=()=>{t.isOpen&&t.positionDropdown()};ct(document,"mousedown",g),ct(window,"scroll",m,c),ct(window,"resize",m,c),this._destroy=()=>{document.removeEventListener("mousedown",g),window.removeEventListener("scroll",m),window.removeEventListener("resize",m),p&&p.removeEventListener("click",f)},this.revertSettings={innerHTML:a.innerHTML,tabIndex:a.tabIndex},a.tabIndex=-1,a.insertAdjacentElement("afterend",t.wrapper),t.sync(!1),e.items=[],delete e.optgroups,delete e.options,ct(a,"invalid",()=>{t.isValid&&(t.isValid=!1,t.isInvalid=!0,t.refreshState())}),t.updateOriginalInput(),t.refreshItems(),t.close(!1),t.inputState(),t.isSetup=!0,a.disabled?t.disable():a.readOnly?t.setReadOnly(!0):t.enable(),t.on("change",this.onChange),yt(a,"tomselected","ts-hidden-accessible"),t.trigger("initialize"),!0===e.preload&&t.preload()}setupOptions(t=[],e=[]){this.addOptions(t),ft(e,t=>{this.registerOptionGroup(t)})}setupTemplates(){var t=this,e=t.settings.labelField,i=t.settings.optgroupLabelField,n={optgroup:t=>{let e=document.createElement("div");return e.className="optgroup",e.appendChild(t.options),e},optgroup_header:(t,e)=>'<div class="optgroup-header">'+e(t[i])+"</div>",option:(t,i)=>"<div>"+i(t[e])+"</div>",item:(t,i)=>"<div>"+i(t[e])+"</div>",option_create:(t,e)=>'<div class="create">Add <strong>'+e(t.input)+"</strong>&hellip;</div>",no_results:()=>'<div class="no-results">No results found</div>',loading:()=>'<div class="spinner"></div>',not_loading:()=>{},dropdown:()=>"<div></div>"};t.settings.render=Object.assign({},n,t.settings.render)}setupCallbacks(){var t,e,i={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(t in i)(e=this.settings[i[t]])&&this.on(t,e)}sync(t=!0){const e=this,i=t?Lt(e.input,{delimiter:e.settings.delimiter}):e.settings;e.setupOptions(i.options,i.optgroups),e.setValue(i.items||[],!0),e.lastQuery=null}onClick(){var t=this;if(t.activeItems.length>0)return t.clearActiveItems(),void t.focus();t.isFocused&&t.isOpen?t.blur():t.focus()}onMouseDown(){}onChange(){vt(this.input,"input"),vt(this.input,"change")}onPaste(t){var e=this;e.isInputHidden||e.isLocked?lt(t):e.settings.splitOn&&setTimeout(()=>{var t=e.inputValue();if(t.match(e.settings.splitOn)){var i=t.trim().split(e.settings.splitOn);ft(i,t=>{nt(t)&&(this.options[t]?e.addItem(t):e.createItem(t))})}},0)}onKeyPress(t){var e=this;if(!e.isLocked){var i=String.fromCharCode(t.keyCode||t.which);return e.settings.create&&"multi"===e.settings.mode&&i===e.settings.delimiter?(e.createItem(),void lt(t)):void 0}lt(t)}onKeyDown(t){var e=this;if(e.ignoreHover=!0,e.isLocked)9!==t.keyCode&&lt(t);else{switch(t.keyCode){case 65:if(dt(xt,t)&&""==e.control_input.value)return lt(t),void e.selectAll();break;case 27:return e.isOpen&&(lt(t,!0),e.close()),void e.clearActiveItems();case 40:if(!e.isOpen&&e.hasOptions)e.open();else if(e.activeOption){let t=e.getAdjacent(e.activeOption,1);t&&e.setActiveOption(t)}return void lt(t);case 38:if(e.activeOption){let t=e.getAdjacent(e.activeOption,-1);t&&e.setActiveOption(t)}return void lt(t);case 13:return void(e.canSelect(e.activeOption)?(e.onOptionSelect(t,e.activeOption),lt(t)):(e.settings.create&&e.createItem()||document.activeElement==e.control_input&&e.isOpen)&&lt(t));case 37:return void e.advanceSelection(-1,t);case 39:return void e.advanceSelection(1,t);case 9:return void(e.settings.selectOnTab&&(e.canSelect(e.activeOption)&&(e.onOptionSelect(t,e.activeOption),lt(t)),e.settings.create&&e.createItem()&&lt(t)));case 8:case 46:return void e.deleteSelection(t)}e.isInputHidden&&!dt(xt,t)&&lt(t)}}onInput(t){if(this.isLocked)return;const e=this.inputValue();this.lastValue!==e&&(this.lastValue=e,""!=e?(this.refreshTimeout&&window.clearTimeout(this.refreshTimeout),this.refreshTimeout=((t,e)=>e>0?window.setTimeout(t,e):(t.call(null),null))(()=>{this.refreshTimeout=null,this._onInput()},this.settings.refreshThrottle)):this._onInput())}_onInput(){const t=this.lastValue;this.settings.shouldLoad.call(this,t)&&this.load(t),this.refreshOptions(),this.trigger("type",t)}onOptionHover(t,e){this.ignoreHover||this.setActiveOption(e,!1)}onFocus(t){var e=this,i=e.isFocused;if(e.isDisabled||e.isReadOnly)return e.blur(),void lt(t);e.ignoreFocus||(e.isFocused=!0,"focus"===e.settings.preload&&e.preload(),i||e.trigger("focus"),e.activeItems.length||(e.inputState(),e.refreshOptions(!!e.settings.openOnFocus)),e.refreshState())}onBlur(t){if(!1!==document.hasFocus()){var e=this;if(e.isFocused){e.isFocused=!1,e.ignoreFocus=!1;var i=()=>{e.close(),e.setActiveItem(),e.setCaret(e.items.length),e.trigger("blur")};e.settings.create&&e.settings.createOnBlur?e.createItem(null,i):i()}}}onOptionSelect(t,e){var i,n=this;e.parentElement&&e.parentElement.matches("[data-disabled]")||(e.classList.contains("create")?n.createItem(null,()=>{n.settings.closeAfterSelect&&n.close()}):void 0!==(i=e.dataset.value)&&(n.lastQuery=null,n.addItem(i),n.settings.closeAfterSelect&&n.close(),!n.settings.hideSelected&&t.type&&/click/.test(t.type)&&n.setActiveOption(e)))}canSelect(t){return!!(this.isOpen&&t&&this.dropdown_content.contains(t))}onItemSelect(t,e){var i=this;return!i.isLocked&&"multi"===i.settings.mode&&(lt(t),i.setActiveItem(e,t),!0)}canLoad(t){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(t)}load(t){const e=this;if(!e.canLoad(t))return;yt(e.wrapper,e.settings.loadingClass),e.loading++;const i=e.loadCallback.bind(e);e.settings.load.call(e,t,i)}loadCallback(t,e){const i=this;i.loading=Math.max(i.loading-1,0),i.lastQuery=null,i.clearActiveOption(),i.setupOptions(t,e),i.refreshOptions(i.isFocused&&!i.isInputHidden),i.loading||_t(i.wrapper,i.settings.loadingClass),i.trigger("load",t,e)}preload(){var t=this.wrapper.classList;t.contains("preloaded")||(t.add("preloaded"),this.load(""))}setTextboxValue(t=""){var e=this.control_input;e.value!==t&&(e.value=t,vt(e,"update"),this.lastValue=t)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(t,e){at(this,e?[]:["change"],()=>{this.clear(e),this.addItems(t,e)})}setMaxItems(t){0===t&&(t=null),this.settings.maxItems=t,this.refreshState()}setActiveItem(t,e){var i,n,r,s,o,a,l=this;if("single"!==l.settings.mode){if(!t)return l.clearActiveItems(),void(l.isFocused&&l.inputState());if("click"===(i=e&&e.type.toLowerCase())&&dt("shiftKey",e)&&l.activeItems.length){for(a=l.getLastActive(),(r=Array.prototype.indexOf.call(l.control.children,a))>(s=Array.prototype.indexOf.call(l.control.children,t))&&(o=r,r=s,s=o),n=r;n<=s;n++)t=l.control.children[n],-1===l.activeItems.indexOf(t)&&l.setActiveItemClass(t);lt(e)}else"click"===i&&dt(xt,e)||"keydown"===i&&dt("shiftKey",e)?t.classList.contains("active")?l.removeActiveItem(t):l.setActiveItemClass(t):(l.clearActiveItems(),l.setActiveItemClass(t));l.inputState(),l.isFocused||l.focus()}}setActiveItemClass(t){const e=this,i=e.control.querySelector(".last-active");i&&_t(i,"last-active"),yt(t,"active last-active"),e.trigger("item_select",t),-1==e.activeItems.indexOf(t)&&e.activeItems.push(t)}removeActiveItem(t){var e=this.activeItems.indexOf(t);this.activeItems.splice(e,1),_t(t,"active")}clearActiveItems(){_t(this.activeItems,"active"),this.activeItems=[]}setActiveOption(t,e=!0){t!==this.activeOption&&(this.clearActiveOption(),t&&(this.activeOption=t,Ct(this.focus_node,{"aria-activedescendant":t.getAttribute("id")}),Ct(t,{"aria-selected":"true"}),yt(t,"active"),e&&this.scrollToOption(t)))}scrollToOption(t,e){if(!t)return;const i=this.dropdown_content,n=i.clientHeight,r=i.scrollTop||0,s=t.offsetHeight,o=t.getBoundingClientRect().top-i.getBoundingClientRect().top+r;o+s>n+r?this.scroll(o-n+s,e):o<r&&this.scroll(o,e)}scroll(t,e){const i=this.dropdown_content;e&&(i.style.scrollBehavior=e),i.scrollTop=t,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(_t(this.activeOption,"active"),Ct(this.activeOption,{"aria-selected":null})),this.activeOption=null,Ct(this.focus_node,{"aria-activedescendant":null})}selectAll(){const t=this;if("single"===t.settings.mode)return;const e=t.controlChildren();e.length&&(t.inputState(),t.close(),t.activeItems=e,ft(e,e=>{t.setActiveItemClass(e)}))}inputState(){var t=this;t.control.contains(t.control_input)&&(Ct(t.control_input,{placeholder:t.settings.placeholder}),t.activeItems.length>0||!t.isFocused&&t.settings.hidePlaceholder&&t.items.length>0?(t.setTextboxValue(),t.isInputHidden=!0):(t.settings.hidePlaceholder&&t.items.length>0&&Ct(t.control_input,{placeholder:""}),t.isInputHidden=!1),t.wrapper.classList.toggle("input-hidden",t.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var t=this;t.isDisabled||t.isReadOnly||(t.ignoreFocus=!0,t.control_input.offsetWidth?t.control_input.focus():t.focus_node.focus(),setTimeout(()=>{t.ignoreFocus=!1,t.onFocus()},0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(t){return this.sifter.getScoreFunction(t,this.getSearchOptions())}getSearchOptions(){var t=this.settings,e=t.sortField;return"string"==typeof t.sortField&&(e=[{field:t.sortField}]),{fields:t.searchField,conjunction:t.searchConjunction,sort:e,nesting:t.nesting}}search(t){var e,i,n=this,r=this.getSearchOptions();if(n.settings.score&&"function"!=typeof(i=n.settings.score.call(n,t)))throw new Error('Tom Select "score" setting must be a function that returns a function');return t!==n.lastQuery?(n.lastQuery=t,e=n.sifter.search(t,Object.assign(r,{score:i})),n.currentResults=e):e=Object.assign({},n.currentResults),n.settings.hideSelected&&(e.items=e.items.filter(t=>{let e=nt(t.id);return!(e&&-1!==n.items.indexOf(e))})),e}refreshOptions(t=!0){var e,i,n,r,s,o,a,l,c,d;const u={},h=[];var p=this,f=p.inputValue();const g=f===p.lastQuery||""==f&&null==p.lastQuery;var m=p.search(f),v=null,b=p.settings.shouldOpen||!1,y=p.dropdown_content;g&&(v=p.activeOption)&&(c=v.closest("[data-group]")),r=m.items.length,"number"==typeof p.settings.maxOptions&&(r=Math.min(r,p.settings.maxOptions)),r>0&&(b=!0);const _=(t,e)=>{let i=u[t];if(void 0!==i){let t=h[i];if(void 0!==t)return[i,t.fragment]}let n=document.createDocumentFragment();return i=h.length,h.push({fragment:n,order:e,optgroup:t}),[i,n]};for(e=0;e<r;e++){let t=m.items[e];if(!t)continue;let r=t.id,a=p.options[r];if(void 0===a)continue;let l=rt(r),d=p.getOption(l,!0);for(p.settings.hideSelected||d.classList.toggle("selected",p.items.includes(l)),s=a[p.settings.optgroupField]||"",i=0,n=(o=Array.isArray(s)?s:[s])&&o.length;i<n;i++){s=o[i];let t=a.$order,e=p.optgroups[s];void 0===e?s="":t=e.$order;const[n,l]=_(s,t);i>0&&(d=d.cloneNode(!0),Ct(d,{id:a.$id+"-clone-"+i,"aria-selected":null}),d.classList.add("ts-cloned"),_t(d,"active"),p.activeOption&&p.activeOption.dataset.value==r&&c&&c.dataset.group===s.toString()&&(v=d)),l.appendChild(d),""!=s&&(u[s]=n)}}var w;p.settings.lockOptgroupOrder&&h.sort((t,e)=>t.order-e.order),a=document.createDocumentFragment(),ft(h,t=>{let e=t.fragment,i=t.optgroup;if(!e||!e.children.length)return;let n=p.optgroups[i];if(void 0!==n){let t=document.createDocumentFragment(),i=p.render("optgroup_header",n);pt(t,i),pt(t,e);let r=p.render("optgroup",{group:n,options:t});pt(a,r)}else pt(a,e)}),y.innerHTML="",pt(y,a),p.settings.highlight&&(w=y.querySelectorAll("span.highlight"),Array.prototype.forEach.call(w,function(t){var e=t.parentNode;e.replaceChild(t.firstChild,t),e.normalize()}),m.query.length&&m.tokens.length&&ft(m.tokens,t=>{Dt(y,t.regex)}));var E=t=>{let e=p.render(t,{input:f});return e&&(b=!0,y.insertBefore(e,y.firstChild)),e};if(p.loading?E("loading"):p.settings.shouldLoad.call(p,f)?0===m.items.length&&E("no_results"):E("not_loading"),(l=p.canCreate(f))&&(d=E("option_create")),p.hasOptions=m.items.length>0||l,b){if(m.items.length>0){if(v||"single"!==p.settings.mode||null==p.items[0]||(v=p.getOption(p.items[0])),!y.contains(v)){let t=0;d&&!p.settings.addPrecedence&&(t=1),v=p.selectable()[t]}}else d&&(v=d);t&&!p.isOpen&&(p.open(),p.scrollToOption(v,"auto")),p.setActiveOption(v)}else p.clearActiveOption(),t&&p.isOpen&&p.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(t,e=!1){const i=this;if(Array.isArray(t))return i.addOptions(t,e),!1;const n=nt(t[i.settings.valueField]);return null!==n&&!i.options.hasOwnProperty(n)&&(t.$order=t.$order||++i.order,t.$id=i.inputId+"-opt-"+t.$order,i.options[n]=t,i.lastQuery=null,e&&(i.userOptions[n]=e,i.trigger("option_add",n,t)),n)}addOptions(t,e=!1){ft(t,t=>{this.addOption(t,e)})}registerOption(t){return this.addOption(t)}registerOptionGroup(t){var e=nt(t[this.settings.optgroupValueField]);return null!==e&&(t.$order=t.$order||++this.order,this.optgroups[e]=t,e)}addOptionGroup(t,e){var i;e[this.settings.optgroupValueField]=t,(i=this.registerOptionGroup(e))&&this.trigger("optgroup_add",i,e)}removeOptionGroup(t){this.optgroups.hasOwnProperty(t)&&(delete this.optgroups[t],this.clearCache(),this.trigger("optgroup_remove",t))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(t,e){const i=this;var n,r;const s=nt(t),o=nt(e[i.settings.valueField]);if(null===s)return;const a=i.options[s];if(null==a)return;if("string"!=typeof o)throw new Error("Value must be set in option data");const l=i.getOption(s),c=i.getItem(s);if(e.$order=e.$order||a.$order,delete i.options[s],i.uncacheValue(o),i.options[o]=e,l){if(i.dropdown_content.contains(l)){const t=i._render("option",e);Ot(l,t),i.activeOption===l&&i.setActiveOption(t)}l.remove()}c&&(-1!==(r=i.items.indexOf(s))&&i.items.splice(r,1,o),n=i._render("item",e),c.classList.contains("active")&&yt(n,"active"),Ot(c,n)),i.lastQuery=null}removeOption(t,e){const i=this;t=rt(t),i.uncacheValue(t),delete i.userOptions[t],delete i.options[t],i.lastQuery=null,i.trigger("option_remove",t),i.removeItem(t,e)}clearOptions(t){const e=(t||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const i={};ft(this.options,(t,n)=>{e(t,n)&&(i[n]=t)}),this.options=this.sifter.items=i,this.lastQuery=null,this.trigger("option_clear")}clearFilter(t,e){return this.items.indexOf(e)>=0}getOption(t,e=!1){const i=nt(t);if(null===i)return null;const n=this.options[i];if(null!=n){if(n.$div)return n.$div;if(e)return this._render("option",n)}return null}getAdjacent(t,e,i="option"){var n;if(!t)return null;n="item"==i?this.controlChildren():this.dropdown_content.querySelectorAll("[data-selectable]");for(let i=0;i<n.length;i++)if(n[i]==t)return e>0?n[i+1]:n[i-1];return null}getItem(t){if("object"==typeof t)return t;var e=nt(t);return null!==e?this.control.querySelector(`[data-value="${ht(e)}"]`):null}addItems(t,e){var i=this,n=Array.isArray(t)?t:[t];const r=(n=n.filter(t=>-1===i.items.indexOf(t)))[n.length-1];n.forEach(t=>{i.isPending=t!==r,i.addItem(t,e)})}addItem(t,e){at(this,e?[]:["change","dropdown_close"],()=>{var i,n;const r=this,s=r.settings.mode,o=nt(t);if((!o||-1===r.items.indexOf(o)||("single"===s&&r.close(),"single"!==s&&r.settings.duplicates))&&null!==o&&r.options.hasOwnProperty(o)&&("single"===s&&r.clear(e),"multi"!==s||!r.isFull())){if(i=r._render("item",r.options[o]),r.control.contains(i)&&(i=i.cloneNode(!0)),n=r.isFull(),r.items.splice(r.caretPos,0,o),r.insertAtCaret(i),r.isSetup){if(!r.isPending&&r.settings.hideSelected){let t=r.getOption(o),e=r.getAdjacent(t,1);e&&r.setActiveOption(e)}r.isPending||r.settings.closeAfterSelect||r.refreshOptions(r.isFocused&&"single"!==s),0!=r.settings.closeAfterSelect&&r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",o,i),r.isPending||r.updateOriginalInput({silent:e})}(!r.isPending||!n&&r.isFull())&&(r.inputState(),r.refreshState())}})}removeItem(t=null,e){const i=this;if(!(t=i.getItem(t)))return;var n,r;const s=t.dataset.value;n=kt(t),t.remove(),t.classList.contains("active")&&(r=i.activeItems.indexOf(t),i.activeItems.splice(r,1),_t(t,"active")),i.items.splice(n,1),i.lastQuery=null,!i.settings.persist&&i.userOptions.hasOwnProperty(s)&&i.removeOption(s,e),n<i.caretPos&&i.setCaret(i.caretPos-1),i.updateOriginalInput({silent:e}),i.refreshState(),i.positionDropdown(),i.trigger("item_remove",s,t)}createItem(t=null,e=()=>{}){3===arguments.length&&(e=arguments[2]),"function"!=typeof e&&(e=()=>{});var i,n=this,r=n.caretPos;if(t=t||n.inputValue(),!n.canCreate(t))return e(),!1;n.lock();var s=!1,o=t=>{if(n.unlock(),!t||"object"!=typeof t)return e();var i=nt(t[n.settings.valueField]);if("string"!=typeof i)return e();n.setTextboxValue(),n.addOption(t,!0),n.setCaret(r),n.addItem(i),e(t),s=!0};return i="function"==typeof n.settings.create?n.settings.create.call(this,t,o):{[n.settings.labelField]:t,[n.settings.valueField]:t},s||o(i),!0}refreshItems(){var t=this;t.lastQuery=null,t.isSetup&&t.addItems(t.items),t.updateOriginalInput(),t.refreshState()}refreshState(){const t=this;t.refreshValidityState();const e=t.isFull(),i=t.isLocked;t.wrapper.classList.toggle("rtl",t.rtl);const n=t.wrapper.classList;var r;n.toggle("focus",t.isFocused),n.toggle("disabled",t.isDisabled),n.toggle("readonly",t.isReadOnly),n.toggle("required",t.isRequired),n.toggle("invalid",!t.isValid),n.toggle("locked",i),n.toggle("full",e),n.toggle("input-active",t.isFocused&&!t.isInputHidden),n.toggle("dropdown-active",t.isOpen),n.toggle("has-options",(r=t.options,0===Object.keys(r).length)),n.toggle("has-items",t.items.length>0)}refreshValidityState(){var t=this;t.input.validity&&(t.isValid=t.input.validity.valid,t.isInvalid=!t.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(t={}){const e=this;var i,n;const r=e.input.querySelector('option[value=""]');if(e.is_select_tag){const s=[],o=e.input.querySelectorAll("option:checked").length;function a(t,i,n){return t||(t=gt('<option value="'+st(i)+'">'+st(n)+"</option>")),t!=r&&e.input.append(t),s.push(t),(t!=r||o>0)&&(t.selected=!0),t}e.input.querySelectorAll("option:checked").forEach(t=>{t.selected=!1}),0==e.items.length&&"single"==e.settings.mode?a(r,"",""):e.items.forEach(t=>{if(i=e.options[t],n=i[e.settings.labelField]||"",s.includes(i.$option)){a(e.input.querySelector(`option[value="${ht(t)}"]:not(:checked)`),t,n)}else i.$option=a(i.$option,t,n)})}else e.input.value=e.getValue();e.isSetup&&(t.silent||e.trigger("change",e.getValue()))}open(){var t=this;t.isLocked||t.isOpen||"multi"===t.settings.mode&&t.isFull()||(t.isOpen=!0,Ct(t.focus_node,{"aria-expanded":"true"}),t.refreshState(),bt(t.dropdown,{visibility:"hidden",display:"block"}),t.positionDropdown(),bt(t.dropdown,{visibility:"visible",display:"block"}),t.focus(),t.trigger("dropdown_open",t.dropdown))}close(t=!0){var e=this,i=e.isOpen;t&&(e.setTextboxValue(),"single"===e.settings.mode&&e.items.length&&e.inputState()),e.isOpen=!1,Ct(e.focus_node,{"aria-expanded":"false"}),bt(e.dropdown,{display:"none"}),e.settings.hideSelected&&e.clearActiveOption(),e.refreshState(),i&&e.trigger("dropdown_close",e.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var t=this.control,e=t.getBoundingClientRect(),i=t.offsetHeight+e.top+window.scrollY,n=e.left+window.scrollX;bt(this.dropdown,{width:e.width+"px",top:i+"px",left:n+"px"})}}clear(t){var e=this;if(e.items.length){var i=e.controlChildren();ft(i,t=>{e.removeItem(t,!0)}),e.inputState(),t||e.updateOriginalInput(),e.trigger("clear")}}insertAtCaret(t){const e=this,i=e.caretPos,n=e.control;n.insertBefore(t,n.children[i]||null),e.setCaret(i+1)}deleteSelection(t){var e,i,n,r,s,o=this;e=t&&8===t.keyCode?-1:1,i={start:(s=o.control_input).selectionStart||0,length:(s.selectionEnd||0)-(s.selectionStart||0)};const a=[];if(o.activeItems.length)r=St(o.activeItems,e),n=kt(r),e>0&&n++,ft(o.activeItems,t=>a.push(t));else if((o.isFocused||"single"===o.settings.mode)&&o.items.length){const t=o.controlChildren();let n;e<0&&0===i.start&&0===i.length?n=t[o.caretPos-1]:e>0&&i.start===o.inputValue().length&&(n=t[o.caretPos]),void 0!==n&&a.push(n)}if(!o.shouldDelete(a,t))return!1;for(lt(t,!0),void 0!==n&&o.setCaret(n);a.length;)o.removeItem(a.pop());return o.inputState(),o.positionDropdown(),o.refreshOptions(!1),!0}shouldDelete(t,e){const i=t.map(t=>t.dataset.value);return!(!i.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(i,e))}advanceSelection(t,e){var i,n,r=this;r.rtl&&(t*=-1),r.inputValue().length||(dt(xt,e)||dt("shiftKey",e)?(n=(i=r.getLastActive(t))?i.classList.contains("active")?r.getAdjacent(i,t,"item"):i:t>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(n.classList.contains("active")&&r.removeActiveItem(i),r.setActiveItemClass(n)):r.moveCaret(t))}moveCaret(t){}getLastActive(t){let e=this.control.querySelector(".last-active");if(e)return e;var i=this.control.querySelectorAll(".active");return i?St(i,t):void 0}setCaret(t){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(t=this.isReadOnly||this.isDisabled){this.isLocked=t,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(t){this.focus_node.tabIndex=t?-1:this.tabIndex,this.isDisabled=t,this.input.disabled=t,this.control_input.disabled=t,this.setLocked()}setReadOnly(t){this.isReadOnly=t,this.input.readOnly=t,this.control_input.readOnly=t,this.setLocked()}destroy(){var t=this,e=t.revertSettings;t.trigger("destroy"),t.off(),t.wrapper.remove(),t.dropdown.remove(),t.input.innerHTML=e.innerHTML,t.input.tabIndex=e.tabIndex,_t(t.input,"tomselected","ts-hidden-accessible"),t._destroy(),delete t.input.tomselect}render(t,e){var i,n;const r=this;if("function"!=typeof this.settings.render[t])return null;if(!(n=r.settings.render[t].call(this,e,st)))return null;if(n=gt(n),"option"===t||"option_create"===t?e[r.settings.disabledField]?Ct(n,{"aria-disabled":"true"}):Ct(n,{"data-selectable":""}):"optgroup"===t&&(i=e.group[r.settings.optgroupValueField],Ct(n,{"data-group":i}),e.group[r.settings.disabledField]&&Ct(n,{"data-disabled":""})),"option"===t||"item"===t){const i=rt(e[r.settings.valueField]);Ct(n,{"data-value":i}),"item"===t?(yt(n,r.settings.itemClass),Ct(n,{"data-ts-item":""})):(yt(n,r.settings.optionClass),Ct(n,{role:"option",id:e.$id}),e.$div=n,r.options[i]=e)}return n}_render(t,e){const i=this.render(t,e);if(null==i)throw"HTMLElement expected";return i}clearCache(){ft(this.options,t=>{t.$div&&(t.$div.remove(),delete t.$div)})}uncacheValue(t){const e=this.getOption(t);e&&e.remove()}canCreate(t){return this.settings.create&&t.length>0&&this.settings.createFilter.call(this,t)}hook(t,e,i){var n=this,r=n[e];n[e]=function(){var e,s;return"after"===t&&(e=r.apply(n,arguments)),s=i.apply(n,arguments),"instead"===t?s:("before"===t&&(e=r.apply(n,arguments)),e)}}};const Ft=t=>"boolean"==typeof t?t?"1":"0":t+"",Nt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},jt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Pt=t=>"string"==typeof t&&t.indexOf("<")>-1;const $t=(t,e,i,n)=>{t.addEventListener(e,i,n)},Ht=t=>"string"==typeof t&&t.indexOf("<")>-1,qt=(t,e)=>{((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(e,(e,i)=>{null==e?t.removeAttribute(i):t.setAttribute(i,""+e)})};const Rt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Bt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Vt=t=>(Array.isArray(t)||(t=[t]),t);const zt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Wt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},Wt=t=>"string"==typeof t&&t.indexOf("<")>-1,Yt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},Kt=t=>(Array.isArray(t)||(t=[t]),t);const Ut=(t,e,i,n)=>{t.addEventListener(e,i,n)};const Xt=(t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())},Qt=(t,e,i,n)=>{t.addEventListener(e,i,n)},Gt=t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Jt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)},Jt=t=>"string"==typeof t&&t.indexOf("<")>-1;const Zt=t=>{var e=[];return((t,e)=>{if(Array.isArray(t))t.forEach(e);else for(var i in t)t.hasOwnProperty(i)&&e(t[i],i)})(t,t=>{"string"==typeof t&&(t=t.trim().split(/[\t\n\f\r\s]/)),Array.isArray(t)&&(e=e.concat(t))}),e.filter(Boolean)},te=t=>(Array.isArray(t)||(t=[t]),t);Mt.define("change_listener",function(){var t,e,i,n;t=this.input,e="change",i=()=>{this.sync()},t.addEventListener(e,i,n)}),Mt.define("checkbox_options",function(t){var e=this,i=e.onOptionSelect;e.settings.hideSelected=!1;const n=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},t);var r=function(t,e){e?(t.checked=!0,n.uncheckedClassNames&&t.classList.remove(...n.uncheckedClassNames),n.checkedClassNames&&t.classList.add(...n.checkedClassNames)):(t.checked=!1,n.checkedClassNames&&t.classList.remove(...n.checkedClassNames),n.uncheckedClassNames&&t.classList.add(...n.uncheckedClassNames))},s=function(t){setTimeout(()=>{var e=t.querySelector("input."+n.className);e instanceof HTMLInputElement&&r(e,t.classList.contains("selected"))},1)};e.hook("after","setupTemplates",()=>{var t=e.settings.render.option;e.settings.render.option=(i,s)=>{var o=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(jt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(t.call(e,i,s)),a=document.createElement("input");n.className&&a.classList.add(n.className),a.addEventListener("click",function(t){Nt(t)}),a.type="checkbox";const l=null==(c=i[e.settings.valueField])?null:Ft(c);var c;return r(a,!!(l&&e.items.indexOf(l)>-1)),o.prepend(a),o}}),e.on("item_remove",t=>{var i=e.getOption(t);i&&(i.classList.remove("selected"),s(i))}),e.on("item_add",t=>{var i=e.getOption(t);i&&s(i)}),e.hook("instead","onOptionSelect",(t,n)=>{if(n.classList.contains("selected"))return n.classList.remove("selected"),e.removeItem(n.dataset.value),e.refreshOptions(),void Nt(t,!0);i.call(e,t,n),s(n)})}),Mt.define("clear_button",function(t){const e=this,i=Object.assign({className:"clear-button",title:"Clear All",html:t=>`<div class="${t.className}" title="${t.title}">&#10799;</div>`},t);e.on("initialize",()=>{var t=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Pt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(i.html(i));t.addEventListener("click",t=>{e.isLocked||(e.clear(),"single"===e.settings.mode&&e.settings.allowEmptyOption&&e.addItem(""),t.preventDefault(),t.stopPropagation())}),e.control.appendChild(t)})}),Mt.define("drag_drop",function(){var t=this;if("multi"!==t.settings.mode)return;var e=t.lock,i=t.unlock;let n,r=!0;t.hook("after","setupTemplates",()=>{var e=t.settings.render.item;t.settings.render.item=(i,s)=>{const o=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Ht(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(e.call(t,i,s));qt(o,{draggable:"true"});const a=t=>{t.preventDefault(),o.classList.add("ts-drag-over"),l(o,n)},l=(t,e)=>{var i,n,r;void 0!==e&&(((t,e)=>{do{var i;if(t==(e=null==(i=e)?void 0:i.previousElementSibling))return!0}while(e&&e.previousElementSibling);return!1})(e,o)?(n=e,null==(r=(i=t).parentNode)||r.insertBefore(n,i.nextSibling)):((t,e)=>{var i;null==(i=t.parentNode)||i.insertBefore(e,t)})(t,e))};return $t(o,"mousedown",t=>{r||((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(t),t.stopPropagation()}),$t(o,"dragstart",t=>{n=o,setTimeout(()=>{o.classList.add("ts-dragging")},0)}),$t(o,"dragenter",a),$t(o,"dragover",a),$t(o,"dragleave",()=>{o.classList.remove("ts-drag-over")}),$t(o,"dragend",()=>{var e;document.querySelectorAll(".ts-drag-over").forEach(t=>t.classList.remove("ts-drag-over")),null==(e=n)||e.classList.remove("ts-dragging"),n=void 0;var i=[];t.control.querySelectorAll("[data-value]").forEach(t=>{if(t.dataset.value){let e=t.dataset.value;e&&i.push(e)}}),t.setValue(i)}),o}}),t.hook("instead","lock",()=>(r=!1,e.call(t))),t.hook("instead","unlock",()=>(r=!0,i.call(t)))}),Mt.define("dropdown_header",function(t){const e=this,i=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:t=>'<div class="'+t.headerClass+'"><div class="'+t.titleRowClass+'"><span class="'+t.labelClass+'">'+t.title+'</span><a class="'+t.closeClass+'">&times;</a></div></div>'},t);e.on("initialize",()=>{var t=(t=>{if(t.jquery)return t[0];if(t instanceof HTMLElement)return t;if(Rt(t)){var e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstChild}return document.querySelector(t)})(i.html(i)),n=t.querySelector("."+i.closeClass);n&&n.addEventListener("click",t=>{((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(t,!0),e.close()}),e.dropdown.insertBefore(t,e.dropdown.firstChild)})}),Mt.define("caret_position",function(){var t=this;t.hook("instead","setCaret",e=>{"single"!==t.settings.mode&&t.control.contains(t.control_input)?(e=Math.max(0,Math.min(t.items.length,e)))==t.caretPos||t.isPending||t.controlChildren().forEach((i,n)=>{n<e?t.control_input.insertAdjacentElement("beforebegin",i):t.control.appendChild(i)}):e=t.items.length,t.caretPos=e}),t.hook("instead","moveCaret",e=>{if(!t.isFocused)return;const i=t.getLastActive(e);if(i){const n=((t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i})(i);t.setCaret(e>0?n+1:n),t.setActiveItem(),((t,...e)=>{var i=Bt(e);(t=Vt(t)).map(t=>{i.map(e=>{t.classList.remove(e)})})})(i,"last-active")}else t.setCaret(t.caretPos+e)})}),Mt.define("dropdown_input",function(){const t=this;t.settings.shouldOpen=!0,t.hook("before","setup",()=>{t.focus_node=t.control,((t,...e)=>{var i=Yt(e);(t=Kt(t)).map(t=>{i.map(e=>{t.classList.add(e)})})})(t.control_input,"dropdown-input");const e=zt('<div class="dropdown-input-wrap">');e.append(t.control_input),t.dropdown.insertBefore(e,t.dropdown.firstChild);const i=zt('<input class="items-placeholder" tabindex="-1" />');i.placeholder=t.settings.placeholder||"",t.control.append(i)}),t.on("initialize",()=>{t.control_input.addEventListener("keydown",e=>{switch(e.keyCode){case 27:return t.isOpen&&(((t,e=!1)=>{t&&(t.preventDefault(),e&&t.stopPropagation())})(e,!0),t.close()),void t.clearActiveItems();case 9:t.focus_node.tabIndex=-1}return t.onKeyDown.call(t,e)}),t.on("blur",()=>{t.focus_node.tabIndex=t.isDisabled?-1:t.tabIndex}),t.on("dropdown_open",()=>{t.control_input.focus()});const e=t.onBlur;var i,n,r,s;t.hook("instead","onBlur",i=>{if(!i||i.relatedTarget!=t.control_input)return e.call(t)}),i=t.control_input,n="blur",r=()=>t.onBlur(),i.addEventListener(n,r,s),t.hook("before","close",()=>{t.isOpen&&t.focus_node.focus({preventScroll:!0})})})}),Mt.define("input_autogrow",function(){var t=this;t.on("initialize",()=>{var e=document.createElement("span"),i=t.control_input;e.style.cssText="position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ",t.wrapper.appendChild(e);for(const t of["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"])e.style[t]=i.style[t];var n=()=>{e.textContent=i.value,i.style.width=e.clientWidth+"px"};n(),t.on("update item_add item_remove",n),Ut(i,"input",n),Ut(i,"keyup",n),Ut(i,"blur",n),Ut(i,"update",n)})}),Mt.define("no_backspace_delete",function(){var t=this,e=t.deleteSelection;this.hook("instead","deleteSelection",i=>!!t.activeItems.length&&e.call(t,i))}),Mt.define("no_active_items",function(){this.hook("instead","setActiveItem",()=>{}),this.hook("instead","selectAll",()=>{})}),Mt.define("optgroup_columns",function(){var t=this,e=t.onKeyDown;t.hook("instead","onKeyDown",i=>{var n,r,s,o;if(!t.isOpen||37!==i.keyCode&&39!==i.keyCode)return e.call(t,i);t.ignoreHover=!0,o=((t,e)=>{for(;t&&t.matches;){if(t.matches(e))return t;t=t.parentNode}})(t.activeOption,"[data-group]"),n=((t,e)=>{if(!t)return-1;e=e||t.nodeName;for(var i=0;t=t.previousElementSibling;)t.matches(e)&&i++;return i})(t.activeOption,"[data-selectable]"),o&&(o=37===i.keyCode?o.previousSibling:o.nextSibling)&&(r=(s=o.querySelectorAll("[data-selectable]"))[Math.min(s.length-1,n)])&&t.setActiveOption(r)})}),Mt.define("remove_button",function(t){const e=Object.assign({label:"&times;",title:"Remove",className:"remove",append:!0},t);var i=this;if(e.append){var n='<a href="javascript:void(0)" class="'+e.className+'" tabindex="-1" title="'+((e.title+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")+'">')+e.label+"</a>";i.hook("after","setupTemplates",()=>{var t=i.settings.render.item;i.settings.render.item=(e,r)=>{var s=Gt(t.call(i,e,r)),o=Gt(n);return s.appendChild(o),Qt(o,"mousedown",t=>{Xt(t,!0)}),Qt(o,"click",t=>{i.isLocked||(Xt(t,!0),i.isLocked||i.shouldDelete([s],t)&&(i.removeItem(s),i.refreshOptions(!1),i.inputState()))}),s}})}}),Mt.define("restore_on_backspace",function(t){const e=this,i=Object.assign({text:t=>t[e.settings.labelField]},t);e.on("item_remove",function(t){if(e.isFocused&&""===e.control_input.value.trim()){var n=e.options[t];n&&e.setTextboxValue(i.text.call(e,n))}})}),Mt.define("virtual_scroll",function(){const t=this,e=t.canLoad,i=t.clearActiveOption,n=t.loadCallback;var r,s,o={},a=!1,l=[];if(t.settings.shouldLoadMore||(t.settings.shouldLoadMore=()=>{if(r.clientHeight/(r.scrollHeight-r.scrollTop)>.9)return!0;if(t.activeOption){var e=t.selectable();if(Array.from(e).indexOf(t.activeOption)>=e.length-2)return!0}return!1}),!t.settings.firstUrl)throw"virtual_scroll plugin requires a firstUrl() method";t.settings.sortField=[{field:"$order"},{field:"$score"}];const c=e=>!("number"==typeof t.settings.maxOptions&&r.children.length>=t.settings.maxOptions)&&!(!(e in o)||!o[e]),d=(e,i)=>t.items.indexOf(i)>=0||l.indexOf(i)>=0;t.setNextUrl=(t,e)=>{o[t]=e},t.getUrl=e=>{if(e in o){const t=o[e];return o[e]=!1,t}return t.clearPagination(),t.settings.firstUrl.call(t,e)},t.clearPagination=()=>{o={}},t.hook("instead","clearActiveOption",()=>{if(!a)return i.call(t)}),t.hook("instead","canLoad",i=>i in o?c(i):e.call(t,i)),t.hook("instead","loadCallback",(e,i)=>{if(a){if(s){const i=e[0];void 0!==i&&(s.dataset.value=i[t.settings.valueField])}}else t.clearOptions(d);n.call(t,e,i),a=!1}),t.hook("after","refreshOptions",()=>{const e=t.lastValue;var i;c(e)?(i=t.render("loading_more",{query:e}))&&(i.setAttribute("data-selectable",""),s=i):e in o&&!r.querySelector(".no-results")&&(i=t.render("no_more_results",{query:e})),i&&(((t,...e)=>{var i=Zt(e);(t=te(t)).map(t=>{i.map(e=>{t.classList.add(e)})})})(i,t.settings.optionClass),r.append(i))}),t.on("initialize",()=>{l=Object.keys(t.options),r=t.dropdown_content,t.settings.render=Object.assign({},{loading_more:()=>'<div class="loading-more-results">Loading more results ... </div>',no_more_results:()=>'<div class="no-more-results">No more results</div>'},t.settings.render),r.addEventListener("scroll",()=>{t.settings.shouldLoadMore.call(t)&&c(t.lastValue)&&(a||(a=!0,t.load.call(t,t.lastValue)))})})});class ee{constructor(t){this.datepicker=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initDatepicker(t)}),this.initDatepicker(t),!0}initDatepicker(t){const e=t.el.querySelectorAll("input[data-provide='datepicker']");e.length>=1&&this.datepicker.initDatepickers(Array.from(e),t)}}class ie{constructor(t){this.nette=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initNetteForms(t)}),this.initNetteForms(t),!0}initNetteForms(t){var e,i;const n=null!==(i=null!==(e=this.nette)&&void 0!==e?e:w().Nette)&&void 0!==i?i:null;n&&t.el.querySelectorAll("form").forEach(t=>n.initForm(t))}}class ne{constructor(t){this.selectpicker=t}onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initSelectpicker(t)}),this.initSelectpicker(t),!0}initSelectpicker(t){const e=t.el.querySelectorAll("select.selectpicker");e.length>=1&&this.selectpicker.initSelectpickers(Array.from(e),t)}}class re{constructor(t){this.sortable=t}onDatagridInit(t){return t.ajax.addEventListener("before",t=>{}),this.sortable.initSortable(t),t.ajax.addEventListener("success",({detail:{payload:e}})=>{if(e._datagrid_sort){for(const i in e._datagrid_sort){const n=e._datagrid_sort[i],r=t.el.querySelector(`#datagrid-sort-${i}`);r&&(r.setAttribute("href",n),r.setAttribute("data-href",n))}this.sortable.initSortable(t)}if(e._datagrid_tree){const i=t.el.querySelector(`.datagrid-tree-item[data-id='${e._datagrid_tree}'] .datagrid-tree-item-children`);if(i&&e.snippets){i.classList.add("loaded");for(const t in e.snippets){const n=e.snippets[t],r=(new DOMParser).parseFromString(n,"text/html").firstElementChild;if(r){const e=document.createElement("div");e.id=t,e.classList.add("datagrid-tree-item"),e.setAttribute("data-id",t),r.hasAttribute("has-children")&&e.classList.add("has-children"),i.append(e)}}}this.sortable.initSortableTree(t)}}),!0}}class se{onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.initPerPage(t),this.initChange(t)}),this.initPerPage(t),this.initChange(t),!0}initPerPage(t){t.el.querySelectorAll("select[data-autosubmit-per-page]").forEach(e=>{e.addEventListener("change",()=>{var i,n;let r=null===(i=e.parentElement)||void 0===i?void 0:i.querySelector("input[type=submit]");if(r||(r=null===(n=e.parentElement)||void 0===n?void 0:n.querySelector("button[type=submit]")),!(r instanceof HTMLElement))return;const s=r.closest("form");s&&t.ajax.submitForm(s)})})}initChange(t){t.el.querySelectorAll("[data-autosubmit]").forEach(e=>{const i=e.closest("form");i&&"true"!==e.dataset.listenersAttached&&(e.dataset.listenersAttached="true",e instanceof HTMLSelectElement?e.addEventListener("change",()=>t.ajax.submitForm(i)):e instanceof HTMLInputElement&&(e.hasAttribute("data-autosubmit-change")&&e.addEventListener("change",E(()=>t.ajax.submitForm(i))),e.addEventListener("keyup",E(e=>{if(_(e)||!function(t,e,i){const n=1===t.key.length?t.key.charCodeAt(0):0;return n>=e&&n<=i}(e,9,40)&&!function(t){return 2===t.key.length&&t.key.startsWith("F")}(e))return t.ajax.submitForm(i)}))))})}}class oe{onDatagridInit(t){return t.ajax.addEventListener("complete",e=>{this.init(t)}),this.init(t)}init(t){let e=null;t.el.addEventListener("click",t=>{if(t.target instanceof HTMLElement&&t.target.classList.contains("col-checkbox")&&(e=t.target,t.shiftKey&&e)){const t=e.closest("tr");if(!t)return;const i=e.closest("tr");if(!i)return;const n=i.closest("tbody");if(!n)return;const r=Array.from(n.querySelectorAll("tr")),[s,o]=[i.rowIndex,t.rowIndex].sort();r.slice(s,o+1).forEach(t=>{const e=t.querySelector('.col-checkbox input[type="checkbox"]');e&&(e.checked=!0)})}});const i=Array.from(t.el.querySelectorAll(`input[data-check='${t.name}']:not([data-check-all])`)),n=t.el.querySelector(`input[data-check='${t.name}'][data-check-all]`),r=t.el.querySelector("select[name='group_action[group_action]']"),s=document.querySelectorAll(".row-group-actions *[type='submit']"),o=document.querySelector(".datagrid-selected-rows-count");return[...i,n].forEach(e=>{e&&e.addEventListener("change",()=>{if(e.hasAttribute("data-check-all")){if(t.name!==e.getAttribute("data-check-all"))return;if(i.forEach(t=>t.checked=e.checked),s.forEach(t=>t.disabled=!e.checked),r&&(r.disabled=!e.checked),o){const t=i.length;o.innerText=`${e.checked?t:0}/${t}`}return}n&&(n.checked=i.every(t=>t.checked));const a=i.filter(t=>t.checked),l=a.length>=1;s.forEach(t=>t.disabled=!l),r&&(r.disabled=!l),o&&(o.innerText=`${a.length}/${i.length}`)})}),!0}}const ae="data-datagrid-confirm";class le{constructor(){this.modalId="datagridConfirmModal",this.messageBoxId="datagridConfirmMessage",this.confirmButtonId="datagridConfirmOk"}onDatagridInit(t){this.datagrid=t;return t.el.querySelectorAll(`[${ae}]:not(.ajax)`).forEach(t=>t.addEventListener("click",e=>this.handleClick(t,e))),t.ajax.addEventListener("interact",e=>{const i=e.detail.element;t.el.contains(i)&&this.handleClick(i,e)}),!0}handleClick(t,e){const i=this.getConfirmationMessage(t);if(!i)return;e.preventDefault(),e.stopPropagation();const n=this.getElement(this.modalId);n?this.showModalConfirm(n,i,t,e):window.confirm(i)&&this.executeConfirmedAction(t,e)}getConfirmationMessage(t){var e,i,n;return null!==(n=null!==(e=t.getAttribute(ae))&&void 0!==e?e:null===(i=t.closest("a"))||void 0===i?void 0:i.getAttribute(ae))&&void 0!==n?n:null}showModalConfirm(t,e,i,n){if("undefined"==typeof bootstrap)return void(window.confirm(e)&&this.executeConfirmedAction(i,n));const r=this.getElement(this.messageBoxId),s=this.getElement(this.confirmButtonId);if(!r||!s)return void(window.confirm(e)&&this.executeConfirmedAction(i,n));r.textContent=e;const o=s.cloneNode(!0);s.parentNode.replaceChild(o,s),o.addEventListener("click",()=>{var e;null===(e=bootstrap.Modal.getInstance(t))||void 0===e||e.hide(),this.executeConfirmedAction(i,n)},{once:!0});(bootstrap.Modal.getInstance(t)||new bootstrap.Modal(t)).show()}executeConfirmedAction(t,e){var i,n;const r=e instanceof CustomEvent&&e.detail&&"object"==typeof e.detail?e.detail:null,s=t.classList.contains("ajax");if(t instanceof HTMLAnchorElement&&t.href&&s){if("undefined"==typeof naja)return;if(r&&"string"==typeof r.method&&"string"==typeof r.url){const t={...r.options,history:!1};naja.makeRequest(r.method,r.url,null!==(i=r.payload)&&void 0!==i?i:null,t)}else{const e=null!==(n=t.getAttribute("data-naja-method"))&&void 0!==n?n:"GET";naja.makeRequest(e,t.href,null,{history:!1})}}else this.triggerNativeInteraction(t)}getElement(t){return document.getElementById(t)}triggerNativeInteraction(t){const e=t.getAttribute(ae);null!==e&&t.removeAttribute(ae);try{t.click()}finally{null!==e&&t.setAttribute(ae,e)}}}const ce="data-datagrid-editable-url";class de{onDatagridInit(t){return t.ajax.addEventListener("success",e=>{this.initEditableCells(t)}),this.initEditableCells(t),!0}initEditableCells(t){t.el.querySelectorAll(`[${ce}]`).forEach(e=>{e.addEventListener("click",i=>{var n,r,s,o;if(!(e instanceof HTMLAnchorElement||e.classList.contains("datagrid-inline-edit")||e.classList.contains("editing"))){e.classList.add("editing");const i=e.innerHTML.replace(/<\/?br>/g,"\n").trim(),a=(null!==(n=e.getAttribute("data-datagrid-editable-value"))&&void 0!==n?n:i).trim();e.setAttribute("originalValue",i),e.setAttribute("valueToEdit",a);const l=null!==(r=e.getAttribute("data-datagrid-editable-type"))&&void 0!==r?r:"text";let c;switch(l){case"textarea":e.innerHTML=`<textarea rows="${function(t){var e;const i=t.style.padding?parseInt(t.style.padding.replace(/[^-\d\.]/g,""),10):0,n=t.getBoundingClientRect().height,r=Math.round(parseFloat(null!==(e=t.style.lineHeight)&&void 0!==e?e:"0"));return Math.round((n-2*i)/r)}(e)}">${a}</textarea>`,c=e.querySelector("textarea");break;case"select":e.innerHTML=null!==(s=e.getAttribute("data-datagrid-editable-element"))&&void 0!==s?s:"",c=e.querySelector("select"),c.querySelectorAll(`option[value='${a}']`).forEach(t=>t.setAttribute("selected","true"));break;default:e.innerHTML=`<input type='${l}' />`,c=e.querySelector("input"),c.setAttribute("value",a)}c.focus();const d=JSON.parse(null!==(o=e.getAttribute("data-datagrid-editable-attrs"))&&void 0!==o?o:"{}");for(const t in d){const e=d[t];c.setAttribute(t,e)}e.classList.remove("edited");const u=async n=>{var r,s,o;let c=n.value;if(c!==a)try{const i=await t.ajax.request({url:null!==(r=e.getAttribute(ce))&&void 0!==r?r:"",method:"POST",data:{value:c}});"select"===l?e.innerHTML=n instanceof HTMLSelectElement&&null!==(o=null===(s=n.options[n.selectedIndex])||void 0===s?void 0:s.text)&&void 0!==o?o:c:(i._datagrid_editable_new_value&&(c=i._datagrid_editable_new_value),e.innerHTML=c),e.classList.add("edited")}catch(t){e.innerHTML=i,e.classList.add("edited-error")}else e.innerHTML=i;e.classList.remove("editing")};e.querySelectorAll("input, textarea, select").forEach(t=>{t instanceof HTMLSelectElement||t.addEventListener("blur",()=>u(t)),t.addEventListener("keydown",n=>{if(_(n))return n.stopPropagation(),n.preventDefault(),u(t);(function(t){return"Escape"===t.key})(n)&&(n.stopPropagation(),n.preventDefault(),e.classList.remove("editing"),e.innerHTML=i)}),t instanceof HTMLSelectElement&&t.addEventListener("change",()=>u(t))})}})})}}class ue{onInit(t){}onDatagridInit(t){return t.ajax.addEventListener("success",({detail:{payload:e}})=>{var i;if(e._datagrid_name&&e._datagrid_name===t.name)if(e._datagrid_inline_edited||e._datagrid_inline_edit_cancel){if(e._datagrid_inline_edited){t.el.querySelectorAll(`tr[data-id='${e._datagrid_inline_edited}'] > td`).forEach(t=>{t.classList.add("edited")})}}else{if(e._datagrid_inline_adding){const e=t.el.querySelector(".datagrid-row-inline-add");e&&(e.classList.remove("datagrid-row-inline-add-hidden"),null===(i=e.querySelector("input:not([readonly]), textarea:not([readonly])"))||void 0===i||i.focus())}t.el.querySelectorAll(".datagrid-inline-edit input").forEach(t=>{t.addEventListener("keydown",e=>{var i,n;if(_(e))return e.stopPropagation(),e.preventDefault(),null===(n=null===(i=t.closest("tr"))||void 0===i?void 0:i.querySelector(".col-action-inline-edit [name='inline_edit[submit]']"))||void 0===n?void 0:n.click()})}),t.el.querySelectorAll(".datagrid-inline-add input").forEach(t=>{t.addEventListener("keydown",e=>{var i,n;if(_(e))return e.stopPropagation(),e.preventDefault(),null===(n=null===(i=t.closest("tr"))||void 0===i?void 0:i.querySelector(".col-action-inline-edit [name='inline_add[submit]']"))||void 0===n?void 0:n.click()})}),t.el.querySelectorAll("[data-datagrid-cancel-inline-add]").forEach(t=>{t.addEventListener("mouseup",e=>{if(0===e.button){e.stopPropagation(),e.preventDefault();const i=t.closest(".datagrid-row-inline-add");i&&i.classList.add("datagrid-row-inline-add-hidden")}})})}}),!0}}class he{onDatagridInit(t){return t.el.querySelectorAll("[data-toggle-detail-grid]").forEach(e=>{if(e.getAttribute("data-toggle-detail-grid")!==t.name)return;const i=e.getAttribute("data-toggle-detail");e.addEventListener("click",n=>{const r=t.el.querySelector(`.item-detail-${t.name}-id-${i}`);e.closest("tr"),r&&(r.classList.add("datagrid--content-row"),r.classList.toggle("is-active")),t.ajax.addEventListener("before",e=>{e.detail.params.url.includes(`do=${t.name}-getItemDetail`)&&e.detail.params.url.includes(`grid-id=${i}`)&&(e.stopPropagation(),e.preventDefault())})})}),t.ajax.addEventListener("success",({detail:{payload:e}})=>{var i;e._datagrid_redraw_item_id&&e._datagrid_redraw_item_class&&(null===(i=t.el.querySelector(`tr[data-id='${e._datagrid_redraw_item_id}']`))||void 0===i||i.setAttribute("class",e._datagrid_redraw_item_class))}),!0}}class pe{onDatagridInit(t){return t.ajax.addEventListener("before",t=>{}),t.ajax.addEventListener("success",({detail:{payload:t}})=>{var e,i;if(t._datagrid_tree){const n=t._datagrid_tree,r=document.querySelector(`.datagrid-tree-item[data-id="${n}"]`),s=document.querySelector(`.datagrid-tree-item[data-id="${n}"] .datagrid-tree-item-children`);if(s){if(s.classList.contains("showed")){if(s.innerHTML="",s.classList.remove("showed"),r){const t=r.querySelector("a.chevron");t&&(t.style.transform="rotate(0deg)")}return}if(s.classList.add("showed"),r){const t=r.querySelector("a.chevron");t&&(t.style.transform="rotate(90deg)")}const n=t.snippets;for(const t in n){const r=n[t],o=(new DOMParser).parseFromString(r,"text/html").querySelector("[data-id]"),a=null!==(e=null==o?void 0:o.getAttribute("data-id"))&&void 0!==e?e:"",l=`\n<div class="datagrid-tree-item" class='${null!==(i=null==o?void 0:o.hasAttribute("data-has-children"))&&void 0!==i&&i?"has-children":""}' id="${t}" data-id="${a}">${r}</div>`;s.innerHTML=l}}}}),!0}}
8
8
  /**!
9
9
  * Sortable 1.15.6
10
10
  * @author RubaXa <trash@rubaxa.org>