hitTestAnnotation

fun hitTestAnnotation(annotations: List<PdfViewerAnnotation>, pageIndex: Int, xPoints: Float, yPoints: Float): Int

Returns the index of the topmost annotation in annotations whose box contains the point (xPoints, yPoints) on page pageIndex, or -1 if the tap missed every annotation on that page.

"Topmost" means the last matching annotation in list order — the viewer paints annotations in list order, so the last one drawn sits visually on top and should be the one a tap deletes. All coordinates are in PDF points (top-left origin, Y down), the same space the annotations are stored in, so the caller maps a screen tap into page points before calling this.

Pure logic with no Compose dependency so it can be unit-tested on the JVM without a UI harness.