text: /**
   * The MIT License (MIT)
   *
   * Copyright (c) 2015 Famous Industries Inc.
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in
   * all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   * THE SOFTWARE.
   */
  
  'use strict';
  
  import { UIEvent } from './UIEvent';
  
  var EMPTY_ARRAY = [];
  
  /**
   * See [Touch Interface](http://www.w3.org/TR/2013/REC-touch-events-20131010/#touch-interface).
   *
   * @class Touch
   * @private
   *
   * @param {Touch} touch The native Touch object.
   */
  class Touch {
    constructor(touch) {
      // interface Touch {
      //     readonly    attribute long        identifier;
      //     readonly    attribute EventTarget target;
      //     readonly    attribute double      screenX;
      //     readonly    attribute double      screenY;
      //     readonly    attribute double      clientX;
      //     readonly    attribute double      clientY;
      //     readonly    attribute double      pageX;
      //     readonly    attribute double      pageY;
      // };
  
      /**
       * @name Touch#identifier
       * @type Number
       */
      this.identifier = touch.identifier;
  
      /**
       * @name Touch#screenX
       * @type Number
       */
      this.screenX = touch.screenX;
  
      /**
       * @name Touch#screenY
       * @type Number
       */
      this.screenY = touch.screenY;
  
      /**
       * @name Touch#clientX
       * @type Number
       */
      this.clientX = touch.clientX;
  
      /**
       * @name Touch#clientY
       * @type Number
       */
      this.clientY = touch.clientY;
  
      /**
       * @name Touch#pageX
       * @type Number
       */
      this.pageX = touch.pageX;
  
      /**
       * @name Touch#pageY
       * @type Number
       */
      this.pageY = touch.pageY;
    }
  
  }
  
  /**
   * Normalizes the browser's native TouchList by converting it into an array of
   * normalized Touch objects.
   *
   * @method  cloneTouchList
   * @private
   *
   * @param  {TouchList} touchList    The native TouchList array.
   * @return {Array.<Touch>}          An array of normalized Touch objects.
   */
  function cloneTouchList(touchList) {
    if (!touchList) return EMPTY_ARRAY;
    // interface TouchList {
    //     readonly    attribute unsigned long length;
    //     getter Touch? item (unsigned long index);
    // };
  
    var touchListArray = [];
    for (var i = 0; i < touchList.length; i++) {
      touchListArray[i] = new Touch(touchList[i]);
    }
    return touchListArray;
  }
  
  /**
   * See [Touch Event Interface](http://www.w3.org/TR/2013/REC-touch-events-20131010/#touchevent-interface).
   *
   * @class TouchEvent
   * @augments UIEvent
   *
   * @param {Event} ev The native DOM event.
   */
  class TouchEvent extends UIEvent {
    constructor(ev) {
      // interface TouchEvent : UIEvent {
      //     readonly    attribute TouchList touches;
      //     readonly    attribute TouchList targetTouches;
      //     readonly    attribute TouchList changedTouches;
      //     readonly    attribute boolean   altKey;
      //     readonly    attribute boolean   metaKey;
      //     readonly    attribute boolean   ctrlKey;
      //     readonly    attribute boolean   shiftKey;
      // };
      super(ev);
  
      /**
       * @name TouchEvent#touches
       * @type Array.<Touch>
       */
      this.touches = cloneTouchList(ev.touches);
  
      /**
       * @name TouchEvent#targetTouches
       * @type Array.<Touch>
       */
      this.targetTouches = cloneTouchList(ev.targetTouches);
  
      /**
       * @name TouchEvent#changedTouches
       * @type TouchList
       */
      this.changedTouches = cloneTouchList(ev.changedTouches);
  
      /**
       * @name TouchEvent#altKey
       * @type Boolean
       */
      this.altKey = ev.altKey;
  
      /**
       * @name TouchEvent#metaKey
       * @type Boolean
       */
      this.metaKey = ev.metaKey;
  
      /**
       * @name TouchEvent#ctrlKey
       * @type Boolean
       */
      this.ctrlKey = ev.ctrlKey;
  
      /**
       * @name TouchEvent#shiftKey
       * @type Boolean
       */
      this.shiftKey = ev.shiftKey;
  
    }
  
    /**
     * Return the name of the event type
     *
     * @method
     *
     * @return {String} Name of the event type
     */
    toString() {
      return 'TouchEvent';
    };
  
  }
  
  export { TouchEvent };
  