/**
 * Custom hook that owns all sectioned-editing state and handlers, extracted
 * from the `Editors` component to keep it manageable.
 *
 * Callers supply the current `EditorContentState` and a callback
 * (`onContentUpdate`) that is invoked whenever a section change produces a
 * new merged full-document source string.  All other section-related
 * callbacks mirror the corresponding `editorProps`.
 */
import { type Dispatch, type SetStateAction } from "react";
import type { EditorContentState } from "../types/editor";
import type { DocumentSection } from "../types/sections";
export interface SectionedEditingOptions {
    contentState: EditorContentState;
    /** Externally controlled edit mode (controlled usage). */
    controlledEditMode?: "document" | "sectioned";
    /** Initial edit mode for uncontrolled usage. */
    defaultEditMode?: "document" | "sectioned";
    onEditModeChange?: (mode: "document" | "sectioned") => void;
    onSectionsChange?: (sections: DocumentSection[]) => void;
    onSectionChange?: (section: DocumentSection) => void;
    /** Called with the merged full-document source whenever section content changes. */
    onContentUpdate: (source: string) => void;
    /**
     * When set (book mode), changing this value triggers an immediate section
     * re-parse and resets to document mode so the newly-loaded chapter is
     * reflected in the TOC even when the editor was previously in sectioned mode.
     */
    chapterKey?: string | null;
}
export interface SectionedEditingResult {
    editMode: "document" | "sectioned";
    sections: DocumentSection[];
    currentSectionId: string | null;
    setCurrentSectionId: Dispatch<SetStateAction<string | null>>;
    documentWrapper: string;
    /** The section currently being edited, or `null` in document mode. */
    currentSection: DocumentSection | null;
    isTocCollapsed: boolean;
    setIsTocCollapsed: Dispatch<SetStateAction<boolean>>;
    /**
     * The source content to display in the code editor.
     * In sectioned mode this is the *inner* content of the current section
     * (outer division tag stripped); in document mode it is the full source.
     */
    activeSourceContent: string;
    /** Called by the code editor when the user edits section content. */
    updateSectionContent: (content: string | undefined) => void;
    /**
     * True when the editor is showing a single book chapter in document mode.
     * In this state {@link activeSourceContent} has the `<chapter>` wrapper
     * stripped and {@link updateChapterBodyContent} (not the raw content
     * update) must be used to propagate edits.
     */
    isBookChapterBody: boolean;
    /**
     * Called by the code editor when the user edits the body of a book chapter
     * in document mode.  Re-wraps the inner content with the chapter's original
     * `<chapter>` tag (preserving its attributes) before propagating.
     */
    updateChapterBodyContent: (content: string | undefined) => void;
    /**
     * Update the active chapter's title / xml:id / label.  Keeps the document
     * wrapper and merged source in sync so the change survives later edits.
     */
    updateActiveChapterMetadata: (changes: {
        title?: string;
        xmlId?: string | null;
        label?: string | null;
    }) => void;
    handleRefreshSections: () => void;
    switchEditMode: (mode: "document" | "sectioned") => void;
    handleSelectSectionInDocMode: (id: string) => void;
    handleAddFirstSection: () => void;
    handleAddSection: (afterId: string | null) => void;
    handleAddIntroduction: () => void;
    handleAddConclusion: () => void;
    handleRemoveSection: (id: string) => void;
    handleUpdateSectionMetadata: (id: string, changes: {
        title?: string;
        type?: DocumentSection["type"];
        xmlId?: string | null;
        label?: string | null;
    }) => void;
    handleReorderSections: (nextSections: DocumentSection[]) => void;
    handleMergeSection: (sourceId: string, targetId: string) => void;
    /**
     * Queue a section-title navigation request that will be applied the
     * next time the chapter-key effect re-splits the document.  Used by
     * book mode to land on a specific section after switching chapters.
     */
    requestSectionNavigation: (sectionTitle: string | null) => void;
    /**
     * A human-readable message describing why the source content can't be
     * parsed, or `null` when it parses cleanly.  Surfaced as a warning
     * banner in the TOC so the user knows section operations are blocked
     * until the XML is fixed.
     */
    parseError: string | null;
}
export declare function useSectionedEditing({ contentState, controlledEditMode, defaultEditMode, onEditModeChange, onSectionsChange, onSectionChange, onContentUpdate, chapterKey, }: SectionedEditingOptions): SectionedEditingResult;
