"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkflowNavigationTargetResolver = void 0;
const server_1 = require("@eclipse-glsp/server");
const inversify_1 = require("inversify");
const graph_extension_1 = require("../graph-extension");
let WorkflowNavigationTargetResolver = class WorkflowNavigationTargetResolver extends server_1.NavigationTargetResolver {
    async resolve(navigationTarget) {
        if (navigationTarget.args && navigationTarget.args['name']) {
            const name = navigationTarget.args['name'];
            const taskNodes = this.modelState.index.getAllByClass(graph_extension_1.TaskNode);
            const element = taskNodes.find(node => name === node.name);
            if (element) {
                return new server_1.NavigationTargetResolution([element.id]);
            }
            return new server_1.NavigationTargetResolution([], this.createArgsWithWarning(`Couldn't find element with name ${name}`));
        }
        return server_1.NavigationTargetResolution.EMPTY;
    }
};
__decorate([
    (0, inversify_1.inject)(server_1.ModelState),
    __metadata("design:type", Object)
], WorkflowNavigationTargetResolver.prototype, "modelState", void 0);
WorkflowNavigationTargetResolver = __decorate([
    (0, inversify_1.injectable)()
], WorkflowNavigationTargetResolver);
exports.WorkflowNavigationTargetResolver = WorkflowNavigationTargetResolver;
//# sourceMappingURL=workflow-navigation-target-resolver.js.map