import { getDefaultConfigPath, getDefaultPersistPath, validateConfigPath, } from "./miniflare/paths.js";
export const getCloudflareEnvProxy = async (options = {}) => {
    const { getPlatformProxy } = await import("wrangler");
    const config = getPlatformProxyOptions(options);
    const proxy = await getPlatformProxy(config);
    return proxy.env;
};
export const getPlatformProxyOptions = (input = {}, throws = true) => {
    const persist = input.persist === false
        ? false
        : {
            path: typeof input.persist === "object" &&
                typeof input.persist.path === "string"
                ? input.persist.path
                : getDefaultPersistPath(),
        };
    if (!persist) {
        const message = "[Alchemy] Persistence for local bindings is disabled. Some bindings may not work as expected. To enable, remove the `persist` option from getPlatformProxyOptions.";
        if (!warned.has(message)) {
            console.warn(message);
            warned.add(message);
        }
    }
    return {
        ...input,
        configPath: validateConfigPath(input.configPath ?? getDefaultConfigPath(), throws),
        persist,
    };
};
const warned = new Set();
//# sourceMappingURL=cloudflare-env-proxy.js.map