'use strict';

var vue = require('vue');
var log = require('../log.cjs');
var props = require('./props.cjs');

function cloneElement(vnode, nodeProps = {}, override = true, mergeRef = false) {
  let ele = vnode;
  if (Array.isArray(vnode))
    ele = props.filterEmpty(vnode)[0];
  if (!ele)
    return null;
  const node = vue.cloneVNode(ele, nodeProps, mergeRef);
  node.props = override ? { ...node.props, ...nodeProps } : node.props;
  log.devWarning(typeof node.props.class !== "object", "class must be string");
  return node;
}
function cloneVNodes(vnodes, nodeProps = {}, override = true) {
  return vnodes.map((vnode) => cloneElement(vnode, nodeProps, override));
}
function deepCloneElement(vnode, nodeProps = {}, override = true, mergeRef = false) {
  if (Array.isArray(vnode)) {
    return vnode.map((item) => deepCloneElement(item, nodeProps, override, mergeRef));
  } else {
    if (!vue.isVNode(vnode))
      return vnode;
    const cloned = cloneElement(vnode, nodeProps, override, mergeRef);
    if (Array.isArray(cloned.children))
      cloned.children = deepCloneElement(cloned.children);
    return cloned;
  }
}
function triggerVNodeUpdate(vm, attrs, dom) {
  vue.render(vue.cloneVNode(vm, { ...attrs }), dom);
}

exports.cloneElement = cloneElement;
exports.cloneVNodes = cloneVNodes;
exports.deepCloneElement = deepCloneElement;
exports.triggerVNodeUpdate = triggerVNodeUpdate;
//# sourceMappingURL=vnode.cjs.map
