text: 'use strict';
  
  exports.__esModule = true;
  
  var _browser = require('../utils/browser.js');
  
  var browser = _interopRequireWildcard(_browser);
  
  var _document = require('global/document');
  
  var _document2 = _interopRequireDefault(_document);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
                                                                                                                                                             * @file text-track-cue-list.js
                                                                                                                                                             */
  
  
  /**
   * A List of text track cues as defined in:
   * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist
   *
   * interface TextTrackCueList {
   *   readonly attribute unsigned long length;
   *   getter TextTrackCue (unsigned long index);
   *   TextTrackCue? getCueById(DOMString id);
   * };
   *
   * @param {Array} cues A list of cues to be initialized with
   * @class TextTrackCueList
   */
  
  var TextTrackCueList = function () {
    function TextTrackCueList(cues) {
      _classCallCheck(this, TextTrackCueList);
  
      var list = this; // eslint-disable-line
  
      if (browser.IS_IE8) {
        list = _document2['default'].createElement('custom');
  
        for (var prop in TextTrackCueList.prototype) {
          if (prop !== 'constructor') {
            list[prop] = TextTrackCueList.prototype[prop];
          }
        }
      }
  
      TextTrackCueList.prototype.setCues_.call(list, cues);
  
      Object.defineProperty(list, 'length', {
        get: function get() {
          return this.length_;
        }
      });
  
      if (browser.IS_IE8) {
        return list;
      }
    }
  
    /**
     * A setter for cues in this list
     *
     * @param {Array} cues an array of cues
     * @method setCues_
     * @private
     */
  
  
    TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
      var oldLength = this.length || 0;
      var i = 0;
      var l = cues.length;
  
      this.cues_ = cues;
      this.length_ = cues.length;
  
      var defineProp = function defineProp(index) {
        if (!('' + index in this)) {
          Object.defineProperty(this, '' + index, {
            get: function get() {
              return this.cues_[index];
            }
          });
        }
      };
  
      if (oldLength < l) {
        i = oldLength;
  
        for (; i < l; i++) {
          defineProp.call(this, i);
        }
      }
    };
  
    /**
     * Get a cue that is currently in the Cue list by id
     *
     * @param {String} id
     * @method getCueById
     * @return {Object} a single cue
     */
  
  
    TextTrackCueList.prototype.getCueById = function getCueById(id) {
      var result = null;
  
      for (var i = 0, l = this.length; i < l; i++) {
        var cue = this[i];
  
        if (cue.id === id) {
          result = cue;
          break;
        }
      }
  
      return result;
    };
  
    return TextTrackCueList;
  }();
  
  exports['default'] = TextTrackCueList;
  