"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SYSTEM_KEYS = exports.SUPPORTED_PROVIDERS = void 0;
exports.classifyKey = classifyKey;
exports.formatKnownKeys = formatKnownKeys;
const preferences_schema_1 = require("./preferences-schema");
/**
 * Cloud provider keys recognized by `flui config set/get/remove`.
 * Kept in sync with the prompts/credential logic; extend here when adding a new provider.
 */
exports.SUPPORTED_PROVIDERS = ['hetzner', 'scaleway'];
exports.SYSTEM_KEYS = ['api-url'];
/**
 * Decide which storage area (preferences vs encrypted token vault) a `flui config` command
 * should target, based purely on the key the user passed in.
 *
 * The dispatch is intentionally schema-driven so adding a new preference or provider does
 * not require touching the user-facing commands.
 */
function classifyKey(key) {
    if ((0, preferences_schema_1.isPreferenceKey)(key))
        return 'preference';
    if (exports.SYSTEM_KEYS.includes(key.toLowerCase())) {
        return 'system';
    }
    if (exports.SUPPORTED_PROVIDERS.includes(key.toLowerCase())) {
        return 'provider';
    }
    return 'unknown';
}
/**
 * Multi-line description of every key the user can target — shown in error messages
 * when an unknown key is passed to `flui config set/get/remove`.
 */
function formatKnownKeys() {
    const prefs = Object.values(preferences_schema_1.PREFERENCES)
        .map((p) => `  - ${p.key} (preference) — ${p.description}`)
        .join('\n');
    const providers = exports.SUPPORTED_PROVIDERS.map((p) => {
        const isCompound = p === 'scaleway';
        return `  - ${p} (${isCompound ? 'access key + secret key' : 'provider token'})`;
    }).join('\n');
    const system = exports.SYSTEM_KEYS.map((k) => `  - ${k} (system override)`).join('\n');
    return `Preferences:\n${prefs}\n\nProviders:\n${providers}\n\nSystem:\n${system}`;
}
