<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Settings;

/**
 * One resolved setting the MCP exposes — the SINGLE source of truth for what a friendly key maps
 * to. Built either by live-enumerating `teinstellungenconf` or from a fixed `lists:` entry in the
 * settings allowlist (see {@see SettingsRegistry}). Carries at most one of {@see SettingConf} (a
 * `teinstellungen` value) or
 * {@see SettingList} (a table listing); `mode` gates which MCP tools may touch it.
 */
final class SettingRow
{
    public const MODES = ['read', 'write', 'both'];

    public function __construct(
        public readonly string $key,
        public readonly string $title,
        public readonly string $summary,
        public readonly string $mode,
        public readonly ?SettingConf $conf = null,
        public readonly ?SettingList $list = null,
    ) {
    }

    public function isReadable(): bool
    {
        return $this->mode === 'read' || $this->mode === 'both';
    }

    public function isWritable(): bool
    {
        return $this->mode === 'write' || $this->mode === 'both';
    }
}
