<?php
/**
 * Canonical map for B9 element style abilities across Doors 2 and 3.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks;

/**
 * Single registry for element style action metadata.
 */
final class ElementStyleAbilityMap
{
    /**
     * @return array<string, array{handler: string, slug: string, label: string, description: string, destructive: bool, idempotent: bool}>
     */
    public static function entries(): array
    {
        return [
            'style_element' => [
                'handler'     => 'styleElement',
                'slug'        => 'lolacore-bricks/style-element',
                'label'       => 'Style Element',
                'description' => 'Apply universal Bricks style controls to one element, including breakpoint and state suffixes. Call with dry_run first.',
                'destructive' => false,
                'idempotent'  => true,
            ],
            'apply_classes' => [
                'handler'     => 'applyClasses',
                'slug'        => 'lolacore-bricks/apply-classes',
                'label'       => 'Apply Classes',
                'description' => 'Apply Bricks global classes to one or more elements. Call with dry_run first to review impact.',
                'destructive' => false,
                'idempotent'  => true,
            ],
            'remove_classes' => [
                'handler'     => 'removeClasses',
                'slug'        => 'lolacore-bricks/remove-classes',
                'label'       => 'Remove Classes',
                'description' => 'Remove Bricks global classes from one or more elements. Call with dry_run first to review impact.',
                'destructive' => false,
                'idempotent'  => true,
            ],
            'update_element_settings' => [
                'handler'     => 'updateElementSettings',
                'slug'        => 'lolacore-bricks/update-element-settings',
                'label'       => 'Update Element Settings',
                'description' => 'Update element-specific Bricks settings after validating keys. Call with dry_run first.',
                'destructive' => false,
                'idempotent'  => true,
            ],
        ];
    }

    /**
     * @return array<string, array{requires_confirmation: bool, type: string}>
     */
    public static function doorTwoActions(): array
    {
        $actions = [];
        foreach (array_keys(self::entries()) as $actionId) {
            $actions[$actionId] = [
                'requires_confirmation' => true,
                'type'                  => 'write',
            ];
        }

        return $actions;
    }

    /**
     * @return string[]
     */
    public static function doorThreeSlugs(): array
    {
        return array_values(array_map(
            static fn (array $entry): string => $entry['slug'],
            self::entries()
        ));
    }
}
