import { type WorkflowDetailDto, type WorkflowStepDto, type WorkflowTriggerBindingDto, type WorkflowActionDefinitionDto, type WorkflowTriggerDto } from '@/services/api/communicationsApi';
import type { WorkflowMetadata } from '@/components/platform/administration/workflows/builder/WorkflowInspectorPanel';
import type { CanvasSelection } from '@/components/platform/administration/workflows/builder/WorkflowCanvas';
/**
 * Identifier prefix marker for entities that exist only in the client state
 * (newly added bindings/steps not yet persisted). The save cascade detects this
 * prefix to know whether to POST (create) or PUT (update).
 */
export declare const TMP_ID_PREFIX = "tmp-";
export declare const newTempId: () => string;
export declare const isTempId: (id: string) => boolean;
/**
 * Immutable snapshot captured at load time so the save cascade can diff
 * current state vs. server state and emit only the deltas.
 */
export interface WorkflowSnapshot {
    readonly metadata: WorkflowMetadata;
    readonly bindings: readonly WorkflowTriggerBindingDto[];
    readonly steps: readonly WorkflowStepDto[];
}
/**
 * Encapsulates the entire builder state model plus all CRUD actions the canvas
 * and inspector need. Keeping this hook discrete from the page component lets
 * us unit-test mutations (e.g. "deleting a step clears dangling pointers")
 * without spinning up the DOM.
 */
export interface UseWorkflowBuilderResult {
    readonly workflow: WorkflowDetailDto | null;
    readonly loading: boolean;
    readonly loadError: string | null;
    readonly metadata: WorkflowMetadata;
    readonly bindings: readonly WorkflowTriggerBindingDto[];
    readonly steps: readonly WorkflowStepDto[];
    readonly selection: CanvasSelection | null;
    readonly initialSnapshot: WorkflowSnapshot | null;
    readonly setMetadata: (next: WorkflowMetadata) => void;
    readonly setSelection: (selection: CanvasSelection | null) => void;
    readonly updateBinding: (bindingId: string, patch: Partial<WorkflowTriggerBindingDto>) => void;
    readonly updateStep: (stepId: string, patch: Partial<WorkflowStepDto>) => void;
    readonly deleteBinding: (bindingId: string) => void;
    readonly deleteStep: (stepId: string) => void;
    readonly insertBindingFromTrigger: (trigger: WorkflowTriggerDto) => string | null;
    readonly insertStepAtPosition: (action: WorkflowActionDefinitionDto, position: number) => string | null;
    readonly insertStepInConditionBranch: (action: WorkflowActionDefinitionDto, conditionStepId: string, branch: 'true' | 'false') => string | null;
    readonly reorderStep: (stepId: string, targetPosition: number) => void;
    readonly load: () => Promise<void>;
    readonly resetToServer: () => void;
}
/**
 * Drives every transition of a workflow being authored or edited.
 *
 * Behavioral contract guarded by tests:
 *
 * - `deleteStep` is *cascading*: any other step whose
 *   `nextOnSuccessStepId`/`nextOnFailureStepId` (or condition input pointers)
 *   referenced the removed step gets cleared, and `stepOrder` is re-normalized
 *   to a 1-based contiguous range. This prevents dangling FKs from reaching
 *   the engine and crashing executions in production.
 *
 * - `insertBindingFromTrigger` is *idempotent*: dragging the same trigger
 *   twice doesn't duplicate.
 *
 * - All inserts auto-select the new node so the inspector immediately surfaces
 *   its properties — the user keeps flow without an extra click.
 *
 * - `metadata.code` is locked once a server id exists (mode edit).
 */
export declare function useWorkflowBuilder(workflowId: string | undefined): UseWorkflowBuilderResult;
//# sourceMappingURL=useWorkflowBuilder.d.ts.map