import { resolve } from "path";
import { pathToFileURL } from "url";
export async function resolvePluginHandler(pluginDir, handlerPath) {
    const absPath = resolve(pluginDir, handlerPath);
    const url = pathToFileURL(absPath).href;
    const mod = (await import(url));
    const handler = (typeof mod.default === "function" ? mod.default : mod.default?.handler) ??
        mod.handler ??
        mod.fix ??
        mod.run;
    if (typeof handler !== "function") {
        throw new Error(`Plugin handler not found: ${handlerPath}`);
    }
    return handler;
}
//# sourceMappingURL=handlerResolver.js.map