"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_plugins_1 = require("@expo/config-plugins");
const withAndroidPrewarm = (config) => {
    return (0, config_plugins_1.withMainApplication)(config, (config) => {
        let content = config.modResults.contents;
        // Add import for NitroWebSocketAutoPrewarmer
        if (!content.includes('import com.margelo.nitro.nitrofetchwebsockets.NitroWebSocketAutoPrewarmer')) {
            content = content.replace(/import android.app.Application/g, `import android.app.Application
import com.margelo.nitro.nitrofetchwebsockets.NitroWebSocketAutoPrewarmer`);
        }
        // Add prewarmOnStart call in onCreate before loadReactNative
        if (!content.includes('NitroWebSocketAutoPrewarmer.prewarmOnStart')) {
            content = content.replace(/super\.onCreate\(\)/, `super.onCreate()
    NitroWebSocketAutoPrewarmer.prewarmOnStart(this)`);
        }
        config.modResults.contents = content;
        return config;
    });
};
exports.default = withAndroidPrewarm;
