<?php

namespace App\Enums;

use App\Filament\Resources\Pages\Schemas\LayoutForms;
use App\ViewModels\Pages as ViewModels;

enum PageLayout: string
{
    case Default = 'default';
    case FrontPage = 'front_page';

    public function label(): string
    {
        return match($this) {
            self::Default => 'Default',
            self::FrontPage => 'Front Page',
        };
    }

    public function route(): string
    {
        return match($this) {
            self::Default => 'Default',
            self::FrontPage => 'Front Page',
        };
    }

    public function handlerClass(): string
    {
        return match($this) {
            self::Default => '',
            self::FrontPage => '',
        };
    }

    public function formClass(): string
    {
        return match($this) {
            self::Default => 'default',
            self::FrontPage => 'front_page',
        };
    }

    public function formPath(): string
    {
        return match($this) {
            self::Default => 'layouts/default.php',
            self::FrontPage => 'layouts/front_page.php',
        };
    }

    public function viewPath(): string
    {
        return match($this) {
            self::Default => 'pages/default.php',
            self::FrontPage => 'home.php',
        };
    }

    public function description(): string
    {
        return match($this) {
            self::Default => 'Basic page layout with standard content structure',
            self::FrontPage => 'Homepage layout with hero section and featured content',
        };
    }

    public static function selectOptions(): array
    {
        $options = [];
        foreach (self::cases() as $case) {
            $options[$case->value] = $case->label();
        }
        return $options;
    }
    
    public static function isValid(string $layout): bool
    {
        foreach (self::cases() as $case) {
            if ($case->value === $layout) {
                return true;
            }
        }
        return false;
    }
}