UNPKG

@zanmato/vue3-treeselect

Version:

Tree select hierarchical component for Vue 3

6 lines 62.8 kB
/*! * vue3-treeselect v0.4.4 | (c) 2026 Andreas Johansson * Released under the MIT License. * https://zanmato.github.io/vue3-treeselect/ */ import{Transition as e,TransitionGroup as t,createApp as n,createElementBlock as r,createElementVNode as i,createTextVNode as o,createVNode as s,defineComponent as a,inject as l,mergeProps as u,openBlock as c}from"vue";import{default as d}from"fuzzysearch";import{default as h}from"lodash/noop";import{default as f}from"lodash/debounce";import{default as p}from"watch-size";import{default as v}from"is-promise";import{default as m}from"lodash/once";import{default as y}from"lodash/identity";import{default as g}from"lodash/constant";import{default as b}from"lodash/last";var S={510(e,t){t.A=(e,t)=>{const n=e.__vccOpts||e;for(const[e,r]of t)n[e]=r;return n}}},O={};function w(e){var t=O[e];if(void 0!==t)return t.exports;var n=O[e]={exports:{}};return S[e](n,n.exports,w),n.exports}w.d=(e,t)=>{for(var n in t)w.o(t,n)&&!w.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},w.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var N=h;function _(e){return function(t){if("mousedown"===t.type&&0===t.button){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.call.apply(e,[this,t].concat(r))}}}function M(e,t){var n=!0,r=p(e,function(){return n||t.apply(void 0,arguments)});return n=!1,r}function L(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return x(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e){var t=getComputedStyle(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/(auto|scroll|overlay)/.test(n+i+r)}function I(e,t){var n=function(e){for(var t=[],n=e.parentNode;n&&"BODY"!==n.nodeName&&n.nodeType===document.ELEMENT_NODE;)C(n)&&t.push(n),n=n.parentNode;return t.push(window),t}(e);window.addEventListener("resize",t,{passive:!0});var r,i=L(n);try{for(i.s();!(r=i.n()).done;){r.value.addEventListener("scroll",t,{passive:!0})}}catch(e){i.e(e)}finally{i.f()}return function(){window.removeEventListener("resize",t,{passive:!0});var e,r=L(n);try{for(r.s();!(e=r.n()).done;){e.value.removeEventListener("scroll",t,{passive:!0})}}catch(e){r.e(e)}finally{r.f()}}}function E(e){return e!=e}var A=function(){return Object.create(null)};function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function T(e){return null!=e&&"object"===D(e)&&Object.getPrototypeOf(e)===Object.prototype}function B(e,t,n){T(n)?(e[t]||(e[t]={}),R(e[t],n)):e[t]=n}function R(e,t){if(T(t))for(var n=Object.keys(t),r=0,i=n.length;r<i;r++)B(e,n[r],t[n[r]]);return e}function z(e,t){return e.includes(t)}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||k(e,t)||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 k(e,t){if(e){if("string"==typeof e)return j(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(e,t):void 0}}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function F(e,t){if(e.length!==t.length)return!0;var n,r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}(e.entries());try{for(r.s();!(n=r.n()).done;){var i=V(n.value,2),o=i[0];if(i[1]!==t[o])return!0}}catch(e){r.e(e)}finally{r.f()}return!1}var P=null,$="ALL_CHILDREN",H="ALL_DESCENDANTS",W="LEAF_CHILDREN",Q="LEAF_DESCENDANTS",K="LOAD_ROOT_OPTIONS",q="LOAD_CHILDREN_OPTIONS",U="ASYNC_SEARCH",X="ALL",Y="BRANCH_PRIORITY",J="LEAF_PRIORITY",G="ALL_WITH_INDETERMINATE",Z="ORDER_SELECTED",ee="LEVEL",te="INDEX",ne=8,re=13,ie=27,oe=35,se=36,ae=37,le=38,ue=39,ce=40,de=46;function he(e){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(e)}function fe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,a=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return a}}(e,t)||be(e,t)||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 pe(e){return function(e){if(Array.isArray(e))return Se(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||be(e)||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 ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function me(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach(function(t){ye(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ye(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=he(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=he(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==he(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ge(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=be(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function be(e,t){if(e){if("string"==typeof e)return Se(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Se(e,t):void 0}}function Se(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Oe(e,t){for(var n=0;;){if(e.level<n)return-1;if(t.level<n)return 1;if(e.index[n]!==t.index[n])return e.index[n]-t.index[n];n++}}function we(e,t,n){return e?d(t,n):z(n,t)}function Ne(e){return e.message||String(e)}var _e=0;const Me={provide:function(){return{instance:this}},props:{allowClearingDisabled:{type:Boolean,default:!1},allowSelectingDisabledDescendants:{type:Boolean,default:!1},alwaysOpen:{type:Boolean,default:!1},appendToBody:{type:Boolean,default:!1},async:{type:Boolean,default:!1},autoFocus:{type:Boolean,default:!1},autoLoadRootOptions:{type:Boolean,default:!0},autoDeselectAncestors:{type:Boolean,default:!1},autoDeselectDescendants:{type:Boolean,default:!1},autoSelectAncestors:{type:Boolean,default:!1},autoSelectDescendants:{type:Boolean,default:!1},backspaceRemoves:{type:Boolean,default:!0},beforeClearAll:{type:Function,default:g(!0)},branchNodesFirst:{type:Boolean,default:!1},cacheOptions:{type:Boolean,default:!0},clearable:{type:Boolean,default:!0},clearAllText:{type:String,default:"Clear all"},clearOnSelect:{type:Boolean,default:!1},clearValueText:{type:String,default:"Clear value"},closeOnSelect:{type:Boolean,default:!0},defaultExpandLevel:{type:Number,default:0},deleteRemoves:{type:Boolean,default:!0},delimiter:{type:String,default:","},flattenSearchResults:{type:Boolean,default:!1},disableBranchNodes:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disableFuzzyMatching:{type:Boolean,default:!1},flat:{type:Boolean,default:!1},instanceId:{default:function(){return"".concat(_e++,"$$")},type:[String,Number]},joinValues:{type:Boolean,default:!1},limit:{type:Number,default:Number.POSITIVE_INFINITY},limitText:{type:Function,default:function(e){return"and ".concat(e," more")}},loadingText:{type:String,default:"Loading..."},loadOptions:{type:Function},matchKeys:{type:Array,default:g(["label"])},maxHeight:{type:Number,default:300},multiple:{type:Boolean,default:!1},name:{type:String},noChildrenText:{type:String,default:"No sub-options."},noOptionsText:{type:String,default:"No options available."},noResultsText:{type:String,default:"No results found..."},normalizer:{type:Function,default:y},openDirection:{type:String,default:"auto",validator:function(e){return z(["auto","top","bottom","above","below"],e)}},openOnClick:{type:Boolean,default:!0},openOnFocus:{type:Boolean,default:!1},options:{type:Array},placeholder:{type:String,default:"Select..."},required:{type:Boolean,default:!1},retryText:{type:String,default:"Retry?"},retryTitle:{type:String,default:"Click to retry"},searchable:{type:Boolean,default:!0},searchNested:{type:Boolean,default:!1},searchPromptText:{type:String,default:"Type to search..."},showCount:{type:Boolean,default:!1},showCountOf:{type:String,default:$,validator:function(e){return z([$,H,W,Q],e)}},showCountOnSearch:null,sortValueBy:{type:String,default:Z,validator:function(e){return z([Z,ee,te],e)}},tabIndex:{type:Number,default:0},modelValue:null,valueConsistsOf:{type:String,default:Y,validator:function(e){return z([X,Y,J,G],e)}},valueFormat:{type:String,default:"id"},zIndex:{type:[Number,String],default:999}},data:function(){return{trigger:{isFocused:!1,searchQuery:""},menu:{isOpen:!1,current:null,lastScrollPosition:0,placement:"bottom",renderKey:0},forest:{normalizedOptions:[],nodeMap:A(),checkedStateMap:A(),selectedNodeIds:this.extractCheckedNodeIdsFromValue(),selectedNodeMap:A()},rootOptionsStates:{isLoaded:!1,isLoading:!1,loadingError:""},localSearch:{active:!1,noResults:!0,countMap:A()},remoteSearch:A(),hasBranchNodes:!1}},computed:{selectedNodes:function(){return this.forest.selectedNodeIds.map(this.getNode)},internalValue:function(){var e,t=this;if(this.single||this.flat||this.disableBranchNodes||this.valueConsistsOf===X)e=this.forest.selectedNodeIds.slice();else if(this.valueConsistsOf===Y)e=this.forest.selectedNodeIds.filter(function(e){var n=t.getNode(e);return!!n.isRootNode||!t.isSelected(n.parentNode)});else if(this.valueConsistsOf===J)e=this.forest.selectedNodeIds.filter(function(e){var n=t.getNode(e);return!!n.isLeaf||0===n.children.length});else if(this.valueConsistsOf===G){var n,r=[];e=this.forest.selectedNodeIds.slice();var i,o=ge(this.selectedNodes);try{for(o.s();!(i=o.n()).done;){var s,a=ge(i.value.ancestors);try{for(a.s();!(s=a.n()).done;){var l=s.value;z(r,l.id)||(z(e,l.id)||r.push(l.id))}}catch(e){a.e(e)}finally{a.f()}}}catch(e){o.e(e)}finally{o.f()}(n=e).push.apply(n,r)}return this.sortValueBy===ee?e.sort(function(e,n){return function(e,t){return e.level===t.level?Oe(e,t):e.level-t.level}(t.getNode(e),t.getNode(n))}):this.sortValueBy===te&&e.sort(function(e,n){return Oe(t.getNode(e),t.getNode(n))}),e},hasValue:function(){return this.internalValue.length>0},single:function(){return!this.multiple},visibleOptionIds:function(){var e=this,t=[];return this.traverseAllNodesByIndex(function(n){if(e.localSearch.active&&!e.shouldOptionBeIncludedInSearchResult(n)||t.push(n.id),n.isBranch&&!e.shouldExpand(n))return!1}),t},navigableOptionIds:function(){if(this.localSearch.active)return this.visibleOptionIds;var e=[];return this.traverseAllNodesByIndex(function(t){e.push(t.id)}),e},hasVisibleOptions:function(){return 0!==this.visibleOptionIds.length},showCountOnSearchComputed:function(){return"boolean"==typeof this.showCountOnSearch?this.showCountOnSearch:this.showCount},shouldFlattenOptions:function(){return this.localSearch.active&&this.flattenSearchResults}},watch:{alwaysOpen:function(e){e?this.openMenu():this.closeMenu()},branchNodesFirst:function(){this.initialize()},disabled:function(e){e&&this.menu.isOpen?this.closeMenu():e||this.menu.isOpen||!this.alwaysOpen||this.openMenu()},flat:function(){this.initialize()},internalValue:function(e,t){F(e,t)&&this.$emit("update:modelValue",this.getValue(),this.getInstanceId())},matchKeys:function(){this.initialize()},multiple:function(e){e&&this.buildForestState()},options:{handler:function(){this.initialize(),this.rootOptionsStates.isLoaded=Array.isArray(this.options)},deep:!0,immediate:!0},"trigger.searchQuery":function(){this.async?this.handleRemoteSearch():this.handleLocalSearch(),this.$emit("search-change",this.trigger.searchQuery,this.getInstanceId())},modelValue:function(){var e=this.extractCheckedNodeIdsFromValue();F(e,this.internalValue)&&this.fixSelectedNodeIds(e)}},methods:{verifyProps:function(){var e=this;if(N(function(){return!e.async||e.searchable},function(){return'For async search mode, the value of "searchable" prop must be true.'}),null!=this.options||this.loadOptions||N(function(){return!1},function(){return'Are you meant to dynamically load options? You need to use "loadOptions" prop.'}),this.flat&&N(function(){return e.multiple},function(){return'You are using flat mode. But you forgot to add "multiple=true"?'}),!this.flat)for(var t=function(){var t=r[n];N(function(){return!e[t]},function(){return'"'.concat(t,'" only applies to flat mode.')})},n=0,r=["autoSelectAncestors","autoSelectDescendants","autoDeselectAncestors","autoDeselectDescendants"];n<r.length;n++)t()},resetFlags:function(){this._blurOnSelect=!1},initialize:function(){var e=this.async&&""!==this.trigger.searchQuery?this.getRemoteSearchEntry().options:this.options;if(Array.isArray(e)){var t=this.forest.nodeMap;this.forest.nodeMap=A(),this.keepDataOfSelectedNodes(t),this.forest.normalizedOptions=this.normalize(P,e,t),this.fixSelectedNodeIds(this.internalValue),this.hasBranchNodes=this.forest.normalizedOptions.some(function(e){return e.isBranch})}else this.forest.normalizedOptions=[]},getInstanceId:function(){return null==this.instanceId?this.id:this.instanceId},getValue:function(){var e=this;if("id"===this.valueFormat)return this.multiple?this.internalValue.slice():this.internalValue[0];var t=this.internalValue.map(function(t){return e.getNode(t).raw});return this.multiple?t:t[0]},getNode:function(e){return N(function(){return null!=e},function(){return"Invalid node id: ".concat(e)}),null==e?null:e in this.forest.nodeMap?this.forest.nodeMap[e]:this.createFallbackNode(e)},createFallbackNode:function(e){var t=this.extractNodeFromValue(e),n={id:e,label:this.enhancedNormalizer(t).label||"".concat(e," (unknown)"),ancestors:[],parentNode:P,isFallbackNode:!0,isRootNode:!0,isLeaf:!0,isBranch:!1,isDisabled:!1,isNew:!1,index:[-1],level:0,raw:t};return this.forest.nodeMap[e]=n},extractCheckedNodeIdsFromValue:function(){var e=this;return null==this.modelValue?[]:"id"===this.valueFormat?this.multiple?this.modelValue.slice():[this.modelValue]:(this.multiple?this.modelValue:[this.modelValue]).map(function(t){return e.enhancedNormalizer(t)}).map(function(e){return e.id})},extractNodeFromValue:function(e){var t=this,n={id:e};return"id"===this.valueFormat?n:function(e,t,n){for(var r=0,i=e.length;r<i;r++)if(t.call(n,e[r],r,e))return e[r]}(this.multiple?Array.isArray(this.modelValue)?this.modelValue:[]:this.modelValue?[this.modelValue]:[],function(n){return n&&t.enhancedNormalizer(n).id===e})||n},fixSelectedNodeIds:function(e){var t=this,n=[];if(this.single||this.flat||this.disableBranchNodes||this.valueConsistsOf===X)n=e;else if(this.valueConsistsOf===Y){var r,i=ge(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.push(o);var s=this.getNode(o);s.isBranch&&this.traverseDescendantsBFS(s,function(e){n.push(e.id)})}}catch(e){i.e(e)}finally{i.f()}}else if(this.valueConsistsOf===J)for(var a=A(),l=e.slice();l.length;){var u=l.shift(),c=this.getNode(u);n.push(u),c.isRootNode||(c.parentNode.id in a||(a[c.parentNode.id]=c.parentNode.children.length),0===--a[c.parentNode.id]&&l.push(c.parentNode.id))}else if(this.valueConsistsOf===G)for(var d=A(),h=e.filter(function(e){var n=t.getNode(e);return n.isLeaf||0===n.children.length});h.length;){var f=h.shift(),p=this.getNode(f);n.push(f),p.isRootNode||(p.parentNode.id in d||(d[p.parentNode.id]=p.parentNode.children.length),0===--d[p.parentNode.id]&&h.push(p.parentNode.id))}F(this.forest.selectedNodeIds,n)&&(this.forest.selectedNodeIds=n),this.buildForestState()},keepDataOfSelectedNodes:function(e){var t,n=ge(this.forest.selectedNodeIds);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(e[r]){var i=me(me({},e[r]),{},{isFallbackNode:!0});this.forest.nodeMap[r]=i}}}catch(e){n.e(e)}finally{n.f()}},isSelected:function(e){return e&&!0===this.forest.selectedNodeMap[e.id]},traverseDescendantsBFS:function(e,t){if(e.isBranch)for(var n=e.children.slice();n.length;){var r=n[0];r.isBranch&&n.push.apply(n,pe(r.children)),t(r),n.shift()}},traverseDescendantsDFS:function(e,t){if(e.isBranch){var n,r=ge(e.children);try{for(r.s();!(n=r.n()).done;){var i=n.value;this.traverseDescendantsDFS(i,t),t(i)}}catch(e){r.e(e)}finally{r.f()}}},traverseAllNodesDFS:function(e){var t,n=ge(this.forest.normalizedOptions);try{for(n.s();!(t=n.n()).done;){var r=t.value;this.traverseDescendantsDFS(r,e),e(r)}}catch(e){n.e(e)}finally{n.f()}},traverseAllNodesByIndex:function(e){var t=function(n){var r,i=ge(n.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;!1!==e(o)&&o.isBranch&&t(o)}}catch(e){i.e(e)}finally{i.f()}};t({children:this.forest.normalizedOptions})},toggleClickOutsideEvent:function(e){e?document.addEventListener("mousedown",this.handleClickOutside,!1):document.removeEventListener("mousedown",this.handleClickOutside,!1)},getValueContainer:function(){return this.$refs.control.$refs["value-container"]},getInput:function(){return this.getValueContainer().$refs.input},focusInput:function(){this.getInput().focus()},blurInput:function(){this.getInput().blur()},handleMouseDown:_(function(e){(e.preventDefault(),e.stopPropagation(),this.disabled)||(this.getValueContainer().$el.contains(e.target)&&!this.menu.isOpen&&(this.openOnClick||this.trigger.isFocused)&&this.openMenu(),this._blurOnSelect?this.blurInput():this.focusInput(),this.resetFlags())}),handleClickOutside:function(e){this.$refs.wrapper&&!this.$refs.wrapper.contains(e.target)&&(this.blurInput(),this.closeMenu())},handleLocalSearch:function(){var e=this,t=this.trigger.searchQuery,n=function(){return e.resetHighlightedOptionWhenNecessary(!0)};if(!t)return this.localSearch.active=!1,n();this.localSearch.active=!0,this.localSearch.noResults=!0,this.traverseAllNodesDFS(function(t){t.isBranch&&(t.isExpandedOnSearch=!1,t.showAllChildrenOnSearch=!1,t.isMatched=!1,t.hasMatchedDescendants=!1,e.localSearch.countMap[t.id]=ye(ye(ye(ye({},$,0),H,0),W,0),Q,0))});var r=t.trim().toLocaleLowerCase(),i=r.replace(/\s+/g," ").split(" ");this.traverseAllNodesDFS(function(t){if(e.searchNested&&i.length>1?t.isMatched=i.every(function(e){return we(!1,e,t.nestedSearchLabel)}):t.isMatched=e.matchKeys.some(function(n){return we(!e.disableFuzzyMatching,r,t.lowerCased[n])}),t.isMatched){e.localSearch.noResults=!1;var n,o=ge(t.ancestors);try{for(o.s();!(n=o.n()).done;){var s=n.value;e.localSearch.countMap[s.id][H]++}}catch(e){o.e(e)}finally{o.f()}t.parentNode!==P&&(e.localSearch.countMap[t.parentNode.id][$]+=1,t.isLeaf&&(e.localSearch.countMap[t.parentNode.id][W]+=1))}(t.isMatched||t.isBranch&&t.isExpandedOnSearch)&&t.parentNode!==P&&(t.parentNode.isExpandedOnSearch=!0,t.parentNode.hasMatchedDescendants=!0)}),n()},handleRemoteSearch:function(){var e=this,t=this.trigger.searchQuery,n=function(){return e.getRemoteSearchEntry()},r=function(n){e.remoteSearch[t]=me(me({},e.remoteSearch[t]),n)},i=function(){e.initialize(),e.resetHighlightedOptionWhenNecessary(!0),e.menu.renderKey++};if((""===t||this.cacheOptions)&&n().isLoaded)return i();this.callLoadOptionsProp({action:U,args:{searchQuery:t},isPending:function(){return n().isLoading},start:function(){r({isLoading:!0,isLoaded:!1,loadingError:""})},succeed:function(n){r({isLoaded:!0,options:n}),e.trigger.searchQuery===t&&i(),i()},fail:function(e){r({loadingError:Ne(e)})},end:function(){r({isLoading:!1})}})},getRemoteSearchEntry:function(){var e=this.trigger.searchQuery,t=this.remoteSearch[e]||me(me({},{isLoaded:!1,isLoading:!1,loadingError:""}),{},{options:[]});return""===e?(Array.isArray(this.options)&&(t.options=this.options),t.isLoaded=!0,t.isLoading=!1,t):(this.remoteSearch[e]||(this.remoteSearch[e]=t),t)},shouldExpand:function(e){return this.localSearch.active?e.isExpandedOnSearch:e.isExpanded},shouldOptionBeIncludedInSearchResult:function(e){return!!e.isMatched||(!(!e.isBranch||!e.hasMatchedDescendants||this.flattenSearchResults)||!(e.isRootNode||!e.parentNode.showAllChildrenOnSearch))},shouldShowOptionInMenu:function(e){return!(this.localSearch.active&&!this.shouldOptionBeIncludedInSearchResult(e))},getControl:function(){var e;return null!==(e=this.$refs)&&void 0!==e&&e.control?this.$refs.control.$el:null},getMenu:function(){var e,t;if(!this.$refs)return null;var n=this.appendToBody?null===(e=this.$refs.portal)||void 0===e||null===(e=e.$refs)||void 0===e?void 0:e.menu:null===(t=this.$refs.menu)||void 0===t||null===(t=t.$refs)||void 0===t?void 0:t.menu;return n&&"#comment"!==n.nodeName?n:null},setCurrentHighlightedOption:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this.menu.current;if(null!=r&&r in this.forest.nodeMap&&(this.forest.nodeMap[r].isHighlighted=!1),this.menu.current=e.id,e.isHighlighted=!0,this.menu.isOpen&&n){var i=function(){var n=t.getMenu();if(n){var r,i,o,s,a,l=n.querySelector('.vue3-treeselect__option[data-id="'.concat(e.id,'"]'));l&&(i=l,o=(r=n).getBoundingClientRect(),s=i.getBoundingClientRect(),a=i.offsetHeight/3,s.bottom+a>o.bottom?r.scrollTop=Math.min(i.offsetTop+i.clientHeight-r.offsetHeight+a,r.scrollHeight):s.top-a<o.top&&(r.scrollTop=Math.max(i.offsetTop-a,0)))}};this.getMenu()?i():this.$nextTick(i)}},resetHighlightedOptionWhenNecessary:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.menu.current;!e&&null!=t&&t in this.forest.nodeMap&&this.shouldShowOptionInMenu(this.getNode(t))||this.highlightFirstOption()},highlightFirstOption:function(){if(this.hasVisibleOptions){var e=this.visibleOptionIds[0];this.setCurrentHighlightedOption(this.getNode(e))}},highlightPrevOption:function(){if(this.hasVisibleOptions){var e=this.visibleOptionIds.indexOf(this.menu.current)-1;if(-1===e)return this.highlightLastOption();this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]))}},highlightNextOption:function(){if(this.hasVisibleOptions){var e=this.visibleOptionIds.indexOf(this.menu.current)+1;if(e===this.visibleOptionIds.length)return this.highlightFirstOption();this.setCurrentHighlightedOption(this.getNode(this.visibleOptionIds[e]))}},highlightLastOption:function(){if(this.hasVisibleOptions){var e=b(this.visibleOptionIds);this.setCurrentHighlightedOption(this.getNode(e))}},resetSearchQuery:function(){this.trigger.searchQuery=""},closeMenu:function(){!this.menu.isOpen||!this.disabled&&this.alwaysOpen||(this.saveMenuScrollPosition(),this.menu.isOpen=!1,this.toggleClickOutsideEvent(!1),this.resetSearchQuery(),this.$emit("close",this.getValue(),this.getInstanceId()))},openMenu:function(){this.disabled||this.menu.isOpen||(this.menu.isOpen=!0,this.$nextTick(this.resetHighlightedOptionWhenNecessary),this.$nextTick(this.restoreMenuScrollPosition),this.options||this.loadRootOptions(),this.toggleClickOutsideEvent(!0),this.$emit("open",this.getInstanceId()))},toggleMenu:function(){this.menu.isOpen?this.closeMenu():this.openMenu()},toggleExpanded:function(e){var t;this.localSearch.active?(t=e.isExpandedOnSearch=!e.isExpandedOnSearch)&&(e.showAllChildrenOnSearch=!0):t=e.isExpanded=!e.isExpanded,t&&!e.childrenStates.isLoaded&&this.loadChildrenOptions(e)},buildForestState:function(){var e,t=A(),n=ge(this.forest.selectedNodeIds);try{for(n.s();!(e=n.n()).done;){t[e.value]=!0}}catch(e){n.e(e)}finally{n.f()}this.forest.selectedNodeMap=t;var r=A();if(this.multiple){this.traverseAllNodesByIndex(function(e){r[e.id]=0});var i,o=ge(this.selectedNodes);try{for(o.s();!(i=o.n()).done;){var s=i.value;if(r[s.id]=2,!this.flat&&!this.disableBranchNodes){var a,l=ge(s.ancestors);try{for(l.s();!(a=l.n()).done;){var u=a.value;this.isSelected(u)||(r[u.id]=1)}}catch(e){l.e(e)}finally{l.f()}}}}catch(e){o.e(e)}finally{o.f()}}this.forest.checkedStateMap=r},enhancedNormalizer:function(e){return me(me({},e),this.normalizer(e,this.getInstanceId()))},mapToNode:function(e,t,n,r){var i=fe(e,2),o=i[0],s=i[1];this.checkDuplication(o),this.verifyNodeShape(o);var a=o.id,l=o.label,u=o.children,c=o.isDefaultExpanded,d=n===P,h=d?0:n.level+1,f=Array.isArray(u)||null===u,p=!f,v=!!o.isDisabled||!this.flat&&!d&&n.isDisabled,m=!!o.isNew,y=this.matchKeys.reduce(function(e,t){return me(me({},e),{},ye({},t,(n=o[t],"string"==typeof n?n:"number"!=typeof n||E(n)?"":n+"").toLocaleLowerCase()));var n},{}),g=d?y.label:n.nestedSearchLabel+" "+y.label;this.forest.nodeMap[a]=A();var b=this.forest.nodeMap[a];if(b.id=a,b.label=l,b.level=h,b.ancestors=d?[]:[n].concat(n.ancestors),b.index=(d?[]:n.index).concat(t),b.parentNode=n,b.lowerCased=y,b.nestedSearchLabel=g,b.isDisabled=v,b.isNew=m,b.isMatched=!1,b.isHighlighted=!1,b.isBranch=f,b.isLeaf=p,b.isRootNode=d,b.raw=s,f){var S=Array.isArray(u);if(b.childrenStates=me(me({},{isLoaded:!1,isLoading:!1,loadingError:""}),{},{isLoaded:S}),b.isExpanded="boolean"==typeof c?c:h<this.defaultExpandLevel,b.hasMatchedDescendants=!1,b.hasDisabledDescendants=!1,b.isExpandedOnSearch=!1,b.showAllChildrenOnSearch=!1,b.count=ye(ye(ye(ye({},$,0),H,0),W,0),Q,0),b.children=S?this.normalize(b,u,r):[],!0===c){var O,w=ge(b.ancestors);try{for(w.s();!(O=w.n()).done;){O.value.isExpanded=!0}}catch(e){w.e(e)}finally{w.f()}}S||"function"==typeof this.loadOptions?!S&&b.isExpanded&&this.loadChildrenOptions(b):N(function(){return!1},function(){return'Unloaded branch node detected. "loadOptions" prop is required to load its children.'})}var _,M=ge(b.ancestors);try{for(M.s();!(_=M.n()).done;){_.value.count[H]++}}catch(e){M.e(e)}finally{M.f()}if(p){var L,x=ge(b.ancestors);try{for(x.s();!(L=x.n()).done;){L.value.count[Q]++}}catch(e){x.e(e)}finally{x.f()}}if(d||(n.count[$]+=1,p&&(n.count[W]+=1),v&&(n.hasDisabledDescendants=!0)),r&&r[a]){var C=r[a];b.isMatched=C.isMatched,b.showAllChildrenOnSearch=C.showAllChildrenOnSearch,b.isHighlighted=C.isHighlighted,C.isBranch&&b.isBranch&&(b.isExpanded=C.isExpanded,b.isExpandedOnSearch=C.isExpandedOnSearch,b.hasMatchedDescendants=C.hasMatchedDescendants,C.childrenStates.isLoaded&&!b.childrenStates.isLoaded?b.isExpanded=!1:b.childrenStates=me({},C.childrenStates))}return b},normalize:function(e,t,n){var r=this,i=t.map(function(e){return[r.enhancedNormalizer(e),e]}).map(function(t,i){return r.mapToNode(t,i,e,n)});if(this.branchNodesFirst){var o=i.filter(function(e){return e.isBranch}),s=i.filter(function(e){return e.isLeaf});i=o.concat(s)}return i},loadRootOptions:function(){var e=this;this.callLoadOptionsProp({action:K,isPending:function(){return e.rootOptionsStates.isLoading},start:function(){e.rootOptionsStates.isLoading=!0,e.rootOptionsStates.loadingError=""},succeed:function(){e.rootOptionsStates.isLoaded=!0,e.$nextTick(function(){e.resetHighlightedOptionWhenNecessary(!0)})},fail:function(t){e.rootOptionsStates.loadingError=Ne(t)},end:function(){e.rootOptionsStates.isLoading=!1}})},loadChildrenOptions:function(e){var t=this,n=e.id,r=e.raw;this.callLoadOptionsProp({action:q,args:{parentNode:r},isPending:function(){return t.getNode(n).childrenStates.isLoading},start:function(){t.getNode(n).childrenStates.isLoading=!0,t.getNode(n).childrenStates.loadingError=""},succeed:function(){t.getNode(n).childrenStates.isLoaded=!0},fail:function(e){t.getNode(n).childrenStates.loadingError=Ne(e)},end:function(){t.getNode(n).childrenStates.isLoading=!1}})},callLoadOptionsProp:function(e){var t=e.action,n=e.args,r=e.isPending,i=e.start,o=e.succeed,s=e.fail,a=e.end;if(this.loadOptions&&!r()){i();var l=m(function(e,t){e?s(e):o(t),a()}),u=this.loadOptions(me(me({id:this.getInstanceId(),instanceId:this.getInstanceId(),action:t},n),{},{callback:l}));v(u)&&u.then(function(){l()},function(e){l(e)}).catch(function(e){console.error(e)})}},checkDuplication:function(e){var t=this;N(function(){return!(e.id in t.forest.nodeMap&&!t.forest.nodeMap[e.id].isFallbackNode)},function(){return"Detected duplicate presence of node id ".concat(JSON.stringify(e.id),". ")+'Their labels are "'.concat(t.forest.nodeMap[e.id].label,'" and "').concat(e.label,'" respectively.')})},verifyNodeShape:function(e){N(function(){return!(void 0===e.children&&!0===e.isBranch)},function(){return"Are you meant to declare an unloaded branch node? `isBranch: true` is no longer supported, please use `children: null` instead."})},select:function(e){if(!this.disabled&&!e.isDisabled){this.single&&this.clear();var t=this.multiple&&!this.flat?0===this.forest.checkedStateMap[e.id]:!this.isSelected(e);t?this._selectNode(e):this._deselectNode(e),this.buildForestState(),t?this.$emit("select",e.raw,this.getInstanceId()):this.$emit("deselect",e.raw,this.getInstanceId()),this.localSearch.active&&t&&(this.single||this.clearOnSelect)&&this.resetSearchQuery(),this.single&&this.closeOnSelect&&(this.closeMenu(),this.searchable&&(this._blurOnSelect=!0))}},clear:function(){var e=this;this.hasValue&&(this.single||this.allowClearingDisabled?this.forest.selectedNodeIds=[]:this.forest.selectedNodeIds=this.forest.selectedNodeIds.filter(function(t){return e.getNode(t).isDisabled}),this.buildForestState())},_selectNode:function(e){var t=this;if(this.single||this.disableBranchNodes)return this.addValue(e);if(this.flat)return this.addValue(e),void(this.autoSelectAncestors?e.ancestors.forEach(function(e){t.isSelected(e)||e.isDisabled||t.addValue(e)}):this.autoSelectDescendants&&this.traverseDescendantsBFS(e,function(e){t.isSelected(e)||e.isDisabled||t.addValue(e)}));var n=e.isLeaf||!e.hasDisabledDescendants||this.allowSelectingDisabledDescendants;if(n&&this.addValue(e),e.isBranch&&(this.traverseDescendantsBFS(e,function(e){if(!e.isDisabled||t.allowSelectingDisabledDescendants){if(t.localSearch.active&&!t.shouldOptionBeIncludedInSearchResult(e))return;t.addValue(e)}}),this.localSearch.active&&n&&!e.children.every(this.isSelected)&&this.removeValue(e)),n&&this.isSelected(e))for(var r=e;(r=r.parentNode)!==P&&r.children.every(this.isSelected);)this.addValue(r)},_deselectNode:function(e){var t=this;if(this.disableBranchNodes)return this.removeValue(e);if(this.flat)return this.removeValue(e),void(this.autoDeselectAncestors?e.ancestors.forEach(function(e){t.isSelected(e)&&!e.isDisabled&&t.removeValue(e)}):this.autoDeselectDescendants&&this.traverseDescendantsBFS(e,function(e){t.isSelected(e)&&!e.isDisabled&&t.removeValue(e)}));var n=!1;if(e.isBranch&&this.traverseDescendantsDFS(e,function(e){e.isDisabled&&!t.allowSelectingDisabledDescendants||(t.removeValue(e),n=!0)}),e.isLeaf||n||0===e.children.length){this.removeValue(e);for(var r=e;(r=r.parentNode)!==P&&this.isSelected(r);)this.removeValue(r)}},addValue:function(e){this.forest.selectedNodeIds.push(e.id),this.forest.selectedNodeMap[e.id]=!0},removeValue:function(e){var t,n,r;t=this.forest.selectedNodeIds,n=e.id,-1!==(r=t.indexOf(n))&&t.splice(r,1),delete this.forest.selectedNodeMap[e.id]},removeLastValue:function(){if(this.hasValue){if(this.single)return this.clear();var e=b(this.internalValue),t=this.getNode(e);this.select(t)}},saveMenuScrollPosition:function(){var e=this.getMenu();e&&(this.menu.lastScrollPosition=e.scrollTop)},restoreMenuScrollPosition:function(){var e=this.getMenu();e&&(e.scrollTop=this.menu.lastScrollPosition)}},created:function(){this.verifyProps(),this.resetFlags()},mounted:function(){this.autoFocus&&this.focusInput(),!this.options&&this.autoLoadRootOptions&&this.loadRootOptions(),this.alwaysOpen&&this.openMenu()},unmounted:function(){this.toggleClickOutsideEvent(!1)}};function Le(e){return"string"==typeof e?e:null==e||E(e)?"":JSON.stringify(e)}const xe=a({name:"vue3-treeselect--hidden-fields",setup:function(){var e=l("instance");return function(){if(!e.name||e.disabled||!e.hasValue)return null;var t=e.internalValue.map(Le);return e.multiple&&e.joinValues&&(t=[t.join(e.delimiter)]),t.map(function(t,n){return s("input",{type:"hidden",name:e.name,value:t,key:"hidden-field-"+n},null)})}}});var Ce=[re,oe,se,ae,le,ue,ce];const Ie={name:"vue3-treeselect--input",inject:["instance"],data:function(){return{inputWidth:5,value:""}},computed:{needAutoSize:function(){var e=this.instance;return e.searchable&&!e.disabled&&e.multiple},inputStyle:function(){return{width:this.needAutoSize?"".concat(this.inputWidth,"px"):null}}},watch:{"instance.trigger.searchQuery":function(e){this.value=e},value:function(){this.needAutoSize&&this.$nextTick(this.updateInputWidth)}},created:function(){this.debouncedCallback=f(this.updateSearchQuery,200,{leading:!0,trailing:!0})},methods:{clear:function(){this.onInput({target:{value:""}})},focus:function(){this.instance.disabled||this.$refs.input&&this.$refs.input.focus()},blur:function(){this.$refs.input&&this.$refs.input.blur()},onFocus:function(){var e=this.instance;e.trigger.isFocused=!0,e.openOnFocus&&e.openMenu()},onBlur:function(){var e=this.instance,t=e.getMenu();if(t&&document.activeElement===t)return this.focus();e.trigger.isFocused=!1,e.closeMenu()},onInput:function(e){var t=e.target.value;this.value=t,t?this.debouncedCallback():(this.debouncedCallback.cancel(),this.updateSearchQuery())},onKeyDown:function(e){var t=this.instance,n="which"in e?e.which:e.keyCode;if(!(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)){if(!t.menu.isOpen&&z(Ce,n))return e.preventDefault(),t.openMenu();switch(n){case ne:t.backspaceRemoves&&!this.value.length&&t.removeLastValue();break;case re:if(e.preventDefault(),null===t.menu.current)return;var r=t.getNode(t.menu.current);if(null==r)return;if(r.isBranch&&t.disableBranchNodes||t.localSearch.active&&!t.shouldOptionBeIncludedInSearchResult(r))return;t.select(r);break;case ie:this.value.length?this.clear():t.menu.isOpen&&t.closeMenu();break;case oe:e.preventDefault(),t.highlightLastOption();break;case se:e.preventDefault(),t.highlightFirstOption();break;case ae:var i=t.getNode(t.menu.current);if(null==i)return;i.isBranch&&t.shouldExpand(i)?(e.preventDefault(),t.toggleExpanded(i)):!i.isRootNode&&(i.isLeaf||i.isBranch&&!t.shouldExpand(i))&&(e.preventDefault(),t.setCurrentHighlightedOption(i.parentNode));break;case le:e.preventDefault(),t.highlightPrevOption();break;case ue:var o=t.getNode(t.menu.current);if(null==o)return;o.isBranch&&!t.shouldExpand(o)&&(e.preventDefault(),t.toggleExpanded(o));break;case ce:e.preventDefault(),t.highlightNextOption();break;case de:t.deleteRemoves&&!this.value.length&&t.removeLastValue();break;default:t.openMenu()}}},onMouseDown:function(e){this.value.length&&e.stopPropagation()},renderInputContainer:function(){var e=this.instance,t={},n=[];return e.searchable&&!e.disabled&&(n.push(this.renderInput()),this.needAutoSize&&n.push(this.renderSizer())),e.searchable||R(t,{on:{focus:this.onFocus,blur:this.onBlur,keydown:this.onKeyDown},ref:"input"}),e.searchable||e.disabled||(t.tabIndex=e.tabIndex),s("div",u({class:"vue3-treeselect__input-container"},t),[n])},renderInput:function(){var e=this.instance;return s("input",{ref:"input",class:"vue3-treeselect__input",type:"text",autocomplete:"off",tabIndex:e.tabIndex,required:e.required&&!e.hasValue,value:this.value,style:this.inputStyle,onFocus:this.onFocus,onInput:this.onInput,onBlur:this.onBlur,onKeydown:this.onKeyDown,onMousedown:this.onMouseDown},null)},renderSizer:function(){return s("div",{ref:"sizer",class:"vue3-treeselect__sizer"},[this.value])},updateInputWidth:function(){this.inputWidth=Math.max(5,this.$refs.sizer.scrollWidth+15)},updateSearchQuery:function(){this.instance.trigger.searchQuery=this.value}},render:function(){return this.renderInputContainer()}},Ee={name:"vue3-treeselect--placeholder",inject:["instance"],render:function(){var e=this.instance,t={"vue3-treeselect__placeholder":!0,"vue3-treeselect-helper-zoom-effect-off":!0,"vue3-treeselect__placeholder-icon":e.$slots["control-icon"],"vue3-treeselect-helper-hide":e.hasValue||e.trigger.searchQuery};return s("div",{class:t},[e.placeholder])}},Ae={name:"vue3-treeselect--single-value",inject:["instance"],methods:{renderSingleValueLabel:function(){var e=this.instance,t=e.selectedNodes[0],n=e.$slots["value-label"];return n?n({node:t}):t.label}},render:function(){var e=this.instance;return(0,this.$parent.renderValueContainer)([e.hasValue&&!e.trigger.searchQuery&&s("div",{class:"vue3-treeselect__single-value"},[this.renderSingleValueLabel()]),s(Ee,null,null),s(Ie,{ref:"input"},null)])}};function De(e){return function(e){if(Array.isArray(e))return Te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Te(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Te(e,t):void 0}}(e)||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 Te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Be={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 348.333 348.333"};const Re={name:"vue3-treeselect--x"};var ze=w(510);const Ve=(0,ze.A)(Re,[["render",function(e,t,n,o,s,a){return c(),r("svg",Be,De(t[0]||(t[0]=[i("path",{d:"M336.559 68.611L231.016 174.165l105.543 105.549c15.699 15.705 15.699 41.145 0 56.85-7.844 7.844-18.128 11.769-28.407 11.769-10.296 0-20.581-3.919-28.419-11.769L174.167 231.003 68.609 336.563c-7.843 7.844-18.128 11.769-28.416 11.769-10.285 0-20.563-3.919-28.413-11.769-15.699-15.698-15.699-41.139 0-56.85l105.54-105.549L11.774 68.611c-15.699-15.699-15.699-41.145 0-56.844 15.696-15.687 41.127-15.687 56.829 0l105.563 105.554L279.721 11.767c15.705-15.687 41.139-15.687 56.832 0 15.705 15.699 15.705 41.145.006 56.844z"},null,-1)])))}]]),ke={name:"vue3-treeselect--multi-value-item",inject:["instance"],props:{node:{type:Object,required:!0}},methods:{handleMouseDown:_(function(){var e=this.instance,t=this.node;e.select(t)})},render:function(){var e=this.instance,t=this.node,n={"vue3-treeselect__multi-value-item":!0,"vue3-treeselect__multi-value-item-disabled":t.isDisabled,"vue3-treeselect__multi-value-item-new":t.isNew},r=e.$slots["value-label"],i=r?r({node:t}):t.label;return s("div",{class:"vue3-treeselect__multi-value-item-container"},[s("div",{class:n},[s("span",{class:"vue3-treeselect__multi-value-label"},[i]),s("span",{class:"vue3-treeselect__icon vue3-treeselect__value-remove",onMousedown:this.handleMouseDown},[s(Ve,null,null)])])])}},je={name:"vue3-treeselect--multi-value",inject:["instance"],methods:{renderMultiValueItems:function(){var e=this.instance;return e.internalValue.slice(0,e.limit).map(e.getNode).map(function(e){return s(ke,{key:"multi-value-item-".concat(e.id),node:e},null)})},renderExceedLimitTip:function(){var e=this.instance,t=e.internalValue.length-e.limit;return t<=0?null:s("div",{class:"vue3-treeselect__limit-tip vue3-treeselect-helper-zoom-effect-off",key:"exceed-limit-tip"},[s("span",{class:"vue3-treeselect__limit-tip-text"},[e.limitText(t)])])}},render:function(){var e=this;return(0,this.$parent.renderValueContainer)(s(t,{class:"vue3-treeselect__multi-value",tag:"div",name:"vue3-treeselect__multi-value-item--transition",appear:!0},{default:function(){return[e.renderMultiValueItems(),e.renderExceedLimitTip(),s(Ee,{key:"placeholder"},null),s(Ie,{ref:"input",key:"input"},null)]}}))}};function Fe(e){return function(e){if(Array.isArray(e))return Pe(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Pe(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pe(e,t):void 0}}(e)||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 Pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var $e={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 292.362 292.362"};const He={name:"vue3-treeselect--arrow"},We=(0,ze.A)(He,[["render",function(e,t,n,o,s,a){return c(),r("svg",$e,Fe(t[0]||(t[0]=[i("path",{d:"M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z"},null,-1)])))}]]),Qe={name:"vue3-treeselect--control",inject:["instance"],computed:{shouldShowX:function(){var e=this.instance;return e.clearable&&!e.disabled&&e.hasValue&&(this.hasUndisabledValue||e.allowClearingDisabled)},shouldShowArrow:function(){var e=this.instance;return!e.alwaysOpen||!e.menu.isOpen},hasUndisabledValue:function(){var e=this.instance;return e.hasValue&&e.internalValue.some(function(t){return!e.getNode(t).isDisabled})}},methods:{renderX:function(){var e=this.instance,t=e.multiple?e.clearAllText:e.clearValueText;if(!this.shouldShowX)return null;var n={"vue3-treeselect__x":!0},r=e.$slots["control-x"];return s("div",{class:"vue3-treeselect__x-container",title:t,onMousedown:this.handleMouseDownOnX},[r?r({xClass:n}):s(Ve,{class:n},null)])},renderArrow:function(){var e=this.instance,t={"vue3-treeselect__control-arrow":!0,"vue3-treeselect__control-arrow--rotated":e.menu.isOpen},n=e.$slots["control-arrow"];return n?n({showArrow:this.shouldShowArrow,menuIsOpen:e.menu.isOpen,isLoading:e.rootOptionsStates.isLoading,arrowClass:t}):this.shouldShowArrow?s(We,{class:t},null):null},renderArrowContainer:function(){return this.shouldShowArrow?s("div",{class:"vue3-treeselect__control-arrow-container",onMousedown:this.handleMouseDownOnArrow},[this.renderArrow()]):null},handleMouseDownOnX:_(function(e){e.stopPropagation(),e.preventDefault();var t=this.instance,n=t.beforeClearAll(),r=function(e){e&&t.clear()};v(n)?n.then(r):setTimeout(function(){return r(n)},0)}),handleMouseDownOnArrow:_(function(e){e.preventDefault(),e.stopPropagation();var t=this.instance;t.focusInput(),t.toggleMenu()}),renderValueContainer:function(e){return s("div",{class:"vue3-treeselect__value-container"},[e])}},render:function(){var e=this.instance,t=e.single?Ae:je,n=e.$slots["control-icon"];return s("div",{class:{"vue3-treeselect__control":!0,"vue3-treeselect__control--has-icon":n},onMousedown:e.handleMouseDown},[s(t,{ref:"value-container"},null),n&&s("div",{class:"vue3-treeselect__control-icon-container"},[n()]),this.renderX(),this.renderArrowContainer()])}},Ke=a({name:"vue3-treeselect--tip",props:{type:{type:String,required:!0},icon:{type:String,required:!0}},setup:function(e,t){var n=t.slots;return function(){var t=n.default?n.default():[];return s("div",{class:"vue3-treeselect__tip vue3-treeselect__".concat(e.type,"-tip")},[s("div",{class:"vue3-treeselect__icon-container"},[s("span",{class:"vue3-treeselect__icon-".concat(e.icon)},null)]),s("span",{class:"vue3-treeselect__tip-text vue3-treeselect__".concat(e.type,"-tip-text")},[t])])}}});function qe(e){return qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qe(e)}function Ue(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=qe(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=qe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==qe(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Xe,Ye,Je,Ge={name:"vue3-treeselect--option",inject:["instance"],props:{node:{type:Object,required:!0}},computed:{shouldExpand:function(){var e=this.instance,t=this.node;return t.isBranch&&e.shouldExpand(t)},shouldShow:function(){var e=this.instance,t=this.node;return e.shouldShowOptionInMenu(t)}},methods:{renderOption:function(){var e=this.instance,t=this.node,n={"vue3-treeselect__option":!0,"vue3-treeselect__option--disabled":t.isDisabled,"vue3-treeselect__option--selected":e.isSelected(t),"vue3-treeselect__option--highlight":t.isHighlighted,"vue3-treeselect__option--matched":e.localSearch.active&&t.isMatched,"vue3-treeselect__option--hide":!this.shouldShow};return s("div",{class:n,onMouseenter:this.handleMouseEnterOption,"data-id":t.id},[this.renderArrow(),this.renderLabelContainer([this.renderCheckboxContainer([this.renderCheckbox()]),this.renderLabel()])])},renderSubOptionsList:function(){return this.shouldExpand?s("div",{class:"vue3-treeselect__list"},[this.renderSubOptions(),this.renderNoChildrenTip(),this.renderLoadingChildrenTip(),this.renderLoadingChildrenErrorTip()]):null},renderArrow:function(){var t=this.instance,n=this.node;if(t.shouldFlattenOptions&&this.shouldShow)return null;if(n.isBranch){var r={"vue3-treeselect__option-arrow":!0,"vue3-treeselect__option-arrow--rotated":this.shouldExpand};return s("div",{class:"vue3-treeselect__option-arrow-container",onMousedown:this.handleMouseDownOnArrow},[s(e,{name:"vue3-treeselect__option-arrow--prepare",appear:!0},{default:function(){return s(We,{class:r},null)}})])}return t.hasBranchNodes?(Xe||(Xe=s("div",{class:"vue3-treeselect__option-arrow-placeholder"},[o(" ")])),Xe):null},renderLabelContainer:function(e){return s("div",{class:"vue3-treeselect__label-container",onMousedown:this.handleMouseDownOnLabelContainer},[e])},renderCheckboxContainer:function(e){var t=this.instance,n=this.node;return t.single||t.disableBranchNodes&&n.isBranch?null:s("div",{class:"vue3-treeselect__checkbox-container"},[e])},renderCheckbox:function(){var e=this.instance,t=this.node,n=e.forest.checkedStateMap[t.id],r={"vue3-treeselect__checkbox":!0,"vue3-treeselect__checkbox--checked":2===n,"vue3-treeselect__checkbox--indeterminate":1===n,"vue3-treeselect__checkbox--unchecked":0===n,"vue3-treeselect__checkbox--disabled":t.isDisabled};return Ye||(Ye=s("span",{class:"vue3-treeselect__check-mark"},null)),Je||(Je=s("span",{class:"vue3-treeselect__minus-mark"},null)),s("span",{class:r},[Ye,Je])},renderLabel:function(){var e=this.instance,t=this.node,n=t.isBranch&&(e.localSearch.active?e.showCountOnSearchComputed:e.showCount),r=n?e.localSearch.active?e.localSearch.countMap[t.id][e.showCountOf]:t.count[e.showCountOf]:Number.NaN,i="vue3-treeselect__label",a="vue3-treeselect__count",l=e.$slots["option-label"];return l?l({node:t,shouldShowCount:n,count:r,labelClassName:i,countClassName:a}):s("label",{class:i},[t.label,n&&s("span",{class:a},[o("