package com.conveyal.taui.models;

import com.conveyal.r5.model.json_serialization.BitSetDeserializer;
import com.conveyal.r5.model.json_serialization.BitSetSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.util.BitSet;

/**
 * Convert a line to frequency.
 */
public class ConvertToFrequency extends Modification {
    public String name;

    public String feed;
    public String[] routes;

    /** Should trips on this route that start outside the days/times specified by frequency entries be retained? */
    public boolean retainTripsOutsideFrequencyEntries = false;

    public FrequencyEntry[] entries;

    @Override
    public String getType() {
        return "convert-to-frequency";
    }

    public static class FrequencyEntry {
        /** Days of the week on which this service is active, 0 is Monday */
        public boolean monday, tuesday, wednesday, thursday, friday, saturday, sunday;

        /** allow naming entries for organizational purposes */
        public String name;

        /** start time (seconds since GTFS midnight) */
        public int startTime;

        /** end time for frequency-based trips (seconds since GTFS midnight) */
        public int endTime;

        /** headway for frequency-based patterns */
        public int headwaySecs;

        /** start times of this trip (seconds since midnight), when non-null scheduled trips will be created */
        @Deprecated
        public int[] startTimes;

        /** trip from which to copy travel times */
        public String sourceTrip;

        /** trips on the selected patterns which could be used as source trips */
        public String[] patternTrips;

        /** Should this frequency entry use exact times? */
        public boolean exactTimes;
    }
}

@@ -32,299 +32,8 @@
 s;%0A%0A
-import com.conveyal.r5.model.json_serialization.BitSetDeserializer;%0Aimport com.conveyal.r5.model.json_serialization.BitSetSerializer;%0Aimport com.fasterxml.jackson.databind.annotation.JsonDeserialize;%0Aimport com.fasterxml.jackson.databind.annotation.JsonSerialize;%0A%0Aimport java.util.BitSet;%0A%0A
 /**%0A
@@ -550,16 +550,43 @@
 Entry %7B%0A
+        public String id;%0A%0A
         
@@ -1546,24 +1546,24 @@
 t times? */%0A
-
         publ
@@ -1584,16 +1584,547 @@
 ctTimes;
+%0A%0A        /** Phase at a stop that is in this modification */%0A        public String phaseAtStop;%0A%0A        /**%0A         * Phase from a timetable (frequency entry) on another modification.%0A         * Syntax is %60$%7Bmodification.id%7D:$%7Btimetable.id%7D%60%0A         */%0A        public String phaseFromTimetable;%0A%0A        /** Phase from a stop that can be found in the phased from modification's stops */%0A        public String phaseFromStop;%0A%0A        /** Amount of time to phase from the other lines frequency */%0A        public int phaseSeconds;
 %0A    %7D%0A%7D

Add fields for phasing frequency entries.