export function formatRule ( selector , block ) { return `${ selector }{${ block }}` ; } export function formatClassRule ( className , block , selector = '' ) { return `.${ formatRule ( className + selector , block ) }` ; } export function formatSupportsRule ( condition , block ? ) { return `@supports ${ typeof block === 'string' ? formatRule ( condition , block ) : condition }` ; } export function formatKeyframesRule ( name , blockList ) { return `@keyframes ${ formatRule ( name , blockList ) }` ; } export function formatFontFaceRule ( block ) { return formatRule ( '@font-face' , block ) ; } export function formatMediaRule ( query , block ? ) { return `@media ${ typeof block === 'string' ? formatRule ( query , block ) : query }` ; } export function combineConditions ( a , b ) { return `${ a [ 0 ] === '(' ? a : `(${ a })` } and ${ b [ 0 ] === '(' ? b : `(${ b })` }` ; } const PRETTY_REGEX = /[{:;}]|(?:(["']).*?\1)/g ; export function prettifyRule ( rule ) { return rule . replace ( PRETTY_REGEX , match => match === '{' ? ' {\n  ' : match === ':' ? ': ' : match === ';' ? ';\n  ' : match === '}' ? ';\n}' : match ) ; }