<?php
/**
 * WooCommerce shop-surface ability schemas.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks\Schemas;

use LolaCoreForBricks\AbilitiesProvider;

/**
 * Door 1 schemas for B14 shop templates and product-element shortcuts.
 */
class WooSurfaceSchemas
{
    /**
     * @return array<string, array<string, mixed>>
     */
    public static function define(): array
    {
        $dryRun = [
            'dry_run' => [
                'type'        => 'boolean',
                'description' => 'Preview the write without saving changes.',
            ],
        ];

        return [
            'getWooBricksSurface' => [
                'description' => 'Show which Bricks shop templates exist, which are missing, and which WooCommerce elements the site already uses.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['woo bricks surface', 'shop templates', 'plantillas de tienda'],
                    'stem'  => ['woocommerce', 'shop', 'tienda'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => (object) [],
                ],
            ],
            'createWooTemplate' => [
                'description' => 'Create a Bricks shop template for product, archive, cart, checkout, or account, with its conditions already set. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['create woo template', 'product template', 'plantilla de producto'],
                    'stem'  => ['woocommerce', 'template', 'cart', 'checkout'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'kind'       => ['type' => 'string'],
                        'type'       => ['type' => 'string'],
                        'title'      => ['type' => 'string'],
                        'status'     => ['type' => 'string'],
                        'conditions' => ['type' => 'array', 'items' => ['type' => 'object']],
                    ]),
                    'required'   => ['kind'],
                ],
            ],
            'addProductElement' => [
                'description' => 'Insert a WooCommerce product element such as title, price, or gallery. Call with dry_run first.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['add product element', 'product price', 'add to cart'],
                    'stem'  => ['product', 'gallery', 'woocommerce'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => array_merge($dryRun, [
                        'post_id'      => ['type' => 'integer'],
                        'area'         => ['type' => 'string'],
                        'parent_id'    => ['type' => 'string'],
                        'position'     => ['type' => 'string'],
                        'reference_id' => ['type' => 'string'],
                        'name'         => ['type' => 'string'],
                        'element'      => ['type' => 'string'],
                        'settings'     => ['type' => 'object'],
                    ]),
                    'required'   => ['post_id', 'name'],
                ],
            ],
            'getProductElementsCatalog' => [
                'description' => 'List Bricks WooCommerce elements grouped by shop function so you can pick one without dumping every name.',
                'category'    => AbilitiesProvider::CATEGORY,
                'keywords'    => [
                    'exact' => ['product elements catalog', 'woo elements', 'catalogo de elementos'],
                    'stem'  => ['catalog', 'woocommerce', 'elements'],
                ],
                'parameters'  => [
                    'type'       => 'object',
                    'properties' => (object) [],
                ],
            ],
        ];
    }
}
