"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.clearAppDialogRunControlsRegistry = clearAppDialogRunControlsRegistry;
exports.registerAppDialogRunControl = registerAppDialogRunControl;
exports.unregisterAppDialogRunControl = unregisterAppDialogRunControl;
exports.getAppDialogRunControlMeta = getAppDialogRunControlMeta;
exports.listAppDialogRunControls = listAppDialogRunControls;
const runControlRegistry = new Map();
function clearAppDialogRunControlsRegistry() {
    runControlRegistry.clear();
}
function registerAppDialogRunControl(params) {
    const id = params.id.trim();
    if (id === '') {
        throw new Error('App dialog run control id cannot be empty');
    }
    if (runControlRegistry.has(id)) {
        const existing = runControlRegistry.get(id);
        throw new Error(`Duplicate app dialog run control id '${id}' (existing app='${existing?.appId ?? 'unknown'}', new app='${params.appId}')`);
    }
    runControlRegistry.set(id, {
        appId: params.appId,
        descriptionI18n: params.descriptionI18n,
    });
}
function unregisterAppDialogRunControl(id) {
    runControlRegistry.delete(id);
}
function getAppDialogRunControlMeta(id) {
    const found = runControlRegistry.get(id);
    return found ?? null;
}
function listAppDialogRunControls() {
    return [...runControlRegistry.entries()].map(([id, meta]) => ({ id, ...meta }));
}
