<?php

declare(strict_types=1);

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

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri:           '/api/v1/design/section-variants',
            method:        'GET',
            domain:        'design',
            resource:      'section-variant',
            verb:          'list',
            inputSchema:   ['type' => 'object', 'properties' => []],
            outputSchema:  ['type' => 'object', 'properties' => ['items' => ['type' => 'array']]],
            requiredScope:   MyronApiScopes::DESIGN_READ,
            summary:         'List saved section variants (operator-curated section configurations applicable across pages).',
            sideEffects:     [],
            preconditions:   [],
            postconditions:  [],
            audienceClass:   3,
            adminAliases:    [],
            snapshotInclude: true,
            snapshotKey:     'design.sectionVariants',
            exposeToMcp:     true,
        );
    }

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