package de.arindy.dicetower

import io.quarkus.qute.TemplateInstance
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.PathParam
import jakarta.ws.rs.Produces
import jakarta.ws.rs.QueryParam
import jakarta.ws.rs.core.MediaType

@Path("chatoverlay")
class ChatOverlayResource {

    @GET
    @Path("/{channel}")
    @Produces(MediaType.TEXT_HTML)
    fun get(
        @PathParam("channel") channel: String,
        @QueryParam("scale") scale: Int? = 7,
        @QueryParam("maxDice") maxDice: Int? = 20,
        @QueryParam("modsAllowed") modsAllowed: Boolean = false,
        @QueryParam("vipAllowed") vipAllowed: Boolean = false,
        @QueryParam("subsAllowed") subsAllowed: Boolean = false,
        @QueryParam("allAllowed") allAllowed: Boolean = false,
        @QueryParam("cmd") cmd: String? = "roll",
        @QueryParam("theme") theme: String? = "default",
        @QueryParam("faceColor") faceColor: String? = "#ff0202",
        @QueryParam("numberColor") numberColor: String? = "#ffffff",
        @QueryParam("clearAfter") clearAfter: Long? = -1,
        @QueryParam("timeout") timeout: Long? = -1,
        @QueryParam("showResults") showResults: Boolean = true
    ): TemplateInstance {
        return Templates.chatoverlay(channel, scale ?: 7, maxDice ?: 20, modsAllowed, vipAllowed, subsAllowed, allAllowed, cmd ?: "roll", theme ?: "default", faceColor ?: "#ff0202", numberColor ?: "#ffffff", clearAfter ?: 10, timeout ?: 60, showResults)
    }

    @GET
    @Produces(MediaType.TEXT_HTML)
    fun config(
    ): TemplateInstance {
        return Templates.chatoverlayconfig()
    }

}
