import { getConfig, withConfig } from "./config/index.js";
import { isServiceWorker } from "./worker/service-worker/config.js";
export async function start(config) {
    if (config) {
        return withConfig(getConfig(config), () => start());
    }
    await import("./scheduled.js");
    await import("./dispatch.js");
    const tracing = await import("./tracing.js");
    let listen, worker;
    if (isServiceWorker()) {
        worker = await import("./worker/service-worker/main.js");
    }
    else {
        listen = await import("./listen/main.js");
    }
    return async function close() {
        await tracing.shutdown();
        await listen?.close();
        await worker?.close();
    };
}
//# sourceMappingURL=start.js.map