"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),j=require("@ant-design/icons-vue/FileOutlined"),M=require("@ant-design/icons-vue/FolderOpenOutlined"),U=require("@ant-design/icons-vue/FolderOutlined"),L=require("lodash-es/debounce"),R=require("../_util/classNames.js"),q=require("../_util/props-util/index.js"),_=require("../_util/props-util/initDefaultProps.js"),$=require("../_util/type.js"),B=require("../config-provider/hooks/useConfigInject.js"),z=require("../vc-tree/util.js"),v=require("../vc-tree/utils/treeUtil.js"),b=require("./Tree.js"),x=require("./utils/dictUtil.js"),C=()=>({...b.treeProps(),expandAction:$.someType([Boolean,String])});function G(e){const{isLeaf:r,expanded:s}=e;return r?l.createVNode(j,null,null):s?l.createVNode(M,null,null):l.createVNode(U,null,null)}const H=l.defineComponent({compatConfig:{MODE:3},name:"ADirectoryTree",inheritAttrs:!1,props:_.default(C(),{showIcon:!0,expandAction:"click"}),slots:Object,setup(e,{attrs:r,slots:s,emit:a,expose:g}){const u=l.ref(e.treeData||v.convertTreeToData(q.filterEmpty(s.default?.())));l.watch(()=>e.treeData,()=>{u.value=e.treeData}),l.onUpdated(()=>{l.nextTick(()=>{e.treeData===void 0&&s.default&&(u.value=v.convertTreeToData(q.filterEmpty(s.default?.())))})});const k=l.ref(),N=l.ref(),i=l.computed(()=>v.fillFieldNames(e.fieldNames)),o=l.ref();g({scrollTo:t=>{o.value?.scrollTo(t)},selectedKeys:l.computed(()=>o.value?.selectedKeys),checkedKeys:l.computed(()=>o.value?.checkedKeys),halfCheckedKeys:l.computed(()=>o.value?.halfCheckedKeys),loadedKeys:l.computed(()=>o.value?.loadedKeys),loadingKeys:l.computed(()=>o.value?.loadingKeys),expandedKeys:l.computed(()=>o.value?.expandedKeys)});const p=()=>{const{keyEntities:t}=v.convertDataToEntities(u.value,{fieldNames:i.value});let c;return e.defaultExpandAll?c=Object.keys(t):e.defaultExpandParent?c=z.conductExpandParent(e.expandedKeys||e.defaultExpandedKeys||[],t):c=e.expandedKeys||e.defaultExpandedKeys,c},m=l.ref(e.selectedKeys||e.defaultSelectedKeys||[]),y=l.ref(p());l.watch(()=>e.selectedKeys,()=>{e.selectedKeys!==void 0&&(m.value=e.selectedKeys)},{immediate:!0}),l.watch(()=>e.expandedKeys,()=>{e.expandedKeys!==void 0&&(y.value=e.expandedKeys)},{immediate:!0});const E=L((t,c)=>{const{isLeaf:n}=c;n||t.shiftKey||t.metaKey||t.ctrlKey||o.value.onNodeExpand(t,c)},200,{leading:!0}),P=(t,c)=>{e.expandedKeys===void 0&&(y.value=t),a("update:expandedKeys",t),a("expand",t,c)},S=(t,c)=>{const{expandAction:n}=e;n==="click"&&E(t,c),a("click",t,c)},A=(t,c)=>{const{expandAction:n}=e;(n==="dblclick"||n==="doubleclick")&&E(t,c),a("doubleclick",t,c),a("dblclick",t,c)},w=(t,c)=>{const{multiple:n}=e,{node:D,nativeEvent:T}=c,f=D[i.value.key],K={...c,selected:!0},I=T?.ctrlKey||T?.metaKey,V=T?.shiftKey;let d;n&&I?(d=t,k.value=f,N.value=d,K.selectedNodes=x.convertDirectoryKeysToNodes(u.value,d,i.value)):n&&V?(d=Array.from(new Set([...N.value||[],...x.calcRangeKeys({treeData:u.value,expandedKeys:y.value,startKey:f,endKey:k.value,fieldNames:i.value})])),K.selectedNodes=x.convertDirectoryKeysToNodes(u.value,d,i.value)):(d=[f],k.value=f,N.value=d,K.selectedNodes=x.convertDirectoryKeysToNodes(u.value,d,i.value)),a("update:selectedKeys",d),a("select",d,K),e.selectedKeys===void 0&&(m.value=d)},F=(t,c)=>{a("update:checkedKeys",t),a("check",t,c)},{prefixCls:h,direction:O}=B.default("tree",e);return()=>{const t=R.default(`${h.value}-directory`,{[`${h.value}-directory-rtl`]:O.value==="rtl"},r.class),{icon:c=s.icon,blockNode:n=!0,...D}=e;return l.createVNode(b.default,{...r,icon:c||G,ref:o,blockNode:n,...D,prefixCls:h.value,class:t,expandedKeys:y.value,selectedKeys:m.value,onSelect:w,onClick:S,onDblclick:A,onExpand:P,onCheck:F},s)}}});exports.default=H;exports.directoryTreeProps=C;
