import { validateSchema } from '../../validate/validate.js';
const migrate = async (context, projectSchema) => {
    const { ['ai-experimental']: ai, ...rest } = projectSchema;
    const migrated = {
        ...rest,
        schemaVersion: '3.57.0'
    };
    if (ai) {
        const migratedWithAi = Object.assign({ ...migrated }, ai);
        const { valid } = await validateSchema({ ignoreEntitlements: true, structureOnly: true }, migratedWithAi);
        if (valid) {
            return migratedWithAi;
        }
        context.logger.warn(`Dropping "ai-experimental" properties schema for project "${projectSchema.projectId}".`);
    }
    return migrated;
};
export default migrate;
