import Foundation

/// Where the mandatory end-of-ride parking photo goes.
///
/// A provider port with an offline stub, mirroring the backend's convention
/// (`app.<x>.enabled=false` → logging stub) so the ride flow runs end to end with no
/// object storage configured.
///
/// The photo is real evidence  bad-parking disputes are the main ops problem in a
/// dockless fleet  so the retention policy and the ops review queue belong with the
/// real implementation, not here.
protocol PhotoUploader {
    /// Returns the URL to hand to booking-service as `photoUrl`.
    func upload(_ jpeg: Data) async throws -> String
}

/// Dev/offline stub: doesn't leave the device, just mints a plausible URL after a short
/// delay so the uploading state is actually exercised in the UI.
///
/// TODO(storage): replace with a multipart upload to object storage (or a
/// booking-service-issued pre-signed URL) once the bucket + retention policy are agreed.
struct StubPhotoUploader: PhotoUploader {
    func upload(_ jpeg: Data) async throws -> String {
        try? await Task.sleep(nanoseconds: 600_000_000)
        return "https://photos.beebbeeb.sa/rides/\(UUID().uuidString).jpg"
    }
}
