/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { generateGAVCoordinates } from '@finos/legend-storage';
import { WorkspaceType } from '@finos/legend-server-sdlc';
import { guaranteeNonNullable } from '@finos/legend-shared';
import { generatePath } from '@finos/legend-application/browser';
export var LEGEND_STUDIO_QUERY_PARAMS;
(function (LEGEND_STUDIO_QUERY_PARAMS) {
    LEGEND_STUDIO_QUERY_PARAMS["EDITOR_CONFIG"] = "editorConfig";
})(LEGEND_STUDIO_QUERY_PARAMS || (LEGEND_STUDIO_QUERY_PARAMS = {}));
export var LEGEND_STUDIO_ROUTE_PATTERN_TOKEN;
(function (LEGEND_STUDIO_ROUTE_PATTERN_TOKEN) {
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["SHOWCASE_PATH"] = "showcasePath";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["PROJECT_ID"] = "projectId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["PATCH_RELEASE_VERSION_ID"] = "patchReleaseVersionId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["WORKSPACE_ID"] = "workspaceId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["GROUP_WORKSPACE_ID"] = "groupWorkspaceId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["REVISION_ID"] = "revisionId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["VERSION_ID"] = "versionId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["REVIEW_ID"] = "reviewId";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["ENTITY_PATH"] = "entityPath";
    LEGEND_STUDIO_ROUTE_PATTERN_TOKEN["GAV"] = "gav";
})(LEGEND_STUDIO_ROUTE_PATTERN_TOKEN || (LEGEND_STUDIO_ROUTE_PATTERN_TOKEN = {}));
export const LEGEND_STUDIO_ROUTE_PATTERN = Object.freeze({
    VIEW: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}`,
    VIEW_BY_ENTITY: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    VIEW_BY_REVISION: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/revision/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.REVISION_ID}`,
    VIEW_BY_VERSION: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/version/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.VERSION_ID}`,
    VIEW_BY_REVISION_ENTITY: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/revision/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.REVISION_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    VIEW_BY_VERSION_ENTITY: `/view/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/version/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.VERSION_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    REVIEW: `/review/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.REVIEW_ID}`,
    PATCH_REVIEW: `/review/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.REVIEW_ID}`,
    EDIT_WORKSPACE: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}/`,
    EDIT_PATCH_WORKSPACE: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}/`,
    EDIT_WORKSPACE_ENTITY: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    EDIT_PATCH_WORKSPACE_ENTITY: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    EDIT_GROUP_WORKSPACE: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/`,
    EDIT_PATCH_GROUP_WORKSPACE: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/`,
    EDIT_GROUP_WORKSPACE_ENTITY: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    EDIT_PATCH_GROUP_WORKSPACE_ENTITY: `/edit/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    SETUP_WORKSPACE: `/setup/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}?/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}?`,
    SETUP_PATCH_WORKSPACE: `/setup/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}?/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}?`,
    SETUP_GROUP_WORKSPACE: `/setup/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/`,
    SETUP_PATCH_GROUP_WORKSPACE: `/setup/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/patches/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PATCH_RELEASE_VERSION_ID}?/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/`,
    TEXT_GROUP_WORKSPACE: `/text/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/groupWorkspace/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GROUP_WORKSPACE_ID}/`,
    TEXT_WORKSPACE: `/text/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.PROJECT_ID}/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.WORKSPACE_ID}/`,
});
export const LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN = Object.freeze({
    VIEW_BY_GAV: `/view/archive/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GAV}`,
    VIEW_BY_GAV_ENTITY: `/view/archive/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GAV}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}`,
    PREVIEW_BY_GAV_ENTITY: `/view/archive/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.GAV}/entity/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.ENTITY_PATH}/preview`,
    SHOWCASE: `/showcase/:${LEGEND_STUDIO_ROUTE_PATTERN_TOKEN.SHOWCASE_PATH}`,
    PCT_REPORT: '/pct',
});
const generateGroupWorkspaceSetupRoute = (projectId, patchReleaseVersionId, groupWorkspaceId) => patchReleaseVersionId
    ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.SETUP_PATCH_GROUP_WORKSPACE, {
        projectId: projectId,
        patchReleaseVersionId: patchReleaseVersionId,
        groupWorkspaceId,
    })
    : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.SETUP_GROUP_WORKSPACE, {
        projectId: projectId,
        groupWorkspaceId,
    });
const generateWorkspaceSetupRoute = (projectId, patchReleaseVersionId, workspaceId) => patchReleaseVersionId
    ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.SETUP_PATCH_WORKSPACE, {
        projectId: projectId,
        patchReleaseVersionId: patchReleaseVersionId,
        workspaceId: workspaceId,
    })
    : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.SETUP_WORKSPACE, {
        projectId: projectId,
        workspaceId: workspaceId,
    });
export const generateSetupRoute = (projectId, patchReleaseVersionId, workspaceId, workspaceType) => workspaceType === WorkspaceType.GROUP
    ? generateGroupWorkspaceSetupRoute(projectId, patchReleaseVersionId, guaranteeNonNullable(workspaceId))
    : generateWorkspaceSetupRoute(projectId, patchReleaseVersionId, workspaceId);
const generateGroupWorkspaceEditorRoute = (projectId, patchReleaseVersionId, groupWorkspaceId, entityPath) => !entityPath
    ? patchReleaseVersionId
        ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_PATCH_GROUP_WORKSPACE, {
            projectId,
            patchReleaseVersionId,
            groupWorkspaceId,
        })
        : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_GROUP_WORKSPACE, {
            projectId,
            groupWorkspaceId,
        })
    : patchReleaseVersionId
        ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_PATCH_GROUP_WORKSPACE_ENTITY, {
            projectId,
            patchReleaseVersionId,
            groupWorkspaceId,
            entityPath,
        })
        : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_GROUP_WORKSPACE_ENTITY, {
            projectId,
            groupWorkspaceId,
            entityPath,
        });
const generateWorkspaceEditorRoute = (projectId, patchReleaseVersionId, workspaceId, entityPath) => !entityPath
    ? patchReleaseVersionId
        ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_PATCH_WORKSPACE, {
            projectId,
            patchReleaseVersionId,
            workspaceId,
        })
        : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_WORKSPACE, {
            projectId,
            workspaceId,
        })
    : patchReleaseVersionId
        ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_PATCH_WORKSPACE_ENTITY, {
            projectId,
            patchReleaseVersionId,
            workspaceId,
            entityPath,
        })
        : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.EDIT_WORKSPACE_ENTITY, {
            projectId,
            workspaceId,
            entityPath,
        });
export const generateEditorRoute = (projectId, patchReleaseVersionId, workspaceId, workspaceType, entityPath) => workspaceType === WorkspaceType.GROUP
    ? generateGroupWorkspaceEditorRoute(projectId, patchReleaseVersionId, workspaceId, entityPath)
    : generateWorkspaceEditorRoute(projectId, patchReleaseVersionId, workspaceId, entityPath);
export const generateReviewRoute = (projectId, reviewId) => generatePath(LEGEND_STUDIO_ROUTE_PATTERN.REVIEW, {
    projectId,
    reviewId,
});
export const generateViewProjectRoute = (projectId) => generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW, {
    projectId,
});
export const generateViewEntityRoute = (projectId, entityPath) => generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_ENTITY, {
    projectId,
    entityPath,
});
export const generateViewVersionRoute = (projectId, versionId, entityPath) => !entityPath
    ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_VERSION, {
        projectId,
        versionId,
    })
    : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_VERSION_ENTITY, {
        projectId,
        versionId,
        entityPath,
    });
export const generateViewRevisionRoute = (projectId, revisionId, entityPath) => !entityPath
    ? generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_REVISION, {
        projectId,
        revisionId,
    })
    : generatePath(LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_REVISION_ENTITY, {
        projectId,
        revisionId,
        entityPath,
    });
export const generateViewProjectByGAVRoute = (groupId, artifactId, versionId, entityPath) => !entityPath
    ? generatePath(LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN.VIEW_BY_GAV, {
        gav: generateGAVCoordinates(groupId, artifactId, versionId),
    })
    : generatePath(LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN.VIEW_BY_GAV_ENTITY, {
        gav: generateGAVCoordinates(groupId, artifactId, versionId),
        entityPath,
    });
export const generateElementPreviewRoute = (groupId, artifactId, versionId, entityPath) => generatePath(LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN.PREVIEW_BY_GAV_ENTITY, {
    gav: generateGAVCoordinates(groupId, artifactId, versionId),
    entityPath,
});
/**
 * @external_application_navigation This depends on Legend Query routing and is hardcoded so it's potentially brittle
 */
export const EXTERNAL_APPLICATION_NAVIGATION__generateServiceQueryCreatorUrl = (queryApplicationUrl, groupId, artifactId, versionId, servicePath) => `${queryApplicationUrl}/create-from-service/${generateGAVCoordinates(groupId, artifactId, versionId)}/${servicePath}`;
export const generateShowcasePath = (showcasePath) => generatePath(LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN.SHOWCASE, {
    showcasePath: encodeURIComponent(showcasePath),
});
export const EXTERNAL_APPLICATION_NAVIGATION__generateUrlWithEditorConfig = (base, editorConfig) => `${base}?${LEGEND_STUDIO_QUERY_PARAMS.EDITOR_CONFIG}=${encodeURIComponent(editorConfig)}`;
//# sourceMappingURL=LegendStudioNavigation.js.map