import { StyleDefinition , Predicate , Expression } from '@trousers/utils' ; export default function styleCollector < Theme = { } > ( elementName ) { const styleDefinitions = [ ] ; const get = ( ) => styleDefinitions ; const modifier = ( idOrPredicate , predicate ? ) => ( styles , ... expressions ) => { let id = '' ; if ( typeof idOrPredicate === 'string' ) { id = idOrPredicate ; } else { predicate = idOrPredicate ; } styleDefinitions . push ( { styles , expressions , predicate : ! ! predicate , name : `${ elementName }--${ id }` , } ) ; return { modifier , get } ; } ; const element = ( styles , ... expressions ) => { styleDefinitions . push ( { styles , expressions , predicate : true , name : `${ elementName }__` , } ) ; return { modifier , get } ; } ; return { element , modifier , get , } ; }