/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
/**
 * Canvas node drag-to-reorder, shared by BOTH canvases (ADR-0003, doc §9.6). The
 * ~700-line pointer machinery (mousemove tracking, RAF drag preview, auto-scroll,
 * drop-zone hit-testing, the move API) is framework-agnostic DOM logic; the
 * runtime-specific bits at the top (`api`, the i18n functions, the instruction
 * registry, the executed flag) are read through an injected `useCanvasRuntime`
 * so v1 can re-import this single provider and pass its own runtime (the allowed
 * v1 → v2 direction). `workflow`/`nodes`/`refresh` come from the now-shared
 * `FlowContext` directly, and the pure graph walks from the relocated modules.
 */
import React from 'react';
import { type CanvasNode } from './contexts';
import type { Instruction } from './Instruction';
/** Per-canvas runtime the drag provider needs but that differs by runtime —
 *  injected via `NodeDragContextProvider`'s `useCanvasRuntime` prop. */
export type CanvasDragRuntime = {
    api: any;
    /** Plain-key translation (no `{{t("…")}}` expansion) — v1 `lang`, v2 `useWorkflowTranslation().t`. */
    lang: (key: string, options?: Record<string, unknown>) => string;
    /** Template expander for instruction titles (`{{t("…")}}`) — v1 `useCompile()`, v2 `useT()`. */
    compile: (source: string) => string;
    /** Resolve an instruction by type — for the drag-preview node title. */
    getInstruction: (type: string) => Instruction | undefined;
    /** Whether the workflow has been executed (read-only) — the move API is disabled. */
    executed: boolean;
};
/**
 * A drop target: the add-slot's position in the graph, identified by its upstream
 * node (`null`/absent = the root slot) and, for a branch slot, its branch index.
 * Built by `AddNodeSlot`'s `DropZone` as `{ upstream, branchIndex }`.
 */
export type DropTarget = {
    upstream?: CanvasNode | null;
    branchIndex?: number | null;
};
/** The result of dropping the dragged node onto a target: whether the move is
 *  allowed (`safe`), allowed-with-consequences (`warning` — lists the nodes whose
 *  variable references would break), or forbidden (`disabled`). */
export type DropImpact = {
    status: 'safe' | 'warning' | 'disabled';
    impactedSelf: CanvasNode[];
    impactedDependents: CanvasNode[];
};
/** The minimal node snapshot driving the floating drag preview (set on drag start,
 *  read by the preview-rendering effect). */
export type DragPreviewNode = {
    id: number;
    key?: string;
    title?: string;
    type?: string;
    hasBranches: boolean;
};
/** What `useNodeDragContext()` exposes to node cards / add-slots / the canvas. */
export type NodeDragContextValue = {
    dragging: boolean;
    dragNode: DragPreviewNode | null;
    onNodeMouseDown: (node: CanvasNode, event: React.MouseEvent) => void;
    getDropImpact: (target: DropTarget) => DropImpact;
    setActiveDrop: (target: DropTarget | null) => void;
    clearActiveDrop: (target: DropTarget) => void;
    /** Registers an add-slot's DOM element as a drop zone; returns a cleanup fn
     *  that unregisters it (used directly as a `useEffect` teardown). */
    registerDropZone: (target: DropTarget, element: HTMLElement | null) => () => void;
    getDropKey: (target: DropTarget) => string;
    activeDropKey: string | null;
    consumeClick: () => boolean;
};
export declare function useNodeDragContext(): NodeDragContextValue;
export declare function NodeDragContextProvider(props: {
    children: React.ReactNode;
    /** Injected per-canvas runtime source. Defaults to the modern canvas's; the
     *  legacy canvas passes its own (v1 `useAPIClient` / `lang` / `useCompile` /
     *  `usePlugin` registry / `useWorkflowExecuted`). */
    useCanvasRuntime?: () => CanvasDragRuntime;
}): React.JSX.Element;
