text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  var _propTypes = require('prop-types');
  
  var _propTypes2 = _interopRequireDefault(_propTypes);
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _link = require('react-toolbox/lib/link');
  
  var _link2 = _interopRequireDefault(_link);
  
  var _asSchemaField = require('./asSchemaField');
  
  var _asSchemaField2 = _interopRequireDefault(_asSchemaField);
  
  var _schemaFormPropTypes = require('./schemaFormPropTypes');
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  Function.prototype.$asyncbind = function anonymous(self, catcher) {
    var resolver = this;
  
    if (catcher === true) {
      if (!Function.prototype.$asyncbind.EagerThenable) Function.prototype.$asyncbind.EagerThenable = function factory(tick) {
        var _tasks = [];
  
        if (!tick) {
          try {
            tick = process.nextTick;
          } catch (ex) {
            tick = function tick(p) {
              setTimeout(p, 0);
            };
          }
        }
  
        function _untask() {
          for (var i = 0; i < _tasks.length; i += 2) {
            var t = _tasks[i + 1],
                r = _tasks[i];
  
            for (var j = 0; j < t.length; j++) {
              t[j].call(null, r);
            }
          }
  
          _tasks = [];
        }
  
        function isThenable(obj) {
          return obj && obj instanceof Object && typeof obj.then === 'function';
        }
  
        function EagerThenable(resolver) {
          function done(inline) {
            var w;
            if (_sync || phase < 0 || (w = _thens[phase]).length === 0) return;
  
            _tasks.push(result, w);
  
            _thens = [[], []];
            if (_tasks.length === 2) inline ? _untask() : tick(_untask);
          }
  
          function resolveThen(x) {
            if (phase >= 0) return;
            if (isThenable(x)) return x.then(resolveThen, rejectThen);
            phase = 0;
            result = x;
            done(true);
          }
  
          function rejectThen(x) {
            if (phase >= 0) return;
            if (isThenable(x)) return x.then(resolveThen, rejectThen);
            phase = 1;
            result = x;
            done(true);
          }
  
          function settler(resolver, rejecter) {
            _thens[0].push(resolver);
  
            _thens[1].push(rejecter);
  
            done();
          }
  
          function toString() {
            return 'EagerThenable{' + {
              '-1': 'pending',
              0: 'resolved',
              1: 'rejected'
            }[phase] + '}=' + result.toString();
          }
  
          function guard() {
            try {
              resolver.call(null, resolveThen, rejectThen);
            } catch (ex) {
              rejectThen(ex);
            }
          }
  
          this.then = settler;
          this.toString = toString;
          var _thens = [[], []],
              _sync = true,
              phase = -1,
              result;
          guard();
          _sync = false;
          done();
        }
  
        EagerThenable.resolve = function (v) {
          return isThenable(v) ? v : {
            then: function then(resolve, reject) {
              return resolve(v);
            }
          };
        };
  
        return EagerThenable;
      }();
      return new Function.prototype.$asyncbind.EagerThenable(boundThen);
    }
  
    if (catcher) {
      if (Function.prototype.$asyncbind.wrapAsyncStack) catcher = Function.prototype.$asyncbind.wrapAsyncStack(catcher);
      return then;
    }
  
    function then(result, error) {
      try {
        return result && result instanceof Object && typeof result.then === 'function' ? result.then(then, catcher) : resolver.call(self, result, error || catcher);
      } catch (ex) {
        return (error || catcher)(ex);
      }
    }
  
    function boundThen(result, error) {
      return resolver.call(self, result, error);
    }
  
    boundThen.then = boundThen;
    return boundThen;
  };
  
  var BoolLink = function (_React$Component) {
    _inherits(BoolLink, _React$Component);
  
    function BoolLink() {
      var _ref;
  
      var _temp, _this, _ret;
  
      _classCallCheck(this, BoolLink);
  
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = BoolLink.__proto__ || Object.getPrototypeOf(BoolLink)).call.apply(_ref, [this].concat(args))), _this), _this.onClick = function () {
        _this.props.onChange(!_this.props.value);
      }, _temp), _possibleConstructorReturn(_this, _ret);
    }
  
    _createClass(BoolLink, [{
      key: 'render',
      value: function render() {
        var label = this.props.formField.titleMap[0].name ? this.props.formField.titleMap[0].name : this.props.formField.titleMap[0];
  
        if (this.props.value) {
          label = this.props.formField.titleMap[1].name ? this.props.formField.titleMap[1].name : this.props.formField.titleMap[1];
        }
  
        return _react2.default.createElement(
          _link2.default,
          _extends({}, this.props.formField.props, { onClick: this.onClick }),
          label
        );
      }
    }]);
  
    return BoolLink;
  }(_react2.default.Component);
  
  BoolLink.propTypes = {
    formField: _schemaFormPropTypes.formShape,
    value: _propTypes2.default.bool,
    onChange: _propTypes2.default.func
  };
  
  exports.default = (0, _asSchemaField2.default)(BoolLink);
  module.exports = exports['default'];