"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Skeleton", {
    enumerable: true,
    get: function() {
        return Skeleton;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _avatar = /*#__PURE__*/ _interop_require_default._(require("../avatar"));
var _typings = require("../../utils/typings");
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    rows: 1,
    animated: false,
    title: false,
    avatar: false,
    avatarSize: '50px',
    visible: false,
    avatarShape: 'round'
});
var Skeleton = function Skeleton(props) {
    var _ref = (0, _object_spread._)({}, defaultProps, props), className = _ref.className, animated = _ref.animated, rows = _ref.rows, title = _ref.title, avatar = _ref.avatar, avatarSize = _ref.avatarSize, visible = _ref.visible, children = _ref.children, avatarShape = _ref.avatarShape, rest = (0, _object_without_properties._)(_ref, [
        "className",
        "animated",
        "rows",
        "title",
        "avatar",
        "avatarSize",
        "visible",
        "children",
        "avatarShape"
    ]);
    var classPrefix = 'nut-skeleton';
    var classes = (0, _classnames.default)(classPrefix, className);
    var _obj;
    var avatarClass = (0, _classnames.default)((_obj = {}, (0, _define_property._)(_obj, "nut-avatar", true), (0, _define_property._)(_obj, "nut-skeleton-content-avatar", true), (0, _define_property._)(_obj, "avatar-".concat(avatarShape), avatarShape), _obj));
    var repeatLines = function repeatLines(num) {
        return Array.from({
            length: num
        }, function(v, i) {
            return i;
        });
    };
    var getStyle = function getStyle() {
        if (avatarSize) {
            return {
                width: avatarSize,
                height: avatarSize
            };
        }
        return {
            width: '50px',
            height: '50px'
        };
    };
    return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, visible ? /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, children) : /*#__PURE__*/ _react.default.createElement("div", (0, _object_spread._)({
        className: classes
    }, rest), animated && /*#__PURE__*/ _react.default.createElement("div", {
        className: "".concat(classPrefix, "-animation")
    }), /*#__PURE__*/ _react.default.createElement("div", {
        className: "".concat(classPrefix, "-content")
    }, avatar && /*#__PURE__*/ _react.default.createElement(_avatar.default, {
        className: avatarClass,
        shape: avatarShape,
        style: getStyle(),
        icon: "null"
    }), rows === 1 ? /*#__PURE__*/ _react.default.createElement("div", {
        className: "".concat(classPrefix, "-content-block")
    }) : /*#__PURE__*/ _react.default.createElement("div", {
        className: "".concat(classPrefix, "-content-line")
    }, title && /*#__PURE__*/ _react.default.createElement("div", {
        className: "".concat(classPrefix, "-content-title")
    }), repeatLines(rows).map(function(item, index) {
        return /*#__PURE__*/ _react.default.createElement("div", {
            className: "".concat(classPrefix, "-content-block"),
            key: index
        });
    })))));
};
Skeleton.displayName = 'NutSkeleton';
