import{$ as $e,a0 as L,b3 as V,bG as We,d as He,Z as s,bH as Ge,bI as Je,cz as Ze,bK as qe,bL as z,T as Qe,aE as Xe,cu as Ye,cA as ae,cB as et,bJ as tt,cC as nt,cD as at,r as g,a2 as lt,cE as rt,bN as ot,ba as j,b9 as D,a4 as c,cx as it,cF as dt,cG as st,cH as ct,a3 as ie,cI as ut,a5 as ht,bO as ft,bP as b,be as vt,cJ as gt,cK as le,cL as mt,b0 as yt,cM as bt}from"./index-9PRMimni.js";const pt=$e([L("tree-select",`
 z-index: auto;
 outline: none;
 width: 100%;
 position: relative;
 `),L("tree-select-menu",`
 position: relative;
 overflow: hidden;
 margin: 4px 0;
 transition: box-shadow .3s var(--n-bezier), background-color .3s var(--n-bezier);
 border-radius: var(--n-menu-border-radius);
 box-shadow: var(--n-menu-box-shadow);
 background-color: var(--n-menu-color);
 outline: none;
 `,[L("tree","max-height: var(--n-menu-height);"),V("empty",`
 display: flex;
 padding: 12px 32px;
 flex: 1;
 justify-content: center;
 `),V("header",`
 padding: var(--n-header-padding);
 transition: 
 color .3s var(--n-bezier);
 border-color .3s var(--n-bezier);
 border-bottom: 1px solid var(--n-header-divider-color);
 color: var(--n-header-text-color);
 `),V("action",`
 padding: var(--n-action-padding);
 transition: 
 color .3s var(--n-bezier);
 border-color .3s var(--n-bezier);
 border-top: 1px solid var(--n-action-divider-color);
 color: var(--n-action-text-color);
 `),We()])]);function re(t,m){const{rawNode:o}=t;return Object.assign(Object.assign({},o),{label:o[m],value:t.key})}function oe(t,m,o,u){const{rawNode:d}=t;return Object.assign(Object.assign({},d),{value:t.key,label:m.map(K=>K.rawNode[u]).join(o)})}const St=Object.assign(Object.assign(Object.assign(Object.assign({},ie.props),{bordered:{type:Boolean,default:!0},cascade:Boolean,checkable:Boolean,clearable:Boolean,clearFilterAfterSelect:{type:Boolean,default:!0},consistentMenuWidth:{type:Boolean,default:!0},defaultShow:Boolean,defaultValue:{type:[String,Number,Array],default:null},disabled:{type:Boolean,default:void 0},filterable:Boolean,checkStrategy:{type:String,default:"all"},loading:Boolean,maxTagCount:[String,Number],multiple:Boolean,showPath:Boolean,separator:{type:String,default:" / "},options:{type:Array,default:()=>[]},placeholder:String,placement:{type:String,default:"bottom-start"},show:{type:Boolean,default:void 0},size:String,value:[String,Number,Array],to:z.propTo,menuProps:Object,virtualScroll:{type:Boolean,default:!0},status:String,renderTag:Function,ellipsisTagPopoverProps:Object}),mt),{renderLabel:Function,renderPrefix:Function,renderSuffix:Function,nodeProps:Function,watchProps:Array,getChildren:Function,onBlur:Function,onFocus:Function,onLoad:Function,onUpdateShow:[Function,Array],onUpdateValue:[Function,Array],"onUpdate:value":[Function,Array],"onUpdate:show":[Function,Array],leafOnly:Boolean}),kt=He({name:"TreeSelect",props:St,slots:Object,setup(t){const m=g(null),o=g(null),u=g(null),d=g(null),{mergedClsPrefixRef:K,namespaceRef:M,inlineThemeDisabled:f}=lt(t),{localeRef:A}=rt("Select"),{mergedSizeRef:p,mergedDisabledRef:E,mergedStatusRef:de,nTriggerFormBlur:se,nTriggerFormChange:ce,nTriggerFormFocus:ue,nTriggerFormInput:he}=ot(t),$=g(t.defaultValue),fe=j(t,"value"),S=D(fe,$),W=g(t.defaultShow),ve=j(t,"show"),w=D(ve,W),F=g(""),ge=c(()=>{const{filter:e}=t;if(e)return e;const{labelField:n}=t;return(l,a)=>l.length?a[n].toLowerCase().includes(l.toLowerCase()):!0}),k=c(()=>it(t.options,dt(t.keyField,t.childrenField,t.disabledField,void 0))),{value:O}=S,H=g(t.checkable?null:Array.isArray(O)&&O.length?O[O.length-1]:null),_=c(()=>t.multiple&&t.cascade&&t.checkable),G=g(t.defaultExpandAll?void 0:t.defaultExpandedKeys||t.expandedKeys),me=j(t,"expandedKeys"),ye=D(me,G),R=g(!1),be=c(()=>{const{placeholder:e}=t;return e!==void 0?e:A.value.placeholder}),J=c(()=>{const{value:e}=S;return t.multiple?Array.isArray(e)?e:[]:e===null||Array.isArray(e)?[]:[e]}),pe=c(()=>t.checkable?[]:J.value),Se=c(()=>{const{multiple:e,showPath:n,separator:l,labelField:a}=t;if(e)return null;const{value:r}=S;if(!Array.isArray(r)&&r!==null){const{value:i}=k,v=i.getNode(r);if(v!==null)return n?oe(v,i.getPath(r).treeNodePath,l,a):re(v,a)}return null}),we=c(()=>{const{multiple:e,showPath:n,separator:l}=t;if(!e)return null;const{value:a}=S;if(Array.isArray(a)){const r=[],{value:i}=k,{checkedKeys:v}=i.getCheckedKeys(a,{checkStrategy:t.checkStrategy,cascade:_.value,allowNotLoaded:t.allowCheckingNotLoaded}),{labelField:h}=t;return v.forEach(B=>{const P=i.getNode(B);P!==null&&r.push(n?oe(P,i.getPath(B).treeNodePath,l,h):re(P,h))}),r}return[]});function I(){var e;(e=o.value)===null||e===void 0||e.focus()}function Z(){var e;(e=o.value)===null||e===void 0||e.focusInput()}function q(e){const{onUpdateShow:n,"onUpdate:show":l}=t;n&&b(n,e),l&&b(l,e),W.value=e}function x(e,n,l){const{onUpdateValue:a,"onUpdate:value":r}=t;a&&b(a,e,n,l),r&&b(r,e,n,l),$.value=e,he(),ce()}function ke(e,n){const{onUpdateIndeterminateKeys:l,"onUpdate:indeterminateKeys":a}=t;l&&b(l,e,n),a&&b(a,e,n)}function xe(e,n,l){const{onUpdateExpandedKeys:a,"onUpdate:expandedKeys":r}=t;a&&b(a,e,n,l),r&&b(r,e,n,l),G.value=e}function Q(e){const{onFocus:n}=t;n&&n(e),ue()}function X(e){y();const{onBlur:n}=t;n&&n(e),se()}function y(){q(!1)}function N(){E.value||(F.value="",q(!0),t.filterable&&Z())}function Ce(){F.value=""}function Ke(e){var n;w.value&&(!((n=o.value)===null||n===void 0)&&n.$el.contains(vt(e))||y())}function Te(){E.value||(w.value?t.filterable||y():N())}function C(e){const{value:{getNode:n}}=k;return e.map(l=>{var a;return((a=n(l))===null||a===void 0?void 0:a.rawNode)||null})}function Fe(e,n,l){const a=C(e),r=l.action==="check"?"select":"unselect",i=l.node;t.multiple?(x(e,a,{node:i,action:r}),t.filterable&&(Z(),t.clearFilterAfterSelect&&(F.value=""))):(e.length?x(e[0],a[0]||null,{node:i,action:r}):x(null,null,{node:i,action:r}),y(),I())}function Re(e){t.checkable&&ke(e,C(e))}function Pe(e){var n;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||(R.value=!0,Q(e))}function Oe(e){var n;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||(R.value=!1,X(e))}function _e(e){var n,l,a;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||!((a=(l=o.value)===null||l===void 0?void 0:l.$el)===null||a===void 0)&&a.contains(e.relatedTarget)||(R.value=!0,Q(e))}function Ie(e){var n,l,a;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||!((a=(l=o.value)===null||l===void 0?void 0:l.$el)===null||a===void 0)&&a.contains(e.relatedTarget)||(R.value=!1,X(e))}function Be(e){e.stopPropagation();const{multiple:n}=t;!n&&t.filterable&&y(),n?x([],[],{node:null,action:"clear"}):x(null,null,{node:null,action:"clear"})}function Me(e){const{value:n}=S;if(Array.isArray(n)){const{value:l}=k,{checkedKeys:a}=l.getCheckedKeys(n,{cascade:_.value,allowNotLoaded:t.allowCheckingNotLoaded}),r=a.findIndex(i=>i===e.value);if(~r){const i=a[r],v=C([i])[0];if(t.checkable){const{checkedKeys:h}=l.uncheck(e.value,a,{checkStrategy:t.checkStrategy,cascade:_.value,allowNotLoaded:t.allowCheckingNotLoaded});x(h,C(h),{node:v,action:"delete"})}else{const h=Array.from(a);h.splice(r,1),x(h,C(h),{node:v,action:"delete"})}}}}function Ae(e){const{value:n}=e.target;F.value=n}function Y(e){const{value:n}=u;return n?n.handleKeydown(e):{enterBehavior:null}}function Ee(e){if(e.key==="Enter"){if(w.value){const{enterBehavior:n}=Y(e);if(!t.multiple)switch(n){case"default":case"toggleSelect":y(),I();break}}else N();e.preventDefault()}else e.key==="Escape"?w.value&&(gt(e),y(),I()):w.value?Y(e):e.key==="ArrowDown"&&N()}function Ne(){y(),I()}function Ue(e){!le(e,"action")&&!le(e,"header")&&e.preventDefault()}const Le=c(()=>{const{renderTag:e}=t;if(e)return function({option:l,handleClose:a}){const{value:r}=l;if(r!==void 0){const i=k.value.getNode(r);if(i)return e({option:i.rawNode,handleClose:a})}return r}});yt(bt,{pendingNodeKeyRef:H,dataTreeMate:k});function ee(){var e;w.value&&((e=m.value)===null||e===void 0||e.syncPosition())}st(d,ee);const Ve=ct(t),te=c(()=>{if(t.checkable){const e=S.value;return t.multiple&&Array.isArray(e)?k.value.getCheckedKeys(e,{cascade:t.cascade,checkStrategy:Ve.value,allowNotLoaded:t.allowCheckingNotLoaded}):{checkedKeys:Array.isArray(e)||e===null?[]:[e],indeterminateKeys:[]}}return{checkedKeys:[],indeterminateKeys:[]}}),je={getCheckedData:()=>{const{checkedKeys:e}=te.value;return{keys:e,options:C(e)}},getIndeterminateData:()=>{const{indeterminateKeys:e}=te.value;return{keys:e,options:C(e)}},focus:()=>{var e;return(e=o.value)===null||e===void 0?void 0:e.focus()},focusInput:()=>{var e;return(e=o.value)===null||e===void 0?void 0:e.focusInput()},blur:()=>{var e;return(e=o.value)===null||e===void 0?void 0:e.blur()},blurInput:()=>{var e;return(e=o.value)===null||e===void 0?void 0:e.blurInput()}},U=ie("TreeSelect","-tree-select",pt,ut,t,K),ne=c(()=>{const{common:{cubicBezierEaseInOut:e},self:{menuBoxShadow:n,menuBorderRadius:l,menuColor:a,menuHeight:r,actionPadding:i,actionDividerColor:v,actionTextColor:h,headerDividerColor:B,headerPadding:P,headerTextColor:ze}}=U.value;return{"--n-menu-box-shadow":n,"--n-menu-border-radius":l,"--n-menu-color":a,"--n-menu-height":r,"--n-bezier":e,"--n-action-padding":i,"--n-action-text-color":h,"--n-action-divider-color":v,"--n-header-padding":P,"--n-header-text-color":ze,"--n-header-divider-color":B}}),T=f?ht("tree-select",void 0,ne,t):void 0,De=c(()=>{const{self:{menuPadding:e}}=U.value;return e});return Object.assign(Object.assign({},je),{menuElRef:d,mergedStatus:de,triggerInstRef:o,followerInstRef:m,treeInstRef:u,mergedClsPrefix:K,mergedValue:S,mergedShow:w,namespace:M,adjustedTo:z(t),isMounted:ft(),focused:R,menuPadding:De,mergedPlaceholder:be,mergedExpandedKeys:ye,treeSelectedKeys:pe,treeCheckedKeys:J,mergedSize:p,mergedDisabled:E,selectedOption:Se,selectedOptions:we,pattern:F,pendingNodeKey:H,mergedCascade:_,mergedFilter:ge,selectionRenderTag:Le,handleTriggerOrMenuResize:ee,doUpdateExpandedKeys:xe,handleMenuLeave:Ce,handleTriggerClick:Te,handleMenuClickoutside:Ke,handleUpdateCheckedKeys:Fe,handleUpdateIndeterminateKeys:Re,handleTriggerFocus:Pe,handleTriggerBlur:Oe,handleMenuFocusin:_e,handleMenuFocusout:Ie,handleClear:Be,handleDeleteOption:Me,handlePatternInput:Ae,handleKeydown:Ee,handleTabOut:Ne,handleMenuMousedown:Ue,mergedTheme:U,cssVars:f?void 0:ne,themeClass:T?.themeClass,onRender:T?.onRender})},render(){const{mergedTheme:t,mergedClsPrefix:m,$slots:o}=this;return s("div",{class:`${m}-tree-select`},s(Ge,null,{default:()=>[s(Je,null,{default:()=>s(Ze,{ref:"triggerInstRef",onResize:this.handleTriggerOrMenuResize,status:this.mergedStatus,focused:this.focused,clsPrefix:m,theme:t.peers.InternalSelection,themeOverrides:t.peerOverrides.InternalSelection,ellipsisTagPopoverProps:this.ellipsisTagPopoverProps,renderTag:this.selectionRenderTag,selectedOption:this.selectedOption,selectedOptions:this.selectedOptions,size:this.mergedSize,bordered:this.bordered,placeholder:this.mergedPlaceholder,disabled:this.mergedDisabled,active:this.mergedShow,loading:this.loading,multiple:this.multiple,maxTagCount:this.maxTagCount,showArrow:!0,filterable:this.filterable,clearable:this.clearable,pattern:this.pattern,onPatternInput:this.handlePatternInput,onClear:this.handleClear,onClick:this.handleTriggerClick,onFocus:this.handleTriggerFocus,onBlur:this.handleTriggerBlur,onDeleteOption:this.handleDeleteOption,onKeydown:this.handleKeydown},{arrow:()=>{var u,d;return[(d=(u=this.$slots).arrow)===null||d===void 0?void 0:d.call(u)]}})}),s(qe,{ref:"followerInstRef",show:this.mergedShow,placement:this.placement,to:this.adjustedTo,teleportDisabled:this.adjustedTo===z.tdkey,containerClass:this.namespace,width:this.consistentMenuWidth?"target":void 0,minWidth:"target"},{default:()=>s(Qe,{name:"fade-in-scale-up-transition",appear:this.isMounted,onLeave:this.handleMenuLeave},{default:()=>{var u;if(!this.mergedShow)return null;const{mergedClsPrefix:d,checkable:K,multiple:M,menuProps:f,options:A}=this;return(u=this.onRender)===null||u===void 0||u.call(this),Xe(s("div",Object.assign({},f,{class:[`${d}-tree-select-menu`,f?.class,this.themeClass],ref:"menuElRef",style:[f?.style||"",this.cssVars],tabindex:0,onMousedown:this.handleMenuMousedown,onKeydown:this.handleKeydown,onFocusin:this.handleMenuFocusin,onFocusout:this.handleMenuFocusout}),ae(o.header,p=>p?s("div",{class:`${d}-tree-select-menu__header`,"data-header":!0},p):null),s(et,{ref:"treeInstRef",blockLine:!0,allowCheckingNotLoaded:this.allowCheckingNotLoaded,showIrrelevantNodes:!1,animated:!1,pattern:this.pattern,getChildren:this.getChildren,filter:this.mergedFilter,data:A,cancelable:M,labelField:this.labelField,keyField:this.keyField,disabledField:this.disabledField,childrenField:this.childrenField,theme:t.peers.Tree,themeOverrides:t.peerOverrides.Tree,defaultExpandAll:this.defaultExpandAll,defaultExpandedKeys:this.defaultExpandedKeys,expandedKeys:this.mergedExpandedKeys,checkedKeys:this.treeCheckedKeys,selectedKeys:this.treeSelectedKeys,checkable:K,checkStrategy:this.checkStrategy,cascade:this.mergedCascade,leafOnly:this.leafOnly,multiple:this.multiple,renderLabel:this.renderLabel,renderPrefix:this.renderPrefix,renderSuffix:this.renderSuffix,renderSwitcherIcon:this.renderSwitcherIcon,nodeProps:this.nodeProps,watchProps:this.watchProps,virtualScroll:this.consistentMenuWidth&&this.virtualScroll,overrideDefaultNodeClickBehavior:this.overrideDefaultNodeClickBehavior,internalTreeSelect:!0,internalUnifySelectCheck:!0,internalScrollable:!0,internalScrollablePadding:this.menuPadding,internalFocusable:!1,internalCheckboxFocusable:!1,internalRenderEmpty:()=>s("div",{class:`${d}-tree-select-menu__empty`},tt(o.empty,()=>[s(nt,{theme:t.peers.Empty,themeOverrides:t.peerOverrides.Empty})])),onLoad:this.onLoad,onUpdateCheckedKeys:this.handleUpdateCheckedKeys,onUpdateIndeterminateKeys:this.handleUpdateIndeterminateKeys,onUpdateExpandedKeys:this.doUpdateExpandedKeys}),ae(o.action,p=>p?s("div",{class:`${d}-tree-select-menu__action`,"data-action":!0},p):null),s(at,{onFocus:this.handleTabOut})),[[Ye,this.handleMenuClickoutside,void 0,{capture:!0}]])}})})]}))}});export{kt as _};
