"use strict";var _luckymoney=require("../../../utils/luckymoney"),_luckymoneyStore=require("../../../store/luckymoney-store"),_luckymoneyService=require("../../../services/luckymoney-service"),_theme=require("../../../utils/theme");Component({properties:{sdkInstance:{type:Object,value:null}},data:{useDarkTheme:!1,luckymoney:{},current:{},record:{},currentTitle:"",currentStatusText:"",resultText:"",amountText:"",withdrawStatusText:"",countdownRedPacketID:0},lifetimes:{detached:function(){"function"==typeof this.unsubMain&&this.unsubMain(),this.unsubMain=null,"function"==typeof this.unsubLuckymoney&&this.unsubLuckymoney(),this.unsubLuckymoney=null}},observers:{sdkInstance:function(t){var e=this;t&&(this.sdkInstance=t,this.sdkInstanceId=(null==t?void 0:t.uuid)||t,this.store=t.store,this.luckymoneyStore=(0,_luckymoneyStore.getLuckymoneyStore)(this.sdkInstanceId),this.luckymoneyService=(0,_luckymoneyService.getLuckymoneyService)(this.sdkInstanceId,{store:this.luckymoneyStore}),"function"==typeof this.unsubMain&&this.unsubMain(),this.unsubMain=null,"function"==typeof this.unsubLuckymoney&&this.unsubLuckymoney(),this.unsubLuckymoney=null,this.unsubLuckymoney=this.luckymoneyStore.subscribe({current:function(){return e.syncLuckymoneyState()},RedPacketWinnerRecordMap:function(){return e.syncLuckymoneyState()},rainingRedPacketID:function(){return e.syncLuckymoneyState()},noAnimationFlowMap:function(){return e.syncLuckymoneyState()},activeNoAnimationRevealRedPacketID:function(){return e.syncLuckymoneyState()},attendModalDisplay:function(){return e.syncLuckymoneyState()},withdrawModalDisplay:function(){return e.syncLuckymoneyState()},withdrawResultDisplay:function(){return e.syncLuckymoneyState()},userStatusMap:function(){return e.syncLuckymoneyState()},data:function(){return e.syncLuckymoneyState()}}),this.unsubMain=this.store.get({liveInfo:function(t){e.setData({useDarkTheme:(0,_theme.isUseDarkTheme)(null==t?void 0:t.Basic)})}}))}},methods:{syncLuckymoneyState:function(){var t=this.luckymoneyStore.state||{},e=(null==t?void 0:t.current)||{},n=this.getRecordByState(t,e),u=this.getCountdownRedPacketID(t);this.setData({luckymoney:t,current:e,record:n,currentTitle:this.getTitle(e),currentStatusText:this.getStatusText(e,t),resultText:this.getResultText(n),amountText:this.getAmountText(n),withdrawStatusText:this.getWithdrawStatusText(e),countdownRedPacketID:u})},closeWithdrawResult:function(){var t,e;null===(t=this.luckymoneyService)||void 0===t||null===(e=t.closeWithdrawResult)||void 0===e||e.call(t)},getRecordByState:function(t,e){return((null==t?void 0:t.RedPacketWinnerRecordMap)||{})[null==e?void 0:e.RedPacketID]||{}},getCountdownRedPacketID:function(t){var e,n=null==t?void 0:t.activeNoAnimationRevealRedPacketID;return n&&(null==t||null===(e=t.noAnimationFlowMap)||void 0===e?void 0:e[n])===_luckymoney.NoAnimationFlowStage.COUNTDOWN?n:0},getStatusText:function(t,e){switch((0,_luckymoney.getVisibleRedPacketStatus)(t,e)){case _luckymoney.RedPacketStatus.OPENING:return"开启中";case _luckymoney.RedPacketStatus.SUCCESS:case _luckymoney.RedPacketStatus.FAILED:return"已结束";case _luckymoney.RedPacketStatus.INIT:case _luckymoney.RedPacketStatus.SENT:return"进行中";default:return""}},getTitle:function(t){if(null!=t&&t.Name)return t.Name;var e=(null==t?void 0:t.TotalAmount)||0,n=(null==t?void 0:t.RedPacketType)===_luckymoney.RedPacketType.POINT;return null!=t&&t.HasNoLimit?n?"积分红包":"现金红包":n?"红包".concat(e).concat((null==t?void 0:t.RewardsPointsUnit)||""):"红包".concat((e||0)/100,"元")},getAmountText:function(t){return(null==t?void 0:t.result)!==_luckymoney.LuckyMoneyResult.WIN?"":(null==t?void 0:t.RedPacketType)===_luckymoney.RedPacketType.POINT?"".concat(t.Amount||0).concat(t.RewardsPointsUnit||""):"".concat((t.Amount||0)/100,"元")},getResultText:function(t){switch(null==t?void 0:t.result){case _luckymoney.LuckyMoneyResult.WIN:return"恭喜你，抢到了红包";case _luckymoney.LuckyMoneyResult.LOSE:return"很遗憾，未抢到红包";case _luckymoney.LuckyMoneyResult.UNATTENDED:return"未参与";case _luckymoney.LuckyMoneyResult.ATTENDED:return"已参与";default:return"结果获取失败"}},getWithdrawStatusText:function(t){switch(Number(null==t?void 0:t.WithdrawalStatus)){case _luckymoney.WithdrawStatus.ING:return"提现处理中";case _luckymoney.WithdrawStatus.YES:return"提现成功";case _luckymoney.WithdrawStatus.NO:return"提现失败";case _luckymoney.WithdrawStatus.CELL:return"提现已取消";default:return"待提现"}}}});