"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortTasks = sortTasks;
exports.addTaskWarnings = addTaskWarnings;
const catalogue_1 = require("./catalogue");
function sortTasks(tasks) {
    const order = {
        'asset-spec': 0,
        asset: 1,
        app: 2,
        'asset-pack': 3,
        'owned-asset': 4,
    };
    return [...tasks].sort((a, b) => {
        if (order[a.kind] !== order[b.kind]) {
            return order[a.kind] - order[b.kind];
        }
        if (a.cataloguePath !== b.cataloguePath) {
            return a.cataloguePath.localeCompare(b.cataloguePath);
        }
        if (a.name !== b.name) {
            return a.name.localeCompare(b.name);
        }
        return 0;
    });
}
function addTaskWarnings(warnings, tasks) {
    for (const task of tasks) {
        if ('missingMetadata' in task && Array.isArray(task.missingMetadata)) {
            const extra = (0, catalogue_1.formatMissingMetadataWarnings)(task);
            if (extra) {
                warnings.add(extra);
            }
        }
    }
}
