/*
Tagify v4.27.0 - tags input component
By: Yair Even-Or <vsync.design@gmail.com>
https://github.com/yairEO/tagify

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

This Software may not be rebranded and sold as a library under any other name
other than "Tagify" (by owner) or as part of another library.
*/

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react/jsx-runtime"),require("react"),require("react-dom/server"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-dom/server","prop-types"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Tagify={},t.jsxRuntime,t.React,t.server,t.propTypes)}(this,(function(t,e,n,i,s){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=a(n),r="&#8203;";function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function d(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var c={isEnabled:function(){var t;return null===(t=window.TAGIFY_DEBUG)||void 0===t||t},log:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i;this.isEnabled()&&(i=console).log.apply(i,["[Tagify]:"].concat(d(e)))},warn:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i;this.isEnabled()&&(i=console).warn.apply(i,["[Tagify]:"].concat(d(e)))}},u=function(t,e,n,i){return t=""+t,e=""+e,i&&(t=t.trim(),e=e.trim()),n?t==e:t.toLowerCase()==e.toLowerCase()},g=function(t,e){return t&&Array.isArray(t)&&t.map((function(t){return h(t,e)}))};function h(t,e){var n,i={};for(n in t)e.indexOf(n)<0&&(i[n]=t[n]);return i}function p(t){var e=document.createElement("div");return t.replace(/\&#?[0-9a-z]+;/gi,(function(t){return e.innerHTML=t,e.innerText}))}function f(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild}function m(t,e){for(e=e||"previous";t=t[e+"Sibling"];)if(3==t.nodeType)return t}function v(t){return"string"==typeof t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/`|'/g,"&#039;"):t}function y(t){var e=Object.prototype.toString.call(t).split(" ")[1].slice(0,-1);return t===Object(t)&&"Array"!=e&&"Function"!=e&&"RegExp"!=e&&"HTMLUnknownElement"!=e}function b(t,e,n){var i,s;function a(t,e){for(var n in e)if(e.hasOwnProperty(n)){if(y(e[n])){y(t[n])?a(t[n],e[n]):t[n]=Object.assign({},e[n]);continue}if(Array.isArray(e[n])){t[n]=Object.assign([],e[n]);continue}t[n]=e[n]}}return i=t,(null!=(s=Object)&&"undefined"!=typeof Symbol&&s[Symbol.hasInstance]?s[Symbol.hasInstance](i):i instanceof s)||(t={}),a(t,e),n&&a(t,n),t}function w(){var t=[],e={},n=!0,i=!1,s=void 0;try{for(var a,o=arguments[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var r=a.value,l=!0,d=!1,c=void 0;try{for(var u,g=r[Symbol.iterator]();!(l=(u=g.next()).done);l=!0){var h=u.value;y(h)?e[h.value]||(t.push(h),e[h.value]=1):t.includes(h)||t.push(h)}}catch(t){d=!0,c=t}finally{try{l||null==g.return||g.return()}finally{if(d)throw c}}}}catch(t){i=!0,s=t}finally{try{n||null==o.return||o.return()}finally{if(i)throw s}}return t}function T(t){return String.prototype.normalize?"string"==typeof t?t.normalize("NFD").replace(/[\u0300-\u036f]/g,""):void 0:t}var O=function(){return/(?=.*chrome)(?=.*android)/i.test(navigator.userAgent)};function D(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(t){return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)}))}function x(t){return t&&t.classList&&t.classList.contains(this.settings.classNames.tag)}function S(t){return t&&t.closest(this.settings.classNames.tagSelector)}function E(t,e){var n=window.getSelection();return e=e||n.getRangeAt(0),"string"==typeof t&&(t=document.createTextNode(t)),e&&(e.deleteContents(),e.insertNode(t)),t}function I(t,e,n){return t?(e&&(t.__tagifyTagData=n?e:b({},t.__tagifyTagData||{},e)),t.__tagifyTagData):(c.warn("tag element doesn't exist",{tagElm:t,data:e}),e)}function M(t){if(t&&t.parentNode){var e=t,n=window.getSelection(),i=n.getRangeAt(0);n.rangeCount&&(i.setStartAfter(e),i.collapse(!0),n.removeAllRanges(),n.addRange(i))}}function N(t,e){t.forEach((function(t){if(I(t.previousSibling)||!t.previousSibling){var n=document.createTextNode("​");t.before(n),e&&M(n)}}))}var _={delimiters:",",pattern:null,tagTextProp:"value",maxTags:1/0,callbacks:{},addTagOnBlur:!0,addTagOn:["blur","tab","enter"],onChangeAfterBlur:!0,duplicates:!1,whitelist:[],blacklist:[],enforceWhitelist:!1,userInput:!0,focusable:!0,keepInvalidTags:!1,createInvalidTags:!0,mixTagsAllowedAfter:/,|\.|\:|\s/,mixTagsInterpolator:["[[","]]"],backspace:!0,skipInvalid:!1,pasteAsTags:!0,editTags:{clicks:2,keepInvalid:!0},transformTag:function(){},trim:!0,a11y:{focusableTags:!1},mixMode:{insertAfterTag:" "},autoComplete:{enabled:!0,rightKey:!1,tabKey:!1},classNames:{namespace:"tagify",mixMode:"tagify--mix",selectMode:"tagify--select",input:"tagify__input",focus:"tagify--focus",tagNoAnimation:"tagify--noAnim",tagInvalid:"tagify--invalid",tagNotAllowed:"tagify--notAllowed",scopeLoading:"tagify--loading",hasMaxTags:"tagify--hasMaxTags",hasNoTags:"tagify--noTags",empty:"tagify--empty",inputInvalid:"tagify__input--invalid",dropdown:"tagify__dropdown",dropdownWrapper:"tagify__dropdown__wrapper",dropdownHeader:"tagify__dropdown__header",dropdownFooter:"tagify__dropdown__footer",dropdownItem:"tagify__dropdown__item",dropdownItemActive:"tagify__dropdown__item--active",dropdownItemHidden:"tagify__dropdown__item--hidden",dropdownItemSelected:"tagify__dropdown__item--selected",dropdownInital:"tagify__dropdown--initial",tag:"tagify__tag",tagText:"tagify__tag-text",tagX:"tagify__tag__removeBtn",tagLoading:"tagify__tag--loading",tagEditing:"tagify__tag--editable",tagFlash:"tagify__tag--flash",tagHide:"tagify__tag--hide"},dropdown:{classname:"",enabled:2,maxItems:10,searchKeys:["value","searchBy"],fuzzySearch:!0,caseSensitive:!1,accentedSearch:!0,includeSelectedTags:!1,escapeHTML:!0,highlightFirst:!0,closeOnSelect:!0,clearOnSelect:!0,position:"all",appendTarget:null},hooks:{beforeRemoveTag:function(){return Promise.resolve()},beforePaste:function(){return Promise.resolve()},suggestionClick:function(){return Promise.resolve()},beforeKeyDown:function(){return Promise.resolve()}}};function A(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function C(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){A(t,e,n[e])}))}return t}function k(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t}var L={events:{binding:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.dropdown.events.callbacks,n=this.listeners.dropdown=this.listeners.dropdown||{position:this.dropdown.position.bind(this,null),onKeyDown:e.onKeyDown.bind(this),onMouseOver:e.onMouseOver.bind(this),onMouseLeave:e.onMouseLeave.bind(this),onClick:e.onClick.bind(this),onScroll:e.onScroll.bind(this)},i=t?"addEventListener":"removeEventListener";"manual"!=this.settings.dropdown.position&&(document[i]("scroll",n.position,!0),window[i]("resize",n.position),window[i]("keydown",n.onKeyDown)),this.DOM.dropdown[i]("mouseover",n.onMouseOver),this.DOM.dropdown[i]("mouseleave",n.onMouseLeave),this.DOM.dropdown[i]("mousedown",n.onClick),this.DOM.dropdown.content[i]("scroll",n.onScroll)},callbacks:{onKeyDown:function(t){var e=this;if(this.state.hasFocus&&!this.state.composing){var n=this.settings,i=this.DOM.dropdown.querySelector(n.classNames.dropdownItemActiveSelector),s=this.dropdown.getSuggestionDataByNode(i),a="mix"==n.mode,o="select"==n.mode;n.hooks.beforeKeyDown(t,{tagify:this}).then((function(r){switch(t.key){case"ArrowDown":case"ArrowUp":case"Down":case"Up":t.preventDefault();var l=e.dropdown.getAllSuggestionsRefs(),d="ArrowUp"==t.key||"Up"==t.key;i&&(i=e.dropdown.getNextOrPrevOption(i,!d)),i&&i.matches(n.classNames.dropdownItemSelector)||(i=l[d?l.length-1:0]),e.dropdown.highlightOption(i,!0);break;case"Escape":case"Esc":e.dropdown.hide();break;case"ArrowRight":if(e.state.actions.ArrowLeft||n.autoComplete.rightKey)return;case"Tab":var u=!n.autoComplete.rightKey||!n.autoComplete.tabKey;if(!a&&!o&&i&&u&&!e.state.editing&&s){t.preventDefault();var g=e.dropdown.getMappedValue(s);return e.input.autocomplete.set.call(e,g),!1}return!0;case"Enter":t.preventDefault(),n.hooks.suggestionClick(t,{tagify:e,tagData:s,suggestionElm:i}).then((function(){if(i)return e.dropdown.selectOption(i),i=e.dropdown.getNextOrPrevOption(i,!d),void e.dropdown.highlightOption(i);e.dropdown.hide(),a||e.addTags(e.state.inputText.trim(),!0)})).catch((function(t){return c.warn(t)}));break;case"Backspace":if(a||e.state.editing.scope)return;var h=e.input.raw.call(e);""!=h&&8203!=h.charCodeAt(0)||(!0===n.backspace?e.removeTags():"edit"==n.backspace&&setTimeout(e.editTag.bind(e),0))}}))}},onMouseOver:function(t){var e=t.target.closest(this.settings.classNames.dropdownItemSelector);this.dropdown.highlightOption(e)},onMouseLeave:function(t){this.dropdown.highlightOption()},onClick:function(t){var e=this;if(0==t.button&&t.target!=this.DOM.dropdown&&t.target!=this.DOM.dropdown.content){var n=t.target.closest(this.settings.classNames.dropdownItemSelector),i=this.dropdown.getSuggestionDataByNode(n);this.state.actions.selectOption=!0,setTimeout((function(){return e.state.actions.selectOption=!1}),50),this.settings.hooks.suggestionClick(t,{tagify:this,tagData:i,suggestionElm:n}).then((function(){n?e.dropdown.selectOption(n,t):e.dropdown.hide()})).catch((function(t){return c.warn(t)}))}},onScroll:function(t){var e=t.target,n=e.scrollTop/(e.scrollHeight-e.parentNode.clientHeight)*100;this.trigger("dropdown:scroll",{percentage:Math.round(n)})}}},refilter:function(t){t=t||this.state.dropdown.query||"",this.suggestedListItems=this.dropdown.filterListItems(t),this.dropdown.fill(),this.suggestedListItems.length||this.dropdown.hide(),this.trigger("dropdown:updated",this.DOM.dropdown)},getSuggestionDataByNode:function(t){for(var e,n=t&&t.getAttribute("value"),i=this.suggestedListItems.length;i--;){if(y(e=this.suggestedListItems[i])&&e.value==n)return e;if(e==n)return{value:e}}},getNextOrPrevOption:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.dropdown.getAllSuggestionsRefs(),i=n.findIndex((function(e){return e===t}));return e?n[i+1]:n[i-1]},highlightOption:function(t,e){var n,i=this.settings.classNames.dropdownItemActive;if(this.state.ddItemElm&&(this.state.ddItemElm.classList.remove(i),this.state.ddItemElm.removeAttribute("aria-selected")),!t)return this.state.ddItemData=null,this.state.ddItemElm=null,void this.input.autocomplete.suggest.call(this);n=this.dropdown.getSuggestionDataByNode(t),this.state.ddItemData=n,this.state.ddItemElm=t,t.classList.add(i),t.setAttribute("aria-selected",!0),e&&(t.parentNode.scrollTop=t.clientHeight+t.offsetTop-t.parentNode.clientHeight),this.settings.autoComplete&&(this.input.autocomplete.suggest.call(this,n),this.dropdown.position())},selectOption:function(t,e){var n=this,i=this.settings,s=i.dropdown,a=s.clearOnSelect,o=s.closeOnSelect;if(!t)return this.addTags(this.state.inputText,!0),void(o&&this.dropdown.hide());e=e||{};var r=t.getAttribute("value"),l="noMatch"==r,d="mix"==i.mode,c=this.suggestedListItems.find((function(t){var e;return(null!==(e=t.value)&&void 0!==e?e:t)==r}));if(this.trigger("dropdown:select",{data:c,elm:t,event:e}),r&&(c||l)){if(this.state.editing){var u=this.normalizeTags([c])[0];c=i.transformTag.call(this,u)||u,this.onEditTagDone(null,b({__isValid:!0},c))}else this[d?"addMixTags":"addTags"]([c||this.input.raw.call(this)],a);(d||this.DOM.input.parentNode)&&(setTimeout((function(){n.DOM.input.focus(),n.toggleFocusClass(!0)})),o&&setTimeout(this.dropdown.hide.bind(this)),t.addEventListener("transitionend",(function(){n.dropdown.fillHeaderFooter(),setTimeout((function(){t.remove(),n.dropdown.refilter()}),100)}),{once:!0}),t.classList.add(this.settings.classNames.dropdownItemHidden))}else o&&setTimeout(this.dropdown.hide.bind(this))},selectAll:function(t){this.suggestedListItems.length=0,this.dropdown.hide(),this.dropdown.filterListItems("");var e=this.dropdown.filterListItems("");return t||(e=this.state.dropdown.suggestions),this.addTags(e,!0),this},filterListItems:function(t,e){var n,i,s,a,o,r,l=function(){var t,l,d=void 0,c=void 0;t=p[b],i=(null!=(l=Object)&&"undefined"!=typeof Symbol&&l[Symbol.hasInstance]?l[Symbol.hasInstance](t):t instanceof l)?p[b]:{value:p[b]};var f,m=!Object.keys(i).some((function(t){return v.includes(t)}))?["value"]:v;u.fuzzySearch&&!e.exact?(a=m.reduce((function(t,e){return t+" "+(i[e]||"")}),"").toLowerCase().trim(),u.accentedSearch&&(a=T(a),r=T(r)),d=0==a.indexOf(r),c=a===r,f=a,s=r.toLowerCase().split(" ").every((function(t){return f.includes(t.toLowerCase())}))):(d=!0,s=m.some((function(t){var n=""+(i[t]||"");return u.accentedSearch&&(n=T(n),r=T(r)),u.caseSensitive||(n=n.toLowerCase()),c=n===r,e.exact?n===r:0==n.indexOf(r)}))),o=!u.includeSelectedTags&&n.isTagDuplicate(y(i)?i.value:i),s&&!o&&(c&&d?h.push(i):"startsWith"==u.sortby&&d?g.unshift(i):g.push(i))},d=this,c=this.settings,u=c.dropdown,g=(e=e||{},[]),h=[],p=c.whitelist,f=u.maxItems>=0?u.maxItems:1/0,m=u.includeSelectedTags||"select"==c.mode,v=u.searchKeys,b=0;if(!(t="select"==c.mode&&this.value.length&&this.value[0][c.tagTextProp]==t?"":t)||!v.length)return g=m?p:p.filter((function(t){return!d.isTagDuplicate(y(t)?t.value:t)})),this.state.dropdown.suggestions=g,g.slice(0,f);for(r=u.caseSensitive?""+t:(""+t).toLowerCase();b<p.length;b++)n=this,l();return this.state.dropdown.suggestions=h.concat(g),"function"==typeof u.sortby?u.sortby(h.concat(g),r):h.concat(g).slice(0,f)},getMappedValue:function(t){var e=this.settings.dropdown.mapValueTo;return e?"function"==typeof e?e(t):t[e]||t.value:t.value},createListHTML:function(t){var e=this;return b([],t).map((function(t,n){"string"!=typeof t&&"number"!=typeof t||(t={value:t});var i=e.dropdown.getMappedValue(t);return i="string"==typeof i&&e.settings.dropdown.escapeHTML?v(i):i,e.settings.templates.dropdownItem.apply(e,[k(C({},t),{mappedValue:i}),e])})).join("")}};function j(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function P(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V(t){return function(t){if(Array.isArray(t))return j(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return j(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return j(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(){for(var t in this.dropdown={},this._dropdown)this.dropdown[t]="function"==typeof this._dropdown[t]?this._dropdown[t].bind(this):this._dropdown[t];this.dropdown.refs(),this.DOM.dropdown.__tagify=this}var F,H,B,U=(F=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){P(t,e,n[e])}))}return t}({},L),H=null!=(H={refs:function(){this.DOM.dropdown=this.parseTemplate("dropdown",[this.settings]),this.DOM.dropdown.content=this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-wrapper']")},getHeaderRef:function(){return this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-header']")},getFooterRef:function(){return this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-footer']")},getAllSuggestionsRefs:function(){return V(this.DOM.dropdown.content.querySelectorAll(this.settings.classNames.dropdownItemSelector))},show:function(t){var e,n,i,s=this,a=this.settings,o="mix"==a.mode&&!a.enforceWhitelist,r=!a.whitelist||!a.whitelist.length,l="manual"==a.dropdown.position;if(t=void 0===t?this.state.inputText:t,!(r&&!o&&!a.templates.dropdownItemNoMatch||!1===a.dropdown.enable||this.state.isLoading||this.settings.readonly)){if(clearTimeout(this.dropdownHide__bindEventsTimeout),this.suggestedListItems=this.dropdown.filterListItems(t),t&&!this.suggestedListItems.length&&(this.trigger("dropdown:noMatch",t),a.templates.dropdownItemNoMatch&&(i=a.templates.dropdownItemNoMatch.call(this,{value:t}))),!i){if(this.suggestedListItems.length)t&&o&&!this.state.editing.scope&&!u(this.suggestedListItems[0].value,t)&&this.suggestedListItems.unshift({value:t});else{if(!t||!o||this.state.editing.scope)return this.input.autocomplete.suggest.call(this),void this.dropdown.hide();this.suggestedListItems=[{value:t}]}n=""+(y(e=this.suggestedListItems[0])?e.value:e),a.autoComplete&&n&&0==n.indexOf(t)&&this.input.autocomplete.suggest.call(this,e)}this.dropdown.fill(i),a.dropdown.highlightFirst&&this.dropdown.highlightOption(this.DOM.dropdown.content.querySelector(a.classNames.dropdownItemSelector)),this.state.dropdown.visible||setTimeout(this.dropdown.events.binding.bind(this)),this.state.dropdown.visible=t||!0,this.state.dropdown.query=t,this.setStateSelection(),l||setTimeout((function(){s.dropdown.position(),s.dropdown.render()})),setTimeout((function(){s.trigger("dropdown:show",s.DOM.dropdown)}))}},hide:function(t){var e=this,n=this.DOM,i=n.scope,s=n.dropdown,a="manual"==this.settings.dropdown.position&&!t;if(s&&document.body.contains(s)&&!a)return window.removeEventListener("resize",this.dropdown.position),this.dropdown.events.binding.call(this,!1),i.setAttribute("aria-expanded",!1),s.parentNode.removeChild(s),setTimeout((function(){e.state.dropdown.visible=!1}),100),this.state.dropdown.query=this.state.ddItemData=this.state.ddItemElm=this.state.selection=null,this.state.tag&&this.state.tag.value.length&&(this.state.flaggedTags[this.state.tag.baseOffset]=this.state.tag),this.trigger("dropdown:hide",s),this},toggle:function(t){this.dropdown[this.state.dropdown.visible&&!t?"hide":"show"]()},getAppendTarget:function(){var t=this.settings.dropdown;return"function"==typeof t.appendTarget?t.appendTarget():t.appendTarget},render:function(){var t,e,n,i=this,s=(t=this.DOM.dropdown,(n=t.cloneNode(!0)).style.cssText="position:fixed; top:-9999px; opacity:0",document.body.appendChild(n),e=n.clientHeight,n.parentNode.removeChild(n),e),a=this.settings,o="number"==typeof a.dropdown.enabled&&a.dropdown.enabled>=0,r=this.dropdown.getAppendTarget();return o?(this.DOM.scope.setAttribute("aria-expanded",!0),document.body.contains(this.DOM.dropdown)||(this.DOM.dropdown.classList.add(a.classNames.dropdownInital),this.dropdown.position(s),r.appendChild(this.DOM.dropdown),setTimeout((function(){return i.DOM.dropdown.classList.remove(a.classNames.dropdownInital)}))),this):this},fill:function(t){t="string"==typeof t?t:this.dropdown.createListHTML(t||this.suggestedListItems);var e,n=this.settings.templates.dropdownContent.call(this,t);this.DOM.dropdown.content.innerHTML=(e=n)?e.replace(/\>[\r\n ]+\</g,"><").split(/>\s+</).join("><").trim():""},fillHeaderFooter:function(){var t=this.dropdown.filterListItems(this.state.dropdown.query),e=this.parseTemplate("dropdownHeader",[t]),n=this.parseTemplate("dropdownFooter",[t]),i=this.dropdown.getHeaderRef(),s=this.dropdown.getFooterRef();e&&(null==i||i.parentNode.replaceChild(e,i)),n&&(null==s||s.parentNode.replaceChild(n,s))},position:function(t){var e=this.settings.dropdown,n=this.dropdown.getAppendTarget();if("manual"!=e.position&&n){var i,s,a,o,r,l,d,c,u,g=this.DOM.dropdown,h=e.RTL,p=n===document.body,f=n===this.DOM.scope,m=p?window.pageYOffset:n.scrollTop,v=document.fullscreenElement||document.webkitFullscreenElement||document.documentElement,y=v.clientHeight,b=Math.max(v.clientWidth||0,window.innerWidth||0)>480?e.position:"all",w=this.DOM["input"==b?"input":"scope"];if(t=t||g.clientHeight,this.state.dropdown.visible){if("text"==b?(a=(i=function(){var t=document.getSelection();if(t.rangeCount){var e,n,i=t.getRangeAt(0),s=i.startContainer,a=i.startOffset;if(a>0)return(n=document.createRange()).setStart(s,a-1),n.setEnd(s,a),{left:(e=n.getBoundingClientRect()).right,top:e.top,bottom:e.bottom};if(s.getBoundingClientRect)return s.getBoundingClientRect()}return{left:-9999,top:-9999}}()).bottom,s=i.top,o=i.left,r="auto"):(l=function(t){var e=0,n=0;for(t=t.parentNode;t&&t!=v;)e+=t.offsetTop||0,n+=t.offsetLeft||0,t=t.parentNode;return{top:e,left:n}}(n),i=w.getBoundingClientRect(),s=f?-1:i.top-l.top,a=(f?i.height:i.bottom-l.top)-1,o=f?-1:i.left-l.left,r=i.width+"px"),!p){var T=function(){for(var t=0,n=e.appendTarget.parentNode;n;)t+=n.scrollTop||0,n=n.parentNode;return t}();s+=T,a+=T}var O;s=Math.floor(s),a=Math.ceil(a),c=((d=null!==(O=e.placeAbove)&&void 0!==O?O:y-i.bottom<t)?s:a)+m,u="left: ".concat(o+(h&&i.width||0)+window.pageXOffset,"px;"),g.style.cssText="".concat(u,"; top: ").concat(c,"px; min-width: ").concat(r,"; max-width: ").concat(r),g.setAttribute("placement",d?"top":"bottom"),g.setAttribute("position",b)}}}})?H:{},Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(H)):function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}(Object(H)).forEach((function(t){Object.defineProperty(F,t,Object.getOwnPropertyDescriptor(H,t))})),F),W="@yaireo/tagify/",K={empty:"empty",exceed:"number of tags exceeded",pattern:"pattern mismatch",duplicate:"already exists",notAllowed:"not allowed"},q={wrapper:function(t,e){return'<tags class="'.concat(e.classNames.namespace," ").concat(e.mode?"".concat(e.classNames[e.mode+"Mode"]):""," ").concat(t.className,'"\n                    ').concat(e.readonly?"readonly":"","\n                    ").concat(e.disabled?"disabled":"","\n                    ").concat(e.required?"required":"","\n                    ").concat("select"===e.mode?"spellcheck='false'":"",'\n                    tabIndex="-1">\n                    ').concat(this.settings.templates.input.call(this),"\n                ").concat(r,"\n        </tags>")},input:function(){var t=this.settings,e=t.placeholder||r;return"<span ".concat(!t.readonly&&t.userInput?"contenteditable":"",' tabIndex="0" data-placeholder="').concat(e,'" aria-placeholder="').concat(t.placeholder||"",'"\n                    class="').concat(t.classNames.input,'"\n                    role="textbox"\n                    autocapitalize="false"\n                    autocorrect="off"\n                    spellcheck="false"\n                    aria-autocomplete="both"\n                    aria-multiline="').concat("mix"==t.mode,'"></span>')},tag:function(t,e){var n=e.settings;return'<tag title="'.concat(t.title||t.value,"\"\n                    contenteditable='false'\n                    tabIndex=\"").concat(n.a11y.focusableTags?0:-1,'"\n                    class="').concat(n.classNames.tag," ").concat(t.class||"",'"\n                    ').concat(this.getAttributes(t),">\n            <x title='' tabIndex=\"").concat(n.a11y.focusableTags?0:-1,'" class="').concat(n.classNames.tagX,"\" role='button' aria-label='remove tag'></x>\n            <div>\n                <span ").concat("select"===n.mode&&n.userInput?"contenteditable='true'":"",' autocapitalize="false" autocorrect="off" spellcheck=\'false\' class="').concat(n.classNames.tagText,'">').concat(t[n.tagTextProp]||t.value,"</span>\n            </div>\n        </tag>")},dropdown:function(t){var e=t.dropdown,n="manual"==e.position;return'<div class="'.concat(n?"":t.classNames.dropdown," ").concat(e.classname,'" role="listbox" aria-labelledby="dropdown" dir="').concat(e.RTL?"rtl":"","\">\n                    <div data-selector='tagify-suggestions-wrapper' class=\"").concat(t.classNames.dropdownWrapper,'"></div>\n                </div>')},dropdownContent:function(t){var e=this.settings.templates,n=this.state.dropdown.suggestions;return"\n            ".concat(e.dropdownHeader.call(this,n),"\n            ").concat(t,"\n            ").concat(e.dropdownFooter.call(this,n),"\n        ")},dropdownItem:function(t){return"<div ".concat(this.getAttributes(t),"\n                    class='").concat(this.settings.classNames.dropdownItem," ").concat(this.isTagDuplicate(t.value)?this.settings.classNames.dropdownItemSelected:""," ").concat(t.class||"",'\'\n                    tabindex="0"\n                    role="option">').concat(t.mappedValue||t.value,"</div>")},dropdownHeader:function(t){return"<header data-selector='tagify-suggestions-header' class=\"".concat(this.settings.classNames.dropdownHeader,'"></header>')},dropdownFooter:function(t){var e=t.length-this.settings.dropdown.maxItems;return e>0?"<footer data-selector='tagify-suggestions-footer' class=\"".concat(this.settings.classNames.dropdownFooter,'">\n                ').concat(e," more items. Refine your search.\n            </footer>"):""},dropdownItemNoMatch:null};function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function X(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function J(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,s,a=[],o=!0,r=!1;try{for(n=n.call(t);!(o=(i=n.next()).done)&&(a.push(i.value),!e||a.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{o||null==n.return||n.return()}finally{if(r)throw s}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return z(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function $(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function Y(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t}function Z(t){return function(t){if(Array.isArray(t))return G(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return G(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var tt={customBinding:function(){var t=this;this.customEventsList.forEach((function(e){t.on(e,t.settings.callbacks[e])}))},binding:function(){var t,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this.settings,i=this.events.callbacks,s=e?"addEventListener":"removeEventListener";if(!this.state.mainEvents||!e){for(var a in this.state.mainEvents=e,e&&!this.listeners.main&&(this.events.bindGlobal.call(this),this.settings.isJQueryPlugin&&jQuery(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))),t=this.listeners.main=this.listeners.main||{keydown:["input",i.onKeydown.bind(this)],click:["scope",i.onClickScope.bind(this)],dblclick:"select"!=n.mode&&["scope",i.onDoubleClickScope.bind(this)],paste:["input",i.onPaste.bind(this)],drop:["input",i.onDrop.bind(this)],compositionstart:["input",i.onCompositionStart.bind(this)],compositionend:["input",i.onCompositionEnd.bind(this)]})t[a]&&this.DOM[t[a][0]][s](a,t[a][1]);var o=this.listeners.main.inputMutationObserver||new MutationObserver(i.onInputDOMChange.bind(this));o.disconnect(),"mix"==n.mode&&o.observe(this.DOM.input,{childList:!0}),this.events.bindOriginaInputListener.call(this)}},bindOriginaInputListener:function(t){var e=(t||0)+500;this.listeners.main&&(clearInterval(this.listeners.main.originalInputValueObserverInterval),this.listeners.main.originalInputValueObserverInterval=setInterval(this.events.callbacks.observeOriginalInputValue.bind(this),e))},bindGlobal:function(t){var e,n=this.events.callbacks,i=t?"removeEventListener":"addEventListener";if(this.listeners&&(t||!this.listeners.global)){this.listeners.global=this.listeners.global||[{type:this.isIE?"keydown":"input",target:this.DOM.input,cb:n[this.isIE?"onInputIE":"onInput"].bind(this)},{type:"keydown",target:window,cb:n.onWindowKeyDown.bind(this)},{type:"focusin",target:this.DOM.scope,cb:n.onFocusBlur.bind(this)},{type:"focusout",target:this.DOM.scope,cb:n.onFocusBlur.bind(this)},{type:"click",target:document,cb:n.onClickAnywhere.bind(this),useCapture:!0}];var s=!0,a=!1,o=void 0;try{for(var r,l=this.listeners.global[Symbol.iterator]();!(s=(r=l.next()).done);s=!0)(e=r.value).target[i](e.type,e.cb,!!e.useCapture)}catch(t){a=!0,o=t}finally{try{s||null==l.return||l.return()}finally{if(a)throw o}}}},unbindGlobal:function(){this.events.bindGlobal.call(this,!0)},callbacks:{onFocusBlur:function(t){var e,n,i=this.settings,s=S.call(this,t.target),a=x.call(this,t.target),o=t.target.classList.contains(i.classNames.tagX),r="focusin"==t.type,l="focusout"==t.type;s&&r&&!a&&!o&&this.toggleFocusClass(this.state.hasFocus=+new Date);var d=t.target?this.trim(this.DOM.input.textContent):"",c=null===(n=this.value)||void 0===n||null===(e=n[0])||void 0===e?void 0:e[i.tagTextProp],u=i.dropdown.enabled>=0,g={relatedTarget:t.relatedTarget},h=this.state.actions.selectOption&&(u||!i.dropdown.closeOnSelect),p=this.state.actions.addNew&&u;if(l){if(t.relatedTarget===this.DOM.scope)return this.dropdown.hide(),void this.DOM.input.focus();this.postUpdate(),i.onChangeAfterBlur&&this.triggerChangeEvent()}if(!(h||p||o))if(r||s?(this.state.hasFocus=+new Date,this.toggleFocusClass(this.state.hasFocus)):this.state.hasFocus=!1,"mix"!=i.mode){if(r){if(!i.focusable)return;var f=0===i.dropdown.enabled&&!this.state.dropdown.visible;return this.toggleFocusClass(!0),this.trigger("focus",g),void(!f||a&&"select"!==i.mode||this.dropdown.show(this.value.length?"":void 0))}if(l){if(this.trigger("blur",g),this.loading(!1),"select"==i.mode){if(this.value.length){var m=this.getTagElms()[0];d=this.trim(m.textContent)}c===d&&(d="")}d&&!this.state.actions.selectOption&&i.addTagOnBlur&&i.addTagOn.includes("blur")&&this.addTags(d,!0)}s||(this.DOM.input.removeAttribute("style"),this.dropdown.hide())}else r?this.trigger("focus",g):l&&(this.trigger("blur",g),this.loading(!1),this.dropdown.hide(),this.state.dropdown.visible=void 0,this.setStateSelection())},onCompositionStart:function(t){this.state.composing=!0},onCompositionEnd:function(t){this.state.composing=!1},onWindowKeyDown:function(t){var e,n=this.settings,i=document.activeElement,s=S.call(this,i)&&this.DOM.scope.contains(document.activeElement),a=s&&i.hasAttribute("readonly");if(this.state.hasFocus||s&&!a){e=i.nextElementSibling;var o=t.target.classList.contains(n.classNames.tagX);switch(t.key){case"Backspace":n.readonly||this.state.editing||(this.removeTags(i),(e||this.DOM.input).focus());break;case"Enter":if(o)return void this.removeTags(t.target.parentNode);n.a11y.focusableTags&&x.call(this,i)&&setTimeout(this.editTag.bind(this),0,i);break;case"ArrowDown":this.state.dropdown.visible||"mix"==n.mode||this.dropdown.show()}}},onKeydown:function(t){var e=this,n=this.settings;if(!this.state.composing&&n.userInput){"select"==n.mode&&n.enforceWhitelist&&this.value.length&&"Tab"!=t.key&&t.preventDefault();var i=this.trim(t.target.textContent);this.trigger("keydown",{event:t}),n.hooks.beforeKeyDown(t,{tagify:this}).then((function(s){if("mix"==n.mode){switch(t.key){case"Left":case"ArrowLeft":e.state.actions.ArrowLeft=!0;break;case"Delete":case"Backspace":if(e.state.editing)return;var a=document.getSelection(),o="Delete"==t.key&&a.anchorOffset==(a.anchorNode.length||0),r=a.anchorNode.previousSibling,l=1==a.anchorNode.nodeType||!a.anchorOffset&&r&&1==r.nodeType&&a.anchorNode.previousSibling;p(e.DOM.input.innerHTML);var d,c,u,g=e.getTagElms(),h=1===a.anchorNode.length&&a.anchorNode.nodeValue==String.fromCharCode(8203);if("edit"==n.backspace&&l)return d=1==a.anchorNode.nodeType?null:a.anchorNode.previousElementSibling,setTimeout(e.editTag.bind(e),0,d),void t.preventDefault();if(O()&&Q(l,Element))return u=m(l),l.hasAttribute("readonly")||l.remove(),e.DOM.input.focus(),void setTimeout((function(){M(u),e.DOM.input.click()}));if("BR"==a.anchorNode.nodeName)return;if((o||l)&&1==a.anchorNode.nodeType?c=0==a.anchorOffset?o?g[0]:null:g[Math.min(g.length,a.anchorOffset)-1]:o?c=a.anchorNode.nextElementSibling:Q(l,Element)&&(c=l),3==a.anchorNode.nodeType&&!a.anchorNode.nodeValue&&a.anchorNode.previousElementSibling&&t.preventDefault(),(l||o)&&!n.backspace)return void t.preventDefault();if("Range"!=a.type&&!a.anchorOffset&&a.anchorNode==e.DOM.input&&"Delete"!=t.key)return void t.preventDefault();if("Range"!=a.type&&c&&c.hasAttribute("readonly"))return void M(m(c));"Delete"==t.key&&h&&I(a.anchorNode.nextSibling)&&e.removeTags(a.anchorNode.nextSibling),clearTimeout(B),B=setTimeout((function(){var t=document.getSelection();p(e.DOM.input.innerHTML),!o&&t.anchorNode.previousSibling,e.value=[].map.call(g,(function(t,n){var i=I(t);if(t.parentNode||i.readonly)return i;e.trigger("remove",{tag:t,index:n,data:i})})).filter((function(t){return t}))}),20)}return!0}var f="manual"==n.dropdown.position;switch(t.key){case"Backspace":"select"==n.mode&&n.enforceWhitelist&&e.value.length?e.removeTags():e.state.dropdown.visible&&"manual"!=n.dropdown.position||""!=t.target.textContent&&8203!=i.charCodeAt(0)||(!0===n.backspace?e.removeTags():"edit"==n.backspace&&setTimeout(e.editTag.bind(e),0));break;case"Esc":case"Escape":if(e.state.dropdown.visible)return;t.target.blur();break;case"Down":case"ArrowDown":e.state.dropdown.visible||e.dropdown.show();break;case"ArrowRight":var v=e.state.inputSuggestion||e.state.ddItemData;if(v&&n.autoComplete.rightKey)return void e.addTags([v],!0);break;case"Tab":var y="select"==n.mode;if(!i||y)return!0;t.preventDefault();case"Enter":if(e.state.dropdown.visible&&!f)return;t.preventDefault(),setTimeout((function(){e.state.dropdown.visible&&!f||e.state.actions.selectOption||!n.addTagOn.includes(t.key.toLowerCase())||e.addTags(i,!0)}))}})).catch((function(t){return t}))}},onInput:function(t){this.postUpdate();var e=this.settings;if("mix"==e.mode)return this.events.callbacks.onMixTagsInput.call(this,t);var n=this.input.normalize.call(this,void 0,{trim:!1}),i=n.length>=e.dropdown.enabled,s={value:n,inputElm:this.DOM.input},a=this.validateTag({value:n});"select"==e.mode&&this.toggleScopeValidation(a),s.isValid=a,this.state.inputText!=n&&(this.input.set.call(this,n,!1),-1!=n.search(e.delimiters)?this.addTags(n)&&this.input.set.call(this):e.dropdown.enabled>=0&&this.dropdown[i?"show":"hide"](n),this.trigger("input",s))},onMixTagsInput:function(t){var e,n,i,s,a,o,r,l,d=this,c=this.settings,u=this.value.length,g=this.getTagElms(),h=document.createDocumentFragment(),p=window.getSelection().getRangeAt(0),f=[].map.call(g,(function(t){return I(t).value}));if("deleteContentBackward"==t.inputType&&O()&&this.events.callbacks.onKeydown.call(this,{target:t.target,key:"Backspace"}),N(this.getTagElms()),this.value.slice().forEach((function(t){t.readonly&&!f.includes(t.value)&&h.appendChild(d.createTagElem(t))})),h.childNodes.length&&(p.insertNode(h),this.setRangeAtStartEnd(!1,h.lastChild)),g.length!=u)return this.value=[].map.call(this.getTagElms(),(function(t){return I(t)})),void this.update({withoutChangeEvent:!0});if(this.hasMaxTags())return!0;if(window.getSelection&&(o=window.getSelection()).rangeCount>0&&3==o.anchorNode.nodeType){if((p=o.getRangeAt(0).cloneRange()).collapse(!0),p.setStart(o.focusNode,0),i=(e=p.toString().slice(0,p.endOffset)).split(c.pattern).length-1,(n=e.match(c.pattern))&&(s=e.slice(e.lastIndexOf(n[n.length-1]))),s){if(this.state.actions.ArrowLeft=!1,this.state.tag={prefix:s.match(c.pattern)[0],value:s.replace(c.pattern,"")},this.state.tag.baseOffset=o.baseOffset-this.state.tag.value.length,l=this.state.tag.value.match(c.delimiters))return this.state.tag.value=this.state.tag.value.replace(c.delimiters,""),this.state.tag.delimiters=l[0],this.addTags(this.state.tag.value,c.dropdown.clearOnSelect),void this.dropdown.hide();a=this.state.tag.value.length>=c.dropdown.enabled;try{r=(r=this.state.flaggedTags[this.state.tag.baseOffset]).prefix==this.state.tag.prefix&&r.value[0]==this.state.tag.value[0],this.state.flaggedTags[this.state.tag.baseOffset]&&!this.state.tag.value&&delete this.state.flaggedTags[this.state.tag.baseOffset]}catch(t){}(r||i<this.state.mixMode.matchedPatternCount)&&(a=!1)}else this.state.flaggedTags={};this.state.mixMode.matchedPatternCount=i}setTimeout((function(){d.update({withoutChangeEvent:!0}),d.trigger("input",b({},d.state.tag,{textContent:d.DOM.input.textContent})),d.state.tag&&d.dropdown[a?"show":"hide"](d.state.tag.value)}),10)},onInputIE:function(t){var e=this;setTimeout((function(){e.events.callbacks.onInput.call(e,t)}))},observeOriginalInputValue:function(){this.DOM.originalInput.parentNode||this.destroy(),this.DOM.originalInput.value!=this.DOM.originalInput.tagifyValue&&this.loadOriginalValues()},onClickAnywhere:function(t){t.target==this.DOM.scope||this.DOM.scope.contains(t.target)||(this.toggleFocusClass(!1),this.state.hasFocus=!1,t.target.closest(".tagify__dropdown")&&t.target.closest(".tagify__dropdown").__tagify!=this&&this.dropdown.hide())},onClickScope:function(t){var e=this.settings,n=t.target.closest("."+e.classNames.tag),i=t.target===this.DOM.scope,s=+new Date-this.state.hasFocus;if(i&&"select"!=e.mode)this.DOM.input.focus();else{if(!t.target.classList.contains(e.classNames.tagX))return n&&!this.state.editing?(this.trigger("click",{tag:n,index:this.getNodeIndex(n),data:I(n),event:t}),void(1!==e.editTags&&1!==e.editTags.clicks&&"select"!=e.mode||this.events.callbacks.onDoubleClickScope.call(this,t))):void(t.target==this.DOM.input&&("mix"==e.mode&&this.fixFirefoxLastTagNoCaret(),s>500||!e.focusable)?this.state.dropdown.visible?this.dropdown.hide():0===e.dropdown.enabled&&"mix"!=e.mode&&this.dropdown.show(this.value.length?"":void 0):"select"!=e.mode||0!==e.dropdown.enabled||this.state.dropdown.visible||(this.events.callbacks.onDoubleClickScope.call(this,Y(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){$(t,e,n[e])}))}return t}({},t),{target:this.getTagElms()[0]})),!e.userInput&&this.dropdown.show()));this.removeTags(t.target.parentNode)}},onPaste:function(t){var e=this;t.preventDefault();var n,i,s,a=this.settings;if("select"==a.mode&&a.enforceWhitelist||!a.userInput)return!1;a.readonly||(i=t.clipboardData||window.clipboardData,s=i.getData("Text"),a.hooks.beforePaste(t,{tagify:this,pastedText:s,clipboardData:i}).then((function(a){void 0===a&&(a=s),a&&(e.injectAtCaret(a,window.getSelection().getRangeAt(0)),"mix"==e.settings.mode?e.events.callbacks.onMixTagsInput.call(e,t):e.settings.pasteAsTags?n=e.addTags(e.state.inputText+a,!0):(e.state.inputText=a,e.dropdown.show(a))),e.trigger("paste",{event:t,pastedText:s,clipboardData:i,tagsElems:n})})).catch((function(t){return t})))},onDrop:function(t){t.preventDefault()},onEditTagInput:function(t,e){var n,i=t.closest("."+this.settings.classNames.tag),s=this.getNodeIndex(i),a=I(i),o=this.input.normalize.call(this,t),r=($(n={},this.settings.tagTextProp,o),$(n,"__tagId",a.__tagId),n),l=this.validateTag(r);this.editTagChangeDetected(b(a,r))||!0!==t.originalIsValid||(l=!0),i.classList.toggle(this.settings.classNames.tagInvalid,!0!==l),a.__isValid=l,i.title=!0===l?a.title||a.value:l,o.length>=this.settings.dropdown.enabled&&(this.state.editing&&(this.state.editing.value=o),this.dropdown.show(o)),this.trigger("edit:input",{tag:i,index:s,data:b({},this.value[s],{newValue:o}),event:e})},onEditTagPaste:function(t,e){var n=(e.clipboardData||window.clipboardData).getData("Text");e.preventDefault();var i=E(n);this.setRangeAtStartEnd(!1,i)},onEditTagClick:function(t,e){this.events.callbacks.onClickScope.call(this,e)},onEditTagFocus:function(t){this.state.editing={scope:t,input:t.querySelector("[contenteditable]")}},onEditTagBlur:function(t,e){var n=x.call(this,e.relatedTarget);if("select"==this.settings.mode&&n&&e.relatedTarget.contains(e.target))this.dropdown.hide();else if(this.state.editing&&(this.state.hasFocus||this.toggleFocusClass(),this.DOM.scope.contains(t))){var i,s,a,o=this.settings,r=t.closest("."+o.classNames.tag),l=I(r),d=this.input.normalize.call(this,t),c=($(i={},o.tagTextProp,d),$(i,"__tagId",l.__tagId),i),u=l.__originalData,g=this.editTagChangeDetected(b(l,c)),h=this.validateTag(c);if(d)if(g){var p;if(s=this.hasMaxTags(),a=b({},u,($(p={},o.tagTextProp,this.trim(d)),$(p,"__isValid",h),p)),o.transformTag.call(this,a,u),!0!==(h=(!s||!0===u.__isValid)&&this.validateTag(a))){if(this.trigger("invalid",{data:a,tag:r,message:h}),o.editTags.keepInvalid)return;o.keepInvalidTags?a.__isValid=h:a=u}else o.keepInvalidTags&&(delete a.title,delete a["aria-invalid"],delete a.class);this.onEditTagDone(r,a)}else this.onEditTagDone(r,u);else this.onEditTagDone(r)}},onEditTagkeydown:function(t,e){if(!this.state.composing)switch(this.trigger("edit:keydown",{event:t}),t.key){case"Esc":case"Escape":this.state.editing=!1,!!e.__tagifyTagData.__originalData.value?e.parentNode.replaceChild(e.__tagifyTagData.__originalHTML,e):e.remove();break;case"Enter":case"Tab":t.preventDefault();setTimeout((function(){return t.target.blur()}),0)}},onDoubleClickScope:function(t){var e,n,i=t.target.closest("."+this.settings.classNames.tag),s=I(i),a=this.settings;i&&!1!==s.editable&&(e=i.classList.contains(this.settings.classNames.tagEditing),n=i.hasAttribute("readonly"),a.readonly||e||n||!this.settings.editTags||!a.userInput||(this.events.callbacks.onEditTagFocus.call(this,i),this.editTag(i)),this.toggleFocusClass(!0),"select"!=a.mode&&this.trigger("dblclick",{tag:i,index:this.getNodeIndex(i),data:I(i)}))},onInputDOMChange:function(t){var e=this;t.forEach((function(t){t.addedNodes.forEach((function(t){if("<div><br></div>"==t.outerHTML)t.replaceWith(document.createElement("br"));else if(1==t.nodeType&&t.querySelector(e.settings.classNames.tagSelector)){var n,i=document.createTextNode("");3==t.childNodes[0].nodeType&&"BR"!=t.previousSibling.nodeName&&(i=document.createTextNode("\n")),(n=t).replaceWith.apply(n,Z([i].concat(Z(Z(t.childNodes).slice(0,-1))))),M(i)}else if(x.call(e,t)){var s;if(3!=(null===(s=t.previousSibling)||void 0===s?void 0:s.nodeType)||t.previousSibling.textContent||t.previousSibling.remove(),t.previousSibling&&"BR"==t.previousSibling.nodeName){t.previousSibling.replaceWith("\n​");for(var a=t.nextSibling,o="";a;)o+=a.textContent,a=a.nextSibling;o.trim()&&M(t.previousSibling)}else t.previousSibling&&!I(t.previousSibling)||t.before("​")}})),t.removedNodes.forEach((function(t){t&&"BR"==t.nodeName&&x.call(e,n)&&(e.removeTags(n),e.fixFirefoxLastTagNoCaret())}))}));var n=this.DOM.input.lastChild;n&&""==n.nodeValue&&n.remove(),n&&"BR"==n.nodeName||this.DOM.input.appendChild(document.createElement("br"))}}};function et(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function nt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function it(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function st(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){nt(t,e,n[e])}))}return t}function at(t){return function(t){if(Array.isArray(t))return et(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return et(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return et(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ot(t,e){if(!t){c.warn("input element not found",t);var n=new Proxy(this,{get:function(){return function(){return n}}});return n}if(t.__tagify)return c.warn("input element is already Tagified - Same instance is returned.",t),t.__tagify;var i;b(this,function(t){var e=document.createTextNode(""),n={};function i(t,n,i){i&&n.split(/\s+/g).forEach((function(n){return e[t+"EventListener"].call(e,n,i)}))}return{removeAllCustomListeners:function(){Object.entries(n).forEach((function(t){var e=J(t,2),n=e[0];e[1].forEach((function(t){return i("remove",n,t)}))})),n={}},off:function(t,e){return t&&(e?i("remove",t,e):t.split(/\s+/g).forEach((function(t){var e;null===(e=n[t])||void 0===e||e.forEach((function(e){return i("remove",t,e)})),delete n[t]}))),this},on:function(t,e){return e&&"function"==typeof e&&(t.split(/\s+/g).forEach((function(t){Array.isArray(n[t])?n[t].push(e):n[t]=[e]})),i("add",t,e)),this},trigger:function(n,i,s){var a;if(s=s||{cloneData:!0},n)if(t.settings.isJQueryPlugin)"remove"==n&&(n="removeTag"),jQuery(t.DOM.originalInput).triggerHandler(n,[i]);else{try{var o="object"==typeof i?i:{value:i};if((o=s.cloneData?b({},o):o).tagify=this,i.event&&(o.event=this.cloneEvent(i.event)),X(i,Object))for(var r in i)X(i[r],HTMLElement)&&(o[r]=i[r]);a=new CustomEvent(n,{detail:o})}catch(t){c.warn(t)}e.dispatchEvent(a)}}}}(this)),this.isFirefox=/firefox|fxios/i.test(navigator.userAgent)&&!/seamonkey/i.test(navigator.userAgent),this.isIE=window.document.documentMode,e=e||{},this.getPersistedData=(i=e.id,function(t){var e,n="/"+t;if(1==localStorage.getItem(W+i+"/v",1))try{e=JSON.parse(localStorage[W+i+n])}catch(t){}return e}),this.setPersistedData=function(t){return t?(localStorage.setItem(W+t+"/v",1),function(e,n){var i="/"+n,s=JSON.stringify(e);e&&n&&(localStorage.setItem(W+t+i,s),dispatchEvent(new Event("storage")))}):function(){}}(e.id),this.clearPersistedData=function(t){return function(e){var n=W+"/"+t+"/";if(e)localStorage.removeItem(n+e);else for(var i in localStorage)i.includes(n)&&localStorage.removeItem(i)}}(e.id),this.applySettings(t,e),this.state={inputText:"",editing:!1,composing:!1,actions:{},mixMode:{},dropdown:{},flaggedTags:{}},this.value=[],this.listeners={},this.DOM={},this.build(t),R.call(this),this.getCSSVars(),this.loadOriginalValues(),this.events.customBinding.call(this),this.events.binding.call(this),t.autofocus&&this.DOM.input.focus(),t.__tagify=this}function rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function lt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){lt(t,e,n[e])}))}return t}function ct(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})),t}function ut(t,e){if(null==t)return{};var n,i,s=function(t,e){if(null==t)return{};var n,i,s={},a=Object.keys(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||(s[n]=t[n]);return s}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}function gt(t){return function(t){if(Array.isArray(t))return rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return rt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rt(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ht(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}ot.prototype={_dropdown:U,placeCaretAfterNode:M,getSetTagData:I,helpers:{sameStr:u,removeCollectionProp:g,omit:h,isObject:y,parseHTML:f,escapeHTML:v,extend:b,concatWithoutDups:w,getUID:D,isNodeTag:x},customEventsList:["change","add","remove","invalid","input","paste","click","keydown","focus","blur","edit:input","edit:beforeUpdate","edit:updated","edit:start","edit:keydown","dropdown:show","dropdown:hide","dropdown:select","dropdown:updated","dropdown:noMatch","dropdown:scroll"],dataProps:["__isValid","__removed","__originalData","__originalHTML","__tagId"],trim:function(t){return this.settings.trim&&t&&"string"==typeof t?t.trim():t},parseHTML:f,templates:q,parseTemplate:function(t,e){return f((t=this.settings.templates[t]||t).apply(this,e))},set whitelist(t){var e=t&&Array.isArray(t);this.settings.whitelist=e?t:[],this.setPersistedData(e?t:[],"whitelist")},get whitelist(){return this.settings.whitelist},set userInput(t){this.settings.userInput=!!t,this.setContentEditable(!!t)},get userInput(){return this.settings.userInput},generateClassSelectors:function(t){var e=function(e){var n=e;Object.defineProperty(t,n+"Selector",{get:function(){return"."+this[n].split(" ")[0]}})};for(var n in t)e(n)},applySettings:function(t,e){var n,i;_.templates=this.templates;var s=b({},_,"mix"==e.mode?{dropdown:{position:"text"}}:{}),a=this.settings=b({},s,e);if(a.disabled=t.hasAttribute("disabled"),a.readonly=a.readonly||t.hasAttribute("readonly"),a.placeholder=v(t.getAttribute("placeholder")||a.placeholder||""),a.required=t.hasAttribute("required"),this.generateClassSelectors(a.classNames),void 0===a.dropdown.includeSelectedTags&&(a.dropdown.includeSelectedTags=a.duplicates),this.isIE&&(a.autoComplete=!1),["whitelist","blacklist"].forEach((function(e){var n=t.getAttribute("data-"+e);n&&it(n=n.split(a.delimiters),Array)&&(a[e]=n)})),"autoComplete"in e&&!y(e.autoComplete)&&(a.autoComplete=_.autoComplete,a.autoComplete.enabled=e.autoComplete),"mix"==a.mode&&(a.pattern=a.pattern||/@/,a.autoComplete.rightKey=!0,a.delimiters=e.delimiters||null,a.tagTextProp&&!a.dropdown.searchKeys.includes(a.tagTextProp)&&a.dropdown.searchKeys.push(a.tagTextProp)),t.pattern)try{a.pattern=new RegExp(t.pattern)}catch(t){}if(a.delimiters){a._delimiters=a.delimiters;try{a.delimiters=new RegExp(this.settings.delimiters,"g")}catch(t){}}a.disabled&&(a.userInput=!1),this.TEXTS=st({},K,a.texts||{}),("select"!=a.mode||(null===(n=e.dropdown)||void 0===n?void 0:n.enabled))&&a.userInput||(a.dropdown.enabled=0),a.dropdown.appendTarget=(null===(i=e.dropdown)||void 0===i?void 0:i.appendTarget)||document.body;var o=this.getPersistedData("whitelist");Array.isArray(o)&&(this.whitelist=Array.isArray(a.whitelist)?w(a.whitelist,o):o)},getAttributes:function(t){var e,n=this.getCustomAttributes(t),i="";for(e in n)i+=" "+e+(void 0!==t[e]?'="'.concat(n[e],'"'):"");return i},getCustomAttributes:function(t){if(!y(t))return"";var e,n={};for(e in t)"__"!=e.slice(0,2)&&"class"!=e&&t.hasOwnProperty(e)&&void 0!==t[e]&&(n[e]=v(t[e]));return n},setStateSelection:function(){var t=window.getSelection(),e={anchorOffset:t.anchorOffset,anchorNode:t.anchorNode,range:t.getRangeAt&&t.rangeCount&&t.getRangeAt(0)};return this.state.selection=e,e},getCSSVars:function(){var t,e,n,i=getComputedStyle(this.DOM.scope,null);this.CSSVars={tagHideTransition:(t=function(t){if(!t)return{};var e=(t=t.trim().split(" ")[0]).split(/\d+/g).filter((function(t){return t})).pop().trim();return{value:+t.split(e).filter((function(t){return t}))[0].trim(),unit:e}}((n="tag-hide-transition",i.getPropertyValue("--"+n))),e=t.value,"s"==t.unit?1e3*e:e)}},build:function(t){var e=this.DOM,n=t.closest("label");this.settings.mixMode.integrated?(e.originalInput=null,e.scope=t,e.input=t):(e.originalInput=t,e.originalInput_tabIndex=t.tabIndex,e.scope=this.parseTemplate("wrapper",[t,this.settings]),e.input=e.scope.querySelector(this.settings.classNames.inputSelector),t.parentNode.insertBefore(e.scope,t),t.tabIndex=-1),n&&n.setAttribute("for","")},destroy:function(){this.events.unbindGlobal.call(this),this.DOM.scope.parentNode.removeChild(this.DOM.scope),this.DOM.originalInput.tabIndex=this.DOM.originalInput_tabIndex,delete this.DOM.originalInput.__tagify,this.dropdown.hide(!0),this.removeAllCustomListeners(),clearTimeout(this.dropdownHide__bindEventsTimeout),clearInterval(this.listeners.main.originalInputValueObserverInterval)},loadOriginalValues:function(t){var e,n=this.settings;if(this.state.blockChangeEvent=!0,void 0===t){var i=this.getPersistedData("value");t=i&&!this.DOM.originalInput.value?i:n.mixMode.integrated?this.DOM.input.textContent:this.DOM.originalInput.value}if(this.removeAllTags(),t)if("mix"==n.mode)this.parseMixTags(t),(e=this.DOM.input.lastChild)&&"BR"==e.tagName||this.DOM.input.insertAdjacentHTML("beforeend","<br>");else{try{it(JSON.parse(t),Array)&&(t=JSON.parse(t))}catch(t){}this.addTags(t,!0).forEach((function(t){return t&&t.classList.add(n.classNames.tagNoAnimation)}))}else this.postUpdate();this.state.lastOriginalValueReported=n.mixMode.integrated?"":this.DOM.originalInput.value},cloneEvent:function(t){var e={};for(var n in t)"path"!=n&&(e[n]=t[n]);return e},loading:function(t){return this.state.isLoading=t,this.DOM.scope.classList[t?"add":"remove"](this.settings.classNames.scopeLoading),this},tagLoading:function(t,e){return t&&t.classList[e?"add":"remove"](this.settings.classNames.tagLoading),this},toggleClass:function(t,e){"string"==typeof t&&this.DOM.scope.classList.toggle(t,e)},toggleScopeValidation:function(t){var e=!0===t||void 0===t;!this.settings.required&&t&&t===this.TEXTS.empty&&(e=!0),this.toggleClass(this.settings.classNames.tagInvalid,!e),this.DOM.scope.title=e?"":t},toggleFocusClass:function(t){this.toggleClass(this.settings.classNames.focus,!!t)},setPlaceholder:function(t){var e=this;["data","aria"].forEach((function(n){return e.DOM.input.setAttribute("".concat(n,"-placeholder"),t)}))},triggerChangeEvent:function(){if(!this.settings.mixMode.integrated){var t=this.DOM.originalInput,e=this.state.lastOriginalValueReported!==t.value,n=new CustomEvent("change",{bubbles:!0});e&&(this.state.lastOriginalValueReported=t.value,n.simulated=!0,t._valueTracker&&t._valueTracker.setValue(Math.random()),t.dispatchEvent(n),this.trigger("change",this.state.lastOriginalValueReported),t.value=this.state.lastOriginalValueReported)}},events:tt,fixFirefoxLastTagNoCaret:function(){},setRangeAtStartEnd:function(t,e){if(e){t="number"==typeof t?t:!!t,e=e.lastChild||e;var n=document.getSelection();if(it(n.focusNode,Element)&&!this.DOM.input.contains(n.focusNode))return!0;try{n.rangeCount>=1&&["Start","End"].forEach((function(i){return n.getRangeAt(0)["set"+i](e,t||e.length)}))}catch(t){console.warn(t)}}},insertAfterTag:function(t,e){if(e=e||this.settings.mixMode.insertAfterTag,t&&t.parentNode&&e)return e="string"==typeof e?document.createTextNode(e):e,t.parentNode.insertBefore(e,t.nextSibling),e},editTagChangeDetected:function(t){var e=t.__originalData;for(var n in e)if(!this.dataProps.includes(n)&&t[n]!=e[n])return!0;return!1},getTagTextNode:function(t){return t.querySelector(this.settings.classNames.tagTextSelector)},setTagTextNode:function(t,e){this.getTagTextNode(t).innerHTML=v(e)},editTag:function(t,e){var n=this;t=t||this.getLastTag(),e=e||{};var i=this.settings,s=this.getTagTextNode(t),a=this.getNodeIndex(t),o=I(t),r=this.events.callbacks,l=!0,d="select"==i.mode;if(!d&&this.dropdown.hide(),s){if(!it(o,Object)||!("editable"in o)||o.editable)return o=I(t,{__originalData:b({},o),__originalHTML:t.cloneNode(!0)}),I(o.__originalHTML,o.__originalData),s.setAttribute("contenteditable",!0),t.classList.add(i.classNames.tagEditing),s.addEventListener("click",r.onEditTagClick.bind(this,t)),s.addEventListener("blur",r.onEditTagBlur.bind(this,this.getTagTextNode(t))),s.addEventListener("input",r.onEditTagInput.bind(this,s)),s.addEventListener("paste",r.onEditTagPaste.bind(this,s)),s.addEventListener("keydown",(function(e){return r.onEditTagkeydown.call(n,e,t)})),s.addEventListener("compositionstart",r.onCompositionStart.bind(this)),s.addEventListener("compositionend",r.onCompositionEnd.bind(this)),e.skipValidation||(l=this.editTagToggleValidity(t)),s.originalIsValid=l,this.trigger("edit:start",{tag:t,index:a,data:o,isValid:l}),s.focus(),!d&&this.setRangeAtStartEnd(!1,s),0===i.dropdown.enabled&&!d&&this.dropdown.show(),this.state.hasFocus=!0,this}else c.warn("Cannot find element in Tag template: .",i.classNames.tagTextSelector)},editTagToggleValidity:function(t,e){var n;if(e=e||I(t))return(n=!("__isValid"in e)||!0===e.__isValid)||this.removeTagsFromValue(t),this.update(),t.classList.toggle(this.settings.classNames.tagNotAllowed,!n),e.__isValid=n,e.__isValid;c.warn("tag has no data: ",t,e)},onEditTagDone:function(t,e){t=t||this.state.editing.scope,e=e||{};var n,i,s={tag:t,index:this.getNodeIndex(t),previousData:I(t),data:e},a=this.settings;this.trigger("edit:beforeUpdate",s,{cloneData:!1}),this.state.editing=!1,delete e.__originalData,delete e.__originalHTML,t&&(void 0!==(i=e[a.tagTextProp])?null===(n=(i+="").trim)||void 0===n?void 0:n.call(i):a.tagTextProp in e?void 0:e.value)?(t=this.replaceTag(t,e),this.editTagToggleValidity(t,e),a.a11y.focusableTags?t.focus():"select"!=a.mode&&M(t)):t&&this.removeTags(t),this.trigger("edit:updated",s),this.dropdown.hide(),this.settings.keepInvalidTags&&this.reCheckInvalidTags()},replaceTag:function(t,e){e&&""!==e.value&&void 0!==e.value||(e=t.__tagifyTagData),e.__isValid&&1!=e.__isValid&&b(e,this.getInvalidTagAttrs(e,e.__isValid));var n=this.createTagElem(e);return t.parentNode.replaceChild(n,t),this.updateValueByDOMTags(),n},updateValueByDOMTags:function(){var t=this;this.value.length=0;var e=this.settings.classNames,n=[e.tagNotAllowed.split(" ")[0],e.tagHide];[].forEach.call(this.getTagElms(),(function(e){at(e.classList).some((function(t){return n.includes(t)}))||t.value.push(I(e))})),this.update()},injectAtCaret:function(t,e){var n;if(!(e=e||(null===(n=this.state.selection)||void 0===n?void 0:n.range))&&t)return this.appendMixTags(t),this;var i=E(t,e);return this.setRangeAtStartEnd(!1,i),this.updateValueByDOMTags(),this.update(),this},input:{set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.settings,i=n.dropdown.closeOnSelect;this.state.inputText=t,e&&(this.DOM.input.innerHTML=v(""+t),t&&this.toggleClass(n.classNames.empty,!this.DOM.input.innerHTML)),!t&&i&&this.dropdown.hide.bind(this),this.input.autocomplete.suggest.call(this),this.input.validate.call(this)},raw:function(){return this.DOM.input.textContent},validate:function(){var t=!this.state.inputText||!0===this.validateTag({value:this.state.inputText});return this.DOM.input.classList.toggle(this.settings.classNames.inputInvalid,!t),t},normalize:function(t,e){var n=t||this.DOM.input,i=[];n.childNodes.forEach((function(t){return 3==t.nodeType&&i.push(t.nodeValue)})),i=i.join("\n");try{i=i.replace(/(?:\r\n|\r|\n)/g,this.settings.delimiters.source.charAt(0))}catch(t){}return i=i.replace(/\s/g," "),(null==e?void 0:e.trim)?this.trim(i):i},autocomplete:{suggest:function(t){if(this.settings.autoComplete.enabled){"object"!=typeof(t=t||{value:""})&&(t={value:t});var e=this.dropdown.getMappedValue(t);if("number"!=typeof e){var n=this.state.inputText.toLowerCase(),i=e.substr(0,this.state.inputText.length).toLowerCase(),s=e.substring(this.state.inputText.length);e&&this.state.inputText&&i==n?(this.DOM.input.setAttribute("data-suggest",s),this.state.inputSuggestion=t):(this.DOM.input.removeAttribute("data-suggest"),delete this.state.inputSuggestion)}}},set:function(t){var e=this.DOM.input.getAttribute("data-suggest"),n=t||(e?this.state.inputText+e:null);return!!n&&("mix"==this.settings.mode?this.replaceTextWithNode(document.createTextNode(this.state.tag.prefix+n)):(this.input.set.call(this,n),this.setRangeAtStartEnd(!1,this.DOM.input)),this.input.autocomplete.suggest.call(this),this.dropdown.hide(),!0)}}},getTagIdx:function(t){return this.value.findIndex((function(e){return e.__tagId==(t||{}).__tagId}))},getNodeIndex:function(t){var e=0;if(t)for(;t=t.previousElementSibling;)e++;return e},getTagElms:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i="."+at(this.settings.classNames.tag.split(" ")).concat(at(e)).join(".");return[].slice.call(this.DOM.scope.querySelectorAll(i))},getLastTag:function(){var t=this.settings.classNames,e=this.DOM.scope.querySelectorAll("".concat(t.tagSelector,":not(.").concat(t.tagHide,"):not([readonly])"));return e[e.length-1]},isTagDuplicate:function(t,e,n){var i=0,s=!0,a=!1,o=void 0;try{for(var r,l=this.value[Symbol.iterator]();!(s=(r=l.next()).done);s=!0){var d=r.value;u(this.trim(""+t),d.value,e)&&n!=d.__tagId&&i++}}catch(t){a=!0,o=t}finally{try{s||null==l.return||l.return()}finally{if(a)throw o}}return i},getTagIndexByValue:function(t){var e=this,n=[],i=this.settings.dropdown.caseSensitive;return this.getTagElms().forEach((function(s,a){s.__tagifyTagData&&u(e.trim(s.__tagifyTagData.value),t,i)&&n.push(a)})),n},getTagElmByValue:function(t){var e=this.getTagIndexByValue(t)[0];return this.getTagElms()[e]},flashTag:function(t){var e=this;t&&(t.classList.add(this.settings.classNames.tagFlash),setTimeout((function(){t.classList.remove(e.settings.classNames.tagFlash)}),100))},isTagBlacklisted:function(t){return t=this.trim(t.toLowerCase()),this.settings.blacklist.filter((function(e){return(""+e).toLowerCase()==t})).length},isTagWhitelisted:function(t){return!!this.getWhitelistItem(t)},getWhitelistItem:function(t,e,n){e=e||"value";var i,s=this.settings;return(n=n||s.whitelist).some((function(n){var a="object"==typeof n?n[e]||n.value:n;if(u(a,t,s.dropdown.caseSensitive,s.trim))return i="object"==typeof n?n:{value:n},!0})),i||"value"!=e||"value"==s.tagTextProp||(i=this.getWhitelistItem(t,s.tagTextProp,n)),i},validateTag:function(t){var e=this.settings,n="value"in t?"value":e.tagTextProp,i=this.trim(t[n]+"");return(t[n]+"").trim()?"mix"!=e.mode&&e.pattern&&it(e.pattern,RegExp)&&!e.pattern.test(i)?this.TEXTS.pattern:!e.duplicates&&this.isTagDuplicate(i,e.dropdown.caseSensitive,t.__tagId)?this.TEXTS.duplicate:this.isTagBlacklisted(i)||e.enforceWhitelist&&!this.isTagWhitelisted(i)?this.TEXTS.notAllowed:!e.validate||e.validate(t):this.TEXTS.empty},getInvalidTagAttrs:function(t,e){return{"aria-invalid":!0,class:"".concat(t.class||""," ").concat(this.settings.classNames.tagNotAllowed).trim(),title:e}},hasMaxTags:function(){return this.value.length>=this.settings.maxTags&&this.TEXTS.exceed},setReadonly:function(t,e){var n=this.settings;this.DOM.scope.contains(document.activeElement)&&document.activeElement.blur(),n[e||"readonly"]=t,this.DOM.scope[(t?"set":"remove")+"Attribute"](e||"readonly",!0),this.settings.userInput=!0,this.setContentEditable(!t)},setContentEditable:function(t){this.DOM.input.contentEditable=t,this.DOM.input.tabIndex=t?0:-1},setDisabled:function(t){this.setReadonly(t,"disabled")},normalizeTags:function(t){var e=this,n=this.settings,i=n.whitelist,s=n.delimiters,a=n.mode,o=n.tagTextProp,r=[],l=!!i&&it(i[0],Object),d=Array.isArray(t),c=d&&t[0].value,u=function(t){return(t+"").split(s).reduce((function(t,n){var i,s=e.trim(n);return s&&t.push((nt(i={},o,s),nt(i,"value",s),i)),t}),[])};if("number"==typeof t&&(t=t.toString()),"string"==typeof t){if(!t.trim())return[];t=u(t)}else d&&(t=t.reduce((function(t,n){if(y(n)){var i=b({},n);o in i||(o="value"),i[o]=e.trim(i[o]),i[o]&&t.push(i)}else if(n){var s;(s=t).push.apply(s,at(u(n)))}return t}),[]));return l&&!c&&(t.forEach((function(t){var n=r.map((function(t){return t.value})),i=e.dropdown.filterListItems.call(e,t[o],{exact:!0});e.settings.duplicates||(i=i.filter((function(t){return!n.includes(t.value)})));var s=i.length>1?e.getWhitelistItem(t[o],o,i):i[0];s&&it(s,Object)?r.push(s):"mix"!=a&&(null==t.value&&(t.value=t[o]),r.push(t))})),r.length&&(t=r)),t},parseMixTags:function(t){var e=this,n=this.settings,i=n.mixTagsInterpolator,s=n.duplicates,a=n.transformTag,o=n.enforceWhitelist,r=n.maxTags,l=n.tagTextProp,d=[];t=t.split(i[0]).map((function(t,n){var c,u,g,h=t.split(i[1]),p=h[0],f=d.length==r;try{if(p==+p)throw Error;u=JSON.parse(p)}catch(t){u=e.normalizeTags(p)[0]||{value:p}}if(a.call(e,u),f||!(h.length>1)||o&&!e.isTagWhitelisted(u.value)||!s&&e.isTagDuplicate(u.value)){if(t)return n?i[0]+t:t}else u[c=u[l]?l:"value"]=e.trim(u[c]),g=e.createTagElem(u),d.push(u),g.classList.add(e.settings.classNames.tagNoAnimation),h[0]=g.outerHTML,e.value.push(u);return h.join("")})).join(""),this.DOM.input.innerHTML=t,this.DOM.input.appendChild(document.createTextNode("")),this.DOM.input.normalize();var c=this.getTagElms();return c.forEach((function(t,e){return I(t,d[e])})),this.update({withoutChangeEvent:!0}),N(c,this.state.hasFocus),t},replaceTextWithNode:function(t,e){if(this.state.tag||e){e=e||this.state.tag.prefix+this.state.tag.value;var n,i,s=this.state.selection||window.getSelection(),a=s.anchorNode,o=this.state.tag.delimiters?this.state.tag.delimiters.length:0;return a.splitText(s.anchorOffset-o),-1==(n=a.nodeValue.lastIndexOf(e))?!0:(i=a.splitText(n),t&&a.parentNode.replaceChild(t,i),!0)}},prepareNewTagNode:function(t,e){e=e||{};var n=this.settings,i=[],s={},a=Object.assign({},t,{value:t.value+""});if(t=Object.assign({},a),n.transformTag.call(this,t),t.__isValid=this.hasMaxTags()||this.validateTag(t),!0!==t.__isValid){if(e.skipInvalid)return;if(b(s,this.getInvalidTagAttrs(t,t.__isValid),{__preInvalidData:a}),t.__isValid==this.TEXTS.duplicate&&this.flashTag(this.getTagElmByValue(t.value)),!n.createInvalidTags)return void i.push(t.value)}return"readonly"in t&&(t.readonly?s["aria-readonly"]=!0:delete t.readonly),{tagElm:this.createTagElem(t,s),tagData:t,aggregatedInvalidInput:i}},postProcessNewTagNode:function(t,e){var n=this,i=this.settings,s=e.__isValid;s&&!0===s?(this.value.push(e),setTimeout((function(){n.trigger("add",{tag:t,index:n.value.length-1,data:e})}))):(this.trigger("invalid",{data:e,index:this.value.length,tag:t,message:s}),i.keepInvalidTags||setTimeout((function(){return n.removeTags(t,!0)}),1e3)),this.dropdown.position()},selectTag:function(t,e){var n=this;if(!this.settings.enforceWhitelist||this.isTagWhitelisted(e.value)){this.state.actions.selectOption&&setTimeout((function(){return n.setRangeAtStartEnd(!1,n.DOM.input)}));var i=this.getLastTag();return i?this.replaceTag(i,e):this.appendTag(t),this.value[0]=e,this.update(),this.trigger("add",{tag:t,data:e}),[t]}},addEmptyTag:function(t){var e=b({value:""},t||{}),n=this.createTagElem(e);I(n,e),this.appendTag(n),this.editTag(n,{skipValidation:!0}),this.toggleFocusClass(!0)},addTags:function(t,e,n){var i=this,s=[],a=this.settings,o=[],r=document.createDocumentFragment();if(!t||0==t.length)return s;switch(t=this.normalizeTags(t),a.mode){case"mix":return this.addMixTags(t);case"select":e=!1,this.removeAllTags()}return this.DOM.input.removeAttribute("style"),t.forEach((function(t){var e=i.prepareNewTagNode(t,{skipInvalid:n||a.skipInvalid});if(e){var l=e.tagElm;if(t=e.tagData,o=e.aggregatedInvalidInput,s.push(l),"select"==a.mode)return i.selectTag(l,t);r.appendChild(l),i.postProcessNewTagNode(l,t)}})),this.appendTag(r),this.update(),t.length&&e&&(this.input.set.call(this,a.createInvalidTags?"":o.join(a._delimiters)),this.setRangeAtStartEnd(!1,this.DOM.input)),this.dropdown.refilter(),s},addMixTags:function(t){var e=this;if((t=this.normalizeTags(t))[0].prefix||this.state.tag)return this.prefixedTextToTag(t[0]);var n=document.createDocumentFragment();return t.forEach((function(t){var i=e.prepareNewTagNode(t);n.appendChild(i.tagElm),e.insertAfterTag(i.tagElm),e.postProcessNewTagNode(i.tagElm,i.tagData)})),this.appendMixTags(n),n.children},appendMixTags:function(t){var e=!!this.state.selection;e?this.injectAtCaret(t):(this.DOM.input.focus(),(e=this.setStateSelection()).range.setStart(this.DOM.input,e.range.endOffset),e.range.setEnd(this.DOM.input,e.range.endOffset),this.DOM.input.appendChild(t),this.updateValueByDOMTags(),this.update())},prefixedTextToTag:function(t){var e,n,i,s=this,a=this.settings,o=null===(e=this.state.tag)||void 0===e?void 0:e.delimiters;if(t.prefix=t.prefix||this.state.tag?this.state.tag.prefix:(a.pattern.source||a.pattern)[0],i=this.prepareNewTagNode(t),n=i.tagElm,this.replaceTextWithNode(n)||this.DOM.input.appendChild(n),setTimeout((function(){return n.classList.add(s.settings.classNames.tagNoAnimation)}),300),this.value.push(i.tagData),this.update(),!o){var r=this.insertAfterTag(n)||n;setTimeout(M,0,r)}return this.state.tag=null,this.postProcessNewTagNode(n,i.tagData),n},appendTag:function(t){var e=this.DOM,n=e.input;e.scope.insertBefore(t,n)},createTagElem:function(t,e){t.__tagId=D();var n,i=b({},t,st({value:v(t.value+"")},e));return function(t){for(var e,n=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,null,!1);e=n.nextNode();)e.textContent.trim()||e.parentNode.removeChild(e)}(n=this.parseTemplate("tag",[i,this])),I(n,t),n},reCheckInvalidTags:function(){var t=this,e=this.settings;this.getTagElms(e.classNames.tagNotAllowed).forEach((function(n,i){var s=I(n),a=t.hasMaxTags(),o=t.validateTag(s),r=!0===o&&!a;if("select"==e.mode&&t.toggleScopeValidation(o),r)return s=s.__preInvalidData?s.__preInvalidData:{value:s.value},t.replaceTag(n,s);n.title=a||o}))},removeTags:function(t,e,n){var i,s=this,a=this.settings;if(t=t&&it(t,HTMLElement)?[t]:it(t,Array)?t:t?[t]:[this.getLastTag()].filter((function(t){return t})),i=t.reduce((function(t,e){e&&"string"==typeof e&&(e=s.getTagElmByValue(e));var n=I(e);return e&&n&&!n.readonly&&t.push({node:e,idx:s.getTagIdx(n),data:I(e,{__removed:!0})}),t}),[]),n="number"==typeof n?n:this.CSSVars.tagHideTransition,"select"==a.mode&&(n=0,this.input.set.call(this)),1==i.length&&"select"!=a.mode&&i[0].node.classList.contains(a.classNames.tagNotAllowed)&&(e=!0),i.length)return a.hooks.beforeRemoveTag(i,{tagify:this}).then((function(){var t=function(t){t.node.parentNode&&(t.node.parentNode.removeChild(t.node),e?a.keepInvalidTags&&this.trigger("remove",{tag:t.node,index:t.idx}):(this.trigger("remove",{tag:t.node,index:t.idx,data:t.data}),this.dropdown.refilter(),this.dropdown.position(),this.DOM.input.normalize(),a.keepInvalidTags&&this.reCheckInvalidTags()))};n&&n>10&&1==i.length?function(e){e.node.style.width=parseFloat(window.getComputedStyle(e.node).width)+"px",document.body.clientTop,e.node.classList.add(a.classNames.tagHide),setTimeout(t.bind(this),n,e)}.call(s,i[0]):i.forEach(t.bind(s)),e||(s.removeTagsFromValue(i.map((function(t){return t.node}))),s.update(),"select"==a.mode&&a.userInput&&s.setContentEditable(!0))})).catch((function(t){}))},removeTagsFromDOM:function(){this.getTagElms().forEach((function(t){return t.remove()}))},removeTagsFromValue:function(t){var e=this;(t=Array.isArray(t)?t:[t]).forEach((function(t){var n=I(t),i=e.getTagIdx(n);i>-1&&e.value.splice(i,1)}))},removeAllTags:function(t){var e=this;t=t||{},this.value=[],"mix"==this.settings.mode?this.DOM.input.innerHTML="":this.removeTagsFromDOM(),this.dropdown.refilter(),this.dropdown.position(),this.state.dropdown.visible&&setTimeout((function(){e.DOM.input.focus()})),"select"==this.settings.mode&&(this.input.set.call(this),this.settings.userInput&&this.setContentEditable(!0)),this.update(t)},postUpdate:function(){this.state.blockChangeEvent=!1;var t,e,n=this.settings,i=n.classNames,s="mix"==n.mode?n.mixMode.integrated?this.DOM.input.textContent:this.DOM.originalInput.value.trim():this.value.length+this.input.raw.call(this).length;(this.toggleClass(i.hasMaxTags,this.value.length>=n.maxTags),this.toggleClass(i.hasNoTags,!this.value.length),this.toggleClass(i.empty,!s),"select"==n.mode)&&this.toggleScopeValidation(null===(e=this.value)||void 0===e||null===(t=e[0])||void 0===t?void 0:t.__isValid)},setOriginalInputValue:function(t){var e=this.DOM.originalInput;this.settings.mixMode.integrated||(e.value=t,e.tagifyValue=e.value,this.setPersistedData(t,"value"))},update:function(t){clearTimeout(this.debouncedUpdateTimeout),this.debouncedUpdateTimeout=setTimeout(function(){var e=this.getInputValue();this.setOriginalInputValue(e),this.settings.onChangeAfterBlur&&(t||{}).withoutChangeEvent||this.state.blockChangeEvent||this.triggerChangeEvent();this.postUpdate()}.bind(this),100),this.events.bindOriginaInputListener.call(this,100)},getInputValue:function(){var t=this.getCleanValue();return"mix"==this.settings.mode?this.getMixedTagsAsString(t):t.length?this.settings.originalInputValueFormat?this.settings.originalInputValueFormat(t):JSON.stringify(t):""},getCleanValue:function(t){return g(t||this.value,this.dataProps)},getMixedTagsAsString:function(){var t="",e=this,n=this.settings,i=n.originalInputValueFormat||JSON.stringify,s=n.mixTagsInterpolator;return function n(a){a.childNodes.forEach((function(a){if(1==a.nodeType){var o=I(a);if("BR"==a.tagName&&(t+="\r\n"),o&&x.call(e,a)){if(o.__removed)return;t+=s[0]+i(h(o,e.dataProps))+s[1]}else a.getAttribute("style")||["B","I","U"].includes(a.tagName)?t+=a.textContent:"DIV"!=a.tagName&&"P"!=a.tagName||(t+="\r\n",n(a))}else t+=a.textContent}))}(this.DOM.input),t}},ot.prototype.removeTag=ot.prototype.removeTags;var pt=function(t){return t};var ft=function(t){var s=t.name,a=t.value,o=t.loading,r=void 0!==o&&o,l=t.onInput,d=void 0===l?pt:l,c=t.onAdd,u=void 0===c?pt:c,g=t.onRemove,h=void 0===g?pt:g,p=t.onEditInput,f=void 0===p?pt:p,m=t.onEditBeforeUpdate,v=void 0===m?pt:m,y=t.onEditUpdated,b=void 0===y?pt:y,w=t.onEditStart,T=void 0===w?pt:w,O=t.onEditKeydown,D=void 0===O?pt:O,x=t.onInvalid,S=void 0===x?pt:x,E=t.onClick,I=void 0===E?pt:E,M=t.onKeydown,N=void 0===M?pt:M,_=t.onFocus,A=void 0===_?pt:_,C=t.onBlur,k=void 0===C?pt:C,L=t.onChange,j=void 0===L?pt:L,P=t.onDropdownShow,V=void 0===P?pt:P,R=t.onDropdownHide,F=void 0===R?pt:R,H=t.onDropdownSelect,B=void 0===H?pt:H,U=t.onDropdownScroll,W=void 0===U?pt:U,K=t.onDropdownNoMatch,q=void 0===K?pt:K,z=t.onDropdownUpdated,X=void 0===z?pt:z,J=t.readOnly,G=t.disabled,$=t.userInput,Q=void 0===$||$,Y=t.children,Z=t.settings,tt=void 0===Z?{}:Z,et=t.InputMode,nt=void 0===et?"input":et,it=t.autoFocus,st=t.className,at=t.whitelist,rt=t.tagifyRef,lt=t.placeholder,ct=void 0===lt?"":lt,ut=t.defaultValue,ft=t.showDropdown,mt=n.useRef(),vt=n.useRef(),yt=n.useRef(),bt=n.useRef(),wt=ut||a,Tt=n.useMemo((function(){return{ref:vt,name:s,defaultValue:Y||"string"==typeof wt?wt:JSON.stringify(wt),className:st,readOnly:J,disabled:G,autoFocus:it,placeholder:ct}}),[]),Ot=n.useCallback((function(){it&&yt.current&&yt.current.DOM.input.focus()}),[yt]);return n.useEffect((function(){!function(t){if(t){var n=function(n){var s=t[n];String(s).includes("jsxRuntime")&&(t[n]=function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return i.renderToStaticMarkup(e.jsx(s,{props:n}))})};for(var s in t)n(s)}}(tt.templates),tt.userInput=Q,"textarea"==nt&&(tt.mode="mix"),at&&at.length&&(tt.whitelist=at);var t=new ot(vt.current,tt);return rt&&(rt.current=t),yt.current=t,Ot(),function(){t.destroy()}}),[]),n.useEffect((function(){yt.current.off("change").on("change",j)}),[j]),n.useEffect((function(){yt.current.off("input").on("input",d)}),[d]),n.useEffect((function(){yt.current.off("add").on("add",u)}),[u]),n.useEffect((function(){yt.current.off("remove").on("remove",h)}),[h]),n.useEffect((function(){yt.current.off("invalid").on("invalid",S)}),[S]),n.useEffect((function(){yt.current.off("keydown").on("keydown",N)}),[N]),n.useEffect((function(){yt.current.off("focus").on("focus",A)}),[A]),n.useEffect((function(){yt.current.off("blur").on("blur",k)}),[k]),n.useEffect((function(){yt.current.off("click").on("click",I)}),[I]),n.useEffect((function(){yt.current.off("edit:input").on("edit:input",f)}),[f]),n.useEffect((function(){yt.current.off("edit:beforeUpdate").on("edit:beforeUpdate",v)}),[v]),n.useEffect((function(){yt.current.off("edit:updated").on("edit:updated",b)}),[b]),n.useEffect((function(){yt.current.off("edit:start").on("edit:start",T)}),[T]),n.useEffect((function(){yt.current.off("edit:keydown").on("edit:keydown",D)}),[D]),n.useEffect((function(){yt.current.off("dropdown:show").on("dropdown:show",V)}),[V]),n.useEffect((function(){yt.current.off("dropdown:hide").on("dropdown:hide",F)}),[F]),n.useEffect((function(){yt.current.off("dropdown:select").on("dropdown:select",B)}),[B]),n.useEffect((function(){yt.current.off("dropdown:scroll").on("dropdown:scroll",W)}),[W]),n.useEffect((function(){yt.current.off("dropdown:noMatch").on("dropdown:noMatch",q)}),[q]),n.useEffect((function(){yt.current.off("dropdown:updated").on("dropdown:updated",X)}),[X]),n.useEffect((function(){Ot()}),[it]),n.useEffect((function(){var t;mt.current&&(yt.current.settings.whitelist.length=0,at&&at.length&&(t=yt.current.settings.whitelist).push.apply(t,gt(at)))}),[at]),n.useEffect((function(){var t,e,n=yt.current.getInputValue();mt.current&&(t=n,(e=function(t){return"string"==typeof t?t:JSON.stringify(t)})(a)!=e(t))&&yt.current.loadOriginalValues(a)}),[a]),n.useEffect((function(){if(mt.current){var t=function(t,e){if((void 0===t?"undefined":ht(t))==(void 0===e?"undefined":ht(e))){var n=t.split(" "),i=e.split(" ");return{added:i.filter((function(t){return!n.includes(t)})),removed:n.filter((function(t){return!i.includes(t)}))}}}(bt.current,st),e=t.added,n=t.removed;e.filter(String).forEach((function(t){return yt.current.toggleClass(t,!0)})),n.filter(String).forEach((function(t){return yt.current.toggleClass(t,!1)}))}bt.current=st}),[st]),n.useEffect((function(){mt.current&&yt.current.loading(r)}),[r]),n.useEffect((function(){mt.current&&yt.current.setReadonly(J)}),[J]),n.useEffect((function(){mt.current&&yt.current.setDisabled(G)}),[G]),n.useEffect((function(){mt.current&&(yt.current.userInput=Q)}),[Q]),n.useEffect((function(){mt.current&&yt.current.setPlaceholder(ct)}),[ct]),n.useEffect((function(){var t=yt.current;mt.current&&(ft?(t.dropdown.show.call(t,ft),t.toggleFocusClass(!0)):t.dropdown.hide.call(t))}),[ft]),n.useEffect((function(){mt.current=!0}),[]),e.jsx("div",{className:"tags-input",children:e.jsx(nt,dt({},Tt))})};ft.propTypes={name:s.string,value:s.oneOfType([s.string,s.array]),loading:s.bool,children:s.oneOfType([s.string,s.array]),onChange:s.func,readOnly:s.bool,disabled:s.bool,userInput:s.bool,settings:s.object,InputMode:s.string,autoFocus:s.bool,className:s.string,tagifyRef:s.object,whitelist:s.array,placeholder:s.string,defaultValue:s.oneOfType([s.string,s.array]),showDropdown:s.oneOfType([s.string,s.bool]),onInput:s.func,onAdd:s.func,onRemove:s.func,onEditInput:s.func,onEditBeforeUpdate:s.func,onEditUpdated:s.func,onEditStart:s.func,onEditKeydown:s.func,onInvalid:s.func,onClick:s.func,onKeydown:s.func,onFocus:s.func,onBlur:s.func,onDropdownShow:s.func,onDropdownHide:s.func,onDropdownSelect:s.func,onDropdownScroll:s.func,onDropdownNoMatch:s.func,onDropdownUpdated:s.func};var mt=o.default.memo(ft);mt.displayName="Tags";t.MixedTags=function(t){var n=t.children,i=ut(t,["children"]);return e.jsx(mt,ct(dt({InputMode:"textarea"},i),{children:n}))},t.default=mt,Object.defineProperty(t,"__esModule",{value:!0})}));
