import type { MatchedRule } from '@variance-authority/core/format'; import type { StyleIndex } from './css-index.js'; /** * The per-element half of the pruning: which indexed rules apply to one node. * * Separated from the index because this side runs once per node where indexing * runs once per document. Everything here is written against a finished * `StyleIndex` and a single element — it never reads a stylesheet, and cannot, * which is what keeps a design system's cost a one-time cost instead of a * per-node one. * * Latent coupling detection lives here for the same reason: a rule that matches * nothing contributes no declaration to the index and is only interesting once * there is an element to ask it about. */ /** * Rules matching one element, in document order. * * Only candidates whose rightmost simple selector could possibly match are * tested. Without that filter this is rules × elements, and a design system's * stylesheet against a page-sized subject makes the collector the slowest part * of the pipeline — in a system whose entire argument is that it does less work * than taking a screenshot. */ export interface MatchResult { /** Rules styling the element itself. */ readonly matched: MatchedRule[]; /** * Rules styling one of the element's pseudo-elements, by pseudo-element * (`::before`, `::marker`, …), in document order. * * Apart from `matched` because they style a different box. A * `.badge::before { color: red }` attached to the badge recolours, in the * snapshot, a box the page never painted red — and the box that *was* painted * red is left with no rule at all. Each rule's `selector` is still the whole * branch, pseudo-element included, because that is the rule a reader finds. */ readonly pseudo: ReadonlyMap; /** * Root-state keys this element is *latently* coupled to. * * A rule like `html.dark .card` does not match today, so it contributes no * declaration and would be invisible to a matched-rules-only view. But the * moment something puts `dark` on `` it applies — and if that something * is another subject in a shared session, this subject's baseline silently * became order-dependent. * * Latent coupling is detected by testing the rule's *rightmost* compound alone: * if the subject's own node would satisfy it and only the ancestor portion * fails, the rule is one root-state change away from applying. That is exactly * the coupling a no-rinse session needs to know about before it bites, rather * than after a hash mysteriously moves. */ readonly couplings: readonly string[]; } export declare function matchRulesFor(element: Element, index: StyleIndex): MatchResult; //# sourceMappingURL=css-match.d.ts.map