syntax = "proto3";

import "fr24/proto/_common.proto";
import "google/protobuf/field_mask.proto";

message LocationBoundaries {
    float north = 1; // Maximum Latitude, degrees, -90 to 90
    float south = 2; // Minimum Latitude, degrees, -90 to 90
    float west = 3;  // Minimum Longitude, degrees, -180 to 180
    float east = 4;  // Maximum Longitude, degrees, -180 to 180
}

message VisibilitySettings {
    repeated _common.DataSource sources_list = 1;
    repeated _common.Service services_list = 2;
    _common.TrafficType traffic_type = 3;
    optional bool only_restricted = 4;
}

message AirportFilter {
    string iata = 1;
    int32 country_id = 2;
    AirportFilterType type = 3;
}
    
enum AirportFilterType {
    BOTH = 0;
    INBOUND = 1;
    OUTBOUND = 2;
}

message Interval {
    int32 min = 1;
    int32 max = 2;
}

message AirlineFilter {
    string icao = 1; // ICAO airline designator, e.g. `CPA`
    AirlineFilterType type = 2;
}

enum AirlineFilterType {
    PAINTED_AS = 0;
    OPERATED_BY = 1;
}

message Filter {
    repeated Interval altitude_ranges_list = 1;
    repeated Interval speed_ranges_list = 2; // Minimum and maximum ground speed, knots
    repeated AirlineFilter airlines_list = 3;
    repeated string callsigns_list = 4;
    repeated string radars_list = 5; // List of receiver IDs, e.g. `["T-VHST000"]`
    repeated string regs_list = 6;
    repeated AirportFilter airports_list = 7;
    repeated string flights_list = 8;
    repeated string types_list = 9; // List of aircraft types, e.g. `["B74*"]`
    repeated Interval birth_year_ranges_list = 10;
    repeated uint32 squawks_list = 11;
    repeated AirportFilter origins_list = 12;
    repeated AirportFilter destinations_list = 13;
    repeated _common.Service categories_list = 14;
    repeated string airspaces_list = 15;
}

message LiveFeedRequest {
    LocationBoundaries bounds = 1;
    VisibilitySettings settings = 2;
    Filter filters_list = 3;
    string fleets_list = 4; // requires authentication
    bool highlight_mode = 5;
    optional bool stats = 6; // Include statistics for the given area
    optional int32 limit = 7; // Maximum number of flights (default 1500 for unauthenticated users, 2000 for authenticated users)
    optional int32 maxage = 8; // Maximum age since last update, seconds (default 14400)
    optional _common.RestrictionVisibility restriction_mode = 9;
    google.protobuf.FieldMask field_mask = 10;
    repeated fixed32 selected_flight_ids_list = 11;
}

message LiveFeedResponse {
    repeated _common.Flight flights_list = 1;
    _common.Stats stats = 2;
    repeated _common.Flight selected_flight_list = 3;
    uint64 server_time_ms = 4;
}

message PlaybackRequest {
    LiveFeedRequest live_feed_request = 1;
    int32 timestamp = 2; // Start timestamp
    // End timestamp, should be timestamp + floor(7.5*(multiplier)) seconds
    // 
    // For 1x playback, it should be timestamp + 7 seconds.
    int32 prefetch = 3;
    optional int32 hfreq = 4; // High frequency mode, likely used to return granular data (?)
}

message PlaybackResponse {
    LiveFeedResponse live_feed_response = 1; // NOTE: position buffer is not included in the response.
}