export class DeepSeekCodeAbortError extends Error {
    constructor(reason) {
        super(abortReasonText(reason));
        this.name = "AbortError";
    }
}
export function throwIfAborted(signal) {
    if (!signal?.aborted)
        return;
    throw new DeepSeekCodeAbortError(signal.reason);
}
export function isAbortError(error, signal) {
    return Boolean(signal?.aborted) || error instanceof DeepSeekCodeAbortError;
}
export function abortReasonText(reason) {
    if (reason instanceof Error)
        return reason.message || "aborted";
    if (typeof reason === "string" && reason.trim())
        return reason;
    return "aborted";
}
