const std = @import("std");

const efa = @import("../../efa.zig");

pub fn iconFromTransportationProductClass(class: efa.ApiTransportationProductClass) ?[]const u8 {
    return switch (class) {
        .zug,
        .s_bahn,
        .zug_nv,
        .zug_fv,
        .zug_fv_m_zuschlag,
        .zug_fv_m_spez_fpr,
        .zug_shuttle,
        => train,

        .u_bahn => subway,

        .stadtbahn, .strassen_trambahn => tram,

        .stadtbus,
        .regionalbus,
        .schnellbus,
        .buergerbus,
        .rufbus_liniengebunden,
        .rufbus,
        .anruf_sammel_taxi,
        => bus,

        .seil_zahnradbahn => gondola,

        .schiff => boat,

        .sonstige => null,

        .flugzeug => flight,

        .sev => no_transfer,

        _ => null,
    };
}

fn encodePng(comptime path: []const u8) []const u8 {
    const raw = @embedFile(path);
    const len = std.base64.standard.Encoder.calcSize(raw.len);
    var buf: [len]u8 = undefined;
    {
        @setEvalBranchQuota(1_000_000);
        _ = std.base64.standard.Encoder.encode(&buf, raw);
    }
    const final = buf;
    return &final;
}

pub const train = encodePng("img/train.png");
pub const subway = encodePng("img/subway.png");
pub const tram = encodePng("img/tram.png");
pub const bus = encodePng("img/bus.png");
pub const shuttle = encodePng("img/shuttle.png");
pub const gondola = encodePng("img/gondola.png");
pub const flight = encodePng("img/flight.png");
pub const boat = encodePng("img/boat.png");
pub const no_transfer = encodePng("img/no_transfer.png");
