import { toast } from "sonner";
import { normalizeOpId } from "./waitForEditOperationTerminal";
/**
 * Terminal toasts for long-running edit operations (publish, import, copy,
 * clone, move, delete). Live progress is NOT shown as a toast — the
 * OperationsIndicator in the menubar renders executing operations — but the
 * moment an operation completes or fails deserves momentary feedback.
 * useSocketMessageHandler calls these from operation:completed/failed.
 */
function toastId(operationId) {
    return `op:${normalizeOpId(operationId)}`;
}
function humanizeType(type) {
    const words = type?.replace(/-/g, " ").trim();
    if (!words)
        return undefined;
    return words.charAt(0).toUpperCase() + words.slice(1);
}
function getLabel(title, type) {
    return title?.trim() || humanizeType(type) || "Operation";
}
export function succeedOperationToast(operationId, title, summary, type) {
    toast.success(getLabel(title, type), {
        // Stable per-operation id so duplicate terminal messages update in place
        id: toastId(operationId),
        description: summary || "Completed",
    });
}
export function failOperationToast(operationId, errorMessage, title, type) {
    toast.error(`${getLabel(title, type)} failed`, {
        id: toastId(operationId),
        description: errorMessage || undefined,
    });
}
//# sourceMappingURL=operationToasts.js.map