"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISEventsTransformation = void 0;
const JISEventEffectHelper_1 = require("../../../helpers/jis/JISEventEffectHelper");
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
let JISEventsTransformation = class JISEventsTransformation extends AbstractTransformation_1.AbstractTransformation {
    constructor() {
        super(...arguments);
        this.name = "JISEventsTransformation";
        this.transformInternal = (data) => {
            const event = {
                id: data.id,
                type: data.type,
                header_text: data.header_text,
                cause: data.cause,
                cause_detail: data.cause_detail,
                severity_level: data.severity_level,
                active_period_start: new Date(data.active_period.start),
                active_period_end: data.active_period.end ? new Date(data.active_period.end) : null,
                display_period_start: new Date(data.display_period.start),
                display_period_end: data.display_period.end ? new Date(data.display_period.end) : null,
                effect: JISEventEffectHelper_1.JISEventEffectHelper.getEffectAsString(data.effect),
                effect_detail: data.effect_detail,
                description_text: data.description_text,
                description_html: data.description_html,
                url: data.url,
                organization_name: data.organization_name,
                created_timestamp: new Date(data.created_timestamp),
                updated_timestamp: new Date(data.last_modified_timestamp),
                deleted_timestamp: data.deleted_at ? new Date(data.deleted_at) : null,
            };
            const eventsRopidGTFSRoutes = data.informed_entity?.routes?.map(({ id }) => ({
                event_id: data.id,
                route_id: id,
            })) ?? [];
            return {
                event,
                eventsRopidGTFSRoutes,
            };
        };
    }
};
exports.JISEventsTransformation = JISEventsTransformation;
exports.JISEventsTransformation = JISEventsTransformation = __decorate([
    (0, tsyringe_1.injectable)()
], JISEventsTransformation);
//# sourceMappingURL=JISEventsTransformation.js.map