import { __assign, __rest } from "tslib";
import { Card, Dropdown, Icon, Menu } from '@alicloud/console-components';
import classnames from 'classnames';
import React from 'react';
function LPCard(props) {
    var className = props.className, style = props.style, cardStyle = props.cardStyle, children = props.children, moreOption = props.moreOption, moreMenuPrpos = props.moreMenuPrpos, moreProps = props.moreProps, filterClassName = props.filterClassName, footerClassName = props.footerClassName, AuxiliaryInfo = props.AuxiliaryInfo, footerAction = props.footerAction, filterContent = props.filterContent, rest = __rest(props, ["className", "style", "cardStyle", "children", "moreOption", "moreMenuPrpos", "moreProps", "filterClassName", "footerClassName", "AuxiliaryInfo", "footerAction", "filterContent"]);
    var menuArea = null;
    if (moreOption) {
        var menuItem = moreOption.map(function (item, index) {
            var name = item.name, rest = __rest(item, ["name"]);
            return React.createElement(Menu.Item, __assign({ key: index + name }, rest, { onClick: function (e) { item.onClick && item.onClick(name, item.key, item, e); } }), name);
        });
        menuArea = React.createElement(Dropdown, __assign({ trigger: React.createElement(Icon, { type: "more", size: "xs", className: "lp-card-more", style: { color: '#555' } }), triggerType: "click" }, moreProps),
            React.createElement(Menu, __assign({}, moreMenuPrpos), menuItem));
    }
    var filterContent_ = filterContent ? React.createElement("div", { className: classnames("lp-card-filterArea", filterClassName) }, filterContent) : null;
    if (footerAction || AuxiliaryInfo) {
        return (React.createElement("div", { className: "lp-card-containrt", style: style },
            React.createElement(Card, __assign({ className: classnames("lp-card", className), extra: menuArea, style: cardStyle }, rest),
                filterContent_,
                children),
            React.createElement("div", { className: classnames("lp-card-footer", footerClassName) },
                AuxiliaryInfo ? React.createElement("div", { className: "lp-footer-left" }, AuxiliaryInfo) : null,
                footerAction ? React.createElement("div", { className: "lp-footer-right" }, footerAction) : null)));
    }
    else {
        var style_ = cardStyle || style;
        return (React.createElement(Card, __assign({ className: classnames("lp-card", className), extra: menuArea, showTitleBullet: false, contentHeight: "auto", style: style_ }, rest),
            filterContent_,
            children));
    }
}
function Cards(props) {
    var dataSource = props.dataSource;
    return (React.createElement("div", { className: "lp-cards" }, dataSource.map(function (item) {
        var nestRight = item.nestRight, nestBottom = item.nestBottom, cardProps = __rest(item, ["nestRight", "nestBottom"]);
        if (item.style) {
            if (nestRight) {
                item.style['marginRight'] = 0;
                item.style['marginBottom'] = 16;
            }
            else if (nestBottom) {
                item.style['marginBottom'] = 0;
                item.style['marginRight'] = 16;
            }
            else {
                item.style['marginRight'] = 16;
                item.style['marginBottom'] = 16;
            }
        }
        else {
            item.style = {};
            if (nestRight) {
                item.style['marginRight'] = 0;
                item.style['marginBottom'] = 16;
            }
            else if (nestBottom) {
                item.style['marginBottom'] = 0;
                item.style['marginRight'] = 16;
            }
            else {
                item.style['marginRight'] = 16;
                item.style['marginBottom'] = 16;
            }
        }
        return React.createElement(LPCard, __assign({}, cardProps));
    })));
}
LPCard.Cards = Cards;
LPCard.Media = Card.Media;
LPCard.Header = Card.Header;
LPCard.Content = Card.Content;
LPCard.Divider = Card.Divider;
LPCard.Actions = Card.Actions;
export default LPCard;
