"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.PublicApiTripTransformation = void 0;
const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
const VehicleIdGenerator_1 = require("../../gtfs-rt/helpers/VehicleIdGenerator");
let PublicApiTripTransformation = class PublicApiTripTransformation extends AbstractTransformation_1.AbstractTransformation {
    constructor() {
        super(...arguments);
        this.name = "PublicApiTripTransformation";
        this.transformInternal = (data) => {
            return {
                gtfs_trip_id: data.gtfs_trip_id,
                route_type: data.gtfs_route_type,
                gtfs_route_short_name: data.gtfs_route_short_name,
                lat: Number.parseFloat(data.lat),
                lng: Number.parseFloat(data.lng),
                bearing: data.bearing,
                delay: data.delay,
                state_position: data.state_position,
                vehicle_id: VehicleIdGenerator_1.VehicleIdGenerator.getVehicleId(data.id, data.gtfs_route_type, data.provider_source_type, data.gtfs_route_short_name, data.cis_trip_number, data.vehicle_registration_number, data.run_number, data.internal_run_number),
                detailed_info: {
                    is_wheelchair_accessible: data.wheelchair_accessible,
                    origin_route_name: data.origin_route_name,
                    shape_id: data.gtfs_shape_id,
                    trip_number: data.cis_trip_number,
                    run_number: data.run_number,
                    trip_headsign: data.last_stop_headsign ?? data.gtfs_trip_headsign,
                    direction_id: data.gtfs_direction_id,
                    shape_dist_traveled: data.shape_dist_traveled === null ? null : Number.parseFloat(data.shape_dist_traveled),
                    last_stop_sequence: data.last_stop_sequence,
                    origin_timestamp: data.origin_timestamp.toISOString(),
                    registration_number: data.vehicle_registration_number,
                    operator: data.agency_name_real ?? data.agency_name_scheduled,
                },
            };
        };
    }
};
exports.PublicApiTripTransformation = PublicApiTripTransformation;
exports.PublicApiTripTransformation = PublicApiTripTransformation = __decorate([
    (0, tsyringe_1.injectable)()
], PublicApiTripTransformation);
//# sourceMappingURL=PublicApiTripTransformation.js.map