<?php
/**
 * ITSWEBER CMS – Intro / Textblock Section
 *
 * Simple text section with title, subtitle, text and optional CTA.
 *
 * @author    Benny Weber (ITSWEBER)
 * @copyright © ITSWEBER – www.itsweber.de
 * @contact   kontakt@itsweber.de
 */

namespace App\Sections\Core;

use App\Sections\AbstractSection;
use App\Core\Request;

class IntroSection extends AbstractSection
{
    public static function typeKey(): string    { return 'intro'; }
    public static function label(): string      { return 'Intro / Textblock'; }
    public static function category(): string   { return 'content'; }
    public static function description(): string { return 'Einfacher Textbereich mit Titel, Untertitel und CTA'; }

    public static function iconSvg(): string
    {
        return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">'
             . '<line x1="4" y1="6" x2="20" y2="6"/>'
             . '<line x1="4" y1="10" x2="18" y2="10"/>'
             . '<line x1="4" y1="14" x2="16" y2="14"/>'
             . '<line x1="4" y1="18" x2="12" y2="18"/>'
             . '</svg>';
    }

    public function buildData(Request $request): array
    {
        $data = [
            'title'              => trim($request->input('title', '')),
            'subtitle'           => trim($request->input('subtitle', '')),
            'text'               => trim($request->input('text', '')),
            'cta_text'           => trim($request->input('cta_text', '')),
            'cta_url'            => trim($request->input('cta_url', '')),
            'color_scheme'       => self::sanitizeToken(trim($request->input('color_scheme', '')), self::allowedColorScheme()),
            'text_align'         => self::sanitizeToken(trim($request->input('text_align', '')),   self::allowedSectionAlign()),
            'max_width'          => self::sanitizeToken(trim($request->input('max_width', '')),     self::allowedMaxWidth()),
            'section_text_color' => self::sanitizeToken(trim($request->input('section_text_color', '')), self::allowedSectionTextColor()),
        ];

        return $this->mergeThemeExtras($data, $request);
    }

    public function defaultData(): array
    {
        return [
            'title' => '', 'subtitle' => '', 'text' => '',
            'cta_text' => '', 'cta_url' => '',
            'color_scheme' => '', 'text_align' => '', 'max_width' => '',
            'section_text_color' => '',
        ];
    }
}
