import type { InjectorConfig , Injector } from './types' ; const STYLE_ELEMENT_ID = '__beamwind' ; const getStyleElement = ( nonce ? ) : HTMLStyleElement => { let element = document . getElementById ( STYLE_ELEMENT_ID ) as HTMLStyleElement | null ; if ( ! element ) { element = document . createElement ( 'style' ) ; element . id = STYLE_ELEMENT_ID ; nonce && ( element . nonce = nonce ) ; document . head . appendChild ( element ) ; } return element ; } ; /**
 * Creates an injector which collects style rules during server-side rendering.
 */ export const virtualInjector = ( { target = [ ] } = { } ) : Injector < string [ ] > => ( { target , insert : ( rule , index ) => target . splice ( index , 0 , rule ) , } ) ; /**
 * Creates an injector which inserts style rules through the CSS Object Model.
 */ export const cssomInjector = ( { nonce , target = getStyleElement ( nonce ) . sheet as CSSStyleSheet , } = { } ) : Injector < CSSStyleSheet > => ( { target , insert : target . insertRule . bind ( target ) , } ) ; /**
 * An injector placeholder which performs no operations. Useful for avoiding errors in a non-browser environment.
 */ export const noOpInjector = ( ) : Injector < null > => ( { target : null , insert : ( ) => { } , } ) ;