/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { u as upperFirst_1 } from '../../_chunks/dep-327559e8.mjs';
import { i as isArray_1 } from '../../_chunks/dep-b57180d0.mjs';
import { getNode } from '../util.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../_chunks/dep-b2235f26.mjs';
import '../../_chunks/dep-8b989474.mjs';
import '../../_chunks/dep-42cc3015.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-2bc37d52.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-2db7b3ec.mjs';
import 'vue';
import '../../_chunks/dep-8932db97.mjs';
import '../../_chunks/dep-0d3dd4b5.mjs';
import '../../_chunks/dep-bc1d737a.mjs';
import '../../_chunks/dep-4d7a675b.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../_chunks/dep-2e7f59b1.mjs';
import '../../_chunks/dep-855db8bc.mjs';
import '../../_chunks/dep-550c24c1.mjs';
import '../../_chunks/dep-a87f3e4c.mjs';
import '../../_chunks/dep-1e566bb5.mjs';
import '../../_chunks/dep-42a19209.mjs';
import '../../_chunks/dep-1434aa15.mjs';
import '../../_chunks/dep-9fe2ef12.mjs';
import '../../_chunks/dep-6884627f.mjs';
import '../../_chunks/dep-8d3e9aa3.mjs';
import '../../_chunks/dep-0fc02184.mjs';
import '../../_chunks/dep-876fb3ec.mjs';
import '../../_chunks/dep-3f21269a.mjs';

function useExposeFunc(treeStore, expose) {
  var setItem = function setItem(value, options) {
    var node = treeStore.value.getNode(value);
    var spec = options;
    var keys = Object.keys(spec);
    if (node && spec) {
      ["expanded", "actived", "checked"].forEach(function (name) {
        if (keys.includes(name)) node["set".concat(upperFirst_1(name))](spec[name], {
          directly: true
        });
      });
    }
  };
  var getItem = function getItem(value) {
    var node = treeStore.value.getNode(value);
    return node === null || node === void 0 ? void 0 : node.getModel();
  };
  var getItems = function getItems(value) {
    var nodes = treeStore.value.getNodes(value);
    return nodes.map(function (node) {
      return node.getModel();
    });
  };
  var appendTo = function appendTo(para, item) {
    var list = [];
    if (isArray_1(item)) list = item;else list = [item];
    list.forEach(function (item2) {
      var val = (item2 === null || item2 === void 0 ? void 0 : item2.value) || "";
      var node = getNode(treeStore.value, val);
      if (node) treeStore.value.appendNodes(para, node);else treeStore.value.appendNodes(para, item2);
    });
  };
  var insertBefore = function insertBefore(value, item) {
    var val = (item === null || item === void 0 ? void 0 : item.value) || "";
    var node = getNode(treeStore.value, val);
    if (node) {
      treeStore.value.insertBefore(value, node);
    } else {
      treeStore.value.insertBefore(value, item);
    }
  };
  var insertAfter = function insertAfter(value, item) {
    var val = (item === null || item === void 0 ? void 0 : item.value) || "";
    var node = getNode(treeStore.value, val);
    if (node) {
      treeStore.value.insertAfter(value, node);
    } else {
      treeStore.value.insertAfter(value, item);
    }
  };
  var remove = function remove(value) {
    return treeStore.value.remove(value);
  };
  var getIndex = function getIndex(value) {
    return treeStore.value.getNodeIndex(value);
  };
  var getParent = function getParent(value) {
    var node = treeStore.value.getParent(value);
    return node === null || node === void 0 ? void 0 : node.getModel();
  };
  var getParents = function getParents(value) {
    var nodes = treeStore.value.getParents(value);
    return nodes.map(function (node) {
      return node.getModel();
    });
  };
  var getPath = function getPath(value) {
    var node = treeStore.value.getNode(value);
    var pathNodes = [];
    if (node) pathNodes = node.getPath().map(function (node2) {
      return node2.getModel();
    });
    return pathNodes;
  };
  expose({
    setItem: setItem,
    getItem: getItem,
    getItems: getItems,
    appendTo: appendTo,
    insertBefore: insertBefore,
    insertAfter: insertAfter,
    remove: remove,
    getIndex: getIndex,
    getParent: getParent,
    getParents: getParents,
    getPath: getPath
  });
}

export { useExposeFunc as default };
//# sourceMappingURL=useExposeFunc.mjs.map
