import { computed } from 'vue';
import { useNormalModel } from '../_util/use/useModel';

var useState = _ref => {
  let {
    props,
    emit
  } = _ref;
  const [currentExpandedKeys, updateExpandedKeys] = useNormalModel(props, emit, {
    prop: 'expandedKeys'
  });
  const [currentCheckedKeys, updateCheckedKeys] = useNormalModel(props, emit, {
    prop: 'checkedKeys'
  });
  const [currentSelectedKeys, updateSelectedKeys] = useNormalModel(props, emit, {
    prop: 'selectedKeys'
  });
  const hasSelected = value => currentSelectedKeys.value.includes(value);
  const hasNoExpandableNode = computed(() => props.data.every(firstLevelNode => !firstLevelNode.children || firstLevelNode.children.length === 0));
  return {
    currentExpandedKeys,
    updateExpandedKeys,
    currentCheckedKeys,
    updateCheckedKeys,
    currentSelectedKeys,
    updateSelectedKeys,
    hasSelected,
    hasNoExpandableNode
  };
};

export { useState as default };
