import type { TreeNodeData } from 'element-plus/es/components/tree/src/tree.type'
export interface operationsType {
  value: string
  label?: string
  icon: string
  iconColor?: string
  disabled?: boolean
  hidden?: boolean
}

export interface TreeOptionProps {
  label?: string 
  pathName?: string 
  children?: string 
  parentId?: string 
  disabled?: string | ((data: TreeNodeData, node?: Node) => boolean) 
  isLeaf?: string | ((data: TreeNodeData, node?: Node) => boolean) 
  
  allowUnSelect?: string | ((data: TreeNodeData) => boolean) 
  class?: (
    data: TreeNodeData,
    node: Node,
  ) =>
    | string
    | {
        [key: string]: boolean
      }
    | string
}

export interface MergeOprations {
  list?: operationsType[]
  position?: 'top' | 'bottom'
}

export interface Props {
  
  data?: any[]

  
  loading?: boolean

  
  nodeKey?: string

  
  modelValue?: string | number | any[]

  
  path?: string | string[]

  
  height?: string | number

  
  isEllipsis?: boolean

  
  draggable?: boolean

  
  allowDrag?: (node: any) => boolean

  
  currentNodeKey?: string | number

  
  defaultCheckedKeys?: string[] | number[]

  
  defaultExpandedKeys?: string[] | number[]

  
  defaultExpandedPaths?: string[] | number[]

  
  defaultExpandRoot?: boolean

  
  expandOnClickNode?: boolean

  
  checkStrictly?: boolean

  
  parentLinkChildrenStrictly?: boolean

  
  dataLinkView?: boolean

  
  getGrandChildren?: (data?: any) => Promise<any[]>

  
  childLinkParentStrictly?: boolean

  
  props?: TreeOptionProps

  
  showCheckbox?: boolean

  
  hideRootCheckbox?: boolean

  
  showOperations?: boolean

  
  operations?: Array<operationsType> | ((node: any, data: any) => Array<operationsType>)

  
  mergeOprations?: {
    list?: Array<operationsType> | ((node: any, data: any) => Array<operationsType>)
    
    position?: 'top' | 'bottom' | ((node: any, data: any) => 'top' | 'bottom')
  }

  
  operationsLayout?: string | ((node: any, data: any) => string)

  
  operationsLabel?: {
    
    add?: string | ((node: any, data: any) => string | undefined)
    
    addItem?: string | ((node: any, data: any) => string | undefined)
    
    edit?: string | ((node: any, data: any) => string | undefined)
    
    delete?: string | ((node: any, data: any) => string | undefined)
  }

  
  maxNodeLevel?: number | string

  
  showFilterInput?: boolean

  
  isFilter?: boolean

  
  filterNodeMethod?: (value: string, data: Record<string, any>) => boolean

  
  filterValue?: string

  
  filterItemClass?: string | ((data: any, index: number) => string | undefined)

  
  inputOptions?: any

  
  emptyText?: string

  
  searchEmptyText?: string

  
  rootNodeId?: string

  
  load?: (data: any, level: number) => Promise<Record<any, any>>

  
  search?: (text: string) => Promise<any[]>

  
  renderDom?: boolean

  
  overlayZIndex?: string

  
  keepSelected?: boolean

  
  notAutoresetLazyLoad?: boolean

  
  changeNodeConfirm?: (item: any) => Promise<any>
}

export interface Emits {
  (e: 'update:filterValue', value: string): void

  (e: 'update:modelValue', value: string | number | any[]): void

  
  (e: 'update:path', value: string | string[]): void

  
  (e: 'change', value: string | string[], data: Record<any, any>, isCheck?: boolean, childrenData?: any[]): void

  
  (e: 'handleOperation', item: any, node: any, data: any): void

  
  (e: 'filter-value-change', value: string): void

  
  (e: 'filter-node-click', item: any): void

  
  (e: 'node-change', item: any): void
  
  (e: 'check-node-change', checkVal: any[], item: any, isCheck: boolean): void

  
  (e: 'node-click', item: any, node: any): void
  
  (e: 'check-node-click', item: any, node: any): void

  
  (e: 'node-db-click', item: any, node: any): void
  
  (e: 'check-node-db-click', item: any, node: any): void

  
  (e: 'current-change', item: any, node: any): void
}

export type Exposes = {
  
  treeRef

  
  treeIsEmpty

  
  findSelectableParentNode

  
  childLinkParent

  
  parentLinkChild

  
  getGrandChildrenFn

  
  resetLazyLoad

  
  autoExpand

  
  searchClear

  
  lazyData

  
  lazyDataNextTick

  
  filterSeach

  
  handleSearchEnter
}

export interface Slots {
  
  'container-top': {}

  
  'container-bootom': {}

  
  top: {}

  
  bottom: {}

  
  prefix: {}

  
  suffix: {}

  
  prepend: {}

  
  append: {}
}
