text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = undefined;
  
  var _deleteProperty = require('babel-runtime/core-js/reflect/delete-property');
  
  var _deleteProperty2 = _interopRequireDefault(_deleteProperty);
  
  var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  
  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  
  var _createClass2 = require('babel-runtime/helpers/createClass');
  
  var _createClass3 = _interopRequireDefault(_createClass2);
  
  var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  
  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  
  var _inherits2 = require('babel-runtime/helpers/inherits');
  
  var _inherits3 = _interopRequireDefault(_inherits2);
  
  var _weakMap = require('babel-runtime/core-js/weak-map');
  
  var _weakMap2 = _interopRequireDefault(_weakMap);
  
  var _get2 = require('lodash/get');
  
  var _get3 = _interopRequireDefault(_get2);
  
  var _common = require('@ciscospark/common');
  
  var _httpCore = require('@ciscospark/http-core');
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  /**!
   *
   * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
   * @private
   */
  
  var strings = new _weakMap2.default();
  /**
   * @class
   */
  
  var SparkUserAgentInterceptor = function (_Interceptor) {
    (0, _inherits3.default)(SparkUserAgentInterceptor, _Interceptor);
  
    /**
     * @param {Object} [options={}]
     * @param {SparkCore} [options.spark]
     * @private
     * @returns {SparkUserAgentInterceptor}
     */
    function SparkUserAgentInterceptor() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      (0, _classCallCheck3.default)(this, SparkUserAgentInterceptor);
  
      var appName = (0, _get3.default)(options, 'spark.config.appName');
      var appVersion = (0, _get3.default)(options, 'spark.config.appVersion');
  
      var libName = (0, _get3.default)(options, 'spark.ciscospark', false) ? 'ciscospark' : 'spark-js-sdk';
      var libVersion = (0, _get3.default)(options, 'spark.version', 'development');
  
      var _this = (0, _possibleConstructorReturn3.default)(this, (SparkUserAgentInterceptor.__proto__ || (0, _getPrototypeOf2.default)(SparkUserAgentInterceptor)).call(this, options));
  
      if (appName && appVersion) {
        strings.set(_this, appName + '/' + appVersion + ' (' + (_common.inBrowser ? 'web' : 'node') + ') ' + libName + '/' + libVersion);
      } else {
        strings.set(_this, libName + '/' + libVersion + ' (' + (_common.inBrowser ? 'web' : 'node') + ')');
      }
      return _this;
    }
  
    /**
     * @returns {SparkUserAgentInterceptor}
     */
  
  
    (0, _createClass3.default)(SparkUserAgentInterceptor, [{
      key: 'onRequest',
  
  
      /**
       * @see Interceptor#onRequest
       * @param {Object} options
       * @returns {Object}
       */
      value: function onRequest(options) {
        options.headers = options.headers || {};
  
        if (options.uri && (options.uri.includes(this.spark.config.credentials.samlUrl) || options.uri.includes(this.spark.config.credentials.tokenUrl) || options.uri.includes(this.spark.config.credentials.authorizeUrl))) {
          return options;
        }
  
        if ('spark-user-agent' in options.headers) {
          if (!options.headers['spark-user-agent']) {
            (0, _deleteProperty2.default)(options.headers, 'spark-user-agent');
          }
          return options;
        }
  
        options.headers['spark-user-agent'] = strings.get(this);
  
        return options;
      }
    }], [{
      key: 'create',
      value: function create() {
        return new SparkUserAgentInterceptor({ spark: this });
      }
    }]);
    return SparkUserAgentInterceptor;
  }(_httpCore.Interceptor);
  
  exports.default = SparkUserAgentInterceptor;