package org.github.tess1o.geopulse.streaming.config;

import io.quarkus.runtime.annotations.StaticInitSafe;
import jakarta.enterprise.context.ApplicationScoped;
import lombok.Getter;
import org.eclipse.microprofile.config.inject.ConfigProperty;

/**
 * Configuration properties for timeline processing with environment variable support.
 * All properties can be overridden via environment variables.
 */
@Getter
@ApplicationScoped
public class TimelineConfigurationProperties {

    @ConfigProperty(name = "geopulse.timeline.staypoint.use_velocity_accuracy", defaultValue = "true")
    @StaticInitSafe
    String useVelocityAccuracy;

    @ConfigProperty(name = "geopulse.timeline.staypoint.velocity.threshold", defaultValue = "2.0")
    @StaticInitSafe
    String staypointVelocityThreshold;

    @ConfigProperty(name = "geopulse.timeline.staypoint.accuracy.threshold", defaultValue = "60.0")
    @StaticInitSafe
    String staypointAccuracyThreshold;

    @ConfigProperty(name = "geopulse.timeline.staypoint.min_accuracy_ratio", defaultValue = "0.5")
    @StaticInitSafe
    String staypointMinAccuracyRatio;

    // Trip Detection
    @ConfigProperty(name = "geopulse.timeline.trip.detection.algorithm", defaultValue = "single")
    @StaticInitSafe
    String tripDetectionAlgorithm;

    @ConfigProperty(name = "geopulse.timeline.staypoint.radius_meters", defaultValue = "50")
    @StaticInitSafe
    String staypointRadiusMeters;

    @ConfigProperty(name = "geopulse.timeline.staypoint.min_duration_minutes", defaultValue = "7")
    @StaticInitSafe
    String staypointMinDurationMinutes;

    // Merging
    @ConfigProperty(name = "geopulse.timeline.staypoint.merge.enabled", defaultValue = "true")
    @StaticInitSafe
    String mergeEnabled;

    @ConfigProperty(name = "geopulse.timeline.staypoint.merge.max_distance_meters", defaultValue = "150")
    @StaticInitSafe
    String mergeMaxDistanceMeters;

    @ConfigProperty(name = "geopulse.timeline.staypoint.merge.max_time_gap_minutes", defaultValue = "10")
    @StaticInitSafe
    String mergeMaxTimeGapMinutes;

    // GPS Path Simplification
    @ConfigProperty(name = "geopulse.timeline.path.simplification.enabled", defaultValue = "true")
    @StaticInitSafe
    String pathSimplificationEnabled;

    @ConfigProperty(name = "geopulse.timeline.path.simplification.tolerance", defaultValue = "15.0")
    @StaticInitSafe
    String pathSimplificationTolerance;

    @ConfigProperty(name = "geopulse.timeline.path.simplification.max_points", defaultValue = "100")
    @StaticInitSafe
    String pathMaxPoints;

    @ConfigProperty(name = "geopulse.timeline.path.simplification.adaptive", defaultValue = "true")
    @StaticInitSafe
    String pathAdaptiveSimplification;

    // Data Gap Detection
    @ConfigProperty(name = "geopulse.timeline.data_gap.threshold_seconds", defaultValue = "10800")
    @StaticInitSafe
    String dataGapThresholdSeconds;

    @ConfigProperty(name = "geopulse.timeline.data_gap.min_duration_seconds", defaultValue = "1800")
    @StaticInitSafe
    String dataGapMinDurationSeconds;

    // Gap Stay Inference - infer stay when gap occurs but points before/after are at same location
    @ConfigProperty(name = "geopulse.timeline.gap_stay_inference.enabled", defaultValue = "false")
    @StaticInitSafe
    String gapStayInferenceEnabled;

    @ConfigProperty(name = "geopulse.timeline.gap_stay_inference.max_gap_hours", defaultValue = "24")
    @StaticInitSafe
    String gapStayInferenceMaxGapHours;

    // Gap Trip Inference - infer trip when gap occurs with long-distance movement
    @ConfigProperty(name = "geopulse.timeline.gap_trip_inference.enabled", defaultValue = "false")
    @StaticInitSafe
    String gapTripInferenceEnabled;

    @ConfigProperty(name = "geopulse.timeline.gap_trip_inference.min_distance_meters", defaultValue = "100000")
    @StaticInitSafe
    String gapTripInferenceMinDistanceMeters;

    @ConfigProperty(name = "geopulse.timeline.gap_trip_inference.min_gap_hours", defaultValue = "1")
    @StaticInitSafe
    String gapTripInferenceMinGapHours;

    @ConfigProperty(name = "geopulse.timeline.gap_trip_inference.max_gap_hours", defaultValue = "24")
    @StaticInitSafe
    String gapTripInferenceMaxGapHours;

