{
  "version": 3,
  "sources": ["../src/shadow-utils.ts"],
  "sourcesContent": ["export const CUSTOM_VALUE_SETTINGS = {\n\tpx: { max: 20, step: 1 },\n\t'%': { max: 100, step: 1 },\n\tvw: { max: 100, step: 1 },\n\tvh: { max: 100, step: 1 },\n\tem: { max: 10, step: 0.1 },\n\trm: { max: 10, step: 0.1 },\n\tsvw: { max: 100, step: 1 },\n\tlvw: { max: 100, step: 1 },\n\tdvw: { max: 100, step: 1 },\n\tsvh: { max: 100, step: 1 },\n\tlvh: { max: 100, step: 1 },\n\tdvh: { max: 100, step: 1 },\n\tvi: { max: 100, step: 1 },\n\tsvi: { max: 100, step: 1 },\n\tlvi: { max: 100, step: 1 },\n\tdvi: { max: 100, step: 1 },\n\tvb: { max: 100, step: 1 },\n\tsvb: { max: 100, step: 1 },\n\tlvb: { max: 100, step: 1 },\n\tdvb: { max: 100, step: 1 },\n\tvmin: { max: 100, step: 1 },\n\tsvmin: { max: 100, step: 1 },\n\tlvmin: { max: 100, step: 1 },\n\tdvmin: { max: 100, step: 1 },\n\tvmax: { max: 100, step: 1 },\n\tsvmax: { max: 100, step: 1 },\n\tlvmax: { max: 100, step: 1 },\n\tdvmax: { max: 100, step: 1 },\n};\n\nexport interface ShadowObject {\n\tx: string;\n\ty: string;\n\tblur: string;\n\tspread: string;\n\tcolor: string;\n\tinset: boolean;\n}\n\nexport function getShadowParts( shadow: string ): string[] {\n\tconst shadowValues = shadow.match( /(?:[^,(]|\\([^)]*\\))+/g ) || [];\n\treturn shadowValues.map( ( value ) => value.trim() );\n}\n\nexport function shadowStringToObject( shadowValue: string ): ShadowObject {\n\t/*\n\t * Shadow spec: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow\n\t * Shadow string format: <offset-x> <offset-y> <blur-radius> <spread-radius> <color> [inset]\n\t *\n\t * A shadow to be valid it must satisfy the following.\n\t *\n\t * 1. Should not contain \"none\" keyword.\n\t * 2. Values x, y, blur, spread should be in the order. Color and inset can be anywhere in the string except in between x, y, blur, spread values.\n\t * 3. Should not contain more than one set of x, y, blur, spread values.\n\t * 4. Should contain at least x and y values. Others are optional.\n\t * 5. Should not contain more than one \"inset\" (case insensitive) keyword.\n\t * 6. Should not contain more than one color value.\n\t */\n\n\tconst defaultShadow: ShadowObject = {\n\t\tx: '0',\n\t\ty: '0',\n\t\tblur: '0',\n\t\tspread: '0',\n\t\tcolor: '#000',\n\t\tinset: false,\n\t};\n\n\tif ( ! shadowValue ) {\n\t\treturn defaultShadow;\n\t}\n\n\t// Rule 1: Should not contain \"none\" keyword.\n\t// if the shadow has \"none\" keyword, it is not a valid shadow string\n\tif ( shadowValue.includes( 'none' ) ) {\n\t\treturn defaultShadow;\n\t}\n\n\t// Rule 2: Values x, y, blur, spread should be in the order.\n\t//\t\t   Color and inset can be anywhere in the string except in between x, y, blur, spread values.\n\t// Extract length values (x, y, blur, spread) from shadow string\n\t// Regex match groups of 1 to 4 length values.\n\tconst lengthsRegex =\n\t\t/((?:^|\\s+)(-?\\d*\\.?\\d+(?:px|%|in|cm|mm|em|rem|ex|pt|pc|vh|vw|vmin|vmax|ch|lh)?)(?=\\s|$)(?![^(]*\\))){1,4}/g;\n\tconst matches = shadowValue.match( lengthsRegex ) || [];\n\n\t// Rule 3: Should not contain more than one set of x, y, blur, spread values.\n\t// if the string doesn't contain exactly 1 set of x, y, blur, spread values,\n\t// it is not a valid shadow string\n\tif ( matches.length !== 1 ) {\n\t\treturn defaultShadow;\n\t}\n\n\t// Extract length values (x, y, blur, spread) from shadow string\n\tconst lengths = matches[ 0 ]\n\t\t.split( ' ' )\n\t\t.map( ( value ) => value.trim() )\n\t\t.filter( ( value ) => value );\n\n\t// Rule 4: Should contain at least x and y values. Others are optional.\n\tif ( lengths.length < 2 ) {\n\t\treturn defaultShadow;\n\t}\n\n\t// Rule 5: Should not contain more than one \"inset\" (case insensitive) keyword.\n\t// check if the shadow string contains \"inset\" keyword\n\tconst insets = shadowValue.match( /inset/gi ) || [];\n\tif ( insets.length > 1 ) {\n\t\treturn defaultShadow;\n\t}\n\n\t// Strip lengths and inset from shadow string, leaving just color.\n\tconst hasInset = insets.length === 1;\n\tlet colorString = shadowValue.replace( lengthsRegex, '' ).trim();\n\tif ( hasInset ) {\n\t\tcolorString = colorString\n\t\t\t.replace( 'inset', '' )\n\t\t\t.replace( 'INSET', '' )\n\t\t\t.trim();\n\t}\n\n\t// Rule 6: Should not contain more than one color value.\n\t// validate color string with regular expression\n\t// check if color has matching hex, rgb or hsl values\n\tconst colorRegex =\n\t\t/^#([0-9a-f]{3}){1,2}$|^#([0-9a-f]{4}){1,2}$|^(?:rgb|hsl)a?\\(?[\\d*\\.?\\d+%?,?\\/?\\s]*\\)$/gi;\n\tlet colorMatches = ( colorString.match( colorRegex ) || [] )\n\t\t.map( ( value ) => value?.trim() )\n\t\t.filter( ( value ) => value );\n\n\t// If color string has more than one color values, it is not a valid\n\tif ( colorMatches.length > 1 ) {\n\t\treturn defaultShadow;\n\t} else if ( colorMatches.length === 0 ) {\n\t\t// check if color string has multiple named color values separated by space\n\t\tcolorMatches = colorString\n\t\t\t.trim()\n\t\t\t.split( ' ' )\n\t\t\t.filter( ( value ) => value );\n\t\t// If color string has more than one color values, it is not a valid\n\t\tif ( colorMatches.length > 1 ) {\n\t\t\treturn defaultShadow;\n\t\t}\n\t}\n\n\t// Return parsed shadow object.\n\tconst [ x, y, blur, spread ] = lengths;\n\treturn {\n\t\tx,\n\t\ty,\n\t\tblur: blur || defaultShadow.blur,\n\t\tspread: spread || defaultShadow.spread,\n\t\tinset: hasInset,\n\t\tcolor: colorString || defaultShadow.color,\n\t};\n}\n\nexport function shadowObjectToString( shadowObj: ShadowObject ): string {\n\tconst shadowString = `${ shadowObj.x || '0px' } ${ shadowObj.y || '0px' } ${\n\t\tshadowObj.blur || '0px'\n\t} ${ shadowObj.spread || '0px' }`;\n\n\treturn `${ shadowObj.inset ? 'inset' : '' } ${ shadowString } ${\n\t\tshadowObj.color || ''\n\t}`.trim();\n}\n"],
  "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