"use strict";var _constant=require("../../utils/constant"),_util=require("../image-text-float/util"),_utils=require("../../utils/utils"),_jump=require("../../utils/jump"),_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"),_richTextParser=require("../../utils/rich-text-parser"),_theme=require("../../utils/theme");function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return(null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.IMAGE&&(null==e?void 0:e.ImageTextContext)}).map(function(e){return e.ImageTextContext})},normalizeDisplayContext:function(e,t){if((null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.TEXT){var n=this.normalizeTextContext(e);return{type:_constant.ImageTextTypes.TEXT,renderType:"text",text:n,segments:(0,_utils.parseTextWithLinks)(n)}}if((null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.IMAGE&&null!=e&&e.ImageTextContext){var o=this.getMessageImages(t),i=Math.max(o.findIndex(function(t){return t===e.ImageTextContext}),0);return{type:_constant.ImageTextTypes.IMAGE,renderType:"image",src:e.ImageTextContext,images:o,imageIndex:i,multiImages:o.length>1}}return null},setIconList:function(e){var t=this,n=[];e.forEach(function(e){var o=[],i=e.Context||[];i.forEach(function(e){var n=t.normalizeDisplayContext(e,i);if(n)o.push(n);else{var u=e.ImageTextType;if(!t.floatImage[u]&&null!=e&&e.CouponContext&&(u=_constant.ImageTextTypes.COUPON),u===_constant.ImageTextTypes.LUCKMONEY){var r,s,c,a,l=(null===(r=t.store)||void 0===r||null===(s=r.get)||void 0===s?void 0:s.call(r,"liveInfo"))||{};if(!(0,_luckymoney.isLuckymoneyEnabled)(l))return void(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-card"}))}if(t.floatImage[u]){var d=t.floatImage[u],y=d.field,f=d.fieldTitle,m=d.describe,p=d.statusRules,T=d.img,k=d.onClick,g=d.getTitle,h=(null==e?void 0:e[y])||(u===_constant.ImageTextTypes.COUPON?null==e?void 0:e.CouponContext:null);if(h){if(u===_constant.ImageTextTypes.COUPON){var I=(t.store.get("userInfo")||{}).levelId;if(!(0,_coupon.isCouponLevelEligible)(null!=I?I:"",h))return}var v=p.find(function(e){return"function"==typeof e.checker?e.checker(h):e.checker});if(!v)return;var b=v.buttonText,_=v.showCountDown,x=v.describe||m,C=("function"==typeof g?g(h):"")||(null==h?void 0:h[f])||(null==h?void 0:h.CouponName)||(null==h?void 0:h.Name)||(null==h?void 0:h.Title)||"";o.push({type:u,icon:"function"==typeof T?T(h):T,describeText:"function"==typeof x?x(h):x,title:"function"==typeof f?f(h):(0,_utils.getBySplit)(C),buttonText:b,buttonType:v.buttonType,onClick:function(){(k||v.onClick||function(){})(h)},showCountDown:"function"==typeof _?_(h):_,current:h})}}}}),o.length&&n.push(_objectSpread(_objectSpread({},e),{},{Context:o}))}),this.setData({iconList:n})},onQuestionClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Question)||this.store.set("QuizInfo",{visible:!0,currentId:e.QuizID})},onQuestionnaireClick:function(e){if(!(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Questionnaire)){var t=null==e?void 0:e.QuestionnaireId,n={questionnaireId:t,from:"card"};this.sdkInstance&&"function"==typeof this.sdkInstance.reportLogger?this.sdkInstance.reportLogger("mini_sdk_questionnaire_entry_click",n):console.log("[mini-sdk] Questionnaire open via card",n),t&&this.store.set("QuestionnaireInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"card",isAuto:!1,isBlocking:!1})}},onCheckInClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.CheckIn)||this.store.set("CheckInInfo",{visible:!0,currentId:e.CheckInId})},onLotteryClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Lottery)||this.store.set("AwardInfo",{visible:!0,currentId:e.ID})},onCouponClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Coupon)||this.sdkInstance.setShowCouponId(e.Id,"interactiveTool")},onLuckymoneyClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Luckymoney)||this.isLogin(!0)&&this.sdkInstance.openLuckymoneyModal(e.RedPacketID)},onVoteClick:function(e){var t=null==e?void 0:e.VoteId;t&&this.store.set("VoteInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"card",isAuto:!1})},onAnnouncementClick:function(e){null!=e&&e.AnnouncementId&&this.store.set("AnnouncementInfo",{visible:!0,currentId:e.AnnouncementId,triggerTime:"image_text",from:"card",isAuto:!1})},onLiveBonusClick: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,"cardList"))},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)},getLuckymoneyStatusText:function(e){switch(this.getLuckymoneyStatus(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""}},getLuckymoneyTitle:function(e){if(null!=e&&e.Name)return e.Name;var t=(null==e?void 0:e.TotalAmount)||0,n=(null==e?void 0:e.RedPacketType)===_luckymoney.RedPacketType.POINT;return null!=e&&e.HasNoLimit?n?"积分红包":"现金红包":n?"红包".concat(t).concat((null==e?void 0:e.RewardsPointsUnit)||""):"红包".concat((t||0)/100,"元")},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")},onClick:function(e){var t,n,o;null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n||null===(o=n.item)||void 0===o||o.onClick()},previewImage:function(e){var t,n=((null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.dataset)||{}).src;n&&this.triggerEvent("previewimage",{src:n})},onTextLinkClick:function(e){var t,n,o=(null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.dataset)||{},i=o.url,u=o.text;i&&(null===(n=this.sdkInstance)||void 0===n||n.emitEvent(_constant.EVENTS.PUBLIC.imageText.linkClick,{url:i,text:u||i}),(0,_jump.navigateToConfiguredWebview)(this.sdkInstance,_jump.JUMP_FEATURES.IMAGE_TEXT_LINK,i))}}});