import { createVNode, cloneVNode } from 'vue';
import { LoadingOutlined, FileOutlined, CaretDownFilled, MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons-vue';
import '../../../../utils/index.mjs';
import { isValidElement } from '../../../../utils/is.mjs';

function renderSwitcherIcon(prefixCls, switcherIcon, props, leafIcon, showLine) {
  const {
    isLeaf,
    expanded,
    loading
  } = props;
  let icon = switcherIcon;
  if (loading)
    return createVNode(LoadingOutlined, {
      "class": `${prefixCls}-switcher-loading-icon`
    }, null);
  let showLeafIcon;
  if (showLine && typeof showLine === "object")
    showLeafIcon = showLine.showLeafIcon;
  let defaultIcon = null;
  const switcherCls = `${prefixCls}-switcher-icon`;
  if (isLeaf) {
    if (!showLine)
      return null;
    if (showLeafIcon && leafIcon)
      return leafIcon(props);
    if (typeof showLine === "object" && !showLeafIcon)
      defaultIcon = createVNode("span", {
        "class": `${prefixCls}-switcher-leaf-line`
      }, null);
    else
      defaultIcon = createVNode(FileOutlined, {
        "class": `${prefixCls}-switcher-line-icon`
      }, null);
    return defaultIcon;
  } else {
    defaultIcon = createVNode(CaretDownFilled, {
      "class": switcherCls
    }, null);
    if (showLine) {
      defaultIcon = expanded ? createVNode(MinusSquareOutlined, {
        "class": `${prefixCls}-switcher-line-icon`
      }, null) : createVNode(PlusSquareOutlined, {
        "class": `${prefixCls}-switcher-line-icon`
      }, null);
    }
  }
  if (typeof switcherIcon === "function") {
    icon = switcherIcon({
      ...props,
      defaultIcon,
      switcherCls
    });
  } else if (isValidElement(icon)) {
    icon = cloneVNode(icon, {
      class: switcherCls
    });
  }
  return icon || defaultIcon;
}

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