window.__require = function e(t, n, r) {
  function s(o, u) {
    if (!n[o]) {
      if (!t[o]) {
        var b = o.split("/");
        b = b[b.length - 1];
        if (!t[b]) {
          var a = "function" == typeof __require && __require;
          if (!u && a) return a(b, !0);
          if (i) return i(b, !0);
          throw new Error("Cannot find module '" + o + "'");
        }
        o = b;
      }
      var f = n[o] = {
        exports: {}
      };
      t[o][0].call(f.exports, function(e) {
        var n = t[o][1][e];
        return s(n || e);
      }, f, f.exports, e, t, n, r);
    }
    return n[o].exports;
  }
  var i = "function" == typeof __require && __require;
  for (var o = 0; o < r.length; o++) s(r[o]);
  return s;
}({
  defaultData: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "ae1e7lMU69J9bCL3svfGQhk", "defaultData");
    "use strict";
    exports.__esModule = true;
    exports.defaultData = void 0;
    var defaultData = {
      maxWrongNumber: 4,
      startAudio: "http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3",
      endAudio: "http://staging-teach.cdn.ireadabc.com/fd8a2b8eeb4abbe7683d30e728ece184.mp3",
      question_arr: [ {
        question_audio_url: "",
        option_arr: [ {
          pic_url: "http://staging-teach.cdn.ireadabc.com/5ba43828aef85c585743a0c898b43c42.png",
          audio_url: "http://staging-teach.cdn.ireadabc.com/ce3337620f22232dd15c29c66af57736.mp3",
          is_right: true
        }, {
          pic_url: "http://staging-teach.cdn.ireadabc.com/d69dee492fd35b3c066207c3fc8e3258.png",
          audio_url: "http://staging-teach.cdn.ireadabc.com/b4d95069fcc91976740461b9061a303a.mp3",
          is_right: false
        }, {
          pic_url: "http://staging-teach.cdn.ireadabc.com/48ecba3519b1d58a1fa434ae694fc831.png",
          audio_url: "http://staging-teach.cdn.ireadabc.com/b4d95069fcc91976740461b9061a303a.mp3",
          is_right: false
        }, {
          pic_url: "http://staging-teach.cdn.ireadabc.com/44464e706225cfe43e918bf1167a2ac1.png",
          audio_url: "http://staging-teach.cdn.ireadabc.com/e62f0e83bc744a6e508fa23aaa656792.mp3",
          is_right: false
        }, {
          pic_url: "http://staging-teach.cdn.ireadabc.com/251667ae3d4921582392f6bc42bd2a96.png",
          audio_url: "http://staging-teach.cdn.ireadabc.com/f4e0925dec2f24505872b1c367343a6e.mp3",
          is_right: false
        } ],
        audio_url: "http://staging-teach.cdn.ireadabc.com/e62f0e83bc744a6e508fa23aaa656792.mp3"
      } ]
    };
    exports.defaultData = defaultData;
    cc._RF.pop();
  }, {} ],
  op_09: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "66cdc2ew0ZDp7uvRjeQwD7o", "op_09");
    "use strict";
    var _util = require("../script/util");
    var _defaultData = require("../script/defaultData");
    function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
      try {
        var info = gen[key](arg);
        var value = info.value;
      } catch (error) {
        reject(error);
        return;
      }
      info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
    }
    function _asyncToGenerator(fn) {
      return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
          var gen = fn.apply(self, args);
          function _next(value) {
            asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
          }
          function _throw(err) {
            asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
          }
          _next(void 0);
        });
      };
    }
    cc.Class({
      extends: cc.Component,
      properties: {},
      onLoad: function onLoad() {
        this.initSceneData();
        this.initSize();
      },
      onDestroy: function onDestroy() {
        void 0 !== this.timeA && clearTimeout(this.timeA);
      },
      _imageResList: null,
      _audioResList: null,
      _animaResList: null,
      initSceneData: function initSceneData() {
        this._imageResList = [];
        this._audioResList = [];
        this._animaResList = [];
      },
      _designSize: null,
      _frameSize: null,
      _mapScaleMin: null,
      _mapScaleMax: null,
      _cocosScale: null,
      initSize: function initSize() {
        var screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height;
        var design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height;
        var f = screen_size >= design_size;
        cc.Canvas.instance.fitHeight = f;
        cc.Canvas.instance.fitWidth = !f;
        var frameSize = cc.view.getFrameSize();
        this._frameSize = frameSize;
        this._designSize = cc.view.getDesignResolutionSize();
        var sx = cc.winSize.width / frameSize.width;
        var sy = cc.winSize.height / frameSize.height;
        this._cocosScale = Math.min(sx, sy);
        sx = frameSize.width / this._designSize.width;
        sy = frameSize.height / this._designSize.height;
        this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
        this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
      },
      start: function start() {
        var _this = this;
        var getData = this.getData.bind(this);
        window && window.courseware && (getData = window.courseware.getData);
        getData(function(data) {
          console.log("data:" + JSON.stringify(data));
          _this.data = data || _this.getDefaultData();
          _this.data = JSON.parse(JSON.stringify(_this.data));
          _this.preloadItem();
        });
      },
      getData: function getData(func) {
        if (window && window.courseware) {
          window.courseware.getData(func, "scene");
          return;
        }
        var middleLayer = cc.find("middleLayer");
        if (middleLayer) {
          var middleLayerComponent = middleLayer.getComponent("middleLayer");
          middleLayerComponent.getData(func);
          return;
        }
        func(this.getDefaultData());
      },
      getDefaultData: function getDefaultData() {
        return _defaultData.defaultData;
      },
      preloadItem: function preloadItem() {
        this.addPreloadImage();
        this.addPreloadAudio();
        this.addPreloadAnima();
        this.preload();
      },
      addPreloadImage: function addPreloadImage() {
        var _this$_imageResList;
        (_this$_imageResList = this._imageResList).push.apply(_this$_imageResList, this.data.question_arr.map(function(question) {
          return question.option_arr.map(function(option) {
            return {
              url: option.pic_url
            };
          });
        }).flat());
      },
      addPreloadAudio: function addPreloadAudio() {
        var _this$_audioResList, _this$_audioResList2;
        this._audioResList.push(this.data.startAudio);
        this._audioResList.push(this.data.endAudio);
        (_this$_audioResList = this._audioResList).push.apply(_this$_audioResList, this.data.question_arr.map(function(question) {
          return question.option_arr.map(function(option) {
            return {
              url: option.audio_url
            };
          });
        }).flat());
        (_this$_audioResList2 = this._audioResList).push.apply(_this$_audioResList2, this.data.question_arr.map(function(question) {
          return {
            url: question.question_audio_url
          };
        }));
      },
      addPreloadAnima: function addPreloadAnima() {},
      preload: function preload() {
        var _this2 = this;
        var preloadArr = [].concat(this._imageResList, this._audioResList, this._animaResList);
        cc.assetManager.loadAny(preloadArr, null, null, function(err, data) {
          if (window && window["air"]) {
            cc.find("Canvas").opacity = 0;
            window.air.onCourseInScreen = function(next) {
              cc.find("Canvas").opacity = 255;
              _this2.loadEnd();
              next();
            };
            window.air.hideAirClassLoading();
          } else _this2.loadEnd();
          cc.debug.setDisplayStats(false);
        });
      },
      loadEnd: function loadEnd() {
        this.initData();
        this.initView();
        this.initListener();
      },
      initData: function initData() {
        this.status = {
          currentQuestionIdx: 0,
          wrongTime: 0
        };
      },
      initView: function initView() {
        var _this3 = this;
        this.refreshCoolCatPosition();
        this.coolCatSpeakStart(function() {
          _this3.showSubmitBtn();
          _this3.jumpToQuestion(_this3.status.currentQuestionIdx);
        });
      },
      refreshCoolCatPosition: function refreshCoolCatPosition() {},
      jumpToQuestion: function jumpToQuestion(questionIdx) {
        var _this4 = this;
        var questionAudioUrl = this.data.question_arr[questionIdx].audio_url;
        this.playAudioByUrl(questionAudioUrl);
        var box = cc.find("Canvas/bg/box");
        box.removeAllChildren();
        var canvasWidth = cc.find("Canvas").width;
        var canvasHeight = cc.find("Canvas").height;
        var optionNum = this.data.question_arr[questionIdx].option_arr.length;
        var maxOptionHeight = 500;
        var maxOptionWidth = .95 * canvasWidth / optionNum;
        var arr = (0, _util.randomSortByArr)(this.data.question_arr[questionIdx].option_arr);
        arr.forEach(function() {
          var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(option, idx) {
            var optionNode;
            return regeneratorRuntime.wrap(function _callee$(_context) {
              while (1) switch (_context.prev = _context.next) {
               case 0:
                _context.next = 2;
                return _this4.createOption(option);

               case 2:
                optionNode = _context.sent;
                optionNode.name = "option_" + idx;
                optionNode.x = (idx - (arr.length - 1) / 2) * maxOptionWidth - box.x;
                optionNode.y = canvasHeight / 2 - box.y - 300;
                optionNode.scale = 0;
                optionNode.parent = box;
                cc.tween(optionNode).to(.1, {
                  scale: Math.min(.8 * maxOptionWidth / optionNode.width, maxOptionHeight / optionNode.height)
                }).start();

               case 9:
               case "end":
                return _context.stop();
              }
            }, _callee);
          }));
          return function(_x, _x2) {
            return _ref.apply(this, arguments);
          };
        }());
      },
      createOption: function createOption(optionData) {
        var _this5 = this;
        return new Promise(function(resolve, reject) {
          var optionNode = cc.instantiate(cc.find("option"));
          _this5.loadSpriteByUrl(optionNode, optionData.pic_url, function() {
            resolve(optionNode);
          });
          optionNode.optionData = optionData;
          optionNode.optionData.selected = false;
          var box = cc.find("Canvas/bg/box");
          optionNode.on(cc.Node.EventType.TOUCH_START, function(event) {
            if (optionNode.optionData.selected) return;
            var location = event.getLocation();
            optionNode.startLocation = location;
            optionNode.startPos = {
              x: optionNode.x,
              y: optionNode.y
            };
            var selectedNum = box.children.filter(function(child) {
              return true == child.optionData.selected;
            }).length;
            optionNode.zIndex = selectedNum;
            _this5.optionJump(optionNode);
            _this5.playAudioByUrl(optionNode.optionData.audio_url);
          });
          optionNode.on(cc.Node.EventType.TOUCH_MOVE, function(event) {
            if (optionNode.optionData.selected) return;
            var location = event.getLocation();
            optionNode.x = optionNode.startPos.x + (location.x - optionNode.startLocation.x);
            optionNode.y = optionNode.startPos.y + (location.y - optionNode.startLocation.y);
          });
          optionNode.on(cc.Node.EventType.TOUCH_END, function(event) {
            if (optionNode.optionData.selected) return;
            var rectOption = optionNode.getBoundingBox();
            if (!cc.Intersection.rectRect(box, rectOption)) {
              cc.tween(optionNode).to(.05, {
                x: optionNode.startPos.x,
                y: optionNode.startPos.y
              }, cc.easing.quadOut).start();
              _this5.playEffect("flyBack");
              return;
            }
            cc.tween(optionNode).to(.2, {
              x: 0,
              y: 100
            }, cc.easing.quadOut).start();
            _this5.boxJump();
            optionNode.optionData.selected = true;
          });
          return optionNode;
        });
      },
      optionJump: function optionJump(node, time) {
        void 0 === time && (time = .1);
        if (node.baseScale) return;
        node.baseScale = node.scaleX;
        cc.tween(node).to(time, {
          scaleX: 1.1 * node.baseScale,
          scaleY: 1.1 * node.baseScale
        }).to(time, {
          scaleX: 1 * node.baseScale,
          scaleY: 1 * node.baseScale
        }).call(function() {
          node.baseScale = null;
        }).start();
      },
      initListener: function initListener() {
        var _this6 = this;
        var btnSubmit = cc.find("Canvas/bg/btnSubmit");
        btnSubmit.on("click", function() {
          _this6.optionJump(btnSubmit, .05);
          _this6.playEffect("submit");
          var box = cc.find("Canvas/bg/box");
          box.children.every(function(child) {
            return child.optionData.selected == child.optionData.is_right;
          }) ? _this6.onAnswerRight() : _this6.coolCatSpeakWrong(function() {
            _this6.status.wrongTime++;
            _this6.status.wrongTime < _this6.data.maxWrongNumber ? _this6.onAnswerWrong() : _this6.onAnswerWrongTwice();
          });
        });
        var btnNext = cc.find("Canvas/bg/btnNext");
        btnNext.on("click", function() {
          _this6.optionJump(btnNext, .05);
        });
        var btnCoolCat = cc.find("Canvas/bg/catFrame/BtnCoolCat");
        btnCoolCat.on("click", function() {
          var cat = cc.find("Canvas/bg/catFrame/CoolCat");
          var btn = cc.find("Canvas/bg/btnReplay");
          if (btn.active) {
            (0, _util.playDragonBoneAnimation)(cat, "finish", -1);
            _this6.playAudioByUrl(_this6.data.endAudio, function() {
              (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
              _this6.showNextBtn();
            });
          } else {
            (0, _util.playDragonBoneAnimation)(cat, "begin", -1);
            _this6.playAudioByUrl(_this6.data.startAudio, function() {
              (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
              _this6.showSubmitBtn();
              _this6.jumpToQuestion(_this6.status.currentQuestionIdx);
            });
          }
        });
      },
      onAnswerRight: function onAnswerRight() {
        var _this7 = this;
        this.coolCatSpeakRight(function() {
          _this7.nextQuestion();
        });
      },
      onAnswerWrong: function onAnswerWrong() {
        var box = cc.find("Canvas/bg/box");
        box.children.filter(function(child) {
          return child.optionData.selected;
        }).forEach(function(child) {
          child.optionData.selected = false;
          cc.tween(child).to(.2, {
            x: child.startPos.x,
            y: child.startPos.y
          }).start();
        });
        this.playEffect("flyBackAll");
      },
      onAnswerWrongTwice: function onAnswerWrongTwice() {
        this.status.currentQuestionIdx = this.data.question_arr.length;
        this.nextQuestion();
        this.playEffect("jumpAll");
      },
      timeA: null,
      nextQuestion: function nextQuestion() {
        var _this8 = this;
        var box = cc.find("Canvas/bg/box");
        box.children.forEach(function(child) {
          cc.tween(child).to(.1, {
            scaleX: 0,
            scaleY: 0
          }).removeSelf().start();
        });
        this.status.currentQuestionIdx++;
        if (this.status.currentQuestionIdx < this.data.question_arr.length) this.timeA = setTimeout(function() {
          _this8.jumpToQuestion(_this8.status.currentQuestionIdx);
        }, 100); else {
          this.hideSubmitBtn();
          this.coolCatSpeakEnd(function() {
            _this8.showNextBtn();
          });
        }
      },
      boxJump: function boxJump() {
        var boxBehind = cc.find("Canvas/bg/box_behind");
        var boxFront = cc.find("Canvas/bg/box_front");
        this.playEffect("boxJump");
        cc.tween(boxFront).to(.1, {
          scaleX: 1.02,
          scaleY: 1.02
        }).to(.1, {
          scaleX: 1,
          scaleY: 1
        }).start();
        cc.tween(boxBehind).to(.1, {
          scaleX: 1.02,
          scaleY: 1.02
        }).to(.1, {
          scaleX: 1,
          scaleY: 1
        }).start();
      },
      showSubmitBtn: function showSubmitBtn() {
        var submitBtn = cc.find("Canvas/bg/btnSubmit");
        if (submitBtn.showed) return;
        submitBtn.showed = true;
        cc.tween(submitBtn).by(1, {
          y: submitBtn.height
        }).start();
      },
      hideSubmitBtn: function hideSubmitBtn() {
        var submitBtn = cc.find("Canvas/bg/btnSubmit");
        if (!submitBtn.showed) return;
        submitBtn.showed = false;
        submitBtn.off("click");
        cc.tween(submitBtn).by(1, {
          y: -submitBtn.height
        }).start();
      },
      showNextBtn: function showNextBtn() {
        this.showRestartBtn();
        var btnNext = cc.find("Canvas/bg/btnNext");
        btnNext.active = true;
        (0, _util.onHomeworkFinish)();
      },
      coolCatSpeakStart: function coolCatSpeakStart(cb) {
        var cat = cc.find("Canvas/bg/catFrame/CoolCat");
        (0, _util.playDragonBoneAnimation)(cat, "begin", -1);
        this.playAudioByUrl(this.data.startAudio, function() {
          (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
          cb();
        });
      },
      coolCatSpeakRight: function coolCatSpeakRight(cb) {
        var cat = cc.find("Canvas/bg/catFrame/CoolCat");
        (0, _util.playDragonBoneAnimation)(cat, "right", -1);
        this.playEffect("CoolCatRight", function() {
          (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
          cb();
        });
      },
      coolCatSpeakWrong: function coolCatSpeakWrong(cb) {
        var cat = cc.find("Canvas/bg/catFrame/CoolCat");
        (0, _util.playDragonBoneAnimation)(cat, "wrong", -1);
        this.playEffect("CoolCatWrong", function() {
          (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
          cb();
        });
      },
      coolCatSpeakEnd: function coolCatSpeakEnd(cb) {
        var cat = cc.find("Canvas/bg/catFrame/CoolCat");
        (0, _util.playDragonBoneAnimation)(cat, "finish", -1);
        this.playAudioByUrl(this.data.endAudio, function() {
          (0, _util.playDragonBoneAnimation)(cat, "normal", -1);
          cb();
        });
      },
      showRestartBtn: function showRestartBtn() {
        var btn = cc.find("Canvas/bg/btnReplay");
        btn.active = true;
        btn.off("click");
        btn.on("click", function() {
          var middleLayer = cc.find("middleLayer");
          middleLayer ? middleLayer.getComponent("middleLayer").reloadBundle() : console.log("\u6ca1\u6709middleLayer");
        });
        var circle = cc.find("Canvas/bg/btnReplay/bg_circle");
        cc.tween(circle).set({
          scale: .8,
          opacity: 255
        }).to(2, {
          scale: 1.2,
          opacity: 0
        }).union().repeatForever().start();
      },
      hideRestartBtn: function hideRestartBtn() {
        console.log("hideRestartBtn");
        var btn = cc.find("Canvas/bg/btnReplay");
        btn.active = false;
        var circle = cc.find("Canvas/bg/btnReplay/bg_circle");
        circle.stopAllActions();
        circle.scale = .8;
        circle.opacity = 255;
      },
      loadSpriteByUrl: function loadSpriteByUrl(node, url, cb) {
        cc.loader.load({
          url: url
        }, function(err, img) {
          node || cb && cb();
          var spriteFrame = new cc.SpriteFrame(img);
          var spr = node.getComponent(cc.Sprite);
          spr.spriteFrame = spriteFrame;
          cb && cb();
        });
      },
      currentPlayedAudioId: null,
      stopCurrentPlayedAudio: function stopCurrentPlayedAudio() {
        if (null !== this.currentPlayedAudioId) {
          cc.audioEngine.stop(this.currentPlayedAudioId);
          this.currentPlayedAudioId = null;
        }
      },
      playEffect: function playEffect(name, cb) {
        this.stopCurrentPlayedAudio();
        var audioNode = cc.find("audios/" + name);
        var audioClip = audioNode.getComponent(cc.AudioSource).clip;
        var audioId = cc.audioEngine.play(audioClip, false, .8);
        this.currentPlayedAudioId = audioId;
        cb && cc.audioEngine.setFinishCallback(audioId, cb);
      },
      playAudioByUrl: function playAudioByUrl(audio_url, cb) {
        var _this9 = this;
        void 0 === cb && (cb = null);
        if (!audio_url) {
          cb && cb();
          return;
        }
        this.stopCurrentPlayedAudio();
        cc.assetManager.loadRemote(audio_url.toLowerCase(), function(err, audioClip) {
          var audioId = cc.audioEngine.play(audioClip, false, .8);
          _this9.currentPlayedAudioId = audioId;
          cb && cc.audioEngine.setFinishCallback(audioId, cb);
        });
      }
    });
    cc._RF.pop();
  }, {
    "../script/defaultData": "defaultData",
    "../script/util": "util"
  } ],
  util: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "afd6eipB41OdKXErpRklnGh", "util");
    "use strict";
    exports.__esModule = true;
    exports.getPosByAngle = getPosByAngle;
    exports.getAngleByPos = getAngleByPos;
    exports.exchangeNodePos = exchangeNodePos;
    exports.RandomInt = RandomInt;
    exports.randomSortByArr = randomSortByArr;
    exports.setSprNodeMaxLen = setSprNodeMaxLen;
    exports.localPosTolocalPos = localPosTolocalPos;
    exports.worldPosToLocalPos = worldPosToLocalPos;
    exports.getScaleRateBy2Node = getScaleRateBy2Node;
    exports.getDistance = getDistance;
    exports.playAudioByUrl = playAudioByUrl;
    exports.btnClickAnima = btnClickAnima;
    exports.getSpriteFrimeByUrl = getSpriteFrimeByUrl;
    exports.getSprNode = getSprNode;
    exports.getSprNodeByUrl = getSprNodeByUrl;
    exports.playAudio = playAudio;
    exports.asyncDelay = asyncDelay;
    exports.showFireworks = showFireworks;
    exports.asyncTweenTo = asyncTweenTo;
    exports.asyncTweenBy = asyncTweenBy;
    exports.showTrebleFirework = showTrebleFirework;
    exports.onHomeworkFinish = onHomeworkFinish;
    exports.asyncPlayDragonBoneAnimation = asyncPlayDragonBoneAnimation;
    exports.playDragonBoneAnimation = playDragonBoneAnimation;
    exports.FireworkSettings = void 0;
    function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
      try {
        var info = gen[key](arg);
        var value = info.value;
      } catch (error) {
        reject(error);
        return;
      }
      info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
    }
    function _asyncToGenerator(fn) {
      return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
          var gen = fn.apply(self, args);
          function _next(value) {
            asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
          }
          function _throw(err) {
            asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
          }
          _next(void 0);
        });
      };
    }
    function getPosByAngle(angle, len) {
      var radian = angle * Math.PI / 180;
      var x = Math.sin(radian) * len;
      var y = Math.cos(radian) * len;
      return {
        x: x,
        y: y
      };
    }
    function getAngleByPos(px, py, mx, my) {
      var x = Math.abs(px - mx);
      var y = Math.abs(py - my);
      var z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
      var cos = y / z;
      var radina = Math.acos(cos);
      var angle = Math.floor(180 / (Math.PI / radina) * 100) / 100;
      mx > px && my > py && (angle = 180 - angle);
      mx === px && my > py && (angle = 180);
      mx > px && my === py && (angle = 90);
      mx < px && my > py && (angle = 180 + angle);
      mx < px && my === py && (angle = 270);
      mx < px && my < py && (angle = 360 - angle);
      return angle;
    }
    function exchangeNodePos(baseNode, targetNode) {
      return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
    }
    function RandomInt(a, b) {
      void 0 === b && (b = 0);
      var max = Math.max(a, b);
      var min = Math.min(a, b);
      return Math.floor(Math.random() * (max - min) + min);
    }
    function randomSortByArr(arr) {
      var newArr = [];
      var tmpArr = arr.concat();
      while (tmpArr.length > 0) {
        var randomIndex = Math.floor(tmpArr.length * Math.random());
        newArr.push(tmpArr[randomIndex]);
        tmpArr.splice(randomIndex, 1);
      }
      return newArr;
    }
    function setSprNodeMaxLen(sprNode, maxW, maxH) {
      var sx = maxW / sprNode.width;
      var sy = maxH / sprNode.height;
      var s = Math.min(sx, sy);
      sprNode.scale = Math.round(1e3 * s) / 1e3;
    }
    function localPosTolocalPos(baseNode, targetNode) {
      var worldPos = targetNode.parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y));
      var localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
      return localPos;
    }
    function worldPosToLocalPos(worldPos, baseNode) {
      var localPos = baseNode.parent.convertToNodeSpaceAR(cc.v2(worldPos.x, worldPos.y));
      return localPos;
    }
    function getScaleRateBy2Node(baseNode, targetNode, maxFlag) {
      void 0 === maxFlag && (maxFlag = true);
      var worldRect1 = targetNode.getBoundingBoxToWorld();
      var worldRect2 = baseNode.getBoundingBoxToWorld();
      var sx = worldRect1.width / worldRect2.width;
      var sy = worldRect1.height / worldRect2.height;
      return maxFlag ? Math.max(sx, sy) : Math.min(sx, sy);
    }
    function getDistance(start, end) {
      var pos = cc.v2(start.x - end.x, start.y - end.y);
      var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
      return dis;
    }
    function playAudioByUrl(audio_url, cb) {
      void 0 === cb && (cb = null);
      audio_url && cc.assetManager.loadRemote(audio_url, function(err, audioClip) {
        var audioId = cc.audioEngine.play(audioClip, false, .8);
        cb && cc.audioEngine.setFinishCallback(audioId, function() {
          cb();
        });
      });
    }
    function btnClickAnima(btn, time, rate) {
      void 0 === time && (time = .15);
      void 0 === rate && (rate = 1.05);
      btn.tmpScale = btn.scale;
      btn.on(cc.Node.EventType.TOUCH_START, function() {
        cc.tween(btn).to(time / 2, {
          scale: btn.scale * rate
        }).start();
      });
      btn.on(cc.Node.EventType.TOUCH_CANCEL, function() {
        cc.tween(btn).to(time / 2, {
          scale: btn.tmpScale
        }).start();
      });
      btn.on(cc.Node.EventType.TOUCH_END, function() {
        cc.tween(btn).to(time / 2, {
          scale: btn.tmpScale
        }).start();
      });
    }
    function getSpriteFrimeByUrl(url, cb) {
      cc.loader.load({
        url: url
      }, function(err, img) {
        var spriteFrame = new cc.SpriteFrame(img);
        cb && cb(spriteFrame);
      });
    }
    function getSprNode(resName) {
      var sf = cc.find("Canvas/res/img/" + resName).getComponent(cc.Sprite).spriteFrame;
      var node = new cc.Node();
      node.addComponent(cc.Sprite).spriteFrame = sf;
      return node;
    }
    function getSprNodeByUrl(url, cb) {
      var node = new cc.Node();
      var spr = node.addComponent(cc.Sprite);
      getSpriteFrimeByUrl(url, function(sf) {
        spr.spriteFrame = sf;
        cb && cb(spr);
      });
    }
    function playAudio(audioClip, cb) {
      void 0 === cb && (cb = null);
      if (audioClip) {
        var audioId = cc.audioEngine.playEffect(audioClip, false, .8);
        cb && cc.audioEngine.setFinishCallback(audioId, function() {
          cb();
        });
      }
    }
    function asyncDelay(_x) {
      return _asyncDelay.apply(this, arguments);
    }
    function _asyncDelay() {
      _asyncDelay = _asyncToGenerator(regeneratorRuntime.mark(function _callee(time) {
        return regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
           case 0:
            return _context.abrupt("return", new Promise(function(resolve, reject) {
              try {
                setTimeout(function() {
                  resolve();
                }, 1e3 * time);
              } catch (e) {
                reject(e);
              }
            }));

           case 1:
           case "end":
            return _context.stop();
          }
        }, _callee);
      }));
      return _asyncDelay.apply(this, arguments);
    }
    var FireworkSettings = function() {
      function FireworkSettings(baseNode, nodeList, pos, side, range, number, scalseRange) {
        void 0 === pos && (pos = cc.v2(0, 0));
        void 0 === side && (side = cc.v2(0, 100));
        void 0 === range && (range = 50);
        void 0 === number && (number = 100);
        void 0 === scalseRange && (scalseRange = 0);
        this.baseNode = void 0;
        this.nodeList = void 0;
        this.pos = void 0;
        this.side = void 0;
        this.range = void 0;
        this.number = void 0;
        this.scalseRange = void 0;
        this.baseNode = baseNode;
        this.nodeList = nodeList;
        this.pos = pos;
        this.side = side;
        this.range = range;
        this.number = number;
        this.scalseRange = scalseRange;
      }
      FireworkSettings.copy = function copy(firework) {
        return new FireworkSettings(firework.baseNode, firework.nodeList, firework.pos, firework.side, firework.range, firework.number);
      };
      return FireworkSettings;
    }();
    exports.FireworkSettings = FireworkSettings;
    function showFireworks(_x2) {
      return _showFireworks.apply(this, arguments);
    }
    function _showFireworks() {
      _showFireworks = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(fireworkSettings) {
        var baseNode, nodeList, pos, side, range, number, scalseRange;
        return regeneratorRuntime.wrap(function _callee3$(_context3) {
          while (1) switch (_context3.prev = _context3.next) {
           case 0:
            baseNode = fireworkSettings.baseNode, nodeList = fireworkSettings.nodeList, pos = fireworkSettings.pos, 
            side = fireworkSettings.side, range = fireworkSettings.range, number = fireworkSettings.number, 
            scalseRange = fireworkSettings.scalseRange;
            new Array(number).fill(" ").forEach(function() {
              var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(_, i) {
                var rabbonNode, node, rate, angle;
                return regeneratorRuntime.wrap(function _callee2$(_context2) {
                  while (1) switch (_context2.prev = _context2.next) {
                   case 0:
                    rabbonNode = new cc.Node();
                    rabbonNode.parent = baseNode;
                    rabbonNode.x = pos.x;
                    rabbonNode.y = pos.y;
                    rabbonNode.angle = 60 * Math.random() - 30;
                    node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
                    node.parent = rabbonNode;
                    node.active = true;
                    node.x = 0;
                    node.y = 0;
                    node.angle = 0;
                    node.scale = (Math.random() - .5) * scalseRange + 1;
                    rate = Math.random();
                    angle = Math.PI * (2 * Math.random() - 1);
                    _context2.next = 16;
                    return asyncTweenBy(rabbonNode, .3, {
                      x: side.x * rate + Math.cos(angle) * range * rate,
                      y: side.y * rate + Math.sin(angle) * range * rate
                    }, {
                      easing: "quadIn"
                    });

                   case 16:
                    cc.tween(rabbonNode).by(8, {
                      y: -2e3
                    }).start();
                    cc.tween(rabbonNode).to(5, {
                      scale: (Math.random() - .5) * scalseRange + 1
                    }).start();
                    rabbonFall(rabbonNode);
                    _context2.next = 21;
                    return asyncDelay(Math.random());

                   case 21:
                    cc.tween(node).by(.15, {
                      x: -10,
                      angle: -10
                    }).by(.3, {
                      x: 20,
                      angle: 20
                    }).by(.15, {
                      x: -10,
                      angle: -10
                    }).union().repeatForever().start();
                    cc.tween(rabbonNode).delay(5).to(.3, {
                      opacity: 0
                    }).call(function() {
                      node.stopAllActions();
                      node.active = false;
                      node.parent = null;
                      node = null;
                    }).start();

                   case 23:
                   case "end":
                    return _context2.stop();
                  }
                }, _callee2);
              }));
              return function(_x16, _x17) {
                return _ref.apply(this, arguments);
              };
            }());

           case 2:
           case "end":
            return _context3.stop();
          }
        }, _callee3);
      }));
      return _showFireworks.apply(this, arguments);
    }
    function rabbonFall(_x3) {
      return _rabbonFall.apply(this, arguments);
    }
    function _rabbonFall() {
      _rabbonFall = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(node) {
        var time, offsetX;
        return regeneratorRuntime.wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
           case 0:
            time = 1 + Math.random();
            offsetX = RandomInt(-200, 200) * time;
            _context4.next = 4;
            return asyncTweenBy(node, time, {
              x: offsetX,
              angle: 60 * offsetX / 200
            });

           case 4:
            rabbonFall(node);

           case 5:
           case "end":
            return _context4.stop();
          }
        }, _callee4);
      }));
      return _rabbonFall.apply(this, arguments);
    }
    function asyncTweenTo(_x4, _x5, _x6, _x7) {
      return _asyncTweenTo.apply(this, arguments);
    }
    function _asyncTweenTo() {
      _asyncTweenTo = _asyncToGenerator(regeneratorRuntime.mark(function _callee5(node, duration, obj, ease) {
        return regeneratorRuntime.wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
           case 0:
            void 0 === ease && (ease = void 0);
            return _context5.abrupt("return", new Promise(function(resolve, reject) {
              try {
                cc.tween(node).to(duration, obj, ease).call(function() {
                  resolve();
                }).start();
              } catch (e) {
                reject(e);
              }
            }));

           case 2:
           case "end":
            return _context5.stop();
          }
        }, _callee5);
      }));
      return _asyncTweenTo.apply(this, arguments);
    }
    function asyncTweenBy(_x8, _x9, _x10, _x11) {
      return _asyncTweenBy.apply(this, arguments);
    }
    function _asyncTweenBy() {
      _asyncTweenBy = _asyncToGenerator(regeneratorRuntime.mark(function _callee6(node, duration, obj, ease) {
        return regeneratorRuntime.wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
           case 0:
            void 0 === ease && (ease = void 0);
            return _context6.abrupt("return", new Promise(function(resolve, reject) {
              try {
                cc.tween(node).by(duration, obj, ease).call(function() {
                  resolve();
                }).start();
              } catch (e) {
                reject(e);
              }
            }));

           case 2:
           case "end":
            return _context6.stop();
          }
        }, _callee6);
      }));
      return _asyncTweenBy.apply(this, arguments);
    }
    function showTrebleFirework(baseNode, rabbonList) {
      var middle = new FireworkSettings(baseNode, rabbonList);
      middle.pos = cc.v2(0, -400);
      middle.side = cc.v2(0, 1e3);
      middle.range = 200;
      middle.number = 100;
      middle.scalseRange = .4;
      var left = FireworkSettings.copy(middle);
      left.pos = cc.v2(-600, -400);
      left.side = cc.v2(200, 1e3);
      var right = FireworkSettings.copy(middle);
      right.pos = cc.v2(600, -400);
      right.side = cc.v2(-200, 1e3);
      showFireworks(middle);
      showFireworks(left);
      showFireworks(right);
    }
    function onHomeworkFinish() {
      var middleLayer = cc.find("middleLayer");
      if (middleLayer) {
        var middleLayerComponent = middleLayer.getComponent("middleLayer");
        "student" == middleLayerComponent.role && middleLayerComponent.onHomeworkFinish(function() {});
      } else console.log("onHomeworkFinish");
    }
    function asyncPlayDragonBoneAnimation(_x12, _x13, _x14, _x15) {
      return _asyncPlayDragonBoneAnimation.apply(this, arguments);
    }
    function _asyncPlayDragonBoneAnimation() {
      _asyncPlayDragonBoneAnimation = _asyncToGenerator(regeneratorRuntime.mark(function _callee7(node, animationName, time, onFrameEvent) {
        return regeneratorRuntime.wrap(function _callee7$(_context7) {
          while (1) switch (_context7.prev = _context7.next) {
           case 0:
            void 0 === time && (time = 1);
            void 0 === onFrameEvent && (onFrameEvent = null);
            return _context7.abrupt("return", new Promise(function(resolve, reject) {
              var armatureDisplay = node.getComponent(dragonBones.ArmatureDisplay);
              armatureDisplay.timeScale = 1;
              armatureDisplay.once(dragonBones.EventObject.COMPLETE, function() {
                resolve();
              });
              armatureDisplay.on(dragonBones.EventObject.FRAME_EVENT, function(event) {
                onFrameEvent && onFrameEvent(event);
              });
              armatureDisplay.playAnimation(animationName, time);
            }));

           case 3:
           case "end":
            return _context7.stop();
          }
        }, _callee7);
      }));
      return _asyncPlayDragonBoneAnimation.apply(this, arguments);
    }
    function playDragonBoneAnimation(node, animationName, time, onFinish, onFrameEvent) {
      void 0 === time && (time = 1);
      void 0 === onFinish && (onFinish = null);
      void 0 === onFrameEvent && (onFrameEvent = null);
      var armatureDisplay = node.getComponent(dragonBones.ArmatureDisplay);
      armatureDisplay.timeScale = 1;
      armatureDisplay.once(dragonBones.EventObject.COMPLETE, function() {
        onFinish && onFinish();
      });
      armatureDisplay.on(dragonBones.EventObject.FRAME_EVENT, function(event) {
        onFrameEvent && onFrameEvent(event);
      });
      armatureDisplay.playAnimation(animationName, time);
    }
    cc._RF.pop();
  }, {} ]
}, {}, [ "op_09", "defaultData", "util" ]);