import { get as getColorModel } from 'color-string' ; ignore export const getColorInitializer = ( cssValue ) => { const cssModel = getColorModel ( cssValue ) ; if ( cssModel === null ) { return 'new Color()' ; } switch ( cssModel . model ) { case 'rgb' : return `Color.rgba(${ cssModel . value . join ( ', ' ) })` ; case 'hsl' : const [ hDegrees , sPercent , lPercent , a ] = cssModel . value ; return `Color.hsla(${ hDegrees / 360 }, ${ sPercent / 100 }, ${ lPercent / 100 }, ${ a })` ; default : throw new Error ( `Unsupported CSS color model: ${ cssModel . model }` ) ; } } ;