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 { Loading as IconLoading, Loading1 as IconLoading1 } from "@nutui/icons-react-taro";
import { View } from "@tarojs/components";
import { ComponentDefaults } from "../../utils/typings";
// 方便以后扩展设置为键值对形式
var loadingMap = {
    circular: IconLoading1,
    spinner: IconLoading
};
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
    // 对比一下,个人感觉还是Loading1比较好看一些,所以用它作为了默认的loading图标
    type: 'circular',
    direction: 'horizontal'
});
export var Loading = /*#__PURE__*/ React.forwardRef(function(props, ref) {
    var _ref = _object_spread({}, defaultProps, props), className = _ref.className, style = _ref.style, children = _ref.children, direction = _ref.direction, icon = _ref.icon, rest = _object_without_properties(_ref, [
        "className",
        "style",
        "children",
        "direction",
        "icon"
    ]);
    var classPrefix = 'nut-loading';
    var getLoadingIcon = function() {
        var LoadingIcon = loadingMap[rest.type] || IconLoading1;
        return /*#__PURE__*/ React.createElement(LoadingIcon, {
            className: "".concat(classPrefix, "-icon")
        });
    };
    var iconboxClassName = function() {
        return !icon ? "".concat(classPrefix, "-icon-box") : '';
    };
    return /*#__PURE__*/ React.createElement(View, {
        className: classNames(classPrefix, direction === 'vertical' ? "".concat(classPrefix, "-vertical") : '', className),
        style: style
    }, /*#__PURE__*/ React.createElement(View, {
        className: iconboxClassName()
    }, icon || getLoadingIcon()), children ? /*#__PURE__*/ React.createElement(View, {
        className: "".concat(classPrefix, "-text")
    }, children) : null);
});
Loading.displayName = 'NutLoading';
