<?php

namespace Acms\Modules\Get\V2;

use Acms\Modules\Get\V2\Base;
use Acms\Services\Facades\Application;

class Js extends Base
{
    /**
     * @inheritDoc
     */
    public function get(): array
    {
        Application::setIsAcmsJsLoaded(true);
        $jsModulesBuilder = Application::make('view.js-modules');
        assert($jsModulesBuilder instanceof \Acms\Services\View\JsModulesBuilder);
        $jsModules = $jsModulesBuilder->getJsModules();
        $query = http_build_query($jsModules, '&');
        if (!empty($query)) {
            return [
                'arguments' => '?' . $query,
            ];
        }
        return [
            'arguments' => null,
        ];
    }
}
