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

import { _ as _defineProperty } from '../_chunks/dep-eb20e23f.mjs';
import { h } from 'vue';
import { p as pick_1 } from '../_chunks/dep-e9bfe96d.mjs';
import { i as isFunction_1 } from '../_chunks/dep-6b22dd27.mjs';
import { i as isString_1 } from '../_chunks/dep-1cf2b129.mjs';
import { i as isArray_1 } from '../_chunks/dep-e3b14d70.mjs';
import { i as isNumber_1 } from '../_chunks/dep-6eea369f.mjs';
import '../_chunks/dep-b4041200.mjs';
import '../_chunks/dep-a0b4a044.mjs';
import '../_chunks/dep-7acc11cb.mjs';
import '../_chunks/dep-66d6733b.mjs';
import '../_chunks/dep-be27d184.mjs';
import '../_chunks/dep-c959a6fb.mjs';
import '../_chunks/dep-c31e1d9e.mjs';
import '../_chunks/dep-0bfbf721.mjs';
import '../_chunks/dep-39cc276d.mjs';
import '../_chunks/dep-8f777748.mjs';
import '../_chunks/dep-0f0c89ff.mjs';
import '../_chunks/dep-ae357f26.mjs';
import '../_chunks/dep-37ba476d.mjs';
import '../_chunks/dep-ea5448a5.mjs';
import '../_chunks/dep-352691c2.mjs';
import '../_chunks/dep-2cfd5b3a.mjs';
import '../_chunks/dep-c852a61a.mjs';
import '../_chunks/dep-05fa17c9.mjs';
import '../_chunks/dep-10085c61.mjs';
import '../_chunks/dep-774ac2d0.mjs';
import '../_chunks/dep-23a0f453.mjs';
import '../_chunks/dep-3afa94cf.mjs';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function getParentsToRoot(element, root) {
  var list = [];
  var el = element;
  while (el && el.parentNode) {
    list.push(el);
    if (el === root) break;
    el = el.parentNode;
  }
  return list;
}
function getParentMarks(name, element, root) {
  var list = getParentsToRoot(element, root);
  return list.map(function (el) {
    var mark = {
      name: name,
      value: el.getAttribute(name) || "",
      el: el
    };
    return mark;
  }).filter(function (mark) {
    return mark.value;
  });
}
function getMark(name, element, root) {
  var list = getParentMarks(name, element, root);
  var info = list.pop() || null;
  return info;
}
function getTNode(prop) {
  var _conf$node;
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  var tnode = null;
  var item = null;
  var conf = _objectSpread({}, options);
  if (isFunction_1(prop)) item = prop(h, (_conf$node = conf.node) === null || _conf$node === void 0 ? void 0 : _conf$node.getModel());else if (isString_1(prop)) item = prop;
  if (isString_1(item)) tnode = item;else if (item) tnode = item;
  return tnode;
}
function getLineModel(nodes, node, index) {
  var lineModel = {
    top: false,
    right: false,
    bottom: false,
    left: false
  };
  var nodeChildren = [];
  if (isArray_1(node.children)) nodeChildren = node.children;
  var childNode = nodes[index - 1] || null;
  var nodeItemIndex = childNode ? childNode.getIndex() : 0;
  if (index === 0) {
    lineModel.left = !!node.parent;
    lineModel.bottom = node.children && node.expanded;
    lineModel.right = node.parent && !node.children;
  } else if (index === 1) {
    lineModel.top = true;
    lineModel.right = true;
    lineModel.bottom = nodeItemIndex < nodeChildren.length - 1;
  } else if (nodeItemIndex < nodeChildren.length - 1) {
    lineModel.top = true;
    lineModel.bottom = true;
  }
  return lineModel;
}
function isTreeNodeValue(item) {
  return isString_1(item) || isNumber_1(item);
}
function getNode(store, item) {
  var node = null;
  var val = null;
  if (isString_1(item) || isNumber_1(item)) val = item;else if (item && isTreeNodeValue(item.value)) val = item.value;
  node = store.getNode(val);
  return node;
}
var getStoreConfig = function getStoreConfig(props) {
  var storeProps = pick_1(props, ["keys", "expandAll", "expandLevel", "expandMutex", "expandParent", "activable", "activeMultiple", "disabled", "draggable", "checkable", "checkStrictly", "load", "lazy", "valueMode", "filter"]);
  return storeProps;
};

export { getLineModel, getMark, getNode, getParentMarks, getParentsToRoot, getStoreConfig, getTNode, isTreeNodeValue };
//# sourceMappingURL=util.mjs.map
