<?php

namespace Tests\Support;

use App\Enums\EventStatus;
use App\Models\Category;
use App\Models\Venue;
use Carbon\Carbon;

/**
 * Cuerpo POST de ejemplo para {@see \App\Http\Controllers\EventController::store} / update,
 * con varias entradas, oferta, cupo compartido, ilimitado y campo personalizado tipo select.
 */
final class FullTestEventStorePayload
{
    /**
     * @return array<string, mixed>
     */
    public static function forStore(Venue $venue, Category $category, ?string $slugSuffix = null): array
    {
        $suffix = $slugSuffix ?? str_replace('.', '', uniqid('t', true));
        $start = Carbon::now()->addMonths(2)->startOfHour();
        $end = $start->copy()->addHours(6);
        $saleEnd = $start->copy()->subDay();

        return [
            'title' => 'PRUEBA REGITICKET · Evento completo',
            'slug' => 'regiticket-regression-'.$suffix,
            'description' => '<p>Descripción HTML de <strong>prueba</strong>.</p>',
            'short_description' => 'Resumen de una línea para tarjetas y SEO.',
            'venue_id' => $venue->id,
            'category_id' => $category->id,
            'start_date' => $start->format('Y-m-d\TH:i'),
            'end_date' => $end->format('Y-m-d\TH:i'),
            'timezone' => 'America/Puerto_Rico',
            'status' => EventStatus::Published->value,
            'hide_from_listings' => '1',
            'sticky_in_calendar' => '1',
            'is_featured' => '1',
            'tickets' => [
                [
                    'name' => 'General early bird',
                    'description' => 'Cupo propio, precio de oferta y venta acotada.',
                    'price' => '45.00',
                    'currency' => 'USD',
                    'has_sale_price' => '1',
                    'sale_price' => '35.00',
                    'sku' => 'GEN-EB-TEST',
                    'capacity_strategy' => 'per_ticket',
                    'capacity' => 500,
                    'shared_pool_size' => '',
                    'sale_start' => $start->copy()->subWeeks(3)->format('Y-m-d\TH:i'),
                    'sale_end' => $saleEnd->format('Y-m-d\TH:i'),
                    'iac' => 'required',
                    'ticket_kind' => 'standard',
                    'is_active' => '1',
                    'custom_fields' => [
                        [
                            'label' => 'Talla de camiseta',
                            'type' => 'select',
                            'required' => '1',
                            'options_text' => "S\nM\nL\nXL",
                            'sort_order' => 0,
                        ],
                        [
                            'label' => 'Notas alergias',
                            'type' => 'textarea',
                            'required' => '',
                            'options_text' => '',
                            'sort_order' => 1,
                        ],
                    ],
                ],
                [
                    'name' => 'VIP pool compartido',
                    'description' => 'Segundo tipo con cupo compartido.',
                    'price' => '120.00',
                    'currency' => 'USD',
                    'has_sale_price' => '',
                    'sale_price' => '',
                    'sku' => 'VIP-POOL-TEST',
                    'capacity_strategy' => 'shared_pool',
                    'capacity' => 200,
                    'shared_pool_size' => 800,
                    'sale_start' => '',
                    'sale_end' => '',
                    'iac' => 'optional',
                    'ticket_kind' => 'standard',
                    'is_active' => '1',
                    'custom_fields' => [],
                ],
                [
                    'name' => 'Acompañante (ilimitado)',
                    'description' => 'Sin tope de cupo en este tipo.',
                    'price' => '0.00',
                    'currency' => 'USD',
                    'has_sale_price' => '',
                    'sale_price' => '',
                    'sku' => '',
                    'capacity_strategy' => 'unlimited',
                    'capacity' => 0,
                    'shared_pool_size' => '',
                    'sale_start' => '',
                    'sale_end' => '',
                    'iac' => 'none',
                    'ticket_kind' => 'standard',
                    'is_active' => '1',
                    'custom_fields' => [],
                ],
            ],
        ];
    }
}
