export function handleErrorResult(result, ui, state) {
    if (result.type === "error") {
        console.log("show error toast", result);
        ui.showErrorToast({
            summary: result.summary || "Error",
            details: result.details || "An error occurred",
        });
        return true;
    }
    if (result.type === "unauthorized") {
        if (result.summary === "Session revoked") {
            window.dispatchEvent(new CustomEvent("parhelia:session-revoked", {
                detail: { reason: result.details || "session-revoked" },
            }));
            return true;
        }
        if (state.configuration.events.onUnauthorized) {
            state.configuration.events.onUnauthorized();
            return true;
        }
        // Session expired (e.g. timeout or logout in another tab). Let the
        // EditorShell render a single, debounced "Your session has expired"
        // toast with a Login action instead of a confirmation dialog.
        window.dispatchEvent(new CustomEvent("parhelia:session-expired", {
            detail: { reason: result.details || "unauthorized" },
        }));
        return true;
    }
}
//# sourceMappingURL=helpers.js.map