var ttGame;!function(e){e.BaseADManager=class{constructor(e,t,a){this.STATE_LOADED=1,this.STATE_SHOW=2,this.STATE_EXPOSURE=3,this._ids={bannerAdID:e,rewardedAdID:t,interstitialAdID:a},this._adState={bannerAdState:0,rewardedAdState:0,interstitialAdState:0},this.createBannerAd(e),this.createRewardedVideoAd(t),this.createInterstitialAd(a)}createBannerAd(e){if(!tt.createBannerAd)return;let t=platform.systemInfo.info,a=tt.createBannerAd({adUnitId:e,adIntervals:30,style:{left:0,top:t.windowHeight,width:this._bannerAdWidth?this._bannerAdWidth:t.windowWidth}});a&&(a.onResize(this.onBannerResize.bind(this)),a.onError(this.onBannerError.bind(this)),a.onLoad(this.onBannerLoaded.bind(this)),this._bannerAd=a)}onBannerResize(e){log("Banner size:",e);let t=platform.systemInfo.info;this._bannerAd.style.left=t.windowWidth-e.width>>1,this._bannerAd.style.top=t.windowHeight-e.height}onBannerError(e){log("Banner广告报错:",e)}onBannerLoaded(){this.addBannerState(this.STATE_LOADED),core.Manager.wtsdk.sendAdLog(this._ids.bannerAdID,core.AdLogType.REQUEST)}addBannerState(e){this._adState.bannerAdState|=e,this._adState.bannerAdState==this.STATE_EXPOSURE&&core.Manager.wtsdk.sendAdLog(this._ids.bannerAdID,core.AdLogType.EXPOSURE)}showBanner(){this._bannerAd&&(this._bannerAd.show(),this.addBannerState(this.STATE_SHOW))}hideBanner(){this._bannerAd&&this._bannerAd.hide(),this._adState.bannerAdState=0}createRewardedVideoAd(e){tt.createRewardedVideoAd&&(this._rewardedVideoAd=tt.createRewardedVideoAd({adUnitId:e}),log("创建激励视频广告",this._rewardedVideoAd),this._rewardedVideoAd&&(this._rewardedVideoAd.onError(this.onRewardedVideoAdError.bind(this)),this._rewardedVideoAd.onClose(this.onRewardedVideoAdClosed.bind(this)),this._rewardedVideoAd.onLoad(this.onRewardedVideoAdLoaded.bind(this))))}onRewardedVideoAdError(e){log("激励视频出错",e),core.Manager.eDispatcher.event(core.Event.REWARDED_AD_ERROR,e)}onRewardedVideoAdClosed(e){log("激励视频关闭",e),this._adState.rewardedAdState=0,e&&e.isEnded&&core.Manager.wtsdk.sendAdLog(this._ids.interstitialAdID,core.AdLogType.FINISH),core.Manager.eDispatcher.event(core.Event.REWARDED_AD_CLOSE,e&&e.isEnded)}onRewardedVideoAdLoaded(e){log("激励视频加载",e),this.addRewardedState(this.STATE_LOADED),core.Manager.wtsdk.sendAdLog(this._ids.rewardedAdID,core.AdLogType.REQUEST),core.Manager.eDispatcher.event(core.Event.REWARDED_AD_ONLOAD,e)}addRewardedState(e){this._adState.rewardedAdState|=e,this._adState.rewardedAdState==this.STATE_EXPOSURE&&core.Manager.wtsdk.sendAdLog(this._ids.rewardedAdID,core.AdLogType.EXPOSURE)}showRewardedVideoAd(){this._rewardedVideoAd&&(this._rewardedVideoAd.show(),this.addRewardedState(this.STATE_SHOW))}createInterstitialAd(e){tt.createInterstitialAd&&(this._interstitialAd=tt.createInterstitialAd({adUnitId:e}),log("创建插屏广告",this._rewardedVideoAd),this._interstitialAd&&(this._interstitialAd.onError(this.onInterstitialAdError.bind(this)),this._interstitialAd.onClose(this.onInterstitialAdClosed.bind(this)),this._interstitialAd.onLoad(this.onInterstitialAdLoaded.bind(this))))}onInterstitialAdError(e){log("插屏广告出错",e),core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_ERROR,e)}onInterstitialAdClosed(e){log("插屏广告关闭",e),this._adState.interstitialAdState=0,core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_CLOSE,e)}onInterstitialAdLoaded(e){log("插屏广告加载",e),this.addInterstitialState(this.STATE_LOADED),core.Manager.wtsdk.sendAdLog(this._ids.interstitialAdID,core.AdLogType.REQUEST),core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_ONLOAD,e)}addInterstitialState(e){this._adState.interstitialAdState|=e,this._adState.interstitialAdState==this.STATE_EXPOSURE&&core.Manager.wtsdk.sendAdLog(this._ids.interstitialAdID,core.AdLogType.EXPOSURE)}showInterstitialAd(){if(!this._interstitialAd)return;let e=this._interstitialAd;this._interstitialAd.load().then(()=>{e.show(),this.addInterstitialState(this.STATE_SHOW)}).catch(e=>{log("显示插屏广告err:",e)})}}}(ttGame||(ttGame={})),function(e){e.ADManager=class extends e.BaseADManager{constructor(){super("5ned9cusvp93gaecf5","548if3698jfe98cl0c","pdjoqnq1i9537a7o1o"),this._bannerAdWidth=Math.floor(tt.getSystemInfoSync().windowWidth/3)}onBannerResize(e){let t=tt.getSystemInfoSync().windowWidth,a=tt.getSystemInfoSync().windowHeight;this._bannerAd.style.left=t-e.width,this._bannerAd.style.top=a-e.height}}}(ttGame||(ttGame={})),function(e){e.BasePlatform=class extends core.BasePlatform{constructor(){super()}initEvent(){tt.onShow(this.onShow.bind(this)),tt.onHide(this.onHide.bind(this))}onShow(e){Laya.timer.resume(),core.Manager.wtsdk.sendStart({scene:this.startScene}),core.Manager.eDispatcher.event(core.Event.ON_SHOW,e)}onHide(e){Laya.timer.pause(),core.Manager.wtsdk.sendExit({scene:this.startScene}),core.Manager.eDispatcher.event(core.Event.ON_HIDE,e)}init(){this.systemInfo=new e.SystemInfo,core.Manager.baseInfo.app_name=this.systemInfo.appName,core.Manager.baseInfo.device=this.systemInfo.device,core.Manager.baseInfo.platform_id=core.PlatformType.ID_TTGAME,this.openDataContext=tt.getOpenDataContext(),this.ad=new e.ADManager,this.initEvent(),this.sendRes(),this.initRecorder(),this.setDefaultShare(),this.login()}login(){tt.login({force:!1,success:this.loginComplete.bind(this,!0),fail:this.loginComplete.bind(this,!1)})}loginComplete(e,t){e||(t.anonymousCode=null,t.code=null),t.app_name=core.Manager.baseInfo.app_name,t.game_id=core.Manager.baseInfo.game_id,t.platform_id=core.Manager.baseInfo.platform_id,t.device=this.systemInfo.device,t.scene=this.startScene,t.version=BaseConfig.version,core.Manager.wtsdk.getUserInfo(t,Laya.Handler.create(this,this.httpUserInfoCallback)),this.getAccessToken()}getAccessToken(e){core.Manager.wtsdk.getAccessToken(Laya.Handler.create(this,t=>{t.code&&(this.appID=t.result.appId,this.accessToken=t.result.data.access_token),e&&e.runWith(t)}))}httpUserInfoCallback(e){e&&200==e.code?(core.Manager.baseInfo.token=e.result.id,core.Manager.selfInfo.updateAll(e.result),this.checkSetting()):log(e)}setUserInfo(e){e?core.Manager.wtsdk.modifyUserInfo({userInfo:e,member_id:core.Manager.selfInfo.id},Laya.Handler.create(this,this.httpModifyUserInfoCallback)):(core.Manager.selfInfo.isAuthorized=!1,this.sendUserInfo(core.Manager.selfInfo))}httpModifyUserInfoCallback(e){e&&200==e.code?(core.Manager.selfInfo.update(e.result),core.Manager.selfInfo.isAuthorized=!0,this.sendUserInfo(core.Manager.selfInfo)):log(e)}checkSetting(){tt.getSetting({success:(e=>{log("tt.getSetting:",e),e.authSetting["scope.userInfo"]?this.getUserInfo():this.authorizeUserInfo(),e.authSetting["scope.screenRecord"]?core.Manager.selfInfo.isAuthorizedScreenRecord=!0:this.authorizeScreenRecord()}).bind(this)})}authorizeUserInfo(){tt.authorize({scope:"scope.userInfo",success:(e=>{this.getUserInfo(),log("tt.authorize UserInfo succ",e)}).bind(this),fail:(e=>{this.setUserInfo(null),log("tt.authorize UserInfo fail",e)}).bind(this),complete:(e=>{log("tt.authorize UserInfo complete",e)}).bind(this)})}authorizeScreenRecord(){tt.authorize({success:(e=>{core.Manager.selfInfo.isAuthorizedScreenRecord=!0,log("tt.authorize screenRecord succ",e)}).bind(this),fail:(e=>{log("tt.authorize screenRecord fail",e)}).bind(this),complete:(e=>{log("tt.authorize screenRecord complete",e)}).bind(this)})}getUserInfo(){tt.getUserInfo({withCredentials:!0,success:(e=>{log("getUserInfo:",e),this.setUserInfo(e.userInfo)}).bind(this),fail:(e=>{log("getUserInfo fail:",e),this.setUserInfo(null)}).bind(this)})}sendRes(){}get startScene(){let e=tt.getLaunchOptionsSync();return e&&e.scene?e.scene:""}setDefaultShare(){tt.onShareAppMessage((()=>{if(this._sharing)return;let e=this.getShareData();return core.ObjectUtil.addKeys(e,{channel:"",success:this.shareSuccess.bind(this),fail:this.shareFail.bind(this),complete:this.shareComplete.bind(this)}),e}).bind(this))}attention(){tt.openAwemeUserProfile()}addToFavorite(){tt.showFavoriteGuide()}getVideoList(){tt.request({url:"https://gate.snssdk.com/developer/api/get_top_video_ids_by_like",method:"POST",data:{app_id:this.appID,number_of_top:100,tag:"rankTag1",access_token:this.accessToken},success:e=>{log("视频排行榜信息",e),-15003==e.data.err_no?this.getAccessToken(Laya.Handler.create(this,this.getVideoList)):core.Manager.eDispatcher.event(core.Event.VIDEO_LIST,0==e.data.err_no?e.data:[])}})}navigateToVideoView(e){tt.navigateToVideoView({videoId:e,success:e=>{log("done")},fail:e=>{1006===e.errCode&&tt.showToast({title:"something wrong with your network"})}})}share(e){if(this._sharing)return;let t=this.getShareData(e);core.ObjectUtil.addKeys(t,{channel:"",success:this.shareSuccess.bind(this,""),fail:this.shareFail.bind(this,""),complete:this.shareComplete.bind(this,"")}),tt.shareAppMessage(t)}getShareData(e){return{success:this.shareSuccess.bind(this),fail:this.shareFail.bind(this),complete:this.shareComplete.bind(this)}}shareVideo(e){if(this._sharing)return;let t=this.getVideoShareData(e);core.ObjectUtil.addKeys(t,{channel:"video",success:this.shareSuccess.bind(this,"video"),fail:this.shareFail.bind(this,"video"),complete:this.shareComplete.bind(this,"video")}),tt.shareAppMessage(t),core.Manager.wtsdk.sendRecord()}getVideoShareData(e){return{channel:"video",success:this.shareSuccess.bind(this,"video"),fail:this.shareFail.bind(this,"video"),complete:this.shareComplete.bind(this,"video")}}shareSuccess(e,t){"video"==e?core.Manager.wtsdk.sendRecordShare():core.Manager.wtsdk.sendShare(),t.channel=e,core.Manager.eDispatcher.event(core.Event.SHARE_SUCCESS,t),log("分享成功",t)}shareFail(e,t){t.channel=e,core.Manager.eDispatcher.event(core.Event.SHARE_FAIL,t),log("分享失败",t)}shareComplete(e,t){t.channel=e,this._sharing=!1,core.Manager.eDispatcher.event(core.Event.SHARE_COMPLETE,t),log("分享完成",t)}getStorageSync(e){return tt.getStorageSync(e)}setStorageSync(e,t){return tt.setStorageSync(e,t)}postMessage(e){this.openDataContext.postMessage(e)}sendUserInfo(e){core.Manager.isLogined=!0;let t={action:core.DomainAction.UserInfo,data:e};this.postMessage(t)}clearCanvas(){let e={action:core.DomainAction.ClearCanvas};this.postMessage(e)}showRank(e){let t;t=0==e?{action:core.DomainAction.RankFriend}:{action:core.DomainAction.RankWorld},this.postMessage(t)}hideRank(){}rankChangePage(e){this.postMessage({action:core.DomainAction.Paging,page:e})}saveScore(e){this.postMessage({action:core.DomainAction.SaveScore,score:e}),core.Manager.wtsdk.saveScore({score:e})}adBanner(e){try{e?this.ad.showBanner():this.ad.hideBanner()}catch(e){log("adBanner error:",e)}}adRewardedVideo(){try{this.ad.showRewardedVideoAd()}catch(e){log("adBanner error:",e)}}adInterstitial(){try{this.ad.showInterstitialAd()}catch(e){log("adBanner error:",e)}}adGrid(e){}initRecorder(){this.recorder=tt.getGameRecorderManager(),this.recorder.onStart(e=>{log("录屏开始",e),core.Manager.eDispatcher.event(core.Event.RECORD_START,e)}),this.recorder.onStop(e=>{log("录屏停止",e),core.Manager.eDispatcher.event(core.Event.RECORD_STOP,e.videoPath)}),this.recorder.onError(e=>{log("录屏错误",e),core.Manager.eDispatcher.event(core.Event.RECORD_ERROR,e)})}startRecord(){try{let e=this.recorder.getMark(),t=(Laya.stage.width-e.markWidth)/2,a=(Laya.stage.height-e.markHeight)/2;this.recorder.start({duration:30,isMarkOpen:!0,locLeft:t,locTop:a})}catch(e){log("startRecord error:",e)}}stopRecord(){try{this.recorder.stop()}catch(e){log("stopRecord error:",e)}}moreGameBtn(t){if(core.Manager.eDispatcher.offAllCaller(this),"ios"!==this.systemInfo.device){if(t){if(!core.Manager.gameList||0==core.Manager.gameList.length)return core.Manager.eDispatcher.on(core.Event.GET_MOREGAME_COMPLETE,this,()=>{this.moreGameBtn(!0)}),null;this._moreGameBtn||(this._moreGameBtn=new e.MoreGameIcon(this.moreGameParams))}else this._moreGameBtn&&(this._moreGameBtn.destroy(),this._moreGameBtn=null);return this._moreGameBtn}}get moreGameParams(){return{x:0,y:0,w:60,h:60,appLaunchOptions:[]}}showMoreGame(){"ios"!==this.systemInfo.device&&tt.showMoreGamesModal({appLaunchOptions:[]})}}}(ttGame||(ttGame={})),function(e){e.Platform=class extends e.BasePlatform{constructor(){super()}getShareData(e){e||(e="跟我一起去感受风的速度吧!");let t={title:e};return core.ObjectUtil.addKeys(t,super.getShareData(e)),t}getVideoShareData(e){let t={query:"",title:"酷跑男女",desc:"跟我一起去感受风的速度吧!",extra:{videoPath:e,videoTopics:["#酷跑男女 #跟我一起去感受风的速度吧!"],withVideoId:!0,videoTag:"rankTag1"}};return core.ObjectUtil.addKeys(t,super.getVideoShareData(e)),t}sendRes(){e.SendRes.sendAtlasList(["res/atlas/res/imgs/rank.atlas","res/atlas/res/imgs/revive.atlas"])}get moreGameParams(){return{x:Laya.stage.width/2,y:258,w:80,h:80,appLaunchOptions:[]}}showSurpass(e){this.postMessage({action:core.DomainActionEx.Surpass,score:e})}showTitle(e){this.postMessage({action:core.DomainActionEx.Title,score:e})}sendLoginCheck(){log("发送登录检查保存分数"),this.postMessage({action:core.DomainActionEx.LoginCheck})}}}(ttGame||(ttGame={})),window.ttGame=ttGame,window.platform=new ttGame.Platform,function(e){e.SendRes=class{static sendAtlasList(e){if(e)for(;e.length>0;){let t=e.pop();Laya.loader.getRes(t)?Laya.TTMiniAdapter.sendAtlasToOpenDataContext(t):Laya.loader.load(t,Laya.Handler.create(Laya.TTMiniAdapter,Laya.TTMiniAdapter.sendAtlasToOpenDataContext,[t]))}}static sendSinglePicList(e){if(e)for(;e.length>0;){let t=e.pop();Laya.loader.getRes(t)?Laya.TTMiniAdapter.sendSinglePicToOpenDataContext(t):Laya.loader.load(t,Laya.Handler.create(Laya.TTMiniAdapter,Laya.TTMiniAdapter.sendSinglePicToOpenDataContext,[t]))}}static sendJsonList(e){if(e)for(;e.length>0;){let t=e.pop();Laya.loader.getRes(t)?Laya.TTMiniAdapter.sendJsonDataToDataContext(t):Laya.loader.load(t,Laya.Handler.create(Laya.TTMiniAdapter,Laya.TTMiniAdapter.sendJsonDataToDataContext,[t]))}}}}(ttGame||(ttGame={})),function(e){e.SystemInfo=class{constructor(){this.info=tt.getSystemInfoSync()}get device(){return this.info.platform}get appName(){return this.info.appName}}}(ttGame||(ttGame={})),function(e){e.MoreGameIcon=class extends Laya.Box{constructor(e){super(),this.ICON_SIZE=120,this.zOrder=core.ZOrder.POPUP,this._appLaunchOptions=e.appLaunchOptions,this.pos(e.x,e.y),this.scale(e.w/this.ICON_SIZE,e.h/this.ICON_SIZE),Laya.stage.addChild(this)}onAwake(){this._index=0,this._icon=new Laya.Image,this._icon.anchorX=.5,this._icon.anchorY=.5,this.addChild(this._icon),this._icon.mouseEnabled=!0,this._label=new Laya.Image(this.getRes("gdhw")),this._label.anchorX=.5,this._label.anchorY=.5,this._label.y=86,this.addChild(this._label),this._label.mouseEnabled=!0,this._iconUrls=[];let e=core.Manager.gameList;for(let t=e.length-1;t>=0;t--)1==e[t].rec_degree&&this._iconUrls.push(e[t].icon);0==this._iconUrls.length&&this._iconUrls.push(e[0].icon),this._tweentimeLite=new core.TweenTimeLine(0),this._tweentimeLite.addToTween(this,{scaleX:.8*this.scaleX,scaleY:.8*this.scaleX},600,Laya.Ease.backOut),this._tweentimeLite.addToTween(this,{scaleX:this.scaleX,scaleY:this.scaleX},600,Laya.Ease.backIn)}getRes(e){return core.Manager.commonResPath+"gameIcon/"+e+".png"}onEnable(){super.onEnable(),this.timerLoop(5e3,this,this.changeSkin),this.changeSkin(),this._tweentimeLite.start(),this.on(Laya.Event.CLICK,this,this.onClick),this._icon.on(Laya.Event.LOADED,this,this.iconLoaded)}changeSkin(){this._index>=this._iconUrls.length&&(this._index=0),this._icon.skin=this._iconUrls[this._index],this._index++}iconLoaded(){this._icon.size(this.ICON_SIZE,this.ICON_SIZE)}onClick(e){window.platform&&platform.showMoreGame()}onDisable(){super.onDisable(),this.clearTimer(this,this.changeSkin),this._tweentimeLite.pause(),this.off(Laya.Event.CLICK,this,this.onClick),this._icon.off(Laya.Event.LOADED,this,this.iconLoaded)}destroy(){super.destroy(),this._tweentimeLite.destroy(),this._tweentimeLite=null,this._appLaunchOptions=null,this._iconUrls=null}}}(ttGame||(ttGame={}));