import adapter, {} from "@sveltejs/adapter-cloudflare";
import { getPlatformProxyOptions } from "../cloudflare-env-proxy.js";
export default (options) => {
    if (shouldDisable()) {
        return {
            name: "alchemy-noop",
            adapt() { },
        };
    }
    const { platformProxy: proxyOptions, ...config } = options ?? {};
    const platformProxy = getPlatformProxyOptions(proxyOptions);
    return adapter({
        platformProxy,
        config: platformProxy.configPath,
        ...config,
    });
};
/**
 * Return true for `svelte-language-server`, `svelte-check`, and `svelte-kit sync`. This is because:
 * - The svelte language server runs from the root and therefore may be running in a different cwd than the `Website.cwd`, so disable to avoid breaking intellisense
 * - The `svelte-check` and `svelte-kit sync` commands do not require Cloudflare-specific configuration, so disable to avoid breaking the commands
 */
function shouldDisable(argv = process.argv) {
    return (argv.some((arg) => arg.includes("svelte-check") || arg.includes("svelte-language-server")) ||
        (argv.some((arg) => arg.includes("svelte-kit")) && argv.includes("sync")));
}
//# sourceMappingURL=plugin.js.map