// engine/figma/multi-file-manager.ts — Multi-file Figma config helpers (SPEC-427)
import { parseFigmaUrl } from './api-client.js';
export function parseAndValidateFileEntry(figmaUrl, label) {
    if (typeof label !== 'string' || label.trim() === '') {
        throw new Error('Label must be a non-empty string');
    }
    const parsed = parseFigmaUrl(figmaUrl);
    return {
        fileKey: parsed.fileKey,
        label: label.trim(),
        figmaUrl,
        addedAt: new Date().toISOString(),
    };
}
export function addFileEntry(existing, entry) {
    const duplicate = existing.some((e) => e.fileKey === entry.fileKey);
    if (duplicate) {
        throw new Error('File already configured: ' + entry.fileKey);
    }
    return [...existing, entry];
}
export function removeFileEntry(existing, fileKey) {
    return existing.filter((e) => e.fileKey !== fileKey);
}
export function prefixFrameLabel(frameName, fileLabel) {
    return `[${fileLabel}] ${frameName}`;
}
export function stripFrameLabel(prefixedName) {
    const match = /^\[(.+?)\] (.+)$/.exec(prefixedName);
    if (match === null) {
        return null;
    }
    return { label: match[1] ?? '', name: match[2] ?? '' };
}
//# sourceMappingURL=multi-file-manager.js.map