/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.data.api.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject

/**
 * `GET /public/pages/:slug` — a block-based CMS page (website `pages.model.js`
 * `serialize`). Everything block-specific lives inside `props`; the renderer
 * dispatches on `type`. `props` is left as a raw JSON object so new block types
 * or props never break decoding — the renderer reads the keys it knows and
 * ignores the rest.
 */
@Serializable
data class PageDto(
    val id: Long,
    val slug: String = "",
    val title: String = "",
    val status: String = "",
    val blocks: List<BlockDto> = emptyList(),
    @SerialName("publishedAt") val publishedAt: String? = null,
    @SerialName("updatedAt") val updatedAt: String? = null,
)

/**
 * One CMS block. Known types (website `src/blocks/types`): `heading`,
 * `rich_text`, `image`, `quote`, `cta`, `divider`, `two_column`. Container
 * blocks (`two_column`) hold sub-block arrays inside their props.
 */
@Serializable
data class BlockDto(
    val type: String = "",
    val props: JsonObject = JsonObject(emptyMap()),
    val visible: Boolean = true,
)
