import { Selectable , } from "@opticss/element-analysis" ; import * as SelectorParser from "postcss-selector-parser" ; import { ParsedSelector } from "../parseSelector" ; import { Match , matches } from "./Match" ; export interface HasSelectorNodes { nodes : Array < SelectorParser . Node > ; } export abstract class Matcher < Type extends Selectable > { param keySelectorOnly matchSelector ( selectable , parsedSelector , keySelectorOnly ) { let matched = parsedSelector . eachCompoundSelector ( ( selector ) => { if ( selector !== parsedSelector . key && keySelectorOnly ) return ; let match = this . matchSelectorComponent ( selectable , selector ) ; if ( matches ( match ) ) return match ; return ; } ) ; return matched || Match . no ; } abstract matchSelectorComponent ( selectable , selector ) ; abstract matchSelectorNode ( selectable , selector ) ; }