import{c_ as je,G as ze,c$ as De,d0 as $e,d1 as We,cE as He,cj as U,cG as ne,cF as Ge,d as Qe,r as v,cI as Je,cK as Xe,cM as Ze,aQ as _,cL as V,F as c,O as qe,d2 as Ye,cw as et,d3 as tt,cJ as oe,cP as nt,cN as j,cO as at,bi as u,cQ as lt,cR as ot,cS as rt,cT as it,a2 as dt,H as st,cx as ct,d4 as ut,cy as ht,cz as ft,cA as gt,d5 as mt,cC as vt,d6 as yt,cZ as p,cW as bt,cX as pt,cs as St,N as wt}from"./index.16e8fdaf.js";const xt=t=>{const{popoverColor:h,boxShadow2:i,borderRadius:s,heightMedium:d,dividerColor:y,textColor2:C}=t;return{menuPadding:"4px",menuColor:h,menuBoxShadow:i,menuBorderRadius:s,menuHeight:`calc(${d} * 7.6)`,actionDividerColor:y,actionTextColor:C,actionPadding:"8px 12px"}},kt=je({name:"TreeSelect",common:ze,peers:{Tree:De,Empty:$e,InternalSelection:We},self:xt}),Tt=kt;function ae(t,h){const{rawNode:i}=t;return Object.assign(Object.assign({},i),{label:i[h],value:t.key})}function le(t,h,i,s){const{rawNode:d}=t;return Object.assign(Object.assign({},d),{value:t.key,label:h.map(y=>y.rawNode[s]).join(i)})}const Kt=He([U("tree-select",` z-index: auto; outline: none; width: 100%; position: relative; `),U("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; `,[U("tree","max-height: var(--n-menu-height);"),ne("empty",` display: flex; padding: 12px 32px; flex: 1; justify-content: center; `),ne("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); `),Ge()])]),Ct=Object.assign(Object.assign(Object.assign(Object.assign({},oe.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:j.propTo,menuProps:Object,virtualScroll:{type:Boolean,default:!0},status:String,renderTag:Function}),mt),{renderLabel:Function,renderPrefix:Function,renderSuffix:Function,nodeProps:Function,onBlur:Function,onFocus:Function,onLoad:Function,onUpdateShow:[Function,Array],onUpdateValue:[Function,Array],"onUpdate:value":[Function,Array],"onUpdate:show":[Function,Array],leafOnly:Boolean}),Ft=Qe({name:"TreeSelect",props:Ct,setup(t){const h=v(null),i=v(null),s=v(null),d=v(null),{mergedClsPrefixRef:y,namespaceRef:C,inlineThemeDisabled:g}=Je(t),{localeRef:N}=Xe("Select"),{mergedSizeRef:O,mergedDisabledRef:A,mergedStatusRef:re,nTriggerFormBlur:ie,nTriggerFormChange:de,nTriggerFormFocus:se,nTriggerFormInput:ce}=Ze(t),z=v(t.defaultValue),ue=_(t,"value"),S=V(ue,z),D=v(t.defaultShow),he=_(t,"show"),w=V(he,D),R=v(""),fe=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}),x=c(()=>vt(t.options,yt(t.keyField,t.childrenField,t.disabledField,void 0))),{value:P}=S,$=v(t.checkable?null:Array.isArray(P)&&P.length?P[P.length-1]:null),M=c(()=>t.multiple&&t.cascade&&t.checkable),W=v(t.defaultExpandAll?void 0:t.defaultExpandedKeys||t.expandedKeys),ge=_(t,"expandedKeys"),me=V(ge,W),F=v(!1),ve=c(()=>{const{placeholder:e}=t;return e!==void 0?e:N.value.placeholder}),ye=c(()=>t.checkable?[]:H.value),H=c(()=>{const{value:e}=S;return t.multiple?Array.isArray(e)?e:[]:e===null||Array.isArray(e)?[]:[e]}),be=c(()=>{const{multiple:e,showPath:n,separator:l,labelField:a}=t;if(e)return null;const{value:o}=S;if(!Array.isArray(o)&&o!==null){const{value:r}=x,m=r.getNode(o);if(m!==null)return n?le(m,r.getPath(o).treeNodePath,l,a):ae(m,a)}return null}),pe=c(()=>{const{multiple:e,showPath:n,separator:l}=t;if(!e)return null;const{value:a}=S;if(Array.isArray(a)){const o=[],{value:r}=x,{checkedKeys:m}=r.getCheckedKeys(a,{checkStrategy:t.checkStrategy,cascade:M.value,allowNotLoaded:t.allowCheckingNotLoaded}),{labelField:f}=t;return m.forEach(te=>{const L=r.getNode(te);L!==null&&o.push(n?le(L,r.getPath(te).treeNodePath,l,f):ae(L,f))}),o}return[]}),Se=c(()=>{const{self:{menuPadding:e}}=E.value;return e});function I(){var e;(e=i.value)===null||e===void 0||e.focus()}function G(){var e;(e=i.value)===null||e===void 0||e.focusInput()}function Q(e){const{onUpdateShow:n,"onUpdate:show":l}=t;n&&p(n,e),l&&p(l,e),D.value=e}function k(e,n,l){const{onUpdateValue:a,"onUpdate:value":o}=t;a&&p(a,e,n,l),o&&p(o,e,n,l),z.value=e,ce(),de()}function we(e,n){const{onUpdateIndeterminateKeys:l,"onUpdate:indeterminateKeys":a}=t;l&&p(l,e,n),a&&p(a,e,n)}function xe(e,n,l){const{onUpdateExpandedKeys:a,"onUpdate:expandedKeys":o}=t;a&&p(a,e,n,l),o&&p(o,e,n,l),W.value=e}function J(e){const{onFocus:n}=t;n&&n(e),se()}function X(e){b();const{onBlur:n}=t;n&&n(e),ie()}function b(){Q(!1)}function B(){A.value||(R.value="",Q(!0),t.filterable&&G())}function ke(){R.value=""}function Te(e){var n;w.value&&(!((n=i.value)===null||n===void 0)&&n.$el.contains(bt(e))||b())}function Ke(){A.value||(w.value?t.filterable||b():B())}function T(e){const{value:{getNode:n}}=x;return e.map(l=>{var a;return((a=n(l))===null||a===void 0?void 0:a.rawNode)||null})}function Ce(e,n,l){const a=T(e),o=l.action==="check"?"select":"unselect",r=l.node;t.multiple?(k(e,a,{node:r,action:o}),t.filterable&&(G(),t.clearFilterAfterSelect&&(R.value=""))):(e.length?k(e[0],a[0]||null,{node:r,action:o}):k(null,null,{node:r,action:o}),b(),I())}function Re(e){t.checkable&&we(e,T(e))}function Fe(e){var n;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||(F.value=!0,J(e))}function Oe(e){var n;!((n=d.value)===null||n===void 0)&&n.contains(e.relatedTarget)||(F.value=!1,X(e))}function Pe(e){var n,l,a;((n=d.value)===null||n===void 0?void 0:n.contains(e.relatedTarget))||((a=(l=i.value)===null||l===void 0?void 0:l.$el)===null||a===void 0?void 0:a.contains(e.relatedTarget))||(F.value=!0,J(e))}function Me(e){var n,l,a;((n=d.value)===null||n===void 0?void 0:n.contains(e.relatedTarget))||((a=(l=i.value)===null||l===void 0?void 0:l.$el)===null||a===void 0?void 0:a.contains(e.relatedTarget))||(F.value=!1,X(e))}function Ie(e){e.stopPropagation();const{multiple:n}=t;!n&&t.filterable&&b(),n?k([],[],{node:null,action:"clear"}):k(null,null,{node:null,action:"clear"})}function Ne(e){const{value:n}=S;if(Array.isArray(n)){const{value:l}=x,{checkedKeys:a}=l.getCheckedKeys(n,{cascade:M.value,allowNotLoaded:t.allowCheckingNotLoaded}),o=a.findIndex(r=>r===e.value);if(~o){const r=a[o],m=T([r])[0];if(t.checkable){const{checkedKeys:f}=l.uncheck(e.value,a,{checkStrategy:t.checkStrategy,cascade:M.value,allowNotLoaded:t.allowCheckingNotLoaded});k(f,T(f),{node:m,action:"delete"})}else{const f=Array.from(a);f.splice(o,1),k(f,T(f),{node:m,action:"delete"})}}}}function Ae(e){const{value:n}=e.target;R.value=n}function Z(e){const{value:n}=s;n&&n.handleKeydown(e)}function Be(e){e.key==="Enter"?(w.value?(Z(e),t.multiple||(b(),I())):B(),e.preventDefault()):e.key==="Escape"?w.value&&(pt(e),b(),I()):w.value?Z(e):e.key==="ArrowDown"&&B()}function Ee(){b(),I()}function Le(e){St(e,"action")||e.preventDefault()}const Ue=c(()=>{const{renderTag:e}=t;if(!!e)return function({option:l,handleClose:a}){const{value:o}=l;if(o!==void 0){const r=x.value.getNode(o);if(r)return e({option:r.rawNode,handleClose:a})}return o}});qe(Ye,{pendingNodeKeyRef:$,dataTreeMate:x});function q(){var e;!w.value||(e=h.value)===null||e===void 0||e.syncPosition()}et(d,q);const _e=tt(t),Y=c(()=>{if(t.checkable){const e=S.value;return t.multiple&&Array.isArray(e)?x.value.getCheckedKeys(e,{cascade:t.cascade,checkStrategy:_e.value,allowNotLoaded:t.allowCheckingNotLoaded}):{checkedKeys:Array.isArray(e)||e===null?[]:[e],indeterminateKeys:[]}}return{checkedKeys:[],indeterminateKeys:[]}}),Ve={getCheckedData:()=>{const{checkedKeys:e}=Y.value;return{keys:e,options:T(e)}},getIndeterminateData:()=>{const{indeterminateKeys:e}=Y.value;return{keys:e,options:T(e)}},focus:()=>{var e;return(e=i.value)===null||e===void 0?void 0:e.focus()},blur:()=>{var e;return(e=i.value)===null||e===void 0?void 0:e.blur()}},E=oe("TreeSelect","-tree-select",Kt,Tt,t,y),ee=c(()=>{const{common:{cubicBezierEaseInOut:e},self:{menuBoxShadow:n,menuBorderRadius:l,menuColor:a,menuHeight:o,actionPadding:r,actionDividerColor:m,actionTextColor:f}}=E.value;return{"--n-menu-box-shadow":n,"--n-menu-border-radius":l,"--n-menu-color":a,"--n-menu-height":o,"--n-bezier":e,"--n-action-padding":r,"--n-action-text-color":f,"--n-action-divider-color":m}}),K=g?nt("tree-select",void 0,ee,t):void 0;return Object.assign(Object.assign({},Ve),{menuElRef:d,mergedStatus:re,triggerInstRef:i,followerInstRef:h,treeInstRef:s,mergedClsPrefix:y,mergedValue:S,mergedShow:w,namespace:C,adjustedTo:j(t),isMounted:at(),focused:F,menuPadding:Se,mergedPlaceholder:ve,mergedExpandedKeys:me,treeSelectedKeys:ye,treeCheckedKeys:H,mergedSize:O,mergedDisabled:A,selectedOption:be,selectedOptions:pe,pattern:R,pendingNodeKey:$,mergedCascade:M,mergedFilter:fe,selectionRenderTag:Ue,handleTriggerOrMenuResize:q,doUpdateExpandedKeys:xe,handleMenuLeave:ke,handleTriggerClick:Ke,handleMenuClickoutside:Te,handleUpdateCheckedKeys:Ce,handleUpdateIndeterminateKeys:Re,handleTriggerFocus:Fe,handleTriggerBlur:Oe,handleMenuFocusin:Pe,handleMenuFocusout:Me,handleClear:Ie,handleDeleteOption:Ne,handlePatternInput:Ae,handleKeydown:Be,handleTabOut:Ee,handleMenuMousedown:Le,mergedTheme:E,cssVars:g?void 0:ee,themeClass:K==null?void 0:K.themeClass,onRender:K==null?void 0:K.onRender})},render(){const{mergedTheme:t,mergedClsPrefix:h,$slots:i}=this;return u("div",{class:`${h}-tree-select`},u(lt,null,{default:()=>[u(ot,null,{default:()=>u(rt,{ref:"triggerInstRef",onResize:this.handleTriggerOrMenuResize,status:this.mergedStatus,focused:this.focused,clsPrefix:h,theme:t.peers.InternalSelection,themeOverrides:t.peerOverrides.InternalSelection,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 s,d;return[(d=(s=this.$slots).arrow)===null||d===void 0?void 0:d.call(s)]}})}),u(it,{ref:"followerInstRef",show:this.mergedShow,placement:this.placement,to:this.adjustedTo,teleportDisabled:this.adjustedTo===j.tdkey,containerClass:this.namespace,width:this.consistentMenuWidth?"target":void 0,minWidth:"target"},{default:()=>u(dt,{name:"fade-in-scale-up-transition",appear:this.isMounted,onLeave:this.handleMenuLeave},{default:()=>{var s;if(!this.mergedShow)return null;const{mergedClsPrefix:d,checkable:y,multiple:C,menuProps:g,options:N}=this;return(s=this.onRender)===null||s===void 0||s.call(this),st(u("div",Object.assign({},g,{class:[`${d}-tree-select-menu`,g==null?void 0:g.class,this.themeClass],ref:"menuElRef",style:[(g==null?void 0:g.style)||"",this.cssVars],tabindex:0,onMousedown:this.handleMenuMousedown,onKeydown:this.handleKeydown,onFocusin:this.handleMenuFocusin,onFocusout:this.handleMenuFocusout}),u(ut,{ref:"treeInstRef",blockLine:!0,allowCheckingNotLoaded:this.allowCheckingNotLoaded,showIrrelevantNodes:!1,animated:!1,pattern:this.pattern,filter:this.mergedFilter,data:N,cancelable:C,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:y,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,virtualScroll:this.consistentMenuWidth&&this.virtualScroll,internalTreeSelect:!0,internalUnifySelectCheck:!0,internalScrollable:!0,internalScrollablePadding:this.menuPadding,internalFocusable:!1,internalCheckboxFocusable:!1,internalRenderEmpty:()=>u("div",{class:`${d}-tree-select-menu__empty`},ht(i.empty,()=>[u(wt,{theme:t.peers.Empty,themeOverrides:t.peerOverrides.Empty})])),onLoad:this.onLoad,onUpdateCheckedKeys:this.handleUpdateCheckedKeys,onUpdateIndeterminateKeys:this.handleUpdateIndeterminateKeys,onUpdateExpandedKeys:this.doUpdateExpandedKeys}),ft(i.action,O=>O?u("div",{class:`${d}-tree-select-menu__action`,"data-action":!0},O):null),u(gt,{onFocus:this.handleTabOut})),[[ct,this.handleMenuClickoutside,void 0,{capture:!0}]])}})})]}))}});export{Ft as N};