<?php

declare(strict_types=1);

namespace Apexl\Io\Display\Hooks;

use Apexl\Io\Display\Collections\PageRegistry;
use Apexl\Io\Display\Pages\BlankPage;
use Apexl\Io\Display\Pages\GenericPageLeftMenu;
use Apexl\Io\Display\Pages\NoUiIframeFlow;
use Apexl\Io\Display\Services\Render;
use Apexl\Io\Interfaces\AbstractHook;

final readonly class SetDefaultRenderDisplaysHook implements AbstractHook
{
    public function hooks(): array
    {
        return [Render::HOOK__COLLECT_PAGES];
    }

    public function __invoke(
        PageRegistry $pages,
    ): void {
        //only apply a default if it hasn't already been done.
        if (!$pages->has(Render::DEFAULT_PAGE_KEY)) {
            $pages->set(Render::DEFAULT_PAGE_KEY, GenericPageLeftMenu::class);
        }
        if (!$pages->has('noUI')) {
            $pages->set('noUI', BlankPage::class);
        }
        if (!$pages->has('noUIiframe')) {
            $pages->set('noUIiframe', NoUiIframeFlow::class);
        }
    }

}