    // Travel Classification
    @ConfigProperty(name = "geopulse.timeline.travel.classification.walking.max_avg_speed", defaultValue = "6.0")
    @StaticInitSafe
    String walkingMaxAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.walking.max_max_speed", defaultValue = "8.0")
    @StaticInitSafe
    String walkingMaxMaxSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.car.enabled", defaultValue = "true")
    @StaticInitSafe
    String carEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.motorcycle.enabled", defaultValue = "false")
    @StaticInitSafe
    String motorcycleEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.preferred_motorized_type", defaultValue = "CAR")
    @StaticInitSafe
    String preferredMotorizedType;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.car.min_avg_speed", defaultValue = "10.0")
    @StaticInitSafe
    String carMinAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.car.min_max_speed", defaultValue = "15.0")
    @StaticInitSafe
    String carMinMaxSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.short_distance_km", defaultValue = "1.0")
    @StaticInitSafe
    String shortDistanceKm;

    // Trip Stop Detection
    @ConfigProperty(name = "geopulse.timeline.trip.arrival.min_duration_seconds", defaultValue = "90")
    @StaticInitSafe
    String tripArrivalDetectionMinDurationSeconds;

    @ConfigProperty(name = "geopulse.timeline.trip.sustained_stop.min_duration_seconds", defaultValue = "60")
    @StaticInitSafe
    String tripSustainedStopMinDurationSeconds;

    @ConfigProperty(name = "geopulse.timeline.trip.arrival.min_points", defaultValue = "3")
    @StaticInitSafe
    String tripArrivalMinPoints;

    // Optional Trip Types - Bicycle
    @ConfigProperty(name = "geopulse.timeline.travel.classification.bicycle.enabled", defaultValue = "false")
    @StaticInitSafe
    String bicycleEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.bicycle.min_avg_speed", defaultValue = "8.0")
    @StaticInitSafe
    String bicycleMinAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.bicycle.max_avg_speed", defaultValue = "25.0")
    @StaticInitSafe
    String bicycleMaxAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.bicycle.max_max_speed", defaultValue = "35.0")
    @StaticInitSafe
    String bicycleMaxMaxSpeed;

    // Optional Trip Types - Running
    @ConfigProperty(name = "geopulse.timeline.travel.classification.running.enabled", defaultValue = "false")
    @StaticInitSafe
    String runningEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.running.min_avg_speed", defaultValue = "7.0")
    @StaticInitSafe
    String runningMinAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.running.max_avg_speed", defaultValue = "14.0")
    @StaticInitSafe
    String runningMaxAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.running.max_max_speed", defaultValue = "18.0")
    @StaticInitSafe
    String runningMaxMaxSpeed;

    // Optional Trip Types - Train
    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.enabled", defaultValue = "false")
    @StaticInitSafe
    String trainEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.min_avg_speed", defaultValue = "30.0")
    @StaticInitSafe
    String trainMinAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.max_avg_speed", defaultValue = "150.0")
    @StaticInitSafe
    String trainMaxAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.min_max_speed", defaultValue = "80.0")
    @StaticInitSafe
    String trainMinMaxSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.max_max_speed", defaultValue = "180.0")
    @StaticInitSafe
    String trainMaxMaxSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.train.max_speed_variance", defaultValue = "15.0")
    @StaticInitSafe
    String trainMaxSpeedVariance;

    // Optional Trip Types - Flight
    @ConfigProperty(name = "geopulse.timeline.travel.classification.flight.enabled", defaultValue = "false")
    @StaticInitSafe
    String flightEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.flight.min_avg_speed", defaultValue = "400.0")
    @StaticInitSafe
    String flightMinAvgSpeed;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.flight.min_max_speed", defaultValue = "500.0")
    @StaticInitSafe
    String flightMinMaxSpeed;

    // Optional Trip Types - Boat
    @ConfigProperty(name = "geopulse.timeline.travel.classification.boat.enabled", defaultValue = "false")
    @StaticInitSafe
    String boatEnabled;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.boat.min_water_ratio", defaultValue = "0.60")
    @StaticInitSafe
    String boatMinWaterRatio;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.boat.min_water_distance_meters", defaultValue = "2000.0")
    @StaticInitSafe
    String boatMinWaterDistanceMeters;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.boat.min_continuous_water_distance_meters", defaultValue = "1000.0")
    @StaticInitSafe
    String boatMinContinuousWaterDistanceMeters;

    @ConfigProperty(name = "geopulse.timeline.travel.classification.boat.max_plausible_speed", defaultValue = "120.0")
    @StaticInitSafe
    String boatMaxPlausibleSpeed;

    // Timeline View Item Limit - maximum number of items to load on Timeline page
    @ConfigProperty(name = "geopulse.timeline.view.item-limit", defaultValue = "150")
    @StaticInitSafe
    Integer viewItemLimit;
}
