'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var express = require('express');
var localsHelper = require('../../utils/localsHelper.js');
var routes = require('./request-missing-report/routes.js');
var routes$1 = require('./download-report/routes.js');
var routes$2 = require('./my-reports/routes.js');
var routes$3 = require('./view-report/routes.js');
var routes$4 = require('./request-report/routes.js');
var routes$5 = require('./product-collection/routes.js');
var routes$6 = require('./report-catalogue/routes.js');
var routes$7 = require('./my-reports-catalogue/routes.js');
var urlHelper = require('../../utils/urlHelper.js');

function DprRoutes({ layoutPath, services }) {
    const router = express.Router({ mergeParams: true });
    router.use('/', routes.RequestMissingReportRoutes({ path: '/request-missing-report', layoutPath, services }));
    router.use('/', routes$1.DownloadReportRoutes({ path: '/download-report', layoutPath, services }));
    router.use('/', routes$2.MyReportsRoutes({ path: '/my-reports', layoutPath, services }));
    router.use('/', routes$3.ViewReportRoutes({ path: '/view-report', layoutPath, services }));
    router.use('/', routes$4.RequestReportRoutes({ path: '/request-report', layoutPath, services }));
    router.use('/', routes$5.ProductCollectionRoutes({ path: '/product-collection', layoutPath, services }));
    router.use('/', routes$6.ReportCatalogueRoutes({ path: '/report-catalogue', layoutPath, services }));
    router.use('/', routes$7.MyReportsCatalogueRoutes({ layoutPath, services }));
    return router;
}
function Redirects() {
    const router = express.Router({ mergeParams: true });
    // Request route redirect
    router.get(`/async/:type/:reportId/:id/request`, (req, res) => {
        const { type, reportId, id } = req.params;
        const { nestedBaseUrl } = localsHelper.getRouteLocals(res);
        const path = urlHelper.setNestedPath(`/dpr/request-report/${type}/${reportId}/${id}/filters`, nestedBaseUrl);
        res.redirect(path);
    });
    // Status route redirect
    router.get(`/async/:type/:reportId/:id/request/:executionId`, (req, res) => {
        const { type, reportId, id, executionId } = req.params;
        const { nestedBaseUrl } = localsHelper.getRouteLocals(res);
        const path = urlHelper.setNestedPath(`/dpr/request-report/${type}/${reportId}/${id}/${executionId}/status`, nestedBaseUrl);
        res.redirect(path);
    });
    return router;
}
function Routes({ layoutPath, services }) {
    const router = express.Router({ mergeParams: true });
    router.use('/dpr', DprRoutes({ layoutPath, services }));
    router.use('/', Redirects());
    return router;
}

exports.DprRoutes = DprRoutes;
exports.Redirects = Redirects;
exports.Routes = Routes;
exports.default = Routes;
//# sourceMappingURL=routes.js.map
