<?php

namespace App\PageBuilder\Components\Marketing;

use App\PageBuilder\PageComponent;

class LogoCloudComponent extends PageComponent
{
    public function key(): string { return 'logo_cloud'; }
    public function category(): string { return 'marketing'; }
    public function label(): string { return 'Logo Cloud'; }
    public function icon(): string { return 'fas fa-images'; }

    public function schema(): array
    {
        return [
            'title' => ['type' => 'text'],
            'items' => [
                'type' => 'repeater',
                'item_schema' => [
                    'logo' => ['type' => 'image', 'required' => true],
                    'alt' => ['type' => 'text'],
                    'link' => ['type' => 'link'],
                ],
                'min' => 1, 'max' => 12,
            ],
            'options' => [
                'columns' => ['type' => 'select', 'options' => [3,4,5,6], 'default' => 5],
                'color' => ['type' => 'color_token', 'default' => 'light'],
                'padding' => ['type' => 'padding_token', 'default' => 'md'],
                'grayscale' => ['type' => 'boolean', 'label' => 'Gri tonlamada göster', 'default' => true],
                'hover_color' => ['type' => 'boolean', 'label' => 'Üzerine gelince renklendir', 'default' => true],
                'logo_height' => ['type' => 'select', 'label' => 'Logo yüksekliği', 'options' => ['32px', '48px', '64px', '80px'], 'default' => '48px'],
            ],
        ];
    }

    public function defaults(): array
    {
        return [
            'title' => 'İş Ortaklarımız',
            'items' => [],
            'options' => [
                'columns' => 5, 'color' => 'light', 'padding' => 'md',
                'grayscale' => true, 'hover_color' => true, 'logo_height' => '48px',
            ],
        ];
    }

    public function render(array $data, array $options): string
    {
        return view('page-builder.components.logo_cloud', compact('data', 'options'))->render();
    }
}
