text: !function(){function e(e){return e&&e.__esModule?e.default:e}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};
  /**
   *
   *
   * @author Jerry Bendy <jerry@icewingcc.com>
   * @licence MIT
   *
   */
  !function(e){var t,n=function(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,(function(e){return t[e]}))},i=function(e){return e.replace(/[ +]/g,"%20").replace(/(%[a-f0-9]{2})+/gi,(function(e){return decodeURIComponent(e)}))},s=function(t){var n={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return m&&(n[e.Symbol.iterator]=function(){return n}),n},r=function(e){var t={};if("object"==typeof e)if(a(e))for(var n=0;n<e.length;n++){var s=e[n];if(!a(s)||2!==s.length)throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");o(t,s[0],s[1])}else for(var r in e)e.hasOwnProperty(r)&&o(t,r,e[r]);else{0===e.indexOf("?")&&(e=e.slice(1));for(var u=e.split("&"),l=0;l<u.length;l++){var c=u[l],h=c.indexOf("=");-1<h?o(t,i(c.slice(0,h)),i(c.slice(h+1))):c&&o(t,i(c),"")}}return t},o=function(e,t,n){var i="string"==typeof n?n:null!=n&&"function"==typeof n.toString?n.toString():JSON.stringify(n);u(e,t)?e[t].push(i):e[t]=[i]},a=function(e){return!!e&&"[object Array]"===Object.prototype.toString.call(e)},u=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l=function(){try{if(e.URLSearchParams&&"bar"===new e.URLSearchParams("foo=bar").get("foo"))return e.URLSearchParams}catch(e){}return null}(),c=l&&"a=1"===new l({a:1}).toString(),h=l&&"+"===new l("s=%2B").get("s"),d=!l||((t=new l).append("s"," &"),"s=+%26"===t.toString()),f=g.prototype,m=!(!e.Symbol||!e.Symbol.iterator);if(!(l&&c&&h&&d)){f.append=function(e,t){o(this.__URLSearchParams__,e,t)},f.delete=function(e){delete this.__URLSearchParams__[e]},f.get=function(e){var t=this.__URLSearchParams__;return this.has(e)?t[e][0]:null},f.getAll=function(e){var t=this.__URLSearchParams__;return this.has(e)?t[e].slice(0):[]},f.has=function(e){return u(this.__URLSearchParams__,e)},f.set=function(e,t){this.__URLSearchParams__[e]=[""+t]},f.toString=function(){var e,t,i,s,r=this.__URLSearchParams__,o=[];for(t in r)for(i=n(t),e=0,s=r[t];e<s.length;e++)o.push(i+"="+n(s[e]));return o.join("&")};var p=!!h&&l&&!c&&e.Proxy;Object.defineProperty(e,"URLSearchParams",{value:p?new Proxy(l,{construct:function(e,t){return new e(new g(t[0]).toString())}}):g});var v=e.URLSearchParams.prototype;v.polyfill=!0,v.forEach=v.forEach||function(e,t){var n=r(this.toString());Object.getOwnPropertyNames(n).forEach((function(i){n[i].forEach((function(n){e.call(t,n,i,this)}),this)}),this)},v.sort=v.sort||function(){var e,t,n,i=r(this.toString()),s=[];for(e in i)s.push(e);for(s.sort(),t=0;t<s.length;t++)this.delete(s[t]);for(t=0;t<s.length;t++){var o=s[t],a=i[o];for(n=0;n<a.length;n++)this.append(o,a[n])}},v.keys=v.keys||function(){var e=[];return this.forEach((function(t,n){e.push(n)})),s(e)},v.values=v.values||function(){var e=[];return this.forEach((function(t){e.push(t)})),s(e)},v.entries=v.entries||function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),s(e)},m&&(v[e.Symbol.iterator]=v[e.Symbol.iterator]||v.entries)}function g(e){((e=e||"")instanceof URLSearchParams||e instanceof g)&&(e=e.toString()),this.__URLSearchParams__=r(e)}}(void 0!==t?t:"undefined"!=typeof window?window:{}),function(){var e=function(e){if("string"!=typeof e&&(e=e.toString()),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()},t=function(e){return"string"!=typeof e&&(e=e.toString()),e},n=function(e){if(e.bodyUsed)return fetch.Promise.reject(new TypeError("Already read"));e.bodyUsed=!0},i=function(e){return new fetch.Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))},s=function(e){var t=new FileReader;return t.readAsArrayBuffer(e),i(t)},r=function(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,"string"==typeof e)this._bodyText=e;else if(c.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(c.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else{if(e)throw new Error("unsupported BodyInit type");this._bodyText=""}},c.blob?(this.blob=function(){var e=n(this);if(e)return e;if(this._bodyBlob)return fetch.Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return fetch.Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(s)},this.text=function(){var e,t,s=n(this);if(s)return s;if(this._bodyBlob)return e=this._bodyBlob,(t=new FileReader).readAsText(e),i(t);if(this._bodyFormData)throw new Error("could not read FormData body as text");return fetch.Promise.resolve(this._bodyText)}):this.text=function(){var e=n(this);return e||fetch.Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(a)}),this.json=function(){return this.text().then((function(e){return JSON.parse(e)}))},this},o=function(e,t){var n,i;if(t=t||{},this.url=e,this.credentials=t.credentials||"omit",this.headers=new f(t.headers),this.method=(n=t.method||"GET",i=n.toUpperCase(),h.indexOf(i)>-1?i:n),this.mode=t.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&t.body)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(t.body)},a=function(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),i=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(s))}})),t},u=function(e){var t=new f;return e.getAllResponseHeaders().trim().split("\n").forEach((function(e){var n=e.trim().split(":"),i=n.shift().trim(),s=n.join(":").trim();t.append(i,s)})),t},l=function(e,t){t||(t={}),this._initBody(e),this.type="default",this.url=null,this.status=t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText,this.headers=t.headers instanceof f?t.headers:new f(t.headers),this.url=t.url||""};if(!self.fetch){f.prototype.append=function(n,i){n=e(n),i=t(i);var s=this.map[n];s||(s=[],this.map[n]=s),s.push(i)},f.prototype.delete=function(t){delete this.map[e(t)]},f.prototype.get=function(t){var n=this.map[e(t)];return n?n[0]:null},f.prototype.getAll=function(t){return this.map[e(t)]||[]},f.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},f.prototype.set=function(n,i){this.map[e(n)]=[t(i)]},f.prototype.forEach=function(e){var t=this;Object.getOwnPropertyNames(this.map).forEach((function(n){e(n,t.map[n])}))};var c={blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in self},h=["DELETE","GET","HEAD","OPTIONS","POST","PUT"],d=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);r.call(o.prototype),r.call(l.prototype),self.Headers=f,self.Request=o,self.Response=l,self.fetch=function(e,t){var n;return n=o.prototype.isPrototypeOf(e)&&!t?e:new o(e,t),new fetch.Promise((function(e,t){var i=function(){if(4===s.readyState){var n=1223===s.status?204:s.status;if(n<100||n>599)t(new TypeError("Network request failed"));else{var i={status:n,statusText:s.statusText,headers:u(s),url:"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0},r="response"in s?s.response:s.responseText;e(new l(r,i))}}},s=function(){return d&&!/^(get|post|head|put|delete|options)$/i.test(this.method)?(this.usingActiveXhr=!0,new ActiveXObject("Microsoft.XMLHTTP")):new XMLHttpRequest}();"cors"===n.credentials&&(s.withCredentials=!0),s.onreadystatechange=i,self.usingActiveXhr||(s.onload=i,s.onerror=function(){t(new TypeError("Network request failed"))}),s.open(n.method,n.url,!0),"responseType"in s&&c.blob&&(s.responseType="blob"),n.headers.forEach((function(e,t){t.forEach((function(t){s.setRequestHeader(e,t)}))})),s.send(void 0===n._bodyInit?null:n._bodyInit)}))},fetch.Promise=self.Promise,self.fetch.polyfill=!0}function f(e){this.map={};var t=this;e instanceof f?e.forEach((function(e,n){n.forEach((function(n){t.append(e,n)}))})):e&&Object.getOwnPropertyNames(e).forEach((function(n){t.append(n,e[n])}))}}();var n,i,s={};function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function h(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function d(e){return e&&e.constructor===Symbol?"symbol":typeof e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e){return f(e)}function p(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?r(e):t}function v(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=m(e);if(t){var s=m(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return p(this,n)}}n=s,i=function(){var e,t=function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}},n=function(e,t){var n,i=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)),i},i=function(e){for(var t=arguments,i=function(i){var s=null!=t[i]?t[i]:{};i%2?n(Object(s),!0).forEach((function(t){var n,i;n=e,t=s[i=t],i in n?Object.defineProperty(n,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[i]=t})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))},s=1;s<arguments.length;s++)i(s);return e},s=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i},r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw r}}}},o=function(e,t){for(var n=document.getElementsByClassName(e.resultsList.className),i=0;i<n.length;i++)t!==n[i]&&t!==e.inputField&&n[i].parentNode.removeChild(n[i]);e.inputField.removeAttribute("aria-activedescendant"),e.inputField.setAttribute("aria-expanded",!1)},a=function(e,t,n){var s,r,o=(s=e,(r=document.createElement(s.resultsList.element)).setAttribute("id",s.resultsList.idName),r.setAttribute("aria-label",s.name),r.setAttribute("class",s.resultsList.className),r.setAttribute("role","listbox"),r.setAttribute("tabindex","-1"),s.resultsList.container&&s.resultsList.container(r),("string"==typeof s.resultsList.destination?document.querySelector(s.resultsList.destination):s.resultsList.destination()).insertAdjacentElement(s.resultsList.position,r),r);e.inputField.setAttribute("aria-expanded",!0);for(var a=function(s){var r,a,u,l,c=t.results[s];(l=(r=c,a=s,u=e,(l=document.createElement(u.resultItem.element)).setAttribute("id","".concat(u.resultItem.idName,"_").concat(a)),l.setAttribute("class",u.resultItem.className),l.setAttribute("role","option"),l.innerHTML=r.match,u.resultItem.content&&u.resultItem.content(r,l),l)).addEventListener("click",(function(r){r={event:r,matches:n,input:t.input,query:t.query,results:t.results,selection:i(i({},c),{},{index:s})},e.onSelection&&e.onSelection(r)})),o.appendChild(l)},u=0;u<t.results.length;u++)a(u);return o},u=function(e,t,n){e.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:t,cancelable:!0}))},l=function(e,t){for(var n=[],i=function(i){function s(s){var r=(s?o[s]:o).toString();r&&((r="function"==typeof e.searchEngine?e.searchEngine(t,r):function(e,t,n){var i=n.diacritics?t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC"):t.toLowerCase();if("loose"===n.searchEngine){e=e.replace(/ /g,"");for(var s=[],r=0,o=0;o<i.length;o++){var a=t[o];r<e.length&&i[o]===e[r]&&(a=n.highlight?'<span class="autoComplete_highlighted">'.concat(a,"</span>"):a,r++),s.push(a)}if(r===e.length)return s.join("")}else if(i.includes(e))return e=new RegExp("".concat(e),"i").exec(t),n.highlight?t.replace(e,'<span class="autoComplete_highlighted">'.concat(e,"</span>")):t}(t,r,e))&&s?n.push({key:s,index:i,match:r,value:o}):r&&!s&&n.push({index:i,match:r,value:o}))}var o=e.data.store[i];if(e.data.key){var a,u=r(e.data.key);try{for(u.s();!(a=u.n()).done;)s(a.value)}catch(e){u.e(e)}finally{u.f()}}else s()},s=0;s<e.data.store.length;s++)i(s);return e.sort?n.sort(e.sort):n};function c(e){!function(e){if(!(e instanceof c))throw new TypeError("Cannot call a class as a function")}(this);var t=void 0===(x=e.name)?"Search":x,n=void 0===(I=e.selector)?"#autoComplete":I,i=void 0!==(F=e.observer)&&F,s=(T=e.data).src,r=T.key,o=void 0!==(b=T.cache)&&b,a=T.store,u=T.results,l=e.query,h=void 0===(k=(O=void 0===(O=e.trigger)?{}:O).event)?["input"]:k,d=void 0!==(w=O.condition)&&w,f=void 0===(C=e.searchEngine)?"strict":C,m=void 0!==(L=e.diacritics)&&L,p=void 0===(D=e.threshold)?1:D,v=void 0===(S=e.debounce)?0:S,g=void 0===(E=(P=void 0===(P=e.resultsList)?{}:P).render)||E,y=void 0!==(R=P.container)&&R,_=P.destination,I=void 0===(x=P.position)?"afterend":x,b=void 0===(F=P.element)?"ul":F,k=void 0===(T=P.idName)?"autoComplete_list":T,w=void 0===(O=P.className)?"autoComplete_list":O,L=void 0!==(C=P.navigation)&&C,S=void 0!==(D=e.sort)&&D,E=e.placeHolder,x=void 0===(R=e.maxResults)?5:R,O=void 0!==(T=(F=void 0===(F=e.resultItem)?{}:F).content)&&T,C=void 0===(P=F.element)?"li":P,R=void 0===(D=F.idName)?"autoComplete_result":D,P=void 0===(T=F.className)?"autoComplete_result":T,D=e.noResults,T=void 0!==(F=e.highlight)&&F,F=e.feedback;e=e.onSelection;this.name=t,this.selector=n,this.observer=i,this.data={src:s,key:r,cache:o,store:a,results:u},this.query=l,this.trigger={event:h,condition:d},this.searchEngine=f,this.diacritics=m,this.threshold=p,this.debounce=v,this.resultsList={render:g,container:y,destination:_||this.selector,position:I,element:b,idName:k,className:w,navigation:L},this.sort=S,this.placeHolder=E,this.maxResults=x,this.resultItem={content:O,element:C,idName:R,className:P},this.noResults=D,this.highlight=T,this.feedback=F,this.onSelection=e,this.inputField="string"==typeof this.selector?document.querySelector(this.selector):this.selector(),this.observer?this.preInit():this.init()}return e=[{key:"start",value:function(e,t){var n=this,s=this.data.results?this.data.results(l(this,t)):l(this,t);t={input:e,query:t,matches:s,results:s.slice(0,this.maxResults)};return u(this.inputField,t,"results"),s.length?this.resultsList.render?(s.length&&a(this,t,s),u(this.inputField,t,"rendered"),function(e,t){function n(e,n,o,a){e.preventDefault(),o?s++:s--,r(n),a.inputField.setAttribute("aria-activedescendant",n[s].id),u(e.srcElement,i(i({event:e},t),{},{selection:t.results[s]}),"navigation")}var s=-1,r=function(e){if(!e)return!1;!function(e){for(var t=0;t<e.length;t++)e[t].removeAttribute("aria-selected"),e[t].classList.remove("autoComplete_selected")}(e),e[s=(s=s>=e.length?0:s)<0?e.length-1:s].setAttribute("aria-selected","true"),e[s].classList.add("autoComplete_selected")},a=e.resultsList.navigation||function(t){var i=document.getElementById(e.resultsList.idName);if(!i)return e.inputField.removeEventListener("keydown",a);i=i.getElementsByTagName(e.resultItem.element),27===t.keyCode?(e.inputField.value="",o(e)):40===t.keyCode||9===t.keyCode?n(t,i,!0,e):38===t.keyCode||9===t.keyCode?n(t,i,!1,e):13===t.keyCode&&(t.preventDefault(),-1<s&&i&&i[s].click())};e.inputField.autoCompleteNavigate&&e.inputField.removeEventListener("keydown",e.inputField.autoCompleteNavigate),e.inputField.autoCompleteNavigate=a,e.inputField.addEventListener("keydown",a)}(this,t),void document.addEventListener("click",(function(e){return o(n,e.target)}))):this.feedback(t):this.noResults?this.noResults(t,a):null}},{key:"dataStore",value:function(){var e=this;return new Promise((function(t,n){return e.data.cache&&e.data.store?t(null):new Promise((function(t,n){return"function"==typeof e.data.src?e.data.src().then(t,n):t(e.data.src)})).then((function(i){try{return e.data.store=i,u(e.inputField,e.data.store,"fetch"),t()}catch(e){return n(e)}}),n)}))}},{key:"compose",value:function(){var e=this;return new Promise((function(t,n){var i,s,r,a,u=function(){return t()};return a=e.inputField,r=i=(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement?a.value:a.innerHTML).toLowerCase(),s=(a=e).query&&a.query.manipulate?a.query.manipulate(r):a.diacritics?r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC"):r,a=s,((r=e).trigger.condition?r.trigger.condition(a):a.length>=r.threshold&&a.replace(/ /g,"").length)?e.dataStore().then((function(t){try{return o(e),e.start(i,s),u.call(e)}catch(e){return n(e)}}),n):(o(e),u.call(e))}))}},{key:"init",value:function(){var e,t,n,i,s=this;(e=this).inputField.setAttribute("type","text"),e.inputField.setAttribute("role","combobox"),e.inputField.setAttribute("aria-haspopup",!0),e.inputField.setAttribute("aria-expanded",!1),e.inputField.setAttribute("aria-controls",e.resultsList.idName),e.inputField.setAttribute("aria-autocomplete","both"),this.placeHolder&&this.inputField.setAttribute("placeholder",this.placeHolder),this.hook=(t=function(){s.compose()},n=this.debounce,function(){var e=this,s=arguments;clearTimeout(i),i=setTimeout((function(){return t.apply(e,s)}),n)}),this.trigger.event.forEach((function(e){s.inputField.removeEventListener(e,s.hook),s.inputField.addEventListener(e,s.hook)})),u(this.inputField,null,"init")}},{key:"preInit",value:function(){var e=this;new MutationObserver((function(t,n){var i,s=r(t);try{for(s.s();!(i=s.n()).done;)i.value,e.inputField&&(n.disconnect(),u(e.inputField,null,"connect"),e.init())}catch(e){s.e(e)}finally{s.f()}})).observe(document,{childList:!0,subtree:!0})}},{key:"unInit",value:function(){this.inputField.removeEventListener("input",this.hook),u(this.inputField,null,"unInit")}}],t(c.prototype,e),c},"object"==typeof s?s=i():"function"==typeof define&&define.amd?define(i):(n="undefined"!=typeof globalThis?globalThis:n||self).autoComplete=i();var g,y={},_="object"==typeof Reflect?Reflect:null,I=_&&"function"==typeof _.apply?_.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};g=_&&"function"==typeof _.ownKeys?_.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var b=Number.isNaN||function(e){return e!=e};function k(){k.init.call(this)}(y=k).once=function(e,t){return new Promise((function(n,i){var s=function(n){e.removeListener(t,r),i(n)},r=function(){"function"==typeof e.removeListener&&e.removeListener("error",s),n([].slice.call(arguments))};D(e,t,r,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&D(e,"error",t,n)}(e,s,{once:!0})}))},k.EventEmitter=k,k.prototype._events=void 0,k.prototype._eventsCount=0,k.prototype._maxListeners=void 0;var w=10;function L(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+(void 0===e?"undefined":d(e)))}function S(e){return void 0===e._maxListeners?k.defaultMaxListeners:e._maxListeners}function E(e,t,n,i){var s,r,o,a;if(L(n),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),r=e._events),o=r[t]),void 0===o)o=r[t]=n,++e._eventsCount;else if("function"==typeof o?o=r[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(s=S(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return e}function x(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function O(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},s=x.bind(i);return s.listener=n,i.wrapFn=s,s}function C(e,t,n){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?n?[s.listener||s]:[s]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(s):P(s,s.length)}function R(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function P(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function D(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+(void 0===e?"undefined":d(e)));e.addEventListener(t,(function s(r){i.once&&e.removeEventListener(t,s),n(r)}))}}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");w=e}}),k.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||b(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},k.prototype.getMaxListeners=function(){return S(this)},k.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(r=t[0]),r instanceof Error)throw r;var o=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw o.context=r,o}var a=s[e];if(void 0===a)return!1;if("function"==typeof a)I(a,this,t);else{var u=a.length,l=P(a,u);for(n=0;n<u;++n)I(l[n],this,t)}return!0},k.prototype.addListener=function(e,t){return E(this,e,t,!1)},k.prototype.on=k.prototype.addListener,k.prototype.prependListener=function(e,t){return E(this,e,t,!0)},k.prototype.once=function(e,t){return L(t),this.on(e,O(this,e,t)),this},k.prototype.prependOnceListener=function(e,t){return L(t),this.prependListener(e,O(this,e,t)),this},k.prototype.removeListener=function(e,t){var n,i,s,r,o;if(L(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(s=-1,r=n.length-1;r>=0;r--)if(n[r]===t||n[r].listener===t){o=n[r].listener,s=r;break}if(s<0)return this;0===s?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,s),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},k.prototype.off=k.prototype.removeListener,k.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var s,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(s=r[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},k.prototype.listeners=function(e){return C(this,e,!0)},k.prototype.rawListeners=function(e){return C(this,e,!1)},k.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):R.call(e,t)},k.prototype.listenerCount=R,k.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};var T={},F=/[\\^$.*+?()[\]{}|]/g,j=RegExp(F.source),N=document.createElement("div"),A={containerTokenfield:'<div class="tokenfield tokenfield-mode-tokens">\n      <input class="tokenfield-copy-helper"\n        style="display:none;position:fixed;top:-1000px;right:1000px;"\n        tabindex="-1"\n        type="text"\n      />\n      <div class="tokenfield-set">\n        <ul></ul>\n      </div>\n      <input class="tokenfield-input" />\n      <div class="tokenfield-suggest">\n        <ul class="tokenfield-suggest-list"></ul>\n      </div>\n    </div>',containerList:'<div class="tokenfield tokenfield-mode-list">\n      <input class="tokenfield-input" />\n      <div class="tokenfield-suggest">\n        <ul class="tokenfield-suggest-list"></ul>\n      </div>\n      <div class="tokenfield-set">\n        <ul></ul>\n      </div>\n    </div>',suggestItem:'<li class="tokenfield-suggest-item"></li>',setItem:'<li class="tokenfield-set-item">\n      <span class="item-label"></span>\n      <a href="#" class="item-remove" tabindex="-1">×</a>\n      <input class="item-input" type="hidden" />\n    </li>'};function M(){return(65536*(1+Math.random())|0).toString(16)+(65536*(1+Math.random())|0).toString(16)}function H(e,t){return e.indexOf(t)>=0}function q(e){return e.nodeName?e:"string"==typeof e?document.querySelector(e):null}function z(e,t){return e.nodeName?e:(e=e.replace(/(\t|\n$)/g,""),N.innerHTML="",N.innerHTML=e,!0===t?N.childNodes:N.childNodes[0])}function B(e){return e.key||e.keyIdentifier?e.key||String.fromCharCode(parseInt(e.keyIdentifier.substr(2),16)):null}var U=function(e){"use strict";c(l,e);var t,n,i,s=v(l);function l(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,l),e=s.call(this);var n={_defaults:{focusedItem:null,cache:{},timer:null,xhr:null,suggested:!1,suggestedItems:[],setItems:[],events:{},delimiters:{}},_options:{el:null,form:!0,mode:"tokenfield",addItemOnBlur:!1,addItemsOnPaste:!1,keepItemsOrder:!0,setItems:[],items:[],newItems:!0,multiple:!0,maxItems:0,minLength:0,keys:{17:"ctrl",16:"shift",91:"meta",8:"delete",27:"esc",37:"left",38:"up",39:"right",40:"down",46:"delete",65:"select",67:"copy",88:"cut",9:"delimiter",13:"delimiter",108:"delimiter"},matchRegex:"{value}",matchFlags:"i",matchStart:!1,matchEnd:!1,delimiters:[],copyProperty:"name",copyDelimiter:", ",remote:{type:"GET",url:null,queryParam:"q",delay:300,timestampParam:"t",params:{},headers:{}},placeholder:null,inputType:"text",minChars:2,maxSuggest:10,maxSuggestWindow:10,filterSetItems:!0,filterMatchCase:!1,singleInput:!1,singleInputValue:"id",singleInputDelimiter:", ",itemLabel:"name",itemName:"items",newItemName:"items_new",itemValue:"id",newItemValue:"name",itemData:"name",validateNewItem:null}},i=n._defaults,a=n._options;e.id=M(),e.key="key_".concat(e.id),e._vars=Object.assign({},i),e._options=Object.assign({},a,t),e._options.keys=Object.assign({},a.keys,t.keys),e._options.remote=Object.assign({},a.remote,t.remote),e._templates=Object.assign({},A,t.templates),e._vars.setItems=e._prepareData(e.remapData(e._options.setItems||[])),e._focused=!1,e._input=null,e._form=!1,e._html={};var u=e._options;u.delimiters.forEach((function(t){e._vars.delimiters[t]=!0}));var c=q(u.el);if(!c)throw new Error("Selector: DOM Element ".concat(u.el," not found."));if(e.el=c,u.singleInput){var h=q(u.singleInput);e._input=h||e.el}if(e.el.tokenfield=r(e),null===u.placeholder&&(u.placeholder=u.el.placeholder||""),!u.form)throw new Error("Cannot create tokenfield without DOM Element.");var d=!1;if(u.form.nodeName)d=u.form;else if(!0===u.form)for(var f=e.el;f.parentNode;){if("FORM"===f.nodeName){d=f;break}f=f.parentNode}else if("string"==typeof d&&!(d=document.querySelector(d)))throw new Error("Selector: DOM Element ".concat(u.form," not found."));return e._form=d,T[e.id]=r(e),e._render(),e}return t=l,n=[{key:"_render",value:function(){var e=this._options,t=this._html;return"tokenfield"===e.mode?t.container=z(this._templates.containerTokenfield):t.container=z(this._templates.containerList),t.suggest=t.container.querySelector(".tokenfield-suggest"),t.suggestList=t.container.querySelector(".tokenfield-suggest-list"),t.items=t.container.querySelector(".tokenfield-set > ul"),t.input=t.container.querySelector(".tokenfield-input"),t.input.setAttribute("type",e.inputType),"tokenfield"===e.mode?t.input.placeholder=this._vars.setItems.length?"":e.placeholder:t.input.placeholder=e.placeholder,t.copyHelper=t.container.querySelector(".tokenfield-copy-helper"),e.el.style.display="none",t.suggest.style.display="none",this._renderSizer(),t.container.tokenfield=this,e.el.parentElement.insertBefore(t.container,e.el),t.container.insertBefore(e.el,t.container.firstChild),this._setEvents(),this._renderItems(),"tokenfield"===e.mode&&this._resizeInput(),this}},{key:"_renderSizer",value:function(){var e=this._html,t=this._getBounds(),n=window.getComputedStyle(e.container),i=parseInt(n.paddingLeft,10)+parseInt(n.paddingRight,10),s={width:"auto",height:"auto",overflow:"hidden",whiteSpace:"pre",maxWidth:t.width-i+"px",position:"fixed",top:"-10000px",left:"10000px",fontSize:n.fontSize,paddingLeft:n.paddingLeft,paddingRight:n.paddingRight};for(var r in e.sizer=document.createElement("div"),e.sizer.id="tokenfield-sizer-"+this.id,s)e.sizer.style[r]=s[r];e.container.appendChild(e.sizer)}},{key:"_minimizeInput",value:function(){return this._html.input.style.width="20px",this}},{key:"_refreshInput",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this._vars,n=this._html;if(e&&(n.input.value=""),"tokenfield"===this._options.mode){this._resizeInput();var i=t.setItems.length?"":this._options.placeholder;n.input.setAttribute("placeholder",i)}else"list"===this._options.mode&&n.input.setAttribute("placeholder",this._options.placeholder);return this}},{key:"_resizeInput",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this._html,n=this._getBounds(),i=window.getComputedStyle(t.container),s=parseInt(i.paddingRight,10)+parseInt(i.borderRightWidth,10),r=s+parseInt(i.paddingLeft,10)+parseInt(i.borderLeftWidth,10);if(t.sizer.innerHTML=e,t.sizer.style.maxWidth=n.width-s+"px",0!==n.width){t.input.style.width="20px";var o=t.sizer.getBoundingClientRect(),a=t.input.getBoundingClientRect(),u=n.width-(a.left-n.left)-s;o.width>u?t.input.style.width=n.width-r-1+"px":t.input.style.width=u-1+"px"}else t.input.style.width="100%"}},{key:"_fetchData",value:function(e){var t=this,n=this._vars,i=this._options,s=i.remote,r=Object.assign({},i.params);for(var o in s.params)r[o]=s.params[o];s.limit&&(r[s.limit]=i.remote.limit),r[s.queryParam]=e,r[s.timestampParam]=Math.round((new Date).getTime()/1e3),n.xhr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=new XMLHttpRequest,s=t.url,r=[];for(var o in e)r.push("".concat(o,"=").concat(encodeURIComponent(e[o])));var a=r.join("&");for(var u in"get"===t.type.toLowerCase()&&(s+="?"+a),i.open(t.type,s,!0),t.headers){var l=t.headers[u];"function"==typeof l&&(l=l(e,t)),i.setRequestHeader(u,l)}return n&&(i.onreadystatechange=n),i.send(e),i}(r,i.remote,(function(){if(n.xhr&&4==n.xhr.readyState){if(200==n.xhr.status){var s=JSON.parse(n.xhr.responseText);n.cache[e]=s;var r=t._prepareData(t.remapData(s)),o=t._filterData(e,r);n.suggestedItems=i.filterSetItems?t._filterSetItems(o):o,t.showSuggestions()}else if(n.xhr.status>0)throw new Error("Error while loading remote data.");t._abortXhr()}}))}},{key:"remapData",value:function(e){return e}},{key:"_prepareData",value:function(e){var t=this;return e.map((function(e){return Object.assign({},e,u({},t.key,M()))}))}},{key:"_filterData",value:function(e,t){var n,i=this._options,s=i.matchRegex.replace("{value}",(n=function(e){if("string"==typeof e)return e;if(null===e)return"";var t=e+"";return"0"===t&&1/e==-1/0?"-0":t}(n=e))&&j.test(n)?n.replace(F,"\\$&"):n);i.matchStart?s="^"+s:i.matchEnd&&(s+="$");var r=new RegExp(s,i.matchFlags);return t.filter((function(e){return r.test(e[i.itemData])}))}},{key:"_abortXhr",value:function(){var e=this._vars;null!==e.xhr&&(e.xhr.abort(),e.xhr=null)}},{key:"_filterSetItems",value:function(e){var t=this._options.itemValue,n=this._vars;if(!n.setItems.length)return e;var i=n.setItems.map((function(e){return e[t]}));return e.filter((function(e){return-1===i.indexOf(e[t])}))}},{key:"_setEvents",value:function(){var e=this._vars,t=this._html;e.events.onClick=this._onClick.bind(this),e.events.onMouseDown=this._onMouseDown.bind(this),e.events.onMouseOver=this._onMouseOver.bind(this),e.events.onFocus=this._onFocus.bind(this),e.events.onResize=this._onResize.bind(this),e.events.onReset=this._onReset.bind(this),e.events.onKeyDown=this._onKeyDown.bind(this),e.events.onFocusOut=this._onFocusOut.bind(this),t.container.addEventListener("click",e.events.onClick),1===Object.keys(T).length&&(document.addEventListener("mousedown",e.events.onMouseDown),window.addEventListener("resize",e.events.onResize)),this._form&&this._form.nodeName&&this._form.addEventListener("reset",e.events.onReset),t.suggestList.addEventListener("mouseover",e.events.onMouseOver),t.input.addEventListener("focus",e.events.onFocus)}},{key:"_onMouseOver",value:function(e){var t=e.target;t.classList.contains("tokenfield-suggest-item")&&([].slice.call(this._html.suggestList.querySelectorAll(".selected")).forEach((function(e){e!==t&&e.classList.remove("selected")})),t.classList.add("selected"),this._selectItem(t.key,!1),this._refreshItemsSelection())}},{key:"_onReset",value:function(){this.setItems(this._options.setItems)}},{key:"_onFocus",value:function(){var e=this._vars,t=this._html,n=this._options;t.input.removeEventListener("keydown",e.events.onKeyDown),t.input.addEventListener("keydown",e.events.onKeyDown),t.input.addEventListener("focusout",e.events.onFocusOut),n.addItemsOnPaste&&(e.events.onPaste=this._onPaste.bind(this),t.input.addEventListener("paste",e.events.onPaste)),this._focused=!0,this._html.container.classList.add("focused"),this._resizeInput(),t.input.value.trim().length>=n.minChars&&this.showSuggestions()}},{key:"_onFocusOut",value:function(e){var t=this._vars,n=this._options,i=this._html;if(i.input.removeEventListener("keydown",t.events.onKeyDown),i.input.removeEventListener("focusout",t.events.onFocusOut),void 0!==t.events.onPaste&&i.input.removeEventListener("paste",t.events.onPaste),!e.relatedTarget||e.relatedTarget!==i.copyHelper){var s=n.multiple&&!n.maxItems||!n.multiple&&!t.setItems.length||n.multiple&&n.maxItems&&t.setItems.length<n.maxItems;this._focused&&n.addItemOnBlur&&s&&this._newItem(i.input.value)?this._renderItems()._refreshInput():this._defocusItems()._renderItems(),this._focused=!1,this._html.container.classList.remove("focused")}}},{key:"_onMouseDown",value:function(e){var t=null;for(var n in T)if(T[n]._html.container.contains(e.target)){t=T[n];break}if(t){for(var i in T)i!==t.id&&(T[i].hideSuggestions(),T[i].blur());e.target!==t._html.input&&e.preventDefault()}else for(var s in T)T[s].hideSuggestions(),T[s].blur()}},{key:"_onResize",value:function(){for(var e in T)T[e]._resizeInput(T[e]._html.input.value)}},{key:"_onPaste",value:function(e){var t=this,n=this._vars,i=this._options,s=e.clipboardData.getData("text"),r=[s];if(i.delimiters.length){var o=i.delimiters.join("|"),a=new RegExp("(".concat(o,")"),"ig");r=s.split(a)}if(r.map((function(e){return e.trim()})).filter((function(e){return e.length>0&&e.length>=i.minLength&&void 0===n.delimiters[e]})).map((function(e){return t._newItem(e)})).length){var u=this;setTimeout((function(){u._renderItems()._refreshInput()._deselectItems().hideSuggestions()}),1),e.preventDefault()}}},{key:"_onKeyDown",value:function(e){var t=this,n=this._vars,i=this._options,s=this._html;i.maxItems&&n.setItems.length>=i.maxItems&&e.preventDefault(),"tokenfield"===i.mode&&setTimeout((function(){t._resizeInput(s.input.value)}),1);var r=B(e);if(void 0!==i.keys[e.keyCode]||H(i.delimiters,r)){if(this._keyAction(e))return!0}else this._defocusItems()._refreshItems();clearTimeout(n.timer),this._abortXhr(),(!i.maxItems||n.setItems.length<i.maxItems)&&setTimeout((function(){t._keyInput(e)}),1)}},{key:"_keyAction",value:function(e){this.key;var t=null,n=this._vars,i=this._options,s=this._html,r=i.keys[e.keyCode],o=s.input.value.trim(),a=B(e);H(i.delimiters,a)&&void 0===r&&(r="delimiter");var u=this._getSelectedItems();switch(u.length&&(t=u[0]),r){case"esc":this._deselectItems()._defocusItems()._renderItems().hideSuggestions();break;case"up":this._vars.suggested&&(this._selectPrevItem()._refreshItemsSelection(),e.preventDefault()),this._defocusItems()._renderItems();break;case"down":this._vars.suggested&&(this._selectNextItem()._refreshItemsSelection(),e.preventDefault()),this._defocusItems()._renderItems();break;case"left":(this.getFocusedItems().length||!s.input.selectionStart&&!s.input.selectionEnd)&&(this._focusPrevItem(e.shiftKey),e.preventDefault());break;case"right":(this.getFocusedItems().length||s.input.selectionStart===o.length)&&(this._focusNextItem(e.shiftKey),e.preventDefault());break;case"delimiter":if(this._abortXhr(),this._defocusItems(),!i.multiple&&n.setItems.length>=1)return!1;o=this.onInput(o,e),t?this._addItem(t):o.length&&(t=this._newItem(o)),t&&this._minimizeInput()._renderItems().focus()._refreshInput()._refreshSuggestions()._deselectItems(),e.preventDefault();break;case"select":if(o.length||!e.ctrlKey&&!e.metaKey)return!1;this._vars.setItems.forEach((function(e){e.focused=!0})),this._refreshItems();break;case"cut":if(!this.getFocusedItems().length||!e.ctrlKey&&!e.metaKey)return!1;this._copy()._delete(e);break;case"copy":if(!this.getFocusedItems().length||!e.ctrlKey&&!e.metaKey)return!1;this._copy();break;case"delete":var l=this;this._abortXhr();var c=this.getFocusedItems();!s.input.selectionEnd&&8===e.keyCode||s.input.selectionStart===o.length&&46===e.keyCode||c.length?this._delete(e):n.timer=setTimeout((function(){l._keyInput(e)}),i.delay)}return!0}},{key:"_copy",value:function(){var e=this._options,t=this._html,n=this.getFocusedItems().map((function(t){return t[e.copyProperty]})).join(e.copyDelimiter);return t.copyHelper.style.display="block",t.copyHelper.value=n,t.copyHelper.focus(),t.copyHelper.select(),document.execCommand("copy"),t.copyHelper.style.display="none",t.copyHelper.value="",t.input.focus(),this}},{key:"_delete",value:function(e){var t=this._vars,n=this._options,i=this.key,s=this._html,r=this.getFocusedItems();if("tokenfield"===n.mode&&t.setItems.length)if(r.length){var o=this;r.forEach((function(e){o._removeItem(e[i])})),this._refreshSuggestions()._keyInput(e)}else s.input.selectionStart||this._focusItem(t.setItems[t.setItems.length-1][i]);else if(r.length){var a=this;r.forEach((function(e){a._removeItem(e[i])})),this._refreshSuggestions()._keyInput(e)}return this._minimizeInput()._renderItems()._refreshInput(!1),this}},{key:"_keyInput",value:function(e){var t=this._vars,n=this._options,i=this._html;this._defocusItems()._refreshItems();var s=this.onInput(i.input.value.trim(),e);if("keydown"===e.type&&this.emit("input",this,s,e),s.length<n.minChars)return this.hideSuggestions(),!1;if(!n.multiple&&t.setItems.length>=1)return!1;if(void 0===t.cache[s]){var r=this;if(n.remote.url)t.timer=setTimeout((function(){r._fetchData(s)}),n.delay);else if(!n.remote.url&&n.items.length){var o=this._prepareData(n.items),a=this._filterData(s,o);t.suggestedItems=n.filterSetItems?this._filterSetItems(a):a,this.showSuggestions()}}else{var u=this._prepareData(this.remapData(t.cache[s])),l=this._filterData(s,u);t.suggestedItems=n.filterSetItems?this._filterSetItems(l):l,this.showSuggestions()}return this}},{key:"_onClick",value:function(e){var t=e.target;if(t.classList.contains("item-remove"))e.preventDefault(),this._removeItem(t.key)._defocusItems()._minimizeInput()._renderItems()._refreshInput(!1)._keyInput(e);else if(t.classList.contains("tokenfield-suggest-item")){var n=this._getSuggestedItem(t.key);this._addItem(n)._minimizeInput()._renderItems()._refreshInput()._refreshSuggestions()}else{var i=function(e){for(var t=[e];e.parentNode;)e=e.parentNode,t.push(e);return t}(t).filter((function(e){return e.classList&&e.classList.contains("tokenfield-set-item")}))[0];i?(this._focusItem(i.key,e.shiftKey,e.ctrlKey||e.metaKey,!0),this._refreshItems()):this._keyInput(e)}this.focus()}},{key:"_selectPrevItem",value:function(){var e=this.key,t=this._options,n=this._vars.suggestedItems,i=this._getSelectedItemIndex();return n.length?(null!==i?0===i?t.newItems?this._deselectItems():this._selectItem(n[n.length-1][e]):this._selectItem(n[i-1][e]):this._selectItem(n[n.length-1][e]),this):this}},{key:"_selectNextItem",value:function(){var e=this.key,t=this._options,n=this._vars.suggestedItems,i=this._getSelectedItemIndex();return n.length?(null!==i?i===n.length-1?t.newItems?this._deselectItems():this._selectItem(n[0][e]):this._selectItem(n[i+1][e]):this._selectItem(n[0][e]),this):this}},{key:"_focusPrevItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.key,n=this._vars.setItems,i=this._getFocusedItemIndex();if(!n.length)return this;if(null!==i)if(0!==i||e)if(0===i&&e){var s=this._getFocusedItemIndex(!0);this._defocusItem(n[s][t])}else this._focusItem(n[i-1][t],e,!1,!0);else this._defocusItems();else this._focusItem(n[n.length-1][t],!1,!1,!0);return this._refreshItems(),this}},{key:"_focusNextItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.key,n=this._vars.setItems,i=this._getFocusedItemIndex(!0);return n.length?(null!==i?i!==n.length-1||e?i===n.length-1&&e?this._focusItem(n[0][t],e):this._focusItem(n[i+1][t],e):this._defocusItems():this._focusItem(n[0][t],!1),this._refreshItems(),this):this}},{key:"_getSelectedItems",value:function(){var e=this.key,t=this._vars.setItems.map((function(t){return t[e]}));return this._vars.suggestedItems.filter((function(n){return n.selected&&t.indexOf(n[e])<0}))}},{key:"_selectItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this;this._vars.suggestedItems.forEach((function(i){if(i.selected=i[n.key]===e,i.selected&&t){var s=parseInt(n._html.suggest.style.maxHeight,10);if(s){var r=n._html.suggestList.getBoundingClientRect(),o=i.el.getBoundingClientRect(),a=o.top-r.top,u=a+o.height;u>=s+n._html.suggest.scrollTop?n._html.suggest.scrollTop=u-s:a<n._html.suggest.scrollTop&&(n._html.suggest.scrollTop=a)}}}))}},{key:"_deselectItem",value:function(e){var t=this;return this._vars.suggestedItems.every((function(n){return n[t.key]!==e||(n.selected=!1,!1)})),this}},{key:"_deselectItems",value:function(){return this._vars.suggestedItems.forEach((function(e){e.selected=!1})),this}},{key:"_refreshItemsSelection",value:function(){this._vars.suggestedItems.forEach((function(e){e.selected&&e.el?e.el.classList.add("selected"):e.el&&e.el.classList.remove("selected")}))}},{key:"_getSelectedItemIndex",value:function(){var e=null;return this._vars.suggestedItems.every((function(t,n){return!t.selected||(e=n,!1)})),e}},{key:"_getFocusedItemIndex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=null;return this._vars.setItems.every((function(n,i){return!(n.focused&&(t=i,!e))})),t}},{key:"_getItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;null===t&&(t=this.key);var n=this._filterItems(this._vars.setItems,e,t);return n.length?n[0]:null}},{key:"_getSuggestedItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;null===t&&(t=this.key);var n=this._filterItems(this._vars.suggestedItems,e,t);return n.length?n[0]:null}},{key:"_getAvailableItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;null===t&&(t=this.key);var n=this._filterItems(this._options.items,e,t);return n.length?n[0]:null}},{key:"_filterItems",value:function(e,t,n){var i=this._options.filterMatchCase;return e.filter((function(e){return"string"==typeof e[n]&&"string"==typeof t?i?e[n]===t:e[n].toLowerCase()==t.toLowerCase():e[n]==t}))}},{key:"_removeItem",value:function(e){var t=this;return this._vars.setItems.every((function(n,i){return n[t.key]!==e||(t.emit("removeToken",t,n),t._vars.setItems.splice(i,1),t.emit("removedToken",t,n),t.emit("change",t),!1)})),this}},{key:"_addItem",value:function(e){e.focused=!1;var t=this._options;if((e.isNew&&!this._getItem(e[t.itemData],t.itemData)||!this._getItem(e[t.itemValue],t.itemValue))&&(this.emit("addToken",this,e),!this._options.maxItems||this._options.maxItems&&this._vars.setItems.length<this._options.maxItems)){e.selected=!1;var n=Object.assign({},e);this._vars.setItems.push(n),this.emit("addedToken",this,n),this.emit("change",this)}return this}},{key:"getFocusedItem",value:function(){var e=this._vars.setItems.filter((function(e){return e.focused}))[0];return e.length?e[0]:null}},{key:"getFocusedItems",value:function(){return this._vars.setItems.filter((function(e){return e.focused}))}},{key:"_focusItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=this;if(t){var r=this,o=null,a=null,u=null,l=this._vars.setItems.length;if(this._vars.setItems.forEach((function(t,n){t[r.key]===e&&(u=n),null===o&&t.focused&&(o=n),t.focused&&(a=n)})),(0===u||u===l-1)&&null===o&&null===a)return;null===o&&null===a?this._vars.setItems[u].focused=!0:0!==u||a!==l-1||i?(o=Math.min(u,o),a=Math.max(u,a),this._vars.setItems.forEach((function(e,t){e.focused=u===t||t>=o&&t<=a}))):this._vars.setItems[o].focused=!1}else this._vars.setItems.forEach((function(t){t.focused=n?t[s.key]===e?!t.focused:t.focused:t[s.key]===e}));return this}},{key:"_defocusItem",value:function(e){var t=this;return this._vars.setItems.filter((function(n){n[t.key]===e&&(n.focused=!1)}))}},{key:"_defocusItems",value:function(){return this._vars.setItems.forEach((function(e){e.focused=!1})),this}},{key:"_newItem",value:function(e){var t=this._options;if("string"==typeof e&&(!e.length||e.length<t.minLength))return null;var n=this._getItem(e,t.itemData)||this._getSuggestedItem(e,t.itemData)||this._getAvailableItem(e,t.itemData);if(!n&&t.newItems){if("function"==typeof t.validateNewItem&&!t.validateNewItem(e))return null;var i;u(i={isNew:!0},this.key,M()),u(i,t.itemData,e),n=i,this.emit("newToken",this,n)}return n?(this._addItem(n),n):null}},{key:"_buildEl",value:function(e){return z(e)}},{key:"_getBounds",value:function(){return this._html.container.getBoundingClientRect()}},{key:"_renderItems",value:function(){var e=this,t=this._vars,n=this._options,i=this._html;return i.items.innerHTML="",t.setItems.forEach((function(t,n){var s=e._renderItem(t,n);i.items.appendChild(s),t.el=s,t.focused?t.el.classList.add("focused"):t.el.classList.remove("focused")})),t.setItems.length>1&&"tokenfield"===n.mode?i.input.setAttribute("placeholder",""):"list"===n.mode&&i.input.setAttribute("placeholder",n.placeholder),this._input&&(this._input.value=t.setItems.map((function(e){return e[n.singleInputValue]})).join(n.singleInputDelimiter)),this}},{key:"_refreshItems",value:function(){this._vars.setItems.forEach((function(e){e.el&&(e.focused?e.el.classList.add("focused"):e.el.classList.remove("focused"))}))}},{key:"_renderItem",value:function(e,t){var n=this._options,i=this.renderSetItemHtml(e),s=i.querySelector(".item-label"),r=i.querySelector(".item-input"),o=i.querySelector(".item-remove"),a=n.keepItemsOrder?"[".concat(t,"]"):"[]";return i.key=e[this.key],o.key=e[this.key],r.setAttribute("name",(e.isNew?n.newItemName:n.itemName)+a),r.value=e[e.isNew?n.newItemValue:n.itemValue]||null,s.textContent=this.renderSetItemLabel(e),e.focused&&i.classList.add("focused"),i}},{key:"onInput",value:function(e,t){return e}},{key:"renderSetItemHtml",value:function(){return this._buildEl(this._templates.setItem)}},{key:"renderSetItemLabel",value:function(e){return e[this._options.itemLabel]}},{key:"renderSuggestions",value:function(e){var t=this,n=this._vars,i=this._options,s=this._html,r=this._getSelectedItemIndex();if(!e.length)return this;if(0===i.maxSuggestWindow&&(s.suggest.style.maxHeight=null),!n.suggestedItems.length)return this;i.newItems||null!==r||(e[0].selected=!0);var o=0;e.every((function(e,n){if(n>=i.maxSuggest)return!1;var r=s.suggestList.childNodes[n],a=e.el=t.renderSuggestedItem(e);return r?r.itemValue===e[i.itemValue]?(r.key=e[t.key],e.el=r):s.suggestList.replaceChild(a,r):r||s.suggestList.appendChild(a),i.maxSuggestWindow>0&&n<i.maxSuggestWindow&&(o+=s.suggestList.childNodes[n].getBoundingClientRect().height),i.maxSuggestWindow>0&&n===i.maxSuggestWindow&&(s.suggest.style.maxHeight=o+"px"),!0}));var a=s.suggestList.childElementCount-e.length;if(a>0)for(var u=a-1;u>=0;u--)s.suggestList.removeChild(s.suggestList.childNodes[e.length+u]);return this}},{key:"renderSuggestedItem",value:function(e){var t=this._options,n=this._buildEl(this._templates.suggestItem);return n.key=e[this.key],n.itemValue=e[t.itemValue],n.innerHTML=this.renderSuggestedItemContent(e),n.setAttribute("title",e[t.itemData]),e.selected&&n.classList.add("selected"),t.filterSetItems||(this._getItem(e[t.itemValue],t.itemValue)||this._getItem(e[t.itemData],t.itemData))&&n.classList.add("set"),n}},{key:"renderSuggestedItemContent",value:function(e){return e[this._options.itemData]}},{key:"_refreshSuggestions",value:function(){var e=this._vars,t=this._options;if(this._html.input.value.length<t.minChars)return this.hideSuggestions(),this;var n=this._prepareData(t.items),i=this._filterData(this._html.input.value,n);return e.suggestedItems=t.filterSetItems?this._filterSetItems(i):i,e.suggestedItems.length&&(!t.maxItems||t.maxItems&&e.setItems.length<t.maxItems)?(this.renderSuggestions(e.suggestedItems),this):(this.hideSuggestions(),this)}},{key:"showSuggestions",value:function(){var e=this._vars,t=this._options;return e.suggestedItems.length?(this.emit("showSuggestions",this),(!t.maxItems||t.maxItems&&e.setItems.length<t.maxItems)&&(this._html.suggest.style.display="block",e.suggested=!0,this.renderSuggestions(e.suggestedItems)),this.emit("shownSuggestions",this)):this.hideSuggestions(),this}},{key:"hideSuggestions",value:function(){return this.emit("hideSuggestions",this),this._vars.suggested=!1,this._html.suggest.style.display="none",this._html.suggestList.innerHTML="",this.emit("hiddenSuggestions",this),this}},{key:"setSuggestedItems",value:function(e){if(!Array.isArray(e))throw new Error("Argument must be an array of objects.");this._options.items=e,this._refreshSuggestions()}},{key:"getItems",value:function(){var e=this;return this._vars.setItems.map((function(t){var n=Object.assign({},t);return delete n[e.key],delete n.el,n}))}},{key:"setItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this._vars.setItems=[],this.addItems(e),this}},{key:"addItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=this,n=this._options.itemValue;return Array.isArray(e)||(e=[e]),this._prepareData(e).forEach((function(e){(e.isNew||void 0!==e[n])&&t._addItem(e)})),this._minimizeInput()._renderItems()._refreshInput().hideSuggestions(),this}},{key:"sortItems",value:function(){var e=this,t=[];h(this._html.items.childNodes).forEach((function(n){var i=e._getItem(n.key);i&&t.push(i)})),this.setItems(t)}},{key:"removeItem",value:function(e){var t=this._options;"object"==typeof e&&(e[t.itemValue]||e[t.newItemValue])&&(e=e[t.itemValue]||e[t.newItemValue]);var n=this._getItem(e,t.itemValue)||this._getItem(e,t.newItemValue);return n?(this._removeItem(n[this.key])._renderItems(),this):this}},{key:"emptyItems",value:function(){return this._vars.setItems=[],this._renderItems()._refreshInput().hideSuggestions(),this.emit("change",this),this}},{key:"getSuggestedItems",value:function(){return this._vars.suggestedItems.map((function(e){return Object.assign({},e)}))}},{key:"focus",value:function(){return this._html.container.classList.add("focused"),this._focused||this._html.input.focus(),this}},{key:"blur",value:function(){return this._html.container.classList.remove("focused"),this._focused&&this._html.input.blur(),this}},{key:"remove",value:function(){var e=this._html;e.container.parentElement.insertBefore(this.el,e.container),e.container.remove(),this.el.style.display="block",1===Object.keys(T).length&&(document.removeEventListener("mousedown",this._vars.events.onMouseDown),window.removeEventListener("resize",this._vars.events.onResize)),this._form&&this._form.nodeName&&this._form.removeEventListener("reset",this._vars.events.onReset),delete T[this.id],delete this.el.tokenfield}}],n&&a(t.prototype,n),i&&a(t,i),l}(e(y)),V=function(e){"use strict";c(n,e);var t=v(n);function n(){var e;return o(this,n),u(r(e=t.apply(this,arguments)),"_renderItem",(function(t,n){var i=e._options,s=e.renderSetItemHtml(t),r=s.querySelector(".item-label"),o=s.querySelector(".item-input"),a=s.querySelector(".item-remove");return s.key=t[e.key],a.key=t[e.key],o.setAttribute("name",t.isNew?i.newItemName:i.itemName),o.value=t[t.isNew?i.newItemValue:i.itemValue]||null,r.textContent=e.renderSetItemLabel(t),t.focused&&s.classList.add("focused"),s})),e}return n}(U);window.TokenField=V}();
  //# sourceMappingURL=review-good.js.map
  