2 lines
151 KiB
JavaScript
2 lines
151 KiB
JavaScript
import e from"@tencentcloud/chat";import t from"tim-upload-plugin";import s from"tim-profanity-filter-plugin";function n(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]])}return s}function i(e,t,s,n){return new(s||(s=Promise))((function(i,r){function a(e){try{u(n.next(e))}catch(e){r(e)}}function o(e){try{u(n.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}u((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(e){return r.instance||(r.instance=this,this.engine=e,this.events={},this.bindIMEvents()),r.instance}addEvent(e,t){this.events[e]||(this.events[e]=new Map),this.events[e].set(t,1)}removeEvents(){Object.keys(this.events).forEach((e=>{this.events[e].clear()})),this.events={}}dispatch(e,t){if(this.events[e])for(const s of this.events[e].keys())s.call(this,t)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.on(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.on(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.off(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.off(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this)}onSDKReady(e){this.dispatch(this.engine.EVENT.SDK_READY,e.data)}onSDKNotReady(e){this.dispatch(this.engine.EVENT.SDK_NOT_READY,e.data)}onKickedOut(e){this.dispatch(this.engine.EVENT.KICKED_OUT,e.data)}onNetStateChange(e){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,e.data)}onReceiveMessage(e){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,e.data)}onMessageModified(e){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,e.data)}onMessageRevoked(e){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,e.data)}onMessageReadByPeer(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,e.data)}onMessageReadReceiptReceived(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,e.data)}onMessageReactionsUpdated(e){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,e.data)}onConversationListUpdated(e){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,e.data)}onTotalMessageCountUpdated(e){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,e.data)}onProfileUpdated(e){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,e.data)}onBlacklistUpdated(e){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,e.data)}onUserStatusUpdated(e){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,e.data)}onGroupListUpdated(e){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,e.data)}onGroupAttributesUpdated(e){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,e.data)}onGroupCounterUpdated(e){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,e.data)}onFriendListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,e.data)}onFriendApplicationListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,e.data)}}var a,o,u,c,g,l,h,p,d;!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIGroup="TUIGroup",e.TUIUser="TUIUser",e.TUIFriend="TUIFriend"}(a||(a={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.SEARCH="search",e.CUSTOM="custom"}(o||(o={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(u||(u={})),function(e){e.BUSINESS_ID="user_typing_status",e[e.STATUS_START=1]="STATUS_START",e[e.STATUS_END=0]="STATUS_END",e[e.VERSION=1]="VERSION",e[e.ACTION_START_ID=14]="ACTION_START_ID",e[e.ACTION_END_ID=0]="ACTION_END_ID",e.ACTION_START="EIMAMSG_InputStatus_Ing",e.ACTION_END="EIMAMSG_InputStatus_End",e[e.NEED_TYPING=1]="NEED_TYPING"}(c||(c={})),function(e){e.ADD="add",e.REMOVE="remove"}(g||(g={})),function(e){e[e.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",e[e.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",e[e.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(l||(l={})),function(e){e[e.NOT_INIT=-1e5]="NOT_INIT",e[e.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",e[e.CONV_ID_SAME=-100002]="CONV_ID_SAME",e[e.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",e[e.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",e[e.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(h||(h={})),function(e){e.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",e.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",e.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(p||(p={})),function(e){e.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",e.INVALID_CONV_ID="会话 ID 无效",e.CONV_ID_SAME="您切换的是同一个会话 ID",e.CONV_NOT_EXIST="会话不存在",e.GET_MSG_LIST_ERROR="Chat SDK is not ready.",e.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(d||(d={}));const f={logout:1,destroy:1},m={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1},v={modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},T={switchGroup:1,getGroupProfile:1,updateGroupProfile:1,createGroup:1,dismissGroup:1,searchGroupByID:1,joinGroup:1,quitGroup:1,getGroupApplicationList:1,handleGroupApplication:1,getGroupOnlineMemberCount:1,changeGroupOwner:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getGroupMemberList:1,getGroupMemberProfile:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberNameCard:1,setGroupMemberCustomField:1,markGroupMemberList:1},E={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},I={getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1},S=function(e){return void 0===e},y=function(e){return e.startsWith("_")},b=function(e){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(e)};const U=function(e){return e&&function(e){if("string"==typeof e)try{return!!JSON.parse(e)}catch(e){return!1}return!1}(e)?JSON.parse(e):e},C=function(e){let t="";return t=e>=1048576?`${(e/1048576).toFixed(2)} Mb`:e>=1024?`${(e/1024).toFixed(2)} Kb`:`${e.toFixed(2)}B`,t},M="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png",O="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.svg",_="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",D="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",P="https://web.sdk.qcloud.com/im/assets/face-elem/",R="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",L="https://apis.map.qq.com/ws/staticmap/v2/?",A={"[TUIEmoji_Expect]":"emoji_0@2x.png","[TUIEmoji_Blink]":"emoji_1@2x.png","[TUIEmoji_Guffaw]":"emoji_2@2x.png","[TUIEmoji_KindSmile]":"emoji_3@2x.png","[TUIEmoji_Haha]":"emoji_4@2x.png","[TUIEmoji_Cheerful]":"emoji_5@2x.png","[TUIEmoji_Smile]":"emoji_6@2x.png","[TUIEmoji_Sorrow]":"emoji_7@2x.png","[TUIEmoji_Speechless]":"emoji_8@2x.png","[TUIEmoji_Amazed]":"emoji_9@2x.png","[TUIEmoji_Complacent]":"emoji_10@2x.png","[TUIEmoji_Lustful]":"emoji_11@2x.png","[TUIEmoji_Stareyes]":"emoji_12@2x.png","[TUIEmoji_Giggle]":"emoji_13@2x.png","[TUIEmoji_Daemon]":"emoji_14@2x.png","[TUIEmoji_Rage]":"emoji_15@2x.png","[TUIEmoji_Yawn]":"emoji_16@2x.png","[TUIEmoji_TearsLaugh]":"emoji_17@2x.png","[TUIEmoji_Silly]":"emoji_18@2x.png","[TUIEmoji_Wail]":"emoji_19@2x.png","[TUIEmoji_Kiss]":"emoji_20@2x.png","[TUIEmoji_Trapped]":"emoji_21@2x.png","[TUIEmoji_Fear]":"emoji_22@2x.png","[TUIEmoji_BareTeeth]":"emoji_23@2x.png","[TUIEmoji_FlareUp]":"emoji_24@2x.png","[TUIEmoji_Tact]":"emoji_25@2x.png","[TUIEmoji_Shit]":"emoji_26@2x.png","[TUIEmoji_ShutUp]":"emoji_27@2x.png","[TUIEmoji_Sigh]":"emoji_28@2x.png","[TUIEmoji_Hehe]":"emoji_29@2x.png","[TUIEmoji_Silent]":"emoji_30@2x.png","[TUIEmoji_Skull]":"emoji_31@2x.png","[TUIEmoji_Mask]":"emoji_32@2x.png","[TUIEmoji_Beer]":"emoji_33@2x.png","[TUIEmoji_Cake]":"emoji_34@2x.png","[TUIEmoji_RedPacket]":"emoji_35@2x.png","[TUIEmoji_Bombs]":"emoji_36@2x.png","[TUIEmoji_Ai]":"emoji_37@2x.png","[TUIEmoji_Celebrate]":"emoji_38@2x.png","[TUIEmoji_Bless]":"emoji_39@2x.png","[TUIEmoji_Flower]":"emoji_40@2x.png","[TUIEmoji_Watermelon]":"emoji_41@2x.png","[TUIEmoji_Cow]":"emoji_42@2x.png","[TUIEmoji_Fool]":"emoji_43@2x.png","[TUIEmoji_Surprised]":"emoji_44@2x.png","[TUIEmoji_Askance]":"emoji_45@2x.png","[TUIEmoji_Monster]":"emoji_46@2x.png","[TUIEmoji_Pig]":"emoji_47@2x.png","[TUIEmoji_Coffee]":"emoji_48@2x.png","[TUIEmoji_Ok]":"emoji_49@2x.png","[TUIEmoji_Heart]":"emoji_50@2x.png","[TUIEmoji_Sun]":"emoji_51@2x.png","[TUIEmoji_Moon]":"emoji_52@2x.png","[TUIEmoji_Star]":"emoji_53@2x.png","[TUIEmoji_Rich]":"emoji_54@2x.png","[TUIEmoji_Fortune]":"emoji_55@2x.png","[TUIEmoji_857]":"emoji_56@2x.png","[TUIEmoji_666]":"emoji_57@2x.png","[TUIEmoji_Prohibit]":"emoji_58@2x.png","[TUIEmoji_Convinced]":"emoji_59@2x.png","[TUIEmoji_Knife]":"emoji_60@2x.png","[TUIEmoji_Like]":"emoji_61@2x.png"},j={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},k={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},N=["messageList","conversationList","newMessageList"],x=["translateTextInfo","voiceToTextInfo"],G="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof uni&&"undefined"==typeof window,V=G||w,F="undefined"!=typeof uni,$=("undefined"!=typeof uni||"undefined"!=typeof window)&&!V,H=G?wx:F?uni:window,Y=$&&window&&window.navigator&&window.navigator.userAgent||"",B=/Android/i.test(Y),K=/(?:Windows Phone)/.test(Y),q=/(?:SymbianOS)/.test(Y),z=/iPad/i.test(Y)||/iPhone/i.test(Y)||/iPod/i.test(Y),J=B||K||q||z,W=$&&!J;class X{constructor(){this.global=H,this.isOfficial=!1}static getInstance(){return X.instance||(X.instance=new X),X.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return W?e="pc":J?e="h5":G?e="wechat":w&&!G&&(e="app"),e}}const Z="group-module",Q="relationship-module";class ee{constructor(){this.EVENT=e.EVENT,this.TYPES=e.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}mount(e,t){this[e]=t}login(t){const{chat:s,SDKAppID:n,userID:i}=t,a=1400187352===n||1400188366===n;return this.createChat(t),this.userID=i,X.getInstance().initOfficial(a),this.TUIStore.update(o.APP,"isOfficial",a),this.TUIStore.update(o.APP,"SDKVersion",e.VERSION),this.eventCenter=new r(this),this.eventCenter.removeEvents(),this.initStore(),this.initService(),s&&s.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(t),this.eventCenter.addEvent(this.EVENT.SDK_READY,(()=>{this.onSDKReady()})),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,(()=>{this.onSDKNotReady()})),this.loginChat(t))}logout(){return this.userID="",this.isInited=!1,this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){if(this.chat)return this.chat.setLogLevel(e);console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.chat.destroy()}getMyUserID(){return this.userID}initStore(){this.TUIStore.reset(o.CHAT),this.TUIStore.reset(o.CONV),this.TUIStore.reset(o.GRP),this.TUIStore.reset(o.USER),this.TUIStore.reset(o.SEARCH),console.log("TUIChatEngine.initStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.initOptionalServices(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}initOptionalServices(){const t=e.VERSION.split(".");t[0]>3||3===t[0]&&t[1]>=3&&t[2]>0?(!0===this.chat.callExperimentalAPI("canIUseModule",[Z])&&this.TUIGroup.init(),!0===this.chat.callExperimentalAPI("canIUseModule",[Q])&&this.TUIFriend.init()):(this.TUIGroup.init(),this.TUIFriend.init())}createChat(t){const{chat:s}=t,i=n(t,["chat"]);S(s)?this.chat=e.create(Object.assign(Object.assign({},i),{scene:"chat-uikit-engine"})):this.chat=s}loginChat(e){const{userID:t,userSig:s}=e;return new Promise(((e,n)=>{this.chat.login({userID:t,userSig:s}).then((t=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),t.data.repeatLogin&&this.chat.isReady()&&e(t),this.loginStatusPromise.set("login",{resolve:e,reject:n,imResponse:t})})).catch((e=>{n(e)}))}))}registerPlugin(e){const{useUploadPlugin:n=!1,useProfanityFilterPlugin:i=!1,TIMPush:r,pushConfig:a,TUIOfflinePush:o,offlinePushConfig:u}=e;!0===n&&this.chat.registerPlugin({"tim-upload-plugin":t}),!0===i&&this.chat.registerPlugin({"tim-profanity-filter-plugin":s}),!w||G||S(r)||S(a)||this.chat.registerPlugin({"tim-push":r,pushConfig:a}),!w||G||S(o)||S(u)||this.chat.registerPlugin({"tim-offline-push-plugin":o,offlinePushConfig:u})}onSDKReady(){if(this.loginStatusPromise.has("login")){const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){if(this.loginStatusPromise.has("login")){this.loginStatusPromise.get("login").reject(new Error("sdk not ready"))}this.loginStatusPromise.delete("login")}checkCommercialAbility(){Object.keys(k).forEach((e=>{const t=k[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then((t=>{const{enabled:s=!1}=t.data;this.TUIStore.update(o.APP,e,s)}))}))}}class te{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class se{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateUserStatusList(e){0!==e.length?e.forEach((e=>{const{userID:t,statusType:s=0,customStatus:n=""}=e;s===u.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:s,customStatus:n})})):this.store.userStatusList.clear()}}class ne{getEngine(){return ee.getInstance()}}const ie=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s}(e)){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return!1},re=["[图片]","[语音]","[视频]","[文件]","[位置]","[地理位置]","[动画表情]","[自定义消息]","[群提示消息]","[聊天记录]"];class ae extends ne{constructor(e){super(),this.initProxy(e),this.isMuted=this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_ACPT_NOT_NOTE||this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_DISCARD,this.operationType=0,this._conversation=e}initProxy(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}updateProperties(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}updateOperationType(e){this.operationType=e}getConversation(){return this._conversation}deleteConversation(){return this.getEngine().TUIConversation.deleteConversation(this.conversationID)}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!0===this.isMuted?e.TYPES.MSG_REMIND_ACPT_AND_NOTE:e.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===e.TYPES.CONV_C2C){const s=this.conversationID.replace(e.TYPES.CONV_C2C,"");t.userIDList=[s]}else if(this.type===e.TYPES.CONV_GROUP){const s=this.conversationID.replace(e.TYPES.CONV_GROUP,"");t.groupID=s}return e.TUIConversation.muteConversation(t)}getAvatar(){var e,t,s,n,i,r;const a=this.getEngine();let o="";switch(this.type){case a.TYPES.CONV_C2C:o=b(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:M;break;case a.TYPES.CONV_GROUP:o=b(null===(s=this.groupProfile)||void 0===s?void 0:s.avatar)?null===(n=this.groupProfile)||void 0===n?void 0:n.avatar:O;break;case a.TYPES.CONV_SYSTEM:o=b(null===(i=this.groupProfile)||void 0===i?void 0:i.avatar)?null===(r=this.groupProfile)||void 0===r?void 0:r.avatar:_}return o}getShowName(){var e,t,s,n;const i=this.getEngine();let r="";switch(this.type){case i.TYPES.CONV_C2C:r=this.remark||(null===(e=this.userProfile)||void 0===e?void 0:e.nick)||(null===(t=this.userProfile)||void 0===t?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:r=(null===(s=this.groupProfile)||void 0===s?void 0:s.name)||(null===(n=this.groupProfile)||void 0===n?void 0:n.groupID)||"";break;case i.TYPES.CONV_SYSTEM:r=i.TUITranslate.t("系统通知")}return r}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),s=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let n="";for(let e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(n=s[this.groupAtInfoList[e].atTypeArray[0]-1]);return n}getLastMessage(e){return"time"===e?this.getLastMessageTime():"text"===e?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let s="";return(null===(e=this.lastMessage)||void 0===e?void 0:e.lastTime)>0&&(s=function(e,t){const s=6e4,n=36e5,i=24*n,r=7*i,a=(new Date).getTime()-e;let o="";if(a<0)return o;const u=a/s,c=a/n,g=a/i,l=a/r;if(l>=1&&l<=4)o=` ${parseInt(`${l}`,10)} ${t("time.周")}${t("time.前")}`;else if(g>=1&&g<=6)o=` ${parseInt(`${g}`,10)} ${t("time.天")}${t("time.前")}`;else if(c>=1&&c<=23)o=` ${parseInt(`${c}`,10)} ${t("time.小时")}${t("time.前")}`;else if(u>=1&&u<=59)o=` ${parseInt(`${u}`,10)} ${t("time.分钟")}${t("time.前")}`;else if(a>=0&&a<=s)o=`${t("time.刚刚")}`;else{const t=new Date;t.setTime(e),o=`${t.getFullYear()}-${t.getMonth()+1<10?`0${t.getMonth()+1}`:t.getMonth()+1}-${t.getDate()<10?`0${t.getDate()}`:t.getDate()}`}return o}(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),s}getLastMessageText(){var e;if(this.draftText){return U(this.draftText).abstract}const t=this.getEngine(),s=t.TUITranslate.t.bind(t.TUITranslate);if(4===this.operationType)return s("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return s("TUIConversation.该群聊已被解散");if(8===this.operationType)return s("TUIConversation.您已退出该群聊");const n=this._conversation,i=this.lastMessage;let r="",a="";const o=n.unreadCount>0&&n.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${n.unreadCount>99?"99+":n.unreadCount}${s("TUIConversation.条")}]`:"";if(n.type===t.TYPES.CONV_GROUP)if(i.fromAccount===t.getMyUserID())r=s("TUIConversation.我");else{const e=i.fromAccount;r=t.TUIFriend.getFriendRemark([e])[e]||i.nameCard||i.nick||e}if(i.type===t.TYPES.MSG_TEXT)a=this.decodeTextMessage(i.payload.text);else if(i.type===t.TYPES.MSG_CUSTOM){const n=U(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.data);if(1===(null==n?void 0:n.businessID))return a=t.TUIChat.messageHandler.handleCallKitSignaling(i),a;a=re.includes(i.messageForShow)?s(`TUIChat.${i.messageForShow}`):i.messageForShow}else a=re.includes(i.messageForShow)?s(`TUIChat.${i.messageForShow}`):i.messageForShow;return i.isRevoked&&(a=s("TUIChat.撤回了一条消息")),n.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?a:`${o}${r?`${r}:`:""}${a}`}decodeTextMessage(e){if(ie(e))return e;const t=/(\[.+?\])/g;let s=e;if(t.test(e)){const n=this.getEngine(),i=n.TUITranslate.t.bind(n.TUITranslate);s=e.replace(t,(e=>{const t=i(`Emoji.${e}`);return G||!t||t.startsWith("Emoji.")?j[e]||e:t}))}return s}}class oe{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(e,t){switch(e){case"conversationList":this.updateConversationList(t);break;case"operationTypeMap":this.updateOperationTypeMap(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find((t=>t.conversationID===e))}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateConversationList(e){const t=[];e.forEach((e=>{let s=e;e instanceof ae?s.updateProperties(e):s=new ae(e);const n=this.getOperationType(e);s.updateOperationType(n),t.push(s)})),this.store.conversationList=t}updateOperationTypeMap(e){const{conversationID:t,operationType:s=0}=e;this.store.operationTypeMap.set(t,s)}getOperationType(e){const{conversationID:t}=e;return this.store.operationTypeMap.get(t)||0}}class ue extends ne{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:e=>this.getEngine().TUIChat.messageHandler.handleTextMessage(e),[this.getEngine().TYPES.MSG_FACE]:e=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(e),[this.getEngine().TYPES.MSG_LOCATION]:e=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(e),[this.getEngine().TYPES.MSG_IMAGE]:e=>this.getEngine().TUIChat.messageHandler.handleImageMessage(e),[this.getEngine().TYPES.MSG_AUDIO]:e=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(e),[this.getEngine().TYPES.MSG_VIDEO]:e=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(e),[this.getEngine().TYPES.MSG_FILE]:e=>this.getEngine().TUIChat.messageHandler.handleFileMessage(e),[this.getEngine().TYPES.MSG_CUSTOM]:e=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(e),[this.getEngine().TYPES.MSG_MERGER]:e=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(e),[this.getEngine().TYPES.MSG_GRP_TIP]:e=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(e)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(e)}initProperties(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}updateProperties(e){this._message=e,Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:h.MISMATCH_TYPE_AND_PAYLOAD,message:d.MISMATCH_TYPE_AND_PAYLOAD}):(this._message.type=e.type||this._message.type,this._message.payload=e.payload||this._message.payload,this._message.cloudCustomData=e.cloudCustomData||this._message.cloudCustomData,this.getEngine().TUIChat.modifyMessage(this._message))}revokeMessage(){return this.getEngine().TUIChat.revokeMessage(this._message)}resendMessage(){return this.getEngine().TUIChat.resendMessage(this._message)}deleteMessage(){return this.getEngine().TUIChat.deleteMessage([this._message])}quoteMessage(){return this.getEngine().TUIChat.quoteMessage(this._message)}replyMessage(){return this.getEngine().TUIChat.replyMessage(this._message)}setMessageExtensions(e){return this.getEngine().TUIChat.setMessageExtensions(this._message,e)}getMessageExtensions(){return this.getEngine().TUIChat.getMessageExtensions(this._message)}deleteMessageExtensions(e){return this.getEngine().TUIChat.deleteMessageExtensions(this._message,e)}getSignalingInfo(){return this.type!==this.getEngine().TYPES.MSG_CUSTOM?null:S(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const e=this.messageHandlers[this.type];if(S(e))return{};if(this.type===this.getEngine().TYPES.MSG_GRP_TIP)return e(this._message);const t=this.getEngine().TUIFriend.getFriendRemark([this.from]);return Object.assign(Object.assign({},e(this._message)),{showName:t[this.from]||this.nameCard||this.nick||this.from})}sendForwardMessage(e){return this.getEngine().TUIChat.sendForwardMessage(e,[this._message])}}class ce{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(e,t){switch(e){case"messageList":this.updateMessageList(t);break;case"translateTextInfo":this.updateTranslateTextInfo(t);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find((t=>t.ID===e))}reset(e=[]){const t=e.filter((e=>!x.includes(e)));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==t?void 0:t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateMessageList(e){const t=[];e.forEach((e=>{let s=e;e instanceof ue||(s=this.getModel(e.ID),s?s.updateProperties(e):s=new ue(e)),t.push(s)})),this.store.messageList=t}updateTranslateTextInfo(e){this.updateBykey("translateTextInfo",e)}updateVoiceToTextInfo(e){this.updateBykey("voiceToTextInfo",e)}updateBykey(e,t){const{conversationID:s,messageID:n,visible:i=!1}=t;this.store[e]||(this.store[e]=new Map),this.store[e].has(s)||this.store[e].set(s,[]);const r=this.store[e].get(s)||[];let a=!0;for(let e=0;e<r.length;e++)if(r[e].messageID===n){r[e].visible=i,a=!1;break}a&&r.push({messageID:n,visible:i}),this.store[e].set(s,r)}}class ge{constructor(e){this.groupAttributes={},this.groupCounters={},this.initProxy(e)}initProxy(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}}class le{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]}}update(e,t){switch(e){case"groupList":this.updateGroupList(t);break;case"currentGroup":this.store.currentGroup=t instanceof ge?t:new ge(t);break;default:this.store[e]=t}}getData(e){if("groupSystemNoticeList"===e){const e=[...this.store.groupSystemNoticeList];return this.store.groupSystemNoticeList.length=0,e}return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateGroupList(e){this.store.groupList=e.map((e=>e instanceof ge?e:new ge(e)))}}class he{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:void 0})),{}))}}class pe{constructor(){this.defaultStore={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class de{constructor(){this.defaultStore={currentSearchInputValue:{value:"",searchType:"global"},currentSearchMessageType:{value:{key:"",label:"",value:""},searchType:"global"},currentSearchMessageTime:{value:{key:"",label:"",value:{timePosition:0,timePeriod:0}},searchType:"global"},currentSearchingStatus:{isSearching:!1,searchType:"global"},isShowInConversationSearch:!1},this.store={currentSearchInputValue:{value:"",searchType:"global"},currentSearchMessageType:{value:{key:"",label:"",value:""},searchType:"global"},currentSearchMessageTime:{value:{key:"",label:"",value:{timePosition:0,timePeriod:0}},searchType:"global"},currentSearchingStatus:{isSearching:!1,searchType:"global"},isShowInConversationSearch:!1}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==e?void 0:e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class fe{constructor(){this.storeMap={[o.APP]:new te,[o.USER]:new se,[o.CONV]:new oe,[o.CHAT]:new ce,[o.GRP]:new le,[o.FRIEND]:new pe,[o.SEARCH]:new de},this.task={}}static getInstance(){return fe.instance||(fe.instance=new fe),fe.instance}watch(e,t){this.task[e]||(this.task[e]={});const s=this.task[e];Object.keys(t).forEach((n=>{const i=t[n];s[n]||(s[n]=new Map),s[n].set(i,1),this.notifyOnWatch(e,n,i)}))}unwatch(e,t){if(!this.task[e])return;const s=this.task[e];Object.keys(t).forEach((e=>{var n;null===(n=s[e])||void 0===n||n.delete(t[e])}))}update(e,t,s){var n;e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new he),null===(n=this.storeMap[e])||void 0===n||n.update(t,s),this.notify(e,t)}getData(e,t){var s;return e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new he),null===(s=this.storeMap[e])||void 0===s?void 0:s.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[o.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[o.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],s=!1){if(e in this.storeMap){const n=this.storeMap[e];0===t.length&&(t=Object.keys(null==n?void 0:n.store)),n.reset(t),s&&t.forEach((t=>{this.notify(e,t)}))}}notifyOnWatch(e,t,s){const n=this.getData(e,t);N.indexOf(t)>-1&&0===n.length||s&&s.call(this,n)}notify(e,t){if(!this.task[e])return;const s=this.task[e];if(s[t]){const n=s[t],i=this.getData(e,t);for(const[e]of n.entries())e.call(this,i)}}}function me(e){return me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},me(e)}function ve(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Te(e){var t=function(e,t){if("object"!=me(e)||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!=me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==me(t)?t:t+""}function Ee(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Te(n.key),n)}}function Ie(e,t,s){return t&&Ee(e.prototype,t),s&&Ee(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function Se(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ye(e,t){return ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ye(e,t)}function be(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ye(e,t)}function Ue(e,t){if(t&&("object"==me(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Se(e)}function Ce(e){return Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ce(e)}function Me(e,t,s){return(t=Te(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Oe(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,n=Array(t);s<t;s++)n[s]=e[s];return n}function _e(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Oe(e,t);var s={}.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?Oe(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Pe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?De(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):De(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var Re={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Le=new(function(){function e(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ve(this,e),this.init(t,s)}return Ie(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Re,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,s,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(s).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Pe(Pe({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),Ae=function(){function e(){ve(this,e),this.observers={}}return Ie(e,[{key:"on",value:function(e,t){var s=this;return e.split(" ").forEach((function(e){s.observers[e]=s.observers[e]||[],s.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,s)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(s))}))}}]),e}();function je(){var e,t,s=new Promise((function(s,n){e=s,t=n}));return s.resolve=e,s.reject=t,s}function ke(e){return null==e?"":""+e}function Ne(e,t,s){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var r="string"!=typeof t?[].concat(t):t.split(".");r.length>1;){if(i())return{};var a=n(r.shift());!e[a]&&s&&(e[a]=new s),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return i()?{}:{obj:e,k:n(r.shift())}}function xe(e,t,s){var n=Ne(e,t,Object);n.obj[n.k]=s}function Ge(e,t){var s=Ne(e,t),n=s.obj,i=s.k;if(n)return n[i]}function we(e,t,s){for(var n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?s&&(e[n]=t[n]):we(e[n],t[n],s):e[n]=t[n]);return e}function Ve(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Fe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function $e(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return Fe[e]})):e}var He="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Ye=[" ",",","?","!",";"];function Be(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var n=t.split(s),i=e,r=0;r<n.length;++r){if(!i)return;if("string"==typeof i[n[r]]&&r+1<n.length)return;if(void 0===i[n[r]]){for(var a=2,o=n.slice(r,r+a).join(s),u=i[o];void 0===u&&n.length>r+a;)a++,u=i[o=n.slice(r,r+a).join(s)];if(void 0===u)return;if(null===u)return null;if(t.endsWith(o)){if("string"==typeof u)return u;if(o&&"string"==typeof u[o])return u[o]}var c=n.slice(r+a).join(s);return c?Be(u,c,s):void 0}i=i[n[r]]}return i}}function Ke(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function qe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Ke(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ke(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ce(e);if(t){var i=Ce(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Ue(this,s)}}var Je=function(){be(t,Ae);var e=ze(t);function t(s){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return ve(this,t),n=e.call(this),He&&Ae.call(Se(n)),n.data=s||{},n.options=i,void 0===n.options.keySeparator&&(n.options.keySeparator="."),void 0===n.options.ignoreJSONStructure&&(n.options.ignoreJSONStructure=!0),n}return Ie(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];s&&"string"!=typeof s&&(a=a.concat(s)),s&&"string"==typeof s&&(a=a.concat(i?s.split(i):s)),e.indexOf(".")>-1&&(a=e.split("."));var o=Ge(this.data,a);return o||!r||"string"!=typeof s?o:Be(this.data&&this.data[e]&&this.data[e][t],s,i)}},{key:"addResource",value:function(e,t,s,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=[e,t];s&&(a=a.concat(r?s.split(r):s)),e.indexOf(".")>-1&&(n=t,t=(a=e.split("."))[1]),this.addNamespaces(t),xe(this.data,a,n),i.silent||this.emit("added",e,t,s,n)}},{key:"addResources",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(e,t,i,s[i],{silent:!0});n.silent||this.emit("added",e,t,s)}},{key:"addResourceBundle",value:function(e,t,s,n,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(n=s,s=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var o=Ge(this.data,a)||{};n?we(o,s,i):o=qe(qe({},o),s),xe(this.data,a,o),r.silent||this.emit("added",e,t,s)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?qe(qe({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),t}(),We={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,s,n,i){var r=this;return e.forEach((function(e){r.processors[e]&&(t=r.processors[e].process(t,s,n,i))})),t}};function Xe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Ze(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Xe(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Xe(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Qe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ce(e);if(t){var i=Ce(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Ue(this,s)}}var et={},tt=function(){be(t,Ae);var e=Qe(t);function t(s){var n,i,r,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ve(this,t),n=e.call(this),He&&Ae.call(Se(n)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r=s,a=Se(n),i.forEach((function(e){r[e]&&(a[e]=r[e])})),n.options=o,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=Le.create("translator"),n}return Ie(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var s=this.resolve(e,t);return s&&void 0!==s.res}},{key:"extractFromKey",value:function(e,t){var s=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],r=s&&e.indexOf(s)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,s){t=t||"",s=s||"";var n=Ye.filter((function(e){return t.indexOf(e)<0&&s.indexOf(e)<0}));if(0===n.length)return!0;var i=new RegExp("(".concat(n.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),r=!i.test(e);if(!r){var a=e.indexOf(s);a>0&&!i.test(e.substring(0,a))&&(r=!0)}return r}(e,s,n));if(r&&!a){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:i};var u=e.split(s);(s!==n||s===n&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),e=u.join(n)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,s,n){var i=this;if("object"!==me(s)&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),"object"===me(s)&&(s=Ze({},s)),s||(s={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var r=void 0!==s.returnDetails?s.returnDetails:this.options.returnDetails,a=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],s),u=o.key,c=o.namespaces,g=c[c.length-1],l=s.lng||this.language,h=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(h){var p=s.nsSeparator||this.options.nsSeparator;return r?{res:"".concat(g).concat(p).concat(u),usedKey:u,exactUsedKey:u,usedLng:l,usedNS:g}:"".concat(g).concat(p).concat(u)}return r?{res:u,usedKey:u,exactUsedKey:u,usedLng:l,usedNS:g}:u}var d=this.resolve(e,s),f=d&&d.res,m=d&&d.usedKey||u,v=d&&d.exactUsedKey||u,T=Object.prototype.toString.apply(f),E=void 0!==s.joinArrays?s.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject;if(I&&f&&("string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(T)<0&&("string"!=typeof E||"[object Array]"!==T)){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var S=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,f,Ze(Ze({},s),{},{ns:c})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return r?(d.res=S,d):S}if(a){var y="[object Array]"===T,b=y?[]:{},U=y?v:m;for(var C in f)if(Object.prototype.hasOwnProperty.call(f,C)){var M="".concat(U).concat(a).concat(C);b[C]=this.translate(M,Ze(Ze({},s),{joinArrays:!1,ns:c})),b[C]===M&&(b[C]=f[C])}f=b}}else if(I&&"string"==typeof E&&"[object Array]"===T)(f=f.join(E))&&(f=this.extendTranslation(f,e,s,n));else{var O=!1,_=!1,D=void 0!==s.count&&"string"!=typeof s.count,P=t.hasDefaultValue(s),R=D?this.pluralResolver.getSuffix(l,s.count,s):"",L=s["defaultValue".concat(R)]||s.defaultValue;!this.isValidLookup(f)&&P&&(O=!0,f=L),this.isValidLookup(f)||(_=!0,f=u);var A=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:f,j=P&&L!==f&&this.options.updateMissing;if(_||O||j){if(this.logger.log(j?"updateKey":"missingKey",l,g,u,j?L:f),a){var k=this.resolve(u,Ze(Ze({},s),{},{keySeparator:!1}));k&&k.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var N=[],x=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if("fallback"===this.options.saveMissingTo&&x&&x[0])for(var G=0;G<x.length;G++)N.push(x[G]);else"all"===this.options.saveMissingTo?N=this.languageUtils.toResolveHierarchy(s.lng||this.language):N.push(s.lng||this.language);var w=function(e,t,n){var r=P&&n!==f?n:A;i.options.missingKeyHandler?i.options.missingKeyHandler(e,g,t,r,j,s):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,g,t,r,j,s),i.emit("missingKey",e,g,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&D?N.forEach((function(e){i.pluralResolver.getSuffixes(e,s).forEach((function(t){w([e],u+t,s["defaultValue".concat(t)]||L)}))})):w(N,u,L))}f=this.extendTranslation(f,e,s,d,n),_&&f===u&&this.options.appendNamespaceToMissingKey&&(f="".concat(g,":").concat(u)),(_||O)&&this.options.parseMissingKeyHandler&&(f="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(g,":").concat(u):u,O?f:void 0):this.options.parseMissingKeyHandler(f))}return r?(d.res=f,d):f}},{key:"extendTranslation",value:function(e,t,s,n,i){var r=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Ze(Ze({},this.options.interpolation.defaultVariables),s),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(Ze(Ze({},s),{interpolation:Ze(Ze({},this.options.interpolation),s.interpolation)}));var a,o="string"==typeof e&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(o){var u=e.match(this.interpolator.nestingRegexp);a=u&&u.length}var c=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(c=Ze(Ze({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,s.lng||this.language,s),o){var g=e.match(this.interpolator.nestingRegexp);a<(g&&g.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&n&&n.res&&(s.lng=n.usedLng),!1!==s.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return i&&i[0]===n[0]&&!s.context?(r.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):r.translate.apply(r,n.concat([t]))}),s)),s.interpolation&&this.interpolator.reset()}var l=s.postProcess||this.options.postProcess,h="string"==typeof l?[l]:l;return null!=e&&h&&h.length&&!1!==s.applyPostProcessor&&(e=We.handle(h,e,t,this.options&&this.options.postProcessPassResolved?Ze({i18nResolved:n},s):s,this)),e}},{key:"resolve",value:function(e){var t,s,n,i,r,a=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var u=a.extractFromKey(e,o),c=u.key;s=c;var g=u.namespaces;a.options.fallbackNS&&(g=g.concat(a.options.fallbackNS));var l=void 0!==o.count&&"string"!=typeof o.count,h=l&&!o.ordinal&&0===o.count&&a.pluralResolver.shouldUseIntlApi(),p=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,d=o.lngs?o.lngs:a.languageUtils.toResolveHierarchy(o.lng||a.language,o.fallbackLng);g.forEach((function(e){a.isValidLookup(t)||(r=e,!et["".concat(d[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(r)&&(et["".concat(d[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(s,'" for languages "').concat(d.join(", "),'" won\'t get resolved as namespace "').concat(r,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),d.forEach((function(s){if(!a.isValidLookup(t)){i=s;var r,u=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(u,c,s,e,o);else{var g;l&&(g=a.pluralResolver.getSuffix(s,o.count,o));var d="".concat(a.options.pluralSeparator,"zero");if(l&&(u.push(c+g),h&&u.push(c+d)),p){var f="".concat(c).concat(a.options.contextSeparator).concat(o.context);u.push(f),l&&(u.push(f+g),h&&u.push(f+d))}}for(;r=u.pop();)a.isValidLookup(t)||(n=r,t=a.getResource(s,e,r,o))}})))}))}})),{res:t,usedKey:s,exactUsedKey:n,usedLng:i,usedNS:r}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,s,n):this.resourceStore.getResource(e,t,s,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,12)&&void 0!==e[s])return!0;return!1}}]),t}();function st(e){return e.charAt(0).toUpperCase()+e.slice(1)}var nt=function(){function e(t){ve(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Le.create("languageUtils")}return Ie(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],s=e.split("-");return this.options.lowerCaseLng?s=s.map((function(e){return e.toLowerCase()})):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=st(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=st(s[1].toLowerCase())),t.indexOf(s[2].toLowerCase())>-1&&(s[2]=st(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,s=this;return e?(e.forEach((function(e){if(!t){var n=s.formatLanguageCode(e);s.options.supportedLngs&&!s.isSupportedCode(n)||(t=n)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var n=s.getLanguagePartFromCode(e);if(s.isSupportedCode(n))return t=n;t=s.options.supportedLngs.find((function(e){return e===n?e:e.indexOf("-")<0&&n.indexOf("-")<0?void 0:0===e.indexOf(n)?e:void 0}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}},{key:"toResolveHierarchy",value:function(e,t){var s=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],r=function(e){e&&(s.isSupportedCode(e)?i.push(e):s.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):"string"==typeof e&&r(this.formatLanguageCode(e)),n.forEach((function(e){i.indexOf(e)<0&&r(s.formatLanguageCode(e))})),i}}]),e}(),it=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],rt={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},at=["v1","v2","v3"],ot={zero:0,one:1,two:2,few:3,many:4,other:5};var ut=function(){function e(t){var s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};ve(this,e),this.languageUtils=t,this.options=n,this.logger=Le.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(s={},it.forEach((function(e){e.lngs.forEach((function(t){s[t]={numbers:e.nr,plurals:rt[e.fc]}}))})),s)}return Ie(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.getRule(e,t);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,s).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,s);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort((function(e,t){return ot[e]-ot[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):n.numbers.map((function(n){return t.getSuffix(e,n,s)})):[]}},{key:"getSuffix",value:function(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,s);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var s=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var r=function(){return s.options.prepend&&i.toString()?s.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):r():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?r():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!at.includes(this.options.compatibilityJSON)}}]),e}();function ct(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function gt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ct(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function lt(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=function(e,t,s){var n=Ge(e,s);return void 0!==n?n:Ge(t,s)}(e,t,s);return!r&&i&&"string"==typeof s&&void 0===(r=Be(e,s,n))&&(r=Be(t,s,n)),r}var ht=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ve(this,e),this.logger=Le.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return Ie(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:$e,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Ve(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Ve(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Ve(t.nestingPrefix):t.nestingPrefixEscaped||Ve("$t("),this.nestingSuffix=t.nestingSuffix?Ve(t.nestingSuffix):t.nestingSuffixEscaped||Ve(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var s="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(s,"g")}},{key:"interpolate",value:function(e,t,s,n){var i,r,a,o=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var g=function(e){if(e.indexOf(o.formatSeparator)<0){var i=lt(t,u,e,o.options.keySeparator,o.options.ignoreJSONStructure);return o.alwaysFormat?o.format(i,void 0,s,gt(gt(gt({},n),t),{},{interpolationkey:e})):i}var r=e.split(o.formatSeparator),a=r.shift().trim(),c=r.join(o.formatSeparator).trim();return o.format(lt(t,u,a,o.options.keySeparator,o.options.ignoreJSONStructure),c,s,gt(gt(gt({},n),t),{},{interpolationkey:a}))};this.resetRegExp();var l=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,h=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?c(o.escape(e)):c(e)}}].forEach((function(t){for(a=0;i=t.regex.exec(e);){var s=i[1].trim();if(void 0===(r=g(s)))if("function"==typeof l){var u=l(e,i,n);r="string"==typeof u?u:""}else if(n&&Object.prototype.hasOwnProperty.call(n,s))r="";else{if(h){r=i[0];continue}o.logger.warn("missed to pass in variable ".concat(s," for interpolating ").concat(e)),r=""}else"string"==typeof r||o.useRawValueToEscape||(r=ke(r));var c=t.safeValue(r);if(e=e.replace(i[0],c),h?(t.regex.lastIndex+=r.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var s,n,i,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function o(e,t){var s=this.nestingOptionsSeparator;if(e.indexOf(s)<0)return e;var n=e.split(new RegExp("".concat(s,"[ ]*{"))),r="{".concat(n[1]);e=n[0];var a=(r=this.interpolate(r,i)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),t&&(i=gt(gt({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(s).concat(r)}return delete i.defaultValue,e}for(;s=this.nestingRegexp.exec(e);){var u=[];(i=(i=gt({},a)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var c=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){var g=s[1].split(this.formatSeparator).map((function(e){return e.trim()}));s[1]=g.shift(),u=g,c=!0}if((n=t(o.call(this,s[1].trim(),i),i))&&s[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=ke(n)),n||(this.logger.warn("missed to resolve ".concat(s[1]," for nesting ").concat(e)),n=""),c&&(n=u.reduce((function(e,t){return r.format(e,t,a.lng,gt(gt({},a),{},{interpolationkey:s[1].trim()}))}),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}]),e}();function pt(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function dt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):pt(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ft(e){var t={};return function(s,n,i){var r=n+JSON.stringify(i),a=t[r];return a||(a=e(n,i),t[r]=a),a(s)}}var mt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ve(this,e),this.logger=Le.create("formatter"),this.options=t,this.formats={number:ft((function(e,t){var s=new Intl.NumberFormat(e,dt({},t));return function(e){return s.format(e)}})),currency:ft((function(e,t){var s=new Intl.NumberFormat(e,dt(dt({},t),{},{style:"currency"}));return function(e){return s.format(e)}})),datetime:ft((function(e,t){var s=new Intl.DateTimeFormat(e,dt({},t));return function(e){return s.format(e)}})),relativetime:ft((function(e,t){var s=new Intl.RelativeTimeFormat(e,dt({},t));return function(e){return s.format(e,t.range||"day")}})),list:ft((function(e,t){var s=new Intl.ListFormat(e,dt({},t));return function(e){return s.format(e)}}))},this.init(t)}return Ie(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=ft(t)}},{key:"format",value:function(e,t,s){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce((function(e,t){var r=function(e){var t=e.toLowerCase().trim(),s={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var i=n[1].substring(0,n[1].length-1);"currency"===t&&i.indexOf(":")<0?s.currency||(s.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?s.range||(s.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=_e(e.split(":")),n=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");s[n.trim()]||(s[n.trim()]=i),"false"===i&&(s[n.trim()]=!1),"true"===i&&(s[n.trim()]=!0),isNaN(i)||(s[n.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:s}}(t),a=r.formatName,o=r.formatOptions;if(n.formats[a]){var u=e;try{var c=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},g=c.locale||c.lng||i.locale||i.lng||s;u=n.formats[a](e,g,dt(dt(dt({},o),i),c))}catch(e){n.logger.warn(e)}return u}return n.logger.warn("there was no format function for ".concat(a)),e}),e)}}]),e}();function vt(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Tt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?vt(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):vt(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Et(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ce(e);if(t){var i=Ce(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Ue(this,s)}}var It=function(){be(t,Ae);var e=Et(t);function t(s,n,i){var r,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return ve(this,t),r=e.call(this),He&&Ae.call(Se(r)),r.backend=s,r.store=n,r.services=i,r.languageUtils=i.languageUtils,r.options=a,r.logger=Le.create("backendConnector"),r.waitingReads=[],r.maxParallelReads=a.maxParallelReads||10,r.readingCalls=0,r.maxRetries=a.maxRetries>=0?a.maxRetries:5,r.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,r.state={},r.queue=[],r.backend&&r.backend.init&&r.backend.init(i,a.backend,a),r}return Ie(t,[{key:"queueLoad",value:function(e,t,s,n){var i=this,r={},a={},o={},u={};return e.forEach((function(e){var n=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!s.reload&&i.store.hasResourceBundle(e,t)?i.state[o]=2:i.state[o]<0||(1===i.state[o]?void 0===a[o]&&(a[o]=!0):(i.state[o]=1,n=!1,void 0===a[o]&&(a[o]=!0),void 0===r[o]&&(r[o]=!0),void 0===u[t]&&(u[t]=!0)))})),n||(o[e]=!0)})),(Object.keys(r).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(r),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,s){var n=e.split("|"),i=n[0],r=n[1];t&&this.emit("failedLoading",i,r,t),s&&this.store.addResourceBundle(i,r,s),this.state[e]=t?-1:2;var a={};this.queue.forEach((function(s){var n,o,u,c,g,l;n=s.loaded,o=r,c=Ne(n,[i],Object),g=c.obj,l=c.k,g[l]=g[l]||[],u&&(g[l]=g[l].concat(o)),u||g[l].push(o),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((function(e){a[e]||(a[e]={});var t=s.loaded[e];t.length&&t.forEach((function(t){void 0===a[e][t]&&(a[e][t]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,s){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:r,callback:a});else{this.readingCalls++;var o=function(o,u){if(n.readingCalls--,n.waitingReads.length>0){var c=n.waitingReads.shift();n.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}o&&u&&i<n.maxRetries?setTimeout((function(){n.read.call(n,e,t,s,i+1,2*r,a)}),r):a(o,u)},u=this.backend[s].bind(this.backend);if(2!==u.length)return u(e,t,o);try{var c=u(e,t);c&&"function"==typeof c.then?c.then((function(e){return o(null,e)})).catch(o):o(null,c)}catch(e){o(e)}}}},{key:"prepareLoading",value:function(e,t){var s=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var r=this.queueLoad(e,t,n,i);if(!r.toLoad.length)return r.pending.length||i(),null;r.toLoad.forEach((function(e){s.loadOne(e)}))}},{key:"load",value:function(e,t,s){this.prepareLoading(e,t,{},s)}},{key:"reload",value:function(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}},{key:"loadOne",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),i=n[0],r=n[1];this.read(i,r,"read",void 0,void 0,(function(n,a){n&&t.logger.warn("".concat(s,"loading namespace ").concat(r," for language ").concat(i," failed"),n),!n&&a&&t.logger.log("".concat(s,"loaded namespace ").concat(r," for language ").concat(i),a),t.loaded(e,n,a)}))}},{key:"saveMissing",value:function(e,t,s,n,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(s,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){var o=Tt(Tt({},r),{},{isUpdate:i}),u=this.backend.create.bind(this.backend);if(u.length<6)try{var c;(c=5===u.length?u(e,t,s,n,o):u(e,t,s,n))&&"function"==typeof c.then?c.then((function(e){return a(null,e)})).catch(a):a(null,c)}catch(e){a(e)}else u(e,t,s,n,a,o)}e&&e[0]&&this.store.addResource(e[0],t,s,n)}}}]),t}();function St(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===me(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===me(e[2])||"object"===me(e[3])){var s=e[3]||e[2];Object.keys(s).forEach((function(e){t[e]=s[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,s,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function yt(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function bt(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Ut(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?bt(Object(s),!0).forEach((function(t){Me(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):bt(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function Ct(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ce(e);if(t){var i=Ce(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Ue(this,s)}}function Mt(){}var Ot=function(){be(t,Ae);var e=Ct(t);function t(){var s,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(ve(this,t),s=e.call(this),He&&Ae.call(Se(s)),s.options=yt(i),s.services={},s.logger=Le,s.modules={external:[]},n=Se(s),Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((function(e){"function"==typeof n[e]&&(n[e]=n[e].bind(n))})),r&&!s.isInitialized&&!i.isClone){if(!s.options.initImmediate)return s.init(i,r),Ue(s,Se(s));setTimeout((function(){s.init(i,r)}),0)}return s}return Ie(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(s=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=St();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=Ut(Ut(Ut({},n),this.options),yt(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Ut(Ut({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var r;this.modules.logger?Le.init(i(this.modules.logger),this.options):Le.init(null,this.options),this.modules.formatter?r=this.modules.formatter:"undefined"!=typeof Intl&&(r=mt);var a=new nt(this.options);this.store=new Je(this.options.resources,this.options);var o=this.services;o.logger=Le,o.resourceStore=this.store,o.languageUtils=a,o.pluralResolver=new ut(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!r||this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format||(o.formatter=i(r),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new ht(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new It(i(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.languageDetector&&(o.languageDetector=i(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=i(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new tt(this.services,this.options),this.translator.on("*",(function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,s||(s=Mt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&"dev"!==u[0]&&(this.options.lng=u[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var s;return(s=e.store)[t].apply(s,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var s;return(s=e.store)[t].apply(s,arguments),e}}));var c=je(),g=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(n),s(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?g():setTimeout(g,0),c}},{key:"loadResources",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,n="string"==typeof e?e:this.language;if("function"==typeof e&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&"cimode"===n.toLowerCase())return s();var i=[],r=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};if(n)r(n);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(i,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),s(e)}))}else s(null)}},{key:"reloadResources",value:function(e,t,s){var n=je();return e||(e=this.languages),t||(t=this.options.ns),s||(s=Mt),this.services.backendConnector.reload(e,t,(function(e){n.resolve(),s(e)})),n}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&We.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}},{key:"changeLanguage",value:function(e,t){var s=this;this.isLanguageChangingTo=e;var n=je();this.emit("languageChanging",e);var i=function(e){s.language=e,s.languages=s.services.languageUtils.toResolveHierarchy(e),s.resolvedLanguage=void 0,s.setResolvedLanguage(e)},r=function(r){e||r||!s.services.languageDetector||(r=[]);var a="string"==typeof r?r:s.services.languageUtils.getBestMatchFromCodes(r);a&&(s.language||i(a),s.translator.language||s.translator.changeLanguage(a),s.services.languageDetector&&s.services.languageDetector.cacheUserLanguage&&s.services.languageDetector.cacheUserLanguage(a)),s.loadResources(a,(function(e){!function(e,r){r?(i(r),s.translator.changeLanguage(r),s.isLanguageChangingTo=void 0,s.emit("languageChanged",r),s.logger.log("languageChanged",r)):s.isLanguageChangingTo=void 0,n.resolve((function(){return s.t.apply(s,arguments)})),t&&t(e,(function(){return s.t.apply(s,arguments)}))}(e,a)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,s){var n=this,i=function e(t,i){var r;if("object"!==me(i)){for(var a=arguments.length,o=new Array(a>2?a-2:0),u=2;u<a;u++)o[u-2]=arguments[u];r=n.options.overloadTranslationOptionHandler([t,i].concat(o))}else r=Ut({},i);r.lng=r.lng||e.lng,r.lngs=r.lngs||e.lngs,r.ns=r.ns||e.ns,r.keyPrefix=r.keyPrefix||s||e.keyPrefix;var c,g=n.options.keySeparator||".";return c=r.keyPrefix&&Array.isArray(t)?t.map((function(e){return"".concat(r.keyPrefix).concat(g).concat(e)})):r.keyPrefix?"".concat(r.keyPrefix).concat(g).concat(t):t,n.t(c,r)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=s.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var a=function(e,s){var n=t.services.backendConnector.state["".concat(e,"|").concat(s)];return-1===n||2===n};if(s.precheck){var o=s.precheck(this,a);if(void 0!==o)return o}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!a(n,e)||i&&!a(r,e)))}},{key:"loadNamespaces",value:function(e,t){var s=this,n=je();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){s.options.ns.indexOf(e)<0&&s.options.ns.push(e)})),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var s=je();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],i=e.filter((function(e){return n.indexOf(e)<0}));return i.length?(this.options.preload=n.concat(i),this.loadResources((function(e){s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new nt(St());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,i=Ut(Ut(Ut({},this.options),s),{isClone:!0}),r=new t(i);void 0===s.debug&&void 0===s.prefix||(r.logger=r.logger.clone(s));return["store","services","language"].forEach((function(t){r[t]=e[t]})),r.services=Ut({},this.services),r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r.translator=new tt(r.services,r.options),r.translator.on("*",(function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];r.emit.apply(r,[e].concat(s))})),r.init(i,n),r.translator.options=r.options,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),t}();Me(Ot,"createInstance",(function(){return new Ot(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var _t=Ot.createInstance();_t.createInstance=Ot.createInstance,_t.createInstance,_t.dir,_t.init,_t.loadResources,_t.reloadResources,_t.use,_t.changeLanguage,_t.getFixedT,_t.t,_t.exists,_t.setDefaultNamespace,_t.hasLoadedNamespace,_t.loadNamespaces,_t.loadLanguages;class Dt extends ne{constructor(){super(),this.languages=null}static getInstance(){return Dt.instance||(Dt.instance=new Dt),Dt.instance}provideLanguages(e){G||(this.languages=e,console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){if(G)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const t={};for(const[e,s]of Object.entries(this.languages)){t["zh_cn"===e?"zh":e]={translation:s}}_t.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:t})}changeLanguage(e){return _t.changeLanguage(e)}t(e){if(!this.languages){let t=e;return!S(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}return _t.t(e)}}class Pt extends ne{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return Pt.instance||(Pt.instance=new Pt),Pt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalUnreadCountUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getConversationInitData()}onConversationListUpdated(e){const t=this.filterSystemConversation(e);this.getEngine().TUIStore.update(o.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(o.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),s=this.getEngine().TUIStore.getData(o.CONV,"conversationList");let n=!1;for(let i=0;i<e.length;i++){if(e[i].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:r}=e[i].payload,a=`GROUP${e[i].to}`,u=4===r||5===r||8===r,c=2===r||6===r||7===r;if(u||c)for(let e=0;e<s.length;e++)if(s[e].type!==t.TYPES.CONV_C2C&&s[e].conversationID===a){if(u){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:a,operationType:r}),n=!0;break}if(c&&s[e].operationType>0){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:a,operationType:0}),n=!0;break}}}if(n){this.getEngine().TUIStore.update(o.CONV,"conversationList",s);const e=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID")||"",t=this.findConversation(e);t&&this.getEngine().TUIStore.update(o.CONV,"currentConversation",t)}}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then((t=>{const{conversationList:s,isSyncCompleted:n}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${s.length} isSyncCompleted:${n}`),s.length>0){this.onConversationListUpdated(s);const t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}}))}switchConversation(e){return i(this,void 0,void 0,(function*(){const t=`${this.serv}.switchConversation`,s=this.getEngine();if(!e)return s.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(o.CONV,"currentConversationID",""),s.TUIStore.update(o.CONV,"currentConversation",null),console.log(`${t} conversationID is empty, conversationID:${e}`),Promise.resolve({});if(!e.startsWith(s.TYPES.CONV_C2C)&&!e.startsWith(s.TYPES.CONV_GROUP))return console.warn(`${t} conversationID is invalid, conversationID:${e}`),Promise.reject({code:h.INVALID_CONV_ID,message:d.INVALID_CONV_ID});const n=s.TUIStore.getData(o.CONV,"currentConversationID");if(n&&n===e)return this.setMessageRead(n),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:h.CONV_ID_SAME,message:d.CONV_ID_SAME});const i=yield this.getConversationModel(e);return S(i)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:h.CONV_NOT_EXIST,message:d.CONV_NOT_EXIST})):(n&&this.setMessageRead(n),e&&this.setMessageRead(e),s.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(o.CONV,"currentConversationID",e),s.TUIStore.update(o.CONV,"currentConversation",i),Promise.resolve(i))}))}getConversationModel(e){return i(this,void 0,void 0,(function*(){let t=this.findConversation(e);if(S(t))try{const s=yield this.getConversationProfile(e);s.data&&s.data.conversation&&(t=new ae(s.data.conversation))}catch(e){t=void 0}return t}))}findConversation(e){let t;const s=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let n=0;n<s.length;n++)if(s[n].conversationID===e){t=s[n];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"currentConversationID"),s=this.findConversation(t);s&&e.TUIStore.update(o.CONV,"currentConversation",s)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){return this.getEngine().chat.deleteConversation(e).then((t=>{const s=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${s}`),e===s&&(this.getEngine().TUIStore.update(o.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(o.CONV,"currentConversation",null)),t}))}pinConversation(e){return this.getEngine().chat.pinConversation(e)}muteConversation(e){return this.getEngine().chat.setMessageRemindType(e)}clearHistoryMessage(e){return this.getEngine().chat.clearHistoryMessage(e).then((e=>(this.getEngine().TUIStore.update(o.CHAT,"messageList",[]),this.getEngine().TUIStore.update(o.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(o.CHAT,"isCompleted",!0),e)))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}setConversationDraft(e){const{conversationID:t,draftInfo:s}=e;let n="";return s&&(n=JSON.stringify(s)),this.getEngine().chat.setConversationDraft({conversationID:t,draftText:n}).then((e=>{const{conversation:t}=e.data;this.updateConversation(t)}))}updateConversation(e){let t=!1;const s=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let n=0;n<s.length;n++)if(s[n].conversationID===e.conversationID){s[n]=e,t=!0;break}t&&this.getEngine().TUIStore.update(o.CONV,"conversationList",s)}filterSystemConversation(e){return e.filter((e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM))}}class Rt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(o.USER,"userProfile");e.forEach((e=>{e.userID===s.userID&&t.TUIStore.update(o.USER,"userProfile",e)}))}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then((e=>{t.TUIStore.update(o.USER,"userBlacklist",e)}))}getUserProfileInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getBlacklist().then((e=>{const t=e.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${t.length}`),t.length>0&&this.onBlacklistUpdated(t)}))}getBlacklistProfile(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));const n=[];t.forEach((e=>{n.push(this.TUIUserService.getUserProfile({userIDList:e}))}));const i=[];return Promise.all(n).then((e=>(e.forEach((e=>{const t=e.data.map((e=>{const{userID:t,nick:s,avatar:n}=e;return{userID:t,nick:s,avatar:n}}));i.push(...t)})),i)))}getUserProfile(e){const t=this.getEngine();return S(e)?t.chat.getMyProfile().then((e=>(t.TUIStore.update(o.USER,"userProfile",e.data),e))).catch((e=>Promise.reject(e))):t.chat.getUserProfile(e)}updateMyProfile(e){return this.getEngine().chat.updateMyProfile(e)}addToBlacklist(e){return this.getEngine().chat.addToBlacklist(e)}removeFromBlacklist(e){return this.getEngine().chat.removeFromBlacklist(e)}}function Lt(e,t,s=!0){!function(e,t){V?H.setStorageSync(e,t):kt()&&localStorage.setItem(e,JSON.stringify(t))}(s?jt(e):e,t)}function At(e,t=!0){try{return function(e){if(V)return H.getStorageSync(e);if(kt()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?jt(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function jt(e){return`chat_engine_${e}`}function kt(){return navigator&&navigator.cookieEnabled&&localStorage}class Nt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=At("displayOnlineStatus")||!1;e.TUIStore.update(o.USER,"displayOnlineStatus",t),e.eventCenter.addEvent(e.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated.bind(this)),this.onConversationListUpdated()}onConversationListUpdated(){const e=this.getEngine();e.TUIStore.watch(o.CONV,{conversationList:()=>{const t=e.TUIStore.getData(o.APP,"enabledOnlineStatus"),s=e.TUIStore.getData(o.USER,"displayOnlineStatus");t&&s&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(o.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:s=!1}=e;t.TUIStore.update(o.USER,"displayOnlineStatus",s),Lt("displayOnlineStatus",s);const n=t.TUIStore.getData(o.APP,"enabledOnlineStatus");n?!0===s?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${n} displayOnlineStatus:${s}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then((e=>{const{successUserList:s}=e.data;return s.length>0&&t.TUIStore.update(o.USER,"userStatusList",s),e})).catch((e=>Promise.reject(e)))}subscribeUserStatus(e){var t;const s=(null===(t=null==e?void 0:e.userIDList)||void 0===t?void 0:t.length)||0;return 0===s?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${s}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(e)}unsubscribeUserStatus(e){const t=this.getEngine(),{userIDList:s=[]}=e||{};return t.chat.unsubscribeUserStatus({userIDList:s}).then((e=>{const{failureUserList:n}=e.data,i=[];return s.forEach((e=>{n.includes(e)||i.push({userID:e,statusType:u.UNSUB_USER})})),t.TUIStore.update(o.USER,"userStatusList",i),e})).catch((e=>Promise.reject(e)))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"conversationList"),s=e.TUIStore.getData(o.USER,"userStatusList"),n=[];t.forEach((t=>{if(t.type===e.TYPES.CONV_C2C){const i=t.conversationID.replace(e.TYPES.CONV_C2C,"");s.has(i)||n.push(i)}})),0!==n.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:n}),this.getUserStatus({userIDList:n}))}}class xt extends ne{constructor(){super(),this.userProfileHandler=new Rt(this),this.userStatusHandler=new Nt(this)}static getInstance(){return xt.instance||(xt.instance=new xt),xt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.KICKED_OUT,this.onKickedOut.bind(this)),e.eventCenter.addEvent(e.EVENT.NET_STATE_CHANGE,this.onNetStateChange.bind(this)),this.userProfileHandler.init(),this.userStatusHandler.init(),this.initMessageReadReceipt()}onKickedOut(e){this.getEngine().TUIStore.update(o.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(o.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=At("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e),Lt("displayMessageReadReceipt",e)}getUserProfile(e){return this.userProfileHandler.getUserProfile(e)}updateMyProfile(e){return this.userProfileHandler.updateMyProfile(e)}addToBlacklist(e){return this.userProfileHandler.addToBlacklist(e)}removeFromBlacklist(e){return this.userProfileHandler.removeFromBlacklist(e)}getUserStatus(e){return this.userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this.userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this.userStatusHandler.unsubscribeUserStatus(e)}}class Gt{constructor(e){this.TUIChatService=e,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(e){return this.getEngine().TUITranslate.t(e)}handleTextMessage(e){return{text:this.decodeText(e.payload)}}handleFaceMessage(e){const t={name:"",url:"",type:""};return e.payload.data.indexOf("@custom")>-1?(t.name=e.payload.data,t.type="custom",t):(t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${P}${t.name}.png`,t)}handleLocationMessage(e){const t={lon:"",lat:"",href:"",url:"",description:""};return t.lon=e.payload.longitude.toFixed(6),t.lat=e.payload.latitude.toFixed(6),t.href=`${R}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${L}center=${t.lat},${t.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${t.lat},${t.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`,t.description=e.payload.description,t}handleImageMessage(e){return{url:e.payload.imageInfoArray[0].url,width:e.payload.imageInfoArray[0].width,height:e.payload.imageInfoArray[0].height}}handleAudioMessage(e){return{url:e.payload.url,second:e.payload.second}}handleVideoMessage(e){return{url:e.payload.videoUrl,snapshotUrl:e.payload.snapshotUrl,snapshotWidth:e.payload.snapshotWidth,snapshotHeight:e.payload.snapshotHeight}}handleFileMessage(e){return{url:e.payload.fileUrl,name:e.payload.fileName,size:C(e.payload.fileSize)}}handleCustomMessage(e){var t;const s=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||s||(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.extension)||`[${this.t("message.custom.自定义消息")}]`,businessID:s?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,s,n,i,r,a;const o=this.getEngine(),u={text:""};let c=(null==e?void 0:e.nick)||(null===(s=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.userIDList)||void 0===s?void 0:s.join(","));switch((null===(i=null===(n=null==e?void 0:e.payload)||void 0===n?void 0:n.memberList)||void 0===i?void 0:i.length)>0&&(c="",null===(a=null===(r=null==e?void 0:e.payload)||void 0===r?void 0:r.memberList)||void 0===a||a.map((e=>{const t=(null==e?void 0:e.nick)||(null==e?void 0:e.userID);c+=`${this.substringByLength(t)},`})),c=null==c?void 0:c.slice(0,-1)),e.payload.operationType){case o.TYPES.GRP_TIP_MBR_JOIN:u.text=`${c} ${this.t("message.tip.加入群组")}`;break;case o.TYPES.GRP_TIP_MBR_QUIT:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.退出群组")}`;break;case o.TYPES.GRP_TIP_MBR_KICKED_OUT:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case o.TYPES.GRP_TIP_MBR_SET_ADMIN:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.成为管理员")}`;break;case o.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被撤销管理员")}`;break;case o.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:u.text=this.handleGroupProfileUpdated(e);break;case o.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被禁言")}`:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被取消禁言")}`;break;default:u.text=`[${this.t("message.tip.群提示消息")}]`}return u}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,s={text:""};switch(e.payload.operationType){case 1:s.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${t}`;break;case 2:s.text=`${this.t("message.tip.成功加入群组")}:${t}`;break;case 3:s.text=`${this.t("message.tip.申请加入群组")}:${t} ${this.t("message.tip.被拒绝")}`;break;case 4:s.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}:${t}`;break;case 5:s.text=`${this.t("message.tip.群")}:${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:s.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}:${t}`;break;case 7:case 12:s.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${t}`;break;case 8:s.text=`${this.t("message.tip.你退出群组")}:${t}`;break;case 9:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}:${t} ${this.t("message.tip.的管理员")}`;break;case 10:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}:${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:s.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}:${t}`;break;case 14:s.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}:${t}`;break;case 255:s.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:s.text="未解析的群系统通知"}return s}handleCallKitSignaling(e){var t,s,n,i,r,a,o,u,c,g;const l=U(e.payload.data);if(1!==(null==l?void 0:l.businessID))return"";const h=U(null==l?void 0:l.data),p=e.fromAccount||e.from,d=this.getEngine().TUIFriend.getFriendRemark([p]),f=this.getEngine().getMyUserID();let m=d[p]||e.nameCard||e.nick||p;switch(m=this.substringByLength(m),null==l?void 0:l.actionType){case 1:return"audioCall"!==(null===(t=null==h?void 0:h.data)||void 0===t?void 0:t.cmd)&&"videoCall"!==(null===(s=null==h?void 0:h.data)||void 0===s?void 0:s.cmd)||!(null==l?void 0:l.groupID)?"hangup"===(null===(n=null==h?void 0:h.data)||void 0===n?void 0:n.cmd)?(null==l?void 0:l.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let s,n,i,r="";return t>=3600?(s=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),n=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),i=t%3600<10?"0"+t%3600:t%3600,i>60&&(n=parseInt(""+i/60,10)<10?`0${parseInt(""+i/60,10)}`:parseInt(""+i/60,10),i=i%60<10?"0"+i%60:i%60),r=`${s}:${n}:${i}`):t>=60&&t<3600?(n=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),i=t%60<10?"0"+t%60:t%60,r=`00:${n}:${i}`):t<60&&(i=t<10?`0${t}`:t,r=`00:00:${i}`),r}(null==h?void 0:h.call_end)}`:"switchToAudio"===(null===(i=null==h?void 0:h.data)||void 0===i?void 0:i.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(r=null==h?void 0:h.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${m} ${this.t("message.custom.发起通话")}`;case 2:return(null==l?void 0:l.groupID)?`${m} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(null==l?void 0:l.inviter)===f?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return"switchToAudio"===(null===(a=null==h?void 0:h.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(o=null==h?void 0:h.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${m} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==l?void 0:l.groupID)?`${m} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):"line_busy"===(null==h?void 0:h.line_busy)||"lineBusy"===(null==h?void 0:h.data.message)?(null==l?void 0:l.inviter)===f?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(null==l?void 0:l.inviter)===f?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if("switchToAudio"===(null===(u=null==h?void 0:h.data)||void 0===u?void 0:u.cmd))return`${this.t("message.custom.切换语音通话")}`;if("switchToVideo"===(null===(c=null==h?void 0:h.data)||void 0===c?void 0:c.cmd))return`${this.t("message.custom.切换视频通话")}`;if(null==l?void 0:l.groupID){if(p===(null==l?void 0:l.inviter)){this.handleCallkitTimeoutSignaling(l.inviteeList);let e="";return null===(g=l.inviteeList)||void 0===g||g.forEach((t=>{const s=this.userShowNameMap.get(t)||t;e+=`${this.substringByLength(s)}、`})),e=e.substring(0,e.lastIndexOf("、")),`${e} ${this.t("message.custom.无应答")}`}return`${m} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(null==l?void 0:l.inviter)===f?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleCreateGroupCustomMessage(e){let t;const s=U(e.payload.data);return"group_create"===(null==s?void 0:s.businessID)&&(t=`${s.opUser} ${s.content}`),t}decodeText(e){const t=[];let s=e.text,n=-1,i=-1;for(;""!==s;)switch(n=s.indexOf("["),i=s.indexOf("]"),n){case 0:if(-1===i)t.push({name:"text",text:s}),s="";else{const e=s.slice(0,i+1);e.indexOf("@custom")>-1?(t.push({name:"img",src:"",type:"custom",emojiKey:e}),s=s.substring(i+1)):A[e]?(t.push({name:"img",src:D+A[e],emojiKey:e}),s=s.substring(i+1)):(t.push({name:"text",text:"["}),s=s.slice(1))}break;case-1:t.push({name:"text",text:s}),s="";break;default:t.push({name:"text",text:s.slice(0,n)}),s=s.substring(n)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:s}=e,{newGroupProfile:n,memberList:i,operatorID:r}=s;let a="";const o=t||r,u=Object.keys(n)[0];switch(u){case"muteAllMembers":a=n[u]?`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":a=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":a=`${o} ${this.t("message.tip.修改群名为")} ${n[u]}`;break;case"notification":a=this.isOldUIKit("message.tip.把群公告修改为")?`${o} ${this.t("message.tip.发布新公告")}`:`${o} ${this.t("message.tip.把群公告修改为")} "${n[u]}"`}return a}handleCallkitTimeoutSignaling(e=[]){if(0===e.length)return;const t=this.getEngine().TUIFriend.getFriendRemark(e),s=[];e.forEach((e=>{const n=t[e];n?this.userShowNameMap.set(e,n):this.requestedUserMap.has(e)||(s.push(e),this.requestedUserMap.set(e,1))})),s.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:s}).then((e=>{(e.data||[]).forEach((e=>{const{userID:t,nick:s}=e,n=s||t;this.userShowNameMap.set(t,n)}))})).catch((e=>{}))}substringByLength(e,t=12){return e.length>t?`${e.slice(0,t)}...`:e}isOldUIKit(e){var t;const s=e.lastIndexOf("."),n=e.slice(0,s+1);return null===(t=this.t(e))||void 0===t?void 0:t.startsWith(n)}}class wt{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(o.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(o.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),s=t.TUIStore.getData(o.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const n=U(e.payload.data);if(n.businessID===c.BUSINESS_ID){const{typingStatus:e,userAction:i}=n;if(e===c.STATUS_START||i===c.ACTION_START_ID)return s?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(o.CHAT,"typingStatus",!0),this.timer=setTimeout((()=>{this.clearTypingStatus()}),3e4),t.TUIStore.getData(o.CHAT,"typingStatus");e!==c.STATUS_END&&i!==c.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(o.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter((e=>{if(e.type===this.getEngine().TYPES.MSG_CUSTOM){return U(e.payload.data).businessID!==c.BUSINESS_ID}return!0}))}createTypingMessage(e=c.STATUS_END,t=""){const{BUSINESS_ID:s,STATUS_START:n,VERSION:i,ACTION_START_ID:r,ACTION_END_ID:a,ACTION_START:o,ACTION_END:u,NEED_TYPING:g}=c;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:s,typingStatus:e,version:i,userAction:e===n?r:a,actionParam:e===n?o:u}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:g,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(c.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(c.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class Vt{constructor(e){this.TUIChatService=e}getEngine(){return this.TUIChatService.getEngine()}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived.bind(this))}onMessageReadReceiptReceived(e){const t=this.getEngine(),s=t.TUIStore.getData(o.CONV,"currentConversationID"),n=[];e.forEach((e=>{const{messageID:i}=e,r=t.chat.findMessage(i);r&&s===r.conversationID&&n.push(r)})),n.length>0&&t.TUIChat.updateMessageList(n,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach((e=>{const s=e.getMessage();t.push(s)})),this.getEngine().chat.sendMessageReadReceipt(t)}getGroupMessageReadMemberList(e){const t=e.message.getMessage(),s=Object.assign(Object.assign({},e),{message:t});return this.getEngine().chat.getGroupMessageReadMemberList(s)}getMessageReadReceiptList(e){const t=this.getEngine(),s=t.TUIStore.getData(o.APP,"enabledMessageReadReceipt"),n=t.TUIStore.getData(o.USER,"displayMessageReadReceipt");!s||!n||0===e.length||e[0].conversationType!==t.TYPES.CONV_GROUP||t.chat.getMessageReadReceiptList(e).then((e=>{const{messageList:t}=e.data;this.TUIChatService.updateMessageList(t,"edit")})).catch((e=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${e.message}`)}))}}class Ft extends ne{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new Gt(this),this.typingHandler=new wt(this),this.readReceiptHandler=new Vt(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return Ft.instance||(Ft.instance=new Ft),Ft.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"push"),this.getEngine().TUIStore.update(o.CHAT,"newMessageList",e)}onMessageModified(e){this.updateMessageList(e,"edit")}onMessageRevoked(e){this.updateMessageList(e,"edit")}onMessageReadByPeer(e){this.updateMessageList(e,"edit")}onMessageReactionsUpdated(e){this.updateMessageReactionList([e])}onCurrentConversationIDUpdated(){const e=this.getEngine();e.TUIStore.watch(o.CONV,{currentConversationID:t=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),e.TUIStore.reset(o.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),ie(t)||this.getMessageList().finally((()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()}))}})}onMessageSource(){const e=this.getEngine();e.TUIStore.watch(o.CHAT,{messageSource:t=>{const s=this.getStoreData(o.CONV,"currentConversationID");if(!s||t&&t.conversationID!==s)return;if(S(t))return this.hoppingConfigMap.clear(),e.TUIStore.update(o.CHAT,"messageList",[]),e.TUIStore.update(o.CHAT,"nextReqMessageID",""),e.TUIStore.update(o.CHAT,"isCompleted",!1),void this.getMessageList();const n=this.getStoreData(o.CHAT,"messageList");n&&n.find((e=>t&&e.ID===t.ID))||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const e=this.getStoreData(o.CHAT,"messageList"),{conversationID:t,sequence:s,time:n,ID:i}=this.getStoreData(o.CHAT,"messageSource");if(e&&e.find((e=>i&&e.ID===i)))return;const r=this.getEngine();r.TUIStore.update(o.CHAT,"messageList",[]),r.TUIStore.update(o.CHAT,"nextReqMessageID",""),r.TUIStore.update(o.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:s,time:n,direction:1})}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}sendMessage(e,t){this.updateMessageList([e],"send");const s=this.getEngine().chat.sendMessage(e,t);return this.getResponse(s)}getResponse(e,t=!0,s=!0){return e.then((e=>{const s=e.data.messageList?e.data.messageList:[e.data.message];return t&&this.updateMessageList(s,"edit"),e})).catch((e=>{var t;return s&&(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)&&this.updateMessageList([e.data.message],"edit"),Promise.reject(e)}))}updateMessageList(e,t=""){if(this.getStoreData(o.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const s=this.getStoreData(o.CHAT,"messageList"),n=this.updateTargetMessageList(e,s,t);this.getEngine().TUIStore.update(o.CHAT,"messageList",n)}updateTargetMessageList(e,t,s=""){const n=this.getStoreData(o.CONV,"currentConversationID");let i=e.filter((e=>e.conversationID===n));if(i=this.handleC2CCallSignaling(i),!s||0===i.length)return t;const r=t||[];let a=[];if("send"===s||"push"===s){const e=this.getStoreData(o.CHAT,"userInfo");Object.keys(e).length>0&&this.updateLocalMessage(i,e)}switch(s){case"edit":for(const e of t){const t=i.find((t=>t.ID===e.ID));a.push(t||e)}break;case"resend":a=r.filter((e=>e.ID!==i[0].ID)).concat(i);break;case"send":a=r.concat(this.typingHandler.filterTypingMessage(i));break;case"push":a=r.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:n});break;case"unshift":a=i.filter((e=>0===r.length||!r.find((t=>t.ID===e.ID)))),a.push(...r)}return a}enterTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),s=this.getStoreData(o.CONV,"currentConversationID");if(!s.startsWith(t.TYPES.CONV_C2C))return;const n=s.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(o.CHAT,"messageList").filter((e=>"in"===e.flow));if(0===e.length)return;const t=1e3*e[e.length-1].time;if((new Date).getTime()-t>3e4)return}this.typingHandler.sendTyping(e,n)}quoteMessage(e){return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"quote"}),e}replyMessage(e){return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(o.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t,s;const n=this.getEngine(),i={abstract:"",type:0};switch(e.type){case n.TYPES.MSG_TEXT:i.abstract=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text,i.type=1;break;case n.TYPES.MSG_CUSTOM:i.abstract="[自定义消息]",i.type=2;break;case n.TYPES.MSG_IMAGE:i.abstract="[图片]",i.type=3;break;case n.TYPES.MSG_AUDIO:i.abstract="[语音]",i.type=4;break;case n.TYPES.MSG_VIDEO:i.abstract="[视频]",i.type=5;break;case n.TYPES.MSG_FILE:i.abstract="[文件]",i.type=6;break;case n.TYPES.MSG_LOCATION:i.type=7;break;case n.TYPES.MSG_FACE:i.abstract="[表情]",i.type=8;break;case n.TYPES.MSG_GRP_TIP:i.type=9;break;case n.TYPES.MSG_MERGER:i.abstract=null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.title,i.type=10}return i}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:s,type:n}=this.getMessageAbstractAndType(e),i={messageAbstract:s,messageSender:e.nick||e.from,messageID:e.ID},r=Object.assign(Object.assign({},i),{messageType:n,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(r.messageRootID=e.ID,e.cloudCustomData)){const t=U(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(r.messageRootID=t.messageReply.messageRootID)}return{messageReply:r,messageReplyRoot:i}}getMessageInfo(e,t,s){const{messageReply:n,messageReplyRoot:i}=this.genMessageReply(t,s),r=e.cloudCustomData?U(e.cloudCustomData):{};let a;if(r.messageReply?r.messageReply=Object.assign(Object.assign({},n),r.messageReply):r.messageReply=n,"reply"===s){const{messageRootID:e}=n;a=this.getEngine().chat.findMessage(e);const t=(null==a?void 0:a.cloudCustomData)?U(a.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),o=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(o):"array"===Object.prototype.toString.call(o).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(i),a.cloudCustomData=JSON.stringify(t)}var o;return{cloudCustomData:JSON.stringify(r),rootMessage:a}}sendTextMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(r=this.getMessageInfo(e,n,i));const a=s.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(a,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),s.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e)))}sendTextAtMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(r=this.getMessageInfo(e,n,i));const a=s.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(a,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),s.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e)))}sendImageMessage(e,t){const s=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendAudioMessage(e,t){const s=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendVideoMessage(e,t){const s=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendCustomMessage(e,t){const s=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}sendFaceMessage(e,t){const s=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}sendFileMessage(e,t){const s=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendLocationMessage(e,t){const s=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}onProgress(e,t){const s=this.getEngine().TUIStore.getMessageModel(e);if(s){(t-s.progress>=.1||1===t)&&(s.progress=t,this.updateMessageList([s],"edit"))}}setAbstractList(e){const t=this.getEngine(),s=e.nick||e.from;let n="";switch(e.type){case t.TYPES.MSG_TEXT:n=e.payload.text||"",n.length>20&&(n=n.slice(0,20));break;case t.TYPES.MSG_MERGER:n=`${this.t("TUIChat.[聊天记录]")}`;break;case t.TYPES.MSG_IMAGE:n=`${this.t("TUIChat.[图片]")}`;break;case t.TYPES.MSG_AUDIO:n=`${this.t("TUIChat.[音频]")}`;break;case t.TYPES.MSG_VIDEO:n=`${this.t("TUIChat.[视频]")}`;break;case t.TYPES.MSG_CUSTOM:n=`${this.t("TUIChat.[自定义消息]")}`;break;case t.TYPES.MSG_FILE:n=`${this.t("TUIChat.[文件]")}`;break;case t.TYPES.MSG_FACE:n=`${this.t("TUIChat.[动画表情]")}`}return`${s}: ${n}`}genMergerForwardPayload(e,t){const{abstractList:s=[],compatibleText:n="",title:i}=t;return 0===s.length&&e.forEach((e=>{s.push(this.setAbstractList(e))})),{messageList:e,title:i,abstractList:s,compatibleText:n||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(e){const{conversationList:t,messageList:s,params:n,mergeInfo:i,sendMessageOptions:r}=e,a=[];for(let e=0;e<t.length;e++){const{conversationID:o,type:u}=t[e],c=Object.assign({to:o.replace(`${u}`,""),conversationType:u,payload:this.genMergerForwardPayload(s,i)},n),g=this.getEngine().chat.createMergerMessage(c);a.push(this.sendMessage(g,r))}return a}genTitle(e,t){const{nick:s,from:n,to:i}=e;return`${s||n} ${this.t("TUIChat.和")} ${t||i} ${this.t("TUIChat.的聊天记录")}`}genMergeInfo(e){var t;return i(this,void 0,void 0,(function*(){const{messageList:s,mergeInfo:n}=e;if(n.title)return n;if(s[0].conversationType===this.getEngine().TYPES.CONV_GROUP)return n.title=this.t("TUIChat.群聊的聊天记录"),n;try{const{data:e=[]}=yield this.getEngine().TUIUser.getUserProfile({userIDList:[s[0].to]});n.title=this.genTitle(s[0],null===(t=e[0])||void 0===t?void 0:t.nick)}catch(e){n.title=this.genTitle(s[0])}return n}))}sendMergerForwardMessage(e){return i(this,void 0,void 0,(function*(){return e.mergeInfo=yield this.genMergeInfo(e),Promise.all(this.genSendMergerForwardMessage(e))}))}getOriginMessageList(e){return e.map((e=>e instanceof ue?e.getMessage():e))}sendForwardMessage(e,t,s){t=this.getOriginMessageList(t);const i=s||{},{needMerge:r=!1,params:a={},mergeInfo:o={}}=i,u=n(i,["needMerge","params","mergeInfo"]);if(r)return this.sendMergerForwardMessage({conversationList:e,messageList:t,params:a,mergeInfo:o,sendMessageOptions:u});const c=[];for(let s=0;s<e.length;s++){const{conversationID:n,type:i}=e[s],r=Object.assign({to:n.replace(`${i}`,""),conversationType:i},a),o=u[n]||u;for(let e=0;e<t.length;e++){Reflect.set(r,"payload",t[e]);const s=this.getEngine().chat.createForwardMessage(r);c.push(this.sendMessage(s,o))}}return Promise.all(c)}revokeMessage(e){const t=this.getEngine().chat.revokeMessage(e);return this.getResponse(t,!0,!1)}resendMessage(e){e.status="unSend",this.updateMessageList([e],"resend");const t=this.getEngine().chat.resendMessage(e);return this.getResponse(t,!0,!0)}deleteMessage(e){const t=this.getEngine().chat.deleteMessage(e);return this.getResponse(t,!0,!1)}setMessageExtensions(e,t){return this.getEngine().chat.setMessageExtensions(e,t)}getMessageExtensions(e){return this.getEngine().chat.getMessageExtensions(e)}deleteMessageExtensions(e,t){return this.getEngine().chat.deleteMessageExtensions(e,t)}modifyMessage(e){const t=this.getEngine().chat.modifyMessage(e);return this.getResponse(t,!0,!1).catch((e=>{const{code:t=0,data:s={}}=e.code;throw t===l.MSG_MODIFY_CONFLICT?console.warn(`${p.MSG_MODIFY_CONFLICT} data.message: ${null==s?void 0:s.message}`):t===l.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(p.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===l.MODIFY_MESSAGE_NOT_EXIST&&console.warn(p.MODIFY_MESSAGE_NOT_EXIST),e}))}getMessageList(e={conversationID:this.getStoreData(o.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(o.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:h.GET_MSG_LIST_ERROR,message:d.GET_MSG_LIST_ERROR});if(this.getStoreData(o.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const s=this.getStoreData(o.CHAT,"messageSource"),n=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),r=n||i;return s&&s.conversationID===e.conversationID&&r?this.getMessageListHopping():t.chat.getMessageList(e).then((e=>{var s;const{messageList:n,nextReqMessageID:i,isCompleted:r}=e.data,a=this.getStoreData(o.CHAT,"userInfo");Object.keys(a).length>0&&this.updateLocalMessage(n,a),this.updateMessageList(n,"unshift"),t.TUIStore.update(o.CHAT,"nextReqMessageID",i),t.TUIStore.update(o.CHAT,"isCompleted",r);const u=null===(s=n[0])||void 0===s?void 0:s.conversationID,{operationType:c=0}=this.getEngine().TUIStore.getConversationModel(u)||{};return 0===c&&(this.getMessageReactions({messageList:n}),this.readReceiptHandler.getMessageReadReceiptList(n)),e})).catch((e=>Promise.reject(e)))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(o.CHAT,"messageSource"))||void 0===t?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const s=this.getEngine();return s.chat.getMessageListHopping(e).then((t=>{const{messageList:n,nextMessageSeq:i,nextMessageTime:r,isCompleted:a}=t.data,u=1===e.direction?e.sequence:i,c=1===e.direction?e.time:r;return this.updateMessageList(n,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",u),this.hoppingConfigMap.set("nextMessageTime",c),s.TUIStore.update(o.CHAT,"isCompleted",a),t})).catch((e=>Promise.reject(e)))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then((e=>{const{isCompleted:t,cursor:s,messageID:n,unreadUserIDList:i,readUserIDList:r}=e.data,a={code:0,data:{cursor:s,isCompleted:t,messageID:n,unreadUserInfoList:[],readUserInfoList:[]}},o=[...i,...r];return 0===o.length?a:this.getEngine().TUIUser.getUserProfile({userIDList:o}).then((e=>(i.length>0?e.data.forEach((e=>{const{userID:t,nick:s="",avatar:n=""}=e;a.data.unreadUserInfoList.push({userID:t,nick:s,avatar:n})})):e.data.forEach((e=>{const{userID:t,nick:s="",avatar:n=""}=e;a.data.readUserInfoList.push({userID:t,nick:s,avatar:n})})),a)))}))}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e)}setTranslationLanguage(e){this.getEngine().TUIStore.update(o.USER,"targetLanguage",e)}translateText(e){const t=this.getStoreData(o.USER,"targetLanguage"),s=Object.assign({targetLanguage:t,sourceLanguage:"auto"},e);return this.getEngine().chat.translateText(s)}searchCloudMessages(e){const t=this.getStoreData(o.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(e).then((e=>{const{searchResultList:s}=e.data;return e.data.searchResultList=s.map((e=>{const{messageList:s,conversationID:i}=e,r=n(e,["messageList","conversationID"]),a=s.map((e=>new ue(e))),o=t.find((e=>e.conversationID===i));return Object.assign(Object.assign({},r),{messageList:a.sort(((e,t)=>t.time-e.time)),conversation:o})})),e}))}addMessageReaction(e,t){return this.getEngine().chat.addMessageReaction(e.getMessage(),t)}removeMessageReaction(e,t){return this.getEngine().chat.removeMessageReaction(e.getMessage(),t)}getMessageReactions(e){const{messageList:t=[]}=e,s=this.getStoreData(o.APP,"enabledEmojiPlugin");console.log(`TUIChatService.getMessageReactions enabledEmojiPlugin:${s} messageList length:${t.length}`),s&&t.length>0&&this.getEngine().chat.getMessageReactions(e).then((e=>{const t=e.data.resultList||e.data;this.updateMessageReactionList(t)})).catch((e=>{}))}getAllUserListOfMessageReaction(e){var t;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},e),{message:null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.getMessage()}))}updateMessageReactionList(e){const t=[];e.forEach((e=>{const{messageID:s,reactionList:n}=e,i=this.getEngine().TUIStore.getMessageModel(s);if(i){const e=[];for(let t=0;t<n.length;t++){let s=!0;for(let e=0;e<i.reactionList.length;e++)if(n[t].reactionID===i.reactionList[e].reactionID){i.reactionList[e]=n[t],s=!1;break}s&&e.push(n[t])}i.reactionList.push(...e),e.length=0,t.push(i)}})),t.length>0&&this.updateMessageList(t,"edit")}convertVoiceToText(e){const{message:t,language:s="zh"}=e,n=t.getMessage();return this.getEngine().chat.convertVoiceToText({message:n,language:s})}updateMessageInfo(e){const t=this.getStoreData(o.CHAT,"userInfo");this.getEngine().TUIStore.update(o.CHAT,"userInfo",Object.assign(t,e));const s=this.getStoreData(o.CHAT,"messageList");if(s.length>0){this.updateLocalMessage(s,e)&&this.getEngine().TUIStore.update(o.CHAT,"messageList",s)}}updateLocalMessage(e,t){let s=!1;return e.forEach((e=>{if(t[e.from]){const{nick:n,nameCard:i,avatar:r}=t[e.from];n&&(e.nick=n,s=!0),i&&(e.nameCard=i,s=!0),r&&(e.avatar=r,s=!0)}})),s}handleC2CCallSignaling(e){const t=this.getEngine(),s=t.getMyUserID();return e.filter((e=>{var n,i,r,a,u;const{conversationType:c,type:g,payload:l}=e;let h=!0;if(c===t.TYPES.CONV_C2C&&g===t.TYPES.MSG_CUSTOM){if(t.chat.getSignalingInfo(e)){const t=U(l.data);if(1===(null==t?void 0:t.businessID)){const c=U(t.data);if(h=!(e._isExcludedFromUnreadCount&&e._isExcludedFromLastMessage),h&&!0!==(null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.consumed)){let n=null===(i=null==c?void 0:c.data)||void 0===i?void 0:i.inviter;"line_busy"!==(null==c?void 0:c.line_busy)&&"lineBusy"!==(null===(r=null==c?void 0:c.data)||void 0===r?void 0:r.message)||(n=t.inviter);const{from:g,to:l}=e;if(n!==s&&e.from===s){const t=this.getStoreData(o.CONV,"currentConversation");e.from=l,e.to=g,e.flow="in",e.avatar=(null===(a=null==t?void 0:t.userProfile)||void 0===a?void 0:a.avatar)||""}if(n===s&&e.from!==s){const t=this.getStoreData(o.USER,"userProfile");e.from=l,e.to=g,e.flow="out",e.avatar=null==t?void 0:t.avatar}console.log(`${this.serv}.handleC2CCallSignaling myUserID:${s} callSignaling.inviter:${t.inviter} customData.data.inviter:${null===(u=null==c?void 0:c.data)||void 0===u?void 0:u.inviter}`)}}}}return h}))}}class $t extends ne{constructor(){super(),this.groupMap=new Map}static getInstance(){return $t.instance||($t.instance=new $t),$t.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getGroupInitData()}onGroupListUpdated(e){const t=this.getEngine();t.TUIStore.update(o.GRP,"groupList",e);const s=t.TUIStore.getData(o.GRP,"currentGroupID");e.forEach((e=>{e.groupID===s&&t.TUIStore.update(o.GRP,"currentGroup",e)}))}onGroupAttributesUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(o.GRP,"currentGroupID");let n=t.TUIStore.getData(o.GRP,"groupList");const{groupID:i,groupAttributes:r}=e;s===i&&t.TUIStore.update(o.GRP,"currentGroupAttributes",r),n=n.map((e=>(e.groupID===i&&(e.groupAttributes=r),e))),t.TUIStore.update(o.GRP,"groupList",n)}onGroupCounterUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(o.GRP,"currentGroupID"),n=t.TUIStore.getData(o.GRP,"currentGroupCounters")||{};let i=t.TUIStore.getData(o.GRP,"groupList");const{groupID:r,key:a,value:u}=e;s===r&&(n[a]=u,t.TUIStore.update(o.GRP,"currentGroupCounters",n)),i=i.map((e=>(e.groupID===r&&(e.groupCounters=Object.assign(Object.assign({},e.groupCounters),{[a]:u})),e))),t.TUIStore.update(o.GRP,"groupList",i)}onMessageReceived(e){const t=this.getEngine(),s=[];e.forEach((e=>{if(e.type===t.TYPES.MSG_GRP_TIP){const{payload:s}=e,{operationType:n,userIDList:i}=s,r=t.TUIStore.getData(o.GRP,"currentGroupID");switch(n){case t.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(i);break;case t.TYPES.GRP_TIP_MBR_QUIT:case t.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(i);break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(i);break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:this.getGroupProfile({groupID:r});break;case t.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:case t.TYPES.GRP_TIP_BAN_AVCHATROOM_MEMBER:case t.TYPES.GRP_TIP_UNBAN_AVCHATROOM_MEMBER:this.updateGroupMember(i)}}e.type===t.TYPES.MSG_GRP_SYS_NOTICE&&s.push(e)})),s.length>0&&t.TUIStore.update(o.GRP,"groupSystemNoticeList",s)}getGroupInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getGroupList().then((e=>{const{groupList:t=[]}=e.data;console.log(`TUIGroupService.init, getGroupList count:${t.length}`),t.length>0&&this.onGroupListUpdated(t)}))}updateGroupMember(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(o.GRP,"currentGroupID");if(t){const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:n}=s.data;this.updateMemberList(n)}}))}resetCurrentStore(){this.getEngine().TUIStore.reset(o.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),s=t.TUIStore.getConversationModel(`GROUP${e}`);if((null==s?void 0:s.operationType)>0){const e=t.TUIStore.getData(o.GRP,"currentGroup");return Promise.resolve(e)}const n=t.TUIStore.getData(o.GRP,"currentGroupID");if(!e)return this.resetCurrentStore(),Promise.resolve({});if(n===e){const e=t.TUIStore.getData(o.GRP,"currentGroup");return Promise.resolve(e)}this.resetCurrentStore(),t.TUIStore.update(o.GRP,"currentGroupID",e);try{yield this.getGroupInfo(e)}catch(e){Promise.reject(e)}const i=setTimeout((()=>{this.groupMap.delete(e),clearTimeout(i)}),5e3),r=t.TUIStore.getData(o.GRP,"currentGroup");return Promise.resolve(r)}))}getGroupInfo(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),s=this.groupMap.get(e);if(s)return this.updateMemberList((null==s?void 0:s.memberList)||[]),t.TUIStore.update(o.GRP,"currentGroup",s.group),t.TUIStore.update(o.GRP,"currentGroupAttributes",s.groupAttributes||{}),void t.TUIStore.update(o.GRP,"currentGroupCounters",s.counters||{});const n={group:{},memberList:[],groupAttributes:void 0,counters:void 0},{data:{group:i}}=yield this.getGroupProfile({groupID:e});n.group=i;const{data:{memberList:r}}=yield this.getGroupMemberList({groupID:e});n.memberList=r;const a=yield this.getGroupAttributes({groupID:e,keyList:[]}),{groupAttributes:u}=a.data;n.groupAttributes=u,t.TUIStore.update(o.GRP,"currentGroupAttributes",u);try{const s=yield this.getGroupCounters({groupID:e,keyList:[]}),{counters:i}=s.data;n.counters=i,t.TUIStore.update(o.GRP,"currentGroupCounters",i)}catch(e){console.warn(null==e?void 0:e.message)}this.groupMap.set(e,n)}))}getGroupProfile(e){const t=this.getEngine();return t.chat.getGroupProfile(e).then((s=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(o.GRP,"currentGroupID")===e.groupID){const{group:e}=s.data;t.TUIStore.update(o.GRP,"currentGroup",e)}return s}))))}updateGroupProfile(e){return this.getEngine().chat.updateGroupProfile(e)}createGroup(e){return this.getEngine().chat.createGroup(e)}dismissGroup(e){return this.getEngine().chat.dismissGroup(e)}searchGroupByID(e){const t=this.getEngine();return t.chat.searchGroupByID(e).then((e=>{const{group:s}=e.data,n=t.TUIStore.getData(o.GRP,"groupList");return e.data.group.isJoinedGroup=n.some((e=>e.groupID===s.groupID)),e}))}joinGroup(e){return this.getEngine().chat.joinGroup(e)}quitGroup(e){return this.getEngine().chat.quitGroup(e)}getGroupApplicationList(){return this.getEngine().chat.getGroupApplicationList()}handleGroupApplication(e){return this.getEngine().chat.handleGroupApplication(e)}getGroupOnlineMemberCount(e){return this.getEngine().chat.getGroupOnlineMemberCount(e)}changeGroupOwner(e){return this.getEngine().chat.changeGroupOwner(e)}initGroupAttributes(e){return this.getEngine().chat.initGroupAttributes(e)}setGroupAttributes(e){return this.getEngine().chat.setGroupAttributes(e)}deleteGroupAttributes(e){return this.getEngine().chat.deleteGroupAttributes(e)}getGroupAttributes(e){return this.getEngine().chat.getGroupAttributes(e)}setGroupCounters(e){return this.getEngine().chat.setGroupCounters(e)}increaseGroupCounter(e){return this.getEngine().chat.increaseGroupCounter(e)}decreaseGroupCounter(e){return this.getEngine().chat.decreaseGroupCounter(e)}getGroupCounters(e){return this.getEngine().chat.getGroupCounters(e)}updateMemberList(e){const t=this.getEngine(),s=[...(t.TUIStore.getData(o.GRP,"currentGroupMemberList")||[]).filter((t=>!e.find((e=>e.userID===t.userID)))),...e];t.TUIStore.update(o.GRP,"currentGroupMemberList",s)}addMemberList(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(o.GRP,"currentGroupID");if(t)try{const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:n}=s.data;this.updateMemberList(n)}catch(t){const s=e.map((e=>({userID:e,avatar:"",nick:"",role:"",joinTime:0,nameCard:"",muteUntil:0,memberCustomField:[]})));this.updateMemberList(s)}}))}removeMemberList(e){const t=this.getEngine(),s=t.TUIStore.getData(o.GRP,"currentGroupMemberList").filter((t=>-1===e.indexOf(t.userID)));t.TUIStore.update(o.GRP,"currentGroupMemberList",s)}getGroupMemberList(e){const t=this.getEngine();return t.chat.getGroupMemberList(e).then((s=>{if(t.TUIStore.getData(o.GRP,"currentGroupID")===e.groupID){const{memberList:e}=s.data;this.updateMemberList(e)}return s}))}getGroupMemberProfile(e){return this.getEngine().chat.getGroupMemberProfile(e)}addGroupMember(e){const t=this.getEngine();return t.chat.addGroupMember(e).then((s=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(o.GRP,"currentGroupID")===e.groupID){const{successUserIDList:e,group:n}=s.data;t.TUIStore.update(o.GRP,"currentGroup",n),this.addMemberList(e)}return s}))))}deleteGroupMember(e){const t=this.getEngine();return t.chat.deleteGroupMember(e).then((s=>{if(t.TUIStore.getData(o.GRP,"currentGroupID")===e.groupID){const{userIDList:e,group:n}=s.data;this.removeMemberList(e),t.TUIStore.update(o.GRP,"currentGroup",n)}return s}))}setGroupMemberMuteTime(e){return this.getEngine().chat.setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this.getEngine().chat.setGroupMemberRole(e)}setGroupMemberNameCard(e){return this.getEngine().chat.setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this.getEngine().chat.setGroupMemberCustomField(e)}markGroupMemberList(e){return this.getEngine().chat.markGroupMemberList(e)}}class Ht extends ne{constructor(){super()}static getInstance(){return Ht.instance||(Ht.instance=new Ht),Ht.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated.bind(this)),this.getFriendInitData()}onFriendListUpdated(e){this.getEngine().TUIStore.update(o.FRIEND,"friendList",e)}onFriendApplicationListUpdated(e){const{friendApplicationList:t,unreadCount:s=0}=e,n=this.getEngine();n.TUIStore.update(o.FRIEND,"friendApplicationList",t),n.TUIStore.update(o.FRIEND,"friendApplicationUnreadCount",s)}getFriendInitData(){const e=this.getEngine();e.chat.isReady()&&(e.chat.getFriendList().then((e=>{const t=e.data||[];console.log(`TUIFriendService.init, getFriendList count:${t.length}`),t.length>0&&this.onFriendListUpdated(t)})),e.chat.getFriendApplicationList().then((e=>{this.onFriendApplicationListUpdated(e.data)})))}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(e){const t=this.getEngine().TUIStore.getData(o.FRIEND,"friendList"),s={};return e.forEach((e=>{for(let n=0;n<t.length;n++)t[n].userID!==e||(s[e]=t[n].remark)})),s}addFriend(e){return this.getEngine().chat.addFriend(e)}deleteFriend(e){return this.getEngine().chat.deleteFriend(e)}checkFriend(e){return this.getEngine().chat.checkFriend(e)}getFriendProfile(e){return this.getEngine().chat.getFriendProfile(e)}updateFriend(e){return this.getEngine().chat.updateFriend(e)}acceptFriendApplication(e){return this.getEngine().chat.acceptFriendApplication(e)}refuseFriendApplication(e){return this.getEngine().chat.refuseFriendApplication({userID:e})}deleteFriendApplication(e){return this.getEngine().chat.deleteFriendApplication(e)}setFriendApplicationRead(){return this.getEngine().chat.setFriendApplicationRead()}}class Yt{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){return"function"!=typeof e&&console.error("middleware must be a function"),this.cache.push(e),this}next(){if(this.middlewares&&this.middlewares.length>0){return this.middlewares.shift().call(this,this.options,this.next.bind(this))}}run(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}function Bt(e,t,s){const n=Object.create(null);Object.keys(s).forEach((s=>{if(!t[s])return;n[s]=t[s];const i=new Yt;t[s]=function(){const r=Array.from(arguments);return i.use((function(t,n){return e.isInited?n():Promise.reject({code:h.NOT_INIT,message:`${s} | ${d.NOT_INIT}`})})).use((function(e,i){return n[s].apply(t,e)})),i.run(r)}}))}console.log("TUIChatEngine.VERSION:2.2.9");const Kt=ee.getInstance(),qt=X.getInstance(),zt=fe.getInstance(),Jt=Dt.getInstance(),Wt=Pt.getInstance(),Xt=xt.getInstance(),Zt=Ft.getInstance(),Qt=$t.getInstance(),es=Ht.getInstance();Kt.mount(a.TUIStore,zt),Kt.mount(a.TUITranslate,Jt),Kt.mount(a.TUIConversation,Wt),Kt.mount(a.TUIUser,Xt),Kt.mount(a.TUIChat,Zt),Kt.mount(a.TUIGroup,Qt),Kt.mount(a.TUIFriend,es),Bt(Kt,Kt,f),Bt(Kt,Wt,m),Bt(Kt,Zt,v),Bt(Kt,Qt,T),Bt(Kt,Xt,E),Bt(Kt,es,I);export{o as StoreName,Kt as TUIChatEngine,Zt as TUIChatService,Wt as TUIConversationService,es as TUIFriendService,qt as TUIGlobal,Qt as TUIGroupService,zt as TUIStore,Jt as TUITranslateService,Xt as TUIUserService,Kt as default};
|