/**
 * amis v3.1.0
 * Copyright 2018-2023 baidu
 */

import { __extends, __rest, __assign, __decorate } from 'tslib';
import React from 'react';
import { Renderer, isPureVariable, resolveVariableAndFilter, filter } from 'amis-core';
import { withRemoteConfig, Timeline } from 'amis-ui';

function TimelineCmpt(props) {
    var items = props.items, mode = props.mode, style = props.style, direction = props.direction, reverse = props.reverse, data = props.data, config = props.config; props.source; var render = props.render;
    // 获取源数据
    var timelineItemsRow = config || items || [];
    // 渲染内容
    var resolveRender = function (region, val) {
        return typeof val === 'string' ? filter(val, data) : val && render(region, val);
    };
    // 处理源数据
    var resolveTimelineItems = timelineItemsRow === null || timelineItemsRow === void 0 ? void 0 : timelineItemsRow.map(function (timelineItem) {
        var icon = timelineItem.icon, iconClassName = timelineItem.iconClassName, title = timelineItem.title;
        return __assign(__assign({}, timelineItem), { iconClassName: iconClassName, icon: isPureVariable(icon)
                ? resolveVariableAndFilter(icon, data, '| raw')
                : icon, title: resolveRender('title', title) });
    });
    return (React.createElement(Timeline, { items: resolveTimelineItems, direction: direction, reverse: reverse, mode: mode, style: style }));
}
var TimelineWithRemoteConfig = withRemoteConfig({
    adaptor: function (data) { return data.items || data; }
})(/** @class */ (function (_super) {
    __extends(class_1, _super);
    function class_1() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    class_1.prototype.render = function () {
        var _a = this.props, config = _a.config; _a.deferLoad; _a.loading; _a.updateConfig; var rest = __rest(_a, ["config", "deferLoad", "loading", "updateConfig"]);
        return React.createElement(TimelineCmpt, __assign({ config: config }, rest));
    };
    return class_1;
}(React.Component)));
/** @class */ ((function (_super) {
    __extends(TimelineRenderer, _super);
    function TimelineRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TimelineRenderer.prototype.render = function () {
        return React.createElement(TimelineWithRemoteConfig, __assign({}, this.props));
    };
    TimelineRenderer = __decorate([
        Renderer({
            type: 'timeline'
        })
    ], TimelineRenderer);
    return TimelineRenderer;
})(React.Component));

export { TimelineCmpt };
