import { RULESET, KEYFRAMES, COMMENT, DECLARATION, IMPORT, LAYER } from './Enum.mjs';
import { sizeof, strlen } from './Utility.mjs';

/**
 * @param {object[]} children
 * @param {function} callback
 * @return {string}
 */
function serialize$1 (children, callback) {
	var output = '';
	var length = sizeof(children);

	for (var i = 0; i < length; i++)
		output += callback(children[i], i, children, callback) || '';

	return output
}

/**
 * @param {object} element
 * @param {number} index
 * @param {object[]} children
 * @param {function} callback
 * @return {string}
 */
function stringify (element, index, children, callback) {
	switch (element.type) {
		case LAYER: if (element.children.length) break
		case IMPORT: case DECLARATION: return element.return = element.return || element.value
		case COMMENT: return ''
		case KEYFRAMES: return element.return = element.value + '{' + serialize$1(element.children, callback) + '}'
		case RULESET: element.value = element.props.join(',');
	}

	return strlen(children = serialize$1(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
}

export { serialize$1 as serialize, stringify };
//# sourceMappingURL=Serializer.mjs.map
