/** The slice of the singleton modal this controller reads and writes. */ export interface OwnableModal { /** Monotonic per-open token; bumped each time a caller claims the singleton. */ generation: number; onBackdrop: (() => void) | null; /** Invoked on the current owner when a newer open claims the modal. */ onSupersede: (() => void) | null; } export interface ModalOwnership { /** True while this open still owns the singleton modal. */ owns(): boolean; /** * Settle this open exactly once. `action` (the owner-only DOM hide plus the * promise resolve/reject) runs only if this open still owns the modal and has * not already settled - a superseded or already-settled open is a no-op. * Returns whether `action` ran. */ settleOwned(action: () => void): boolean; } /** * Claim the singleton modal for a fresh open. Any earlier open that never settled * is superseded: the generation is bumped first (so the prior open's `owns()` * turns false and its late callbacks can no longer touch the modal we now own), * then its supersede hook is invoked so its promise rejects. * * @param onSuperseded rejects THIS open's promise when a later open supersedes it. */ export declare function claimModalOpen(m: OwnableModal, onSuperseded: () => void): ModalOwnership;