<?php

namespace Plainwork\Ui;

use Plainwork\Core\App;
use Plainwork\Http\Router;
use Plainwork\Ui\Ui;

class Boot
{
    public function __construct(App $app)
    {
        $app->onBoot(Router::class, function ($router) {
            $router
                ->middleware('*', Middleware\UiMiddleware::class, 85)
                ->middleware('*', Middleware\ExceptionMiddleware::class, 14)
                // ->middleware('', Middleware\FlashMessageMiddleware::class, 90)
                ;
        });

        $app->onBoot(Ui::class, function ($ui) {
            $ui
                ->renderer(Component\LabelRow::class, Renderer\LabelRowRenderer::class)
                ->renderer(Component\Form\Form::class, Renderer\Form\FormRenderer::class)
                ->renderer(Component\Form\Button::class, Renderer\Form\ButtonRenderer::class)
                ->renderer(Component\Form\AbstractInput::class, Renderer\Form\InputRenderer::class)
                ->renderer(Component\Form\TextInput::class, Renderer\Form\TextInputRenderer::class)
                ->renderer(Component\Form\NumberInput::class, Renderer\Form\NumberInputRenderer::class)
                ->renderer(Component\Form\FileInput::class, Renderer\Form\FileInputRenderer::class)
                ->renderer(Component\Form\TextareaInput::class, Renderer\Form\TextareaInputRenderer::class)
                ->renderer(Component\Form\PasswordInput::class, Renderer\Form\PasswordInputRenderer::class)
                ->renderer(Component\Form\SelectInput::class, Renderer\Form\SelectInputRenderer::class)
                ->renderer(Component\Form\ColorInput::class, Renderer\Form\ColorInputRenderer::class)
                ->renderer(Component\Form\ColorPickerInput::class, Renderer\Form\ColorPickerInputRenderer::class)
                ->renderer(Component\Form\CheckboxInput::class, Renderer\Form\CheckboxInputRenderer::class)
                ->renderer(Component\Form\CheckboxSetInput::class, Renderer\Form\CheckboxSetInputRenderer::class)
                ->renderer(Component\Form\RadioInput::class, Renderer\Form\RadioInputRenderer::class)
                ->renderer(Component\Form\RadioSetInput::class, Renderer\Form\RadioSetInputRenderer::class)
                ->renderer(Component\Form\DateInput::class, Renderer\Form\NativeDateInputRenderer::class)
                ->renderer(Component\Form\DatePickerInput::class, Renderer\Form\DatePickerJsInputRenderer::class)
                ->renderer(Component\Form\DatePeriodInput::class, Renderer\Form\DatePeriodInputRenderer::class)
                ->renderer(Component\Form\TimeInput::class, Renderer\Form\TimeInputRenderer::class)
                ->renderer(Component\Form\DurationInput::class, Renderer\Form\DurationInputRenderer::class)
                ->renderer(Component\Form\TogglableInput::class, Renderer\Form\TogglableInputRenderer::class)
                ->renderer(Component\Form\FormErrors::class, Renderer\Form\FormErrorsRenderer::class)

                ->renderer(Component\Collection::class, Renderer\CollectionRenderer::class)

                ->renderer(Component\Html::class, Renderer\HtmlRenderer::class)
                ->renderer(Component\HtmlTemplate::class, Renderer\HtmlTemplateRenderer::class)
                ->renderer(Component\AbstractTag::class, Renderer\HtmlElementRenderer::class)
                ->renderer(Component\Main::class, Renderer\MainRenderer::class)
                // ->renderer(Component\Main::class, Renderer\MainRendererLayoutDecorator::class)
                ->renderer(Component\Main::class, Renderer\PrintViewMainRendererDecorator::class)
                ->renderer(Component\Card::class, Renderer\CardRenderer::class)
                ->renderer(Component\DetailsCard::class, Renderer\DetailsCardRenderer::class)
                ->renderer(Component\DropdownButton::class, Renderer\DropdownButtonRenderer::class)
                ->renderer(Component\Href::class, Renderer\HrefRenderer::class)
                ->renderer(Component\Link::class, Renderer\LinkRenderer::class)
                ->renderer(Component\Details::class, Renderer\DetailsRenderer::class)
                ->renderer(Component\Breadcrumbs::class, Renderer\BreadcrumbsRenderer::class)
                ->renderer(Component\Table::class, Renderer\TableRenderer::class)
                ->renderer(Component\StartEnd::class, Renderer\StartEndRenderer::class)
                ->renderer(Component\Dl::class, Renderer\DlRenderer::class)
                ->renderer(Component\FlashMessage::class, Renderer\FlashMessageRenderer::class)
                ->renderer(Component\Pager::class, Renderer\PagerRenderer::class)
                ->renderer(Component\Menu::class, Renderer\MenuRenderer::class)
                ->renderer(Component\InlineList::class, Renderer\InlineListRenderer::class)
                ->renderer(Component\BlockList::class, Renderer\BlockListRenderer::class)
                ->renderer(Component\TabMenu::class, Renderer\TabMenuRenderer::class)
                ->renderer(Component\Grid::class, Renderer\GridRenderer::class)
                ->renderer(Component\Partial::class, Renderer\PartialRenderer::class)
                ->renderer(Component\TabbedMenu::class, Renderer\TabbedMenuRenderer::class)
                ->renderer(Component\Ul::class, Renderer\UlRenderer::class)
                ->renderer(Component\Ol::class, Renderer\OlRenderer::class)
                ;
        });
    }
}
