package com.isidroid.spot.data.mapper

import com.isidroid.spot.model.PrintProfile
import com.isidroid.spot.data.source.remote.response.ProfileResponse

internal fun ProfileResponse.transform(spotId: String, index: Int): PrintProfile {
    val printWidth = options.paperSize.width - options.paperSize.marginLeft - options.paperSize.marginRight
    val printHeight = options.paperSize.height - options.paperSize.marginTop - options.paperSize.marginBottom
    val dimensionFactor = 10

    return PrintProfile(
        id = "$id",
        spotId = spotId,
        name = name.orEmpty(),
        width = options.paperSize.width * dimensionFactor,
        height = options.paperSize.height * dimensionFactor,
        dpix = 300,
        dpiy = 300,

        // fix it
        printWidth = printWidth * dimensionFactor,
        printHeight = printHeight * dimensionFactor,
        marginTop = options.paperSize.marginTop * dimensionFactor,
        marginLeft = options.paperSize.marginLeft * dimensionFactor,

        sort = index,
        grayscale = options.outputColor?.grayscale == true || (spotId == "1" && id == 1)
    )
}