/**
 * Sync Settings - Controls what SpecWeave can modify in external tools
 *
 * These settings determine how Living Docs sync with external tools (GitHub, JIRA, ADO).
 * All settings default to false for safety (explicit opt-in required).
 *
 * Storage: .specweave/config.json under sync.settings
 */
/**
 * Default sync settings (all permissions enabled — sync should work out of the box)
 */
export const DEFAULT_SYNC_SETTINGS = {
    canUpsertInternalItems: true,
    canUpdateExternalItems: true,
    canUpdateStatus: true,
};
/**
 * Type guard to check if an object is valid SyncSettings
 */
export function isValidSyncSettings(obj) {
    return (typeof obj === 'object' &&
        obj !== null &&
        typeof obj.canUpsertInternalItems === 'boolean' &&
        typeof obj.canUpdateExternalItems === 'boolean' &&
        typeof obj.canUpdateStatus === 'boolean');
}
/**
 * Migrate old syncDirection to new SyncSettings
 */
export function migrateSyncDirection(syncDirection) {
    switch (syncDirection) {
        case 'bidirectional':
            return { canUpsertInternalItems: true, canUpdateExternalItems: true, canUpdateStatus: true };
        case 'export':
        case 'to-external':
            return { canUpsertInternalItems: true, canUpdateExternalItems: false, canUpdateStatus: false };
        case 'import':
        case 'from-external':
            return { canUpsertInternalItems: false, canUpdateExternalItems: false, canUpdateStatus: true };
        default:
            return { ...DEFAULT_SYNC_SETTINGS };
    }
}
/**
 * Validate SyncSettings object
 *
 * @throws Error if settings are invalid
 */
export function validateSyncSettings(settings) {
    if (!settings || typeof settings !== 'object') {
        throw new Error('SyncSettings must be a non-null object');
    }
    const requiredBooleans = [
        'canUpsertInternalItems',
        'canUpdateExternalItems',
        'canUpdateStatus',
    ];
    for (const field of requiredBooleans) {
        if (typeof settings[field] !== 'boolean') {
            throw new Error(`SyncSettings.${field} must be a boolean (required)`);
        }
    }
}
/**
 * Merge user-provided settings with defaults (fill in missing fields)
 */
export function mergeSyncSettings(userSettings) {
    return {
        ...DEFAULT_SYNC_SETTINGS,
        ...userSettings,
    };
}
//# sourceMappingURL=sync-settings.js.map