package chat.vojo.proxy.ui

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.PathBuilder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

/**
 * Thin stroke icons (1.7dp, round caps) matching the design bundle's shared.jsx
 * icon set — unicode glyphs render inconsistently across system fallback fonts.
 * Tinted via Icon(..., tint = ...).
 */
object VojoIcons {

    private inline fun stroke(name: String, crossinline body: PathBuilder.() -> Unit): ImageVector =
        ImageVector.Builder(
            name = name, defaultWidth = 24.dp, defaultHeight = 24.dp,
            viewportWidth = 24f, viewportHeight = 24f,
        ).apply {
            path(
                fill = null,
                stroke = SolidColor(Color.White),
                strokeLineWidth = 1.7f,
                strokeLineCap = StrokeCap.Round,
                strokeLineJoin = StrokeJoin.Round,
            ) { body() }
        }.build()

    private inline fun fill(name: String, crossinline body: PathBuilder.() -> Unit): ImageVector =
        ImageVector.Builder(
            name = name, defaultWidth = 24.dp, defaultHeight = 24.dp,
            viewportWidth = 24f, viewportHeight = 24f,
        ).apply {
            path(fill = SolidColor(Color.White)) { body() }
        }.build()

    private fun PathBuilder.circle(cx: Float, cy: Float, r: Float) {
        moveTo(cx + r, cy)
        arcTo(r, r, 0f, isMoreThanHalf = false, isPositiveArc = true, x1 = cx - r, y1 = cy)
        arcTo(r, r, 0f, isMoreThanHalf = false, isPositiveArc = true, x1 = cx + r, y1 = cy)
        close()
    }

    val Search: ImageVector by lazy {
        stroke("search") {
            moveTo(18f, 11f)
            arcTo(7f, 7f, 0f, isMoreThanHalf = false, isPositiveArc = true, x1 = 4f, y1 = 11f)
            arcTo(7f, 7f, 0f, isMoreThanHalf = false, isPositiveArc = true, x1 = 18f, y1 = 11f)
            moveTo(16f, 16f)
            lineTo(20f, 20f)
        }
    }

    val More: ImageVector by lazy {
        fill("more") {
            circle(5f, 12f, 1.6f)
            circle(12f, 12f, 1.6f)
            circle(19f, 12f, 1.6f)
        }
    }

    val ChevronDown: ImageVector by lazy {
        stroke("chevron-down") {
            moveTo(6f, 9.5f)
            lineTo(12f, 15.5f)
            lineTo(18f, 9.5f)
        }
    }

    val Check: ImageVector by lazy {
        stroke("check") {
            moveTo(5f, 12.5f)
            lineTo(10f, 17.5f)
            lineTo(19f, 6.5f)
        }
    }

    val Plus: ImageVector by lazy {
        stroke("plus") {
            moveTo(12f, 5f)
            verticalLineTo(19f)
            moveTo(5f, 12f)
            horizontalLineTo(19f)
        }
    }

    val Eye: ImageVector by lazy {
        stroke("eye") {
            moveTo(2f, 12f)
            curveTo(5f, 5.8f, 19f, 5.8f, 22f, 12f)
            curveTo(19f, 18.2f, 5f, 18.2f, 2f, 12f)
            close()
            circle(12f, 12f, 3f)
        }
    }

    val EyeOff: ImageVector by lazy {
        stroke("eye-off") {
            moveTo(2f, 12f)
            curveTo(5f, 5.8f, 19f, 5.8f, 22f, 12f)
            curveTo(19f, 18.2f, 5f, 18.2f, 2f, 12f)
            close()
            moveTo(5f, 3.5f)
            lineTo(19f, 20.5f)
        }
    }

    val Cross: ImageVector by lazy {
        stroke("cross") {
            moveTo(6f, 6f)
            lineTo(18f, 18f)
            moveTo(18f, 6f)
            lineTo(6f, 18f)
        }
    }

    val Clipboard: ImageVector by lazy {
        stroke("clipboard") {
            moveTo(9f, 5f)
            horizontalLineTo(6f)
            arcTo(1.5f, 1.5f, 0f, isMoreThanHalf = false, isPositiveArc = false, x1 = 4.5f, y1 = 6.5f)
            verticalLineTo(19.5f)
            arcTo(1.5f, 1.5f, 0f, isMoreThanHalf = false, isPositiveArc = false, x1 = 6f, y1 = 21f)
            horizontalLineTo(18f)
            arcTo(1.5f, 1.5f, 0f, isMoreThanHalf = false, isPositiveArc = false, x1 = 19.5f, y1 = 19.5f)
            verticalLineTo(6.5f)
            arcTo(1.5f, 1.5f, 0f, isMoreThanHalf = false, isPositiveArc = false, x1 = 18f, y1 = 5f)
            horizontalLineTo(15f)
            moveTo(9f, 3.5f)
            horizontalLineTo(15f)
            verticalLineTo(6.5f)
            horizontalLineTo(9f)
            close()
        }
    }
}
