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; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/*
  ## Why does this exist?!?

  `Ember.Map` was a private API provided by Ember (for quite some time).
  Unfortunately, ember-data made `Ember.Map` part of its public API surface via
  documentation blocks.

  `Ember.Map` will be deprecated and removed from Ember "soon"
  (https://github.com/emberjs/rfcs/pull/237) and we would like to confirm that
  Ember Data will work without deprecation before and after that happens.

  `Ember.Map` differs from native `Map` in a few ways:

  * `Ember.Map` has custom `copy` and `isEmpty` methods which are not present in native `Map`
  * `Ember.Map` adds a static `create` method (which simply instantiates itself with `new Ember.Map()`)
  * `Ember.Map` does not accept constructor arguments
  * `Ember.Map` does not have:
    * `@@species`
    * `@@iterator`
    * `entries`
    * `values`

  This implementation adds a deprecated backwards compatibility for:

  * `copy`
  * `isEmpty`

  ## Why is this written this way?!?

  This is needed because `Map` requires instantiation with `new` and by default
  Babel transpilation will do `superConstructor.apply(this, arguments)` which
  throws an error with native `Map`.

  The desired code (if we lived in an "only native class" world) would be:

  ```js
  export default class MapWithDeprecations extends Map {
    constructor(options) {
      super();
      this.defaultValue = options.defaultValue;
    }

    get(key) {
      let hasValue = this.has(key);

      if (hasValue) {
        return super.get(key);
      } else {
        let defaultValue = this.defaultValue(key);
        this.set(key, defaultValue);
        return defaultValue;
      }
    }
  }
  ```
*/
var MapWithDeprecations = function () {
  function MapWithDeprecations(options) {
    _classCallCheck(this, MapWithDeprecations);

    this._map = new Map();
  }

  MapWithDeprecations.prototype.copy = function copy() {
    (true && !(false) && Ember.deprecate('Calling `.copy()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.copy', until: '3.5.0' }));

    // can't just pass `this._map` here because IE11 doesn't accept
    // constructor args with its `Map`

    var newMap = new MapWithDeprecations();
    this._map.forEach(function (value, key) {
      newMap.set(key, value);
    });

    return newMap;
  };

  MapWithDeprecations.prototype.isEmpty = function isEmpty() {
    (true && !(false) && Ember.deprecate('Calling `.isEmpty()` on a map generated by ember-data is deprecated, please migrate to using native Map functionality only.', false, { id: 'ember-data.map.isEmpty', until: '3.5.0' }));


    return this.size === 0;
  };

  // proxy all normal Map methods to the underlying Map


  MapWithDeprecations.prototype.clear = function clear() {
    var _map;

    return (_map = this._map).clear.apply(_map, arguments);
  };

  MapWithDeprecations.prototype.delete = function _delete() {
    var _map2;

    return (_map2 = this._map).delete.apply(_map2, arguments);
  };

  MapWithDeprecations.prototype.entries = function entries() {
    var _map3;

    return (_map3 = this._map).entries.apply(_map3, arguments);
  };

  MapWithDeprecations.prototype.forEach = function forEach() {
    var _map4;

    return (_map4 = this._map).forEach.apply(_map4, arguments);
  };

  MapWithDeprecations.prototype.get = function get() {
    var _map5;

    return (_map5 = this._map).get.apply(_map5, arguments);
  };

  MapWithDeprecations.prototype.has = function has() {
    var _map6;

    return (_map6 = this._map).has.apply(_map6, arguments);
  };

  MapWithDeprecations.prototype.keys = function keys() {
    var _map7;

    return (_map7 = this._map).keys.apply(_map7, arguments);
  };

  MapWithDeprecations.prototype.set = function set() {
    var _map8;

    return (_map8 = this._map).set.apply(_map8, arguments);
  };

  MapWithDeprecations.prototype.values = function values() {
    var _map9;

    return (_map9 = this._map).values.apply(_map9, arguments);
  };

  _createClass(MapWithDeprecations, [{
    key: 'size',
    get: function get() {
      return this._map.size;
    }
  }]);

  return MapWithDeprecations;
}();

export default MapWithDeprecations;