<?php

declare(strict_types=1);

namespace App\Filament\Resources\Pages;

use App\Filament\Contracts\DberpFilamentCreateSaveFirstGuidance;
use App\Filament\Support\DberpFilamentSubheading;
use App\Filament\Support\DberpFormSaveSubheading;
use Filament\Resources\Pages\CreateRecord as FilamentCreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateRecord extends FilamentCreateRecord
{
    public function getSubheading(): string|Htmlable|null
    {
        $resource = static::getResource();

        $guidanceKey = null;
        if (is_a($resource, DberpFilamentCreateSaveFirstGuidance::class, true)) {
            $guidanceKey = $resource::createSaveFirstGuidanceTranslationKey();
        }

        $parent = parent::getSubheading();
        $withGuidance = DberpFilamentSubheading::prependBusinessHint($parent, $guidanceKey);

        return DberpFormSaveSubheading::append($withGuidance);
    }
}
