var touch,__extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){function a(){this.constructor=t}if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n),t.prototype=null===n?Object.create(n):(a.prototype=n.prototype,new a)}}();!function(e){var t;!function(e){e.success="success",e.fail="failed",e.cancel="cancel"}(t||(t={}));var n=function(n){function a(t){var a=n.call(this)||this;return a._main=null,a._onlineRemainingTime=0,a.onlineGiftIndex=0,a._main=t,a.btnClose.clickHandler=Laya.Handler.create(a,a.onClickClose,null,!1),a.btnAward00.clickHandler=Laya.Handler.create(a,a.onClickAward00,null,!1),a.btnAward11.clickHandler=Laya.Handler.create(a,a.onClickAward11,null,!1),a.btnAward22.clickHandler=Laya.Handler.create(a,a.onClickAward22,null,!1),a.btnBuy.clickHandler=Laya.Handler.create(a,a.onBuyDiaond,null,!1),a.updateOnlineReward(),a.payItem.visible=GameBaseData.isSupportPay,a.bg.height=GameBaseData.isSupportPay?790:600,a.award.text=e.Lang.getLangText(e.Lang.award),a.watch_video.text=e.Lang.getLangText(e.Lang.watch_video),a.login_game.text=e.Lang.getLangText(e.Lang.login_game),a.watch_get.text=e.Lang.getLangText(e.Lang.get),a.login_get.text=e.Lang.getLangText(e.Lang.get),a.adapterScreen(),Laya.stage.on(Laya.Event.RESIZE,a,a.onResize),a}return __extends(a,n),a.prototype.onResize=function(){this.adapterScreen()},a.prototype.updateOnlineReward=function(){this.btnAward0.visible=!0,this.btnAward00.visible=!1,this.tfDiamond.text=e.GameData.instance.diamond.toString(),this.txtAward1.text=e.Lang.getLangText(e.Lang.tomorrow),this.txtAward0.text=e.Lang.getLangText(e.Lang.tomorrow);for(var t=e.GameData.instance.onlineIndex,n=0;n4?(this.btnAward2.visible=!0,this.btnAward22.visible=!1):(this.btnAward2.visible=!1,this.btnAward22.visible=!0)},a.prototype.adapterScreen=function(){var e=GameBaseData.getAdapterRatio();this.scale(e,e)},a.prototype.destroy=function(){null!=this.btnClose.clickHandler&&(this.btnClose.clickHandler.recover(),this.btnClose.clickHandler=null),null!=this.btnAward00.clickHandler&&(this.btnAward00.clickHandler.recover(),this.btnAward00.clickHandler=null),null!=this.btnAward11.clickHandler&&(this.btnAward11.clickHandler.recover(),this.btnAward11.clickHandler=null),null!=this.btnAward22.clickHandler&&(this.btnAward22.clickHandler.recover(),this.btnAward22.clickHandler=null),null!=this.btnBuy.clickHandler&&(this.btnBuy.clickHandler.recover(),this.btnBuy.clickHandler=null),n.prototype.destroy.call(this),Laya.stage.off(Laya.Event.RESIZE,this,this.onResize)},a.prototype.timeLoop=function(){this._onlineRemainingTime--,this.txtAward0.text=e.TimeUtil.getHourMinuteSecond(1e3*this._onlineRemainingTime),this._onlineRemainingTime<=0&&(Laya.timer.clear(this,this.timeLoop),this.updateOnlineReward())},a.prototype.onClickAward00=function(){SdkHelper.EventLogger.logDailyGiftAdButtonClick(),this.playNativeAward()},a.prototype.playNativeAward=function(){GameBaseData.isNative?this.playIronSourceVideo():this.playH5Video()},a.prototype.playIronSourceVideo=function(){var t=this;SdkHelper.IronSourceHelper.isVideoReady()?SdkHelper.IronSourceHelper.showVideoAdsAsync(function(n){n?(SdkHelper.EventLogger.logAdShowEvent("DailyAward",e.GameData.instance.isNewUser),e.GameData.instance.setAddDiamond(100),e.GameData.instance.onlineIndex=t.onlineGiftIndex,e.Notice.show("Successful get 100 diamonds."),SdkHelper.EventLogger.logAwardReceiveAd(),SdkHelper.EventLogger.logAwardReceiveAdWithTimes()):e.Notice.show("Complete the ads to get rewards"),t.updateOnlineReward()}):(console.info("Reward Ads Not Ready"),e.Notice.show("Ads Not Ready, Try Again Later"))},a.prototype.playH5Video=function(){var t=this;SdkHelper.MiniGameSDKHelper.isRewardVideoReady()?SdkHelper.MiniGameSDKHelper.showRewardedVideo(function(n){if(n){SdkHelper.EventLogger.logAdShowEvent("DailyAward",e.GameData.instance.isNewUser),e.GameData.instance.setAddDiamond(100),e.GameData.instance.onlineIndex=t.onlineGiftIndex,SdkHelper.EventLogger.logAwardReceiveAd(),SdkHelper.EventLogger.logAwardReceiveAdWithTimes();var a=e.Lang.getLangText(e.Lang.suc_get_diamonds);a=a.replace("${value}","100"),e.Notice.show(a)}else e.Notice.show(e.Lang.getLangText(e.Lang.complete_get_ads_rewards));t.updateOnlineReward()}):(console.info("Reward Ads Not Ready"),e.Notice.show(e.Lang.getLangText(e.Lang.ads_not_ready)))},a.prototype.onClickAward11=function(){e.GameData.instance.setAddDiamond(200);var t=e.Lang.getLangText(e.Lang.suc_get_diamonds);t=t.replace("${value}","200"),e.Notice.show(t),e.GameData.instance.dailyVaild=!1,this.updateOnlineReward(),SdkHelper.EventLogger.logAwardReceive(),SdkHelper.EventLogger.logAwardReceiveWithTimes()},a.prototype.onClickAward22=function(){a.isFromAward=!0,this.close(),this._main.event(e.GameEvent.OPEN_RANK)},a.prototype.onClickClose=function(){this.close("",!1),SdkHelper.SdkUtils.setAdflyState(1)},a.prototype.onBuyDiaond=function(){var n=this;if(SdkHelper.SdkUtils.isH5Platform){var a=window.minigame,i={};i.productID="minigameball001",a.payments.purchaseAsync(i).then(function(t){a.payments.consumePurchaseAsync(t.purchaseToken).then(function(){e.GameData.instance.setAddDiamond(1e3),n.tfDiamond.text=e.GameData.instance.diamond.toString(),e.Notice.show("Successful buy 1000 diamonds.")}).catch(function(e){console.error("====> consumePurchaseAsync error: ".concat(e))})}).catch(function(t){console.error("====> purchaseAsync error: ".concat(t)),e.Notice.show("fail to pay diamond")})}else SdkHelper.PayHelper.pay(function(a){switch(a){case t.success:e.GameData.instance.setAddDiamond(1e3),n.tfDiamond.text=e.GameData.instance.diamond.toString(),e.Notice.show("Successful buy 1000 diamonds.");break;case t.fail:case t.cancel:e.Notice.show("fail to pay diamond: "+a)}})},a.isFromAward=!1,a.friendNums=0,a}(ui.AwardDialogUI);e.AwardDialog=n}(touch||(touch={}));