/** * Fallback CSS-path walker — the safety net for the v1 element-selector * algorithm. * * When the orchestrator's strategy chain finds nothing usable across the full * ancestor walk, the engine invokes this fallback. It produces a positional * selector by walking up from the target to , expressing each step as * either an id anchor (when one survives the autogen filter) or a * `tag:nth-of-type(n)` step. * * Key differences from the legacy autocapture `cssPath`: * * 1. Ids are filtered through `getStableId`, which honors the * explicit-tracking-attribute suppression signal AND the autogenerated-id * pattern pack. The legacy `cssPath` would happily anchor on `id=":r5:"` * and produce selectors that never match across page loads. * * 2. Classes — when they're used at all for sibling disambiguation — are * filtered through `filterClasses` against the unstable-class pattern * pack. The current v1 implementation here doesn't emit classes (we lean * entirely on `:nth-of-type` for sibling disambiguation), but the * filtering helper is wired through so future iterations can opt back in * surgically without re-deriving the policy. * * 3. A unique anchor id terminates the walk early — once we hit `body#main`, * we don't need to keep walking up to ``. * * 4. Ambiguous id anchors are skipped. Duplicate ids are invalid HTML but * common enough in the wild that fallback must not emit selectors that * resolve to the wrong target. * * Output format mirrors the orchestrator's output: ` > `. * When no usable id is found anywhere on the walk, the fallback emits a * pure-positional selector rooted at `html`. * * See the design doc: * packages/plugin-autocapture-browser/element-selector-strategy-v1-no-classes.md */ import { ResolvedSelectorConfig } from './types'; export interface FallbackCssPathOptions { /** Document or shadow root used for uniqueness checks. Defaults to the target's owner document. */ scope?: ParentNode; } /** * Build a positional CSS selector for `el`, using stable ids as anchors when * available and falling back to `tag:nth-of-type(n)` for disambiguation. * * Honors `config.maxAncestorWalkDepth` defensively — once the depth limit is * reached, the walker stops and returns whatever it has built so far rooted at * the deepest reached ancestor. */ export declare function fallbackCssPath(el: Element, config: ResolvedSelectorConfig, options?: FallbackCssPathOptions): string; //# sourceMappingURL=fallback-css-path.d.ts.map