// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function(window) {
  'use strict';

  /**
   * Don't add new API methods to GrChangeReplyInterfaceOld.
   * All new API should be added to GrChangeReplyInterface.
   * @deprecated
   */
  class GrChangeReplyInterfaceOld {
    constructor(el) {
      this._el = el;
    }

    getLabelValue(label) {
      return this._el.getLabelValue(label);
    }

    setLabelValue(label, value) {
      this._el.setLabelValue(label, value);
    }

    send(opt_includeComments) {
      return this._el.send(opt_includeComments);
    }
  }

  class GrChangeReplyInterface extends GrChangeReplyInterfaceOld {
    constructor(plugin, el) {
      super(el);
      this.plugin = plugin;
    }

    addReplyTextChangedCallback(handler) {
      this.plugin.getDomHook('reply-text').then(el => {
        if (!el.content) { return; }
        el.content.addEventListener('value-changed', e => {
          handler(e.detail.value);
        });
      });
    }
  }

  window.GrChangeReplyInterface = GrChangeReplyInterface;
})(window);

@@ -653,237 +653,131 @@
   * 
-Don't add new API methods to GrChangeReplyInterfaceOld.%0A   * All new API should be added to GrChangeReplyInterface.%0A   * @deprecated%0A   */%0A  class GrChangeReplyInterfaceOld %7B%0A    constructor(el) %7B%0A      this._el = el;%0A    %7D%0A%0A    
+@deprecated%0A   */%0A  function GrChangeReplyInterfaceOld(el) %7B%0A    this._el = el;%0A  %7D%0A%0A  GrChangeReplyInterfaceOld.prototype.
 getL
@@ -781,24 +781,35 @@
 etLabelValue
+ = function
 (label) %7B%0A  
@@ -802,26 +802,24 @@
 on(label) %7B%0A
-  
     return t
@@ -850,25 +850,58 @@
 bel);%0A  
-  
 %7D
+;
 %0A%0A  
-  
+GrChangeReplyInterfaceOld.prototype.
 setLabel
@@ -897,32 +897,43 @@
 pe.setLabelValue
+ = function
 (label, value) %7B
@@ -929,26 +929,24 @@
 l, value) %7B%0A
-  
     this._el
@@ -981,21 +981,65 @@
 ;%0A  
-  
 %7D
+;
 %0A%0A  
-  send
+GrChangeReplyInterfaceOld.prototype.send = function
 (opt
@@ -1054,26 +1054,24 @@
 Comments) %7B%0A
-  
     return t
@@ -1111,170 +1111,1123 @@
 ;%0A  
-  %7D%0A  %7D%0A%0A  class GrChangeReplyInterface extends GrChangeReplyInterfaceOld %7B%0A    constructor(plugin, el) %7B%0A      super(el);%0A      this.plugin = plugin;%0A    %7D%0A%0A    
+%7D;%0A%0A  function GrChangeReplyInterface(plugin, el) %7B%0A    GrChangeReplyInterfaceOld.call(this, el);%0A    this.plugin = plugin;%0A    this._hookName = plugin.getPluginName() + '-autogenerated-'%0A      + String(Math.random()).split('.')%5B1%5D;%0A  %7D%0A  GrChangeReplyInterface.prototype._hookName = '';%0A  GrChangeReplyInterface.prototype._hookClass = null;%0A  GrChangeReplyInterface.prototype._hookPromise = null;%0A%0A  GrChangeReplyInterface.prototype =%0A    Object.create(GrChangeReplyInterfaceOld.prototype);%0A  GrChangeReplyInterface.prototype.constructor = GrChangeReplyInterface;%0A%0A  GrChangeReplyInterface.prototype.getDomHook = function() %7B%0A    if (!this._hookPromise) %7B%0A      this._hookPromise = new Promise((resolve, reject) =%3E %7B%0A        this._hookClass = Polymer(%7B%0A          is: this._hookName,%0A          properties: %7B%0A            plugin: Object,%0A            content: Object,%0A          %7D,%0A          attached() %7B%0A            resolve(this);%0A          %7D,%0A        %7D);%0A        this.plugin.registerCustomComponent('reply-text', this._hookName);%0A      %7D);%0A    %7D%0A    return this._hookPromise;%0A  %7D;%0A%0A  GrChangeReplyInterface.prototype.
 addR
@@ -2249,16 +2249,31 @@
 Callback
+ =%0A    function
 (handler
@@ -2287,23 +2287,16 @@
    this.
-plugin.
 getDomHo
@@ -2298,28 +2298,16 @@
 DomHook(
-'reply-text'
 ).then(e
@@ -2472,20 +2472,17 @@
 );%0A    %7D
-%0A  %7D
+;
 %0A%0A  wind

Revert gr-change-reply-js-api to non-ES6 class