"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[7284],{24488:(e,t,s)=>{s.d(t,{US:()=>c,n4:()=>l,pt:()=>r});var i=s(56070),n=s(43723),o=s(31209),a=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const r=(0,n.p)("conversationTagAtom@tiktok/webapp-atoms",{allConversationTagGroupList:[],allConversationTagList:[],selectedConversationTagList:[],unreadOnly:!1,isLoading:!0}),{useServiceState:d,useServiceDispatchers:c,useAtomService:l,getStaticApi:u}=(0,o.i)(r,((e,t)=>({setSelectedConversationTagList(e){t(r,(t=>Object.assign(Object.assign({},t),{selectedConversationTagList:e})))},setAllConversationTagGroupList(e){t(r,(t=>Object.assign(Object.assign({},t),{allConversationTagGroupList:e})))},setAllConversationTagList(e){t(r,(t=>Object.assign(Object.assign({},t),{allConversationTagList:e})))},setUnreadOnly(e){t(r,(t=>Object.assign(Object.assign({},t),{unreadOnly:e})))},setLoading(e){t(r,(t=>Object.assign(Object.assign({},t),{isLoading:e})))},getAllConversationTags(){var e;return a(this,void 0,void 0,(function*(){try{t(r,(e=>Object.assign(Object.assign({},e),{isLoading:!0})));const s=yield a(void 0,void 0,void 0,(function*(){return i.h.get("/api/ba/business/suite/contact/label/mapping",{baseUrlType:2})})),n=null!==(e=s.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{t(r,(e=>Object.assign(Object.assign({},e),{isLoading:!1})))}}))}})))},42952:(e,t,s)=>{s.d(t,{nU:()=>_,IA:()=>j,VI:()=>T,Yl:()=>L,by:()=>I});var i=s(43723),n=s(31209),o=s(25754),a=s(9350),r=s(60072),d=s(61918),c=s(34360),l=s(54888);const u=(0,c.y)(l.$);var g=s(41548),v=s(11983),h=s(56070),p=s(26325),f=s(71281),y=s(51250),m=s(4474),M=s(53737),b=s(33147),S=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const C=(e,t)=>S(void 0,void 0,void 0,(function*(){return h.h.get("/api/im/item_detail/",{query:{itemId:e,coverFormat:t},baseUrlType:2})})),O={friends:{},strangers:{},hasProcessedGroupChatUserMap:{},selectedConversation:void 0,currentMessage:{list:[],refMsgMap:new Map,hasMore:!0},isLoadingMoreMessage:!1,failedMessageMap:{},hasFeedbackMap:{},fetchingVideoCodeMap:{},failedVideoCodeMap:{},itemListByMessageId:[],recordedFocusOrigin:"",moderationResultMap:{},sendingProgressMap:{},lastUpdatedMap:{}},_=(0,i.p)("conversationAtom@tiktok/webapp-atoms",O),{useServiceState:I,useServiceDispatchers:L,useAtomService:T,getStaticApi:j}=(0,n.i)(_,((e,t)=>({setSelectedConversation(e){t(_,(t=>Object.assign(Object.assign({},t),{selectedConversation:e,refMessage:void 0})))},setActionOpenedConversation(e){t(_,(t=>Object.assign(Object.assign({},t),{actionOpenedConversation:e})))},setUser(s){const{item:i,isStranger:n}=s,o=e(_);t(_,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){t(_,(t=>Object.assign(Object.assign({},t),{failedMessageMap:Object.assign(Object.assign({},t.failedMessageMap),e)})))},setModerationResult(e){t(_,(t=>Object.assign(Object.assign({},t),{moderationResultMap:e})))},setProcessedGroupChatUsers(e){t(_,(t=>Object.assign(Object.assign({},t),{hasProcessedGroupChatUserMap:Object.assign(Object.assign({},t.hasProcessedGroupChatUserMap),{[e]:!0})})))},setLastUpdated(e){t(_,(t=>Object.assign(Object.assign({},t),{lastUpdatedMap:e})))},setSendingProgress(s){const{messageId:i,sendingProgress:n}=s,o=e(_).sendingProgressMap,a=Object.assign({},o);a[i]=n,t(_,(e=>Object.assign(Object.assign({},e),{sendingProgressMap:a})))},multiSetConversation(s){const{list:i,isStranger:n}=s,o=e(_),a={};i.forEach((e=>{a[e.id]=e})),t(_,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){t(_,(t=>{const{refMsgMap:s}=t.currentMessage;return null==e||e.forEach((e=>{if(!e.referenceInfo)return;const t=e.referenceInfo.referenced_message_id.toString();s.has(t)||s.set(t,null)})),null==e||e.forEach((e=>{null===s.get(e.serverId)&&s.set(e.serverId,e)})),Object.assign(Object.assign({},t),{currentMessage:Object.assign(Object.assign({},t.currentMessage),{list:null!=e?e:[]})})}))},setRecordedFocusOrigin(e){t(_,(t=>Object.assign(Object.assign({},t),{recordedFocusOrigin:e})))},setMessageHasMore(e){t(_,(t=>Object.assign(Object.assign({},t),{currentMessage:Object.assign(Object.assign({},t.currentMessage),{hasMore:e})})))},setIsLoadingMoreMessage(e){t(_,(t=>Object.assign(Object.assign({},t),{isLoadingMoreMessage:e})))},setHasFeedbackMap(e){t(_,(t=>Object.assign(Object.assign({},t),{hasFeedbackMap:Object.assign(Object.assign({},t.hasFeedbackMap),{[e]:!0})})))},setFailedVideoCodeMap(e){t(_,(t=>Object.assign(Object.assign({},t),{failedVideoCodeMap:Object.assign(Object.assign({},t.failedVideoCodeMap),e)})))},setItemListByMessageId(e){t(_,(t=>Object.assign(Object.assign({},t),{itemListByMessageId:e})))},setRefMessage(e){t(_,(t=>Object.assign(Object.assign({},t),{refMessage:e})))},removeRefMessage(){t(_,(e=>Object.assign(Object.assign({},e),{refMessage:void 0})))},setMessageList(e){return S(this,void 0,void 0,(function*(){const t=(0,f.d)("web_dm_quote_message");return"v2"===t||"v3"===t?this.setMessageListV2(e):this.setMessageListV1(e)}))},setMessageListV1(t){return S(this,void 0,void 0,(function*(){const{list:s,shouldHandleVideoMessage:i,abTestVersion:n}=t,{items:o}=e(r.Pu),{failedVideoCodeMap:a}=e(_);if(!i)return void this.setMessageListAction(s);const d=[],c=[],l=[];s.forEach((e=>{const{type:t,content:s,clientId:i}=e;if(8!==t)return;let n={};try{n=JSON.parse(s)}catch(e){return null}const r=n.itemId;a[r]||(c.push(r),l.push(i),(null==o?void 0:o[r])||d.push(r))})),this.setMessageListAction(s),yield this.getVideoListV1({needRequestList:d,allList:c,allListByMessageId:l,abTestVersion:n})}))},setMessageListV2(t){return S(this,void 0,void 0,(function*(){const{list:s,shouldHandleVideoMessage:i,abTestVersion:n}=t,{failedVideoCodeMap:o,fetchingVideoCodeMap:a}=e(_);if(!i)return void this.setMessageListAction(s);const d=[],c=[],l=[];s.forEach((e=>{const{type:t,content:s,clientId:i}=e;if(8!==t)return;let n={};try{n=JSON.parse(s)}catch(e){return null}const u=n.itemId;o[u]||(c.push(u),l.push(i),(0,r.ud)().getStaticItem(u)||a[u]||d.push(u))})),this.setMessageListAction(s),yield this.getVideoListV2({needRequestList:d,allList:c,allListByMessageId:l,abTestVersion:n})}))},handleMessageUpsert(t){return S(this,void 0,void 0,(function*(){const{message:s,abTestVersion:i}=t,{selectedConversation:n}=e(_);n&&[1802,1803].includes(s.type)&&7===s.source&&(yield this.getMessageList({id:null==n?void 0:n.id,shouldHandleVideoMessage:!1,abTestVersion:i}))}))},handleConversationLeave(t){return S(this,void 0,void 0,(function*(){const{selectedConversation:s}=e(_);(null==s?void 0:s.id)===t.id&&this.setSelectedConversation(void 0),yield(0,a.fI)().deleteConversation({conversation:t})}))},handleConversationUpsert(e){return S(this,void 0,void 0,(function*(){yield this.getMessageList({id:e.id,shouldHandleVideoMessage:!1})}))},handleConversationDelete(t){var s,i,n;const{selectedConversation:o}=e(_);if((null==o?void 0:o.id)===t.id){if(!o.isGroupChat){const e=null!==(s=o.toParticipantUserId)&&void 0!==s?s:"",t=null!==(n=null===(i=(0,b.py)().getUser(e))||void 0===i?void 0:i.uniqueId)&&void 0!==n?n:"";(0,M.Hz)("user-delete",{uid:e,uniqueId:t,conversationShortId:o.shortId})}this.setSelectedConversation(void 0)}},getMessageList(t){var s;return S(this,void 0,void 0,(function*(){try{const{id:i,shouldHandleVideoMessage:n,abTestVersion:o}=t,{friends:a,strangers:r,selectedConversation:d}=e(_),c=null!==(s=a[i])&&void 0!==s?s:r[i];if(!c)return;if(i!==(null==d?void 0:d.id))return;const l=c.getMessageList(y.U);yield this.setMessageList({list:l,shouldHandleVideoMessage:n,abTestVersion:o})}catch(e){}}))},loadMoreMessage(s){return S(this,void 0,void 0,(function*(){try{t(_,(e=>Object.assign(Object.assign({},e),{isLoadingMoreMessage:!0})));const{conversation:i,abTestVersion:n}=s,{selectedConversation:o}=e(_);if((null==o?void 0:o.id)!==i.id)return;const{hasMore:r}=yield(0,a.fI)().getMessagesByConversation({conversation:i}),d=i.getMessageList(y.U);this.setMessageHasMore(r),yield this.setMessageList({list:d,shouldHandleVideoMessage:!0,abTestVersion:n})}catch(e){}finally{t(_,(e=>Object.assign(Object.assign({},e),{isLoadingMoreMessage:!1})))}}))},setConversationSettingInfo(t){var s,i;return S(this,void 0,void 0,(function*(){const{friends:n,strangers:o}=e(_),{id:r,mute:d,stickOnTop:c}=t,l=null!==(i=null!==(s=n[r])&&void 0!==s?s:o[r])&&void 0!==i?i:{};yield(0,a.fI)().setConversationSettingInfo({conversation:l,mute:d,stickOnTop:c})}))},deleteConversation(t){var s,i,n,o;return S(this,void 0,void 0,(function*(){const{id:r}=t,{friends:d,selectedConversation:c}=e(_),l=null!==(s=d[r])&&void 0!==s?s:{};if(yield(0,a.fI)().deleteConversation({conversation:l}),(null==c?void 0:c.shortId)===l.shortId){if(!c.isGroupChat){const e=null!==(i=c.toParticipantUserId)&&void 0!==i?i:"",t=null!==(o=null===(n=(0,b.py)().getUser(e))||void 0===n?void 0:n.uniqueId)&&void 0!==o?o:"";(0,M.Hz)("user-delete",{uid:e,uniqueId:t,conversationShortId:c.shortId})}this.setSelectedConversation(void 0)}}))},markConversationRead(t){var s,i;return S(this,void 0,void 0,(function*(){const{id:n}=t,{friends:o,strangers:r}=e(_),d=null!==(i=null!==(s=o[n])&&void 0!==s?s:r[n])&&void 0!==i?i:{};yield(0,a.fI)().markConversationRead({conversation:d})}))},handleMessageSend(t){return S(this,void 0,void 0,(function*(){const{selectedConversation:s}=e(_);if(!s)return;const i=8===t.type;yield this.getMessageList({id:s.id,shouldHandleVideoMessage:i,abTestVersion:t.abTestVersion})}))},handleReceiveNewMessage(t){return S(this,void 0,void 0,(function*(){const{selectedConversation:s}=e(_);if(!s)return;const i=8===t.type;yield this.getMessageList({id:s.id,shouldHandleVideoMessage:i,abTestVersion:t.abTestVersion})}))},handleMessageDelete(t){var s,i,n;return S(this,void 0,void 0,(function*(){const{selectedConversation:o}=e(_);if(!o)return;const a=8===t.type;if(yield this.getMessageList({id:o.id,shouldHandleVideoMessage:a,abTestVersion:t.abTestVersion}),0===o.getMessageList(y.U).length&&(this.setSelectedConversation(void 0),!o.isGroupChat)){const e=null!==(s=o.toParticipantUserId)&&void 0!==s?s:"",t=null!==(n=null===(i=(0,b.py)().getUser(e))||void 0===i?void 0:i.uniqueId)&&void 0!==n?n:"";(0,M.Hz)("user-delete",{uid:e,uniqueId:t,conversationShortId:o.shortId})}}))},deleteMessage(e){return S(this,void 0,void 0,(function*(){const{message:t}=e;yield(0,a.fI)().deleteMessage({message:t})}))},likeMessage(e){return S(this,void 0,void 0,(function*(){const{message:t,isLiked:i}=e;{const{im_proto:e}=yield Promise.all([s.e(4563),s.e(3305),s.e(6706),s.e(8904),s.e(1960),s.e(4835),s.e(6483),s.e(759),s.e(4685),s.e(694),s.e(4714),s.e(1377),s.e(1798)]).then(s.bind(s,15226)),n=(0,a.fI)().getInstance();return yield null==n?void 0:n.modifyMessageProperty({message:t,modifyContent:[{operation:i?e.OPERATION_TYPE.REMOVE_PROPERTY_ITEM:e.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:"e:love"}]})}}))},reactToMessage({message:e,currentReaction:t,newReaction:i}){return S(this,void 0,void 0,(function*(){{const{im_proto:n}=yield Promise.all([s.e(4563),s.e(3305),s.e(6706),s.e(8904),s.e(1960),s.e(4835),s.e(6483),s.e(759),s.e(4685),s.e(694),s.e(4714),s.e(1377),s.e(1798)]).then(s.bind(s,15226)),o=(0,a.fI)().getInstance();let r;return!t&&i&&(r=[{operation:n.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:i},{operation:n.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:"e:love"}]),t&&i&&(r="e:love"===t?[{operation:n.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:i}]:[{operation:n.OPERATION_TYPE.REMOVE_PROPERTY_ITEM,key:t},{operation:n.OPERATION_TYPE.ADD_PROPERTY_ITEM,key:i}]),(t&&!i||t===i)&&(r=[{operation:n.OPERATION_TYPE.REMOVE_PROPERTY_ITEM,key:t},{operation:n.OPERATION_TYPE.REMOVE_PROPERTY_ITEM,key:"e:love"}]),r?yield null==o?void 0:o.modifyMessageProperty({message:e,modifyContent:r}):void console.warn("invalid operation",{currentReaction:t,newReaction:i})}}))},handleMessagePropertyUpsert(t){var s,i,n;return S(this,void 0,void 0,(function*(){const{friends:o,strangers:a,selectedConversation:r}=e(_),d=null!==(s=t.uid)&&void 0!==s?s:"",c=t.conversationId,l="v2"===(0,f.d)("web_dm_message_reaction"),u=null!==(n=null!==(i=o[c])&&void 0!==i?i:a[c])&&void 0!==n?n:{};if(l)if(t.property["e:love"]){const{sender:e}=t;if(e!==d)return;const s=t.property,{"e:love":i}=s,n=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n0?(o=c[0].split(":")[1],a=n[c[0]]):(o="❤️",a=i);const l=[];for(let e=0;e1){const{content:s}=e,i=s.match(/"server_message_id":(\d+)/);if(!i)return;const n=i[1];this.setModerationResult({[n]:t})}},updateMessageFromServer(e){return S(this,void 0,void 0,(function*(){const t=(0,a.fI)().getConversationByMessage({message:e});if(t){const s=yield(0,a.fI)().getMessages({messages:[e],conversation:t,upsert:!0});this.setLastUpdated({[e.clientId]:{timestamp:Date.now(),success:Boolean(s&&s.length>0)}})}}))},handleLoadMediaFail(e){const{message:t,mediaType:s,mediaUrl:i,error:n,scene:a}=e;console.log(t,i,n),o.w.handleMediaMessageShowFail({media_type:s,scene:a})},handleMediaModerationTimeout(e){const{message:t,mediaType:s,mediaUrl:i}=e;console.log(t,s,i)},feedbackMessage(t){return S(this,void 0,void 0,(function*(){const s=(0,g.T)(),i=s("direct_meaasge_sending_ban_feedback_again"),n=s("Sorry, something wrong with the server, please try again.");try{const{hasFeedbackMap:s}=e(_),{conversationId:o,shortId:a,uid:r,selfUid:d,content:c,messageId:l,serverMsgId:u,checkMessageStatusCode:g}=t;if(s[l])return void v.F.open({content:i,duration:3,widthType:"half"});const f=yield(({conversationId:e,shortId:t,uid:s,selfUid:i,content:n,messageId:o,serverMsgId:a,checkMessageStatusCode:r})=>S(void 0,void 0,void 0,(function*(){const d=m.stringify({conv_id:e,con_short_id:t,receiver_uid:s,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.h.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:c,messageId:l,serverMsgId:u,checkMessageStatusCode:g}),{status_code:y}=f;0===y?(v.F.open({content:i,duration:3,widthType:"half"}),this.setHasFeedbackMap(l)):v.F.open({content:n,duration:3,widthType:"half"})}catch(e){v.F.open({content:n,duration:3,widthType:"half"})}}))},getVideoListV1(t){return S(this,void 0,void 0,(function*(){try{const s=e(u),{needRequestList:i,allList:n,allListByMessageId:o}=t;i.length||((0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o));const a=i.map((e=>S(this,void 0,void 0,(function*(){var t,i;return yield C(e,null===(i=null===(t=s.bizContext)||void 0===t?void 0:t.videoCoverSettings)||void 0===i?void 0:i.format)})))),c=yield Promise.all(a),l={},g=[];c.forEach((({statusCode:e,itemInfo:t},s)=>{const a=i[s];if(0!==e){l[a]=e;const t=n.indexOf(a);t>-1&&(n.splice(t,1),o.splice(t,1))}else g.push(null==t?void 0:t.itemStruct)})),this.setFailedVideoCodeMap(l),(0,r.ud)().addItems(g),(0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o)}catch(e){console.error(e)}}))},getVideoListV2(t){return S(this,void 0,void 0,(function*(){try{const{failedVideoCodeMap:s}=e(_),{needRequestList:i,allList:n,allListByMessageId:o}=t;i.length||((0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o));const a=i.map((e=>this.getSingleItem(e))),r=yield Promise.all(a),c=[];r.forEach((({statusCode:e,itemStruct:t},a)=>{const r=i[a];if(0!==e){s[r]=e;const t=n.indexOf(r);t>-1&&(n.splice(t,1),o.splice(t,1))}else c.push(t)})),(0,d.Cg)().setItemListById({list:n}),this.setItemListByMessageId(o)}catch(e){console.error(e)}}))},getSingleItem(t){var s,i;return S(this,void 0,void 0,(function*(){const{fetchingVideoCodeMap:n,failedVideoCodeMap:o}=e(_),a=e(u);if((0,r.ud)().getStaticItem(t))return{itemStruct:(0,r.ud)().getStaticItem(t),statusCode:0};if(o[t])return{itemStruct:void 0,statusCode:o[t]};let d;n[t]||(n[t]=C(t,null===(i=null===(s=a.bizContext)||void 0===s?void 0:s.videoCoverSettings)||void 0===i?void 0:i.format)),d=yield n[t];const{statusCode:c,itemInfo:l}=d;return 0!==c?(o[t]=c,this.setFailedVideoCodeMap(o)):(0,r.ud)().addItems([l.itemStruct]),delete n[t],{itemStruct:null==l?void 0:l.itemStruct,statusCode:c}}))}})))},9350:(e,t,s)=>{s.d(t,{A5:()=>g,I9:()=>v,Ye:()=>h,fI:()=>y,rp:()=>p});var i=s(43723),n=s(31209),o=s(11983),a=s(41548),r=s(24488),d=s(29474),c=s(53737),l=s(71281),u=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const g=1,v=(0,i.p)("imSdkAtom@tiktok/webapp-atoms",{instance:void 0,options:void 0,friendsCursor:"0",groupCursor:"0",strangerCursor:"0",conversationTagCursor:"0",hasMoreFriends:!0,hasMoreGroup:!0,hasMoreStranger:!0,hasMoreConversationTag:!0,isFromBusiness:!1}),{useServiceState:h,useServiceDispatchers:p,useAtomService:f,getStaticApi:y}=(0,n.i)(v,((e,t)=>({getInstance(){const{instance:t}=e(v);return t},initSdk(i,n){var r,d;return u(this,void 0,void 0,(function*(){try{{const o=yield Promise.all([s.e(4563),s.e(3305),s.e(6706),s.e(8904),s.e(1960),s.e(4835),s.e(6483),s.e(759),s.e(4685),s.e(694),s.e(4714),s.e(1377),s.e(1798)]).then(s.bind(s,15226)),{instance:a}=e(v);if(a)return;const h="v2"===(null!==(r=(0,l.V7)(n,"web_dm_share_panel_fix"))&&void 0!==r?r:"v1"),p=null!==(d=(0,l.V7)(n,"web_dm_combo"))&&void 0!==d?d:"v1",{BytedIM:f,ExtensionPlugin:y,StrangerPlugin:m,MultimediaPlugin:M,ComboPlugin:b,im_proto:S,IMEvent:C,InitResult:O}=o;i.authType=S.AuthType.SESSION_AUTH;const _=[y,m,M];"v2"===p&&(_.push(b),i.enableOptimizedPull=!0),"v3"===p&&(_.push(b),i.enableOptimizedPull=!0,i.enablePassivePullControl=!0),t(v,(e=>Object.assign(Object.assign({},e),{options:i,instance:new f(i,_)})));const{options:I,instance:L}=e(v);if(!(null==L?void 0:L.event))throw new Error("[IM SDK] init failed!");[C.ConversationChange,C.MessageSend,C.ReceiveNewMessage,C.MessageDelete,C.MessagePropertyUpsert,C.ConversationLeave,C.MessageUpsert,C.RefreshMessage,C.ConversationUpsert,C.StrangerUpgrade,C.ConversationDelete].forEach((e=>{L.event.subscribe(e,(t=>u(this,void 0,void 0,(function*(){yield null==I?void 0:I.eventListener({event:e,params:t,uid:I.userId})}))))}));const T=yield L.init();return T===O.Succeeded&&((0,c.YJ)().setListLoading(!0),h?(this.loadFullFriendConversationV2(),this.loadFullStrangerConversationV2(),Array.isArray(null==I?void 0:I.inboxType)&&(null==I?void 0:I.inboxType.includes(g))&&this.loadFullGroupConversation()):yield Promise.all([this.loadFullFriendConversationV1(),this.loadFullStrangerConversationV1()]),(0,c.YJ)().setInitialized(!0),yield(0,c.YJ)().startConversationChange()),T}}catch(e){const t=(0,a.T)();o.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(`[IM SDK] init failed, e=${e}`)}}))},getConversationparticipants(t){var s;const{instance:i}=e(v),n=null==i?void 0:i.getConversationParticipants({conversation:t});return null!==(s=null==n?void 0:n.map((e=>e.userId)))&&void 0!==s?s:[]},getLocalConversationList(t){var s;const{instance:i}=e(v);return null!==(s=null==i?void 0:i.getConversationList({filter:t}))&&void 0!==s?s:[]},getConversationListOnline(t){return u(this,void 0,void 0,(function*(){try{const{instance:s}=e(v);if(!s)throw new Error("sdk is not defined");return yield s.getConversationListOnline({filter:t})}catch(e){const t=(0,a.T)();o.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreFriendConversation(){return u(this,void 0,void 0,(function*(){try{const{instance:s,friendsCursor:i,hasMoreFriends:n}=e(v);if(n){const e=yield null==s?void 0:s.getMessagesByUserInit({inboxType:0,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;t(v,(e=>Object.assign(Object.assign({},e),{friendsCursor:null!=n?n:"0",hasMoreFriends:null!=o&&o})))}}catch(e){const t=(0,a.T)();o.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreGroupConversation(){return u(this,void 0,void 0,(function*(){try{const{instance:s,groupCursor:i,hasMoreGroup:n}=e(v);if(n){const e=yield null==s?void 0:s.getMessagesByUserInit({inboxType:g,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;t(v,(e=>Object.assign(Object.assign({},e),{groupCursor:null!=n?n:"0",hasMoreGroup:null!=o&&o})))}}catch(e){const t=(0,a.T)();o.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},loadMoreStrangerConversation(){return u(this,void 0,void 0,(function*(){try{const{instance:s,strangerCursor:i,hasMoreStranger:n}=e(v);if(n){const e=yield null==s?void 0:s.getMessagesByUserInit({inboxType:3,cursor:i}),n=null==e?void 0:e.cursor.toString(),o=null==e?void 0:e.hasMore;t(v,(e=>Object.assign(Object.assign({},e),{strangerCursor:null!=n?n:"0",hasMoreStranger:null!=o&&o})))}}catch(e){const t=(0,a.T)();o.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"}),console.error(e)}}))},createConversation({uid:t,inboxType:s}){return u(this,void 0,void 0,(function*(){const{instance:i}=e(v);return yield null==i?void 0:i.createConversation({participants:t,inboxType:s})}))},createMessage({type:t,content:s,conversation:i,referenceMessage:n,fileInfo:o}){return u(this,void 0,void 0,(function*(){const{instance:a}=e(v);let r,d;if(n&&(r=JSON.stringify({content:n.content,refmsg_content:JSON.stringify(n.content||{}),refmsg_sec_uid:n.secSender,refmsg_type:n.type,refmsg_uid:n.sender,refmsg_sub_type:"",refmsg_template_quote:""})),o){const{fileType:e,fileHandler:s,width:c,height:l,onUploadProcess:u,onUploadComplete:g,onUploadError:v}=o,h=e.startsWith("image");d=yield null==a?void 0:a.createFileMessage({conversation:i,type:t,referenceMessage:n,referenceHint:r,fileInfo:{type:h?"image":"video",fileHandler:s,displayType:"media",encrypt:!0,imagePreviewWidth:c,imagePreviewHeight:l,ext:h?{}:{"s:file_ext_key_video_width":`${c||0}`,"s:file_ext_key_video_height":`${l||0}`},onUploadProcess:e=>{var t;null==u||u(null!==(t=null==d?void 0:d.clientId)&&void 0!==t?t:"",e)},onUploadComplete:e=>{var t;null==g||g(null!==(t=null==d?void 0:d.clientId)&&void 0!==t?t:"",e)},onUploadError:e=>{var t;null==v||v(null!==(t=null==d?void 0:d.clientId)&&void 0!==t?t:"",e)}},scene:"private_"+(h?"image":"video")})}else d=yield null==a?void 0:a.createMessage({conversation:i,type:t,content:s,referenceMessage:n,referenceHint:r});return d}))},sendMessage({message:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);return yield null==s?void 0:s.sendMessage({message:t})}))},setConversationSettingInfo({conversation:t,mute:s,stickOnTop:i}){return u(this,void 0,void 0,(function*(){const{instance:n}=e(v);return yield null==n?void 0:n.setConversationSettingInfo({conversation:t,mute:s,stickOnTop:i})}))},deleteConversation({conversation:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);return yield null==s?void 0:s.deleteConversation({conversation:t})}))},markConversationRead({conversation:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);return yield null==s?void 0:s.markConversationRead({conversation:t})}))},getStrangerPreview(){return u(this,void 0,void 0,(function*(){const{instance:t}=e(v);return yield null==t?void 0:t.getStrangerPreview({})}))},getMessagesByConversation({conversation:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);if(!s)throw new Error("sdk is not defined");return yield s.getMessagesByConversation({conversation:t})}))},getStrangerConversationMessage({conversation:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);return yield null==s?void 0:s.getStrangerConversationMessage({conversation:t})}))},deleteMessage({message:t}){return u(this,void 0,void 0,(function*(){const{instance:s}=e(v);return yield null==s?void 0:s.deleteMessage({message:t})}))},decryptMedia({message:t,fetchIndex:s}){return u(this,void 0,void 0,(function*(){const{instance:i}=e(v);return yield null==i?void 0:i.decryptMedia({message:t,fetchIndex:s})}))},getConversationByMessage({message:t}){const{instance:s}=e(v);return null==s?void 0:s.getConversation({conversationId:t.conversationId})},getMessages({messages:t,conversation:s,upsert:i}){return u(this,void 0,void 0,(function*(){const{instance:n}=e(v);return yield null==n?void 0:n.getMessages({messages:t,conversation:s,upsert:i})}))},loadMoreConversationsWithTags({isReset:s}){return u(this,void 0,void 0,(function*(){s&&t(v,(e=>Object.assign(Object.assign({},e),{hasMoreConversationTag:!0,conversationTagCursor:"0"})));const{hasMoreConversationTag:i,conversationTagCursor:n,instance:o}=e(v),{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&&t(v,(t=>Object.assign(Object.assign({},t),{hasMoreConversationTag:e.hasMore,conversationTagCursor:e.nextCursor.toString()})))}}))},getConversationListByTags(){var t,s;const{instance:i}=e(v),{selectedConversationTagList:n}=e(r.pt),{conversationListType:o}=e(d.G7);return"friends"===o?(null!==(t=null==i?void 0:i.getConversationList({filter:e=>!e.isStrangerConversation}))&&void 0!==t?t:[]).filter((e=>{for(const t of n.map((e=>e.label_id)))if(!e.userConversationTags.includes(String(t)))return!1;return!0})):(null!==(s=null==i?void 0:i.getConversationList({filter:e=>e.isStrangerConversation}))&&void 0!==s?s:[]).filter((e=>{for(const t of n.map((e=>e.label_id)))if(!e.userConversationTags.includes(String(t)))return!1;return!0}))},loadFullFriendConversationV1(){return u(this,void 0,void 0,(function*(){const{options:t}=e(v);let{hasMoreFriends:s,hasMoreGroup:i}=e(v);if(Array.isArray(null==t?void 0:t.inboxType)&&(null==t?void 0:t.inboxType.includes(g)))for(;s||i;)s&&(yield this.loadMoreFriendConversation()),i&&(yield this.loadMoreGroupConversation()),s=e(v).hasMoreFriends,i=e(v).hasMoreGroup;else for(;s;)yield this.loadMoreFriendConversation(),s=e(v).hasMoreFriends}))},loadFullStrangerConversationV1(){return u(this,void 0,void 0,(function*(){let{hasMoreStranger:t}=e(v);for(;t;)yield this.loadMoreStrangerConversation(),t=e(v).hasMoreStranger}))},loadFullFriendConversationV2(){const t=()=>u(this,void 0,void 0,(function*(){e(v).hasMoreFriends?(yield this.loadMoreFriendConversation(),setTimeout((()=>{t()}),0)):yield(0,c.YJ)().startConversationChange()}));t()},loadFullGroupConversation(){const t=()=>u(this,void 0,void 0,(function*(){e(v).hasMoreGroup?(yield this.loadMoreGroupConversation(),setTimeout((()=>{t()}),0)):yield(0,c.YJ)().startConversationChange()}));t()},loadFullStrangerConversationV2(){const t=()=>u(this,void 0,void 0,(function*(){e(v).hasMoreStranger&&(yield this.loadMoreStrangerConversation(),setTimeout((()=>{t()}),0))}));t()}})))},29474:(e,t,s)=>{s.d(t,{G7:()=>I,Ks:()=>j,Xq:()=>T,g9:()=>L});var i,n,o,a=s(43723),r=s(31209),d=s(56070),c=s(26325),l=s(4474),u=s(53737),g=s(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=s(11983),S=s(41548),C=s(42952),O=s(33147),_=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const I=(0,a.p)("messagePageAtom@tiktok/webapp-atoms",{conversationListType:"friends",chatMode:0,notice:"",clickableNotice:null,showSettingModal:!1,acceptedStrangerList:[],reportResons:[],selectedReportReasons:[],isShowReportSelectModal:!1,isShowReportSuccessModal:!1,isShowContactButton:!1,isUsingV3Reasons:!0}),{useServiceState:L,useServiceDispatchers:T,useAtomService:j,getStaticApi:w}=(0,r.i)(I,((e,t)=>({setIsUsingV3Reasons(e){t(I,(t=>Object.assign(Object.assign({},t),{isUsingV3Reasons:e})))},setConversationListType(e){t(I,(t=>Object.assign(Object.assign({},t),{conversationListType:e})))},setChatMode(e){t(I,(t=>Object.assign(Object.assign({},t),{chatMode:e})))},setNotice(e){t(I,(t=>Object.assign(Object.assign({},t),{notice:e})))},setClickableNotice(e){t(I,(t=>Object.assign(Object.assign({},t),{clickableNotice:e})))},addAcceptedStranger(e){t(I,(t=>Object.assign(Object.assign({},t),{acceptedStrangerList:[...t.acceptedStrangerList,e]})))},setReportReasons(e){t(I,(t=>Object.assign(Object.assign({},t),{reportResons:e})))},setSelectedReportReasons(e){t(I,(t=>Object.assign(Object.assign({},t),{selectedReportReasons:e})))},setIsShowReportSelectModal(e){t(I,(t=>Object.assign(Object.assign({},t),{isShowReportSelectModal:e})))},setIsShowContactButton(e){t(I,(t=>Object.assign(Object.assign({},t),{isShowContactButton:e})))},setIsShowReportSuccessModal(e){t(I,(t=>Object.assign(Object.assign({},t),{isShowReportSuccessModal:e})))},getConversationNotice(e){return _(this,void 0,void 0,(function*(){try{const{secUid:s,conversationId:i}=e;if(!s||!i)return this.setNotice(""),void this.setClickableNotice(null);const n=yield(t={secUid:s,conversationId:i},_(void 0,void 0,void 0,(function*(){const{secUid:e,conversationId:s}=t;return d.h.get("/api/im/chat/notice",{query:{sec_to_user_id:e,conversation_id:s,aid:1988},baseUrlType:2})}))),{data:o}=n;if(1022===o.msg_type){const{tips:e,template:t}=o.msg_content;if(t){const{key:s,name:i}=t[0]||{};this.setClickableNotice({desc:e,clickText:i,template:`{{${s}}}`,action:0})}else this.setNotice(e),this.setClickableNotice(null)}else this.setNotice(""),this.setClickableNotice(null)}catch(e){this.setNotice(""),this.setClickableNotice(null)}var t}))},acceptStranger(e){return _(this,void 0,void 0,(function*(){const{id:t,uid:s}=e,i=yield(({id:e,uid:t})=>_(void 0,void 0,void 0,(function*(){return d.h.post("/api/im/stranger/unlimit",{query:{aid:1988},headers:{[c.nk]:d.h.csrfToken},body:l.stringify({conversation_id:e,to_user_id:t}),baseUrlType:2})})))({id:t,uid:s}),{status_code:n}=i;if(0===n){const e=(()=>{var e;let t=[];try{const s=null!==(e=localStorage.getItem(v))&&void 0!==e?e:"";t=Array.isArray(JSON.parse(s))?JSON.parse(s):[]}catch(e){t=[]}return t})();e.push(t),localStorage.setItem(v,JSON.stringify(e)),this.addAcceptedStranger(t)}else{const e=(0,S.T)();b.F.open({content:e("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}return i}))},deleteStranger(t){var s,i,n;return _(this,void 0,void 0,(function*(){const{conversation:o}=t,{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!==(s=o.toParticipantUserId)&&void 0!==s?s:"",t=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:t,conversationShortId:o.shortId}),(0,C.IA)().setSelectedConversation(void 0)}}))},getReportReasons(t){return _(this,void 0,void 0,(function*(){const{isUsingV3Reasons:s}=e(I),i=yield((e,t)=>_(void 0,void 0,void 0,(function*(){return d.h.get("/node/report/reasons",{query:{report_type:"im",lang:e,api_version:t?3:2},baseUrlType:2})})))(t,s),{body:n=[]}=i;this.setReportReasons(n)}))},postReport(e){return _(this,void 0,void 0,(function*(){const t=(0,S.T)();try{const i=yield(s=e,_(void 0,void 0,void 0,(function*(){return d.h.post("/aweme/v2/aweme/feedback/",{query:s,baseUrlType:2})}))),{status_code:n}=i;if(0!==n)return void b.F.open({content:t("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:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}var s}))}})))},53737:(e,t,s)=>{s.d(t,{YJ:()=>U,lU:()=>T,Hz:()=>I,D1:()=>k,_q:()=>w,VB:()=>j});var i=s(43723),n=s(31209),o=s(56070),a=s(58305),r=s(95868),d=s(9350),c=s(42952),l=s(25754),u=s(33147),g=s(84908),v=s(44841);const h=e=>{var t,s;return null!==(s=null===(t=null==e?void 0:e.url_list)||void 0===t?void 0:t.find((e=>!/\.webp/.test(e))))&&void 0!==s?s:""},p=({is_block:e,is_blocked:t,follow_status:s})=>{if(null!=s)return e?4:t?5:v.i[s]},f=e=>{const{avatar_medium:t,avatar_thumb:s,uid:i,short_id:n,unique_id:o,sec_uid:a,nickname:r,is_block:d,follow_status:c,signature:l,custom_verify:u,enterprise_verify_reason:g,follower_status:v}=e;return{avatarLarger:"",avatarMedium:h(t),avatarThumb:h(s),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:c}),signature:l,verified:Boolean(u||g),createTime:0,extraInfo:{followerStatus:v}}},y=e=>{const{users:t=[]}=e;return t.map((e=>{var t,s,i,n,o;return{avatar_medium:e.im_user_profile.avatars.avatar_medium,avatar_thumb:null!==(t=e.im_user_profile.avatars.avatar_small)&&void 0!==t?t:{},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===(s=e.im_user_profile.block_info)||void 0===s?void 0:s.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,t,s)=>{const i=JSON.parse((0,a._S)(e));i[t]=s,(0,a.AP)(e,JSON.stringify(i))};var M=s(24488),b=s(29474),S=s(96266),C=s.n(S),O=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const _="web_dm_storage_",I=(e,t)=>{try{if("business"!==new URLSearchParams(window.location.search).get("scene"))return;window.parent.postMessage({type:e,params:t},window.location.origin)}catch(e){console.error("postMessage error",e)}},L=e=>O(void 0,void 0,void 0,(function*(){try{const t=new URLSearchParams({aid:"1988",user_ids:`[${e.map((e=>`"${e}"`)).join(",")}]`}),s=yield window.fetch.call(null,`/tiktok/v1/im/user/profile/?${t}`,{method:"GET"}),i=yield s.text();return C().parse(i)}catch(e){return console.log("err when parsing regex",e),{statusCode:"400"}}})),T=(0,i.p)("messageAtom@tiktok/webapp-atoms",{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}),{useServiceState:j,useServiceDispatchers:w,useAtomService:k,getStaticApi:U}=(0,n.i)(T,((e,t)=>({setMessageCount(e){t(T,(t=>Object.assign(Object.assign({},t),{messageCount:e}))),I("new-message",{count:e})},setConversationMap(e){t(T,(t=>Object.assign(Object.assign({},t),{conversationMap:e})))},setConversationList(e){e.sort(((e,t)=>{if(e.isStickOnTop&&t.isStickOnTop||!e.isStickOnTop&&!t.isStickOnTop){const s=Math.max(e.customLocalLike?e.customLocalLike.date.getTime():-1,e.lastVisibleMessage?e.lastVisibleMessage.createdAt.getTime():-1);return Math.max(t.customLocalLike?t.customLocalLike.date.getTime():-1,t.lastVisibleMessage?t.lastVisibleMessage.createdAt.getTime():-1)-s}return 0})),t(T,(t=>Object.assign(Object.assign({},t),{conversationList:e})))},setAllConversationList(e){t(T,(t=>Object.assign(Object.assign({},t),{allConversationList:e})))},setStrangerConversationList(e){t(T,(t=>Object.assign(Object.assign({},t),{strangerConversationList:e})))},setListLoading(e){t(T,(t=>Object.assign(Object.assign({},t),{isListLoading:e})))},setRecentUids(e){t(T,(t=>Object.assign(Object.assign({},t),{recentUids:e})))},updateRecentUserList(e){const{uniqueIdList:s,nicknameList:i,uidList:n}=e;t(T,(e=>Object.assign(Object.assign({},e),{recentUserList:[...s],recentUserNameList:[...i],recentUidList:[...n]})))},updateFollowingUserList(e){t(T,(t=>Object.assign(Object.assign({},t),{followingUser:e})))},setFollowingLoading(e){t(T,(t=>Object.assign(Object.assign({},t),{isFollowingLoading:e})))},setUidList(e){t(T,(t=>Object.assign(Object.assign({},t),{allUidList:e})))},addSentMessageSuccessCount(){const{successSentMessageCount:s}=e(T);t(T,(e=>Object.assign(Object.assign({},e),{successSentMessageCount:s+1})))},setSendMessageStatus(e){const{isFailed:s,isLoading:i,successCount:n}=e;t(T,(e=>Object.assign(Object.assign({},e),{isSendMessageFailed:null!=s&&s,isSendMessageLoading:null!=i&&i,successSentMessageCount:null!=n?n:e.successSentMessageCount})))},setOtherUid(e){t(T,(t=>Object.assign(Object.assign({},t),{otherUid:e})))},setInitialized(e){t(T,(t=>Object.assign(Object.assign({},t),{initialized:e})))},setIsMediaSafeTipShown(e){t(T,(t=>Object.assign(Object.assign({},t),{isMediaSafeTipShown:e})))},setIsMediaSelectionTipShown(e){t(T,(t=>Object.assign(Object.assign({},t),{isMediaSelectionTipShown:e})))},setVideoPlayerVolume(e){t(T,(t=>Object.assign(Object.assign({},t),{videoPlayerVolume:e})))},initWebDMLocalStorage(e){const t=`${_}${e}`;let s=!0;try{localStorage.getItem(t)}catch(e){s=!1}if(!s)return;const i=(0,a._S)(t);let n={},o=!1;try{i&&(n=JSON.parse(i))}catch(e){o=!0}i&&!o&&"object"==typeof n||((0,a.AP)(t,"{}"),n={}),n.isMediaSafeTipShown||this.setIsMediaSafeTipShown(!1),n.isMediaSelectionTipShown||this.setIsMediaSelectionTipShown(!1),"number"==typeof n.videoPlayerVolume&&this.setVideoPlayerVolume(n.videoPlayerVolume)},closeMediaSafeTip(e){m(`${_}${e}`,"isMediaSafeTipShown",!0),this.setIsMediaSafeTipShown(!0)},closeMediaSelectionTip(e){m(`${_}${e}`,"isMediaSelectionTipShown",!0),this.setIsMediaSelectionTipShown(!0)},saveVideoPlayerVolume(e){const{uid:t,volume:s}=e;m(`${_}${t}`,"videoPlayerVolume",s),this.setVideoPlayerVolume(s)},handleIMEvent(e){return O(this,void 0,void 0,(function*(){{const{IMEvent:t}=yield Promise.all([s.e(4563),s.e(3305),s.e(6706),s.e(8904),s.e(1960),s.e(4835),s.e(6483),s.e(759),s.e(4685),s.e(694),s.e(4714),s.e(1377),s.e(1798)]).then(s.bind(s,15226)),{event:i,params:n,abTestVersion:o,uid:a}=e;switch(i){case t.ConversationChange:yield this.startConversationChange();break;case t.MessageSend:yield(0,c.IA)().handleMessageSend(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case t.ReceiveNewMessage:yield(0,c.IA)().handleReceiveNewMessage(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case t.MessageDelete:yield(0,c.IA)().handleMessageDelete(Object.assign(Object.assign({},n),{abTestVersion:o}));break;case t.MessagePropertyUpsert:yield(0,c.IA)().handleMessagePropertyUpsert(Object.assign(Object.assign({},n),{uid:a}));break;case t.RefreshMessage:(0,c.IA)().handleRefreshMessage(Object.assign({},n));break;case t.MessageUpsert:yield(0,c.IA)().handleMessageUpsert({message:n,abTestVersion:o});break;case t.ConversationLeave:yield(0,c.IA)().handleConversationLeave(n);break;case t.ConversationDelete:(0,c.IA)().handleConversationDelete(n);break;case t.ConversationUpsert:yield(0,c.IA)().handleConversationUpsert(n);break;case t.StrangerUpgrade:yield this.getStrangerConversationList({isLoadMore:!1,forceRefresh:!0});break;default:return}}}))},startConversationChange(){var t;return O(this,void 0,void 0,(function*(){try{const{initialized:s}=e(T),{friendsCursor:i,groupCursor:n,hasMoreFriends:o,hasMoreGroup:a,options:r}=e(d.I9),l=Array.isArray(null==r?void 0:r.inboxType)&&(null==r?void 0:r.inboxType.includes(d.A5));if(!s||!l&&"0"===i&&o||l&&"0"===i&&o&&"0"===n&&a)return;this.setListLoading(!0);const u=null!==(t=yield(0,d.fI)().getConversationListOnline((e=>!e.isStrangerConversation)))&&void 0!==t?t:[],{selectedConversation:g}=e(c.nU),{otherUid:v,recentUserNameList:h}=e(T),p=new Set,f=[],y={};v&&p.add(v);const m=u.reduce(((e,t)=>{var s;const{id:i,toParticipantUserId:n,unreadCount:o,isMuted:a}=t;if(t.isGroupChat)(null===(s=t.lastMessage)||void 0===s?void 0:s.sender)&&p.add(t.lastMessage.sender);else{const e=n;e&&e!==v&&(p.add(e),f.push(e),y[e]=t)}return 0===o||a||i===(null==g?void 0:g.id)?e:e+o}),0),{selectedConversationTagList:b,unreadOnly:S}=e(M.pt),C=Array.from(p),O=f.slice(0,20),_=[this.setConversationMap(y),this.setUidList(C),this.getMultiUsersByUids({uidList:C}),(0,c.IA)().multiSetConversation({list:u,isStranger:!1}),this.getStrangerConversationList({isLoadMore:!1,forceRefresh:!0}),this.setAllConversationList(u)];S||b.length>0?_.push(this.getConversationListWithFilter()):_.push(this.setConversationList(u)),yield Promise.all(_);const{strangerConversationList:I}=e(T);this.setMessageCount(m+I.length),S||0!==b.length||(yield this.getStrangerPreview()),h.lengthe.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===s.length&&(yield this.getStrangerPreview())):this.setStrangerConversationList(o)}))},getStrangerPreview(){var t,s;return O(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(T),a=o.findIndex((e=>e.isStrangerConversation));a>-1&&o.splice(a,1);const r=yield(0,d.fI)().getStrangerPreview(),l=null==r?void 0:r.conversation,g=l.toParticipantUserId;if(!g)return;const v=[...o],h=null!==(s=null===(t=l.lastVisibleMessage)||void 0===t?void 0:t.createdAt.getTime())&&void 0!==s?s:-1;v.some(((e,t)=>{var s,i;return(null!==(i=null===(s=e.lastVisibleMessage)||void 0===s?void 0:s.createdAt.getTime())&&void 0!==i?i:-1)e.isStrangerConversation)))&&void 0!==i?i:[],t=a.reduce(((e,t)=>(e[t.id]=t,e)),{}),s=e.filter((e=>!u[e.id]||!t[e.id])),n=s.map((e=>{var t;return null!==(t=e.toParticipantUserId)&&void 0!==t?t:""}));this.setConversationMap(Object.assign(Object.assign({},t),l)),(0,c.IA)().multiSetConversation({list:s,isStranger:!0}),yield this.getMultiUsersByUids({uidList:n}),this.setStrangerConversationList(e)}r&&t(T,(e=>Object.assign(Object.assign({},e),{isFirstTimeLoadStranger:!1})))}))},getMultiUsersByUids(t){return O(this,void 0,void 0,(function*(){try{const{uidList:s,isGetRecentUsers:i}=t,{users:n}=e(u.YK),{otherUid:o}=e(T),{pathname:a}=location;if(!(0,r.tO)(a)&&5===(0,r.M5)(a))return;const d=s.filter((e=>void 0===n[e]));if(!s.length)return;const c=String(d);this.setRecentUids(c);const l=[];for(let e=0;e{g[e.id]=e})),d.forEach((e=>{g[e]||n[e]?(o===e&&I("user-select",{uid:e,uniqueId:g[e].uniqueId,from:"message-init"}),g[e].id=e):g[e]=null})),(0,u.py)().multiSetUsers(g),i){const e=[],t=[],i=[];s.forEach((s=>{var o;const a=null!==(o=g[s])&&void 0!==o?o:n[s];a&&(e.push(a.uniqueId),t.push(a.nickname),i.push(s))})),this.updateRecentUserList({uniqueIdList:e,nicknameList:t,uidList:i})}}catch(e){}}))},getFollowingUserListWithCanShare(s){return O(this,void 0,void 0,(function*(){try{this.setFollowingLoading(!0);const{count:n}=s,{followingUser:a}=e(T),{list:r,nicknameList:d,uidList:c}=a,l=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n{var t;return M.push(null!==(t=e.unique_id)&&void 0!==t?t:""),b.push(e.nickname),S.push(e.uid),f(e)})),this.updateFollowingUserList({list:[...r,...M],nicknameList:[...d,...b],uidList:[...c,...S],maxCursor:h,minCursor:p,hasMore:Boolean(m)}),(0,g.Gp)().multiSetUser(e)}else t(T,(e=>Object.assign(Object.assign({},e),{followingUser:Object.assign(Object.assign({},e.followingUser),{hasMore:!1})})))}catch(e){}finally{this.setFollowingLoading(!1)}var i}))},sendMessage(t){var s,i,n,o,a;return O(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,referenceMessage:M}=t,{friends:b,strangers:S}=e(c.nU);let C;if(h){const e=null!==(s=b[y])&&void 0!==s?s:S[y];C=yield(0,d.fI)().createMessage({conversation:e,type:g,content:JSON.stringify(v),referenceMessage:M,fileInfo:m})}else{const e=yield(0,d.fI)().createConversation({uid:r,inboxType:0}),t=null!==(i=null==e?void 0:e.payload)&&void 0!==i?i:{};C=yield(0,d.fI)().createMessage({conversation:t,type:g,content:JSON.stringify(v),referenceMessage:M,fileInfo:m})}if(49999===g)return;if(void 0===C)throw new Error("create message response is undefined");const O=yield(0,d.fI)().sendMessage({message:C});if(void 0===O)throw new Error("send message response is undefined");const{success:_,checkMsg:L,serverMessageId:T,payload:j}=O;this.setSendMessageStatus({isFailed:!1,isLoading:!1}),this.addSentMessageSuccessCount(),_?(l.w.handleSendMessage({chat_type:null!=p?p:"private",conversation_id:null!==(n=null==j?void 0:j.conversationId)&&void 0!==n?n:"",relation_tag:u,to_user_id:r,message_type:null!=f?f:"share_video",if_contain_quote:M?1:0,quote_message_type:null==M?void 0:M.type}),I("message-send",{uid:r})):(l.w.handleFailSendMessage({chat_type:null!=p?p:"private",conversation_id:null!==(o=null==j?void 0:j.conversationId)&&void 0!==o?o:"",message_type:null!=f?f:"share_video",error_code:null!==(a=JSON.parse(null!=L?L:"{}").status_code)&&void 0!==a?a:-1,relation_tag:u,to_user_id:r,if_contain_quote:M?1:0,quote_message_type:null==M?void 0:M.type}),(null==j?void 0:j.clientId)&&(0,c.IA)().addFailedMessage({[j.clientId]:{checkMsg:null!=L?L:"null",serverMessageId:T}}))}catch(e){const{uid:s,relation:i=0,chatType:n,messageType:o,convId:a,referenceMessage:r}=t;console.error(e),l.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:s,if_contain_quote:r?1:0,quote_message_type:null==r?void 0:r.type}),this.setSendMessageStatus({isFailed:!0,isLoading:!1})}}))},batchSendMessages(t){var s,i,n;return O(this,void 0,void 0,(function*(){const{uid:o,relation:a=0,hasConversation:r,chatType:u,convId:g,batchList:v}=t,{friends:h,strangers:p}=e(c.nU);let f;if(this.setSendMessageStatus({isFailed:!1,isLoading:!0}),r)f=null!==(i=null!==(s=h[g])&&void 0!==s?s: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=>O(this,void 0,void 0,(function*(){var t,s;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_contain_quote:0};if(i)this.addSentMessageSuccessCount(),(0,c.IA)().setSendingProgress({messageId:null!==(t=null==r?void 0:r.clientId)&&void 0!==t?t:"",sendingProgress:{finished:!0}}),l.w.handleSendMessage(f),I("message-send",{uid:o});else{(null==r?void 0:r.clientId)&&(0,c.IA)().addFailedMessage({[r.clientId]:{checkMsg:null!=n?n:"null",serverMessageId:p}});const e=Object.assign(Object.assign({},f),{error_code:null!==(s=JSON.parse(null!=n?n:"{}").status_code)&&void 0!==s?s:-1,status_code:null!=d?d:-1,status_msg:null!=h?h:-1});l.w.handleFailSendMessage(e)}}}}catch(e){l.w.handleFailSendMessage({chat_type:null!=u?u:"private",conversation_id:g,message_type:"media",error_code:-1,relation_tag:a,to_user_id:o,if_contain_quote:0})}}))));try{yield Promise.allSettled(y),this.setSendMessageStatus({isFailed:!1,isLoading:!1})}catch(e){this.setSendMessageStatus({isFailed:!0,isLoading:!1})}}))},loadFullFriendConversations(){return O(this,void 0,void 0,(function*(){let{hasMoreFriends:t,hasMoreGroup:s}=e(d.I9);for(;t||s;)yield(0,d.fI)().loadMoreConversation(),t=e(d.I9).hasMoreFriends,s=e(d.I9).hasMoreGroup}))},loadFullStrangerConversation(){return O(this,void 0,void 0,(function*(){let{hasMoreStranger:t}=e(d.I9);for(;t;)yield(0,d.fI)().loadMoreStrangerConversation(),t=e(d.I9).hasMoreStranger}))}})))},33147:(e,t,s)=>{s.d(t,{EL:()=>g,L_:()=>v,Sk:()=>h,YK:()=>u,py:()=>p});var i=s(43723),n=s(31209),o=s(84908),a=s(56070),r=s(26325),d=s(11983),c=s(41548),l=function(e,t,s,i){return new(s||(s=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 t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,r)}d((i=i.apply(e,t||[])).next())}))};const u=(0,i.p)("messageUserAtom@tiktok/webapp-atoms",{users:{}}),{useServiceState:g,useServiceDispatchers:v,useAtomService:h,getStaticApi:p}=(0,n.i)(u,((e,t)=>({getUser(t){const s=e(u),{users:i}=s;return i[t]},multiSetUsers(s){const i=e(u),{users:n}=i;t(u,{users:Object.assign(Object.assign({},n),s)})},setUserRelation({uid:s,relation:i}){const n=e(u),{users:o}=n,a=n.users[s];if(!a)return;const r=Object.assign(Object.assign({},a),{relation:i}),d=Object.assign({},o);d[s]=r,t(u,{users:Object.assign({},d)})},blockUser(t){var s;return l(this,void 0,void 0,(function*(){try{const{uid:n,isBlock:g}=t,v=e(u),{users:h}=v,{uniqueId:p=""}=null!==(s=h[n])&&void 0!==s?s:{},f=(0,c.T)(),y=yield(i={user_id:n,block_type:g?1:0},l(void 0,void 0,void 0,(function*(){return a.h.post("/aweme/v1/user/block/",{query:Object.assign(Object.assign({},i),{source:3}),baseUrlType:2,headers:{[r.nk]:a.h.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){console.log("block has error",e);const t=(0,c.T)();d.F.open({content:t("Sorry, something wrong with the server, please try again."),duration:3,widthType:"half"})}var i}))}})))},51250:(e,t,s)=>{var i;s.d(t,{U:()=>n}),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"}(i||(i={}));const n=e=>!(!e.visible||e.scene&&/streak/.test(e.scene)||e.content&&1===e.type&&/\{\{[0-9]\}\}/.test(e.content))}}]);