const classish = ( str ) : boolean => ! ! str && str . indexOf ( '.' ) >= 0 ; export const mapStyles = ( styles ) : string [ ] => ( styles . replace ( /({[^{}]+})/g , '$' ) . replace ( /({[^{}]+})/g , '$' ) . match ( /\.([^>~,+$:{\[\s]+)?/g ) || [ ] ) . map ( ( x ) => x . replace ( /[\s,.>~+$]+/ , '' ) ) . map ( ( x ) => x . replace ( /[.\s.:]+/ , '' ) ) ; export const mapSelector = ( selector ) : string [ ] => { const cleanSelector = selector . replace ( /\(([^)])*\)/g , '' ) . replace ( /(\\\+)/g , 'PLUS_SYMBOL' ) ; const ruleSelection = cleanSelector . match ( /\.([^>~+$:{\[\s]+)?/g ) || [ ] ; ruleSelection . reverse ( ) ; const effectiveMatcher = ruleSelection . find ( classish ) || '' ; const selectors = effectiveMatcher . match ( /(\.[^.>~+,$:{\[\s]+)?/g ) ; return ( selectors || [ ] ) . map ( ( x ) => x . replace ( /[.\s.:]+/ , '' ) . replace ( /PLUS_SYMBOL/g , '+' ) ) . filter ( Boolean ) ; } ;