<?php

namespace App\Filament\Forms\Components;

use App\Support\Theme\ThemePresets;
use Filament\Forms\Components\ViewField;

/**
 * The theme preset grid — a searchable, groupable library of mini preview
 * cards, each painted from its preset's REAL token sets, replacing the
 * one-row ToggleButtons the Theme tab shipped with. Mirrors the source
 * project's ThemeManager PresetGridCard (see the leolanka-inertia repo).
 *
 * Selecting a card writes the preset key straight into the form state via a
 * deferred `wire:model` input, so the adjacent live theme preview repaints
 * through the field's own `->live()` server re-render.
 */
class PresetPicker extends ViewField
{
    protected function setUp(): void
    {
        parent::setUp();

        $this->view('filament.forms.preset-picker');
        $this->columnSpanFull();
        $this->viewData(fn (): array => [
            'presets' => ThemePresets::catalogue(),
            'groups' => ['All', ...ThemePresets::groups()],
        ]);
    }
}
