import { dispatcher } from "../events/schedule/schedule.js";
import { createWaitUntil } from "../fetch/index.js";
import { isSignalled } from "../is.js";
export const removeContentDeleteDispatchFunction = dispatcher("contentdelete", async (event, dispatch) => {
    const { signal, controller } = getSignal();
    const { wait, waitUntil } = createWaitUntil();
    try {
        await dispatch({
            ...event,
            signal,
            waitUntil
        });
        await wait();
    }
    catch (error) {
        if (!signal.aborted) {
            controller?.abort(error);
        }
        throw await Promise.reject(error);
    }
    finally {
        if (!signal.aborted) {
            controller?.abort();
        }
        await wait();
    }
    function getSignal() {
        if (isSignalled(event)) {
            return { signal: event.signal, controller: undefined };
        }
        const controller = new AbortController();
        return {
            signal: controller.signal,
            controller
        };
    }
});
//# sourceMappingURL=dispatch.js.map