"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/********************************************************************************
 * Copyright (c) 2022-2023 STMicroelectronics and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/
require("reflect-metadata");
const layout_elk_1 = require("@eclipse-glsp/layout-elk");
const node_1 = require("@eclipse-glsp/server/node");
const inversify_1 = require("inversify");
const workflow_layout_configurator_1 = require("../common/layout/workflow-layout-configurator");
const workflow_diagram_module_1 = require("../common/workflow-diagram-module");
const workflow_cli_parser_1 = require("./workflow-cli-parser");
async function launch(argv) {
    const options = (0, workflow_cli_parser_1.createWorkflowCliParser)().parse(argv);
    const appContainer = new inversify_1.Container();
    appContainer.load((0, node_1.createAppModule)(options));
    const elkLayoutModule = (0, layout_elk_1.configureELKLayoutModule)({ algorithms: ['layered'], layoutConfigurator: workflow_layout_configurator_1.WorkflowLayoutConfigurator });
    const serverModule = new workflow_diagram_module_1.WorkflowServerModule().configureDiagramModule(new workflow_diagram_module_1.WorkflowDiagramModule(() => node_1.GModelStorage), elkLayoutModule);
    if (options.webSocket) {
        const launcher = appContainer.resolve(node_1.WebSocketServerLauncher);
        launcher.configure(serverModule);
        launcher.start({ port: options.port, host: options.host, path: 'workflow' });
    }
    else {
        const launcher = appContainer.resolve(node_1.SocketServerLauncher);
        launcher.configure(serverModule);
        launcher.start({ port: options.port, host: options.host });
    }
}
launch(process.argv).catch(error => console.error('Error in workflow server launcher:', error));
//# sourceMappingURL=app.js.map