text: this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};(function(e,t,i,a,n){"use strict";var r=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"getName",value:function e(){return"application"}},{key:"getState",value:function e(){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},mobile:{keyboardShow:false},device:{type:this.getVariable("device.type",a.DeviceType.desktop),orientation:this.getVariable("device.orientation",a.DeviceOrientation.portrait)},options:{quoteEnable:this.getVariable("options.quoteEnable",true),quoteFromRight:this.getVariable("options.quoteFromRight",true),autoplayVideo:this.getVariable("options.autoplayVideo",true),darkBackground:this.getVariable("options.darkBackground",false)},error:{active:false,code:"",description:""}}}},{key:"getStateSaveException",value:function e(){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)})}},{key:"getActions",value:function e(){var t=this;return{set:function e(i,a){i.commit("set",t.validate(a))}}}},{key:"getMutations",value:function e(){var t=this;return{set:function e(i,a){var n=false;for(var r in a){if(!a.hasOwnProperty(r)){continue}for(var o in a[r]){if(!a[r].hasOwnProperty(o)){continue}i[r][o]=a[r][o];n=true}}if(n&&t.isSaveNeeded(a)){t.saveState(i)}},increaseDialogExtraCount:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var a=i.count,n=a===void 0?1:a;t.dialog.messageExtraCount+=n},decreaseDialogExtraCount:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var a=i.count,n=a===void 0?1:a;var r=t.dialog.messageExtraCount-n;if(r<=0){r=0}t.dialog.messageExtraCount=r},clearDialogExtraCount:function e(t){t.dialog.messageExtraCount=0}}}},{key:"validate",value:function e(t){var i={};if(babelHelpers.typeof(t.common)==="object"&&t.common){i.common={};if(typeof t.common.userId==="number"){i.common.userId=t.common.userId}if(typeof t.common.languageId==="string"){i.common.languageId=t.common.languageId}}if(babelHelpers.typeof(t.dialog)==="object"&&t.dialog){i.dialog={};if(typeof t.dialog.dialogId==="number"){i.dialog.dialogId=t.dialog.dialogId.toString();i.dialog.chatId=0}else if(typeof t.dialog.dialogId==="string"){i.dialog.dialogId=t.dialog.dialogId;if(typeof t.dialog.chatId!=="number"){var n=t.dialog.dialogId;if(n.startsWith("chat")){n=t.dialog.dialogId.substr(4)}n=parseInt(n);i.dialog.chatId=!isNaN(n)?n:0;t.dialog.chatId=i.dialog.chatId}}if(typeof t.dialog.chatId==="number"){i.dialog.chatId=t.dialog.chatId}if(typeof t.dialog.diskFolderId==="number"){i.dialog.diskFolderId=t.dialog.diskFolderId}if(typeof t.dialog.messageLimit==="number"){i.dialog.messageLimit=t.dialog.messageLimit}if(typeof t.dialog.messageExtraCount==="number"){i.dialog.messageExtraCount=t.dialog.messageExtraCount}if(typeof t.dialog.enableReadMessages==="boolean"){i.dialog.enableReadMessages=t.dialog.enableReadMessages}}if(babelHelpers.typeof(t.disk)==="object"&&t.disk){i.disk={};if(typeof t.disk.enabled==="boolean"){i.disk.enabled=t.disk.enabled}if(typeof t.disk.maxFileSize==="number"){i.disk.maxFileSize=t.disk.maxFileSize}}if(babelHelpers.typeof(t.mobile)==="object"&&t.mobile){i.mobile={};if(typeof t.mobile.keyboardShow==="boolean"){i.mobile.keyboardShow=t.mobile.keyboardShow}}if(babelHelpers.typeof(t.device)==="object"&&t.device){i.device={};if(typeof t.device.type==="string"&&typeof a.DeviceType[t.device.type]!=="undefined"){i.device.type=t.device.type}if(typeof t.device.orientation==="string"&&typeof a.DeviceOrientation[t.device.orientation]!=="undefined"){i.device.orientation=t.device.orientation}}if(babelHelpers.typeof(t.error)==="object"&&t.error){if(typeof t.error.active==="boolean"){i.error={active:t.error.active,code:t.error.code.toString()||"",description:t.error.description.toString()||""}}}return i}}]);return t}(i.VuexBuilderModel);var o={empty:"empty",equal:"equal",none:"none",found:"found",foundReverse:"foundReverse"};var s=function(e){babelHelpers.inherits(i,e);function i(){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).apply(this,arguments))}babelHelpers.createClass(i,[{key:"getName",value:function e(){return"messages"}},{key:"getState",value:function e(){return{created:0,collection:{},mutationType:{},saveMessageList:{},saveFileList:{},saveUserList:{}}}},{key:"getElementState",value:function e(){return{templateId:0,templateType:"message",id:0,chatId:0,authorId:0,date:new Date,text:"",textConverted:"",params:{TYPE:"default",COMPONENT_ID:"bx-messenger-message"},push:false,unread:false,sending:false,error:false,retry:false,blink:false}}},{key:"getGetters",value:function e(){var t=this;return{getMutationType:function e(t){return function(e){if(!t.mutationType[e]){return{initialType:a.MutationType.none,appliedType:a.MutationType.none}}return t.mutationType[e]}},getLastId:function e(t){return function(e){if(!t.collection[e]||t.collection[e].length<=0){return null}var i=0;for(var a=0;a<t.collection[e].length;a++){var n=t.collection[e][a];if(n.push||n.sending||n.id.toString().startsWith("temporary")){continue}if(i<n.id){i=n.id}}return i?i:null}},getMessage:function e(t){return function(e,i){if(!t.collection[e]||t.collection[e].length<=0){return null}for(var a=t.collection[e].length-1;a>=0;a--){if(t.collection[e][a].id===i){return t.collection[e][a]}}return null}},get:function e(t){return function(e){if(!t.collection[e]||t.collection[e].length<=0){return[]}return t.collection[e]}},getBlank:function e(i){return function(e){return t.getElementState()}},getSaveFileList:function e(t){return function(e){return t.saveFileList}},getSaveUserList:function e(t){return function(e){return t.saveUserList}}}}},{key:"getActions",value:function e(){var i=this;return{add:function e(t,a){var n=i.validate(Object.assign({},a));n.params=Object.assign({},i.getElementState().params,n.params);n.id="temporary"+(new Date).getTime()+t.state.created;n.templateId=n.id;n.unread=false;t.commit("add",Object.assign({},i.getElementState(),n));if(a.sending!==false){t.dispatch("actionStart",{id:n.id,chatId:n.chatId})}return n.id},actionStart:function e(i,a){if(/^\d+$/.test(a.id)){a.id=parseInt(a.id)}a.chatId=parseInt(a.chatId);t.Vue.nextTick(function(){i.commit("update",{id:a.id,chatId:a.chatId,fields:{sending:true}})})},actionError:function e(i,a){if(/^\d+$/.test(a.id)){a.id=parseInt(a.id)}a.chatId=parseInt(a.chatId);t.Vue.nextTick(function(){i.commit("update",{id:a.id,chatId:a.chatId,fields:{sending:false,error:true,retry:a.retry!==false}})})},actionFinish:function e(i,a){if(/^\d+$/.test(a.id)){a.id=parseInt(a.id)}a.chatId=parseInt(a.chatId);t.Vue.nextTick(function(){i.commit("update",{id:a.id,chatId:a.chatId,fields:{sending:false,error:false,retry:false}})})},set:function e(t,n){if(n instanceof Array){n=n.map(function(e){return i.prepareMessage(e)})}else{var r=i.prepareMessage(n);(n=[]).push(r)}t.commit("set",{insertType:a.MutationType.set,data:n})},setAfter:function e(t,n){if(n instanceof Array){n=n.map(function(e){return i.prepareMessage(e)})}else{var r=i.prepareMessage(n);(n=[]).push(r)}t.commit("set",{insertType:a.MutationType.setAfter,data:n})},setBefore:function e(t,n){if(n instanceof Array){n=n.map(function(e){return i.prepareMessage(e)})}else{var r=i.prepareMessage(n);(n=[]).push(r)}t.commit("set",{insertType:a.MutationType.setBefore,data:n})},update:function e(t,a){if(/^\d+$/.test(a.id)){a.id=parseInt(a.id)}if(/^\d+$/.test(a.chatId)){a.chatId=parseInt(a.chatId)}t.commit("initCollection",{chatId:a.chatId});var n=t.state.collection[a.chatId].findIndex(function(e){return e.id===a.id});if(n<0){return false}var r=i.validate(Object.assign({},a.fields));if(r.params){r.params=Object.assign({},i.getElementState().params,t.state.collection[a.chatId][n].params,r.params)}t.commit("update",{id:a.id,chatId:a.chatId,index:n,fields:r});if(a.fields.blink){setTimeout(function(){t.commit("update",{id:a.id,chatId:a.chatId,fields:{blink:false}})},1e3)}return true},delete:function e(t,i){if(!(i.id instanceof Array)){i.id=[i.id]}i.id=i.id.map(function(e){if(/^\d+$/.test(e)){e=parseInt(e)}return e});t.commit("delete",{chatId:i.chatId,elements:i.id});return true},clear:function e(t,i){i.chatId=parseInt(i.chatId);t.commit("clear",{chatId:i.chatId});return true},applyMutationType:function e(t,i){i.chatId=parseInt(i.chatId);t.commit("applyMutationType",{chatId:i.chatId});return true},readMessages:function e(t,i){i.readId=parseInt(i.readId)||0;i.chatId=parseInt(i.chatId);if(typeof t.state.collection[i.chatId]==="undefined"){return{count:0}}var a=0;for(var n=t.state.collection[i.chatId].length-1;n>=0;n--){var r=t.state.collection[i.chatId][n];if(!r.unread)continue;if(i.readId===0||r.id<=i.readId){a++}}t.commit("readMessages",{chatId:i.chatId,readId:i.readId});return{count:a}},unreadMessages:function e(t,i){i.unreadId=parseInt(i.unreadId)||0;i.chatId=parseInt(i.chatId);if(typeof t.state.collection[i.chatId]==="undefined"||!i.unreadId){return{count:0}}var a=0;for(var n=t.state.collection[i.chatId].length-1;n>=0;n--){var r=t.state.collection[i.chatId][n];if(r.unread)continue;if(r.id>=i.unreadId){a++}}t.commit("unreadMessages",{chatId:i.chatId,unreadId:i.unreadId});return{count:a}}}}},{key:"getMutations",value:function e(){var i=this;return{initCollection:function e(t,a){return i.initCollection(t,a)},add:function e(t,n){i.initCollection(t,{chatId:n.chatId});i.setMutationType(t,{chatId:n.chatId,initialType:a.MutationType.add});t.collection[n.chatId].push(n);t.saveMessageList[n.chatId].push(n.id);t.created+=1;i.saveState(t,n.chatId)},set:function e(t,n){var r=[];var s=[];var l={};l.initialType=n.insertType;if(n.insertType===a.MutationType.set){(function(){n.insertType=a.MutationType.setAfter;var e={};n.data.forEach(function(t){if(!e[t.chatId]){e[t.chatId]=[]}e[t.chatId].push(t.id)});var r=function r(s){if(!e.hasOwnProperty(s))return"continue";i.initCollection(t,{chatId:s});if(t.saveMessageList[s].length>e[s].length||e[s].length<a.StorageLimit.messages){t.collection[s]=t.collection[s].filter(function(t){return e[s].includes(t.id)});t.saveMessageList[s]=t.saveMessageList[s].filter(function(t){return e[s].includes(t)})}var d=i.manageCacheBeforeSet(babelHelpers.toConsumableArray(t.saveMessageList[s].reverse()),e[s]);if(d.type===o.none){if(d.foundElements.length>0){t.collection[s]=t.collection[s].filter(function(e){return!d.foundElements.includes(e.id)});t.saveMessageList[s]=t.saveMessageList[s].filter(function(e){return!d.foundElements.includes(e)})}i.removeIntersectionCacheElements=t.collection[s].map(function(e){return e.id});clearTimeout(i.removeIntersectionCacheTimeout);i.removeIntersectionCacheTimeout=setTimeout(function(){t.collection[s]=t.collection[s].filter(function(e){return!i.removeIntersectionCacheElements.includes(e.id)});t.saveMessageList[s]=t.saveMessageList[s].filter(function(e){return!i.removeIntersectionCacheElements.includes(e)});i.removeIntersectionCacheElements=[]},1e3)}else{if(d.type===o.foundReverse){n.insertType=a.MutationType.setBefore;n.data=n.data.reverse()}}if(d.foundElements.length>0){if(d.type===o.found&&d.noneElements[0]){l.scrollStickToTop=false;l.scrollMessageId=d.foundElements[d.foundElements.length-1]}else{l.scrollStickToTop=false;l.scrollMessageId=0}}else if(d.type===o.none){l.scrollStickToTop=false;l.scrollMessageId=n.data[0].id}};for(var s in e){var d=r(s);if(d==="continue")continue}})()}l.appliedType=n.insertType;var d=true;var c=false;var u=undefined;try{var f=function e(){var o=g.value;i.initCollection(t,{chatId:o.chatId});var l=t.collection[o.chatId].findIndex(function(e){return e.id===o.id});if(l>-1){delete o.templateId;t.collection[o.chatId][l]=Object.assign(t.collection[o.chatId][l],o)}else if(n.insertType===a.MutationType.setBefore){t.collection[o.chatId].unshift(o)}else if(n.insertType===a.MutationType.setAfter){t.collection[o.chatId].push(o)}r.push(o.chatId);if(i.store.getters["dialogues/canSaveChat"]&&i.store.getters["dialogues/canSaveChat"](o.chatId)){s.push(o.chatId)}};for(var p=n.data[Symbol.iterator](),g;!(d=(g=p.next()).done);d=true){f()}}catch(e){c=true;u=e}finally{try{if(!d&&p.return!=null){p.return()}}finally{if(c){throw u}}}r=babelHelpers.toConsumableArray(new Set(r));s=babelHelpers.toConsumableArray(new Set(s));if(l.initialType===a.MutationType.set){r.forEach(function(e){var i=0;var a=false;for(var n=0;n<t.collection[e].length;n++){var r=t.collection[e][n];if(r.id<i){a=true;break}i=r.id}if(a){t.collection[e].sort(function(e,t){return e.id-t.id})}})}r.forEach(function(e){i.setMutationType(t,babelHelpers.objectSpread({chatId:e},l))});if(l.initialType!==a.MutationType.setBefore){s.forEach(function(e){i.saveState(t,e)})}},update:function e(t,a){i.initCollection(t,{chatId:a.chatId});var n=-1;if(typeof a.index!=="undefined"&&t.collection[a.chatId][a.index]){n=a.index}else{n=t.collection[a.chatId].findIndex(function(e){return e.id===a.id})}if(n>=0){var r=t.saveMessageList[a.chatId].includes(t.collection[a.chatId][n].id)||a.fields.id&&!a.fields.id.toString().startsWith("temporary")&&t.collection[a.chatId][n].id.toString().startsWith("temporary");delete a.fields.templateId;t.collection[a.chatId][n]=Object.assign(t.collection[a.chatId][n],a.fields);if(r){i.saveState(t,a.chatId)}}},delete:function e(t,n){i.initCollection(t,{chatId:n.chatId});i.setMutationType(t,{chatId:n.chatId,initialType:a.MutationType.delete});t.collection[n.chatId]=t.collection[n.chatId].filter(function(e){return!n.elements.includes(e.id)});if(t.saveMessageList[n.chatId].length>0){var r=true;var o=false;var s=undefined;try{for(var l=n.elements[Symbol.iterator](),d;!(r=(d=l.next()).done);r=true){var c=d.value;if(t.saveMessageList[n.chatId].includes(c)){i.saveState(t,n.chatId);break}}}catch(e){o=true;s=e}finally{try{if(!r&&l.return!=null){l.return()}}finally{if(o){throw s}}}}},clear:function e(t,a){i.initCollection(t,{chatId:a.chatId});i.setMutationType(t,{chatId:a.chatId,initialType:"clear"});t.collection[a.chatId]=[];t.saveMessageList[a.chatId]=[]},applyMutationType:function e(i,n){if(typeof i.mutationType[n.chatId]==="undefined"){t.Vue.set(i.mutationType,n.chatId,{applied:false,initialType:a.MutationType.none,appliedType:a.MutationType.none,scrollStickToTop:0,scrollMessageId:0})}i.mutationType[n.chatId].applied=true},readMessages:function e(t,a){i.initCollection(t,{chatId:a.chatId});var n=false;for(var r=t.collection[a.chatId].length-1;r>=0;r--){var o=t.collection[a.chatId][r];if(!o.unread)continue;if(a.readId===0||o.id<=a.readId){t.collection[a.chatId][r]=Object.assign(t.collection[a.chatId][r],{unread:false});n=true}}if(n){i.saveState(t,a.chatId)}},unreadMessages:function e(t,a){i.initCollection(t,{chatId:a.chatId});var n=false;for(var r=t.collection[a.chatId].length-1;r>=0;r--){var o=t.collection[a.chatId][r];if(o.unread)continue;if(o.id>=a.unreadId){t.collection[a.chatId][r]=Object.assign(t.collection[a.chatId][r],{unread:true});n=true}}if(n){i.saveState(t,a.chatId);i.updateSubordinateStates()}}}}},{key:"initCollection",value:function e(i,n){if(typeof n.chatId==="undefined"){return false}if(typeof n.chatId==="undefined"||typeof i.collection[n.chatId]!=="undefined"){return true}t.Vue.set(i.collection,n.chatId,n.messages?[].concat(n.messages):[]);t.Vue.set(i.mutationType,n.chatId,{applied:false,initialType:a.MutationType.none,appliedType:a.MutationType.none,scrollStickToTop:0,scrollMessageId:0});t.Vue.set(i.saveMessageList,n.chatId,[]);t.Vue.set(i.saveFileList,n.chatId,[]);t.Vue.set(i.saveUserList,n.chatId,[]);return true}},{key:"setMutationType",value:function e(i,n){var r={applied:false,initialType:a.MutationType.none,appliedType:a.MutationType.none,scrollStickToTop:false,scrollMessageId:0};if(n.initialType&&!n.appliedType){n.appliedType=n.initialType}if(typeof i.mutationType[n.chatId]==="undefined"){t.Vue.set(i.mutationType,n.chatId,r)}i.mutationType[n.chatId]=babelHelpers.objectSpread({},r,n);return true}},{key:"prepareMessage",value:function e(t){var i=this.validate(Object.assign({},t));i.params=Object.assign({},this.getElementState().params,i.params);i.templateId=i.id;return Object.assign({},this.getElementState(),i)}},{key:"manageCacheBeforeSet",value:function e(t,i){var a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var n={type:o.empty,foundElements:[],noneElements:[]};if(!t||t.length<=0){return n}var r=true;var s=false;var l=undefined;try{for(var d=i[Symbol.iterator](),c;!(r=(c=d.next()).done);r=true){var u=c.value;if(t.includes(u)){if(n.type===o.empty){n.type=o.found}n.foundElements.push(u)}else{if(n.type===o.empty){n.type=o.none}n.noneElements.push(u)}}}catch(e){s=true;l=e}finally{try{if(!r&&d.return!=null){d.return()}}finally{if(s){throw l}}}if(n.type===o.found&&t.length===i.length&&n.foundElements.length===i.length){n.type=o.equal}else if(n.type===o.none&&!a&&n.foundElements.length>0){var f=this.manageCacheBeforeSet(t.reverse(),i.reverse(),true);if(f.type===o.found){f.type=o.foundReverse;return f}}return n}},{key:"updateSaveLists",value:function e(t,i){if(!this.isSaveAvailable()){return true}if(!i||!this.store.getters["dialogues/canSaveChat"]||!this.store.getters["dialogues/canSaveChat"](i)){return false}this.initCollection(t,{chatId:i});var n=0;var r=[];var o=[];var s=[];var l=this.store.getters["dialogues/getByChatId"](i);if(l&&l.type==="private"){s.push(parseInt(l.dialogId))}for(var d=t.collection[i].length-1;d>=0;d--){if(t.collection[i][d].id.toString().startsWith("temporary")){continue}if(n>=a.StorageLimit.messages&&!t.collection[i][d].unread){break}r.unshift(t.collection[i][d].id);n++}r=r.slice(0,a.StorageLimit.messages);t.collection[i].filter(function(e){return r.includes(e.id)}).forEach(function(e){if(e.authorId>0){s.push(e.authorId)}if(e.params.FILE_ID instanceof Array){o=e.params.FILE_ID.concat(o)}});t.saveMessageList[i]=r;t.saveFileList[i]=babelHelpers.toConsumableArray(new Set(o));t.saveUserList[i]=babelHelpers.toConsumableArray(new Set(s));return true}},{key:"getSaveTimeout",value:function e(){return 150}},{key:"saveState",value:function e(t,a){if(!this.updateSaveLists(t,a)){return false}babelHelpers.get(babelHelpers.getPrototypeOf(i.prototype),"saveState",this).call(this,function(){var e={collection:{},saveMessageList:{},saveUserList:{},saveFileList:{}};var i=function i(a){if(!t.saveMessageList.hasOwnProperty(a)){return"continue"}if(!t.collection[a]){return"continue"}if(!e.collection[a]){e.collection[a]=[]}t.collection[a].filter(function(e){return t.saveMessageList[a].includes(e.id)}).forEach(function(t){return e.collection[a].push(t)});e.saveMessageList[a]=t.saveMessageList[a];e.saveFileList[a]=t.saveFileList[a];e.saveUserList[a]=t.saveUserList[a]};for(var a in t.saveMessageList){var n=i(a);if(n==="continue")continue}return e})}},{key:"updateSubordinateStates",value:function e(){this.store.dispatch("users/saveState");this.store.dispatch("files/saveState")}},{key:"validate",value:function e(t){var i={};if(typeof t.id==="number"){i.id=t.id}else if(typeof t.id==="string"){if(t.id.startsWith("temporary")){i.id=t.id}else{i.id=parseInt(t.id)}}if(typeof t.templateId==="number"){i.templateId=t.templateId}else if(typeof t.templateId==="string"){if(t.templateId.startsWith("temporary")){i.templateId=t.templateId}else{i.templateId=parseInt(t.templateId)}}if(typeof t.chat_id!=="undefined"){t.chatId=t.chat_id}if(typeof t.chatId==="number"||typeof t.chatId==="string"){i.chatId=parseInt(t.chatId)}if(typeof t.date!=="undefined"){i.date=n.Utils.date.cast(t.date)}if(typeof t.textOriginal==="string"||typeof t.textOriginal==="number"){i.text=t.textOriginal.toString();if(typeof t.text==="string"||typeof t.text==="number"){i.textConverted=this.convertToHtml({text:t.text.toString(),isConverted:true})}}else{if(typeof t.text_converted!=="undefined"){t.textConverted=t.text_converted}if(typeof t.textConverted==="string"||typeof t.textConverted==="number"){i.textConverted=t.textConverted.toString()}if(typeof t.text==="string"||typeof t.text==="number"){i.text=t.text.toString();var a=typeof i.textConverted!=="undefined";i.textConverted=this.convertToHtml({text:a?i.textConverted:i.text,isConverted:a})}}if(typeof t.senderId!=="undefined"){t.authorId=t.senderId}else if(typeof t.author_id!=="undefined"){t.authorId=t.author_id}if(typeof t.authorId==="number"||typeof t.authorId==="string"){if(t.system===true||t.system==="Y"){i.authorId=0}else{i.authorId=parseInt(t.authorId)}}if(babelHelpers.typeof(t.params)==="object"&&t.params!==null){var r=this.validateParams(t.params);if(r){i.params=r}}if(typeof t.push==="boolean"){i.push=t.push}if(typeof t.sending==="boolean"){i.sending=t.sending}if(typeof t.unread==="boolean"){i.unread=t.unread}if(typeof t.blink==="boolean"){i.blink=t.blink}if(typeof t.error==="boolean"||typeof t.error==="string"){i.error=t.error}if(typeof t.retry==="boolean"){i.retry=t.retry}return i}},{key:"validateParams",value:function e(t){var i={};try{for(var a in t){if(!t.hasOwnProperty(a)){continue}if(a==="COMPONENT_ID"){if(typeof t[a]==="string"&&BX.Vue.isComponent(t[a])){i[a]=t[a]}}else if(a==="LIKE"){if(t[a]instanceof Array){i["REACTION"]={like:t[a].map(function(e){return parseInt(e)})}}}else if(a==="CHAT_LAST_DATE"){i[a]=n.Utils.date.cast(t[a])}else{i[a]=t[a]}}}catch(e){}var r=false;for(var o in i){if(!i.hasOwnProperty(o)){continue}r=true;break}return r?i:null}},{key:"convertToHtml",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=t.quote,a=i===void 0?true:i,n=t.image,r=n===void 0?true:n,o=t.text,s=o===void 0?"":o,l=t.highlightText,d=l===void 0?"":l,c=t.isConverted,u=c===void 0?false:c,f=t.enableBigSmile,p=f===void 0?true:f;s=s.trim();if(!u){s=s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}if(s.startsWith("/me")){s="<i>".concat(s.substr(4),"</i>")}else if(s.startsWith("/loud")){s="<b>".concat(s.substr(6),"</b>")}var g="&gt;&gt;";if(a&&s.indexOf(g)>=0){var h=s.split(u?"<br />":"\n");for(var m=0;m<h.length;m++){if(h[m].startsWith(g)){h[m]=h[m].replace(g,'<div class="bx-im-message-content-quote"><div class="bx-im-message-content-quote-wrap">');while(++m<h.length&&h[m].startsWith(g)){h[m]=h[m].replace(g,"")}h[m-1]+="</div></div><br>"}}s=h.join("<br />")}s=s.replace(/\n/gi,"<br />");s=s.replace(/\t/gi,"&nbsp;&nbsp;&nbsp;&nbsp;");s=this.decodeBbCode(s,false,p);if(a){s=s.replace(/------------------------------------------------------<br \/>(.*?)\[(.*?)\]<br \/>(.*?)------------------------------------------------------(<br \/>)?/g,function(e,t,i,a,n,r){return(r>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>"+a+"</div></div><br />"});s=s.replace(/------------------------------------------------------<br \/>(.*?)------------------------------------------------------(<br \/>)?/g,function(e,t,i,a,n){return(n>0?"<br>":"")+'<div class="bx-im-message-content-quote"><div class="bx-im-message-content-quote-wrap">'+t+"</div></div><br />"})}if(r){var v=false;s=s.replace(/<a(.*?)>(http[s]{0,1}:\/\/.*?)<\/a>/gi,function(e,t,i,a){if(!i.match(/(\.(jpg|jpeg|png|gif)\?|\.(jpg|jpeg|png|gif)$)/i)||i.indexOf("/docs/pub/")>0||i.indexOf("logout=yes")>0){return e}else{v=true;return(a>0?"<br />":"")+"<a"+t+' target="_blank" class="bx-im-element-file-image"><img src="'+i+'" class="bx-im-element-file-image-source-text" onerror="BX.Messenger.Model.MessagesModel.hideErrorImage(this)"></a></span>'}});if(v){s=s.replace(/<\/span>(\n?)<br(\s\/?)>/gi,"</span>").replace(/<br(\s\/?)>(\n?)<br(\s\/?)>(\n?)<span/gi,"<br /><span")}}if(d){s=s.replace(new RegExp("("+d.replace(/[\-\[\]\/{}()*+?.\\^$|]/g,"\\$&")+")","ig"),'<span class="bx-messenger-highlight">$1</span>')}if(p){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,a,n,r,o){return i+parseInt(a,10)*1.7+n+parseInt(r,10)*1.7+o})}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}},{key:"decodeBbCode",value:function e(t){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return i.decodeBbCode({text:t,textOnly:a,enableBigSmile:n})}}],[{key:"decodeBbCode",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=t.text,a=t.textOnly,r=a===void 0?false:a,o=t.enableBigSmile,s=o===void 0?true:o;var l=[];i=i.replace(/\[CODE\]\n?([\s\S]*?)\[\/CODE\]/gi,function(e,t){var i=l.length;l.push(t);return"####REPLACEMENT_MARK_"+i+"####"});i=i.replace(/\[LIKE\]/gi,'<span class="bx-smile bx-im-smile-like"></span>');i=i.replace(/\[DISLIKE\]/gi,'<span class="bx-smile bx-im-smile-dislike"></span>');i=i.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,function(e,t,i){return'<span class="bx-im-mention" data-type="USER" data-value="'+t+'">'+i+"</span>"});i=i.replace(/\[CHAT=(imol\|)?([0-9]{1,})\](.*?)\[\/CHAT\]/gi,function(e,t,i,a){return t?a:'<span class="bx-im-mention" data-type="CHAT" data-value="chat'+i+'">'+a+"</span>"});i=i.replace(/\[CALL(?:=(.+?))?\](.+?)?\[\/CALL\]/gi,function(e,t,i){return'<span class="bx-im-mention" data-type="CALL" data-value="'+n.Utils.text.htmlspecialchars(t)+'">'+i+"</span>"});i=i.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,function(e,t,i){return i});i=i.replace(/\[SEND(?:=(.+?))?\](.+?)?\[\/SEND\]/gi,function(e,t,i){var a="";i=i?i:t;t=(t?t:i).replace("<br />","\n");if(!r&&i){i=i.replace(/<([\w]+)[^>]*>(.*?)<\\1>/i,"$2",i);i=i.replace(/\[([\w]+)[^\]]*\](.*?)\[\/\1\]/i,"$2",i);a='<span class="bx-im-message-command-wrap">'+'<span class="bx-im-message-command" data-entity="send">'+i+"</span>"+'<span class="bx-im-message-command-data">'+t+"</span>"+"</span>"}else{a=i}return a});i=i.replace(/\[PUT(?:=(.+?))?\](.+?)?\[\/PUT\]/gi,function(e,t,i){var a="";i=i?i:t;t=(t?t:i).replace("<br />","\n");if(!r&&i){i=i.replace(/<([\w]+)[^>]*>(.*?)<\/\1>/i,"$2",i);i=i.replace(/\[([\w]+)[^\]]*\](.*?)\[\/\1\]/i,"$2",i);a='<span class="bx-im-message-command" data-entity="put">'+i+"</span>";a+='<span class="bx-im-message-command-data">'+t+"</span>"}else{a=i}return a});var d=0;if(s){d=i.replace(/\[icon\=([^\]]*)\]/gi,"").trim().length}i=i.replace(/\[icon\=([^\]]*)\]/gi,function(e){var t=e.match(/icon\=(\S+[^\s.,> )\];\'\"!?])/i);if(t&&t[1]){t=t[1]}else{return""}var i={src:t,border:0};var a=e.match(/size\=(\d+)/i);if(a&&a[1]){i["width"]=a[1];i["height"]=a[1]}else{var r=e.match(/width\=(\d+)/i);if(r&&r[1]){i["width"]=r[1]}var o=e.match(/height\=(\d+)/i);if(o&&o[1]){i["height"]=o[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&&d===0&&i["width"]===i["height"]&&i["width"]===20){i["width"]=40;i["height"]=40}var l=e.match(/title\=(.*[^\s\]])/i);if(l&&l[1]){l=l[1];if(l.indexOf("width=")>-1){l=l.substr(0,l.indexOf("width="))}if(l.indexOf("height=")>-1){l=l.substr(0,l.indexOf("height="))}if(l.indexOf("size=")>-1){l=l.substr(0,l.indexOf("size="))}if(l){i["title"]=n.Utils.text.htmlspecialchars(l).trim();i["alt"]=i["title"]}}var c="";for(var u in i){if(i.hasOwnProperty(u)){c+=u+'="'+i[u]+'" '}}return'<img class="bx-smile bx-icon" '+c+">"});l.forEach(function(e,t){i=i.replace("####REPLACEMENT_MARK_"+t+"####",!r?'<div class="bx-im-message-content-code">'+e+"</div>":e)});return i}},{key:"hideErrorImage",value:function e(t){if(t.parentNode&&t.parentNode){t.parentNode.innerHTML='<a href="'+t.src+'" target="_blank">'+t.src+"</a>"}return true}}]);return i}(i.VuexBuilderModel);var l=function(e){babelHelpers.inherits(i,e);function i(){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).apply(this,arguments))}babelHelpers.createClass(i,[{key:"getName",value:function e(){return"dialogues"}},{key:"getState",value:function e(){return{host:this.getVariable("host",location.protocol+"//"+location.host),collection:{},saveDialogList:[],saveChatList:[]}}},{key:"getStateSaveException",value:function e(){return{host:null}}},{key:"getElementStateSaveException",value:function e(){return{writingList:null,quoteId:null}}},{key:"getElementState",value:function e(){return{dialogId:"0",chatId:0,counter:0,unreadId:0,unreadLastId:0,managerList:[],readedList:[],writingList:[],textareaMessage:"",quoteId:0,init:false,name:"",owner:0,extranet:false,avatar:"",color:"#17A3EA",type:"chat",entityType:"",entityId:"",entityData1:"",entityData2:"",entityData3:"",dateCreate:new Date}}},{key:"getGetters",value:function e(){var t=this;return{get:function e(t){return function(e){if(!t.collection[e]){return null}return t.collection[e]}},getByChatId:function e(t){return function(e){e=parseInt(e);for(var i in t.collection){if(!t.collection.hasOwnProperty(i)){continue}if(t.collection[i].chatId===e){return t.collection[i]}}return null}},getBlank:function e(i){return function(e){return t.getElementState()}},getQuoteId:function e(t){return function(e){if(!t.collection[e]){return 0}return t.collection[e].quoteId}},canSaveChat:function e(t){return function(e){if(/^\d+$/.test(e)){e=parseInt(e)}return t.saveChatList.includes(parseInt(e))}},canSaveDialog:function e(t){return function(e){return t.saveDialogList.includes(e.toString())}},isPrivateDialog:function e(t){return function(e){e=e.toString();return t.collection[e.toString()]&&t.collection[e].type==="private"}}}}},{key:"getActions",value:function e(){var t=this;return{set:function e(i,a){if(a instanceof Array){a=a.map(function(e){return Object.assign({},t.validate(Object.assign({},e),{host:i.state.host}),{init:true})})}else{var n=[];n.push(Object.assign({},t.validate(Object.assign({},a),{host:i.state.host}),{init:true}));a=n}i.commit("set",a)},update:function e(i,a){if(typeof i.state.collection[a.dialogId]==="undefined"||i.state.collection[a.dialogId].init===false){return true}i.commit("update",{dialogId:a.dialogId,fields:t.validate(Object.assign({},a.fields),{host:i.state.host})});return true},delete:function e(t,i){t.commit("delete",i.dialogId);return true},updateWriting:function e(i,a){if(typeof i.state.collection[a.dialogId]==="undefined"||i.state.collection[a.dialogId].init===false){return true}var n=i.state.collection[a.dialogId].writingList.findIndex(function(e){return e.userId===a.userId});if(a.action){if(n>=0){return true}else{var r=[].concat(i.state.collection[a.dialogId].writingList);r.unshift({userId:a.userId,userName:a.userName});i.commit("update",{actionName:"updateWriting/1",dialogId:a.dialogId,fields:t.validate({writingList:r},{host:i.state.host})})}}else{if(n>=0){var o=i.state.collection[a.dialogId].writingList.filter(function(e){return e.userId!==a.userId});i.commit("update",{actionName:"updateWriting/2",dialogId:a.dialogId,fields:t.validate({writingList:o},{host:i.state.host})});return true}else{return true}}return false},updateReaded:function e(i,a){if(typeof i.state.collection[a.dialogId]==="undefined"||i.state.collection[a.dialogId].init===false){return true}var n=i.state.collection[a.dialogId].readedList.filter(function(e){return e.userId!==a.userId});if(a.action){n.push({userId:a.userId,userName:a.userName||"",messageId:a.messageId,date:a.date||new Date})}i.commit("update",{actionName:"updateReaded",dialogId:a.dialogId,fields:t.validate({readedList:n},{host:i.state.host})});return false},increaseCounter:function e(t,i){if(typeof t.state.collection[i.dialogId]==="undefined"||t.state.collection[i.dialogId].init===false){return true}var a=t.state.collection[i.dialogId].counter;if(a===100){return true}var n=a+i.count;if(n>100){n=100}var r={counter:n};if(typeof i.unreadLastId!=="undefined"){r.unreadLastId=i.unreadLastId}t.commit("update",{actionName:"increaseCounter",dialogId:i.dialogId,fields:r});return false},decreaseCounter:function e(t,i){if(typeof t.state.collection[i.dialogId]==="undefined"||t.state.collection[i.dialogId].init===false){return true}var a=t.state.collection[i.dialogId].counter;if(a===100){return true}var n=a-i.count;if(n<0){n=0}var r=i.unreadId>t.state.collection[i.dialogId].unreadId?i.unreadId:t.state.collection[i.dialogId].unreadId;if(t.state.collection[i.dialogId].unreadId!==r||t.state.collection[i.dialogId].counter!==n){if(n===0){r=0}t.commit("update",{actionName:"decreaseCounter",dialogId:i.dialogId,fields:{counter:n,unreadId:r}})}return false},saveDialog:function e(t,i){if(typeof t.state.collection[i.dialogId]==="undefined"||t.state.collection[i.dialogId].init===false){return true}t.commit("saveDialog",{dialogId:i.dialogId,chatId:i.chatId});return false}}}},{key:"getMutations",value:function e(){var t=this;return{initCollection:function e(i,a){t.initCollection(i,a)},saveDialog:function e(i,n){if(!(n.chatId>0&&n.dialogId.length>0)){return false}var r=i.saveDialogList.filter(function(e){return e!==n.dialogId});r.unshift(n.dialogId);r=r.slice(0,a.StorageLimit.dialogues);if(i.saveDialogList.join(",")===r.join(",")){return true}i.saveDialogList=r;var o=i.saveChatList.filter(function(e){return e!==n.chatId});o.unshift(n.chatId);i.saveChatList=o.slice(0,a.StorageLimit.dialogues);t.saveState(i)},set:function e(i,a){var n=true;var r=false;var o=undefined;try{for(var s=a[Symbol.iterator](),l;!(n=(l=s.next()).done);n=true){var d=l.value;t.initCollection(i,{dialogId:d.dialogId});i.collection[d.dialogId]=Object.assign(t.getElementState(),i.collection[d.dialogId],d)}}catch(e){r=true;o=e}finally{try{if(!n&&s.return!=null){s.return()}}finally{if(r){throw o}}}t.saveState(i)},update:function e(i,a){t.initCollection(i,a);i.collection[a.dialogId]=Object.assign(i.collection[a.dialogId],a.fields);t.saveState(i)},delete:function e(i,a){delete i.collection[a.dialogId];t.saveState(i)}}}},{key:"initCollection",value:function e(i,a){if(typeof i.collection[a.dialogId]!=="undefined"){return true}t.Vue.set(i.collection,a.dialogId,this.getElementState());if(a.fields){i.collection[a.dialogId]=Object.assign(i.collection[a.dialogId],this.validate(Object.assign({},a.fields),{host:i.host}))}return true}},{key:"getSaveTimeout",value:function e(){return 100}},{key:"saveState",value:function e(){var t=this;var a=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(!this.isSaveAvailable()){return true}babelHelpers.get(babelHelpers.getPrototypeOf(i.prototype),"saveState",this).call(this,function(){var e={collection:{},saveDialogList:[].concat(a.saveDialogList),saveChatList:[].concat(a.saveChatList)};a.saveDialogList.forEach(function(i){if(!a.collection[i])return false;e.collection[i]=Object.assign(t.getElementState(),t.cloneState(a.collection[i],t.getElementStateSaveException()))});return e})}},{key:"validate",value:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var a={};i.host=i.host||this.getState().host;if(typeof t.dialog_id!=="undefined"){t.dialogId=t.dialog_id}if(typeof t.dialogId==="number"||typeof t.dialogId==="string"){a.dialogId=t.dialogId.toString()}if(typeof t.chat_id!=="undefined"){t.chatId=t.chat_id}else if(typeof t.id!=="undefined"){t.chatId=t.id}if(typeof t.chatId==="number"||typeof t.chatId==="string"){a.chatId=parseInt(t.chatId)}if(typeof t.quoteId==="number"){a.quoteId=parseInt(t.quoteId)}if(typeof t.counter==="number"||typeof t.counter==="string"){a.counter=parseInt(t.counter)}if(typeof t.unread_id!=="undefined"){t.unreadId=t.unread_id}if(typeof t.unreadId==="number"||typeof t.unreadId==="string"){a.unreadId=parseInt(t.unreadId)}if(typeof t.unread_last_id!=="undefined"){t.unreadLastId=t.unread_last_id}if(typeof t.unreadLastId==="number"||typeof t.unreadLastId==="string"){a.unreadLastId=parseInt(t.unreadLastId)}if(typeof t.readed_list!=="undefined"){t.readedList=t.readed_list}if(typeof t.readedList!=="undefined"){a.readedList=[];if(t.readedList instanceof Array){t.readedList.forEach(function(e){var t={};if(typeof e.user_id!=="undefined"){e.userId=e.user_id}if(typeof e.user_name!=="undefined"){e.userName=e.user_name}if(typeof e.message_id!=="undefined"){e.messageId=e.message_id}if(!e.userId||!e.userName||!e.messageId){return false}t.userId=parseInt(e.userId);t.userName=e.userName.toString();t.messageId=parseInt(e.messageId);t.date=n.Utils.date.cast(e.date);a.readedList.push(t)})}}if(typeof t.writing_list!=="undefined"){t.writingList=t.writing_list}if(typeof t.writingList!=="undefined"){a.writingList=[];if(t.writingList instanceof Array){t.writingList.forEach(function(e){var t={};if(!e.userId){return false}t.userId=parseInt(e.userId);t.userName=e.userName;a.writingList.push(t)})}}if(typeof t.manager_list!=="undefined"){t.managerList=t.manager_list}if(typeof t.managerList!=="undefined"){a.managerList=[];if(t.managerList instanceof Array){t.managerList.forEach(function(e){e=parseInt(e);if(e>0){a.managerList.push(e)}})}}if(typeof t.mute_list!=="undefined"){t.muteList=t.mute_list}if(typeof t.muteList!=="undefined"){a.muteList=[];if(t.muteList instanceof Array){t.muteList.forEach(function(e){e=parseInt(e);if(e>0){a.muteList.push(e)}})}}if(typeof t.textareaMessage!=="undefined"){a.textareaMessage=t.textareaMessage.toString()}if(typeof t.title!=="undefined"){t.name=t.title}if(typeof t.name==="string"||typeof t.name==="number"){a.name=t.name.toString()}if(typeof t.owner!=="undefined"){t.ownerId=t.owner}if(typeof t.ownerId==="number"||typeof t.ownerId==="string"){a.ownerId=parseInt(t.ownerId)}if(typeof t.extranet==="boolean"){a.extranet=t.extranet}if(typeof t.avatar==="string"){var r;if(!t.avatar||t.avatar.endsWith("/js/im/images/blank.gif")){r=""}else if(t.avatar.startsWith("http")){r=t.avatar}else{r=i.host+t.avatar}if(r){a.avatar=encodeURI(r)}}if(typeof t.color==="string"){a.color=t.color.toString()}if(typeof t.type==="string"){a.type=t.type.toString()}if(typeof t.entity_type!=="undefined"){t.entityType=t.entity_type}if(typeof t.entityType==="string"){a.entityType=t.entityType.toString()}if(typeof t.entity_id!=="undefined"){t.entityId=t.entity_id}if(typeof t.entityId==="string"||typeof t.entityId==="number"){a.entityId=t.entityId.toString()}if(typeof t.entity_data_1!=="undefined"){t.entityData1=t.entity_data_1}if(typeof t.entityData1==="string"){a.entityData1=t.entityData1.toString()}if(typeof t.entity_data_2!=="undefined"){t.entityData2=t.entity_data_2}if(typeof t.entityData2==="string"){a.entityData2=t.entityData2.toString()}if(typeof t.entity_data_3!=="undefined"){t.entityData3=t.entity_data_3}if(typeof t.entityData3==="string"){a.entityData3=t.entityData3.toString()}if(typeof t.date_create!=="undefined"){t.dateCreate=t.date_create}if(typeof t.dateCreate!=="undefined"){a.dateCreate=n.Utils.date.cast(t.dateCreate)}if(typeof t.dateLastOpen!=="undefined"){a.dateLastOpen=n.Utils.date.cast(t.dateLastOpen)}return a}}]);return i}(i.VuexBuilderModel);var d=function(e){babelHelpers.inherits(i,e);function i(){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).apply(this,arguments))}babelHelpers.createClass(i,[{key:"getName",value:function e(){return"users"}},{key:"getState",value:function e(){return{host:this.getVariable("host",location.protocol+"//"+location.host),collection:{}}}},{key:"getElementState",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=t.id,a=i===void 0?0:i,n=t.name,r=n===void 0?this.getVariable("default.name",""):n,o=t.firstName,s=o===void 0?this.getVariable("default.name",""):o,l=t.lastName,d=l===void 0?"":l;return{id:a,name:r,firstName:s,lastName:d,workPosition:"",color:"#048bd0",avatar:"",gender:"M",birthday:false,extranet:false,network:false,bot:false,connector:false,externalAuthId:"default",status:"online",idle:false,lastActivityDate:false,mobileLastDate:false,absent:false,departments:[],phones:{workPhone:"",personalMobile:"",personalPhone:"",innerPhone:""},init:false}}},{key:"getGetters",value:function e(){var t=this;return{get:function e(i){return function(e){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;e=parseInt(e);if(e<=0){if(a){e=0}else{return null}}if(!a&&(!i.collection[e]||!i.collection[e].init)){return null}if(!i.collection[e]){return t.getElementState({id:e})}return i.collection[e]}},getBlank:function e(i){return function(e){return t.getElementState(e)}}}}},{key:"getActions",value:function e(){var t=this;return{set:function e(i,a){if(a instanceof Array){a=a.map(function(e){return Object.assign({},t.getElementState(),t.validate(Object.assign({},e),{host:i.state.host}),{init:true})})}else{var n=[];n.push(Object.assign({},t.getElementState(),t.validate(Object.assign({},a),{host:i.state.host}),{init:true}));a=n}i.commit("set",a)},update:function e(i,a){a.id=parseInt(a.id);if(typeof i.state.collection[a.id]==="undefined"||i.state.collection[a.id].init===false){return true}i.commit("update",{id:a.id,fields:t.validate(Object.assign({},a.fields),{host:i.state.host})});return true},delete:function e(t,i){t.commit("delete",i.id);return true},saveState:function e(t,i){t.commit("saveState",{});return true}}}},{key:"getMutations",value:function e(){var t=this;return{set:function e(i,a){var n=true;var r=false;var o=undefined;try{for(var s=a[Symbol.iterator](),l;!(n=(l=s.next()).done);n=true){var d=l.value;t.initCollection(i,{id:d.id});i.collection[d.id]=d;t.saveState(i)}}catch(e){r=true;o=e}finally{try{if(!n&&s.return!=null){s.return()}}finally{if(r){throw o}}}},update:function e(i,a){t.initCollection(i,a);i.collection[a.id]=Object.assign(i.collection[a.id],a.fields);t.saveState(i)},delete:function e(i,a){delete i.collection[a.id];t.saveState(i)},saveState:function e(i,a){t.saveState(i)}}}},{key:"initCollection",value:function e(i,a){if(typeof i.collection[a.id]!=="undefined"){return true}t.Vue.set(i.collection,a.id,this.getElementState());return true}},{key:"getSaveUserList",value:function e(){if(!this.db){return[]}if(!this.store.getters["messages/getSaveUserList"]){return[]}var t=this.store.getters["messages/getSaveUserList"]();if(!t){return[]}return t}},{key:"getSaveTimeout",value:function e(){return 250}},{key:"saveState",value:function e(t){var a=this;if(!this.isSaveAvailable()){return false}babelHelpers.get(babelHelpers.getPrototypeOf(i.prototype),"saveState",this).call(this,function(){var e=a.getSaveUserList();if(!e){return false}var i={collection:{}};var n={absent:true,idle:true,mobileLastDate:true,lastActivityDate:true};for(var r in e){if(!e.hasOwnProperty(r)){continue}e[r].forEach(function(e){if(!t.collection[e]){return false}i.collection[e]=a.cloneState(t.collection[e],n)})}return i})}},{key:"validate",value:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var a={};i.host=i.host||this.getState().host;if(typeof t.id==="number"||typeof t.id==="string"){a.id=parseInt(t.id)}if(typeof t.first_name!=="undefined"){t.firstName=t.first_name}if(typeof t.last_name!=="undefined"){t.lastName=t.last_name}if(typeof t.name==="string"||typeof t.name==="number"){a.name=t.name.toString();if(typeof t.firstName!=="undefined"&&!t.firstName){var r=t.name.split(" ");if(r.length>1){delete r[r.length-1];t.firstName=r.join(" ").trim()}else{t.firstName=a.name}}if(typeof t.lastName!=="undefined"&&!t.lastName){var o=t.name.split(" ");if(o.length>1){t.lastName=o[o.length-1]}else{t.lastName=""}}}if(typeof t.firstName==="string"||typeof t.name==="number"){a.firstName=t.firstName.toString()}if(typeof t.lastName==="string"||typeof t.name==="number"){a.lastName=t.lastName.toString()}if(typeof t.work_position!=="undefined"){t.workPosition=t.work_position}if(typeof t.workPosition==="string"||typeof t.workPosition==="number"){a.workPosition=t.workPosition.toString()}if(typeof t.color==="string"){a.color=t.color}if(typeof t.avatar==="string"){var s;if(!t.avatar||t.avatar.endsWith("/js/im/images/blank.gif")){s=""}else if(t.avatar.startsWith("http")){s=t.avatar}else{s=i.host+t.avatar}if(s){a.avatar=encodeURI(s)}}if(typeof t.gender!=="undefined"){a.gender=t.gender==="F"?"F":"M"}if(typeof t.birthday==="string"){a.birthday=t.birthday}if(typeof t.extranet==="boolean"){a.extranet=t.extranet}if(typeof t.network==="boolean"){a.network=t.network}if(typeof t.bot==="boolean"){a.bot=t.bot}if(typeof t.connector==="boolean"){a.connector=t.connector}if(typeof t.external_auth_id!=="undefined"){t.externalAuthId=t.external_auth_id}if(typeof t.externalAuthId==="string"&&t.externalAuthId){a.externalAuthId=t.externalAuthId}if(typeof t.status==="string"){a.status=t.status}if(typeof t.idle!=="undefined"){a.idle=n.Utils.date.cast(t.idle,false)}if(typeof t.last_activity_date!=="undefined"){t.lastActivityDate=t.last_activity_date}if(typeof t.lastActivityDate!=="undefined"){a.lastActivityDate=n.Utils.date.cast(t.lastActivityDate,false)}if(typeof t.mobile_last_date!=="undefined"){t.mobileLastDate=t.mobile_last_date}if(typeof t.mobileLastDate!=="undefined"){a.mobileLastDate=n.Utils.date.cast(t.mobileLastDate,false)}if(typeof t.absent!=="undefined"){a.absent=n.Utils.date.cast(t.absent,false)}if(typeof t.departments!=="undefined"){a.departments=[];if(t.departments instanceof Array){t.departments.forEach(function(e){e=parseInt(e);if(e>0){a.departments.push(e)}})}}if(babelHelpers.typeof(t.phones)==="object"&&t.phones){a.phones={};if(typeof t.phones.work_phone!=="undefined"){t.phones.workPhone=t.phones.work_phone}if(typeof t.phones.workPhone==="string"||typeof t.phones.workPhone==="number"){a.phones.workPhone=t.phones.workPhone.toString()}if(typeof t.phones.personal_mobile!=="undefined"){t.phones.personalMobile=t.phones.personal_mobile}if(typeof t.phones.personalMobile==="string"||typeof t.phones.personalMobile==="number"){a.phones.personalMobile=t.phones.personalMobile.toString()}if(typeof t.phones.personal_phone!=="undefined"){t.phones.personalPhone=t.phones.personal_phone}if(typeof t.phones.personalPhone==="string"||typeof t.phones.personalPhone==="number"){a.phones.personalPhone=t.phones.personalPhone.toString()}if(typeof t.phones.inner_phone!=="undefined"){t.phones.innerPhone=t.phones.inner_phone}if(typeof t.phones.innerPhone==="string"||typeof t.phones.innerPhone==="number"){a.phones.innerPhone=t.phones.innerPhone.toString()}}return a}}]);return i}(i.VuexBuilderModel);var c=function(e){babelHelpers.inherits(i,e);function i(){babelHelpers.classCallCheck(this,i);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).apply(this,arguments))}babelHelpers.createClass(i,[{key:"getName",value:function e(){return"files"}},{key:"getState",value:function e(){return{created:0,host:this.getVariable("host",location.protocol+"//"+location.host),collection:{},index:{}}}},{key:"getElementState",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=t.id,n=i===void 0?0:i,r=t.chatId,o=r===void 0?0:r,s=t.name,l=s===void 0?this.getVariable("default.name",""):s;return{id:n,chatId:o,name:l,templateId:n,date:new Date,type:"file",extension:"",icon:"empty",size:0,image:false,status:a.FileStatus.done,progress:100,authorId:0,authorName:"",urlPreview:"",urlShow:"",urlDownload:"",init:false}}},{key:"getGetters",value:function e(){var t=this;return{get:function e(t){return function(e,i){var a=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(!e||!i){return null}if(!t.index[e]||!t.index[e][i]){return null}if(!a&&!t.index[e][i].init){return null}return t.index[e][i]}},getList:function e(t){return function(e){if(!t.index[e]){return null}return t.index[e]}},getBlank:function e(i){return function(e){return t.getElementState(e)}}}}},{key:"getActions",value:function e(){var t=this;return{add:function e(i,a){var n=t.validate(Object.assign({},a),{host:i.state.host});n.id="temporary"+(new Date).getTime()+i.state.created;n.templateId=n.id;n.init=true;i.commit("add",Object.assign({},t.getElementState(),n));return n.id},set:function e(i,n){if(n instanceof Array){n=n.map(function(e){var a=t.validate(Object.assign({},e),{host:i.state.host});a.templateId=a.id;return Object.assign({},t.getElementState(),a,{init:true})})}else{var r=t.validate(Object.assign({},n),{host:i.state.host});r.templateId=r.id;n=[];n.push(Object.assign({},t.getElementState(),r,{init:true}))}i.commit("set",{insertType:a.MutationType.setAfter,data:n})},setBefore:function e(i,n){if(n instanceof Array){n=n.map(function(e){var a=t.validate(Object.assign({},e),{host:i.state.host});a.templateId=a.id;return Object.assign({},t.getElementState(),a,{init:true})})}else{var r=t.validate(Object.assign({},n),{host:i.state.host});r.templateId=r.id;n=[];n.push(Object.assign({},t.getElementState(),r,{init:true}))}i.commit("set",{actionName:"setBefore",insertType:a.MutationType.setBefore,data:n})},update:function e(i,a){var n=t.validate(Object.assign({},a.fields),{host:i.state.host});i.commit("initCollection",{chatId:a.chatId});var r=i.state.collection[a.chatId].findIndex(function(e){return e.id===a.id});if(r<0){return false}i.commit("update",{id:a.id,chatId:a.chatId,index:r,fields:n});if(a.fields.blink){setTimeout(function(){i.commit("update",{id:a.id,chatId:a.chatId,fields:{blink:false}})},1e3)}return true},delete:function e(t,i){t.commit("delete",{id:i.id,chatId:i.chatId});return true},saveState:function e(t,i){t.commit("saveState",{});return true}}}},{key:"getMutations",value:function e(){var t=this;return{initCollection:function e(i,a){t.initCollection(i,a)},add:function e(i,a){t.initCollection(i,a);i.collection[a.chatId].push(a);i.index[a.chatId][a.id]=a;i.created+=1;t.saveState(i)},set:function e(i,n){var r=true;var o=false;var s=undefined;try{var l=function e(){var r=c.value;t.initCollection(i,{chatId:r.chatId});var o=i.collection[r.chatId].findIndex(function(e){return e.id===r.id});if(o>-1){delete r.templateId;i.collection[r.chatId][o]=Object.assign(i.collection[r.chatId][o],r)}else if(n.insertType===a.MutationType.setBefore){i.collection[r.chatId].unshift(r)}else{i.collection[r.chatId].push(r)}i.index[r.chatId][r.id]=r;t.saveState(i)};for(var d=n.data[Symbol.iterator](),c;!(r=(c=d.next()).done);r=true){l()}}catch(e){o=true;s=e}finally{try{if(!r&&d.return!=null){d.return()}}finally{if(o){throw s}}}},update:function e(i,a){t.initCollection(i,a);var n=-1;if(typeof a.index!=="undefined"&&i.collection[a.chatId][a.index]){n=a.index}else{n=i.collection[a.chatId].findIndex(function(e){return e.id===a.id})}if(n>=0){delete a.fields.templateId;var r=Object.assign(i.collection[a.chatId][n],a.fields);i.collection[a.chatId][n]=r;i.index[a.chatId][r.id]=r;t.saveState(i)}},delete:function e(i,a){t.initCollection(i,a);i.collection[a.chatId]=i.collection[a.chatId].filter(function(e){return e.id!==a.id});delete i.index[a.chatId][a.id];t.saveState(i)},saveState:function e(i,a){t.saveState(i)}}}},{key:"initCollection",value:function e(i,a){if(typeof i.collection[a.chatId]!=="undefined"){return true}t.Vue.set(i.collection,a.chatId,[]);t.Vue.set(i.index,a.chatId,{});return true}},{key:"getLoadedState",value:function e(t){if(!t||babelHelpers.typeof(t)!=="object"){return t}if(babelHelpers.typeof(t.collection)!=="object"){return t}t.index={};var i=function e(i){if(!t.collection.hasOwnProperty(i)){return"continue"}t.index[i]={};t.collection[i].filter(function(e){return e!=null}).forEach(function(e){t.index[i][e.id]=e})};for(var a in t.collection){var n=i(a);if(n==="continue")continue}return t}},{key:"getSaveFileList",value:function e(){if(!this.db){return[]}if(!this.store.getters["messages/getSaveFileList"]){return[]}var t=this.store.getters["messages/getSaveFileList"]();if(!t){return[]}return t}},{key:"getSaveTimeout",value:function e(){return 250}},{key:"saveState",value:function e(t){var a=this;if(!this.isSaveAvailable()){return false}babelHelpers.get(babelHelpers.getPrototypeOf(i.prototype),"saveState",this).call(this,function(){var e=a.getSaveFileList();if(!e){return false}var i={collection:{}};var n=function a(n){if(!e.hasOwnProperty(n)){return"continue"}e[n].forEach(function(e){if(!t.index[n]){return false}if(!t.index[n][e]){return false}if(!i.collection[n]){i.collection[n]=[]}i.collection[n].push(t.index[n][e])})};for(var r in e){var o=n(r);if(o==="continue")continue}return i})}},{key:"validate",value:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var o={};r.host=r.host||this.getState().host;if(typeof t.id==="number"){o.id=t.id}else if(typeof t.id==="string"){if(t.id.startsWith("temporary")){o.id=t.id}else{o.id=parseInt(t.id)}}if(typeof t.templateId==="number"){o.templateId=t.templateId}else if(typeof t.templateId==="string"){if(t.templateId.startsWith("temporary")){o.templateId=t.templateId}else{o.templateId=parseInt(t.templateId)}}if(typeof t.chatId==="number"||typeof t.chatId==="string"){o.chatId=parseInt(t.chatId)}if(typeof t.date!=="undefined"){o.date=n.Utils.date.cast(t.date)}if(typeof t.type==="string"){o.type=t.type}if(typeof t.extension==="string"){o.extension=t.extension.toString();if(o.type==="image"){o.icon="img"}else if(o.type==="video"){o.icon="mov"}else{o.icon=i.getIconType(o.extension)}}if(typeof t.name==="string"||typeof t.name==="number"){o.name=t.name.toString()}if(typeof t.size==="number"||typeof t.size==="string"){o.size=parseInt(t.size)}if(typeof t.image==="boolean"){o.image=false}else if(babelHelpers.typeof(t.image)==="object"&&t.image){o.image={width:0,height:0};if(typeof t.image.width==="string"||typeof t.image.width==="number"){o.image.width=parseInt(t.image.width)}if(typeof t.image.height==="string"||typeof t.image.height==="number"){o.image.height=parseInt(t.image.height)}if(o.image.width<=0||o.image.height<=0){o.image=false}}if(typeof t.status==="string"&&typeof a.FileStatus[t.status]!=="undefined"){o.status=t.status}if(typeof t.progress==="number"||typeof t.progress==="string"){o.progress=parseInt(t.progress)}if(typeof t.authorId==="number"||typeof t.authorId==="string"){o.authorId=parseInt(t.authorId)}if(typeof t.authorName==="string"||typeof t.authorName==="number"){o.authorName=t.authorName.toString()}if(typeof t.urlPreview==="string"){if(!t.urlPreview||t.urlPreview.startsWith("http")||t.urlPreview.startsWith("bx")||t.urlPreview.startsWith("file")){o.urlPreview=t.urlPreview}else{o.urlPreview=r.host+t.urlPreview}}if(typeof t.urlDownload==="string"){if(!t.urlDownload||t.urlDownload.startsWith("http")||t.urlDownload.startsWith("bx")||t.urlPreview.startsWith("file")){o.urlDownload=t.urlDownload}else{o.urlDownload=r.host+t.urlDownload}}if(typeof t.urlShow==="string"){if(!t.urlShow||t.urlShow.startsWith("http")||t.urlShow.startsWith("bx")||t.urlShow.startsWith("file")){o.urlShow=t.urlShow}else{o.urlShow=r.host+t.urlShow}}return o}}],[{key:"getType",value:function e(t){t=t.toString().toLowerCase().split(".").splice(-1)[0];switch(t){case"png":case"jpe":case"jpg":case"jpeg":case"gif":case"heic":case"bmp":return a.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 a.FileType.video;case"mp3":return a.FileType.audio}return a.FileType.file}},{key:"getIconType",value:function e(t){var i="empty";switch(t.toString()){case"png":case"jpe":case"jpg":case"jpeg":case"gif":case"heic":case"bmp":i="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":i="mov";break;case"txt":i="txt";break;case"doc":case"docx":i="doc";break;case"xls":case"xlsx":i="xls";break;case"php":i="php";break;case"pdf":i="pdf";break;case"ppt":case"pptx":i="ppt";break;case"rar":i="rar";break;case"zip":case"7z":case"tar":case"gz":case"gzip":i="zip";break;case"set":i="set";break;case"conf":case"ini":case"plist":i="set";break}return i}}]);return i}(i.VuexBuilderModel);e.ApplicationModel=r;e.MessagesModel=s;e.DialoguesModel=l;e.UsersModel=d;e.FilesModel=c})(this.BX.Messenger.Model=this.BX.Messenger.Model||{},BX,BX,BX.Messenger.Const,BX.Messenger);
  //# sourceMappingURL=registry.bundle.map.js