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

import { __extends } from 'tslib';
import React__default from 'react';
import { isClickOnInput, buildStyle, themeable } from 'amis-core';

var Card = /** @class */ (function (_super) {
    __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 (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 = (React__default.createElement("div", { className: cx('Card-heading', headerClassName) },
                avatar ? (React__default.createElement("span", { className: cx('Card-avtar', avatarClassName) },
                    React__default.createElement("img", { className: cx('Card-img', imageClassName), src: avatar }))) : avatarText ? (React__default.createElement("span", { className: cx('Card-avtarText', avatarTextClassName), style: buildStyle(avatarTextStyle, data) }, avatarText)) : null,
                React__default.createElement("div", { className: cx('Card-meta') },
                    title ? (React__default.createElement("div", { className: cx('Card-title', titleClassName) }, title)) : null,
                    subTitle || subTitlePlaceholder ? (React__default.createElement("div", { className: cx('Card-subTitle', subTitleClassName) }, subTitle
                        ? subTitle
                        : subTitlePlaceholder
                            ? subTitlePlaceholder
                            : null)) : null,
                    description || descriptionPlaceholder ? (React__default.createElement("div", { className: cx('Card-desc', descriptionClassName) }, description
                        ? description
                        : descriptionPlaceholder
                            ? descriptionPlaceholder
                            : null)) : null),
                toolbar));
        }
        var body = children;
        var actionView = secondary || actions ? (React__default.createElement("div", { className: cx('Card-footer-wrapper', footerClassName) },
            secondary ? (React__default.createElement("div", { className: cx('Card-secondary', secondaryClassName) }, secondary)) : null,
            actions ? (React__default.createElement("div", { className: cx('Card-actions-wrapper') }, actions)) : null)) : null;
        return (React__default.createElement("div", { onClick: this.handleClick, className: cx('Card', className, {
                'Card--link': onClick
            }), style: style }, media ? (React__default.createElement(React__default.Fragment, null,
            React__default.createElement("div", { className: cx("Card-multiMedia--".concat(mediaPosition)) },
                media,
                React__default.createElement("div", { className: cx('Card-multiMedia-flex') },
                    heading,
                    body ? (React__default.createElement("div", { className: cx('Card-body', bodyClassName) }, body)) : null,
                    !mediaActionPosition ? actionView : null)),
            mediaActionPosition === 'outside' ? actionView : null)) : (React__default.createElement(React__default.Fragment, null,
            heading,
            body ? (React__default.createElement("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.Component));
var Card$1 = themeable(Card);

export { Card, Card$1 as default };
