<?php

namespace Plainwork\Ui\Renderer;

use Plainwork\Core\App;
use Plainwork\Core\Translate;
use Plainwork\Http\Request;
use Plainwork\Ui\Html;
use Plainwork\Ui\Component\Main;
use Plainwork\Ui\Component\HtmlElement;
use Plainwork\Ui\Ui;

final class MainRenderer
{
    public $self;
    public $app = App::class;
    public $translate = Translate::class;
    public $ui = Ui::class;

    public function __invoke(Main $el, Request $request)
    {
        $ret = $el->content;
        // $ret = $this->self->render($el, $request);

        $ret = (new HtmlElement('div', $ret))
            ->withAttr('id', 'pw2')
            ;
        $ret = $this->ui->render($ret, $request);

    // translate
        $ret = $this->translate->translate($ret);

        return $ret;
    }
}
