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

import { defineComponent, computed, createVNode, isVNode } from 'vue';
import isString from 'lodash/isString';
import { usePrefixClass, useCommonClassName } from '../hooks/useConfig.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import { Loading } from '../loading/index.js';
import props from './props.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-e041f5b0.js';
import 'dayjs';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isObject';
import '../utils/withInstall.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '@babel/runtime/helpers/defineProperty';
import '../utils/dom.js';
import '../utils/easing.js';
import '../loading/loading.js';
import '@babel/runtime/helpers/slicedToArray';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
}
var _Card = defineComponent({
  name: "TCard",
  props: props,
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var renderTNodeJSX = useTNodeJSX();
    var COMPONENT_NAME = usePrefixClass("card");
    var _useCommonClassName = useCommonClassName(),
      SIZE = _useCommonClassName.SIZE;
    var baseCls = computed(function () {
      var defaultClass = [COMPONENT_NAME.value];
      if (props2.size === "small") defaultClass.push("".concat(SIZE.value[props2.size]));
      if (props2.bordered) defaultClass.push("".concat(COMPONENT_NAME.value, "--bordered"));
      if (props2.shadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow"));
      if (props2.hoverShadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow-hover"));
      return defaultClass;
    });
    var headerCls = computed(function () {
      var defaultClass = ["".concat(COMPONENT_NAME.value, "__header")];
      return props2.headerBordered ? defaultClass.concat("".concat(COMPONENT_NAME.value, "__title--bordered")) : ["".concat(COMPONENT_NAME.value, "__header")];
    });
    var headerWrapperCls = usePrefixClass("card__header-wrapper");
    var headerAvatarCls = usePrefixClass("card__avatar");
    var headerTitleCls = usePrefixClass("card__title");
    var headerSubTitleCls = usePrefixClass("card__subtitle");
    var headerDescriptionCls = usePrefixClass("card__description");
    var actionsCls = usePrefixClass("card__actions");
    var bodyCls = usePrefixClass("card__body");
    var coverCls = usePrefixClass("card__cover");
    var footerCls = usePrefixClass("card__footer");
    var footerWrapperCls = usePrefixClass("card__footer-wrapper");
    var isPoster2 = computed(function () {
      return props2.theme === "poster2";
    });
    var showTitle = computed(function () {
      return props2.title || slots.title;
    });
    var showHeader = computed(function () {
      return props2.header || slots.header;
    });
    var showSubtitle = computed(function () {
      return props2.subtitle || slots.subtitle;
    });
    var showAvatar = computed(function () {
      return props2.avatar || slots.avatar;
    });
    var showDescription = computed(function () {
      return props2.description || slots.description;
    });
    var showStatus = computed(function () {
      return props2.status || slots.status;
    });
    var showActions = computed(function () {
      return props2.actions || slots.actions;
    });
    var showFooter = computed(function () {
      return props2.footer || slots.footer;
    });
    var showCover = computed(function () {
      return props2.cover || slots.cover;
    });
    var showLoading = computed(function () {
      return props2.loading || slots.loading;
    });
    var showContent = computed(function () {
      return props2.content || slots.content || props2["default"] || slots["default"];
    });
    var isHeaderRender = computed(function () {
      return showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value;
    });
    var isFooterRender = computed(function () {
      return showFooter.value || showActions.value && isPoster2.value;
    });
    var renderHeader = function renderHeader() {
      if (showHeader.value) return createVNode("div", {
        "class": headerCls.value
      }, [renderTNodeJSX("header")]);
      return createVNode("div", {
        "class": headerCls.value
      }, [createVNode("div", {
        "class": headerWrapperCls.value
      }, [showAvatar.value && createVNode("div", {
        "class": headerAvatarCls.value
      }, [renderTNodeJSX("avatar")]), createVNode("div", null, [showTitle.value && createVNode("span", {
        "class": headerTitleCls.value
      }, [renderTNodeJSX("title")]), showSubtitle.value && createVNode("span", {
        "class": headerSubTitleCls.value
      }, [renderTNodeJSX("subtitle")]), showDescription.value && createVNode("p", {
        "class": headerDescriptionCls.value
      }, [renderTNodeJSX("description")])])]), showActions.value && !isPoster2.value && createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("actions")]), showStatus.value && createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("status")])]);
    };
    var renderCover = function renderCover() {
      var textCover = isString(props2.cover);
      return createVNode("div", {
        "class": coverCls.value
      }, [textCover ? createVNode("img", {
        "src": props2.cover
      }, null) : renderTNodeJSX("cover")]);
    };
    return function () {
      var content = createVNode("div", {
        "class": baseCls.value
      }, [isHeaderRender.value ? renderHeader() : null, showCover.value ? renderCover() : null, showContent.value && createVNode("div", {
        "class": bodyCls.value
      }, [renderTNodeJSX("default") || renderTNodeJSX("content")]), isFooterRender.value && createVNode("div", {
        "class": footerCls.value
      }, [createVNode("div", {
        "class": footerWrapperCls.value
      }, [renderTNodeJSX("footer")]), showActions.value && isPoster2.value && createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("actions")])])]);
      if (showLoading.value) return renderTNodeJSX("loading") || createVNode(Loading, null, _isSlot(content) ? content : {
        "default": function _default() {
          return [content];
        }
      });
      return content;
    };
  }
});

export { _Card as default };
//# sourceMappingURL=card.js.map
