File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/modules/im/install/js/im/v2/model/dist/registry.bundle.min.js
Back
this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};this.BX.Messenger.v2=this.BX.Messenger.v2||{};(function(e,t,i,s,a,n,r,l){"use strict";class o extends n.BuilderModel{getName(){return"application"}getState(){return{common:{host:this.getVariable("common.host",location.protocol+"//"+location.host),siteId:this.getVariable("common.siteId","default"),userId:this.getVariable("common.userId",0),languageId:this.getVariable("common.languageId","en")},dialog:{dialogId:this.getVariable("dialog.dialogId","0"),chatId:this.getVariable("dialog.chatId",0),diskFolderId:this.getVariable("dialog.diskFolderId",0),messageLimit:this.getVariable("dialog.messageLimit",20),enableReadMessages:this.getVariable("dialog.enableReadMessages",true),messageExtraCount:0},disk:{enabled:false,maxFileSize:5242880},call:{serverEnabled:false,maxParticipants:24},mobile:{keyboardShow:false},device:{type:this.getVariable("device.type",r.DeviceType.desktop),orientation:this.getVariable("device.orientation",r.DeviceOrientation.portrait)},options:{quoteEnable:this.getVariable("options.quoteEnable",true),quoteFromRight:this.getVariable("options.quoteFromRight",true),autoplayVideo:this.getVariable("options.autoplayVideo",true),darkTheme:this.getVariable("options.darkTheme",false),showSmiles:false},error:{active:false,code:"",description:""}}}getStateSaveException(){return Object.assign({common:this.getVariable("saveException.common",null),dialog:this.getVariable("saveException.dialog",null),mobile:this.getVariable("saveException.mobile",null),device:this.getVariable("saveException.device",null),error:this.getVariable("saveException.error",null)})}getGetters(){return{getOption:e=>t=>{if(!r.Settings[t]){return false}return e.options[t]}}}getActions(){return{set:(e,t)=>{e.commit("set",this.validate(t))},showSmiles:(e,t)=>{e.commit("showSmiles")},hideSmiles:(e,t)=>{e.commit("hideSmiles")},setOptions:(e,t)=>{if(!a.Type.isPlainObject(t)){return false}t=this.validateOptions(t);Object.entries(t).forEach((([t,i])=>{e.commit("setOptions",{option:t,value:i})}))}}}getMutations(){return{set:(e,t)=>{let i=false;for(let s in t){if(!t.hasOwnProperty(s)){continue}for(let a in t[s]){if(!t[s].hasOwnProperty(a)){continue}e[s][a]=t[s][a];i=true}}if(i&&this.isSaveNeeded(t)){this.saveState(e)}},increaseDialogExtraCount(e,t={}){let{count:i=1}=t;e.dialog.messageExtraCount+=i},decreaseDialogExtraCount(e,t={}){let{count:i=1}=t;let s=e.dialog.messageExtraCount-i;if(s<=0){s=0}e.dialog.messageExtraCount=s},clearDialogExtraCount(e){e.dialog.messageExtraCount=0},showSmiles(e){e.options.showSmiles=true},hideSmiles(e){e.options.showSmiles=false},setOptions:(e,t)=>{e.options[t.option]=t.value}}}validate(e){const t={};if(typeof e.common==="object"&&e.common){t.common={};if(typeof e.common.userId==="number"){t.common.userId=e.common.userId}if(typeof e.common.languageId==="string"){t.common.languageId=e.common.languageId}}if(typeof e.dialog==="object"&&e.dialog){t.dialog={};if(typeof e.dialog.dialogId==="number"){t.dialog.dialogId=e.dialog.dialogId.toString();t.dialog.chatId=0}else if(typeof e.dialog.dialogId==="string"){t.dialog.dialogId=e.dialog.dialogId;if(typeof e.dialog.chatId!=="number"){let i=e.dialog.dialogId;if(i.startsWith("chat")){i=e.dialog.dialogId.substr(4)}i=parseInt(i);t.dialog.chatId=!isNaN(i)?i:0;e.dialog.chatId=t.dialog.chatId}}if(typeof e.dialog.chatId==="number"){t.dialog.chatId=e.dialog.chatId}if(typeof e.dialog.diskFolderId==="number"){t.dialog.diskFolderId=e.dialog.diskFolderId}if(typeof e.dialog.messageLimit==="number"){t.dialog.messageLimit=e.dialog.messageLimit}if(typeof e.dialog.messageExtraCount==="number"){t.dialog.messageExtraCount=e.dialog.messageExtraCount}if(typeof e.dialog.enableReadMessages==="boolean"){t.dialog.enableReadMessages=e.dialog.enableReadMessages}}if(typeof e.disk==="object"&&e.disk){t.disk={};if(typeof e.disk.enabled==="boolean"){t.disk.enabled=e.disk.enabled}if(typeof e.disk.maxFileSize==="number"){t.disk.maxFileSize=e.disk.maxFileSize}}if(typeof e.call==="object"&&e.call){t.call={};if(typeof e.call.serverEnabled==="boolean"){t.call.serverEnabled=e.call.serverEnabled}if(typeof e.call.maxParticipants==="number"){t.call.maxParticipants=e.call.maxParticipants}}if(typeof e.mobile==="object"&&e.mobile){t.mobile={};if(typeof e.mobile.keyboardShow==="boolean"){t.mobile.keyboardShow=e.mobile.keyboardShow}}if(typeof e.device==="object"&&e.device){t.device={};if(typeof e.device.type==="string"&&typeof r.DeviceType[e.device.type]!=="undefined"){t.device.type=e.device.type}if(typeof e.device.orientation==="string"&&typeof r.DeviceOrientation[e.device.orientation]!=="undefined"){t.device.orientation=e.device.orientation}}if(typeof e.error==="object"&&e.error){if(typeof e.error.active==="boolean"){t.error={active:e.error.active,code:e.error.code.toString()||"",description:e.error.description.toString()||""}}}return t}validateOptions(e){const t={};if(!a.Type.isUndefined(e.darkTheme)&&a.Type.isStringFilled(e.darkTheme)){if(e.darkTheme==="auto"&&BX.MessengerProxy){t.darkTheme=BX.MessengerProxy.isDarkTheme()}else{t.darkTheme=e.darkTheme==="dark"}}return t}}const d={empty:"empty",equal:"equal",none:"none",found:"found",foundReverse:"foundReverse"};class c extends n.BuilderModel{getName(){return"messages"}getState(){return{created:0,collection:{},mutationType:{},saveMessageList:{},saveFileList:{},saveUserList:{}}}getElementState(){return{templateId:0,templateType:"message",placeholderType:0,id:0,chatId:0,authorId:0,date:new Date,text:"",textConverted:"",params:{TYPE:"default",COMPONENT_ID:"bx-im-view-message"},push:false,unread:false,sending:false,error:false,retry:false,blink:false}}getGetters(){return{getMutationType:e=>t=>{if(!e.mutationType[t]){return{initialType:r.MutationType.none,appliedType:r.MutationType.none}}return e.mutationType[t]},getLastId:e=>t=>{if(!e.collection[t]||e.collection[t].length<=0){return null}let i=0;for(let s=0;s<e.collection[t].length;s++){let a=e.collection[t][s];if(a.push||a.sending||a.id.toString().startsWith("temporary")){continue}if(i<a.id){i=a.id}}return i?i:null},getMessage:e=>(t,i)=>{if(!e.collection[t]||e.collection[t].length<=0){return null}for(let s=e.collection[t].length-1;s>=0;s--){if(e.collection[t][s].id===i){return e.collection[t][s]}}return null},get:e=>t=>{if(!e.collection[t]||e.collection[t].length<=0){return[]}return e.collection[t]},getBlank:e=>e=>this.getElementState(),getSaveFileList:e=>t=>e.saveFileList,getSaveUserList:e=>t=>e.saveUserList}}getActions(){return{add:(e,t)=>{let i=this.validate(Object.assign({},t));i.params=Object.assign({},this.getElementState().params,i.params);if(t.id){if(e.state.collection[t.chatId]){const i=e.state.collection[t.chatId].length-1;for(let s=i;s>=0;s--){const i=e.state.collection[t.chatId][s];if(i.templateId===t.id){return}}}i.id=t.id}else{i.id="temporary"+(new Date).getTime()+e.state.created}i.templateId=i.id;i.unread=false;e.commit("add",Object.assign({},this.getElementState(),i));if(t.sending!==false){e.dispatch("actionStart",{id:i.id,chatId:i.chatId})}return i.id},actionStart:(e,i)=>{if(/^\d+$/.test(i.id)){i.id=parseInt(i.id)}i.chatId=parseInt(i.chatId);t.nextTick((()=>{e.commit("update",{id:i.id,chatId:i.chatId,fields:{sending:true}})}))},actionError:(e,i)=>{if(/^\d+$/.test(i.id)){i.id=parseInt(i.id)}i.chatId=parseInt(i.chatId);t.nextTick((()=>{e.commit("update",{id:i.id,chatId:i.chatId,fields:{sending:false,error:true,retry:i.retry!==false}})}))},actionFinish:(e,i)=>{if(/^\d+$/.test(i.id)){i.id=parseInt(i.id)}i.chatId=parseInt(i.chatId);t.nextTick((()=>{e.commit("update",{id:i.id,chatId:i.chatId,fields:{sending:false,error:false,retry:false}})}))},set:(e,t)=>{if(t instanceof Array){t=t.map((e=>this.prepareMessage(e)))}else{let e=this.prepareMessage(t);(t=[]).push(e)}e.commit("set",{insertType:r.MutationType.set,data:t});return"set is done"},addPlaceholders:(e,t)=>{if(t.placeholders instanceof Array){t.placeholders=t.placeholders.map((e=>this.prepareMessage(e)))}else{return false}const i=t.requestMode==="history"?r.MutationType.setBefore:r.MutationType.setAfter;if(i===r.MutationType.setBefore){t.placeholders=t.placeholders.reverse()}e.commit("set",{insertType:i,data:t.placeholders});return t.placeholders[0].id},clearPlaceholders:(e,t)=>{e.commit("clearPlaceholders",t)},updatePlaceholders:(e,t)=>{if(t.data instanceof Array){t.data=t.data.map((e=>this.prepareMessage(e)))}else{return false}e.commit("updatePlaceholders",t);return true},setAfter:(e,t)=>{if(t instanceof Array){t=t.map((e=>this.prepareMessage(e)))}else{let e=this.prepareMessage(t);(t=[]).push(e)}e.commit("set",{insertType:r.MutationType.setAfter,data:t})},setBefore:(e,t)=>{if(t instanceof Array){t=t.map((e=>this.prepareMessage(e)))}else{let e=this.prepareMessage(t);(t=[]).push(e)}e.commit("set",{insertType:r.MutationType.setBefore,data:t})},update:(e,t)=>{if(/^\d+$/.test(t.id)){t.id=parseInt(t.id)}if(/^\d+$/.test(t.chatId)){t.chatId=parseInt(t.chatId)}e.commit("initCollection",{chatId:t.chatId});if(!e.state.collection[t.chatId]){return false}let i=e.state.collection[t.chatId].findIndex((e=>e.id===t.id));if(i<0){return false}let s=this.validate(Object.assign({},t.fields));if(s.params){s.params=Object.assign({},this.getElementState().params,e.state.collection[t.chatId][i].params,s.params)}e.commit("update",{id:t.id,chatId:t.chatId,index:i,fields:s});if(t.fields.blink){setTimeout((()=>{e.commit("update",{id:t.id,chatId:t.chatId,fields:{blink:false}})}),1e3)}return true},delete:(e,t)=>{if(!(t.id instanceof Array)){t.id=[t.id]}t.id=t.id.map((e=>{if(/^\d+$/.test(e)){e=parseInt(e)}return e}));e.commit("delete",{chatId:t.chatId,elements:t.id});return true},clear:(e,t)=>{t.chatId=parseInt(t.chatId);if(t.keepPlaceholders){e.commit("clearMessages",{chatId:t.chatId})}else{e.commit("clear",{chatId:t.chatId})}return true},applyMutationType:(e,t)=>{t.chatId=parseInt(t.chatId);e.commit("applyMutationType",{chatId:t.chatId});return true},readMessages:(e,t)=>{t.readId=parseInt(t.readId)||0;t.chatId=parseInt(t.chatId);if(typeof e.state.collection[t.chatId]==="undefined"){return{count:0}}let i=0;for(let s=e.state.collection[t.chatId].length-1;s>=0;s--){let a=e.state.collection[t.chatId][s];if(!a.unread)continue;if(t.readId===0||a.id<=t.readId){i++}}e.commit("readMessages",{chatId:t.chatId,readId:t.readId});return{count:i}},unreadMessages:(e,t)=>{t.unreadId=parseInt(t.unreadId)||0;t.chatId=parseInt(t.chatId);if(typeof e.state.collection[t.chatId]==="undefined"||!t.unreadId){return{count:0}}let i=0;for(let s=e.state.collection[t.chatId].length-1;s>=0;s--){let a=e.state.collection[t.chatId][s];if(a.unread)continue;if(a.id>=t.unreadId){i++}}e.commit("unreadMessages",{chatId:t.chatId,unreadId:t.unreadId});return{count:i}}}}getMutations(){return{initCollection:(e,t)=>this.initCollection(e,t),add:(e,t)=>{this.initCollection(e,{chatId:t.chatId});e.collection[t.chatId].push(t);e.saveMessageList[t.chatId].push(t.id);e.created+=1;e.collection[t.chatId].sort(((e,t)=>e.id-t.id));this.saveState(e,t.chatId);i.Logger.warn("Messages model: saving state after add")},clearPlaceholders:(e,t)=>{if(!e.collection[t.chatId]){return false}e.collection[t.chatId]=e.collection[t.chatId].filter((e=>!e.id.toString().startsWith("placeholder")))},updatePlaceholders:(e,t)=>{const s=`placeholder${t.firstMessage}`;const a=e.collection[t.chatId].findIndex((e=>e.id===s));if(a>=0){e.collection[t.chatId].splice(a,t.amount);e.collection[t.chatId].splice(a,0,...t.data)}e.collection[t.chatId].sort(((e,t)=>e.id-t.id));i.Logger.warn("Messages model: saving state after updating placeholders");this.saveState(e,t.chatId)},set:(e,t)=>{i.Logger.warn("Messages model: set mutation",t);let a=[];let n=[];let l=false;t.data=c.getPayloadWithTempMessages(e,t);const o=t.insertType;if(t.insertType===r.MutationType.set){t.insertType=r.MutationType.setAfter;let s={};t.data.forEach((e=>{if(!s[e.chatId]){s[e.chatId]=[]}s[e.chatId].push(e.id)}));for(let a in s){if(!s.hasOwnProperty(a))continue;this.initCollection(e,{chatId:a});i.Logger.warn("Messages model: messages before adding from request - ",e.collection[a].length);if(e.saveMessageList[a].length>s[a].length||s[a].length<r.StorageLimit.messages){e.collection[a]=e.collection[a].filter((e=>s[a].includes(e.id)));e.saveMessageList[a]=e.saveMessageList[a].filter((e=>s[a].includes(e)))}i.Logger.warn("Messages model: cache length",e.saveMessageList[a].length);let n=this.manageCacheBeforeSet([...e.saveMessageList[a].reverse()],s[a]);i.Logger.warn("Messages model: set intersection with cache",n);if(n.type===d.none){if(n.foundElements.length>0){e.collection[a]=e.collection[a].filter((e=>!n.foundElements.includes(e.id)));e.saveMessageList[a]=e.saveMessageList[a].filter((e=>!n.foundElements.includes(e)))}i.Logger.warn("Messages model: no intersection - removing cache");this.removeIntersectionCacheElements=e.collection[a].map((e=>e.id));e.collection[a]=e.collection[a].filter((e=>!this.removeIntersectionCacheElements.includes(e.id)));e.saveMessageList[a]=e.saveMessageList[a].filter((e=>!this.removeIntersectionCacheElements.includes(e)));this.removeIntersectionCacheElements=[]}else if(n.type===d.foundReverse){i.Logger.warn("Messages model: found reverse intersection");t.insertType=r.MutationType.setBefore;t.data=t.data.reverse()}}}i.Logger.warn("Messages model: adding messages to model",t.data);for(let i of t.data){this.initCollection(e,{chatId:i.chatId});let s=e.collection[i.chatId].findIndex((e=>{if(c.isTemporaryMessage(e)){return e.templateId===i.templateId}return e.id===i.id}));if(s>-1){e.collection[i.chatId][s]=Object.assign(e.collection[i.chatId][s],i)}else if(t.insertType===r.MutationType.setBefore){e.collection[i.chatId].unshift(i)}else if(t.insertType===r.MutationType.setAfter){e.collection[i.chatId].push(i)}a.push(i.chatId);if(this.store.getters["dialogues/canSaveChat"]&&this.store.getters["dialogues/canSaveChat"](i.chatId)){n.push(i.chatId)}}a=[...new Set(a)];n=[...new Set(n)];l=t.data.every((e=>e.push===true));i.Logger.warn("Is it fake push message?",l);a.forEach((t=>{e.collection[t].sort(((e,t)=>e.id-t.id));if(!l){i.Logger.warn("setting messagesSet = true for chatId = ",t);setTimeout((()=>{s.EventEmitter.emit(r.EventType.dialog.messagesSet,{chatId:t});s.EventEmitter.emit(r.EventType.dialog.readVisibleMessages,{chatId:t})}),100)}}));if(o!==r.MutationType.setBefore){n.forEach((t=>{i.Logger.warn("Messages model: saving state after set");this.saveState(e,t)}))}},update:(e,t)=>{this.initCollection(e,{chatId:t.chatId});let s=-1;if(typeof t.index!=="undefined"&&e.collection[t.chatId][t.index]){s=t.index}else{s=e.collection[t.chatId].findIndex((e=>e.id===t.id))}if(s>=0){let a=e.saveMessageList[t.chatId].includes(e.collection[t.chatId][s].id)||t.fields.id&&!t.fields.id.toString().startsWith("temporary")&&e.collection[t.chatId][s].id.toString().startsWith("temporary");e.collection[t.chatId][s]=Object.assign(e.collection[t.chatId][s],t.fields);if(a){i.Logger.warn("Messages model: saving state after update");this.saveState(e,t.chatId)}}},delete:(e,t)=>{this.initCollection(e,{chatId:t.chatId});e.collection[t.chatId]=e.collection[t.chatId].filter((e=>!t.elements.includes(e.id)));if(e.saveMessageList[t.chatId].length>0){for(let s of t.elements){if(e.saveMessageList[t.chatId].includes(s)){i.Logger.warn("Messages model: saving state after delete");this.saveState(e,t.chatId);break}}}},clear:(e,t)=>{this.initCollection(e,{chatId:t.chatId});e.collection[t.chatId]=[];e.saveMessageList[t.chatId]=[]},clearMessages:(e,t)=>{this.initCollection(e,{chatId:t.chatId});e.collection[t.chatId]=e.collection[t.chatId].filter((e=>e.id.toString().startsWith("placeholder")));e.saveMessageList[t.chatId]=[]},applyMutationType:(e,t)=>{if(typeof e.mutationType[t.chatId]==="undefined"){e.mutationType[t.chatId]={applied:false,initialType:r.MutationType.none,appliedType:r.MutationType.none,scrollStickToTop:0,scrollMessageId:0}}e.mutationType[t.chatId].applied=true},readMessages:(e,t)=>{this.initCollection(e,{chatId:t.chatId});let s=false;for(let i=e.collection[t.chatId].length-1;i>=0;i--){let a=e.collection[t.chatId][i];if(!a.unread)continue;if(t.readId===0||a.id<=t.readId){e.collection[t.chatId][i]=Object.assign(e.collection[t.chatId][i],{unread:false});s=true}}if(s){i.Logger.warn("Messages model: saving state after reading");this.saveState(e,t.chatId)}},unreadMessages:(e,t)=>{this.initCollection(e,{chatId:t.chatId});let s=false;for(let i=e.collection[t.chatId].length-1;i>=0;i--){let a=e.collection[t.chatId][i];if(a.unread)continue;if(a.id>=t.unreadId){e.collection[t.chatId][i]=Object.assign(e.collection[t.chatId][i],{unread:true});s=true}}if(s){i.Logger.warn("Messages model: saving state after unreading");this.saveState(e,t.chatId);this.updateSubordinateStates()}}}}initCollection(e,t){if(typeof t.chatId==="undefined"){return false}if(typeof t.chatId==="undefined"||typeof e.collection[t.chatId]!=="undefined"){return true}e.collection[t.chatId]=t.messages?[...t.messages]:[];e.saveMessageList[t.chatId]=[];e.saveFileList[t.chatId]=[];e.saveUserList[t.chatId]=[];return true}prepareMessage(e,t={}){let i=this.validate(Object.assign({},e),t);i.params=Object.assign({},this.getElementState().params,i.params);if(!i.templateId){i.templateId=i.id}return Object.assign({},this.getElementState(),i)}manageCacheBeforeSet(e,t,s=false){i.Logger.warn("manageCacheBeforeSet",e,t);let a={type:d.empty,foundElements:[],noneElements:[]};if(!e||e.length<=0){return a}for(let i of t){if(e.includes(i)){if(a.type===d.empty){a.type=d.found}a.foundElements.push(i)}else{if(a.type===d.empty){a.type=d.none}a.noneElements.push(i)}}if(a.type===d.found&&e.length===t.length&&a.foundElements.length===t.length){a.type=d.equal}else if(a.type===d.none&&!s&&a.foundElements.length>0){let i=this.manageCacheBeforeSet(e.reverse(),t.reverse(),true);if(i.type===d.found){i.type=d.foundReverse;return i}}return a}updateSaveLists(e,t){if(!this.isSaveAvailable()){return true}if(!t||!this.store.getters["dialogues/canSaveChat"]||!this.store.getters["dialogues/canSaveChat"](t)){return false}this.initCollection(e,{chatId:t});let i=0;let s=[];let a=[];let n=[];let l=this.store.getters["dialogues/getByChatId"](t);if(l&&l.type==="private"){n.push(parseInt(l.dialogId))}let o=0;for(let a=e.collection[t].length-1;a>=0;a--){if(e.collection[t][a].id.toString().startsWith("temporary")){continue}if(!e.collection[t][a].unread){o++}if(i>=r.StorageLimit.messages&&o>=50){break}s.unshift(e.collection[t][a].id);i++}s=s.slice(0,r.StorageLimit.messages);e.collection[t].filter((e=>s.includes(e.id))).forEach((e=>{if(e.authorId>0){n.push(e.authorId)}if(e.params.FILE_ID instanceof Array){a=e.params.FILE_ID.concat(a)}}));e.saveMessageList[t]=s;e.saveFileList[t]=[...new Set(a)];e.saveUserList[t]=[...new Set(n)];return true}getSaveTimeout(){return 150}saveState(e,t){if(!this.updateSaveLists(e,t)){return false}super.saveState((()=>{let t={collection:{},saveMessageList:{},saveUserList:{},saveFileList:{}};for(let s in e.saveMessageList){if(!e.saveMessageList.hasOwnProperty(s)){continue}if(!e.collection[s]){continue}if(!t.collection[s]){t.collection[s]=[]}e.collection[s].filter((t=>e.saveMessageList[s].includes(t.id))).forEach((e=>{if(e.templateType!=="placeholder"){t.collection[s].push(e)}}));i.Logger.warn("Cache after updating",t.collection[s]);t.saveMessageList[s]=e.saveMessageList[s];t.saveFileList[s]=e.saveFileList[s];t.saveUserList[s]=e.saveUserList[s]}return t}))}updateSubordinateStates(){this.store.dispatch("users/saveState");this.store.dispatch("files/saveState")}validate(e,t){const i={};if(typeof e.id==="number"){i.id=e.id}else if(typeof e.id==="string"){if(e.id.startsWith("temporary")||e.id.startsWith("placeholder")||l.Utils.text.isUuidV4(e.id)){i.id=e.id}else{i.id=parseInt(e.id)}}if(typeof e.uuid==="string"){i.templateId=e.uuid}else if(typeof e.templateId==="number"){i.templateId=e.templateId}else if(typeof e.templateId==="string"){if(e.templateId.startsWith("temporary")||l.Utils.text.isUuidV4(e.templateId)){i.templateId=e.templateId}else{i.templateId=parseInt(e.templateId)}}if(typeof e.templateType==="string"){i.templateType=e.templateType}if(typeof e.placeholderType==="number"){i.placeholderType=e.placeholderType}if(typeof e.chat_id!=="undefined"){e.chatId=e.chat_id}if(typeof e.chatId==="number"||typeof e.chatId==="string"){i.chatId=parseInt(e.chatId)}if(typeof e.date!=="undefined"){i.date=l.Utils.date.cast(e.date)}if(typeof e.textOriginal==="string"||typeof e.textOriginal==="number"){i.text=e.textOriginal.toString();if(typeof e.text==="string"||typeof e.text==="number"){i.textConverted=this.convertToHtml({text:e.text.toString(),isConverted:true})}}else{if(typeof e.text_converted!=="undefined"){e.textConverted=e.text_converted}if(typeof e.textConverted==="string"||typeof e.textConverted==="number"){i.textConverted=e.textConverted.toString()}if(typeof e.text==="string"||typeof e.text==="number"){i.text=e.text.toString();let t=typeof i.textConverted!=="undefined";i.textConverted=this.convertToHtml({text:t?i.textConverted:i.text,isConverted:t})}}if(typeof e.senderId!=="undefined"){e.authorId=e.senderId}else if(typeof e.author_id!=="undefined"){e.authorId=e.author_id}if(typeof e.authorId==="number"||typeof e.authorId==="string"){if(e.system===true||e.system==="Y"){i.authorId=0}else{i.authorId=parseInt(e.authorId)}}if(typeof e.params==="object"&&e.params!==null){const s=this.validateParams(e.params,t);if(s){i.params=s}}if(typeof e.push==="boolean"){i.push=e.push}if(typeof e.sending==="boolean"){i.sending=e.sending}if(typeof e.unread==="boolean"){i.unread=e.unread}if(typeof e.blink==="boolean"){i.blink=e.blink}if(typeof e.error==="boolean"||typeof e.error==="string"){i.error=e.error}if(typeof e.retry==="boolean"){i.retry=e.retry}return i}validateParams(e,t){const i={};try{for(let s in e){if(!e.hasOwnProperty(s)){continue}if(s==="COMPONENT_ID"){if(typeof e[s]==="string"&&BX.Vue.isComponent(e[s])){i[s]=e[s]}}else if(s==="LIKE"){if(e[s]instanceof Array){i["REACTION"]={like:e[s].map((e=>parseInt(e)))}}}else if(s==="CHAT_LAST_DATE"){i[s]=l.Utils.date.cast(e[s])}else if(s==="AVATAR"){if(e[s]){i[s]=e[s].startsWith("http")?e[s]:t.host+e[s]}}else if(s==="NAME"){if(e[s]){i[s]=e[s]}}else if(s==="LINK_ACTIVE"){if(e[s]){i[s]=e[s].map((function(e){return parseInt(e)}))}}else if(s==="ATTACH"){i[s]=this.decodeAttach(e[s])}else{i[s]=e[s]}}}catch(e){}let s=false;for(let e in i){if(!i.hasOwnProperty(e)){continue}s=true;break}return s?i:null}convertToHtml(e={}){let{quote:t=true,image:i=true,text:s="",isConverted:a=false,enableBigSmile:n=true}=e;s=s.trim();if(!a){s=s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}if(s.startsWith("/me")){s=`<i>${s.substr(4)}</i>`}else if(s.startsWith("/loud")){s=`<b>${s.substr(6)}</b>`}const r=">>";if(t&&s.indexOf(r)>=0){let e=s.split(a?"<br />":"\n");for(let t=0;t<e.length;t++){if(e[t].startsWith(r)){e[t]=e[t].replace(r,'<div class="bx-im-message-content-quote"><div class="bx-im-message-content-quote-wrap">');while(++t<e.length&&e[t].startsWith(r)){e[t]=e[t].replace(r,"")}e[t-1]+="</div></div><br>"}}s=e.join("<br />")}s=s.replace(/\n/gi,"<br />");s=s.replace(/\t/gi," ");s=this.decodeBbCode(s,false,n);if(t){s=s.replace(/------------------------------------------------------<br \/>(.*?)\[(.*?)\]<br \/>(.*?)------------------------------------------------------(<br \/>)?/g,(function(e,t,i,s,a,n){return(n>0?"<br>":"")+'<div class="bx-im-message-content-quote"><div class="bx-im-message-content-quote-wrap"><div class="bx-im-message-content-quote-name"><span class="bx-im-message-content-quote-name-text">'+t+'</span><span class="bx-im-message-content-quote-name-time">'+i+"</span></div>"+s+"</div></div><br />"}));s=s.replace(/------------------------------------------------------<br \/>(.*?)------------------------------------------------------(<br \/>)?/g,(function(e,t,i,s,a){return(a>0?"<br>":"")+'<div class="bx-im-message-content-quote"><div class="bx-im-message-content-quote-wrap">'+t+"</div></div><br />"}))}if(i){let e=false;s=s.replace(/<a(.*?)>(http[s]{0,1}:\/\/.*?)<\/a>/gi,(function(t,i,s,a){if(!s.match(/(\.(jpg|jpeg|png|gif|webp)\?|\.(jpg|jpeg|png|gif|webp)$)/i)||s.indexOf("/docs/pub/")>0||s.indexOf("logout=yes")>0){return t}else{e=true;return(a>0?"<br />":"")+"<a"+i+' target="_blank" class="bx-im-element-file-image"><img src="'+s+'" class="bx-im-element-file-image-source-text" onerror="BX.Messenger.Model.MessagesModel.hideErrorImage(this)"></a></span>'}}));if(e){s=s.replace(/<\/span>(\n?)<br(\s\/?)>/gi,"</span>").replace(/<br(\s\/?)>(\n?)<br(\s\/?)>(\n?)<span/gi,"<br /><span")}}if(n){s=s.replace(/^(\s*<img\s+src=[^>]+?data-code=[^>]+?data-definition="UHD"[^>]+?style="width:)(\d+)(px[^>]+?height:)(\d+)(px[^>]+?class="bx-smile"\s*\/?>\s*)$/,(function e(t,i,s,a,n,r){return i+parseInt(s,10)*1.7+a+parseInt(n,10)*1.7+r}))}if(s.substr(-6)=="<br />"){s=s.substr(0,s.length-6)}s=s.replace(/<br><br \/>/gi,"<br />");s=s.replace(/<br \/><br>/gi,"<br />");return s}decodeBbCode(e,t=false,i=true){return c.decodeBbCode({text:e,textOnly:t,enableBigSmile:i})}decodeAttach(e){if(Array.isArray(e)){e.forEach((e=>{e=this.decodeAttach(e)}))}else if(typeof e==="object"&&e!==null){for(const t in e){if(e.hasOwnProperty(t)){e[t]=this.decodeAttach(e[t])}}}else{if(typeof e==="string"){e=l.Utils.text.htmlspecialcharsback(e)}}return e}static decodeBbCode(e={}){let{text:t,textOnly:i=false,enableBigSmile:s=true}=e;let a=[];t=t.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,(function(e){var t=a.length;a.push(e);return"####REPLACEMENT_PUT_"+t+"####"}));let n=[];t=t.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,(function(e){var t=n.length;n.push(e);return"####REPLACEMENT_SEND_"+t+"####"}));let r=[];t=t.replace(/\[CODE\]\n?(.*?)\[\/CODE\]/gis,(function(e,t){let i=r.length;r.push(t);return"####REPLACEMENT_CODE_"+i+"####"}));t=t.replace(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,(function(e,t,i){let s=document.createElement("a");s.href=l.Utils.text.htmlspecialcharsback(t);s.target="_blank";s.text=l.Utils.text.htmlspecialcharsback(i);let a=["http:","https:","ftp:","file:","tel:","callto:","mailto:","skype:","viber:"];if(a.indexOf(s.protocol)<=-1){return e}return s.outerHTML}));t=t.replace(/\[url\]([^\]]+)\[\/url\]/gi,(function(e,t){t=l.Utils.text.htmlspecialcharsback(t);let i=document.createElement("a");i.href=t;i.target="_blank";i.text=t;let s=["http:","https:","ftp:","file:","tel:","callto:","mailto:","skype:","viber:"];if(s.indexOf(i.protocol)<=-1){return e}return i.outerHTML}));t=t.replace(/\[LIKE\]/gi,'<span class="bx-smile bx-im-smile-like"></span>');t=t.replace(/\[DISLIKE\]/gi,'<span class="bx-smile bx-im-smile-dislike"></span>');t=t.replace(/\[BR\]/gi,"<br/>");t=t.replace(/\[([buis])\](.*?)\[(\/[buis])\]/gi,((e,t,i,s)=>"<"+t+">"+i+"<"+s+">"));t=t.replace(/\[CHAT=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,((e,t,i,s)=>t?s:'<span class="bx-im-mention" data-type="CHAT" data-value="chat'+i+'">'+s+"</span>"));t=t.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,((e,t,i)=>'<span class="bx-im-mention" data-type="CALL" data-value="'+l.Utils.text.htmlspecialchars(t)+'">'+i+"</span>"));t=t.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,((e,t,i)=>i));let o=0;if(s){o=t.replace(/\[icon\=([^\]]*)\]/gi,"").trim().length}t=t.replace(/\[icon\=([^\]]*)\]/gi,(e=>{let t=e.match(/icon\=(\S+[^\s.,> )\];\'\"!?])/i);if(t&&t[1]){t=t[1]}else{return""}let i={src:t,border:0};let a=e.match(/size\=(\d+)/i);if(a&&a[1]){i["width"]=a[1];i["height"]=a[1]}else{let t=e.match(/width\=(\d+)/i);if(t&&t[1]){i["width"]=t[1]}let s=e.match(/height\=(\d+)/i);if(s&&s[1]){i["height"]=s[1]}if(i["width"]&&!i["height"]){i["height"]=i["width"]}else if(i["height"]&&!i["width"]){i["width"]=i["height"]}else if(i["height"]&&i["width"]);else{i["width"]=20;i["height"]=20}}i["width"]=i["width"]>100?100:i["width"];i["height"]=i["height"]>100?100:i["height"];if(s&&o===0&&i["width"]===i["height"]&&i["width"]===20){i["width"]=40;i["height"]=40}let n=e.match(/title\=(.*[^\s\]])/i);if(n&&n[1]){n=n[1];if(n.indexOf("width=")>-1){n=n.substr(0,n.indexOf("width="))}if(n.indexOf("height=")>-1){n=n.substr(0,n.indexOf("height="))}if(n.indexOf("size=")>-1){n=n.substr(0,n.indexOf("size="))}if(n){i["title"]=l.Utils.text.htmlspecialchars(n).trim();i["alt"]=i["title"]}}let r="";for(let e in i){if(i.hasOwnProperty(e)){r+=e+'="'+i[e]+'" '}}return'<img class="bx-smile bx-icon" '+r+">"}));n.forEach(((e,i)=>{t=t.replace("####REPLACEMENT_SEND_"+i+"####",e)}));t=t.replace(/\[SEND(?:=(?:.+?))?\](?:.+?)?\[\/SEND]/gi,(e=>e.replace(/\[SEND(?:=(.+))?\](.+?)?\[\/SEND]/gi,((e,t,s)=>{let a="";s=s?s:t;t=(t?t:s).replace("<br />","\n");if(!i&&s){s=s.replace(/<([\w]+)[^>]*>(.*?)<\\1>/i,"$2",s);s=s.replace(/\[([\w]+)[^\]]*\](.*?)\[\/\1\]/i,"$2",s);t=t.split("####REPLACEMENT_PUT_").join("####REPLACEMENT_SP_");a="\x3c!--IM_COMMAND_START--\x3e"+'<span class="bx-im-message-command-wrap">'+'<span class="bx-im-message-command" data-entity="send">'+s+"</span>"+'<span class="bx-im-message-command-data">'+t+"</span>"+"</span>"+"\x3c!--IM_COMMAND_END--\x3e"}else{a=s}return a}))));a.forEach(((e,i)=>{t=t.replace("####REPLACEMENT_PUT_"+i+"####",e)}));t=t.replace(/\[PUT(?:=(?:.+?))?\](?:.+?)?\[\/PUT]/gi,(e=>e.replace(/\[PUT(?:=(.+))?\](.+?)?\[\/PUT]/gi,((e,t,s)=>{let a="";s=s?s:t;t=(t?t:s).replace("<br />","\n");if(!i&&s){s=s.replace(/<([\w]+)[^>]*>(.*?)<\/\1>/i,"$2",s);s=s.replace(/\[([\w]+)[^\]]*\](.*?)\[\/\1\]/i,"$2",s);a="\x3c!--IM_COMMAND_START--\x3e"+'<span class="bx-im-message-command-wrap">'+'<span class="bx-im-message-command" data-entity="put">'+s+"</span>"+'<span class="bx-im-message-command-data">'+t+"</span>"+"</span>"+"\x3c!--IM_COMMAND_END--\x3e"}else{a=s}return a}))));r.forEach(((e,s)=>{t=t.replace("####REPLACEMENT_CODE_"+s+"####",!i?'<div class="bx-im-message-content-code">'+e+"</div>":e)}));if(n.length>0){do{n.forEach(((e,i)=>{t=t.replace("####REPLACEMENT_SEND_"+i+"####",e)}))}while(t.includes("####REPLACEMENT_SEND_"))}t=t.split("####REPLACEMENT_SP_").join("####REPLACEMENT_PUT_");if(a.length>0){do{a.forEach(((e,i)=>{t=t.replace("####REPLACEMENT_PUT_"+i+"####",e)}))}while(t.includes("####REPLACEMENT_PUT_"))}return t}static hideErrorImage(e){if(e.parentNode&&e.parentNode){e.parentNode.innerHTML='<a href="'+e.src+'" target="_blank">'+e.src+"</a>"}return true}static isTemporaryMessage(e){return e.id&&(l.Utils.text.isUuidV4(e.id)||e.id.toString().startsWith("temporary"))}static getPayloadWithTempMessages(e,t){const i=[...t.data];if(!l.Utils.platform.isBitrixMobile()){return i}if(!t.data||t.data.length<=0){return i}const s=t.data[0].chatId;if(!e.collection[s]){return i}e.collection[s].forEach((e=>{if(c.isTemporaryMessage(e)&&!c.existsInPayload(t,e.templateId)&&c.doesTaskExist(e)){i.push(e)}}));return i}static existsInPayload(e,t){return e.data.find((e=>e.templateId===t))}static doesTaskExist(e){if(Array.isArray(e.params.FILE_ID)){let t=false;e.params.FILE_ID.forEach((e=>{if(!t){t=window.imDialogUploadTasks.find((t=>t.taskId.split("|")[1]===e))}}));return!!t}if(e.templateId){const t=window.imDialogMessagesTasks.find((t=>t.taskId.split("|")[1]===e.templateId));return!!t}return false}}const u=35e3;class p extends n.BuilderModel{getName(){return"dialogues"}getState(){return{collection:{},writingStatusTimers:{},chatOptions:{}}}getElementState(){return{dialogId:"0",chatId:0,type:r.ChatTypes.chat,name:"",avatar:"",color:"#17A3EA",extranet:false,counter:0,userCounter:0,messageCounter:0,unreadId:0,lastMessageId:0,managerList:[],readList:[],writingList:[],muteList:[],textareaMessage:"",quoteId:0,editId:0,owner:0,entityType:"",entityId:"",dateCreate:null,public:{code:"",link:""}}}getGetters(){return{get:e=>(t,i=false)=>{if(!e.collection[t]&&i){return this.getElementState()}else if(!e.collection[t]&&!i){return null}return e.collection[t]},getByChatId:e=>t=>{t=Number.parseInt(t,10);return Object.values(e.collection).find((e=>e.chatId===t))},getBlank:()=>this.getElementState(),getChatOption:e=>(t,i)=>{if(!e.chatOptions[t]){t="default"}return e.chatOptions[t][i]},getQuoteId:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].quoteId},getEditId:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].editId},areUnreadMessagesLoaded:e=>t=>{const i=e.collection[t];if(!i||i.lastMessageId===0){return true}const s=this.store.getters["messages/get"](i.chatId);if(s.length===0){return true}let n=0;for(let e=s.length-1;e>=0;e--){const t=s[e];if(a.Type.isNumber(t.id)){n=t.id;break}}return n>=i.lastMessageId}}}getActions(){return{set:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.map((e=>this.validate(e))).forEach((t=>{const i=e.state.collection[t.dialogId];if(i){e.commit("update",{dialogId:t.dialogId,fields:t})}else{e.commit("add",{dialogId:t.dialogId,fields:{...this.getElementState(),...t}})}}))},add:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.map((e=>this.validate(e))).forEach((t=>{const i=e.state.collection[t.dialogId];if(!i){e.commit("add",{dialogId:t.dialogId,fields:{...this.getElementState(),...t}})}}))},update:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}e.commit("update",{dialogId:t.dialogId,fields:this.validate(t.fields)})},delete:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}e.commit("delete",t.dialogId)},startWriting:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=`${t.dialogId}|${t.userId}`;const a=i.writingList.some((e=>e.userId===t.userId));if(a){clearTimeout(e.state.writingStatusTimers[s]);e.state.writingStatusTimers[s]=this.setWritingStatusTimeout(t);return true}const n={userId:t.userId,userName:t.userName};const r=[n,...i.writingList];e.commit("update",{actionName:"startWriting",dialogId:t.dialogId,fields:this.validate({writingList:r})});if(!e.state.writingStatusTimers[s]){e.state.writingStatusTimers[s]=this.setWritingStatusTimeout(t)}},stopWriting:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=i.writingList.find((e=>e.userId===t.userId));if(!s){return false}const a=i.writingList.filter((e=>e.userId!==t.userId));e.commit("update",{actionName:"stopWriting",dialogId:t.dialogId,fields:this.validate({writingList:a})});const n=`${t.dialogId}|${t.userId}`;clearTimeout(e.state.writingStatusTimers[n]);delete e.state.writingStatusTimers[n]},addToReadList:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=i.readList.filter((e=>e.userId!==t.userId));s.push({userId:t.userId,userName:t.userName||"",messageId:t.messageId,date:t.date||new Date});e.commit("update",{actionName:"addToReadList",dialogId:t.dialogId,fields:this.validate({readList:s})})},removeFromReadList:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=i.readList.filter((e=>e.userId!==t.userId));e.commit("update",{actionName:"removeFromReadList",dialogId:t.dialogId,fields:this.validate({readList:s})})},increaseCounter:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}if(i.counter===100){return true}let s=i.counter+t.count;if(s>100){s=100}e.commit("update",{actionName:"increaseCounter",dialogId:t.dialogId,fields:{counter:s,previousCounter:i.counter}})},decreaseCounter:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}if(i.counter===100){return true}let s=i.counter-t.count;if(s<0){s=0}e.commit("update",{actionName:"decreaseCounter",dialogId:t.dialogId,fields:{counter:s,previousCounter:i.counter}})},increaseMessageCounter:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}e.commit("update",{actionName:"increaseMessageCount",dialogId:t.dialogId,fields:{messageCounter:i.messageCounter+t.count}})},mute:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=this.store.state.application.common.userId;if(i.muteList.includes(s)){return false}const a=[...i.muteList,s];e.commit("update",{actionName:"mute",dialogId:t.dialogId,fields:this.validate({muteList:a})})},unmute:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return false}const s=this.store.state.application.common.userId;const a=i.muteList.filter((e=>e!==s));e.commit("update",{actionName:"unmute",dialogId:t.dialogId,fields:this.validate({muteList:a})})},setChatOptions:(e,t)=>{e.commit("setChatOptions",this.validateChatOptions(t))}}}getMutations(){return{add:(e,t)=>{e.collection[t.dialogId]=t.fields},update:(e,t)=>{e.collection[t.dialogId]={...e.collection[t.dialogId],...t.fields}},delete:(e,t)=>{delete e.collection[t.dialogId]},setChatOptions:(e,t)=>{e.chatOptions=t}}}setWritingStatusTimeout(e){return setTimeout((()=>{this.store.dispatch("dialogues/stopWriting",{dialogId:e.dialogId,userId:e.userId})}),u)}validate(e){const t={};if(!a.Type.isUndefined(e.dialog_id)){e.dialogId=e.dialog_id}if(a.Type.isNumber(e.dialogId)||a.Type.isStringFilled(e.dialogId)){t.dialogId=e.dialogId.toString()}if(!a.Type.isUndefined(e.chat_id)){e.chatId=e.chat_id}else if(!a.Type.isUndefined(e.id)){e.chatId=e.id}if(a.Type.isNumber(e.chatId)||a.Type.isStringFilled(e.chatId)){t.chatId=Number.parseInt(e.chatId,10)}if(a.Type.isStringFilled(e.type)){t.type=e.type.toString()}if(a.Type.isNumber(e.quoteId)){t.quoteId=Number.parseInt(e.quoteId,10)}if(a.Type.isNumber(e.editId)){t.editId=Number.parseInt(e.editId,10)}if(a.Type.isNumber(e.counter)||a.Type.isStringFilled(e.counter)){t.counter=Number.parseInt(e.counter,10)}if(!a.Type.isUndefined(e.user_counter)){t.userCounter=e.user_counter}if(a.Type.isNumber(e.userCounter)||a.Type.isStringFilled(e.userCounter)){t.userCounter=Number.parseInt(e.userCounter,10)}if(!a.Type.isUndefined(e.message_count)){t.messageCounter=e.message_count}if(a.Type.isNumber(e.messageCounter)||a.Type.isStringFilled(e.messageCounter)){t.messageCounter=Number.parseInt(e.messageCounter,10)}if(!a.Type.isUndefined(e.unread_id)){e.unreadId=e.unread_id}if(a.Type.isNumber(e.unreadId)||a.Type.isStringFilled(e.unreadId)){t.unreadId=Number.parseInt(e.unreadId,10)}if(!a.Type.isUndefined(e.last_message_id)){e.lastMessageId=e.last_message_id}if(a.Type.isNumber(e.lastMessageId)||a.Type.isStringFilled(e.lastMessageId)){t.lastMessageId=Number.parseInt(e.lastMessageId,10)}if(!a.Type.isUndefined(e.textareaMessage)){t.textareaMessage=e.textareaMessage.toString()}if(!a.Type.isUndefined(e.title)){e.name=e.title}if(a.Type.isNumber(e.name)||a.Type.isStringFilled(e.name)){t.name=l.Utils.text.htmlspecialcharsback(e.name.toString())}if(!a.Type.isUndefined(e.owner)){e.ownerId=e.owner}if(a.Type.isNumber(e.ownerId)||a.Type.isStringFilled(e.ownerId)){t.owner=Number.parseInt(e.ownerId,10)}if(a.Type.isString(e.avatar)){t.avatar=this.prepareAvatar(e.avatar)}if(a.Type.isStringFilled(e.color)){t.color=e.color}if(a.Type.isBoolean(e.extranet)){t.extranet=e.extranet}if(!a.Type.isUndefined(e.entity_type)){e.entityType=e.entity_type}if(a.Type.isStringFilled(e.entityType)){t.entityType=e.entityType}if(!a.Type.isUndefined(e.entity_id)){e.entityId=e.entity_id}if(a.Type.isNumber(e.entityId)||a.Type.isStringFilled(e.entityId)){t.entityId=e.entityId.toString()}if(!a.Type.isUndefined(e.date_create)){e.dateCreate=e.date_create}if(!a.Type.isUndefined(e.dateCreate)){t.dateCreate=l.Utils.date.cast(e.dateCreate)}if(a.Type.isPlainObject(e.public)){t.public={};if(a.Type.isStringFilled(e.public.code)){t.public.code=e.public.code}if(a.Type.isStringFilled(e.public.link)){t.public.link=e.public.link}}if(!a.Type.isUndefined(e.readed_list)){e.readList=e.readed_list}if(a.Type.isArray(e.readList)){t.readList=this.prepareReadList(e.readList)}if(!a.Type.isUndefined(e.writing_list)){e.writingList=e.writing_list}if(a.Type.isArray(e.writingList)){t.writingList=this.prepareWritingList(e.writingList)}if(!a.Type.isUndefined(e.manager_list)){e.managerList=e.manager_list}if(a.Type.isArray(e.managerList)){t.managerList=[];e.managerList.forEach((e=>{e=Number.parseInt(e,10);if(e>0){t.managerList.push(e)}}))}if(!a.Type.isUndefined(e.mute_list)){e.muteList=e.mute_list}if(a.Type.isArray(e.muteList)||a.Type.isPlainObject(e.muteList)){t.muteList=this.prepareMuteList(e.muteList)}return t}prepareAvatar(e){let t="";if(!e||e.endsWith("/js/im/images/blank.gif")){t=""}else if(e.startsWith("http")){t=e}else{t=this.store.state.application.common.host+e}if(t){t=encodeURI(t)}return t}prepareReadList(e){const t=[];e.forEach((e=>{const i={};if(!a.Type.isUndefined(e.user_id)){e.userId=e.user_id}if(!a.Type.isUndefined(e.user_name)){e.userName=e.user_name}if(!a.Type.isUndefined(e.message_id)){e.messageId=e.message_id}if(!e.userId||!e.userName||!e.messageId){return false}i.userId=Number.parseInt(e.userId,10);i.userName=e.userName.toString();i.messageId=Number.parseInt(e.messageId,10);i.date=l.Utils.date.cast(e.date);t.push(i)}));return t}prepareWritingList(e){const t=[];e.forEach((e=>{const i={};if(!e.userId){return false}i.userId=Number.parseInt(e.userId,10);i.userName=l.Utils.text.htmlspecialcharsback(e.userName);t.push(i)}));return t}prepareMuteList(e){const t=[];if(a.Type.isArray(e)){e.forEach((e=>{e=Number.parseInt(e,10);if(e>0){t.push(e)}}))}else if(a.Type.isPlainObject(e)){Object.entries(e).forEach((([e,i])=>{if(!i){return}const s=Number.parseInt(e,10);if(s>0){t.push(s)}}))}return t}validateChatOptions(e){const t={};Object.entries(e).forEach((([e,i])=>{const s=l.Utils.text.convertSnakeToCamelCase(e.toLowerCase());t[s]={};Object.entries(i).forEach((([e,i])=>{const a=l.Utils.text.convertSnakeToCamelCase(e.toLowerCase());t[s][a]=i}))}));return t}}class f extends n.BuilderModel{getName(){return"users"}getState(){return{collection:{},onlineList:[],mobileOnlineList:[],absentList:[],botList:{}}}getElementState(e={}){const{id:t=0}=e;return{id:t,name:"",firstName:"",lastName:"",workPosition:"",gender:"M",extranet:false,network:false,bot:false,connector:false,externalAuthId:"default",status:"",idle:false,lastActivityDate:false,mobileLastDate:false,isOnline:false,isMobileOnline:false,birthday:false,isBirthday:false,absent:false,isAbsent:false,departments:[],phones:{workPhone:"",personalMobile:"",personalPhone:"",innerPhone:""}}}getGetters(){return{get:e=>(t,i=false)=>{t=Number.parseInt(t,10);if(t<=0){if(i){t=0}else{return null}}const s=e.collection[t];if(!i&&!s){return null}else if(i&&!s){return this.getElementState({id:t})}return s},getBlank:()=>e=>this.getElementState(e),getList:e=>t=>{const i=[];if(!Array.isArray(t)){return null}t.forEach((t=>{if(e.collection[t]){i.push(e.collection[t])}else{i.push(this.getElementState({id:t}))}}));return i},hasBirthday:e=>t=>{t=Number.parseInt(t,10);const i=e.collection[t];if(t<=0||!i){return false}return i.isBirthday},getStatus:e=>t=>{t=Number.parseInt(t,10);const i=e.collection[t];if(t<=0||!i){return false}if(!i.isOnline){return""}if(i.isMobileOnline){return r.UserStatus.mobileOnline}else if(i.idle){return r.UserStatus.idle}else{return i.status}},getLastOnline:e=>t=>{t=Number.parseInt(t,10);const i=e.collection[t];if(t<=0||!i){return""}return l.Utils.user.getLastDateText(i)},getPosition:e=>t=>{t=Number.parseInt(t,10);const i=e.collection[t];if(t<=0||!i){return false}if(i.workPosition){return i.workPosition}return a.Loc.getMessage("IM_MODEL_USERS_DEFAULT_NAME")},getBotType:e=>t=>{t=Number.parseInt(t,10);const i=e.collection[t];if(t<=0||!i||!i.bot||!e.botList[t]){return""}const s=e.botList[t].type;if(!r.BotType[s]){return r.BotType.bot}return s}}}getActions(){return{set:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.map((e=>this.validate(e))).forEach((t=>{const i=e.state.collection[t.id];if(i){e.commit("update",{id:t.id,fields:t})}else{e.commit("add",{id:t.id,fields:{...this.getElementState(),...t}})}}))},add:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.map((e=>this.validate(e))).forEach((t=>{const i=e.state.collection[t.id];if(!i){e.commit("add",{id:t.id,fields:{...this.getElementState(),...t}})}}))},update:(e,t)=>{t.id=Number.parseInt(t.id,10);const i=e.state.collection[t.id];if(!i){return false}e.commit("update",{id:t.id,fields:this.validate(t.fields)})},delete:(e,t)=>{e.commit("delete",t.id)},setBotList:(e,t)=>{e.commit("setBotList",t)}}}getMutations(){return{add:(e,t)=>{e.collection[t.id]=t.fields;const i=e.collection[t.id];if(l.Utils.user.isOnline(i.lastActivityDate)){i.isOnline=true;this.addToOnlineList(i.id)}if(l.Utils.user.isMobileOnline(i.lastActivityDate,i.mobileLastDate)){i.isMobileOnline=true;this.addToMobileOnlineList(i.id)}if(i.birthday&&l.Utils.user.isBirthdayToday(i.birthday)){i.isBirthday=true;setTimeout((()=>{i.isBirthday=false}),l.Utils.date.getTimeToNextMidnight())}if(i.absent){i.isAbsent=true;this.addToAbsentList(i.id)}this.startOnlineCheckInterval();this.startAbsentCheckInterval()},update:(e,t)=>{const i=e.collection[t.id];if(l.Utils.user.isOnline(t.fields.lastActivityDate)){i.isOnline=true;this.addToOnlineList(t.fields.id)}if(l.Utils.user.isMobileOnline(t.fields.lastActivityDate,t.fields.mobileLastDate)){i.isMobileOnline=true;this.addToMobileOnlineList(t.fields.id)}if(t.fields.absent===false){e.absentList=e.absentList.filter((e=>e!==t.id));e.collection[t.id].isAbsent=false}else if(a.Type.isDate(t.fields.absent)){e.collection[t.id].isAbsent=true;this.addToAbsentList(t.id)}e.collection[t.id]={...e.collection[t.id],...t.fields}},delete:(e,t)=>{delete e.collection[t.id]},setBotList:(e,t)=>{e.botList=t}}}validate(e){const t={};if(a.Type.isNumber(e.id)||a.Type.isString(e.id)){t.id=Number.parseInt(e.id,10)}if(a.Type.isStringFilled(e.first_name)){e.firstName=e.first_name}if(a.Type.isStringFilled(e.last_name)){e.lastName=e.last_name}if(a.Type.isStringFilled(e.firstName)){t.firstName=l.Utils.text.htmlspecialcharsback(e.firstName)}if(a.Type.isStringFilled(e.lastName)){t.lastName=l.Utils.text.htmlspecialcharsback(e.lastName)}if(a.Type.isStringFilled(e.name)){e.name=l.Utils.text.htmlspecialcharsback(e.name);t.name=e.name}if(a.Type.isStringFilled(e.work_position)){e.workPosition=e.work_position}if(a.Type.isStringFilled(e.workPosition)){t.workPosition=l.Utils.text.htmlspecialcharsback(e.workPosition)}if(a.Type.isStringFilled(e.gender)){t.gender=e.gender==="F"?"F":"M"}if(a.Type.isStringFilled(e.birthday)){t.birthday=e.birthday}if(a.Type.isBoolean(e.extranet)){t.extranet=e.extranet}if(a.Type.isBoolean(e.network)){t.network=e.network}if(a.Type.isBoolean(e.bot)){t.bot=e.bot}if(a.Type.isBoolean(e.connector)){t.connector=e.connector}if(a.Type.isStringFilled(e.external_auth_id)){e.externalAuthId=e.external_auth_id}if(a.Type.isStringFilled(e.externalAuthId)){t.externalAuthId=e.externalAuthId}if(a.Type.isStringFilled(e.status)){t.status=e.status}if(!a.Type.isUndefined(e.idle)){t.idle=l.Utils.date.cast(e.idle,false)}if(!a.Type.isUndefined(e.last_activity_date)){e.lastActivityDate=e.last_activity_date}if(!a.Type.isUndefined(e.lastActivityDate)){t.lastActivityDate=l.Utils.date.cast(e.lastActivityDate,false)}if(!a.Type.isUndefined(e.mobile_last_date)){e.mobileLastDate=e.mobile_last_date}if(!a.Type.isUndefined(e.mobileLastDate)){t.mobileLastDate=l.Utils.date.cast(e.mobileLastDate,false)}if(!a.Type.isUndefined(e.absent)){t.absent=l.Utils.date.cast(e.absent,false)}if(Array.isArray(e.departments)){t.departments=[];e.departments.forEach((e=>{e=Number.parseInt(e,10);if(e>0){t.departments.push(e)}}))}if(a.Type.isPlainObject(e.phones)){t.phones=this.preparePhones(e.phones)}return t}preparePhones(e){const t={};if(!a.Type.isUndefined(e.work_phone)){e.workPhone=e.work_phone}if(a.Type.isStringFilled(e.workPhone)||a.Type.isNumber(e.workPhone)){t.workPhone=e.workPhone.toString()}if(!a.Type.isUndefined(e.personal_mobile)){e.personalMobile=e.personal_mobile}if(a.Type.isStringFilled(e.personalMobile)||a.Type.isNumber(e.personalMobile)){t.personalMobile=e.personalMobile.toString()}if(!a.Type.isUndefined(e.personal_phone)){e.personalPhone=e.personal_phone}if(a.Type.isStringFilled(e.personalPhone)||a.Type.isNumber(e.personalPhone)){t.personalPhone=e.personalPhone.toString()}if(!a.Type.isUndefined(e.inner_phone)){e.innerPhone=e.inner_phone}if(a.Type.isStringFilled(e.innerPhone)||a.Type.isNumber(e.innerPhone)){t.innerPhone=e.innerPhone.toString()}return t}addToOnlineList(e){const t=this.store.state.users;if(!t.onlineList.includes(e)){t.onlineList.push(e)}}addToMobileOnlineList(e){const t=this.store.state.users;if(!t.mobileOnlineList.includes(e)){t.mobileOnlineList.push(e)}}addToAbsentList(e){const t=this.store.state.users;if(!t.absentList.includes(e)){t.absentList.push(e)}}startAbsentCheckInterval(){if(this.absentCheckInterval){return true}const e=1e3*60*60*24;this.absentCheckInterval=setTimeout((()=>{setInterval((()=>{const e=this.store.state.users;e.absentList.forEach((t=>{const i=e.collection[t];if(!i){return}const s=Date.now();const a=new Date(i.absent).getTime();if(a<=s){e.absentList=e.absentList.filter((e=>e!==t));i.isAbsent=false}}))}),e)}),l.Utils.date.getTimeToNextMidnight())}startOnlineCheckInterval(){if(this.onlineCheckInterval){return true}const e=6e4;this.onlineCheckInterval=setInterval((()=>{const e=this.store.state.users;e.onlineList.forEach((t=>{const i=e.collection[t];if(!i){return}if(l.Utils.user.isOnline(i.lastActivityDate)){i.isOnline=true}else{i.isOnline=false;e.onlineList=e.onlineList.filter((e=>e!==t))}}));e.mobileOnlineList.forEach((t=>{const i=e.collection[t];if(!i){return}if(l.Utils.user.isMobileOnline(i.lastActivityDate,i.mobileLastDate)){i.isMobileOnline=true}else{i.isMobileOnline=false;e.mobileOnlineList=e.mobileOnlineList.filter((e=>e!==t))}}))}),e)}}class g extends n.BuilderModel{getName(){return"files"}getState(){return{created:0,collection:{},index:{}}}getElementState(e={}){const{id:t=0,chatId:i=0,name:s="File is deleted"}=e;return{id:t,chatId:i,name:s,templateId:t,date:new Date,type:"file",extension:"",icon:"empty",size:0,image:false,status:r.FileStatus.done,progress:100,authorId:0,authorName:"",urlPreview:"",urlShow:"",urlDownload:"",init:false,viewerAttrs:{}}}getGetters(){return{get:e=>(t,i,s=false)=>{if(!t||!i){return null}if(!e.index[t]||!e.index[t][i]){return null}if(!s&&!e.index[t][i].init){return null}return e.index[t][i]},getList:e=>t=>{if(!e.index[t]){return null}return e.index[t]},getBlank:e=>e=>this.getElementState(e)}}getActions(){return{add:(e,t)=>{let i=this.validate(Object.assign({},t));if(t.id){i.id=t.id}else{i.id="temporary"+(new Date).getTime()+e.state.created}i.templateId=i.id;i.init=true;e.commit("add",Object.assign({},this.getElementState(),i));return i.id},set:(e,t)=>{if(t instanceof Array){t=t.map((e=>{let t=this.validate(Object.assign({},e));t.templateId=t.id;return Object.assign({},this.getElementState(),t,{init:true})}))}else{let e=this.validate(Object.assign({},t));e.templateId=e.id;t=[];t.push(Object.assign({},this.getElementState(),e,{init:true}))}e.commit("set",{insertType:r.MutationType.setAfter,data:t})},setBefore:(e,t)=>{if(t instanceof Array){t=t.map((e=>{let t=this.validate(Object.assign({},e));t.templateId=t.id;return Object.assign({},this.getElementState(),t,{init:true})}))}else{let e=this.validate(Object.assign({},t));e.templateId=e.id;t=[];t.push(Object.assign({},this.getElementState(),e,{init:true}))}e.commit("set",{actionName:"setBefore",insertType:r.MutationType.setBefore,data:t})},update:(e,t)=>{let i=this.validate(Object.assign({},t.fields));e.commit("initCollection",{chatId:t.chatId});let s=e.state.collection[t.chatId].findIndex((e=>e.id===t.id));if(s<0){return false}e.commit("update",{id:t.id,chatId:t.chatId,index:s,fields:i});if(t.fields.blink){setTimeout((()=>{e.commit("update",{id:t.id,chatId:t.chatId,fields:{blink:false}})}),1e3)}return true},delete:(e,t)=>{e.commit("delete",{id:t.id,chatId:t.chatId});return true},saveState:(e,t)=>{e.commit("saveState",{});return true}}}getMutations(){return{initCollection:(e,t)=>{this.initCollection(e,t)},add:(e,t)=>{this.initCollection(e,t);e.collection[t.chatId].push(t);e.index[t.chatId][t.id]=t;e.created+=1;this.saveState(e)},set:(e,t)=>{for(let i of t.data){this.initCollection(e,{chatId:i.chatId});let s=e.collection[i.chatId].findIndex((e=>e.id===i.id));if(s>-1){delete i.templateId;e.collection[i.chatId][s]=Object.assign(e.collection[i.chatId][s],i)}else if(t.insertType===r.MutationType.setBefore){e.collection[i.chatId].unshift(i)}else{e.collection[i.chatId].push(i)}e.index[i.chatId][i.id]=i;this.saveState(e)}},update:(e,t)=>{this.initCollection(e,t);let i=-1;if(typeof t.index!=="undefined"&&e.collection[t.chatId][t.index]){i=t.index}else{i=e.collection[t.chatId].findIndex((e=>e.id===t.id))}if(i>=0){delete t.fields.templateId;let s=Object.assign(e.collection[t.chatId][i],t.fields);e.collection[t.chatId][i]=s;e.index[t.chatId][s.id]=s;this.saveState(e)}},delete:(e,t)=>{this.initCollection(e,t);e.collection[t.chatId]=e.collection[t.chatId].filter((e=>e.id!==t.id));delete e.index[t.chatId][t.id];this.saveState(e)},saveState:(e,t)=>{this.saveState(e)}}}initCollection(e,t){if(typeof e.collection[t.chatId]!=="undefined"){return true}e.collection[t.chatId]=[];e.index[t.chatId]=[];return true}getLoadedState(e){if(!e||typeof e!=="object"){return e}if(typeof e.collection!=="object"){return e}e.index={};for(let t in e.collection){if(!e.collection.hasOwnProperty(t)){continue}e.index[t]={};e.collection[t].filter((e=>e!=null)).forEach((i=>{e.index[t][i.id]=i}))}return e}getSaveFileList(){if(!this.db){return[]}if(!this.store.getters["messages/getSaveFileList"]){return[]}let e=this.store.getters["messages/getSaveFileList"]();if(!e){return[]}return e}getSaveTimeout(){return 250}saveState(e){if(!this.isSaveAvailable()){return false}super.saveState((()=>{let t=this.getSaveFileList();if(!t){return false}let i={collection:{}};for(let s in t){if(!t.hasOwnProperty(s)){continue}t[s].forEach((t=>{if(!e.index[s]){return false}if(!e.index[s][t]){return false}if(!i.collection[s]){i.collection[s]=[]}i.collection[s].push(e.index[s][t])}))}return i}))}validate(e,t={}){const i={};if(typeof e.id==="number"){i.id=e.id}else if(typeof e.id==="string"){if(e.id.startsWith("temporary")){i.id=e.id}else{i.id=parseInt(e.id)}}if(typeof e.templateId==="number"){i.templateId=e.templateId}else if(typeof e.templateId==="string"){if(e.templateId.startsWith("temporary")){i.templateId=e.templateId}else{i.templateId=parseInt(e.templateId)}}if(typeof e.chatId==="number"||typeof e.chatId==="string"){i.chatId=parseInt(e.chatId)}if(typeof e.date!=="undefined"){i.date=l.Utils.date.cast(e.date)}if(typeof e.type==="string"){i.type=e.type}if(typeof e.extension==="string"){i.extension=e.extension.toString();if(i.type==="image"){i.icon="img"}else if(i.type==="video"){i.icon="mov"}else{i.icon=g.getIconType(i.extension)}}if(typeof e.name==="string"||typeof e.name==="number"){i.name=e.name.toString()}if(typeof e.size==="number"||typeof e.size==="string"){i.size=parseInt(e.size)}if(typeof e.image==="boolean"){i.image=false}else if(typeof e.image==="object"&&e.image){i.image={width:0,height:0};if(typeof e.image.width==="string"||typeof e.image.width==="number"){i.image.width=parseInt(e.image.width)}if(typeof e.image.height==="string"||typeof e.image.height==="number"){i.image.height=parseInt(e.image.height)}if(i.image.width<=0||i.image.height<=0){i.image=false}}if(typeof e.status==="string"&&typeof r.FileStatus[e.status]!=="undefined"){i.status=e.status}if(typeof e.progress==="number"||typeof e.progress==="string"){i.progress=parseInt(e.progress)}if(typeof e.authorId==="number"||typeof e.authorId==="string"){i.authorId=parseInt(e.authorId)}if(typeof e.authorName==="string"||typeof e.authorName==="number"){i.authorName=e.authorName.toString()}if(typeof e.urlPreview==="string"){if(!e.urlPreview||e.urlPreview.startsWith("http")||e.urlPreview.startsWith("bx")||e.urlPreview.startsWith("file")||e.urlPreview.startsWith("blob")){i.urlPreview=e.urlPreview}else{i.urlPreview=this.store.state.application.common.host+e.urlPreview}}if(typeof e.urlDownload==="string"){if(!e.urlDownload||e.urlDownload.startsWith("http")||e.urlDownload.startsWith("bx")||e.urlPreview.startsWith("file")){i.urlDownload=e.urlDownload}else{i.urlDownload=this.store.state.application.common.host+e.urlDownload}}if(typeof e.urlShow==="string"){if(!e.urlShow||e.urlShow.startsWith("http")||e.urlShow.startsWith("bx")||e.urlShow.startsWith("file")){i.urlShow=e.urlShow}else{i.urlShow=this.store.state.application.common.host+e.urlShow}}if(typeof e.viewerAttrs==="object"){if(i.type==="image"&&!l.Utils.platform.isBitrixMobile()){i.viewerAttrs=e.viewerAttrs}if(i.type==="video"&&!l.Utils.platform.isBitrixMobile()&&i.size>g.maxDiskFileSize){i.viewerAttrs=e.viewerAttrs}}return i}static getType(e){e=e.toString().toLowerCase().split(".").splice(-1)[0];switch(e){case"png":case"jpe":case"jpg":case"jpeg":case"gif":case"heic":case"bmp":case"webp":return r.FileType.image;case"mp4":case"mkv":case"webm":case"mpeg":case"hevc":case"avi":case"3gp":case"flv":case"m4v":case"ogg":case"wmv":case"mov":return r.FileType.video;case"mp3":return r.FileType.audio}return r.FileType.file}static getIconType(e){let t="empty";switch(e.toString()){case"png":case"jpe":case"jpg":case"jpeg":case"gif":case"heic":case"bmp":case"webp":t="img";break;case"mp4":case"mkv":case"webm":case"mpeg":case"hevc":case"avi":case"3gp":case"flv":case"m4v":case"ogg":case"wmv":case"mov":t="mov";break;case"txt":t="txt";break;case"doc":case"docx":t="doc";break;case"xls":case"xlsx":t="xls";break;case"php":t="php";break;case"pdf":t="pdf";break;case"ppt":case"pptx":t="ppt";break;case"rar":t="rar";break;case"zip":case"7z":case"tar":case"gz":case"gzip":t="zip";break;case"set":t="set";break;case"conf":case"ini":case"plist":t="set";break}return t}}g.maxDiskFileSize=5242880;class h extends n.BuilderModel{getName(){return"recent"}getState(){return{collection:{},activeCalls:[],options:{showBirthday:true,showInvited:true,showLastMessage:true}}}getElementState(){return{dialogId:"0",message:{id:0,text:"",date:new Date,senderId:0,status:r.MessageStatus.received},draft:{text:"",date:null},unread:false,pinned:false,liked:false,invitation:{isActive:false,originator:0,canResend:false},options:{}}}getActiveCallDefaultState(){return{dialogId:0,name:"",call:{},state:r.RecentCallStatus.waiting}}getGetters(){return{getCollection:e=>Object.values(e.collection),getSortedCollection:e=>{const t=Object.values(e.collection).filter((e=>{const t=e.options.birthdayPlaceholder;const i=e.options.defaultUserRecord;return!t&&!i&&e.message.id}));return[...t].sort(((e,t)=>t.message.date-e.message.date))},get:e=>t=>{if(a.Type.isNumber(t)){t=t.toString()}if(e.collection[t]){return e.collection[t]}return null},getItemText:e=>t=>{const i=e.collection[t];if(!i){return""}let s=i.message.text;s=s.replace(/\[user=(\d+) replace](.*?)\[\/user]/gi,((e,t,i)=>{const s=this.store.getters["users/get"](t);return s?s.name:i}));s=s.replace(/\[user=(\d+)]\[\/user]/gi,((e,t)=>{const i=this.store.getters["users/get"](t);return i?i.name:e}));return s.replace(/\[user=(\d+)](.+?)\[\/user]/gi,"$2")},needsBirthdayPlaceholder:e=>t=>{const i=e.collection[t];if(!i){return false}const s=this.store.getters["dialogues/get"](t);if(!s||s.type!==r.ChatTypes.user){return false}const a=this.store.getters["users/hasBirthday"](t);if(!a){return false}const n=i.message.id>0&&l.Utils.date.isToday(i.message.date);return e.options.showBirthday&&!n&&s.counter===0},getMessageDate:e=>t=>{const i=e.collection[t];if(!i){return null}if(a.Type.isDate(i.draft.date)&&i.draft.date>i.message.date){return i.draft.date}const s=this.store.getters["recent/needsBirthdayPlaceholder"](i.dialogId);if(s){return l.Utils.date.getStartOfTheDay()}return i.message.date},hasActiveCall:e=>e.activeCalls.some((e=>e.state===r.RecentCallStatus.joined)),getOption:e=>t=>{if(!r.RecentSettings[t]){return false}return e.options[t]}}}getActions(){return{set:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}const i=[];const s=[];t.map((e=>this.validate(e))).forEach((t=>{const a=e.state.collection[t.dialogId];if(a){i.push({id:a.dialogId,fields:{...t}})}else{s.push({...this.getElementState(),...t})}}));if(s.length>0){e.commit("add",s)}if(i.length>0){e.commit("update",i)}},update:(e,t)=>{const i=e.state.collection[t.id];if(!i){return false}e.commit("update",{id:i.dialogId,fields:this.validate(t.fields)})},unread:(e,t)=>{const i=e.state.collection[t.id];if(!i){return false}e.commit("update",{id:i.dialogId,fields:{unread:t.action}})},pin:(e,t)=>{const i=e.state.collection[t.id];if(!i){return false}e.commit("update",{id:i.dialogId,fields:{pinned:t.action}})},like:(e,t)=>{const i=e.state.collection[t.id];if(!i){return false}const s=i.message.id===Number.parseInt(t.messageId,10);const n=!a.Type.isUndefined(t.messageId)&&t.liked===true;if(n&&!s){return false}e.commit("update",{id:i.dialogId,fields:{liked:t.liked===true}})},draft:(e,t)=>{const i=this.store.getters["dialogues/get"](t.id);if(!i){return false}let s=e.state.collection[t.id];if(!s){if(t.text===""){return false}const i={dialogId:t.id.toString()};e.commit("add",{...this.getElementState(),...i});s=e.state.collection[t.id]}const a=this.validate({draft:{text:t.text.toString()}});if(a.draft.text===s.draft.text){return false}e.commit("update",{id:s.dialogId,fields:a})},delete:(e,t)=>{const i=e.state.collection[t.id];if(!i){return false}e.commit("delete",{id:i.dialogId})},addActiveCall:(e,t)=>{const i=e.state.activeCalls.findIndex((e=>e.dialogId===t.dialogId||e.call.id===t.call.id));if(i>-1){e.commit("updateActiveCall",{index:i,fields:this.validateActiveCall(t)});return true}e.commit("addActiveCall",this.prepareActiveCall(t))},updateActiveCall:(e,t)=>{const i=e.state.activeCalls.findIndex((e=>e.dialogId===t.dialogId));e.commit("updateActiveCall",{index:i,fields:this.validateActiveCall(t.fields)})},deleteActiveCall:(e,t)=>{const i=e.state.activeCalls.findIndex((e=>e.dialogId===t.dialogId));if(i===-1){return false}e.commit("deleteActiveCall",{index:i})},setOptions:(e,t)=>{if(!a.Type.isPlainObject(t)){return false}t=this.validateOptions(t);Object.entries(t).forEach((([t,i])=>{e.commit("setOptions",{option:t,value:i})}))}}}getMutations(){return{add:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.forEach((t=>{e.collection[t.dialogId]=t}))},update:(e,t)=>{if(!Array.isArray(t)&&a.Type.isPlainObject(t)){t=[t]}t.forEach((({id:t,fields:i})=>{const s=i.options&&i.options.defaultUserRecord&&!i.invitation;if(s){return false}const a=e.collection[t];i.message={...a.message,...i.message};i.options={...a.options,...i.options};e.collection[t]={...a,...i}}))},delete:(e,t)=>{delete e.collection[t.id]},addActiveCall:(e,t)=>{e.activeCalls.push(t)},updateActiveCall:(e,t)=>{e.activeCalls[t.index]={...e.activeCalls[t.index],...t.fields}},deleteActiveCall:(e,t)=>{e.activeCalls.splice(t.index,1)},setOptions:(e,t)=>{e.options[t.option]=t.value}}}validate(e){const t={options:{}};if(a.Type.isNumber(e.id)){t.dialogId=e.id.toString()}if(a.Type.isStringFilled(e.id)){t.dialogId=e.id}if(a.Type.isNumber(e.dialogId)){t.dialogId=e.dialogId.toString()}if(a.Type.isStringFilled(e.dialogId)){t.dialogId=e.dialogId}if(a.Type.isPlainObject(e.message)){t.message=this.prepareMessage(e)}if(a.Type.isPlainObject(e.draft)){t.draft=this.prepareDraft(e)}if(a.Type.isBoolean(e.unread)){t.unread=e.unread}if(a.Type.isBoolean(e.pinned)){t.pinned=e.pinned}if(a.Type.isBoolean(e.liked)){t.liked=e.liked}if(a.Type.isPlainObject(e.invited)){t.invitation={isActive:true,originator:e.invited.originator_id,canResend:e.invited.can_resend};t.options.defaultUserRecord=true}else if(e.invited===false){t.invitation={isActive:false,originator:0,canResend:false};t.options.defaultUserRecord=true}if(a.Type.isPlainObject(e.options)){if(!t.options){t.options={}}if(a.Type.isBoolean(e.options.default_user_record)){e.options.defaultUserRecord=e.options.default_user_record}if(a.Type.isBoolean(e.options.defaultUserRecord)){t.options.defaultUserRecord=e.options.defaultUserRecord}if(a.Type.isBoolean(e.options.birthdayPlaceholder)){t.options.birthdayPlaceholder=e.options.birthdayPlaceholder}}return t}prepareChatType(e){if(e.type===r.ChatTypes.user){return r.ChatTypes.user}if(e.chat){return e.chat.type}return e.type}prepareMessage(e){const{message:t}=this.getElementState();if(a.Type.isNumber(e.message.id)){t.id=e.message.id}if(a.Type.isString(e.message.text)){const i={};if(e.message.withAttach||e.message.attach){i.WITH_ATTACH=true}else if(e.message.withFile||e.message.file){i.WITH_FILE=true}t.text=this.prepareText(e.message.text,i)}if(a.Type.isDate(e.message.date)||a.Type.isString(e.message.date)){t.date=l.Utils.date.cast(e.message.date)}if(a.Type.isNumber(e.message.author_id)){t.senderId=e.message.author_id}if(a.Type.isNumber(e.message.senderId)){t.senderId=e.message.senderId}if(a.Type.isStringFilled(e.message.status)){t.status=e.message.status}return t}prepareDraft(e){const{draft:t}=this.getElementState();if(a.Type.isString(e.draft.text)){t.text=this.prepareText(e.draft.text,{})}if(a.Type.isStringFilled(t.text)){t.date=new Date}else{t.date=null}return t}prepareText(e,t){let i=e.trim();if(i.startsWith("/me")){i=i.slice(4)}else if(i.startsWith("/loud")){i=i.slice(6)}i=i.replace(/<br><br \/>/gi,"<br />");i=i.replace(/<br \/><br>/gi,"<br />");const s=[];i=i.replace(/\[code]\n?([\0-\uFFFF]*?)\[\/code]/gi,((e,t)=>{const i=s.length;s.push(t);return`####REPLACEMENT_CODE_${i}####`}));i=i.replace(/\[put(?:=.+?)?](?:.+?)?\[\/put]/gi,(e=>e.replace(/\[put(?:=(.+))?](.+?)?\[\/put]/gi,((e,t,i)=>i||t))));i=i.replace(/\[send(?:=.+?)?](?:.+?)?\[\/send]/gi,(e=>e.replace(/\[send(?:=(.+))?](.+?)?\[\/send]/gi,((e,t,i)=>i||t))));i=i.replace(/\[[bisu]](.*?)\[\/[bisu]]/gi,"$1");i=i.replace(/\[url](.*?)\[\/url]/gi,"$1");i=i.replace(/\[url=(.*?)](.*?)\[\/url]/gi,"$2");i=i.replace(/\[rating=([1-5])]/gi,(()=>`[${a.Loc.getMessage("IM_UTILS_TEXT_RATING")}] `));i=i.replace(/\[attach=(\d+)]/gi,(()=>`[${a.Loc.getMessage("IM_UTILS_TEXT_ATTACH")}] `));i=i.replace(/\[dialog=(chat\d+|\d+)(?: message=(\d+))?](.*?)\[\/dialog]/gi,((e,t,i,s)=>s));i=i.replace(/\[chat=(\d+)](.*?)\[\/chat]/gi,"$2");i=i.replace(/\[send(?:=.+?)?](.+?)?\[\/send]/gi,"$1");i=i.replace(/\[put(?:=.+?)?](.+?)?\[\/put]/gi,"$1");i=i.replace(/\[call(?:=.+?)?](.*?)\[\/call]/gi,"$1");i=i.replace(/\[pch=(\d+)](.*?)\[\/pch]/gi,"$2");i=i.replace(/<img.*?data-code="([^"]*)".*?>/gi,"$1");i=i.replace(/<span.*?title="([^"]*)".*?>.*?<\/span>/gi,"($1)");i=i.replace(/<img.*?title="([^"]*)".*?>/gi,"($1)");i=i.replace(/<s>([^"]*)<\/s>/gi," ");i=i.replace(/\[s]([^"]*)\[\/s]/gi," ");i=i.replace(/\[icon=([^\]]*)]/gi,this.prepareIconCode);s.forEach(((e,t)=>{i=i.replace(`####REPLACEMENT_CODE_${t}####`,e)}));i=i.replace(/-{54}(.*?)-{54}/gims,`[${a.Loc.getMessage("IM_UTILS_TEXT_QUOTE")}] `);i=i.replace(/^(>>(.*)(\n)?)/gim,`[${a.Loc.getMessage("IM_UTILS_TEXT_QUOTE")}] `);if(t.WITH_ATTACH&&i.length===0){i=`[${a.Loc.getMessage("IM_UTILS_TEXT_ATTACH")}] ${i}`}else if(t.WITH_FILE&&i.length===0){i=`[${a.Loc.getMessage("IM_UTILS_TEXT_FILE")}] ${i}`}i=i.replace(/\n/gi," ").trim();const n=24;const r="\u200b";if(i.length>n){let e=i.slice(0,n+1);const t=i.slice(n+1);const s=/\s/.test(e);const a=/\[user=(\d+)](.*?)\[\/user]/i.test(i);if(e.length===n+1&&!s&&!a){e+=r}i=e+t}return i}prepareIconCode(e){let t=e.match(/title=(.*[^\s\]])/i);if(t&&t[1]){t=t[1];if(t.includes("width=")){t=t.slice(0,Math.max(0,t.indexOf("width=")))}if(t.includes("height=")){t=t.slice(0,Math.max(0,t.indexOf("height=")))}if(t.includes("size=")){t=t.slice(0,Math.max(0,t.indexOf("size=")))}if(t){t=`(${t.trim()})`}}else{t=`(${a.Loc.getMessage("IM_UTILS_TEXT_ICON")})`}return t}prepareActiveCall(e){return{...this.getActiveCallDefaultState(),...this.validateActiveCall(e)}}validateActiveCall(e){const t={};if(a.Type.isStringFilled(e.dialogId)||a.Type.isNumber(e.dialogId)){t.dialogId=e.dialogId}if(a.Type.isStringFilled(e.name)){t.name=e.name}if(a.Type.isObjectLike(e.call)){var i,s;t.call=e.call;if(((i=e.call)==null?void 0:(s=i.associatedEntity)==null?void 0:s.avatar)==="/bitrix/js/im/images/blank.gif"){t.call.associatedEntity.avatar=""}}if(r.RecentCallStatus[e.state]){t.state=e.state}return t}validateOptions(e){const t={};if(a.Type.isBoolean(e.showBirthday)){t.showBirthday=e.showBirthday}if(a.Type.isBoolean(e.showInvited)){t.showInvited=e.showInvited}if(a.Type.isBoolean(e.showLastMessage)){t.showLastMessage=e.showLastMessage}return t}}e.ApplicationModel=o;e.MessagesModel=c;e.DialoguesModel=p;e.UsersModel=f;e.FilesModel=g;e.RecentModel=h})(this.BX.Messenger.v2.Model=this.BX.Messenger.v2.Model||{},BX.Vue3,BX.Messenger.v2.Lib,BX.Event,BX,BX.Vue3.Vuex,BX.Messenger.v2.Const,BX.Messenger.v2.Lib); //# sourceMappingURL=registry.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings