import type { GeoJsonFeature } from "@trackunit/geo-json-utils"; import type { ResolveShapeLabel, ShapeLabelResolution, ShapeLabelResolutionContext } from "./shapeLabelResolution"; /** * The subset of `ShapeLabelResolutionContext` that governs the * annotation/edge-label decision. Kept minimal so the policy doesn't * depend on viewport-density or geometry fields it doesn't use. */ export type AnnotationContext = Readonly<{ /** True when the viewport is fully contained inside the shape (no edges visible). */ isViewportInsideShape: boolean; /** True when the feature is the currently selected entity. */ isSelected: boolean; /** True when the feature is the currently hovered entity. */ isHovered: boolean; }>; /** * Couples the edge-label resolution function with the annotation opt-in * predicate so the two cannot drift apart. * * `resolveLabel` must return `"hide"` whenever `shouldAnnotate` returns * `true` for the same feature — enforced structurally by `createShapeLabelPolicy`. * * See ADR-0017 for rationale. */ export type ShapeLabelPolicy = Readonly<{ resolveLabel: ResolveShapeLabel; shouldAnnotate: (feature: GeoJsonFeature, ctx: AnnotationContext) => boolean; }>; /** * Factory that creates a `ShapeLabelPolicy` where `resolveLabel` and * `shouldAnnotate` are structurally coupled: when `annotateWhen` returns * `true` for a feature, `resolveLabel` automatically returns `"hide"` so * the edge label is suppressed and the annotation takes over. * * @param opts.annotateWhen - Predicate; returns true when the annotation * fallback should render instead of the edge label. * @param opts.resolve - Edge-label resolution used when `annotateWhen` is false. */ export declare const createShapeLabelPolicy: (opts: { readonly annotateWhen: (feature: GeoJsonFeature, ctx: AnnotationContext) => boolean; readonly resolve: (feature: GeoJsonFeature, ctx: ShapeLabelResolutionContext) => ShapeLabelResolution; }) => ShapeLabelPolicy;