import * as tslib_1 from "tslib";
import * as React from 'react';
import classNames from 'classnames';
import FlipItem from './flip-item';
import warning from '../_utils/warning';
var defaultProps = {
    prefixCls: 'ty-flip',
    direction: 'horizontal',
    reverse: false,
};
var Flip = function (props) {
    var _a;
    var width = props.width, height = props.height, direction = props.direction, reverse = props.reverse, prefixCls = props.prefixCls, className = props.className, children = props.children, style = props.style;
    var cls = classNames(prefixCls, className);
    var innerCls = classNames(prefixCls + "__inner", (_a = {},
        _a[prefixCls + "__inner_hor"] = direction === 'horizontal' && !reverse,
        _a[prefixCls + "__inner_hor_reverse"] = direction === 'horizontal' && reverse,
        _a[prefixCls + "__inner_ver"] = direction === 'vertical' && !reverse,
        _a[prefixCls + "__inner_ver_reverse"] = direction === 'vertical' && reverse,
        _a));
    warning(!children || React.Children.count(children) !== 2, 'Children must contain front and back components.', true);
    return (React.createElement("div", { className: cls, style: tslib_1.__assign({ width: width, height: height }, style) },
        React.createElement("div", { className: innerCls }, React.Children.map(children, function (child, index) {
            var _a;
            return (React.cloneElement(child, tslib_1.__assign({}, child.props, { className: classNames((_a = {},
                    _a[prefixCls + "__item-front"] = index === 0,
                    _a[prefixCls + "__item-back"] = index === 1,
                    _a[prefixCls + "__item-back_hor"] = index === 1 && direction === 'horizontal' && !reverse,
                    _a[prefixCls + "__item-back_hor_reverse"] = index === 1 && direction === 'horizontal' && reverse,
                    _a[prefixCls + "__item-back_ver"] = index === 1 && direction === 'vertical' && !reverse,
                    _a[prefixCls + "__item-back_ver_reverse"] = index === 1 && direction === 'vertical' && reverse,
                    _a), child.props.className) })));
        }))));
};
Flip.defaultProps = defaultProps;
Flip.Item = FlipItem;
export default Flip;
//# sourceMappingURL=index.js.map