package at.procon.eventhub.tachographfilesession.service;

import at.procon.eventhub.config.EventHubProperties;
import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.processing.driverworkingtime.service.DriverWorkingTimeReusableProjectionBuilder;
import at.procon.eventhub.tachographfilesession.model.DriverExtractionSession;
import at.procon.eventhub.tachographfilesession.model.ResolvedDriverTimeline;
import at.procon.eventhub.tachographfilesession.model.TachographEsperDrivingDerivedProjectionBundle;
import at.procon.eventhub.tachographfilesession.model.TachographFileSession;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @deprecated Legacy forwarding shell kept only for external callers that still reference the old
 * type. Prefer {@link TachographDerivedProjectionCompatibilityFacade} for tachograph-owned usage
 * or {@link DriverWorkingTimeReusableProjectionBuilder} / the neutral processing core for shared
 * processing.
 */
@Component
@Deprecated(forRemoval = false)
public class DriverTimelineReusableProjectionBuilder {

    private final TachographDerivedProjectionCompatibilityFacade delegate;

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public DriverTimelineReusableProjectionBuilder(
            DriverTimelineBuilder driverTimelineBuilder,
            EventHubProperties properties
    ) {
        this(new TachographDerivedProjectionCompatibilityFacade(driverTimelineBuilder, properties));
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public DriverTimelineReusableProjectionBuilder(
            DriverTimelineBuilder driverTimelineBuilder,
            RawSourceDriverTimelineEventBuilder rawSourceEventBuilder,
            EventHubProperties properties
    ) {
        this(new TachographDerivedProjectionCompatibilityFacade(
                driverTimelineBuilder,
                rawSourceEventBuilder,
                properties
        ));
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Autowired
    @Deprecated(forRemoval = false)
    public DriverTimelineReusableProjectionBuilder(
            TachographDerivedProjectionCompatibilityFacade delegate
    ) {
        this.delegate = delegate;
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade#commonBuilder()}.
     */
    @Deprecated(forRemoval = false)
    public DriverWorkingTimeReusableProjectionBuilder commonBuilder() {
        return delegate.commonBuilder();
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public TachographEsperDrivingDerivedProjectionBundle buildEsperDrivingDerivedProjectionBundle(
            TachographFileSession session,
            DriverExtractionSession driverSession,
            int significantDrivingMinutes,
            int minimumRestPeriodMinutes
    ) {
        return delegate.buildEsperDrivingDerivedProjectionBundle(
                session,
                driverSession,
                significantDrivingMinutes,
                minimumRestPeriodMinutes
        );
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public TachographEsperDrivingDerivedProjectionBundle buildEsperDrivingDerivedProjectionBundle(
            TachographFileSession session,
            int significantDrivingMinutes,
            int minimumRestPeriodMinutes
    ) {
        return delegate.buildEsperDrivingDerivedProjectionBundle(
                session,
                significantDrivingMinutes,
                minimumRestPeriodMinutes
        );
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public TachographEsperDrivingDerivedProjectionBundle buildEsperDrivingDerivedProjectionBundle(
            UUID sessionId,
            String driverKey,
            ResolvedDriverTimeline timeline,
            int significantDrivingMinutes,
            int minimumRestPeriodMinutes
    ) {
        return delegate.buildEsperDrivingDerivedProjectionBundle(
                sessionId,
                driverKey,
                timeline,
                significantDrivingMinutes,
                minimumRestPeriodMinutes
        );
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public TachographEsperDrivingDerivedProjectionBundle buildEsperDrivingDerivedProjectionBundleFromEvents(
            List<EventHubEventDto> events,
            int significantDrivingMinutes,
            int minimumRestPeriodMinutes
    ) {
        return delegate.buildEsperDrivingDerivedProjectionBundleFromEvents(
                events,
                significantDrivingMinutes,
                minimumRestPeriodMinutes
        );
    }

    /**
     * @deprecated Use {@link TachographDerivedProjectionCompatibilityFacade}.
     */
    @Deprecated(forRemoval = false)
    public TachographEsperDrivingDerivedProjectionBundle buildEsperDrivingDerivedProjectionBundleFromEvents(
            UUID fallbackSessionId,
            String fallbackDriverKey,
            List<EventHubEventDto> events,
            int significantDrivingMinutes,
            int minimumRestPeriodMinutes
    ) {
        return delegate.buildEsperDrivingDerivedProjectionBundleFromEvents(
                fallbackSessionId,
                fallbackDriverKey,
                events,
                significantDrivingMinutes,
                minimumRestPeriodMinutes
        );
    }
}
