"use strict";var _FLOATING_ICON_TYPE_K,_socket=require("../../utils/socket"),_constant=require("../../utils/constant"),_util=require("./util"),_coupon=require("../../utils/coupon"),_logger=require("../../utils/logger"),_luckymoney=require("../../utils/luckymoney"),_luckymoneyStore=require("../../store/luckymoney-store"),_featureProcess=require("../../utils/feature-process"),_vote=require("../../utils/vote"),_theme=require("../../utils/theme"),_utils=require("../../utils/utils"),_storage=require("../../utils/storage");function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0,n={visibleIconList:e.slice(0,this.data.floatIconNum),hasMoreVisibleIcon:t};(0,_utils.isSmallPlainDataEqual)({visibleIconList:this.data.visibleIconList,hasMoreVisibleIcon:this.data.hasMoreVisibleIcon},n)||this.setData(n)},openImageTextCardDrawer:function(){this.triggerEvent("openImageTextCardDrawer")},notifyAttentionInteraction:function(){this.triggerEvent("attentionInteraction")},openMore:function(){this.data.isLandScape?this.triggerEvent("openImageTextTab"):this.openImageTextCardDrawer()},setIconList:function(e){var t=this,n=[],o=this._floatingIconList||[];e.forEach(function(e){var i;null===(i=e.Context)||void 0===i||i.forEach(function(i,r){var s,u,c,a,l=i.ImageTextType;if(!t.floatImage[l]&&null!=i&&i.CouponContext&&(l=_constant.ImageTextTypes.COUPON),l!==_constant.ImageTextTypes.LUCKMONEY||(0,_luckymoney.isLuckymoneyEnabled)(null===(s=t.store)||void 0===s||null===(u=s.get)||void 0===u?void 0:u.call(s,"liveInfo"))){if(t.floatImage[l]){var d=t.floatImage[l],f=d.field,I=d.idField,y=d.filter,m=d.statusRules,_=d.img,v=(null==i?void 0:i[f])||(l===_constant.ImageTextTypes.COUPON?null==i?void 0:i.CouponContext:null),g=v&&"object"===_typeof(v)?_objectSpread({},v):v?_defineProperty({},f,v):null;if(g&&l===_constant.ImageTextTypes.COUPON&&void 0!==i.AllowCloseIcon&&(g.AllowCloseIcon=i.AllowCloseIcon),!g)return;var p=FLOATING_ICON_TYPE_KEY_MAP[l];if(p&&!(0,_featureProcess.isFloatingInteractionIconVisible)(t.sdkInstance,p))return;if(l===_constant.ImageTextTypes.COUPON&&void 0===g.couponStatus){var k=(t.store.get("liveInfo")||{}).ActivityId,h=(t.store.get("userInfo")||{}).userId,T=h&&k&&(0,_coupon.isCouponPicked)(k,h,g.Id)?1:0;g.couponStatus=(0,_coupon.calcCouponStatus)(g,T)}if(l===_constant.ImageTextTypes.COUPON){var C=(t.store.get("userInfo")||{}).levelId;if(!(0,_coupon.isCouponLevelEligible)(null!=C?C:"",g))return}if(l===_constant.ImageTextTypes.QUESTION&&(g.Deadline=g.Deadline/60),g&&y(g)){var b,S,L=m.find(function(e){return"function"==typeof e.checker?e.checker(g):e.checker}),P=L.text,x=L.timeOverText,O=[e.ImageTextId||e.CreateTime||"",r,l,g[I]||""].join("_"),E=null===(b=null===(S=o.filter(function(e){return e.stableKey===O})[0])||void 0===S?void 0:S.visible)||void 0===b||b;n.push({stableKey:O,type:l,visible:E,img:"function"==typeof _?_(g):_,text:"function"==typeof P?P(g):P,timeOverText:x,current:g})}}}else null===(c=t.sdkInstance)||void 0===c||null===(a=c.reportLogger)||void 0===a||a.call(c,"".concat(_logger.LoggerPrefixObj.luckymoney,"_feature_disabled"),{from:"image-text-float"})})}),this._floatingIconList=n,this.syncVisibleFloatingIconList()},bindSocketEvents:function(){},onQuestionIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Question)||this.store.set("QuizInfo",{visible:!0,currentId:e.QuizID})},onQuestionnaireIconClick:function(e){if(!(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Questionnaire)){var t=null==e?void 0:e.QuestionnaireId,n={questionnaireId:t,from:"float"};this.sdkInstance&&"function"==typeof this.sdkInstance.reportLogger?this.sdkInstance.reportLogger("mini_sdk_questionnaire_entry_click",n):console.log("[mini-sdk] Questionnaire open via float",n),t&&this.store.set("QuestionnaireInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"float",isAuto:!1,isBlocking:!1})}},onCheckInIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.CheckIn)||this.store.set("CheckInInfo",{visible:!0,currentId:e.CheckInId})},onImageIconClick:function(e){this.triggerEvent("previewimage",{src:null==e?void 0:e.ImageTextContext})},onLotteryIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Lottery)||this.store.set("AwardInfo",{visible:!0,currentId:e.ID})},onCouponIconClick:function(e){var t,n;(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Coupon)||(this.sdkInstance.setShowCouponId(e.Id,"interactiveIcon"),this.sdkInstance&&null!==(t=this.sdkInstance.EVENTS)&&void 0!==t&&null!==(n=t.coupon)&&void 0!==n&&n.entryClick&&this.sdkInstance.emit(this.sdkInstance.EVENTS.coupon.entryClick,{couponId:e.Id,coupon:e}))},onLuckymoneyIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Luckymoney)||this.isLogin(!0)&&this.sdkInstance.openLuckymoneyModal(e.RedPacketID)},onVoteIconClick:function(e){var t=null==e?void 0:e.VoteId;t&&this.store.set("VoteInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"float",isAuto:!1})},onAnnouncementIconClick:function(e){null!=e&&e.AnnouncementId&&this.store.set("AnnouncementInfo",{visible:!0,currentId:e.AnnouncementId,triggerTime:"image_text",from:"float",isAuto:!1})},onLiveBonusIconClick:function(e){var t,n;this.isLogin(!0)&&null!=e&&e.Id&&(null===(t=(n=this.sdkInstance).openLiveBonusPanel)||void 0===t||t.call(n,e.Id,"floatIcon"))},getLuckymoneyUserStatus:function(e){var t;return((null===(t=this.luckymoneyStore.state)||void 0===t?void 0:t.userStatusMap)||{})[null==e?void 0:e.RedPacketID]||(0,_luckymoney.getUserStatusByStatus)(null==e?void 0:e.RedPacketStatus)},getLuckymoneyStatus:function(e){return(0,_luckymoney.getVisibleRedPacketStatus)(e,this.luckymoneyStore.state)},shouldShowLuckymoneyIcon:function(e){var t=this.getLuckymoneyStatus(e),n=this.getLuckymoneyUserStatus(e);return[_luckymoney.RedPacketStatus.SENT,_luckymoney.RedPacketStatus.INIT,_luckymoney.RedPacketStatus.OPENING].includes(t)||[_luckymoney.LuckyMoneyResult.ATTENDED,_luckymoney.LuckyMoneyResult.WIN,_luckymoney.LuckyMoneyResult.LOSE].includes(n)},isCheckInChecked:function(e){var t,n,o,i;if(null==e||!e.CheckInId)return!1;if(e.IsChecked)return!0;var r=((null===(t=this.store)||void 0===t||null===(n=t.get)||void 0===n?void 0:n.call(t,"mainInfo"))||{}).activityId,s=((null===(o=this.store)||void 0===o||null===(i=o.get)||void 0===i?void 0:i.call(o,"userInfo"))||{}).userId;if(!r||!s)return!1;var u=(0,_storage.safeGetStorageJSON)("checkedId",{}),c=r+"_"+s;return Array.isArray(u[c])&&u[c].includes(e.CheckInId)},isLogin:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return 2===((null===(e=this.store)||void 0===e?void 0:e.get("mainInfo"))||{}).mode||(t&&this.triggerEvent("commentCheck"),!1)},commentCheck:function(){this.triggerEvent("commentCheck")},previewImage:function(e){this.triggerEvent("previewimage",e.detail)},onClick:function(e){var t,n,o=null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n?void 0:n.item;o&&o.type&&this.floatImage[o.type]&&this.floatImage[o.type].onClick(o.current)},onClose:function(e){var t,n,o=null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n?void 0:n.item;if(o&&o.type&&this.floatImage[o.type]){var i=this._floatingIconList||[],r=i.findIndex(function(e){return e.stableKey===o.stableKey});if(!(r<0)){var s=_toConsumableArray(i);s[r]=_objectSpread(_objectSpread({},s[r]),{},{visible:!1}),this._floatingIconList=s,this.syncVisibleFloatingIconList()}}}}});