import { _ as _define_property } from "@swc/helpers/_/_define_property";
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
import React from "react";
import classNames from "classnames";
import Avatar from "../avatar";
import { ComponentDefaults } from "../../utils/typings";
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
    rows: 1,
    animated: false,
    title: false,
    avatar: false,
    avatarSize: '50px',
    visible: false,
    avatarShape: 'round'
});
export var Skeleton = function(props) {
    var _ref = _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 = _object_without_properties(_ref, [
        "className",
        "animated",
        "rows",
        "title",
        "avatar",
        "avatarSize",
        "visible",
        "children",
        "avatarShape"
    ]);
    var classPrefix = 'nut-skeleton';
    var classes = classNames(classPrefix, className);
    var _obj;
    var avatarClass = classNames((_obj = {}, _define_property(_obj, "nut-avatar", true), _define_property(_obj, "nut-skeleton-content-avatar", true), _define_property(_obj, "avatar-".concat(avatarShape), avatarShape), _obj));
    var repeatLines = function(num) {
        return Array.from({
            length: num
        }, function(v, i) {
            return i;
        });
    };
    var getStyle = function() {
        if (avatarSize) {
            return {
                width: avatarSize,
                height: avatarSize
            };
        }
        return {
            width: '50px',
            height: '50px'
        };
    };
    return /*#__PURE__*/ React.createElement(React.Fragment, null, visible ? /*#__PURE__*/ React.createElement(React.Fragment, null, children) : /*#__PURE__*/ React.createElement("div", _object_spread({
        className: classes
    }, rest), animated && /*#__PURE__*/ React.createElement("div", {
        className: "".concat(classPrefix, "-animation")
    }), /*#__PURE__*/ React.createElement("div", {
        className: "".concat(classPrefix, "-content")
    }, avatar && /*#__PURE__*/ React.createElement(Avatar, {
        className: avatarClass,
        shape: avatarShape,
        style: getStyle(),
        icon: "null"
    }), rows === 1 ? /*#__PURE__*/ React.createElement("div", {
        className: "".concat(classPrefix, "-content-block")
    }) : /*#__PURE__*/ React.createElement("div", {
        className: "".concat(classPrefix, "-content-line")
    }, title && /*#__PURE__*/ React.createElement("div", {
        className: "".concat(classPrefix, "-content-title")
    }), repeatLines(rows).map(function(item, index) {
        return /*#__PURE__*/ React.createElement("div", {
            className: "".concat(classPrefix, "-content-block"),
            key: index
        });
    })))));
};
Skeleton.displayName = 'NutSkeleton';
