<?php

declare(strict_types=1);

/**
 * APO-193 Card 9 — List footer variants.
 *
 * URI:   GET /api/v1/design/footers
 * Scope: design.read
 */
final class MyronListFootersAction implements MyronAction
{
    public function __construct(
        private readonly MyronFooterDesignRepository $footers,
    ) {
    }

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri:           '/api/v1/design/footers',
            method:        'GET',
            domain:        'design',
            resource:      'footer',
            verb:          'list',
            inputSchema:   ['type' => 'object', 'properties' => []],
            outputSchema:  ['type' => 'object', 'properties' => ['items' => ['type' => 'array']]],
            requiredScope:   MyronApiScopes::DESIGN_READ,
            summary:         'List footer variants with their activation, default, and configuration state. Each row includes both `variant_id` (machine code, e.g. "footer.standard") and `variant_label` (human-readable name, e.g. "Standard"). Footer variants are layout templates distinct from saved section variants.',
            sideEffects:     [],
            preconditions:   [],
            postconditions:  [],
            audienceClass:   3,
            adminAliases:    [],
            snapshotInclude: true,
            snapshotKey:     'design.footers',
            exposeToMcp:     true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok([
            'items' => $this->footers->listVariants(),
        ]);
    }
}
