text: 'use strict';
  
  Object.defineProperty(exports, '__esModule', { value: true });
  
  var jss = require('jss');
  
  var now = Date.now();
  var fnValuesNs = "fnValues" + now;
  var fnRuleNs = "fnStyle" + ++now;
  function functionPlugin() {
    return {
      onCreateRule: function onCreateRule(name, decl, options) {
        if (typeof decl !== 'function') return null;
        var rule = jss.createRule(name, {}, options);
        rule[fnRuleNs] = decl;
        return rule;
      },
      onProcessStyle: function onProcessStyle(style, rule) {
        // We don't ned to extract functions on each style update, since this can
        // happen only one.
        // We don't support function values inside of function rules.
        if (fnValuesNs in rule) return style;
        var fnValues = {};
  
        for (var prop in style) {
          var value = style[prop];
          if (typeof value !== 'function') continue;
          delete style[prop];
          fnValues[prop] = value;
        } // $FlowFixMe
  
  
        rule[fnValuesNs] = fnValues;
        return style;
      },
      onUpdate: function onUpdate(data, rule, sheet, options) {
        var styleRule = rule;
        var fnRule = styleRule[fnRuleNs]; // If we have a style function, the entire rule is dynamic and style object
        // will be returned from that function.
  
        if (fnRule) {
          styleRule.style = fnRule(data);
        }
  
        var fnValues = styleRule[fnValuesNs]; // If we have a fn values map, it is a rule with function values.
  
        if (fnValues) {
          for (var prop in fnValues) {
            styleRule.prop(prop, fnValues[prop](data), options);
          }
        }
      }
    };
  }
  
  exports.default = functionPlugin;
  