export function handleErrorResult(result, ui, state) {
    if (result.type === "error") {
        console.log("show error toast", result);
        ui.showErrorToast({
            summary: result.summary,
            details: result.details,
            rawDetails: result.rawDetails,
        });
        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). The
        // SessionExpiredOverlay listens for this event and renders a blocking
        // full-screen modal so the user cannot keep interacting with stale UI.
        window.dispatchEvent(new CustomEvent("parhelia:session-expired", {
            detail: { reason: result.details || "unauthorized" },
        }));
        return true;
    }
}
//# sourceMappingURL=helpers.js.map