/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
var Card = /** @class */ (function (_super) {
    tslib.__extends(Card, _super);
    function Card(props) {
        var _this = _super.call(this, props) || this;
        _this.handleClick = _this.handleClick.bind(_this);
        return _this;
    }
    Card.prototype.handleClick = function (e) {
        if (amisCore.isClickOnInput(e)) {
            return;
        }
        this.props.onClick && this.props.onClick(e);
    };
    Card.prototype.render = function () {
        var _a = this.props, cx = _a.classnames, className = _a.className, style = _a.style, headerClassName = _a.headerClassName, bodyClassName = _a.bodyClassName, titleClassName = _a.titleClassName, subTitleClassName = _a.subTitleClassName, descriptionClassName = _a.descriptionClassName, avatarClassName = _a.avatarClassName, avatarTextStyle = _a.avatarTextStyle, imageClassName = _a.imageClassName, avatarTextClassName = _a.avatarTextClassName, secondaryClassName = _a.secondaryClassName, footerClassName = _a.footerClassName, media = _a.media, mediaPosition = _a.mediaPosition, mediaActionPosition = _a.mediaActionPosition, actions = _a.actions, children = _a.children, onClick = _a.onClick, toolbar = _a.toolbar, title = _a.title, subTitle = _a.subTitle, subTitlePlaceholder = _a.subTitlePlaceholder, description = _a.description, descriptionPlaceholder = _a.descriptionPlaceholder, secondary = _a.secondary, avatar = _a.avatar, avatarText = _a.avatarText, data = _a.data;
        var heading = null;
        var isShowHeading = avatar ||
            avatarText ||
            title ||
            subTitle ||
            subTitlePlaceholder ||
            description ||
            descriptionPlaceholder ||
            toolbar;
        if (isShowHeading) {
            heading = (_J$X_("div", { className: cx('Card-heading', headerClassName) },
                avatar ? (_J$X_("span", { className: cx('Card-avtar', avatarClassName) },
                    _J$X_("img", { className: cx('Card-img', imageClassName), src: avatar }))) : avatarText ? (_J$X_("span", { className: cx('Card-avtarText', avatarTextClassName), style: amisCore.buildStyle(avatarTextStyle, data) }, avatarText)) : null,
                _J$X_("div", { className: cx('Card-meta') },
                    title ? (_J$X_("div", { className: cx('Card-title', titleClassName) }, title)) : null,
                    subTitle || subTitlePlaceholder ? (_J$X_("div", { className: cx('Card-subTitle', subTitleClassName) }, subTitle
                        ? subTitle
                        : subTitlePlaceholder
                            ? subTitlePlaceholder
                            : null)) : null,
                    description || descriptionPlaceholder ? (_J$X_("div", { className: cx('Card-desc', descriptionClassName) }, description
                        ? description
                        : descriptionPlaceholder
                            ? descriptionPlaceholder
                            : null)) : null),
                toolbar));
        }
        var body = children;
        var actionView = secondary || actions ? (_J$X_("div", { className: cx('Card-footer-wrapper', footerClassName) },
            secondary ? (_J$X_("div", { className: cx('Card-secondary', secondaryClassName) }, secondary)) : null,
            actions ? (_J$X_("div", { className: cx('Card-actions-wrapper') }, actions)) : null)) : null;
        return (_J$X_("div", { onClick: this.handleClick, className: cx('Card', className, {
                'Card--link': onClick
            }), style: style }, media ? (_J$X_(React__default["default"].Fragment, null,
            _J$X_("div", { className: cx("Card-multiMedia--".concat(mediaPosition)) },
                media,
                _J$X_("div", { className: cx('Card-multiMedia-flex') },
                    heading,
                    body ? (_J$X_("div", { className: cx('Card-body', bodyClassName) }, body)) : null,
                    !mediaActionPosition ? actionView : null)),
            mediaActionPosition === 'outside' ? actionView : null)) : (_J$X_(React__default["default"].Fragment, null,
            heading,
            body ? (_J$X_("div", { className: cx('Card-body', bodyClassName) }, body)) : null,
            actionView))));
    };
    Card.defaultProps = {
        className: '',
        avatarClassName: '',
        headerClassName: '',
        footerClassName: '',
        secondaryClassName: '',
        avatarTextClassName: '',
        bodyClassName: '',
        titleClassName: '',
        subTitleClassName: '',
        descriptionClassName: '',
        imageClassName: '',
        mediaPosition: 'left'
    };
    return Card;
}(React__default["default"].Component));
var Card$1 = amisCore.themeable(Card);

exports.Card = Card;
exports["default"] = Card$1;
