import { useState } from "react"; // An overlay's toast-host rank (see the overlay-hosts note in Toaster). Its own module so Toaster exports // only components (Fast Refresh); the counter is module state, so there is exactly one sequence. let overlaySeq = 0; /** This overlay's rank among open overlays — taken once, when it mounts. Call it in the overlay * itself, never in a component that can remount while the overlay stays open. */ export function useOverlayOrder(): number { const [order] = useState(() => ++overlaySeq); return order; }