"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[7284],{24488:(e,s,t)=>{t.d(s,{US:()=>l,n4:()=>c,pt:()=>r});var i=t(39228),n=t(71111),o=t(31209),a=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const r=(0,n.atom)({allConversationTagGroupList:[],allConversationTagList:[],selectedConversationTagList:[],unreadOnly:!1,isLoading:!0});r.debugLabel="conversationTagAtom";const{useServiceState:d,useServiceDispatchers:l,useAtomService:c,getStaticApi:u}=(0,o.i)(r,((e,s)=>({setSelectedConversationTagList(e){s(r,(s=>Object.assign(Object.assign({},s),{selectedConversationTagList:e})))},setAllConversationTagGroupList(e){s(r,(s=>Object.assign(Object.assign({},s),{allConversationTagGroupList:e})))},setAllConversationTagList(e){s(r,(s=>Object.assign(Object.assign({},s),{allConversationTagList:e})))},setUnreadOnly(e){s(r,(s=>Object.assign(Object.assign({},s),{unreadOnly:e})))},setLoading(e){s(r,(s=>Object.assign(Object.assign({},s),{isLoading:e})))},getAllConversationTags(){var e;return a(this,void 0,void 0,(function*(){try{s(r,(e=>Object.assign(Object.assign({},e),{isLoading:!0})));const t=yield a(void 0,void 0,void 0,(function*(){return i.hd.get("/api/ba/business/suite/contact/label/mapping",{baseUrlType:2})})),n=null!==(e=t.label_groups)&&void 0!==e?e:[],o=n.filter((e=>e.labels&&e.labels.length>0)).map((e=>e.labels)).flat(2);this.setAllConversationTagGroupList(n),this.setAllConversationTagList(o)}catch(e){}finally{s(r,(e=>Object.assign(Object.assign({},e),{isLoading:!1})))}}))}})))},42952:(e,s,t)=>{t.d(s,{nU:()=>b,IA:()=>L,VI:()=>O,Yl:()=>C,by:()=>S});var i=t(71111),n=t(31209),o=t(25754),a=t(9350),r=t(60072),d=t(61918),l=t(34360),c=t(54888);const u=(0,l.y)(c.$);var g=t(41548),v=t(11983),h=t(39228),p=t(26325),f=t(4474),y=t(53737),M=t(33147),m=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const b=(0,i.atom)({friends:{},strangers:{},hasProcessedGroupChatUserMap:{},selectedConversation:void 0,currentMessage:{list:[],hasMore:!0},isLoadingMoreMessage:!1,failedMessageMap:{},hasFeedbackMap:{},failedVideoCodeMap:{},itemListByMessageId:[],recordedFocusOrigin:"",moderationResultMap:{},sendingProgressMap:{},lastUpdatedMap:{}});b.debugLabel="conversationAtom";const{useServiceState:S,useServiceDispatchers:C,useAtomService:O,getStaticApi:L}=(0,n.i)(b,((e,s)=>({setSelectedConversation(e){s(b,(s=>Object.assign(Object.assign({},s),{selectedConversation:e})))},setActionOpenedConversation(e){s(b,(s=>Object.assign(Object.assign({},s),{actionOpenedConversation:e})))},setUser(t){const{item:i,isStranger:n}=t,o=e(b);s(b,n?Object.assign(Object.assign({},o),{strangers:Object.assign(Object.assign({},o.strangers),{[i.id]:i})}):Object.assign(Object.assign({},o),{friends:Object.assign(Object.assign({},o.friends),{[i.id]:i})}))},addFailedMessage(e){s(b,(s=>Object.assign(Object.assign({},s),{failedMessageMap:Object.assign(Object.assign({},s.failedMessageMap),e)})))},setModerationResult(e){s(b,(s=>Object.assign(Object.assign({},s),{moderationResultMap:e})))},setProcessedGroupChatUsers(e){s(b,(s=>Object.assign(Object.assign({},s),{hasProcessedGroupChatUserMap:Object.assign(Object.assign({},s.hasProcessedGroupChatUserMap),{[e]:!0})})))},setLastUpdated(e){s(b,(s=>Object.assign(Object.assign({},s),{lastUpdatedMap:e})))},setSendingProgress(t){const{messageId:i,sendingProgress:n}=t,o=e(b).sendingProgressMap,a=Object.assign({},o);a[i]=n,s(b,(e=>Object.assign(Object.assign({},e),{sendingProgressMap:a})))},multiSetConversation(t){const{list:i,isStranger:n}=t,o=e(b),a={};i.forEach((e=>{a[e.id]=e})),s(b,n?Object.assign(Object.assign({},o),{strangers:Object.assign(Object.assign({},o.strangers),a)}):Object.assign(Object.assign({},o),{friends:Object.assign(Object.assign({},o.friends),a)}))},setMessageListAction(e){s(b,(s=>Object.assign(Object.assign({},s),{currentMessage:Object.assign(Object.assign({},s.currentMessage),{list:null!=e?e:[]})})))},setRecordedFocusOrigin(e){s(b,(s=>Object.assign(Object.assign({},s),{recordedFocusOrigin:e})))},setMessageHasMore(e){s(b,(s=>Object.assign(Object.assign({},s),{currentMessage:Object.assign(Object.assign({},s.currentMessage),{hasMore:e})})))},setIsLoadingMoreMessage(e){s(b,(s=>Object.assign(Object.assign({},s),{isLoadingMoreMessage:e})))},setHasFeedbackMap(e){s(b,(s=>Object.assign(Object.assign({},s),{hasFeedbackMap:Object.assign(Object.assign({},s.hasFeedbackMap),{[e]:!0})})))},setFailedVideoCodeMap(e){s(b,(s=>Object.assign(Object.assign({},s),{failedVideoCodeMap:Object.assign(Object.assign({},s.failedVideoCodeMap),e)})))},setItemListByMessageId(e){s(b,(s=>Object.assign(Object.assign({},s),{itemListByMessageId:e})))},setMessageList(s){return m(this,void 0,void 0,(function*(){const{list:t,shouldHandleVideoMessage:i,abTestVersion:n}=s,{items:o}=e(r.Pu),{failedVideoCodeMap:a}=e(b);if(!i)return void this.setMessageListAction(t);const d=[],l=[],c=[];t.forEach((e=>{const{type:s,content:t,clientId:i}=e;if(8!==s)return;let n={};try{n=JSON.parse(t)}catch(e){return null}const r=n.itemId;a[r]||(l.push(r),c.push(i),(null==o?void 0:o[r])||d.push(r))})),this.setMessageListAction(t),yield this.getVideoList({needRequestList:d,allList:l,allListByMessageId:c,abTestVersion:n})}))},handleMessageUpsert(s){return m(this,void 0,void 0,(function*(){const{message:t,abTestVersion:i}=s,{selectedConversation:n}=e(b);n&&[1802,1803].includes(t.type)&&7===t.source&&(yield this.getMessageList({id:null==n?void 0:n.id,shouldHandleVideoMessage:!1,abTestVersion:i}))}))},handleConversationLeave(s){return m(this,void 0,void 0,(function*(){const{selectedConversation:t}=e(b);(null==t?void 0:t.id)===s.id&&this.setSelectedConversation(void 0),yield(0,a.fI)().deleteConversation({conversation:s})}))},handleConversationUpsert(e){return m(this,void 0,void 0,(function*(){yield this.getMessageList({id:e.id,shouldHandleVideoMessage:!1})}))},handleConversationDelete(s){var t,i,n;const{selectedConversation:o}=e(b);if((null==o?void 0:o.id)===s.id){if(!o.isGroupChat){const e=null!==(t=o.toParticipantUserId)&&void 0!==t?t:"",s=null!==(n=null===(i=(0,M.py)().getUser(e))||void 0===i?void 0:i.uniqueId)&&void 0!==n?n:"";(0,y.Hz)("user-delete",{uid:e,uniqueId:s,conversationShortId:o.shortId})}this.setSelectedConversation(void 0)}},getMessageList(s){var t;return m(this,void 0,void 0,(function*(){try{const{id:i,shouldHandleVideoMessage:n,abTestVersion:o}=s,{friends:a,strangers:r,selectedConversation:d}=e(b),l=null!==(t=a[i])&&void 0!==t?t:r[i];if(!l)return;if(i!==(null==d?void 0:d.id))return;const c=l.getMessageList();yield this.setMessageList({list:c,shouldHandleVideoMessage:n,abTestVersion:o})}catch(e){}}))},loadMoreMessage(t){return m(this,void 0,void 0,(function*(){try{s(b,(e=>Object.assign(Object.assign({},e),{isLoadingMoreMessage:!0})));const{conversation:i,abTestVersion:n}=t,{selectedConversation:o}=e(b);if((null==o?void 0:o.id)!==i.id)return;const{hasMore:r}=yield(0,a.fI)().getMessagesByConversation({conversation:i}),d=i.getMessageList();this.setMessageHasMore(r),yield this.setMessageList({list:d,shouldHandleVideoMessage:!0,abTestVersion:n})}catch(e){}finally{s(b,(e=>Object.assign(Object.assign({},e),{isLoadingMoreMessage:!1})))}}))},setConversationSettingInfo(s){var t,i;return m(this,void 0,void 0,(function*(){const{friends:n,strangers:o}=e(b),{id:r,mute:d,stickOnTop:l}=s,c=null!==(i=null!==(t=n[r])&&void 0!==t?t:o[r])&&void 0!==i?i:{};yield(0,a.fI)().setConversationSettingInfo({conversation:c,mute:d,stickOnTop:l})}))},deleteConversation(s){var t,i,n,o;return m(this,void 0,void 0,(function*(){const{id:r}=s,{friends:d,selectedConversation:l}=e(b),c=null!==(t=d[r])&&void 0!==t?t:{};if(yield(0,a.fI)().deleteConversation({conversation:c}),(null==l?void 0:l.shortId)===c.shortId){if(!l.isGroupChat){const e=null!==(i=l.toParticipantUserId)&&void 0!==i?i:"",s=null!==(o=null===(n=(0,M.py)().getUser(e))||void 0===n?void 0:n.uniqueId)&&void 0!==o?o:"";(0,y.Hz)("user-delete",{uid:e,uniqueId:s,conversationShortId:l.shortId})}this.setSelectedConversation(void 0)}}))},markConversationRead(s){var t,i;return m(this,void 0,void 0,(function*(){const{id:n}=s,{friends:o,strangers:r}=e(b),d=null!==(i=null!==(t=o[n])&&void 0!==t?t:r[n])&&void 0!==i?i:{};yield(0,a.fI)().markConversationRead({conversation:d})}))},handleMessageSend(s){return m(this,void 0,void 0,(function*(){const{selectedConversation:t}=e(b);if(!t)return;const i=8===s.type;yield this.getMessageList({id:t.id,shouldHandleVideoMessage:i,abTestVersion:s.abTestVersion})}))},handleReceiveNewMessage(s){return m(this,void 0,void 0,(function*(){const{selectedConversation:t}=e(b);if(!t)return;const i=8===s.type;yield this.getMessageList({id:t.id,shouldHandleVideoMessage:i,abTestVersion:s.abTestVersion})}))},handleMessageDelete(s){var t,i,n;return m(this,void 0,void 0,(function*(){const{selectedConversation:o}=e(b);if(!o)return;const a=8===s.type;if(yield this.getMessageList({id:o.id,shouldHandleVideoMessage:a,abTestVersion:s.abTestVersion}),0===o.getMessageList().length&&(this.setSelectedConversation(void 0),!o.isGroupChat)){const e=null!==(t=o.toParticipantUserId)&&void 0!==t?t:"",s=null!==(n=null===(i=(0,M.py)().getUser(e))||void 0===i?void 0:i.uniqueId)&&void 0!==n?n:"";(0,y.Hz)("user-delete",{uid:e,uniqueId:s,conversationShortId:o.shortId})}}))},deleteMessage(e){return m(this,void 0,void 0,(function*(){const{message:s}=e;yield(0,a.fI)().deleteMessage({message:s})}))},likeMessage(e){return m(this,void 0,void 0,(function*(){const{message:s,isLiked:t}=e;yield(0,a.fI)().modifyMessageProperty({message:s,isLiked:t})}))},handleMessagePropertyUpsert(s){var t,i,n;return m(this,void 0,void 0,(function*(){const{friends:o,strangers:a,selectedConversation:r}=e(b),d=null!==(t=s.uid)&&void 0!==t?t:"",l=s.conversationId,c=null!==(n=null!==(i=o[l])&&void 0!==i?i:a[l])&&void 0!==n?n:{};if(s.property["e:love"]){const{sender:e}=s;if(e!==d)return;const t=s.property["e:love"],{length:i}=t,n=[];for(let e=0;e1){const{content:t}=e,i=t.match(/"server_message_id":(\d+)/);if(!i)return;const n=i[1];this.setModerationResult({[n]:s})}},updateMessageFromServer(e){return m(this,void 0,void 0,(function*(){const s=(0,a.fI)().getConversationByMessage({message:e});if(s){const t=yield(0,a.fI)().getMessages({messages:[e],conversation:s,upsert:!0});this.setLastUpdated({[e.clientId]:{timestamp:Date.now(),success:Boolean(t&&t.length>0)}})}}))},handleLoadMediaFail(e){const{message:s,mediaType:t,mediaUrl:i,error:n,scene:a}=e;console.log(s,i,n),o.w.handleMediaMessageShowFail({media_type:t,scene:a})},handleMediaModerationTimeout(e){const{message:s,mediaType:t,mediaUrl:i}=e;console.log(s,t,i)},feedbackMessage(s){return m(this,void 0,void 0,(function*(){const t=(0,g.T)(),i=t("direct_meaasge_sending_ban_feedback_again"),n=t("Sorry, something wrong with the server, please try again.");try{const{hasFeedbackMap:t}=e(b),{conversationId:o,shortId:a,uid:r,selfUid:d,content:l,messageId:c,serverMsgId:u,checkMessageStatusCode:g}=s;if(t[c])return void v.F.open({content:i,duration:3,widthType:"half"});const y=yield(({conversationId:e,shortId:s,uid:t,selfUid:i,content:n,messageId:o,serverMsgId:a,checkMessageStatusCode:r})=>m(void 0,void 0,void 0,(function*(){const d=f.stringify({conv_id:e,con_short_id:s,receiver_uid:t,content:n,msg_type:"7",biz_app_id:1988,scene:"sending_ban",msg_id:o,event:"tt_web_im",content_pb:"",server_msg_id:a,check_message_status_code:r,sending_ban_messages:`[${JSON.stringify({msg_id:o,server_msg_id:a,msg_type:"7",sender_uid:i,content:n,content_pb:"",banned:!1})}]`});return h.hd.post("/aweme/v1/im/msg/feedback/",{query:{report_type:"im",appId:1233},headers:{"Content-Type":p.Ty.FORM_ENCODE},body:d})})))({conversationId:o,shortId:a,uid:r,selfUid:d,content:l,messageId:c,serverMsgId:u,checkMessageStatusCode:g}),{status_code:M}=y;0===M?(v.F.open({content:i,duration:3,widthType:"half"}),this.setHasFeedbackMap(c)):v.F.open({content:n,duration:3,widthType:"half"})}catch(e){v.F.open({content:n,duration:3,widthType:"half"})}}))},getVideoList(s){return m(this,void 0,void 0,(function*(){try{const t=e(u),{needRequestList:i,allList:n,allListByMessageId:o}=s;i.length||((0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o));const a=i.map((e=>m(this,void 0,void 0,(function*(){var s,i,n,o;return yield(n=e,o=null===(i=null===(s=t.bizContext)||void 0===s?void 0:s.videoCoverSettings)||void 0===i?void 0:i.format,m(void 0,void 0,void 0,(function*(){return h.hd.get("/api/im/item_detail/",{query:{itemId:n,coverFormat:o},baseUrlType:2})})))})))),l=yield Promise.all(a),c={},g=[];l.forEach((({statusCode:e,itemInfo:s},t)=>{const a=i[t];if(0!==e){c[a]=e;const s=n.indexOf(a);s>-1&&(n.splice(s,1),o.splice(s,1))}else g.push(null==s?void 0:s.itemStruct)})),this.setFailedVideoCodeMap(c),(0,r.ud)().addItems(g),(0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o)}catch(e){console.error(e)}}))}})))},9350:(e,s,t)=>{t.d(s,{I9:()=>u,Ye:()=>g,fI:()=>p,rp:()=>v});var i=t(71111),n=t(31209),o=t(11983),a=t(41548),r=t(24488),d=t(29474),l=t(53737),c=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const u=(0,i.atom)({instance:void 0,options:void 0,friendsCursor:"0",groupCursor:"0",strangerCursor:"0",conversationTagCursor:"0",hasMoreFriends:!0,hasMoreGroup:!0,hasMoreStranger:!0,hasMoreConversationTag:!0,isFromBusiness:!1});u.debugLabel="imSdkAtom";const{useServiceState:g,useServiceDispatchers:v,useAtomService:h,getStaticApi:p}=(0,n.i)(u,((e,s)=>({initSdk(i,n=!1){return c(this,void 0,void 0,(function*(){try{{const o=yield Promise.all([t.e(4563),t.e(1329),t.e(4835),t.e(3305),t.e(6483),t.e(8904),t.e(759),t.e(4685),t.e(694),t.e(4714),t.e(6706),t.e(1960),t.e(1377),t.e(1798)]).then(t.bind(t,41294)),{instance:a}=e(u);if(a)return;const{BytedIM:r,ExtensionPlugin:d,UserPlugin:g,StrangerPlugin:v,MultimediaPlugin:h,im_proto:p,IMEvent:f,InitResult:y}=o;i.authType=p.AuthType.SESSION_AUTH,s(u,(e=>Object.assign(Object.assign({},e),{options:i,instance:new r(i,[d,v,g,h])})));const{options:M,instance:m}=e(u);if(!(null==m?void 0:m.event))throw new Error("[IM SDK] init failed!");[f.ConversationChange,f.MessageSend,f.ReceiveNewMessage,f.MessageDelete,f.MessagePropertyUpsert,f.ConversationLeave,f.MessageUpsert,f.RefreshMessage,f.ConversationUpsert,f.StrangerUpgrade,f.ConversationDelete].forEach((e=>{m.event.subscribe(e,(s=>c(this,void 0,void 0,(function*(){yield null==M?void 0:M.eventListener({event:e,params:s,uid:M.userId})}))))}));const b=yield m.init();return b===y.Succeeded&&((0,l.YJ)().setListLoading(!0),n?(this.loadFullFriendConversationV2(),this.loadFullStrangerConversationV2(),Array.isArray(null==M?void 0:M.inboxType)&&(null==M?void 0:M.inboxType.includes(1))&&this.loadFullGroupConversation()):yield Promise.all([this.loadFullFriendConversationV1(),this.loadFullStrangerConversationV1()]),(0,l.YJ)().setInitialized(!0),yield(0,l.YJ)().startConversationChange()),b}}catch(e){const s=(0,a.T)();o.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(`[IM SDK] init failed, e=${e}`)}}))},getMultiUsersByUids(s){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.getMultiUsersByUids({uids:s})}))},getConversationparticipants(s){var t;const{instance:i}=e(u),n=null==i?void 0:i.getConversationParticipants({conversation:s});return null!==(t=null==n?void 0:n.map((e=>e.userId)))&&void 0!==t?t:[]},getLocalConversationList(s){var t;const{instance:i}=e(u);return null!==(t=null==i?void 0:i.getConversationList({filter:s}))&&void 0!==t?t:[]},getConversationListOnline(s){return c(this,void 0,void 0,(function*(){try{const{instance:t}=e(u);if(!t)throw new Error("sdk is not defined");return yield t.getConversationListOnline({filter:s})}catch(e){const s=(0,a.T)();o.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreFriendConversation(){return c(this,void 0,void 0,(function*(){try{const{instance:t,friendsCursor:i,hasMoreFriends:n}=e(u);if(n){const e=yield null==t?void 0:t.getMessagesByUserInit({inboxType:0,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;s(u,(e=>Object.assign(Object.assign({},e),{friendsCursor:null!=n?n:"0",hasMoreFriends:null!=o&&o})))}}catch(e){const s=(0,a.T)();o.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreGroupConversation(){return c(this,void 0,void 0,(function*(){try{const{instance:t,groupCursor:i,hasMoreGroup:n}=e(u);if(n){const e=yield null==t?void 0:t.getMessagesByUserInit({inboxType:1,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;s(u,(e=>Object.assign(Object.assign({},e),{groupCursor:null!=n?n:"0",hasMoreGroup:null!=o&&o})))}}catch(e){const s=(0,a.T)();o.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreStrangerConversation(){return c(this,void 0,void 0,(function*(){try{const{instance:t,strangerCursor:i,hasMoreStranger:n}=e(u);if(n){const e=yield null==t?void 0:t.getMessagesByUserInit({inboxType:3,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;s(u,(e=>Object.assign(Object.assign({},e),{strangerCursor:null!=n?n:"0",hasMoreStranger:null!=o&&o})))}}catch(e){const s=(0,a.T)();o.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},createConversation({uid:s,inboxType:t}){return c(this,void 0,void 0,(function*(){const{instance:i}=e(u);return yield null==i?void 0:i.createConversation({participants:s,inboxType:t})}))},createMessage({type:s,content:t,conversation:i,fileInfo:n}){return c(this,void 0,void 0,(function*(){const{instance:o}=e(u);let a;if(n){const{fileType:e,fileHandler:t,width:r,height:d,onUploadProcess:l,onUploadComplete:c,onUploadError:u}=n,g=e.startsWith("image");a=yield null==o?void 0:o.createFileMessage({conversation:i,type:s,fileInfo:{type:g?"image":"video",fileHandler:t,displayType:"media",encrypt:!0,imagePreviewWidth:r,imagePreviewHeight:d,ext:g?{}:{"s:file_ext_key_video_width":`${r||0}`,"s:file_ext_key_video_height":`${d||0}`},onUploadProcess:e=>{var s;null==l||l(null!==(s=null==a?void 0:a.clientId)&&void 0!==s?s:"",e)},onUploadComplete:e=>{var s;null==c||c(null!==(s=null==a?void 0:a.clientId)&&void 0!==s?s:"",e)},onUploadError:e=>{var s;null==u||u(null!==(s=null==a?void 0:a.clientId)&&void 0!==s?s:"",e)}},scene:"private_"+(g?"image":"video")})}else a=yield null==o?void 0:o.createMessage({conversation:i,type:s,content:t});return a}))},sendMessage({message:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.sendMessage({message:s})}))},setConversationSettingInfo({conversation:s,mute:t,stickOnTop:i}){return c(this,void 0,void 0,(function*(){const{instance:n}=e(u);return yield null==n?void 0:n.setConversationSettingInfo({conversation:s,mute:t,stickOnTop:i})}))},deleteConversation({conversation:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.deleteConversation({conversation:s})}))},markConversationRead({conversation:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.markConversationRead({conversation:s})}))},getStrangerPreview(){return c(this,void 0,void 0,(function*(){const{instance:s}=e(u);return yield null==s?void 0:s.getStrangerPreview({})}))},getMessagesByConversation({conversation:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);if(!t)throw new Error("sdk is not defined");return yield t.getMessagesByConversation({conversation:s})}))},getStrangerConversationMessage({conversation:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.getStrangerConversationMessage({conversation:s})}))},deleteMessage({message:s}){return c(this,void 0,void 0,(function*(){const{instance:t}=e(u);return yield null==t?void 0:t.deleteMessage({message:s})}))},modifyMessageProperty({message:s,isLiked:i}){return c(this,void 0,void 0,(function*(){{const{im_proto:n}=yield Promise.all([t.e(4563),t.e(1329),t.e(4835),t.e(3305),t.e(6483),t.e(8904),t.e(759),t.e(4685),t.e(694),t.e(4714),t.e(6706),t.e(1960),t.e(1377),t.e(1798)]).then(t.bind(t,41294)),{instance:o}=e(u);return yield null==o?void 0:o.modifyMessageProperty({message:s,modifyContent:[{operation:i?n.OPERATION_TYPE.REMOVE_PROPERTY_ITEM:n.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:"e:love"}]})}}))},decryptMedia({message:s,fetchIndex:t}){return c(this,void 0,void 0,(function*(){const{instance:i}=e(u);return yield null==i?void 0:i.decryptMedia({message:s,fetchIndex:t})}))},getConversationByMessage({message:s}){const{instance:t}=e(u);return null==t?void 0:t.getConversation({conversationId:s.conversationId})},getMessages({messages:s,conversation:t,upsert:i}){return c(this,void 0,void 0,(function*(){const{instance:n}=e(u);return yield null==n?void 0:n.getMessages({messages:s,conversation:t,upsert:i})}))},loadMoreConversationsWithTags({isReset:t}){return c(this,void 0,void 0,(function*(){t&&s(u,(e=>Object.assign(Object.assign({},e),{hasMoreConversationTag:!0,conversationTagCursor:"0"})));const{hasMoreConversationTag:i,conversationTagCursor:n,instance:o}=e(u),{selectedConversationTagList:a}=e(r.pt);if(i){const e=yield null==o?void 0:o.getMessagesAndConversationsByTags({limit:20,cursor:n,tags:a.map((e=>e.label_id)),inboxType:0});e&&s(u,(s=>Object.assign(Object.assign({},s),{hasMoreConversationTag:e.hasMore,conversationTagCursor:e.nextCursor.toString()})))}}))},getConversationListByTags(){var s,t;const{instance:i}=e(u),{selectedConversationTagList:n}=e(r.pt),{conversationListType:o}=e(d.G7);return"friends"===o?(null!==(s=null==i?void 0:i.getConversationList({filter:e=>!e.isStrangerConversation}))&&void 0!==s?s:[]).filter((e=>{for(const s of n.map((e=>e.label_id)))if(!e.userConversationTags.includes(String(s)))return!1;return!0})):(null!==(t=null==i?void 0:i.getConversationList({filter:e=>e.isStrangerConversation}))&&void 0!==t?t:[]).filter((e=>{for(const s of n.map((e=>e.label_id)))if(!e.userConversationTags.includes(String(s)))return!1;return!0}))},loadFullFriendConversationV1(){return c(this,void 0,void 0,(function*(){const{options:s}=e(u);let{hasMoreFriends:t,hasMoreGroup:i}=e(u);if(Array.isArray(null==s?void 0:s.inboxType)&&(null==s?void 0:s.inboxType.includes(1)))for(;t||i;)t&&(yield this.loadMoreFriendConversation()),i&&(yield this.loadMoreGroupConversation()),t=e(u).hasMoreFriends,i=e(u).hasMoreGroup;else for(;t;)yield this.loadMoreFriendConversation(),t=e(u).hasMoreFriends}))},loadFullStrangerConversationV1(){return c(this,void 0,void 0,(function*(){let{hasMoreStranger:s}=e(u);for(;s;)yield this.loadMoreStrangerConversation(),s=e(u).hasMoreStranger}))},loadFullFriendConversationV2(){let s=!1;const t=setInterval((()=>c(this,void 0,void 0,(function*(){s||(s=!0,yield this.loadMoreFriendConversation(),e(u).hasMoreFriends||(clearInterval(t),yield(0,l.YJ)().startConversationChange()),s=!1)}))),1e3)},loadFullGroupConversation(){let s=!1;const t=setInterval((()=>c(this,void 0,void 0,(function*(){s||(s=!0,yield this.loadMoreGroupConversation(),e(u).hasMoreGroup||(clearInterval(t),yield(0,l.YJ)().startConversationChange()),s=!1)}))),1e3)},loadFullStrangerConversationV2(){let s=!1;const t=setInterval((()=>c(this,void 0,void 0,(function*(){s||(s=!0,yield this.loadMoreStrangerConversation(),e(u).hasMoreStranger||(clearInterval(t),yield(0,l.YJ)().startConversationChange()),s=!1)}))),1e3)}})))},29474:(e,s,t)=>{t.d(s,{G7:()=>_,Ks:()=>j,Xq:()=>T,g9:()=>I});var i,n,o,a=t(71111),r=t(31209),d=t(39228),l=t(26325),c=t(4474),u=t(53737),g=t(9350);!function(e){e[e.OpenPrivacySetting=0]="OpenPrivacySetting",e[e.Report=1]="Report",e[e.Feedback=2]="Feedback"}(i||(i={})),function(e){e[e.Default=0]="Default",e[e.Report=1]="Report"}(n||(n={})),function(e){e[e.InProgress=1]="InProgress",e[e.Pass=2]="Pass",e[e.Block=3]="Block",e[e.Risk=4]="Risk"}(o||(o={}));const v="webapp-dm-accepted-list";var h,p,f,y,M,m;!function(e){e.Friends="friends",e.Strangers="strangers"}(h||(h={})),function(e){e[e.None=0]="None",e[e.StartChatTip=1]="StartChatTip",e[e.Text=7]="Text",e[e.Video=8]="Video",e[e.Inline=1031]="Inline",e[e.BusinessInvitation=1037]="BusinessInvitation",e[e.GroupNoticeGuide=1039]="GroupNoticeGuide",e[e.Placeholder=49999]="Placeholder",e[e.Sticker=1805]="Sticker",e[e.LEGACY_MESSAGE_TYPE_EMOJI=5]="LEGACY_MESSAGE_TYPE_EMOJI",e[e.MsgTypeTemplatePictureCard=1802]="MsgTypeTemplatePictureCard",e[e.MsgTypeTemplateVideoCard=1803]="MsgTypeTemplateVideoCard"}(p||(p={})),function(e){e[e.CreateGroupNotice=103101]="CreateGroupNotice",e[e.RemoveUserNotice=103102]="RemoveUserNotice",e[e.AdminChangeNotice=103103]="AdminChangeNotice",e[e.LeftGroupNotice=103104]="LeftGroupNotice",e[e.AddMemberNotice=103105]="AddMemberNotice",e[e.GroupNameChangeNotice=103106]="GroupNameChangeNotice",e[e.RiskMemberJoinNotice=103107]="RiskMemberJoinNotice",e[e.GroupNameViolationNotice=103108]="GroupNameViolationNotice",e[e.GroupNameViolationOnSsh=103109]="GroupNameViolationOnSsh",e[e.GroupNameViolationReportWithLink=103110]="GroupNameViolationReportWithLink",e[e.RemoveMemberByServerNotice=103111]="RemoveMemberByServerNotice",e[e.CreateGroupAndAddMember=103112]="CreateGroupAndAddMember",e[e.RiskLevelWarningWithLink=103114]="RiskLevelWarningWithLink"}(f||(f={})),function(e){e.EcomEmail="ecom_email",e.Business="business"}(y||(y={})),function(e){e.MessageSend="message-send",e.UserSelect="user-select",e.MessageCountChange="new-message",e.OnLoad="on-load",e.UserDelete="user-delete"}(M||(M={})),function(e){e.CloseContactCard="close-contact-card",e.VideoChange="on-video-change",e.PlayVideo="play-video",e.PauseVideo="pause-video",e.MessagePageVisible="message-page-visible"}(m||(m={}));var b=t(11983),S=t(41548),C=t(42952),O=t(33147),L=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const _=(0,a.atom)({conversationListType:"friends",chatMode:0,notice:"",clickableNotice:null,showSettingModal:!1,acceptedStrangerList:[],reportResons:[],selectedReportReasons:[],isShowReportSelectModal:!1,isShowReportSuccessModal:!1,isShowContactButton:!1,isUsingV3Reasons:!0});_.debugLabel="messagePageAtom";const{useServiceState:I,useServiceDispatchers:T,useAtomService:j,getStaticApi:w}=(0,r.i)(_,((e,s)=>({setIsUsingV3Reasons(e){s(_,(s=>Object.assign(Object.assign({},s),{isUsingV3Reasons:e})))},setConversationListType(e){s(_,(s=>Object.assign(Object.assign({},s),{conversationListType:e})))},setChatMode(e){s(_,(s=>Object.assign(Object.assign({},s),{chatMode:e})))},setNotice(e){s(_,(s=>Object.assign(Object.assign({},s),{notice:e})))},setClickableNotice(e){s(_,(s=>Object.assign(Object.assign({},s),{clickableNotice:e})))},addAcceptedStranger(e){s(_,(s=>Object.assign(Object.assign({},s),{acceptedStrangerList:[...s.acceptedStrangerList,e]})))},setReportReasons(e){s(_,(s=>Object.assign(Object.assign({},s),{reportResons:e})))},setSelectedReportReasons(e){s(_,(s=>Object.assign(Object.assign({},s),{selectedReportReasons:e})))},setIsShowReportSelectModal(e){s(_,(s=>Object.assign(Object.assign({},s),{isShowReportSelectModal:e})))},setIsShowContactButton(e){s(_,(s=>Object.assign(Object.assign({},s),{isShowContactButton:e})))},setIsShowReportSuccessModal(e){s(_,(s=>Object.assign(Object.assign({},s),{isShowReportSuccessModal:e})))},getConversationNotice(e){return L(this,void 0,void 0,(function*(){try{const{secUid:t,conversationId:i}=e;if(!t||!i)return this.setNotice(""),void this.setClickableNotice(null);const n=yield(s={secUid:t,conversationId:i},L(void 0,void 0,void 0,(function*(){const{secUid:e,conversationId:t}=s;return d.hd.get("/api/im/chat/notice",{query:{sec_to_user_id:e,conversation_id:t,aid:1988},baseUrlType:2})}))),{data:o}=n;if(1022===o.msg_type){const{tips:e,template:s}=o.msg_content;if(s){const{key:t,name:i}=s[0]||{};this.setClickableNotice({desc:e,clickText:i,template:`{{${t}}}`,action:0})}else this.setNotice(e),this.setClickableNotice(null)}else this.setNotice(""),this.setClickableNotice(null)}catch(e){this.setNotice(""),this.setClickableNotice(null)}var s}))},acceptStranger(e){return L(this,void 0,void 0,(function*(){const{id:s,uid:t}=e,i=yield(({id:e,uid:s})=>L(void 0,void 0,void 0,(function*(){return d.hd.post("/api/im/stranger/unlimit",{query:{aid:1988},headers:{[l.nk]:d.hd.csrfToken},body:c.stringify({conversation_id:e,to_user_id:s}),baseUrlType:2})})))({id:s,uid:t}),{status_code:n}=i;if(0===n){const e=(()=>{var e;let s=[];try{const t=null!==(e=localStorage.getItem(v))&&void 0!==e?e:"";s=Array.isArray(JSON.parse(t))?JSON.parse(t):[]}catch(e){s=[]}return s})();e.push(s),localStorage.setItem(v,JSON.stringify(e)),this.addAcceptedStranger(s)}else{const e=(0,S.T)();b.F.open({content:e("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}}))},deleteStranger(s){var t,i,n;return L(this,void 0,void 0,(function*(){const{conversation:o}=s,{selectedConversation:a}=e(C.nU);yield(0,g.fI)().deleteConversation({conversation:o});const{strangerConversationList:r}=e(u.lU);if((0,u.YJ)().setStrangerConversationList(r.filter((e=>e.id!==o.id))),(null==a?void 0:a.shortId)===o.shortId){const e=null!==(t=o.toParticipantUserId)&&void 0!==t?t:"",s=null!==(n=null===(i=(0,O.py)().getUser(e))||void 0===i?void 0:i.uniqueId)&&void 0!==n?n:"";(0,u.Hz)("user-delete",{uid:e,uniqueId:s,conversationShortId:o.shortId}),(0,C.IA)().setSelectedConversation(void 0)}}))},getReportReasons(s){return L(this,void 0,void 0,(function*(){const{isUsingV3Reasons:t}=e(_),i=yield((e,s)=>L(void 0,void 0,void 0,(function*(){return d.hd.get("/node/report/reasons",{query:{report_type:"im",lang:e,api_version:s?3:2},baseUrlType:2})})))(s,t),{body:n=[]}=i;this.setReportReasons(n)}))},postReport(e){return L(this,void 0,void 0,(function*(){const s=(0,S.T)();try{const i=yield(t=e,L(void 0,void 0,void 0,(function*(){return d.hd.post("/aweme/v2/aweme/feedback/",{query:t,baseUrlType:2})}))),{status_code:n}=i;if(0!==n)return void b.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"});this.setChatMode(0),this.setIsShowReportSuccessModal(!0)}catch(e){b.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}var t}))}})))},53737:(e,s,t)=>{t.d(s,{YJ:()=>j,lU:()=>L,Hz:()=>O,D1:()=>T,_q:()=>I,VB:()=>_});var i=t(71111),n=t(31209),o=t(39228),a=t(58305),r=t(78662),d=t(9350),l=t(42952),c=t(25754),u=t(33147),g=t(84908),v=t(44841);const h=e=>{var s,t;return null!==(t=null===(s=null==e?void 0:e.url_list)||void 0===s?void 0:s.find((e=>!/\.webp/.test(e))))&&void 0!==t?t:""},p=({is_block:e,is_blocked:s,follow_status:t})=>{if(null!=t)return e?4:s?5:v.i[t]},f=e=>{const{avatar_medium:s,avatar_thumb:t,uid:i,short_id:n,unique_id:o,sec_uid:a,nickname:r,is_block:d,follow_status:l,signature:c,custom_verify:u,enterprise_verify_reason:g,follower_status:v}=e;return{avatarLarger:"",avatarMedium:h(s),avatarThumb:h(t),id:i,shortId:n,uniqueId:null!=o?o:"",secUid:null!=a?a:"",nickname:r,relation:p({is_block:d,is_blocked:void 0,follow_status:l}),signature:c,verified:Boolean(u||g),createTime:0,extraInfo:{followerStatus:v}}},y=e=>{const{users:s}=e;return s.map((e=>{var s,t,i,n,o;return{avatar_medium:e.im_user_profile.avatars.avatar_medium,avatar_thumb:null!==(s=e.im_user_profile.avatars.avatar_small)&&void 0!==s?s:{},uid:e.im_user_profile.user_id.toString(),short_id:"",unique_id:e.im_user_profile.unique_id,nickname:e.im_user_profile.nick_name,is_block:null!==(i=null===(t=e.im_user_profile.block_info)||void 0===t?void 0:t.block)&&void 0!==i&&i,follow_status:e.im_user_profile.follow_status,signature:"",custom_verify:null!==(n=e.im_user_profile.user_verify_reason)&&void 0!==n?n:"",enterprise_verify_reason:null!==(o=e.im_user_profile.enterprise_verify_reason)&&void 0!==o?o:"",follower_status:e.im_user_profile.follower_status}})).map((e=>f(e)))},M=(e,s,t)=>{const i=JSON.parse((0,a._S)(e));i[s]=t,(0,a.AP)(e,JSON.stringify(i))};var m=t(24488),b=t(29474),S=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const C="web_dm_storage_",O=(e,s)=>{try{if("business"!==new URLSearchParams(window.location.search).get("scene"))return;window.parent.postMessage({type:e,params:s},window.location.origin)}catch(e){console.error("postMessage error",e)}},L=(0,i.atom)({initialized:!1,messageCount:0,recentUserList:[],recentUserNameList:[],recentUidList:[],allUidList:[],followingUser:{list:[],nicknameList:[],uidList:[],hasMore:!0,maxCursor:0,minCursor:0},isFollowingLoading:!1,isSendMessageFailed:!1,isSendMessageLoading:!1,conversationMap:{},allConversationList:[],conversationList:[],strangerConversationList:[],successSentMessageCount:0,isListLoading:!0,recentUids:"",otherUid:"",isFirstTimeLoadHistory:!0,isFirstTimeLoadStranger:!0,isMediaSafeTipShown:!0,isMediaSelectionTipShown:!0,videoPlayerVolume:0});L.debugLabel="messageAtom";const{useServiceState:_,useServiceDispatchers:I,useAtomService:T,getStaticApi:j}=(0,n.i)(L,((e,s)=>({setMessageCount(e){s(L,(s=>Object.assign(Object.assign({},s),{messageCount:e}))),O("new-message",{count:e})},setConversationMap(e){s(L,(s=>Object.assign(Object.assign({},s),{conversationMap:e})))},setConversationList(e){e.sort(((e,s)=>{if(e.isStickOnTop&&s.isStickOnTop||!e.isStickOnTop&&!s.isStickOnTop){const t=Math.max(e.customLocalLike?e.customLocalLike.date.getTime():-1,e.lastVisibleMessage?e.lastVisibleMessage.createdAt.getTime():-1);return Math.max(s.customLocalLike?s.customLocalLike.date.getTime():-1,s.lastVisibleMessage?s.lastVisibleMessage.createdAt.getTime():-1)-t}return 0})),s(L,(s=>Object.assign(Object.assign({},s),{conversationList:e})))},setAllConversationList(e){s(L,(s=>Object.assign(Object.assign({},s),{allConversationList:e})))},setStrangerConversationList(e){s(L,(s=>Object.assign(Object.assign({},s),{strangerConversationList:e})))},setListLoading(e){s(L,(s=>Object.assign(Object.assign({},s),{isListLoading:e})))},setRecentUids(e){s(L,(s=>Object.assign(Object.assign({},s),{recentUids:e})))},updateRecentUserList(e){const{uniqueIdList:t,nicknameList:i,uidList:n}=e;s(L,(e=>Object.assign(Object.assign({},e),{recentUserList:[...t],recentUserNameList:[...i],recentUidList:[...n]})))},updateFollowingUserList(e){s(L,(s=>Object.assign(Object.assign({},s),{followingUser:e})))},setFollowingLoading(e){s(L,(s=>Object.assign(Object.assign({},s),{isFollowingLoading:e})))},setUidList(e){s(L,(s=>Object.assign(Object.assign({},s),{allUidList:e})))},addSentMessageSuccessCount(){const{successSentMessageCount:t}=e(L);s(L,(e=>Object.assign(Object.assign({},e),{successSentMessageCount:t+1})))},setSendMessageStatus(e){const{isFailed:t,isLoading:i,successCount:n}=e;s(L,(e=>Object.assign(Object.assign({},e),{isSendMessageFailed:null!=t&&t,isSendMessageLoading:null!=i&&i,successSentMessageCount:null!=n?n:e.successSentMessageCount})))},setOtherUid(e){s(L,(s=>Object.assign(Object.assign({},s),{otherUid:e})))},setInitialized(e){s(L,(s=>Object.assign(Object.assign({},s),{initialized:e})))},setIsMediaSafeTipShown(e){s(L,(s=>Object.assign(Object.assign({},s),{isMediaSafeTipShown:e})))},setIsMediaSelectionTipShown(e){s(L,(s=>Object.assign(Object.assign({},s),{isMediaSelectionTipShown:e})))},setVideoPlayerVolume(e){s(L,(s=>Object.assign(Object.assign({},s),{videoPlayerVolume:e})))},initWebDMLocalStorage(e){const s=`${C}${e}`;let t=!0;try{localStorage.getItem(s)}catch(e){t=!1}if(!t)return;const i=(0,a._S)(s);let n={},o=!1;try{i&&(n=JSON.parse(i))}catch(e){o=!0}i&&!o&&"object"==typeof n||((0,a.AP)(s,"{}"),n={}),n.isMediaSafeTipShown||this.setIsMediaSafeTipShown(!1),n.isMediaSelectionTipShown||this.setIsMediaSelectionTipShown(!1),"number"==typeof n.videoPlayerVolume&&this.setVideoPlayerVolume(n.videoPlayerVolume)},closeMediaSafeTip(e){M(`${C}${e}`,"isMediaSafeTipShown",!0),this.setIsMediaSafeTipShown(!0)},closeMediaSelectionTip(e){M(`${C}${e}`,"isMediaSelectionTipShown",!0),this.setIsMediaSelectionTipShown(!0)},saveVideoPlayerVolume(e){const{uid:s,volume:t}=e;M(`${C}${s}`,"videoPlayerVolume",t),this.setVideoPlayerVolume(t)},handleIMEvent(e){return S(this,void 0,void 0,(function*(){{const{IMEvent:s}=yield Promise.all([t.e(4563),t.e(1329),t.e(4835),t.e(3305),t.e(6483),t.e(8904),t.e(759),t.e(4685),t.e(694),t.e(4714),t.e(6706),t.e(1960),t.e(1377),t.e(1798)]).then(t.bind(t,41294)),{event:i,params:n,abTestVersion:o,uid:a}=e;switch(i){case s.ConversationChange:yield this.startConversationChange();break;case s.MessageSend:yield(0,l.IA)().handleMessageSend(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case s.ReceiveNewMessage:yield(0,l.IA)().handleReceiveNewMessage(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case s.MessageDelete:yield(0,l.IA)().handleMessageDelete(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case s.MessagePropertyUpsert:yield(0,l.IA)().handleMessagePropertyUpsert(Object.assign(Object.assign({},n),{uid:a}));break;case s.RefreshMessage:(0,l.IA)().handleRefreshMessage(Object.assign({},n));break;case s.MessageUpsert:yield(0,l.IA)().handleMessageUpsert({message:n,abTestVersion:o});break;case s.ConversationLeave:yield(0,l.IA)().handleConversationLeave(n);break;case s.ConversationDelete:(0,l.IA)().handleConversationDelete(n);break;case s.ConversationUpsert:yield(0,l.IA)().handleConversationUpsert(n);break;case s.StrangerUpgrade:yield this.getStrangerConversationList({isLoadMore:!1,forceRefresh:!0});break;default:return}}}))},startConversationChange(){var s;return S(this,void 0,void 0,(function*(){try{const{initialized:t}=e(L),{friendsCursor:i,groupCursor:n,hasMoreFriends:o,hasMoreGroup:a}=e(d.I9);if(!t||"0"===i&&o&&"0"===n&&a)return;this.setListLoading(!0);const r=null!==(s=yield(0,d.fI)().getConversationListOnline((e=>!e.isStrangerConversation)))&&void 0!==s?s:[],{selectedConversation:c}=e(l.nU),{otherUid:u}=e(L),g=[],v=new Set,h={};u&&(g.push(u),v.add(u));const p=r.reduce(((e,s)=>{var t;const{id:i,toParticipantUserId:n,unreadCount:o,isMuted:a}=s;if(s.isGroupChat){if((null===(t=s.lastMessage)||void 0===t?void 0:t.sender)&&v.add(s.lastMessage.sender),0!==o&&!a&&i!==(null==c?void 0:c.id))return e+1}else{const t=n;if(t&&(t!==u&&(g.push(t),v.add(t),h[t]=s),0!==o&&!a&&i!==(null==c?void 0:c.id)))return e+1}return e}),0),{selectedConversationTagList:f,unreadOnly:y}=e(m.pt),M=[this.setMessageCount(p),this.setConversationMap(h),this.setUidList(g),this.getMultiUsersByUids({uidList:Array.from(v),isGetRecentUsers:!0}),(0,l.IA)().multiSetConversation({list:r,isStranger:!1}),this.getStrangerConversationList({isLoadMore:!1,forceRefresh:!0}),this.setAllConversationList(r)];y||f.length>0?M.push(this.getConversationListWithFilter()):M.push(this.setConversationList(r)),yield Promise.all(M),y||0!==f.length||(yield this.getStrangerPreview()),this.setListLoading(!1)}catch(e){this.setListLoading(!1)}}))},getConversationListWithFilter(){return S(this,void 0,void 0,(function*(){const{unreadOnly:s,selectedConversationTagList:t}=e(m.pt),{conversationListType:i}=e(b.G7),{selectedConversation:n}=e(l.nU),o=(0,d.fI)().getConversationListByTags();if(s){const e=o.filter((e=>e.unreadCount>0||(null==n?void 0:n.shortId)===e.shortId));"friends"===i?this.setConversationList(e):this.setStrangerConversationList(e)}else"friends"===i?(this.setConversationList(o),0===t.length&&(yield this.getStrangerPreview())):this.setStrangerConversationList(o)}))},getStrangerPreview(){var s,t;return S(this,void 0,void 0,(function*(){try{const{users:i}=e(u.YK),{options:n}=e(d.I9);if(!n)return;const{allConversationList:o}=e(L),a=o.findIndex((e=>e.isStrangerConversation));a>-1&&o.splice(a,1);const r=yield(0,d.fI)().getStrangerPreview(),c=null==r?void 0:r.conversation,g=c.toParticipantUserId;if(!g)return;const v=[...o],h=null!==(t=null===(s=c.lastVisibleMessage)||void 0===s?void 0:s.createdAt.getTime())&&void 0!==t?t:-1;v.some(((e,s)=>{var t,i;return(null!==(i=null===(t=e.lastVisibleMessage)||void 0===t?void 0:t.createdAt.getTime())&&void 0!==i?i:-1)e.isStrangerConversation)))&&void 0!==i?i:[],s=a.reduce(((e,s)=>(e[s.id]=s,e)),{}),t=e.filter((e=>!u[e.id]||!s[e.id])),n=t.map((e=>{var s;return null!==(s=e.toParticipantUserId)&&void 0!==s?s:""}));this.setConversationMap(Object.assign(Object.assign({},s),c)),(0,l.IA)().multiSetConversation({list:t,isStranger:!0}),yield this.getMultiUsersByUids({uidList:n}),this.setStrangerConversationList(e)}r&&s(L,(e=>Object.assign(Object.assign({},e),{isFirstTimeLoadStranger:!1})))}))},getMultiUsersByUids(s){return S(this,void 0,void 0,(function*(){try{const{uidList:t,isGetRecentUsers:i}=s,{users:n}=e(u.YK),{otherUid:o,recentUids:a}=e(L),{pathname:l}=location;if(!(0,r.tO)(l)&&5===(0,r.M5)(l))return;const c=t.filter((e=>void 0===n[e])),g=String(t);if(!t.length||a===g||!c.length)return;const v=String(c);this.setRecentUids(v);const h=[];for(let e=0;e{p[e.id]=e}));const M=[],m=[],b=[];if(!c.map((e=>{if(p[e])return o===e&&O("user-select",{uid:e,uniqueId:p[e].uniqueId,from:"message-init"}),p[e].id=e,M.push(p[e].uniqueId),m.push(p[e].nickname),b.push(e),p[e];p[e]=null})).filter((e=>e)).length)return;(0,u.py)().multiSetUsers(p),i&&this.updateRecentUserList({uniqueIdList:M,nicknameList:m,uidList:b})}catch(e){}}))},getFollowingUserListWithCanShare(s){return S(this,void 0,void 0,(function*(){try{this.setFollowingLoading(!0);const{count:i}=s,{followingUser:n}=e(L),{list:a,nicknameList:r,uidList:d}=n,l=function(e,s){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&s.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n{var s;return M.push(null!==(s=e.unique_id)&&void 0!==s?s:""),m.push(e.nickname),b.push(e.uid),f(e)})),this.updateFollowingUserList({list:[...a,...M],nicknameList:[...r,...m],uidList:[...d,...b],maxCursor:v,minCursor:h,hasMore:Boolean(y)}),(0,g.Gp)().multiSetUser(e)}}catch(e){}finally{this.setFollowingLoading(!1)}var t}))},sendMessage(s){var t,i,n,o,a;return S(this,void 0,void 0,(function*(){try{const{uid:r,relation:u=0,type:g,content:v,hasConversation:h,chatType:p,messageType:f,convId:y,fileInfo:M}=s,{friends:m,strangers:b}=e(l.nU);let S;if(h){const e=null!==(t=m[y])&&void 0!==t?t:b[y];S=yield(0,d.fI)().createMessage({conversation:e,type:g,content:JSON.stringify(v),fileInfo:M})}else{const e=yield(0,d.fI)().createConversation({uid:r,inboxType:0}),s=null!==(i=null==e?void 0:e.payload)&&void 0!==i?i:{};S=yield(0,d.fI)().createMessage({conversation:s,type:g,content:JSON.stringify(v),fileInfo:M})}if(49999===g)return;if(void 0===S)throw new Error("create message response is undefined");const C=yield(0,d.fI)().sendMessage({message:S});if(void 0===C)throw new Error("send message response is undefined");const{success:L,checkMsg:_,serverMessageId:I,payload:T}=C;this.setSendMessageStatus({isFailed:!1,isLoading:!1}),this.addSentMessageSuccessCount(),L?(c.w.handleSendMessage({chat_type:null!=p?p:"private",conversation_id:null!==(n=null==T?void 0:T.conversationId)&&void 0!==n?n:"",relation_tag:u,to_user_id:r,message_type:null!=f?f:"share_video"}),O("message-send",{uid:r})):(c.w.handleFailSendMessage({chat_type:null!=p?p:"private",conversation_id:null!==(o=null==T?void 0:T.conversationId)&&void 0!==o?o:"",message_type:null!=f?f:"share_video",error_code:null!==(a=JSON.parse(null!=_?_:"{}").status_code)&&void 0!==a?a:-1,relation_tag:u,to_user_id:r}),(null==T?void 0:T.clientId)&&(0,l.IA)().addFailedMessage({[T.clientId]:{checkMsg:null!=_?_:"null",serverMessageId:I}}))}catch(e){const{uid:t,relation:i=0,chatType:n,messageType:o,convId:a}=s;console.error(e),c.w.handleFailSendMessage({chat_type:null!=n?n:"private",conversation_id:a,message_type:null!=o?o:"share_video",error_code:-1,relation_tag:i,to_user_id:t}),this.setSendMessageStatus({isFailed:!0,isLoading:!1})}}))},batchSendMessages(s){var t,i,n;return S(this,void 0,void 0,(function*(){const{uid:o,relation:a=0,hasConversation:r,chatType:u,convId:g,batchList:v}=s,{friends:h,strangers:p}=e(l.nU);let f;if(this.setSendMessageStatus({isFailed:!1,isLoading:!0}),r)f=null!==(i=null!==(t=h[g])&&void 0!==t?t:p[g])&&void 0!==i?i:{};else try{const e=yield(0,d.fI)().createConversation({uid:o,inboxType:0});f=null!==(n=null==e?void 0:e.payload)&&void 0!==n?n:{}}catch(e){console.log(e)}const y=v.map((e=>S(this,void 0,void 0,(function*(){var s,t;try{const{type:i,content:n,fileInfo:r,messageType:v}=e,h=yield(0,d.fI)().createMessage({conversation:f,type:i,content:JSON.stringify(n),fileInfo:r});if(h){const e=yield(0,d.fI)().sendMessage({message:h});if(e){const{success:i,checkMsg:n,payload:r,statusCode:d,statusMsg:h,serverMessageId:p}=e,f={chat_type:null!=u?u:"private",conversation_id:g,message_type:null!=v?v:"default",relation_tag:a,to_user_id:o};if(i)this.addSentMessageSuccessCount(),(0,l.IA)().setSendingProgress({messageId:null!==(s=null==r?void 0:r.clientId)&&void 0!==s?s:"",sendingProgress:{finished:!0}}),c.w.handleSendMessage(f),O("message-send",{uid:o});else{(null==r?void 0:r.clientId)&&(0,l.IA)().addFailedMessage({[r.clientId]:{checkMsg:null!=n?n:"null",serverMessageId:p}});const e=Object.assign(Object.assign({},f),{error_code:null!==(t=JSON.parse(null!=n?n:"{}").status_code)&&void 0!==t?t:-1,status_code:null!=d?d:-1,status_msg:null!=h?h:-1});c.w.handleFailSendMessage(e)}}}}catch(e){c.w.handleFailSendMessage({chat_type:null!=u?u:"private",conversation_id:g,message_type:"media",error_code:-1,relation_tag:a,to_user_id:o})}}))));try{yield Promise.allSettled(y),this.setSendMessageStatus({isFailed:!1,isLoading:!1})}catch(e){this.setSendMessageStatus({isFailed:!0,isLoading:!1})}}))},loadFullFriendConversations(){return S(this,void 0,void 0,(function*(){let{hasMoreFriends:s,hasMoreGroup:t}=e(d.I9);for(;s||t;)yield(0,d.fI)().loadMoreConversation(),s=e(d.I9).hasMoreFriends,t=e(d.I9).hasMoreGroup}))},loadFullStrangerConversation(){return S(this,void 0,void 0,(function*(){let{hasMoreStranger:s}=e(d.I9);for(;s;)yield(0,d.fI)().loadMoreStrangerConversation(),s=e(d.I9).hasMoreStranger}))}})))},33147:(e,s,t)=>{t.d(s,{EL:()=>g,L_:()=>v,Sk:()=>h,YK:()=>u,py:()=>p});var i=t(71111),n=t(31209),o=t(84908),a=t(39228),r=t(26325),d=t(11983),l=t(41548),c=function(e,s,t,i){return new(t||(t=Promise))((function(n,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function r(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var s;e.done?n(e.value):(s=e.value,s instanceof t?s:new t((function(e){e(s)}))).then(a,r)}d((i=i.apply(e,s||[])).next())}))};const u=(0,i.atom)({users:{}});u.debugLabel="messageUserAtom";const{useServiceState:g,useServiceDispatchers:v,useAtomService:h,getStaticApi:p}=(0,n.i)(u,((e,s)=>({getUser(s){const t=e(u),{users:i}=t;return i[s]},multiSetUsers(t){const i=e(u),{users:n}=i;s(u,{users:Object.assign(Object.assign({},n),t)})},setUserRelation({uid:t,relation:i}){const n=e(u),{users:o}=n,a=n.users[t];if(!a)return;const r=Object.assign(Object.assign({},a),{relation:i}),d=Object.assign({},o);d[t]=r,s(u,{users:Object.assign({},d)})},blockUser(s){var t;return c(this,void 0,void 0,(function*(){try{const{uid:n,isBlock:g}=s,v=e(u),{users:h}=v,{uniqueId:p=""}=null!==(t=h[n])&&void 0!==t?t:{},f=(0,l.T)(),y=yield(i={user_id:n,block_type:g?1:0},c(void 0,void 0,void 0,(function*(){return a.hd.post("/aweme/v1/user/block/",{query:Object.assign(Object.assign({},i),{source:3}),baseUrlType:2,headers:{[r.nk]:a.hd.csrfToken}})}))),{status_code:M}=y;if(0!==M)return void d.F.open({content:f("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"});const m=g?4:0;this.setUserRelation({uid:n,relation:m}),(0,o.Gp)().setUserRelation({uniqueId:p,relation:m})}catch(e){const s=(0,l.T)();d.F.open({content:s("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}var i}))}})))}}]);