function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
import React from "react";
export var VisualList = function VisualList(param) {
    var className = param.className, style = param.style, _param_data = param.data, data = _param_data === void 0 ? [] : _param_data, _param_filter = param.filter, filter = _param_filter === void 0 ? function() {
        return true;
    } : _param_filter, emptyRender = param.emptyRender, renderItem = param.renderItem, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading, loadingRender = param.loadingRender, itemStyle = param.itemStyle, imageStyle = param.imageStyle, linkStyle = param.linkStyle;
    // 加载状态渲染
    if (loading) {
        return /*#__PURE__*/ React.createElement("div", {
            className: className,
            style: _object_spread({
                display: 'flex',
                listStyle: 'none',
                margin: 0,
                padding: 0,
                flexFlow: 'wrap'
            }, style)
        }, loadingRender ? loadingRender() : /*#__PURE__*/ React.createElement("span", null, "加载中..."));
    }
    // 过滤数据
    var displayList = data.filter(filter);
    // 空状态渲染
    if (displayList.length === 0) {
        return /*#__PURE__*/ React.createElement("div", {
            className: className,
            style: _object_spread({
                display: 'flex',
                listStyle: 'none',
                margin: 0,
                padding: 0
            }, style)
        }, emptyRender ? emptyRender() : /*#__PURE__*/ React.createElement("span", null, "暂无数据"));
    }
    // 默认渲染函数
    var defaultRenderItem = function defaultRenderItem(item, index) {
        return /*#__PURE__*/ React.createElement("li", {
            key: item.id || index,
            style: _object_spread({
                marginRight: 8,
                marginBottom: 8,
                borderRadius: 8,
                boxSizing: 'border-box',
                overflow: 'hidden',
                border: '1px solid #ddd',
                display: 'flex'
            }, itemStyle)
        }, item.href ? /*#__PURE__*/ React.createElement("a", {
            href: item.href,
            style: _object_spread({
                display: 'flex',
                textDecoration: 'none'
            }, linkStyle)
        }, /*#__PURE__*/ React.createElement("img", {
            width: 40,
            height: 40,
            src: item.src,
            alt: item.alt || item.title || '',
            title: item.title,
            style: _object_spread({
                objectFit: 'cover'
            }, imageStyle)
        })) : /*#__PURE__*/ React.createElement("img", {
            width: 40,
            height: 40,
            src: item.src,
            alt: item.alt || item.title || '',
            title: item.title,
            style: _object_spread({
                objectFit: 'cover'
            }, imageStyle)
        }));
    };
    return /*#__PURE__*/ React.createElement("ul", {
        className: className,
        style: _object_spread({
            display: 'flex',
            boxSizing: 'border-box',
            listStyle: 'none',
            margin: 0,
            padding: 0,
            flexFlow: 'wrap'
        }, style)
    }, displayList.map(function(item, index) {
        if (renderItem) {
            return renderItem(item, index);
        }
        return defaultRenderItem(item, index);
    }));
};
