var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { implementRuntimeComponent } from '@subscan/widget-runtime';
import { Type } from '@sinclair/typebox';
import { PRESET_PROPERTY_CATEGORY } from '@subscan/widget-shared';
import { css, cx } from '@emotion/css';
import { COMPONENTS_CATEGORY, VERSION } from 'config/constants';
import { FALLBACK_METADATA } from 'utils/widget-helper';
import { StyledFont12, StyledFont14, StyledModuleBox } from 'ui/common';
import { Icons } from 'components/Svg/Icons';
import styled from 'styled-components';
var StyledGrid = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  display: grid;\n  grid-template-columns: repeat(auto-fill, 180px);\n  grid-row-gap: 20px;\n"], ["\n  display: grid;\n  grid-template-columns: repeat(auto-fill, 180px);\n  grid-row-gap: 20px;\n"])));
var StyledColumn = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  display: flex;\n"], ["\n  display: flex;\n"])));
var StyledValue = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n  margin-left: 20px;\n"], ["\n  margin-left: 20px;\n"])));
var CssBox = css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n  padding: 25px;\n"], ["\n  padding: 25px;\n"])));
export var ColumnSpec = Type.Object({
    title: Type.String({
        title: 'Title',
        category: PRESET_PROPERTY_CATEGORY.Basic,
    }),
    value: Type.String({
        title: 'Value',
        category: PRESET_PROPERTY_CATEGORY.Basic,
    }),
    icon: Type.KeyOf(Type.Object(Icons), {
        title: 'Icon Name',
    }),
});
export default implementRuntimeComponent({
    version: VERSION.Core,
    metadata: __assign(__assign({}, FALLBACK_METADATA), { name: 'cardsummary', displayName: 'Card Summary', description: 'Card Summary', exampleProperties: {
            columns: [
                {
                    title: 'Finalized Block',
                    value: '145,431',
                    icon: 'barchart',
                },
                {
                    title: 'Signed Extrinsics',
                    value: '54,541,324',
                    icon: 'barchart',
                },
                {
                    title: 'Signed Extrinsics',
                    value: '54,541,324',
                    icon: 'barchart',
                },
                {
                    title: 'Signed Extrinsics',
                    value: '54,541,324',
                    icon: 'barchart',
                },
                {
                    title: 'Signed Extrinsics',
                    value: '54,541,324',
                    icon: 'barchart',
                },
            ],
        }, annotations: {
            category: COMPONENTS_CATEGORY.Display,
        } }),
    spec: {
        properties: Type.Object({
            columns: Type.Array(ColumnSpec, {
                title: 'Columns',
                description: '',
                category: PRESET_PROPERTY_CATEGORY.Columns,
                widget: 'core/v1/array',
                widgetOptions: {
                    displayedKeys: ['title'],
                },
                weight: 0,
            }),
        }),
        state: Type.Object({
            isHover: Type.Boolean(),
        }),
        methods: {},
        slots: {},
        styleSlots: ['content'],
        events: ['onClick'],
    },
})(function (_a) {
    var _b = _a.columns, columns = _b === void 0 ? [] : _b, customStyle = _a.customStyle, callbackMap = _a.callbackMap, elementRef = _a.elementRef, mergeState = _a.mergeState;
    return (_jsx(StyledModuleBox, __assign({ className: cx(css(customStyle === null || customStyle === void 0 ? void 0 : customStyle.content), CssBox), ref: elementRef }, { children: _jsx(StyledGrid, { children: columns.map(function (column, index) {
                var IconComponent = Icons[column.icon];
                return (_jsxs(StyledColumn, { children: [_jsx(IconComponent, { width: "20" }), _jsxs(StyledValue, { children: [_jsx(StyledFont12, __assign({ block: true, fontColor: "background02" }, { children: column.title })), _jsx(StyledFont14, __assign({ block: true, bold: true }, { children: column.value }))] })] }, "".concat(column.title).concat(index)));
            }) }) })));
});
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
