<?php
/**
 * Element style ability schemas.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks\Schemas;

use LolaCoreForBricks\AbilitiesProvider;

/**
 * Door 1 schemas for B9 element styling.
 */
class ElementStyleSchemas
{
    /**
     * @return array<string, array<string, mixed>>
     */
    public static function define(): array
    {
        $dryRun = [
            'dry_run' => [
                'type'        => 'boolean',
                'description' => 'Preview the write without saving changes.',
            ],
        ];

        $page = [
            'post_id' => [
                'type'        => 'integer',
                'description' => 'WordPress post or page ID.',
            ],
            'area'    => [
                'type'        => 'string',
                'description' => 'Page area: content, header, or footer.',
            ],
        ];

        return [
            'styleElement' => [
                'description' => 'Apply universal Bricks style controls to one element. Optional breakpoint and state compose the setting key. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['style element', 'padding', 'estilar elemento'],
                    'stem'  => ['style', 'padding', 'estilo'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, $page, [
                        'element_id' => ['type' => 'string'],
                        'styles'     => ['type' => 'object'],
                        'breakpoint' => [
                            'type'        => 'string',
                            'description' => 'Optional breakpoint such as tablet_portrait.',
                        ],
                        'state'      => [
                            'type'        => 'string',
                            'description' => 'Optional state such as hover or active.',
                        ],
                    ]),
                    'required'   => ['post_id', 'element_id', 'styles'],
                ],
            ],
            'applyClasses' => [
                'description' => 'Apply one or more Bricks global classes to a set of elements in one confirmation. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['apply class', 'aplicar clase', 'add global class'],
                    'stem'  => ['apply', 'class', 'clase'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, $page, [
                        'element_ids' => ['type' => 'array', 'items' => ['type' => 'string']],
                        'classes'     => ['type' => 'array', 'items' => ['type' => 'string']],
                    ]),
                    'required'   => ['post_id', 'element_ids', 'classes'],
                ],
            ],
            'removeClasses' => [
                'description' => 'Remove one or more Bricks global classes from a set of elements. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['remove class', 'quitar clase'],
                    'stem'  => ['remove', 'class', 'quitar'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, $page, [
                        'element_ids' => ['type' => 'array', 'items' => ['type' => 'string']],
                        'classes'     => ['type' => 'array', 'items' => ['type' => 'string']],
                    ]),
                    'required'   => ['post_id', 'element_ids', 'classes'],
                ],
            ],
            'updateElementSettings' => [
                'description' => 'Update element-specific Bricks settings. Unknown keys abort and return the closest valid keys. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['update element settings', 'ajustar elemento'],
                    'stem'  => ['settings', 'ajustes', 'element'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, $page, [
                        'element_id' => ['type' => 'string'],
                        'settings'   => ['type' => 'object'],
                    ]),
                    'required'   => ['post_id', 'element_id', 'settings'],
                ],
            ],
        ];
    }
}
