import type { Edge } from '@xyflow/react';
import type { CanvasNodeType } from '../components/features/features-canvas/index.js';
import type { FeatureNodeData } from '../components/common/feature-node/index.js';
import type { RepositoryNodeData } from '../components/common/repository-node/index.js';
import type { ApplicationNodeData } from '../components/common/application-node/application-node-config.js';
import { type FeatureEntry, type GraphCallbacks } from '../lib/derive-graph.js';
export type { GraphCallbacks } from '../lib/derive-graph.js';
export interface UseGraphStateReturn {
    /** Derived React Flow nodes (from domain Maps). */
    nodes: CanvasNodeType[];
    /** Derived React Flow edges (from domain Maps). */
    edges: Edge[];
    /**
     * Reconcile domain Maps with fresh server data (new initialNodes/initialEdges).
     * Preserves pending (creating) nodes unless a matching real feature appears.
     * No-ops when a mutation is in-flight (see beginMutation/endMutation).
     */
    reconcile: (newNodes: CanvasNodeType[], newEdges: Edge[]) => void;
    /** Update a feature's state/lifecycle/name (e.g., from SSE events). */
    updateFeature: (featureNodeId: string, updates: FeatureDataUpdates) => void;
    /** Add a pending (optimistic) feature node (state='creating'). */
    addPendingFeature: (nodeId: string, data: FeatureNodeData, parentNodeId?: string) => void;
    /** Remove a pending feature node (e.g., on rollback). */
    removePendingFeature: (nodeId: string) => void;
    /** Remove a real feature node from the domain Map. */
    removeFeature: (nodeId: string) => void;
    /** Restore a previously removed feature (rollback). */
    restoreFeature: (nodeId: string, entry: FeatureEntry) => void;
    /** Add a repository node (may use a temp ID initially). */
    addRepository: (nodeId: string, data: RepositoryNodeData) => void;
    /** Remove a repository node. */
    removeRepository: (nodeId: string) => void;
    /** Replace a temp repo ID with the real one (atomic). */
    replaceRepository: (tempId: string, realId: string, data: RepositoryNodeData) => void;
    /** Stable lookup: get the repositoryPath for a feature node. */
    getFeatureRepositoryPath: (featureNodeId: string) => string | undefined;
    /** Stable lookup: get repository node data by nodeId. */
    getRepositoryData: (nodeId: string) => RepositoryNodeData | undefined;
    /** Stable lookup: get the current number of repositories in the domain Map. */
    getRepoMapSize: () => number;
    /** Add an application node. */
    addApplication: (nodeId: string, data: ApplicationNodeData) => void;
    /** Remove an application node. */
    removeApplication: (nodeId: string) => void;
    /** Update callbacks injected into node data (does NOT trigger re-render). */
    setCallbacks: (callbacks: GraphCallbacks) => void;
    /**
     * Signal that an optimistic mutation has started. While any mutation is
     * in-flight, `reconcile` becomes a no-op so stale poll data cannot
     * overwrite optimistic state. Calls are ref-counted — nest freely.
     */
    beginMutation: () => void;
    /**
     * Signal that an optimistic mutation has resolved. Adds a one-poll-interval
     * cooldown (default 3 s) so the next poll fetches post-mutation data.
     */
    endMutation: (cooldownMs?: number) => void;
    /** Whether a mutation is currently in-flight (for polling skip logic). */
    isMutating: () => boolean;
}
type FeatureDataUpdates = Partial<Pick<FeatureNodeData, 'state' | 'lifecycle' | 'name' | 'description'>>;
export declare function useGraphState(initialNodes: CanvasNodeType[], initialEdges: Edge[], showArchived?: boolean): UseGraphStateReturn;
//# sourceMappingURL=use-graph-state.d.ts.map