generateCSS = function generateCSS(selector
/* : string */
, styleTypes
/* : SheetDefinition[] */
, selectorHandlers
/* : SelectorHandler[] */
, stringHandlers
/* : StringHandlers */
, useImportant
/* : boolean */
)
/* : string[] */
{
  var merged = new OrderedElements();

  for (var i = 0; i < styleTypes.length; i++) {
    merged.addStyleType(styleTypes[i]);
  }

  var plainDeclarations = new OrderedElements();
  var generatedStyles = []; // TODO(emily): benchmark this to see if a plain for loop would be faster.

  merged.forEach(function (val, key) {
    // For each key, see if one of the selector handlers will handle these
    // styles.
    var foundHandler = selectorHandlers.some(function (handler) {
      var result = handler(key, selector, function (newSelector) {
        return generateCSS(newSelector, [val], selectorHandlers, stringHandlers, useImportant);
      });

      if (result != null) {
        // If the handler returned something, add it to the generated
        // CSS and stop looking for another handler.
        if (Array.isArray(result)) {
          generatedStyles.push.apply(generatedStyles, _toConsumableArray(result));
        } else {
          // eslint-disable-next-line
          console.warn('WARNING: Selector handlers should return an array of rules.' + 'Returning a string containing multiple rules is deprecated.', handler);
          generatedStyles.push("@media all {".concat(result, "}"));
        }

        return true;
      }
    }); // If none of the handlers handled it, add it to the list of plain
    // style declarations.

    if (!foundHandler) {
      plainDeclarations.set(key, val, true);
    }
  });
  var generatedRuleset = generateCSSRuleset(selector, plainDeclarations, stringHandlers, useImportant, selectorHandlers);

  if (generatedRuleset) {
    generatedStyles.unshift(generatedRuleset);
  }

  return generatedStyles;
}
Generate CSS for a selector and some styles.

This function handles the media queries and pseudo selectors that can be used
in aphrodite styles.

@param {string} selector: A base CSS selector for the styles to be generated
    with.
@param {Object} styleTypes: A list of properties of the return type of
    StyleSheet.create, e.g. [styles.red, styles.blue].
@param {Array.<SelectorHandler>} selectorHandlers: A list of selector
    handlers to use for handling special selectors. See
    `defaultSelectorHandlers`.
@param stringHandlers: See `generateCSSRuleset`
@param useImportant: See `generateCSSRuleset`

To actually generate the CSS special-construct-less styles are passed to
`generateCSSRuleset`.

For instance, a call to

    generateCSS(".foo", [{
      color: "red",
      "@media screen": {
        height: 20,
        ":hover": {
          backgroundColor: "black"
        }
      },
      ":active": {
        fontWeight: "bold"
      }
    }], defaultSelectorHandlers);

with the default `selectorHandlers` will make 5 calls to
`generateCSSRuleset`:

    generateCSSRuleset(".foo", { color: "red" }, ...)
    generateCSSRuleset(".foo:active", { fontWeight: "bold" }, ...)
    // These 2 will be wrapped in @media screen {}
    generateCSSRuleset(".foo", { height: 20 }, ...)
    generateCSSRuleset(".foo:hover", { backgroundColor: "black" }, ...)