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,IAGXM,eAoBqBC,CAAoBpB,GAAD","sources":["src/preview.js"],"sourcesContent":["(() => {\n\t/**\n\t * Check if the provided value is a numeric.\n\t *\n\t * Thanks to Dan (https://stackoverflow.com/users/17121/dan) for his answer on StackOverflow:\n\t * @see https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number#answer-175787\n\t *\n\t * @param {string|number} str The provided value.\n\t * @return bool\n\t */\n\tconst isNumeric = (str) => {\n\n\t\t// Number is a numeric.\n\t\tif ('number' === typeof str) return true;\n\n\t\t// We only process strings.\n\t\tif ('string' !== typeof str) return false;\n\n\t\t// Use type coercion to parse the entirety of the string (`parseFloat` alone does not do this) and ensure strings of whitespace fail.\n\t\treturn (!isNaN(str) && !isNaN(parseFloat(str)));\n\n\t};\n\n\t/**\n\t * Generate value from color object.\n\t *\n\t * @param {Object} value The value.\n\t * @return string\n\t */\n\tconst generateStringValue = (value) => {\n\n\t\talphaEnabled = false;\n\n\t\tif (value.r || value.g || value.b) {\n\t\t\tcolorMode = \"undefined\" !== typeof value.a ? 'rgba' : 'rgb';\n\t\t\talphaEnabled = 'rgba' === colorMode ? true : alphaEnabled;\n\n\t\t\tpos1 = value.r;\n\t\t\tpos2 = value.g;\n\t\t\tpos3 = value.b;\n\t\t\tpos4 = 'rgba' === colorMode ? value.a : 1;\n\t\t} else if (value.h || value.s) {\n\t\t\tpos1 = value.h;\n\n\t\t\tif (value.l) {\n\t\t\t\tcolorMode = \"undefined\" !== typeof value.a ? 'hsla' : 'hsl';\n\t\t\t\tpos2 = isNumeric(value.l) ? value.l + '%' : value.l;\n\t\t\t} else if (value.v) {\n\t\t\t\tcolorMode = \"undefined\" !== typeof value.a ? 'hvla' : 'hvl';\n\t\t\t\tpos2 = isNumeric(value.v) ? value.v + '%' : value.v;\n\t\t\t}\n\n\t\t\talphaEnabled = 'hsla' === colorMode || 'hsva' === colorMode ? true : alphaEnabled;\n\n\t\t\tpos3 = isNumeric(value) ? value.s + '%' : value.s;\n\t\t\tpos4 = alphaEnabled ? value.a : 1;\n\t\t}\n\n\t\tif (alphaEnabled) {\n\t\t\tformattedValue = colorMode + '(' + pos1 + ', ' + pos2 + ', ' + pos3 + ', ' + pos4 + ')';\n\t\t} else {\n\t\t\tformattedValue = colorMode + '(' + pos1 + ', ' + pos2 + ', ' + pos3 + ')';\n\t\t}\n\n\t\treturn formattedValue;\n\n\t};\n\n\t/**\n\t * Function to hook into `kirkiPostMessageStylesOutput` filter.\n\t *\n\t * @param {string} styles The styles to be filtered.\n\t * @param {string|Object|int} value The control's value.\n\t * @param {Object} output The control's output argument.\n\t * @param {string} controlType The control type.\n\t *\n\t * @return {string} The filtered styles.\n\t */\n\tconst stylesOutput = (styles, value, output, controlType) => {\n\n\t\tif ('kirki-react-colorful' !== controlType) return styles;\n\t\tif ('string' === typeof value || 'number' === typeof value) return styles;\n\n\t\tstyles += output.element + '{'\n\t\t\t+ output.property + ': ' + generateStringValue(value) + ';\\\n\t\t}';\n\n\t\treturn styles;\n\n\t};\n\n\t// Hook the function to the `kirkiPostMessageStylesOutput` filter.\n\twp.hooks.addFilter('kirkiPostMessageStylesOutput', 'kirki', stylesOutput);\n})();\n"],"names":["isNumeric","str","isNaN","parseFloat","wp","hooks","addFilter","styles","value","output","controlType","element","property","alphaEnabled","r","g","b","colorMode","a","pos1","pos2","pos3","pos4","h","s","l","v","formattedValue","generateStringValue"],"version":3,"file":"preview.js.map"}