Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/im/v2/model/dist/ |
Upload File : |
this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};this.BX.Messenger.v2=this.BX.Messenger.v2||{};(function(e,t,i,s,o,a,n,r,l,c,d,u){"use strict";const m=e=>d.Type.isNumber(e)||d.Type.isString(e);const g=e=>e.toString();const h=e=>Number.parseInt(e,10);const f=e=>n.Utils.date.cast(e,false);const p=/(_[\da-z])/gi;const y=e=>{const t={};Object.entries(e).forEach((([e,i])=>{const s=I(e);if(d.Type.isPlainObject(i)){t[s]=y(i);return}if(d.Type.isArray(i)){t[s]=N(i);return}t[s]=i}));return t};const I=e=>{let t=e;if(t.search(p)!==-1){t=t.toLowerCase()}return d.Text.toCamelCase(t)};const N=e=>e.map((e=>{if(!d.Type.isPlainObject(e)){return e}return y(e)}));const F={im:10};const C=e=>{const t={};const i=b(e);i.forEach((e=>{const i={};e.notices.forEach((e=>{i[e.id]=e}));t[e.id]={id:e.id,label:e.label,items:i}}));return t};const b=e=>[...e].sort(((e,t)=>{var i,s;const o=(i=F[e.id])!=null?i:0;const a=(s=F[t.id])!=null?s:0;return a-o}));const S=[{fieldName:r.Settings.notification.enableSound,targetFieldName:r.Settings.notification.enableSound,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.notification.enableAutoRead,targetFieldName:r.Settings.notification.enableAutoRead,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.notification.mode,targetFieldName:r.Settings.notification.mode,checkFunction:d.Type.isString},{fieldName:r.Settings.notification.enableWeb,targetFieldName:r.Settings.notification.enableWeb,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.notification.enableMail,targetFieldName:r.Settings.notification.enableMail,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.notification.enablePush,targetFieldName:r.Settings.notification.enablePush,checkFunction:d.Type.isBoolean},{fieldName:"notifications",targetFieldName:"notifications",checkFunction:d.Type.isArray,formatFunction:C},{fieldName:r.Settings.message.bigSmiles,targetFieldName:r.Settings.message.bigSmiles,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.appearance.background,targetFieldName:r.Settings.appearance.background,checkFunction:m,formatFunction:h},{fieldName:r.Settings.appearance.alignment,targetFieldName:r.Settings.appearance.alignment,checkFunction:d.Type.isString},{fieldName:r.Settings.recent.showBirthday,targetFieldName:r.Settings.recent.showBirthday,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.recent.showInvited,targetFieldName:r.Settings.recent.showInvited,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.recent.showLastMessage,targetFieldName:r.Settings.recent.showLastMessage,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.hotkey.sendByEnter,targetFieldName:r.Settings.hotkey.sendByEnter,checkFunction:d.Type.isString,formatFunction:e=>e==="1"},{fieldName:r.Settings.hotkey.sendByEnter,targetFieldName:r.Settings.hotkey.sendByEnter,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.desktop.enableRedirect,targetFieldName:r.Settings.desktop.enableRedirect,checkFunction:d.Type.isBoolean},{fieldName:r.Settings.user.status,targetFieldName:r.Settings.user.status,checkFunction:d.Type.isString}];const T=(e,t)=>{const i={};const s=y(e);t.forEach((t=>{const{fieldName:o,targetFieldName:a,checkFunction:n,formatFunction:r}=t;const l=v(s,o);if(!l){return}if(!P(s[l],n)){return}i[a]=L({fieldValue:s[l],formatFunction:r,currentResult:i,rawFields:e})}));return i};const v=(e,t)=>{let i=t;if(d.Type.isStringFilled(i)){i=[i]}for(const t of i){if(!d.Type.isUndefined(e[t])){return t}}return null};const P=(e,t)=>{let i=t;if(d.Type.isUndefined(i)){return true}if(d.Type.isFunction(i)){i=[i]}return i.some((t=>t(e)))};const L=e=>{const{fieldValue:t,formatFunction:i,currentResult:s,rawFields:o}=e;if(d.Type.isUndefined(i)){return t}return i(t,s,o)};class k extends c.BuilderModel{getState(){return{[r.Settings.appearance.background]:1,[r.Settings.appearance.alignment]:r.DialogAlignment.left,[r.Settings.notification.enableSound]:true,[r.Settings.notification.enableAutoRead]:true,[r.Settings.notification.mode]:r.NotificationSettingsMode.simple,[r.Settings.notification.enableWeb]:true,[r.Settings.notification.enableMail]:true,[r.Settings.notification.enablePush]:true,notifications:{},[r.Settings.message.bigSmiles]:true,[r.Settings.recent.showBirthday]:true,[r.Settings.recent.showInvited]:true,[r.Settings.recent.showLastMessage]:true,[r.Settings.desktop.enableRedirect]:true}}getGetters(){return{get:e=>t=>e[t]}}getActions(){return{set:(e,t)=>{e.commit("set",this.formatFields(t))},setNotificationOption:(e,t)=>{e.commit("setNotificationOption",t)}}}getMutations(){return{set:(e,t)=>{Object.entries(t).forEach((([t,i])=>{e[t]=i}))},setNotificationOption:(e,t)=>{var i;const{moduleId:s,optionName:o,type:a,value:n}=t;const r=e.notifications[s];if(!(r!=null&&(i=r.items)!=null&&i[o])){return}r.items[o][a]=n}}}formatFields(e){return T(e,S)}}const M=[{fieldName:"fullChatHistory",targetFieldName:"fullChatHistory",checkFunction:d.Type.isPlainObject}];class x extends c.BuilderModel{getState(){return{fullChatHistory:{isAvailable:true,limitDays:null}}}getGetters(){return{get:e=>e,isHistoryAvailable:e=>{var t,i;return(t=(i=e.fullChatHistory)==null?void 0:i.isAvailable)!=null?t:false}}}getActions(){return{set:(e,t)=>{e.commit("set",this.formatFields(t))}}}getMutations(){return{set:(e,t)=>{Object.entries(t).forEach((([t,i])=>{e[t]=i}))}}}formatFields(e){return T(e,M)}}class E extends c.BuilderModel{getName(){return"application"}getNestedModules(){return{settings:k,tariffRestrictions:x}}getState(){return{layout:{name:r.Layout.chat.name,entityId:"",contextId:0}}}getGetters(){return{getLayout:e=>e.layout,isChatOpen:e=>t=>{const i=[r.Layout.chat.name,r.Layout.copilot.name,r.Layout.channel.name,r.Layout.collab.name];if(!i.includes(e.layout.name)){return false}return e.layout.entityId===t.toString()},isLinesChatOpen:e=>t=>{if(e.layout.name!==r.Layout.openlines.name&&e.layout.name!==r.Layout.openlinesV2.name){return false}return e.layout.entityId===t.toString()},areNotificationsOpen:e=>e.layout.name===r.Layout.notification.name}}getActions(){return{setLayout:(e,i)=>{const{name:s,entityId:o="",contextId:a=0}=i;if(!d.Type.isStringFilled(s)){return}const n={...e.state.layout};const l={name:this.validateLayout(s),entityId:this.validateLayoutEntityId(s,o),contextId:a};t.EventEmitter.emit(r.EventType.layout.onLayoutChange,{from:n,to:l});if(n.name===l.name&&n.entityId===l.entityId){return}e.commit("updateLayout",{layout:l})}}}getMutations(){return{updateLayout:(e,t)=>{e.layout={...e.layout,...t.layout}}}}validateLayout(e){if(!r.Layout[e]){return r.Layout.chat.name}return e}validateLayoutEntityId(e,t){if(!r.Layout[e]){return""}return t}}const B=e=>{const t=Object.values(r.MessageComponent);if(!t.includes(e)){return r.MessageComponent.unsupported}return e};const w=(e,t,i)=>{if(d.Type.isString(i.system)&&i.system==="Y"){return 0}if(d.Type.isBoolean(i.isSystem)&&i.isSystem===true){return 0}return h(e)};const A=e=>e.map((e=>({...e,block:e.block==="Y",disabled:e.disabled==="Y",vote:e.vote==="Y",wait:e.wait==="Y"})));const H=[{fieldName:["id","temporaryId"],targetFieldName:"id",checkFunction:[d.Type.isNumber,n.Utils.text.isTempMessage]},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:m,formatFunction:h},{fieldName:"date",targetFieldName:"date",checkFunction:[d.Type.isString,d.Type.isDate],formatFunction:n.Utils.date.cast},{fieldName:"text",targetFieldName:"text",checkFunction:m,formatFunction:g},{fieldName:["senderId","authorId"],targetFieldName:"authorId",checkFunction:m,formatFunction:w},{fieldName:"sending",targetFieldName:"sending",checkFunction:d.Type.isBoolean},{fieldName:"unread",targetFieldName:"unread",checkFunction:d.Type.isBoolean},{fieldName:"viewed",targetFieldName:"viewed",checkFunction:d.Type.isBoolean},{fieldName:"viewedByOthers",targetFieldName:"viewedByOthers",checkFunction:d.Type.isBoolean},{fieldName:"error",targetFieldName:"error",checkFunction:d.Type.isBoolean},{fieldName:"componentId",targetFieldName:"componentId",checkFunction:e=>d.Type.isString(e)&&e!=="",formatFunction:B},{fieldName:"componentParams",targetFieldName:"componentParams",checkFunction:d.Type.isPlainObject},{fieldName:["files","fileId"],targetFieldName:"files",checkFunction:d.Type.isArray},{fieldName:"attach",targetFieldName:"attach",checkFunction:[d.Type.isArray,d.Type.isBoolean,d.Type.isString]},{fieldName:"keyboard",targetFieldName:"keyboard",checkFunction:d.Type.isArray,formatFunction:A},{fieldName:"keyboard",targetFieldName:"keyboard",checkFunction:e=>e==="N",formatFunction:()=>[]},{fieldName:"isEdited",targetFieldName:"isEdited",checkFunction:d.Type.isString,formatFunction:e=>e==="Y"},{fieldName:"isEdited",targetFieldName:"isEdited",checkFunction:d.Type.isBoolean},{fieldName:"isDeleted",targetFieldName:"isDeleted",checkFunction:d.Type.isString,formatFunction:e=>e==="Y"},{fieldName:"isDeleted",targetFieldName:"isDeleted",checkFunction:d.Type.isBoolean},{fieldName:"replyId",targetFieldName:"replyId",checkFunction:m,formatFunction:h},{fieldName:"forward",targetFieldName:"forward",checkFunction:d.Type.isPlainObject}];class O extends c.BuilderModel{getState(){return{collection:{}}}getGetters(){return{getPinned:e=>t=>{if(!e.collection[t]){return[]}const i=[];[...e.collection[t]].forEach((e=>{const t=l.Core.getStore().getters["messages/getById"](e);if(t){i.push(t)}}));return i},isPinned:e=>t=>{const{chatId:i,messageId:s}=t;if(!e.collection[i]){return false}return e.collection[i].has(s)}}}getActions(){return{setPinned:(e,t)=>{const{chatId:i,pinnedMessages:s}=t;if(s.length===0){return}e.commit("setPinned",{chatId:i,pinnedMessageIds:s})},set:(e,t)=>{e.commit("set",t)},add:(e,t)=>{e.commit("add",t)},delete:(e,t)=>{e.commit("delete",t)}}}getMutations(){return{setPinned:(e,t)=>{o.Logger.warn("Messages/pin model: setPinned mutation",t);const{chatId:i,pinnedMessageIds:s}=t;e.collection[i]=new Set(s.reverse())},add:(e,t)=>{o.Logger.warn("Messages/pin model: add pin mutation",t);const{chatId:i,messageId:s}=t;if(!e.collection[i]){e.collection[i]=new Set}e.collection[i].add(s)},delete:(e,t)=>{o.Logger.warn("Messages/pin model: delete pin mutation",t);const{chatId:i,messageId:s}=t;if(!e.collection[i]){return}e.collection[i].delete(s)}}}}const U=Object.freeze({like:"like",kiss:"kiss",laugh:"laugh",wonder:"wonder",cry:"cry",angry:"angry",facepalm:"facepalm"});const j=5;class R extends c.BuilderModel{getState(){return{collection:{}}}getElementState(){return{reactionCounters:{},reactionUsers:{},ownReactions:new Set}}getGetters(){return{getByMessageId:e=>t=>e.collection[t]}}getActions(){return{set:(e,t)=>{e.commit("set",this.prepareSetPayload(t))},setReaction:(e,t)=>{if(!U[t.reaction]){return}if(!e.state.collection[t.messageId]){e.commit("initCollection",t.messageId)}e.commit("setReaction",t)},removeReaction:(e,t)=>{if(!e.state.collection[t.messageId]||!U[t.reaction]){return}e.commit("removeReaction",t)},clearCollection:e=>{e.commit("clearCollection")}}}getMutations(){return{set:(e,t)=>{t.forEach((t=>{const i={reactionCounters:t.reactionCounters,reactionUsers:t.reactionUsers};const s=e.collection[t.messageId];const o=Boolean(t.ownReactions);if(o){i.ownReactions=t.ownReactions}else{i.ownReactions=s?s.ownReactions:new Set}e.collection[t.messageId]=i}))},setReaction:(e,t)=>{const{messageId:i,userId:s,reaction:o}=t;const a=e.collection[i];if(l.Core.getUserId()===s){this.removeAllCurrentUserReactions(e,i);a.ownReactions.add(o)}if(!a.reactionCounters[o]){a.reactionCounters[o]=0}const n=a.reactionCounters[o];if(n+1<=j){if(!a.reactionUsers[o]){a.reactionUsers[o]=new Set}a.reactionUsers[o].add(s)}a.reactionCounters[o]++},removeReaction:(e,t)=>{var i;const{messageId:s,userId:o,reaction:a}=t;const n=e.collection[s];if(l.Core.getUserId()===o){n.ownReactions.delete(a)}(i=n.reactionUsers[a])==null?void 0:i.delete(o);n.reactionCounters[a]--;if(n.reactionCounters[a]===0){delete n.reactionCounters[a]}},initCollection:(e,t)=>{if(!e.collection[t]){e.collection[t]=this.getElementState()}},clearCollection:e=>{e.collection={}}}}removeAllCurrentUserReactions(e,t){const i=e.collection[t];i.ownReactions.forEach((e=>{var t;(t=i.reactionUsers[e])==null?void 0:t.delete(l.Core.getUserId());i.reactionCounters[e]--;if(i.reactionCounters[e]===0){delete i.reactionCounters[e]}}));i.ownReactions=new Set}prepareSetPayload(e){return e.map((e=>{var t;const i={};Object.entries(e.reactionUsers).forEach((([e,t])=>{i[e]=new Set(t)}));const s={};Object.entries(e.reactionCounters).forEach((([e,t])=>{s[e]=t}));const o={messageId:e.messageId,reactionCounters:s,reactionUsers:i};if(((t=e.ownReactions)==null?void 0:t.length)>0){o.ownReactions=new Set(e.ownReactions)}return o}))}}const D=[{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"lastUserIds",targetFieldName:"lastUserIds",checkFunction:d.Type.isArray},{fieldName:"messageCount",targetFieldName:"messageCount",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"isUserSubscribed",targetFieldName:"isUserSubscribed",checkFunction:d.Type.isBoolean}];const W=3;var G=babelHelpers.classPrivateFieldLooseKey("formatFields");var V=babelHelpers.classPrivateFieldLooseKey("isMessageAuthor");class K extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,V,{value:z});Object.defineProperty(this,G,{value:_})}getState(){return{collection:{},layout:{opened:false,channelDialogId:"",postId:0}}}getElementState(){return{chatId:0,lastUserIds:[],messageCount:0,messageId:0,isUserSubscribed:false}}getGetters(){return{getByMessageId:e=>t=>{var i;return(i=e.collection[t])!=null?i:this.getElementState()},getMessageIdByChatId:e=>t=>{const i=Object.values(e.collection);const s=i.find((e=>e.chatId===t));return s==null?void 0:s.messageId},isUserSubscribed:e=>t=>{var i;const s=e.collection[t];if(!s&&babelHelpers.classPrivateFieldLooseBase(this,V)[V](t)){return true}return(i=s==null?void 0:s.isUserSubscribed)!=null?i:false},areOpened:e=>e.layout.opened,areOpenedForChannel:e=>t=>e.layout.channelDialogId===t,areOpenedForChannelPost:e=>t=>e.layout.postId===t,getOpenedChannelId:e=>{var t;return(t=e.layout.channelDialogId)!=null?t:""}}}getActions(){return{set:(e,t)=>{let i=t;if(!i){return}if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i=i.map((t=>{const i=e.state.collection[t.messageId];if(i){return{...i,...babelHelpers.classPrivateFieldLooseBase(this,G)[G](t)}}return{...this.getElementState(),isUserSubscribed:babelHelpers.classPrivateFieldLooseBase(this,V)[V](t.messageId),...babelHelpers.classPrivateFieldLooseBase(this,G)[G](t)}}));e.commit("set",i)},setLastUser:(e,t)=>{const{messageId:i,newUserId:s}=t;const o=e.state.collection[i];if(!o||s===0){return}e.commit("setLastUser",t)},subscribe:(e,t)=>{l.Core.getStore().dispatch("messages/comments/set",{messageId:t,isUserSubscribed:true})},unsubscribe:(e,t)=>{l.Core.getStore().dispatch("messages/comments/set",{messageId:t,isUserSubscribed:false})},setOpened:(e,t)=>{e.commit("setOpened",t)},setClosed:e=>{e.commit("setClosed")}}}getMutations(){return{set:(e,t)=>{t.forEach((t=>{e.collection[t.messageId]=t}))},setLastUser:(e,t)=>{const{messageId:i,newUserId:s}=t;const{lastUserIds:o}=e.collection[i];if(o.includes(s)){return}if(o.length<W){o.unshift(s);return}o.pop();o.unshift(s)},setOpened:(e,t)=>{const{channelDialogId:i,commentsPostId:s}=t;e.layout={opened:true,channelDialogId:i,postId:s}},setClosed:e=>{e.layout={opened:false,channelDialogId:"",commentsPostId:0}}}}}function _(e){return u.formatFieldsWithConfig(e,D)}function z(e){const t=l.Core.getStore().getters["messages/getById"](e);return(t==null?void 0:t.authorId)===l.Core.getUserId()}class X extends c.BuilderModel{getState(){return{collection:{}}}getGetters(){return{getCollection:e=>t=>{if(!e.collection[t]){return null}const i=[...e.collection[t]];const s=i.filter((e=>l.Core.getStore().getters["messages/isExists"](e)));return new Set(s)},isBulkActionsModeActive:e=>t=>Boolean(e.collection[t]),isMessageSelected:e=>(t,i)=>{if(!e.collection[i]){return false}return e.collection[i].has(t)}}}getActions(){return{enableBulkMode:(e,t)=>{const{messageId:i,dialogId:s}=t;if(e.state.collection[s]){return}e.commit("enableBulkMode",{messageId:i,dialogId:s})},disableBulkMode:(e,t)=>{const{dialogId:i}=t;if(!e.state.collection[i]){return}e.commit("disableBulkMode",{dialogId:i})},toggleMessageSelection:(e,t)=>{const{messageId:i,dialogId:s}=t;if(!e.state.collection[s]){return}e.commit("toggleMessageSelection",{messageId:i,dialogId:s})},clearCollection:e=>{e.commit("clearCollection")}}}getMutations(){return{enableBulkMode:(e,t)=>{const{messageId:i,dialogId:s}=t;e.collection[s]=new Set;e.collection[s].add(i)},disableBulkMode:(e,t)=>{const{dialogId:i}=t;delete e.collection[i]},toggleMessageSelection:(e,t)=>{const{messageId:i,dialogId:s}=t;if(e.collection[s].has(i)){e.collection[s].delete(i);return}e.collection[s].add(i)},clearCollection:e=>{e.collection={}}}}}function Y(e,t){return e.messageId===t.messageId&&e.type===t.type&&e.userId===t.userId&&e.fromUserId===t.fromUserId}function $(e,t,i){return e.userId===l.Core.getUserId()&&e.chatId===i&&e.type===t}class q extends c.BuilderModel{getName(){return"anchors"}getState(){return{anchors:[]}}getGetters(){return{getChatMessageIdsWithAnchors:e=>t=>[...e.anchors].filter((e=>e.chatId===t)).map((e=>e.messageId)),isMessageHasAnchors:e=>t=>{const i=l.Core.getUserId();return e.anchors.some((e=>e.messageId===t&&e.userId===i))},isChatHasAnchors:e=>t=>{const i=l.Core.getUserId();return e.anchors.some((e=>e.chatId===t&&e.userId===i))},isChatHasAnchorsWithType:e=>(t,i)=>e.anchors.some((e=>$(e,i,t))),getCounterInChatByType:e=>(t,i)=>e.anchors.filter((e=>$(e,i,t))).length,getNextMessageIdWithAnchorType:e=>(t,i)=>{var s;const o=e.anchors.filter((e=>$(e,i,t))).sort(((e,t)=>e.messageId-t.messageId));return(s=o.at(0))==null?void 0:s.messageId}}}getActions(){return{setAnchors:(e,t)=>{if(d.Type.isPlainObject(t)===false){return}e.commit("setAnchors",{anchors:t.anchors})},addAnchor:(e,t)=>{if(d.Type.isPlainObject(t)===false){return}const i=e.state.anchors.find((e=>Y(e,t.anchor)));if(!i){e.commit("addAnchor",t)}},removeAnchor:(e,t)=>{if(d.Type.isPlainObject(t)===false){return}e.commit("removeAnchor",t)},removeUserAnchorsFromMessage:(e,t)=>{e.state.anchors.forEach((i=>{if(i.userId===t.userId&&i.messageId===t.messageId){e.commit("removeAnchor",{anchor:i})}}))},removeChatAnchors:(e,t)=>{e.commit("removeChatAnchors",t)},removeAllAnchors:e=>{e.commit("removeAllAnchors")}}}getMutations(){return{setAnchors:(e,t)=>{e.anchors=[...t.anchors]},addAnchor:(e,t)=>{e.anchors.push(t.anchor)},removeAnchor:(e,t)=>{const i=e.anchors.findIndex((e=>Y(e,t.anchor)));if(i>-1){e.anchors.splice(i,1)}},removeChatAnchors:(e,t)=>{e.anchors=e.anchors.filter((e=>e.chatId!==t.chatId||e.userId!==t.userId))},removeAllAnchors:e=>{e.anchors=[]}}}}var Q=babelHelpers.classPrivateFieldLooseKey("findNextLoadingMessages");var J=babelHelpers.classPrivateFieldLooseKey("formatFields");var Z=babelHelpers.classPrivateFieldLooseKey("needToSwapAuthorId");var ee=babelHelpers.classPrivateFieldLooseKey("prepareSwapAuthorId");var te=babelHelpers.classPrivateFieldLooseKey("getMaxMessageId");var ie=babelHelpers.classPrivateFieldLooseKey("findLowestMessageId");var se=babelHelpers.classPrivateFieldLooseKey("findMaxMessageId");var oe=babelHelpers.classPrivateFieldLooseKey("findLastOwnMessageId");var ae=babelHelpers.classPrivateFieldLooseKey("findFirstUnread");var ne=babelHelpers.classPrivateFieldLooseKey("sortCollection");var re=babelHelpers.classPrivateFieldLooseKey("makeFakePreviousSiblingId");class le extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,re,{value:Ne});Object.defineProperty(this,ne,{value:Ie});Object.defineProperty(this,ae,{value:ye});Object.defineProperty(this,oe,{value:pe});Object.defineProperty(this,se,{value:fe});Object.defineProperty(this,ie,{value:he});Object.defineProperty(this,te,{value:ge});Object.defineProperty(this,ee,{value:me});Object.defineProperty(this,Z,{value:ue});Object.defineProperty(this,J,{value:de});Object.defineProperty(this,Q,{value:ce})}getName(){return"messages"}getNestedModules(){return{pin:O,reactions:R,comments:K,select:X,anchors:q}}getState(){return{collection:{},chatCollection:{},loadingMessages:{}}}getElementState(){return{id:0,chatId:0,authorId:0,replyId:0,date:new Date,text:"",files:[],attach:[],keyboard:[],unread:false,viewed:true,viewedByOthers:false,sending:false,error:false,componentId:r.MessageComponent.default,componentParams:{},forward:{id:"",userId:0},isEdited:false,isDeleted:false}}getGetters(){return{getByChatId:(e,t)=>i=>{if(!e.chatCollection[i]){return[]}const s={id:babelHelpers.classPrivateFieldLooseBase(this,re)[re](i)};const o=babelHelpers.classPrivateFieldLooseBase(this,Q)[Q](s,t);return[...e.chatCollection[i]].map((t=>e.collection[t])).sort(babelHelpers.classPrivateFieldLooseBase(this,ne)[ne]).reduce(((e,i)=>{e.push(i,...babelHelpers.classPrivateFieldLooseBase(this,Q)[Q](i,t));return e}),[...o])},getById:e=>t=>e.collection[t],getByIdList:e=>t=>{const i=[];t.forEach((t=>{if(e.collection[t]){i.push(e.collection[t])}}));return i},hasMessage:e=>({chatId:t,messageId:i})=>{if(!e.chatCollection[t]){return false}return e.chatCollection[t].has(i)},isForward:e=>t=>{const i=e.collection[t];if(!i){return false}return d.Type.isStringFilled(i.forward.id)},isExists:e=>t=>{const i=e.collection[t];return i&&!i.isDeleted},isInChatCollection:e=>t=>{var i;const{messageId:s}=t;const o=e.collection[s];if(!o){return false}const{chatId:a}=o;return(i=e.chatCollection[a])==null?void 0:i.has(s)},getFirstId:e=>t=>{if(!e.chatCollection[t]){return 0}return babelHelpers.classPrivateFieldLooseBase(this,ie)[ie](e,t)},getLastId:e=>t=>{if(!e.chatCollection[t]){return 0}return babelHelpers.classPrivateFieldLooseBase(this,se)[se](e,t)},getLastOwnMessageId:e=>t=>{if(!e.chatCollection[t]){return 0}return babelHelpers.classPrivateFieldLooseBase(this,oe)[oe](e,t)},getFirstUnread:e=>t=>{if(!e.chatCollection[t]){return 0}return babelHelpers.classPrivateFieldLooseBase(this,ae)[ae](e,t)},getChatUnreadMessages:e=>t=>{if(!e.chatCollection[t]){return[]}const i=[...e.chatCollection[t]].map((t=>e.collection[t]));return i.filter((e=>e.unread===true))},getMessageFiles:e=>t=>{const i=t;if(!e.collection[i]){return[]}return e.collection[i].files.map((e=>this.store.getters["files/get"](e,true)))},getMessageType:e=>t=>{const i=e.collection[t];if(!i){return null}const s=l.Core.getUserId();if(i.authorId===0){return r.MessageType.system}if(i.authorId===s){return r.MessageType.self}return r.MessageType.opponent},getPreviousMessage:e=>t=>{const{messageId:i,chatId:s}=t;const o=e.collection[i];if(!o){return null}const a=[...e.chatCollection[s]];const n=a.indexOf(i);const r=a[n-1];if(!r){return null}return e.collection[r]},findPreviousMessageId:(e,t)=>e=>{const i=t.getByChatId(e.chatId);const s=i.findIndex((t=>t.id===e.messageId));if(s>0){return i[s-1].id}return-1},findLastChatMessageId:(e,t)=>e=>{const i=t.getByChatId(e).pop();if(i){return i.id}return null},hasLoadingMessageByPreviousSiblingId:e=>t=>Boolean(e.loadingMessages[t]),getLoadingMessageByPreviousSiblingId:e=>t=>{var i;return(i=e.loadingMessages[t])!=null?i:null},getLoadingMessageByMessageId:e=>t=>{const i=Object.values(e.loadingMessages).find((e=>e.id===t));if(i){return i}return null},hasLoadingMessageByMessageId:(e,t)=>e=>t.getLoadingMessageByMessageId(e)!==null,isRealMessage:()=>e=>!n.Utils.text.isTempMessage(e)}}getActions(){return{setChatCollection:(e,t)=>{var i,s;let{messages:o,clearCollection:a}=t;a=(i=a)!=null?i:false;if(!Array.isArray(o)&&d.Type.isPlainObject(o)){o=[o]}o=o.map((e=>({...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,J)[J](e)})));const n=(s=o[0])==null?void 0:s.chatId;if(n&&a){e.commit("clearCollection",{chatId:n})}e.commit("store",{messages:o});e.commit("setChatCollection",{messages:o})},store:(e,t)=>{let i=t;if(d.Type.isPlainObject(t)){i=[t]}i=i.map((t=>{const i=e.state.collection[t.id];if(i){return{...i,...babelHelpers.classPrivateFieldLooseBase(this,J)[J](t)}}return{...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,J)[J](t)}}));if(i.length===0){return}e.commit("store",{messages:i})},add:(e,t)=>{const i={...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,J)[J](t)};e.commit("store",{messages:[i]});e.commit("setChatCollection",{messages:[i]});return i.id},updateWithId:(e,t)=>{const{id:i,fields:s}=t;if(!e.state.collection[i]){return}e.commit("updateWithId",{id:i,fields:babelHelpers.classPrivateFieldLooseBase(this,J)[J](s)})},update:(e,t)=>{const{id:i,fields:s}=t;const o=e.state.collection[i];if(!o){return}e.commit("update",{id:i,fields:{...o,...babelHelpers.classPrivateFieldLooseBase(this,J)[J](s)}})},readMessages:(e,t)=>{const{chatId:i,messageIds:s}=t;if(!e.state.chatCollection[i]){return 0}const o=[...e.state.chatCollection[i]].map((t=>e.state.collection[t]));let a=0;const n=babelHelpers.classPrivateFieldLooseBase(this,te)[te](s);const r=s;const l=[];o.forEach((e=>{if(!e.unread){return}if(e.id<=n){a++;l.push(e.id)}}));e.commit("readMessages",{messageIdsToRead:l,messageIdsToView:r});return a},setViewedByOthers:(e,t)=>{const{ids:i}=t;e.commit("setViewedByOthers",{ids:i})},delete:(e,t)=>{const{id:i}=t;if(!e.state.collection[i]){return}if(e.getters.hasLoadingMessageByPreviousSiblingId(i)){const t=e.state.collection[i];const s=e.getters.findPreviousMessageId({messageId:t.id,chatId:t.chatId});e.commit("updateLoadingMessagePreviousSiblingId",{oldId:t.id,newId:s})}if(e.getters.hasLoadingMessageByMessageId(i)){e.commit("deleteLoadingMessageByMessageId",{messageId:i})}e.commit("delete",{id:i})},clearChatCollection:(e,t)=>{const{chatId:i}=t;e.commit("clearCollection",{chatId:i})},deleteAttach:(e,t)=>{const{messageId:i,attachId:s}=t;const o=e.state.collection[i];if(!o||!d.Type.isArray(o.attach)){return}const a=o.attach.filter((e=>s!==e.id));e.commit("update",{id:i,fields:{...o,...babelHelpers.classPrivateFieldLooseBase(this,J)[J]({attach:a})}})},addLoadingMessage:(e,t)=>{const i={...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,J)[J](t.message)};e.commit("store",{messages:[i]});if(!e.state.chatCollection[i.chatId]){e.commit("initChatCollection",{chatId:i.chatId})}const s=(()=>{const t=e.getters.findLastChatMessageId(i.chatId);if(d.Type.isNull(t)){return babelHelpers.classPrivateFieldLooseBase(this,re)[re](i.chatId)}return t})();e.commit("addLoadingMessage",{message:i,previousSiblingId:s})},deleteLoadingMessageByMessageId:(e,t)=>{e.commit("deleteLoadingMessageByMessageId",{...t})}}}getMutations(){return{setChatCollection:(e,t)=>{o.Logger.warn("Messages model: setChatCollection mutation",t);t.messages.forEach((t=>{if(!e.chatCollection[t.chatId]){e.chatCollection[t.chatId]=new Set}e.chatCollection[t.chatId].add(t.id)}))},initChatCollection:(e,t)=>{if(!e.chatCollection[t.chatId]){e.chatCollection[t.chatId]=new Set}},store:(e,t)=>{o.Logger.warn("Messages model: store mutation",t);t.messages.forEach((t=>{e.collection[t.id]=t}))},updateWithId:(e,t)=>{o.Logger.warn("Messages model: updateWithId mutation",t);const{id:i,fields:s}=t;const a={...e.collection[i]};delete e.collection[i];e.collection[s.id]={...a,...s,sending:false};if(e.chatCollection[a.chatId].has(i)){e.chatCollection[a.chatId].delete(i);e.chatCollection[a.chatId].add(s.id)}},update:(e,t)=>{o.Logger.warn("Messages model: update mutation",t);const{id:i,fields:s}=t;e.collection[i]={...e.collection[i],...s}},delete:(e,t)=>{var i;o.Logger.warn("Messages model: delete mutation",t);const{id:s}=t;const{chatId:a}=e.collection[s];(i=e.chatCollection[a])==null?void 0:i.delete(s);delete e.collection[s]},clearCollection:(e,t)=>{o.Logger.warn("Messages model: clear collection mutation",t.chatId);e.chatCollection[t.chatId]=new Set},readMessages:(e,t)=>{const{messageIdsToRead:i,messageIdsToView:s}=t;i.forEach((t=>{const i=e.collection[t];if(!i){return}i.unread=false}));s.forEach((t=>{const i=e.collection[t];if(!i){return}i.viewed=true}))},setViewedByOthers:(e,t)=>{const{ids:i}=t;i.forEach((t=>{const i=e.collection[t];if(!i){return}const s=i.authorId===l.Core.getUserId();if(!s||i.viewedByOthers){return}i.viewedByOthers=true}))},addLoadingMessage:(e,t)=>{const{message:i,previousSiblingId:s}=t;e.loadingMessages[s]=i},deleteLoadingMessageByMessageId:(e,t)=>{const i=Object.entries(e.loadingMessages);const s=i.find((([,e])=>e.id===t.messageId));if(s){const[t]=s;delete e.loadingMessages[t]}},updateLoadingMessagePreviousSiblingId:(e,t)=>{const{oldId:i,newId:s}=t;const o=e.loadingMessages[i];if(o){delete e.loadingMessages[i];e.loadingMessages[s]=o}}}}}function ce(e,t){if(t.hasLoadingMessageByPreviousSiblingId(e.id)){const i=t.getLoadingMessageByPreviousSiblingId(e.id);return[i,...babelHelpers.classPrivateFieldLooseBase(this,Q)[Q](i,t)]}return[]}function de(e){const t=d.Type.isPlainObject(e.params)?e.params:{};const i={...e,...t};const s=u.formatFieldsWithConfig(i,H);if(babelHelpers.classPrivateFieldLooseBase(this,Z)[Z](s,t)){s.authorId=babelHelpers.classPrivateFieldLooseBase(this,ee)[ee](s,t)}return s}function ue(e,t){const{NAME:i,USER_ID:s}=t;return Boolean(i&&s&&e.authorId)}function me(e,t){const{NAME:s,USER_ID:o,AVATAR:a}=t;const n=e.authorId;const l=h(o);const c=new i.UserManager;const d=`${r.UserIdNetworkPrefix}-${n}-${l}`;void c.setUsersToModel({networkId:d,name:s,avatar:a!=null?a:""});return d}function ge(e){let t=0;e.forEach((e=>{if(t<e){t=e}}));return t}function he(e,t){let i=null;const s=[...e.chatCollection[t]];for(const t of s){const s=e.collection[t];if(!i){i=s.id}if(n.Utils.text.isTempMessage(s.id)){continue}if(s.id<i){i=s.id}}return i}function fe(e,t){let i=0;const s=[...e.chatCollection[t]];for(const t of s){const s=e.collection[t];if(n.Utils.text.isTempMessage(s.id)){continue}if(s.id>i){i=s.id}}return i}function pe(e,t){let i=0;const s=[...e.chatCollection[t]].sort(((e,t)=>t-e));for(const t of s){const s=e.collection[t];if(n.Utils.text.isTempMessage(s.id)){continue}if(s.authorId===l.Core.getUserId()){i=s.id;break}}return i}function ye(e,t){let i=0;for(const s of e.chatCollection[t]){const t=e.collection[s];if(t.unread){i=s;break}}return i}function Ie(e,t){if(n.Utils.text.isUuidV4(e.id)&&!n.Utils.text.isUuidV4(t.id)){return 1}if(!n.Utils.text.isUuidV4(e.id)&&n.Utils.text.isUuidV4(t.id)){return-1}if(n.Utils.text.isUuidV4(e.id)&&n.Utils.text.isUuidV4(t.id)){return e.date.getTime()-t.date.getTime()}return e.id-t.id}function Ne(e){return`${e}/-1`}const Fe=e=>{const t=[];e.forEach((e=>{const i=Number.parseInt(e,10);if(i>0){t.push(i)}}));return t};const Ce=e=>d.Text.decode(e.toString());const be=e=>{let t="";if(!e||e.endsWith("/js/im/images/blank.gif")){t=""}else if(e.startsWith("http")){t=e}else{t=l.Core.getHost()+e}if(t){t=encodeURI(t)}return t};const Se=e=>{const t=[];if(d.Type.isArray(e)){e.forEach((e=>{const i=Number.parseInt(e,10);if(i>0){t.push(i)}}))}else if(d.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};const Te=e=>{const{countOfViewers:t,firstViewers:i,messageId:s}=e;let o=null;for(const e of i){if(e.userId===l.Core.getUserId()){continue}o={userId:e.userId,userName:e.userName,date:n.Utils.date.cast(e.date)};break}if(t>0&&!o){throw new Error("Chats model: no first viewer for message")}return{countOfViewers:t,firstViewer:o,messageId:s}};const ve=[{fieldName:"dialogId",targetFieldName:"dialogId",checkFunction:m,formatFunction:g},{fieldName:["id","chatId"],targetFieldName:"chatId",checkFunction:m,formatFunction:h},{fieldName:"type",targetFieldName:"type",checkFunction:d.Type.isString},{fieldName:"quoteId",targetFieldName:"quoteId",checkFunction:d.Type.isNumber},{fieldName:"counter",targetFieldName:"counter",checkFunction:m,formatFunction:h},{fieldName:"userCounter",targetFieldName:"userCounter",checkFunction:m,formatFunction:h},{fieldName:"lastId",targetFieldName:"lastReadId",checkFunction:d.Type.isNumber},{fieldName:"markedId",targetFieldName:"markedId",checkFunction:d.Type.isNumber},{fieldName:"lastMessageId",targetFieldName:"lastMessageId",checkFunction:m,formatFunction:h},{fieldName:"lastMessageViews",targetFieldName:"lastMessageViews",checkFunction:d.Type.isPlainObject,formatFunction:Te},{fieldName:"hasPrevPage",targetFieldName:"hasPrevPage",checkFunction:d.Type.isBoolean},{fieldName:"hasNextPage",targetFieldName:"hasNextPage",checkFunction:d.Type.isBoolean},{fieldName:"savedPositionMessageId",targetFieldName:"savedPositionMessageId",checkFunction:d.Type.isNumber},{fieldName:["title","name"],targetFieldName:"name",checkFunction:m,formatFunction:Ce},{fieldName:["owner","ownerId"],targetFieldName:"ownerId",checkFunction:m,formatFunction:h},{fieldName:"avatar",targetFieldName:"avatar",checkFunction:d.Type.isString,formatFunction:be},{fieldName:"color",targetFieldName:"color",checkFunction:d.Type.isString},{fieldName:"extranet",targetFieldName:"extranet",checkFunction:d.Type.isBoolean},{fieldName:"containsCollaber",targetFieldName:"containsCollaber",checkFunction:d.Type.isBoolean},{fieldName:"entityLink",targetFieldName:"entityLink",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,Pe)},{fieldName:"dateCreate",targetFieldName:"dateCreate",formatFunction:n.Utils.date.cast},{fieldName:"public",targetFieldName:"public",checkFunction:d.Type.isPlainObject},{fieldName:"inputActionList",targetFieldName:"inputActionList",checkFunction:d.Type.isPlainObject},{fieldName:"managerList",targetFieldName:"managerList",checkFunction:d.Type.isArray,formatFunction:Fe},{fieldName:"muteList",targetFieldName:"muteList",checkFunction:[d.Type.isArray,d.Type.isPlainObject],formatFunction:Se},{fieldName:"inited",targetFieldName:"inited",checkFunction:d.Type.isBoolean},{fieldName:"loading",targetFieldName:"loading",checkFunction:d.Type.isBoolean},{fieldName:"description",targetFieldName:"description",checkFunction:d.Type.isString},{fieldName:"diskFolderId",targetFieldName:"diskFolderId",checkFunction:d.Type.isNumber},{fieldName:"role",targetFieldName:"role",checkFunction:d.Type.isString,formatFunction:e=>e.toLowerCase()},{fieldName:"permissions",targetFieldName:"permissions",checkFunction:d.Type.isPlainObject},{fieldName:"tariffRestrictions",targetFieldName:"tariffRestrictions",checkFunction:d.Type.isPlainObject},{fieldName:"parentChatId",targetFieldName:"parentChatId",checkFunction:d.Type.isNumber},{fieldName:"backgroundId",targetFieldName:"backgroundId",checkFunction:d.Type.isString},{fieldName:"textFieldEnabled",targetFieldName:"isTextareaEnabled",checkFunction:d.Type.isBoolean}];const Pe=[{fieldName:"type",targetFieldName:"type",checkFunction:d.Type.isString},{fieldName:"url",targetFieldName:"url",checkFunction:d.Type.isString}];const Le=[{fieldName:"delay",targetFieldName:"delay",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber}];var ke=babelHelpers.classPrivateFieldLooseKey("formatFields");class Me extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,ke,{value:xe})}getState(){return{collection:new Map}}getGetters(){return{isEnabled:e=>t=>{var i;return(i=e.collection.has(t))!=null?i:false},getDelay:e=>t=>{var i;return(i=e.collection.get(t))!=null?i:r.AutoDeleteDelay.Off}}}getActions(){return{set:(e,t)=>{let i=t;if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i.forEach((t=>{const i=babelHelpers.classPrivateFieldLooseBase(this,ke)[ke](t);const{delay:s}=i;if(s===r.AutoDeleteDelay.Off){e.commit("delete",i);return}e.commit("set",i)}))}}}getMutations(){return{set:(e,t)=>{const{chatId:i,delay:s}=t;e.collection.set(i,s)},delete:(e,t)=>{const{chatId:i}=t;e.collection.delete(i)}}}}function xe(e){return u.formatFieldsWithConfig(e,Le)}const Ee=[{fieldName:"collabId",targetFieldName:"collabId",checkFunction:d.Type.isNumber},{fieldName:"guestCount",targetFieldName:"guestCount",checkFunction:d.Type.isNumber},{fieldName:"entities",targetFieldName:"entities",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,Be)}];const Be=[{fieldName:"tasks",targetFieldName:"tasks",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,we)},{fieldName:"files",targetFieldName:"files",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,we)},{fieldName:"calendar",targetFieldName:"calendar",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,we)}];const we=[{fieldName:"counter",targetFieldName:"counter",checkFunction:d.Type.isNumber},{fieldName:"url",targetFieldName:"url",checkFunction:d.Type.isStringFilled}];var Ae=babelHelpers.classPrivateFieldLooseKey("formatFields");class He extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,Ae,{value:Oe})}getState(){return{collection:{}}}getElementState(){return{collabId:0,guestCount:0,entities:{tasks:{counter:0,url:""},files:{counter:0,url:""},calendar:{counter:0,url:""}}}}getGetters(){return{getByChatId:e=>t=>{var i;return(i=e.collection[t])!=null?i:this.getElementState()}}}getActions(){return{set:(e,t)=>{const{chatId:i,collabInfo:s}=t;if(!d.Type.isPlainObject(s)){return}e.commit("set",{chatId:i,collabInfo:babelHelpers.classPrivateFieldLooseBase(this,Ae)[Ae](s)})},setCounter:(e,t)=>{const{chatId:i,entity:s,counter:o}=t;const a=e.state;const n=a.collection[i];if(!n||!n.entities[s]){return}e.commit("setCounter",{chatId:i,entity:s,counter:o})},setGuestCount:(e,t)=>{const{chatId:i,guestCount:s}=t;const o=e.state;const a=o.collection[i];if(!a){return}e.commit("setGuestCount",{chatId:i,guestCount:s})}}}getMutations(){return{set:(e,t)=>{const{chatId:i,collabInfo:s}=t;e.collection[i]=s},setCounter:(e,t)=>{const{chatId:i,entity:s,counter:o}=t;const a=e.collection[i];a.entities[s].counter=o},setGuestCount:(e,t)=>{const{chatId:i,guestCount:s}=t;const o=e.collection[i];o.guestCount=s}}}}function Oe(e){return u.formatFieldsWithConfig(e,Ee)}class Ue extends c.BuilderModel{getState(){return{collection:{}}}getGetters(){return{getByDialogId:e=>t=>{const i=e.collection[t];if(!i||i.length===0){return null}return i},isChatActive:e=>t=>{const i=e.collection[t];if(!i){return false}return i.length>0},isActionActive:e=>t=>{const{dialogId:i,type:s,userId:o}=t;if(!e.collection[i]){return false}const a=e.collection[i];return this.isAlreadyActive(a,s,o)}}}getActions(){return{start:(e,t)=>{const{dialogId:i,type:s,userId:o}=t;if(!e.state.collection[i]){e.commit("initCollection",i)}const a=e.state.collection[i];const n=this.isAlreadyActive(a,s,o);if(n){return}e.commit("start",t)},stop:(e,t)=>{const{dialogId:i,type:s,userId:o}=t;const a=e.state.collection[i];if(!a){return}const n=this.isAlreadyActive(a,s,o);if(!n){return}e.commit("stop",t)},stopUserActionsInChat:(e,t)=>{const{dialogId:i}=t;const s=e.state.collection[i];if(!s){return}e.commit("stopUserActionsInChat",t)}}}getMutations(){return{start:(e,t)=>{const{dialogId:i,type:s,userId:o,userName:a}=t;const n=e.collection[i];n.push({type:s,userId:o,userName:a})},stop:(e,t)=>{const{dialogId:i,type:s,userId:o}=t;const a=e.collection[i];e.collection[i]=a.filter((e=>e.userId!==o||e.type!==s))},stopUserActionsInChat:(e,t)=>{const{dialogId:i,userId:s}=t;const o=e.collection[i];e.collection[i]=o.filter((e=>e.userId!==s))},initCollection:(e,t)=>{e.collection[t]=[]}}}isAlreadyActive(e,t,i){return e.some((e=>e.userId===i&&e.type===t))}}class je extends c.BuilderModel{getName(){return"chats"}getNestedModules(){return{collabs:He,inputActions:Ue,autoDelete:Me}}getState(){return{collection:{}}}getElementState(){return{dialogId:"0",chatId:0,type:r.ChatType.chat,name:"",description:"",avatar:"",color:r.Color.base,extranet:false,containsCollaber:false,counter:0,userCounter:0,lastReadId:0,markedId:0,lastMessageId:0,lastMessageViews:{countOfViewers:0,firstViewer:null,messageId:0},savedPositionMessageId:0,managerList:[],inputActionList:{},muteList:[],quoteId:0,ownerId:0,entityLink:{},dateCreate:null,public:{code:"",link:""},inited:false,loading:false,hasPrevPage:false,hasNextPage:false,diskFolderId:0,role:r.UserRole.member,permissions:{manageUi:r.UserRole.none,manageSettings:r.UserRole.none,manageUsersAdd:r.UserRole.none,manageUsersDelete:r.UserRole.none,manageMessages:r.UserRole.member},tariffRestrictions:{isHistoryLimitExceeded:false},parentChatId:0,backgroundId:"",isTextareaEnabled:true}}getGetters(){return{get:e=>(t,i=false)=>{if(!e.collection[t]&&i){return this.getElementState()}if(!e.collection[t]&&!i){return null}return e.collection[t]},getByChatId:e=>(t,i=false)=>{const s=Number.parseInt(t,10);const o=Object.values(e.collection).find((e=>e.chatId===s));if(!o&&i){return this.getElementState()}return o},getQuoteId:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].quoteId},isUser:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].type===r.ChatType.user},getLastReadId:e=>t=>{if(!e.collection[t]){return 0}const{lastReadId:i}=e.collection[t];const s=l.Core.getStore().getters["messages/getById"](i);if(!s){return 0}return i},getInitialMessageId:e=>t=>{if(!e.collection[t]){return 0}const{lastReadId:i,markedId:s}=e.collection[t];if(s===0){return i}return Math.min(i,s)},isSupport:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].type===r.ChatType.support24Question},getBackgroundId:e=>t=>{if(!e.collection[t]){return""}return e.collection[t].backgroundId}}}getActions(){return{set:(e,t)=>{let i=t;if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i.map((e=>this.formatFields(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)=>{let i=t;if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i.map((e=>this.formatFields(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}e.commit("update",{dialogId:t.dialogId,fields:this.formatFields(t.fields)})},delete:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}e.commit("delete",{dialogId:t.dialogId})},clearCounters:e=>{e.commit("clearCounters")},mute:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}const s=l.Core.getUserId();if(i.muteList.includes(s)){return}const o=[...i.muteList,s];e.commit("update",{actionName:"mute",dialogId:t.dialogId,fields:this.formatFields({muteList:o})})},unmute:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}const s=l.Core.getUserId();const o=i.muteList.filter((e=>e!==s));e.commit("update",{actionName:"unmute",dialogId:t.dialogId,fields:this.formatFields({muteList:o})})},setLastMessageViews:(e,t)=>{const{dialogId:i,fields:{userId:s,userName:o,date:a,messageId:r}}=t;const l=e.state.collection[i];if(!l){return}const c={countOfViewers:1,messageId:r,firstViewer:{userId:s,userName:o,date:n.Utils.date.cast(a)}};e.commit("update",{actionName:"setLastMessageViews",dialogId:i,fields:{lastMessageViews:c}})},clearLastMessageViews:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}const{lastMessageViews:s}=this.getElementState();e.commit("update",{actionName:"clearLastMessageViews",dialogId:t.dialogId,fields:{lastMessageViews:s}})},incrementLastMessageViews:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}const s=i.lastMessageViews.countOfViewers+1;e.commit("update",{actionName:"incrementLastMessageViews",dialogId:t.dialogId,fields:{lastMessageViews:{...i.lastMessageViews,countOfViewers:s}}})}}}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]},clearCounters:e=>{Object.keys(e.collection).forEach((t=>{e.collection[t].counter=0;e.collection[t].markedId=0}))}}}formatFields(e){return u.formatFieldsWithConfig(e,ve)}}const Re=e=>{let t="";if(!e||e.endsWith("/js/im/images/blank.gif")){t=""}else if(e.startsWith("http")){t=e}else{t=l.Core.getHost()+e}if(t){t=encodeURI(t)}return t};const De=e=>{const t=[];e.forEach((e=>{const i=Number.parseInt(e,10);if(i>0){t.push(i)}}));return t};const We=e=>{const t={};if(d.Type.isStringFilled(e.workPhone)||d.Type.isNumber(e.workPhone)){t.workPhone=e.workPhone.toString()}if(d.Type.isStringFilled(e.personalMobile)||d.Type.isNumber(e.personalMobile)){t.personalMobile=e.personalMobile.toString()}if(d.Type.isStringFilled(e.personalPhone)||d.Type.isNumber(e.personalPhone)){t.personalPhone=e.personalPhone.toString()}if(d.Type.isStringFilled(e.innerPhone)||d.Type.isNumber(e.innerPhone)){t.innerPhone=e.innerPhone.toString()}return t};const Ge=[{fieldName:"id",targetFieldName:"id",checkFunction:m,formatFunction:h},{fieldName:"networkId",targetFieldName:"id",checkFunction:n.Utils.user.isNetworkUserId},{fieldName:"firstName",targetFieldName:"firstName",checkFunction:d.Type.isString,formatFunction:d.Text.decode},{fieldName:"lastName",targetFieldName:"lastName",checkFunction:d.Type.isString,formatFunction:d.Text.decode},{fieldName:"name",targetFieldName:"name",checkFunction:d.Type.isString,formatFunction:d.Text.decode},{fieldName:"color",targetFieldName:"color",checkFunction:d.Type.isString},{fieldName:"avatar",targetFieldName:"avatar",checkFunction:d.Type.isString,formatFunction:Re},{fieldName:"workPosition",targetFieldName:"workPosition",checkFunction:d.Type.isString,formatFunction:d.Text.decode},{fieldName:"gender",targetFieldName:"gender",checkFunction:d.Type.isString},{fieldName:"birthday",targetFieldName:"birthday",checkFunction:d.Type.isString},{fieldName:"isBirthday",targetFieldName:"isBirthday",checkFunction:d.Type.isBoolean},{fieldName:"isAdmin",targetFieldName:"isAdmin",checkFunction:d.Type.isBoolean},{fieldName:"type",targetFieldName:"type",checkFunction:d.Type.isString},{fieldName:"network",targetFieldName:"network",checkFunction:d.Type.isBoolean},{fieldName:"connector",targetFieldName:"connector",checkFunction:d.Type.isBoolean},{fieldName:"externalAuthId",targetFieldName:"externalAuthId",checkFunction:d.Type.isString},{fieldName:"status",targetFieldName:"status",checkFunction:d.Type.isString},{fieldName:"idle",targetFieldName:"idle",formatFunction:f},{fieldName:"lastActivityDate",targetFieldName:"lastActivityDate",formatFunction:f},{fieldName:"mobileLastDate",targetFieldName:"mobileLastDate",formatFunction:f},{fieldName:"absent",targetFieldName:"absent",formatFunction:f},{fieldName:"isAbsent",targetFieldName:"isAbsent",checkFunction:d.Type.isBoolean},{fieldName:"departments",targetFieldName:"departments",checkFunction:d.Type.isArray,formatFunction:De},{fieldName:"phones",targetFieldName:"phones",checkFunction:d.Type.isPlainObject,formatFunction:We}];const Ve=[{fieldName:"appId",targetFieldName:"appId",checkFunction:d.Type.isString},{fieldName:"type",targetFieldName:"type",checkFunction:d.Type.isString},{fieldName:"code",targetFieldName:"code",checkFunction:d.Type.isString},{fieldName:"isHidden",targetFieldName:"isHidden",checkFunction:d.Type.isBoolean},{fieldName:"isSupportOpenline",targetFieldName:"isHidden",checkFunction:d.Type.isBoolean},{fieldName:"isHuman",targetFieldName:"isHidden",checkFunction:d.Type.isBoolean},{fieldName:"backgroundId",targetFieldName:"backgroundId",checkFunction:d.Type.isString}];class Ke extends c.BuilderModel{getState(){return{collection:{}}}getElementState(){return{code:"",type:r.BotType.bot,appId:"",isHidden:false,isSupportOpenline:false,isHuman:false,backgroundId:""}}getGetters(){return{getByUserId:e=>t=>e.collection[t],isNetwork:e=>t=>{var i;return((i=e.collection[t])==null?void 0:i.type)===r.BotType.network},isSupport:e=>t=>{var i;return((i=e.collection[t])==null?void 0:i.type)===r.BotType.support24},getCopilotUserId:e=>{for(const[t,i]of Object.entries(e.collection)){if(i.code===r.BotCode.copilot){return Number.parseInt(t,10)}}return null},isCopilot:(e,t)=>e=>{const i=t.getCopilotUserId;return i===Number.parseInt(e,10)},getBackgroundId:e=>t=>{if(!e.collection[t]){return""}return e.collection[t].backgroundId}}}getActions(){return{set:(e,t)=>{const{userId:i,botData:s}=t;if(!s){return}e.commit("set",{userId:i,botData:{...this.getElementState(),...this.formatFields(s)}})}}}getMutations(){return{set:(e,t)=>{const{userId:i,botData:s}=t;e.collection[i]=s}}}formatFields(e){const t=y(e);if(t.type===r.RawBotType.human){t.type=r.BotType.bot;t.isHuman=true}const i=[r.RawBotType.openline,r.RawBotType.supervisor];if(i.includes(t.type)){t.type=r.BotType.bot}return u.formatFieldsWithConfig(t,Ve)}}const _e={[r.UserType.bot]:d.Loc.getMessage("IM_MODEL_USERS_CHAT_BOT"),[r.UserType.collaber]:d.Loc.getMessage("IM_MODEL_USERS_COLLABER"),default:d.Loc.getMessage("IM_MODEL_USERS_DEFAULT_NAME")};class ze extends c.BuilderModel{getName(){return"users"}getNestedModules(){return{bots:Ke}}getState(){return{collection:{},absentList:[],absentCheckInterval:null}}getElementState(e={}){const{id:t=0}=e;return{id:t,name:"",firstName:"",lastName:"",avatar:"",color:r.Color.base,workPosition:"",gender:"M",isAdmin:false,type:r.UserType.user,network:false,connector:false,externalAuthId:"default",status:"",idle:false,lastActivityDate:false,mobileLastDate:false,birthday:false,isBirthday:false,absent:false,isAbsent:false,departments:[],phones:{workPhone:"",personalMobile:"",personalPhone:"",innerPhone:""}}}getGetters(){return{get:e=>(t,i=false)=>{const s=e.collection[t];if(!i&&!s){return null}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=>{const i=Number.parseInt(t,10);const s=e.collection[i];if(i<=0||!s){return false}return s.isBirthday},hasVacation:e=>t=>{const i=Number.parseInt(t,10);const s=e.collection[i];if(i<=0||!s){return false}return s.isAbsent},getLastOnline:e=>t=>{const i=Number.parseInt(t,10);const s=e.collection[i];if(i<=0||!s){return""}return n.Utils.user.getLastDateText(s)},getPosition:e=>t=>{var i;const s=Number.parseInt(t,10);const o=e.collection[s];const a=l.Core.getStore().getters["users/bots/isSupport"](s);if(s<=0||!o||a){return""}if(o.workPosition){return o.workPosition}return(i=_e[o.type])!=null?i:_e.default}}}getActions(){return{set:(e,t)=>{let i=t;if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i.map((e=>this.formatFields(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)=>{let i=t;if(!Array.isArray(i)&&d.Type.isPlainObject(i)){i=[i]}i.map((e=>this.formatFields(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)=>{const i=t;i.id=Number.parseInt(i.id,10);const s=e.state.collection[i.id];if(!s){return}const o={...i.fields,id:i.id};e.commit("update",{id:i.id,fields:this.formatFields(o)})},delete:(e,t)=>{e.commit("delete",t.id)},setStatus:(e,t)=>{e.commit("update",{id:l.Core.getUserId(),fields:this.formatFields(t)})}}}getMutations(){return{add:(e,t)=>{e.collection[t.id]=t.fields;s.UserStatusManager.getInstance().onUserUpdate(t.fields)},update:(e,t)=>{e.collection[t.id]={...e.collection[t.id],...t.fields};s.UserStatusManager.getInstance().onUserUpdate(t.fields)},delete:(e,t)=>{delete e.collection[t.id]}}}formatFields(e){const t=u.formatFieldsWithConfig(e,Ge);const i=t.type===r.UserType.bot;if(i){l.Core.getStore().dispatch("users/bots/set",{userId:t.id,botData:e.botData||e.bot_data})}return t}addToAbsentList(e){const t=this.store.state.users;if(!t.absentList.includes(e)){t.absentList.push(e)}}startAbsentCheckInterval(){const e=this.store.state.users;if(e.absentCheckInterval){return}const t=1e3*60*60*24;e.absentCheckInterval=setTimeout((()=>{setInterval((()=>{e.absentList.forEach((t=>{const i=e.collection[t];if(!i){return}const s=Date.now();const o=new Date(i.absent).getTime();if(o<=s){e.absentList=e.absentList.filter((e=>e!==t));i.isAbsent=false}}))}),t)}),n.Utils.date.getTimeToNextMidnight())}}class Xe extends c.BuilderModel{getName(){return"files"}getState(){return{collection:{},temporaryFilesMap:new Map}}getElementState(){return{id:0,chatId:0,name:"File is deleted",date:new Date,type:"file",extension:"",icon:"empty",size:0,image:false,status:r.FileStatus.done,progress:100,authorId:0,authorName:"",urlPreview:"",urlShow:"",urlDownload:"",viewerAttrs:null}}getGetters(){return{get:(e,t)=>(i,s=false)=>{if(!i){return null}if(!s&&!e.collection[i]){return null}const o=e.collection[i];const a=t.hasMappedTemporaryFile({serverFileId:i});if(o&&a){const e=t.getMappedTemporaryFile({serverFileId:i});return{...o,urlPreview:e.urlPreview,urlShow:e.urlShow}}return o},isInCollection:e=>t=>{const{fileId:i}=t;return Boolean(e.collection[i])},hasMappedTemporaryFile:e=>t=>{if(e.temporaryFilesMap.has(t.serverFileId)){const i=e.temporaryFilesMap.get(t.serverFileId);return Object.hasOwn(e.collection,i)}return false},getMappedTemporaryFile:e=>t=>{const{serverFileId:i}=t;if(e.temporaryFilesMap.has(i)){const t=e.temporaryFilesMap.get(i);return e.collection[t]}return null}}}getActions(){return{add:(e,t)=>{const i={...this.getElementState(),...this.validate(t)};e.commit("add",{files:[i]})},set:(e,...t)=>{const i=t.flat().map((e=>({...this.getElementState(),...this.validate(e)})));e.commit("add",{files:i})},update:(e,t)=>{const{id:i,fields:s}=t;const o=e.state.collection[i];if(!o){return false}e.commit("update",{id:i,fields:this.validate(s)});return true},updateWithId:(e,t)=>{const{id:i,fields:s}=t;if(!e.state.collection[i]){return}e.commit("updateWithId",{id:i,fields:this.validate(s)})},delete:(e,t)=>{const{id:i}=t;if(!e.state.collection[i]){return}e.commit("delete",{id:i})},setTemporaryFileMapping:(e,t)=>{e.commit("setTemporaryFileMapping",t)}}}getMutations(){return{add:(e,t)=>{t.files.forEach((t=>{e.collection[t.id]=t}))},update:(e,t)=>{Object.entries(t.fields).forEach((([i,s])=>{e.collection[t.id][i]=s}))},updateWithId:(e,t)=>{const{id:i,fields:s}=t;const o={...e.collection[i]};delete e.collection[i];e.collection[s.id]={...o,...s}},delete:(e,t)=>{o.Logger.warn("Files model: delete mutation",t);const{id:i}=t;delete e.collection[i]},setTemporaryFileMapping:(e,t)=>{e.temporaryFilesMap.set(t.serverFileId,t.temporaryFileId)}}}validate(e,t={}){const i={};if(d.Type.isNumber(e.id)||d.Type.isStringFilled(e.id)){i.id=e.id}if(d.Type.isNumber(e.chatId)||d.Type.isString(e.chatId)){i.chatId=Number.parseInt(e.chatId,10)}if(!d.Type.isUndefined(e.date)){i.date=n.Utils.date.cast(e.date)}if(d.Type.isString(e.type)){i.type=e.type}if(d.Type.isString(e.extension)){i.extension=e.extension.toString();if(i.type==="image"){i.icon="img"}else if(i.type==="video"){i.icon="mov"}else{i.icon=n.Utils.file.getIconTypeByExtension(i.extension)}}if(d.Type.isString(e.name)||d.Type.isNumber(e.name)){i.name=e.name.toString()}if(d.Type.isNumber(e.size)||d.Type.isString(e.size)){i.size=Number.parseInt(e.size,10)}if(d.Type.isBoolean(e.image)){i.image=false}else if(d.Type.isPlainObject(e.image)){i.image={width:0,height:0};if(d.Type.isString(e.image.width)||d.Type.isNumber(e.image.width)){i.image.width=Number.parseInt(e.image.width,10)}if(d.Type.isString(e.image.height)||d.Type.isNumber(e.image.height)){i.image.height=Number.parseInt(e.image.height,10)}if(i.image.width<=0||i.image.height<=0){i.image=false}}if(d.Type.isString(e.status)&&!d.Type.isUndefined(r.FileStatus[e.status])){i.status=e.status}if(d.Type.isNumber(e.progress)||d.Type.isString(e.progress)){i.progress=Number.parseInt(e.progress,10)}if(d.Type.isNumber(e.authorId)||d.Type.isString(e.authorId)){i.authorId=Number.parseInt(e.authorId,10)}if(d.Type.isString(e.authorName)||d.Type.isNumber(e.authorName)){i.authorName=e.authorName.toString()}if(d.Type.isString(e.urlPreview)){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=l.Core.getHost()+e.urlPreview}}if(d.Type.isString(e.urlDownload)){if(!e.urlDownload||e.urlDownload.startsWith("http")||e.urlDownload.startsWith("bx")||e.urlDownload.startsWith("file")||e.urlDownload.startsWith("blob")){i.urlDownload=e.urlDownload}else{i.urlDownload=l.Core.getHost()+e.urlDownload}}if(d.Type.isString(e.urlShow)){if(!e.urlShow||e.urlShow.startsWith("http")||e.urlShow.startsWith("bx")||e.urlShow.startsWith("file")||e.urlShow.startsWith("blob")){i.urlShow=e.urlShow}else{i.urlShow=l.Core.getHost()+e.urlShow}}if(d.Type.isPlainObject(e.viewerAttrs)){i.viewerAttrs=e.viewerAttrs}return i}}const Ye=e=>{if(!e.text||e.text===""){return{text:"",date:null}}return{text:e.text,date:new Date}};const $e=e=>{if(d.Type.isPlainObject(e)){return{isActive:true,originator:e.originatorId,canResend:e.canResend}}return{isActive:false,originator:0,canResend:false}};const qe=[{fieldName:["id","dialogId"],targetFieldName:"dialogId",checkFunction:m,formatFunction:g},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:m},{fieldName:"draft",targetFieldName:"draft",checkFunction:d.Type.isPlainObject,formatFunction:Ye},{fieldName:"invited",targetFieldName:"invitation",checkFunction:[d.Type.isPlainObject,d.Type.isBoolean],formatFunction:$e},{fieldName:"unread",targetFieldName:"unread",checkFunction:d.Type.isBoolean},{fieldName:"pinned",targetFieldName:"pinned",checkFunction:d.Type.isBoolean},{fieldName:"liked",targetFieldName:"liked",checkFunction:d.Type.isBoolean},{fieldName:["defaultUserRecord","isFakeElement"],targetFieldName:"isFakeElement",checkFunction:d.Type.isBoolean},{fieldName:"isBirthdayPlaceholder",targetFieldName:"isBirthdayPlaceholder",checkFunction:d.Type.isBoolean},{fieldName:["dateLastActivity","lastActivityDate"],targetFieldName:"lastActivityDate",checkFunction:[d.Type.isString,d.Type.isDate],formatFunction:n.Utils.date.cast}];class Qe extends c.BuilderModel{getState(){return{collection:{}}}getElementState(){return{dialogId:0,name:"",call:{},state:r.RecentCallStatus.waiting}}getGetters(){return{get:e=>Object.values(e.collection),getCallByDialog:e=>t=>e.collection[t],hasActiveCall:e=>t=>{if(d.Type.isUndefined(t)){const t=Object.values(e.collection).find((e=>e.state===r.RecentCallStatus.joined));return Boolean(t)}const i=Object.values(e.collection).find((e=>e.dialogId===t));if(!i){return false}return i.state===r.RecentCallStatus.joined}}}getActions(){return{addActiveCall:(e,t)=>{const i=Object.values(e.state.collection).find((e=>e.dialogId===t.dialogId||e.call.uuid===t.call.uuid));if(i){e.commit("updateActiveCall",{dialogId:i.dialogId,fields:this.validateActiveCall(t)});return true}e.commit("addActiveCall",this.prepareActiveCall(t))},updateActiveCall:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}e.commit("updateActiveCall",{dialogId:i.dialogId,fields:this.validateActiveCall(t.fields)})},deleteActiveCall:(e,t)=>{const i=e.state.collection[t.dialogId];if(!i){return}e.commit("deleteActiveCall",{dialogId:i.dialogId})}}}getMutations(){return{addActiveCall:(e,t)=>{e.collection[t.dialogId]=t},updateActiveCall:(e,t)=>{e.collection[t.dialogId]={...e.collection[t.dialogId],...t.fields}},deleteActiveCall:(e,t)=>{delete e.collection[t.dialogId]}}}prepareActiveCall(e){return{...this.getElementState(),...this.validateActiveCall(e)}}validateActiveCall(e){const t={};if(d.Type.isStringFilled(e.dialogId)||d.Type.isNumber(e.dialogId)){t.dialogId=e.dialogId}if(d.Type.isStringFilled(e.name)){t.name=e.name}if(d.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}}var Je=babelHelpers.classPrivateFieldLooseKey("formatFields");var Ze=babelHelpers.classPrivateFieldLooseKey("updateUnloadedRecentCounters");var et=babelHelpers.classPrivateFieldLooseKey("updateUnloadedCopilotCounters");var tt=babelHelpers.classPrivateFieldLooseKey("updateUnloadedCollabCounters");var it=babelHelpers.classPrivateFieldLooseKey("updateUnloadedCounters");var st=babelHelpers.classPrivateFieldLooseKey("getMessage");var ot=babelHelpers.classPrivateFieldLooseKey("getDialog");var at=babelHelpers.classPrivateFieldLooseKey("hasTodayMessage");var nt=babelHelpers.classPrivateFieldLooseKey("canDelete");var rt=babelHelpers.classPrivateFieldLooseKey("handleFakeItemWithDraft");var lt=babelHelpers.classPrivateFieldLooseKey("prepareFakeItemWithDraft");var ct=babelHelpers.classPrivateFieldLooseKey("createFakeMessageForDraft");var dt=babelHelpers.classPrivateFieldLooseKey("shouldDeleteItemWithDraft");class ut extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,dt,{value:Tt});Object.defineProperty(this,ct,{value:St});Object.defineProperty(this,lt,{value:bt});Object.defineProperty(this,rt,{value:Ct});Object.defineProperty(this,nt,{value:Ft});Object.defineProperty(this,at,{value:Nt});Object.defineProperty(this,ot,{value:It});Object.defineProperty(this,st,{value:yt});Object.defineProperty(this,it,{value:pt});Object.defineProperty(this,tt,{value:ft});Object.defineProperty(this,et,{value:ht});Object.defineProperty(this,Ze,{value:gt});Object.defineProperty(this,Je,{value:mt})}getName(){return"recent"}getNestedModules(){return{calls:Qe}}getState(){return{collection:{},recentCollection:new Set,unreadCollection:new Set,copilotCollection:new Set,channelCollection:new Set,collabCollection:new Set}}getElementState(){return{dialogId:"0",messageId:0,draft:{text:"",date:null},unread:false,pinned:false,liked:false,invitation:{isActive:false,originator:0,canResend:false},isFakeElement:false,isBirthdayPlaceholder:false,lastActivityDate:null}}getGetters(){return{getRecentCollection:e=>[...e.recentCollection].filter((e=>{const t=this.store.getters["chats/get"](e);return Boolean(t)})).map((t=>e.collection[t])),getUnreadCollection:e=>[...e.unreadCollection].map((t=>e.collection[t])),getCopilotCollection:e=>[...e.copilotCollection].filter((e=>{const t=this.store.getters["chats/get"](e);return Boolean(t)})).map((t=>e.collection[t])),getChannelCollection:e=>[...e.channelCollection].filter((e=>{const t=this.store.getters["chats/get"](e);return Boolean(t)})).map((t=>e.collection[t])),getCollabCollection:e=>[...e.collabCollection].filter((e=>{const t=this.store.getters["chats/get"](e);return Boolean(t)})).map((t=>e.collection[t])),getSortedCollection:e=>{const t=[...e.recentCollection].map((t=>e.collection[t]));return t.sort(((e,t)=>{const i=babelHelpers.classPrivateFieldLooseBase(this,st)[st](e.messageId);const s=babelHelpers.classPrivateFieldLooseBase(this,st)[st](t.messageId);return s.date-i.date}))},get:e=>t=>{if(!e.collection[t]){return null}return e.collection[t]},getMessage:e=>t=>{const i=e.collection[t];if(!i){return null}return babelHelpers.classPrivateFieldLooseBase(this,st)[st](i.messageId)},needsBirthdayPlaceholder:e=>t=>{const i=e.collection[t];if(!i){return false}const s=this.store.getters["chats/get"](t);if(!s||s.type!==r.ChatType.user){return false}const o=this.store.getters["users/hasBirthday"](t);if(!o){return false}const a=Number.parseInt(t,10)===l.Core.getUserId();if(a){return false}const n=this.store.getters["application/settings/get"](r.Settings.recent.showBirthday);const c=babelHelpers.classPrivateFieldLooseBase(this,at)[at](i.messageId);return n&&!c&&s.counter===0},needsVacationPlaceholder:e=>t=>{const i=e.collection[t];if(!i){return false}const s=Number.parseInt(t,10)===l.Core.getUserId();if(s){return false}const o=this.store.getters["chats/get"](t);if(!o||o.type!==r.ChatType.user){return false}const a=this.store.getters["users/hasVacation"](t);if(!a){return false}const n=babelHelpers.classPrivateFieldLooseBase(this,at)[at](i.messageId);return!n&&o.counter===0},getSortDate:e=>t=>{const i=e.collection[t];if(!i){return null}const s=babelHelpers.classPrivateFieldLooseBase(this,st)[st](i.messageId);if(d.Type.isDate(i.draft.date)&&i.draft.date>s.date){return i.draft.date}const o=this.store.getters["recent/needsBirthdayPlaceholder"](i.dialogId);if(o){return n.Utils.date.getStartOfTheDay()}const r=i.lastActivityDate;const l=d.Type.isDate(r)&&r>s.date;if(a.ChannelManager.isChannel(i.dialogId)&&l){return r}return s.date}}}getActions(){return{setRecent:async(e,t)=>{const i=await l.Core.getStore().dispatch("recent/store",t);e.commit("setRecentCollection",i);babelHelpers.classPrivateFieldLooseBase(this,Ze)[Ze](t)},setUnread:async(e,t)=>{const i=await this.store.dispatch("recent/store",t);e.commit("setUnreadCollection",i)},setCopilot:async(e,t)=>{const i=await this.store.dispatch("recent/store",t);e.commit("setCopilotCollection",i);babelHelpers.classPrivateFieldLooseBase(this,et)[et](t)},setChannel:async(e,t)=>{const i=await this.store.dispatch("recent/store",t);e.commit("setChannelCollection",i)},setCollab:async(e,t)=>{const i=await this.store.dispatch("recent/store",t);e.commit("setCollabCollection",i);babelHelpers.classPrivateFieldLooseBase(this,tt)[tt](t)},clearChannelCollection:e=>{e.commit("clearChannelCollection")},store:(e,t)=>{if(!Array.isArray(t)&&d.Type.isPlainObject(t)){t=[t]}const i=[];const s=[];t.map((e=>babelHelpers.classPrivateFieldLooseBase(this,Je)[Je](e))).forEach((t=>{const o={...t};const a=e.state.collection[t.dialogId];if(a){i.push({dialogId:a.dialogId,fields:o})}else{s.push({...this.getElementState(),...o})}}));if(s.length>0){e.commit("add",s)}if(i.length>0){e.commit("update",i)}return[...s,...i].map((e=>e.dialogId))},update:(e,t)=>{const{id:i,fields:s}=t;const o=e.state.collection[i];if(!o){return}e.commit("update",{dialogId:o.dialogId,fields:babelHelpers.classPrivateFieldLooseBase(this,Je)[Je](s)})},unread:(e,t)=>{const i=e.state.collection[t.id];if(!i){return}e.commit("update",{dialogId:i.dialogId,fields:{unread:t.action}})},pin:(e,t)=>{const i=e.state.collection[t.id];if(!i){return}e.commit("update",{dialogId:i.dialogId,fields:{pinned:t.action}})},like:(e,t)=>{const i=e.state.collection[t.id];if(!i){return}const s=i.messageId===Number.parseInt(t.messageId,10);const o=!d.Type.isUndefined(t.messageId)&&t.liked===true;if(o&&!s){return}e.commit("update",{dialogId:i.dialogId,fields:{liked:t.liked===true}})},setDraft:(e,t)=>{const i=!d.Type.isStringFilled(t.text);if(i&&babelHelpers.classPrivateFieldLooseBase(this,dt)[dt](t)){void l.Core.getStore().dispatch("recent/delete",{id:t.id});return}const s=e.state.recentCollection.has(t.id);const o=!s&&!i;if(o){babelHelpers.classPrivateFieldLooseBase(this,rt)[rt](t,e)}const a=e.state.collection[t.id];if(!a){return}void l.Core.getStore().dispatch("recent/update",{id:t.id,fields:{draft:{text:t.text.toString()}}})},delete:(e,t)=>{const i=e.state.collection[t.id];if(!i){return}e.commit("deleteFromRecentCollection",i.dialogId);e.commit("deleteFromCopilotCollection",i.dialogId);e.commit("deleteFromChannelCollection",i.dialogId);e.commit("deleteFromCollabCollection",i.dialogId);const s=babelHelpers.classPrivateFieldLooseBase(this,nt)[nt](i.dialogId);if(!s){return}e.commit("delete",{id:i.dialogId})},clearUnread:e=>{e.commit("clearUnread")}}}getMutations(){return{setRecentCollection:(e,t)=>{t.forEach((t=>{e.recentCollection.add(t)}))},deleteFromRecentCollection:(e,t)=>{e.recentCollection.delete(t)},setUnreadCollection:(e,t)=>{t.forEach((t=>{e.unreadCollection.add(t)}))},setCopilotCollection:(e,t)=>{t.forEach((t=>{e.copilotCollection.add(t)}))},deleteFromCopilotCollection:(e,t)=>{e.copilotCollection.delete(t)},deleteFromChannelCollection:(e,t)=>{e.channelCollection.delete(t)},setChannelCollection:(e,t)=>{t.forEach((t=>{e.channelCollection.add(t)}))},clearChannelCollection:e=>{e.channelCollection=new Set},setCollabCollection:(e,t)=>{t.forEach((t=>{e.collabCollection.add(t)}))},deleteFromCollabCollection:(e,t)=>{e.collabCollection.delete(t)},add:(e,t)=>{if(!Array.isArray(t)&&d.Type.isPlainObject(t)){t=[t]}t.forEach((t=>{e.collection[t.dialogId]=t}))},update:(e,t)=>{if(!Array.isArray(t)&&d.Type.isPlainObject(t)){t=[t]}t.forEach((({dialogId:t,fields:i})=>{const s=e.recentCollection.has(t);const o=i.isFakeElement&&n.Utils.text.isTempMessage(i.messageId);if(s&&o&&!i.invitation){return}const a=e.collection[t];e.collection[t]={...a,...i}}))},delete:(e,t)=>{delete e.collection[t.id]},clearUnread:e=>{Object.keys(e.collection).forEach((t=>{e.collection[t].unread=false}))}}}}function mt(e){const t=d.Type.isPlainObject(e.options)?e.options:{};const i={...e,...t};return u.formatFieldsWithConfig(i,qe)}function gt(e){babelHelpers.classPrivateFieldLooseBase(this,it)[it](e,"counters/setUnloadedChatCounters")}function ht(e){babelHelpers.classPrivateFieldLooseBase(this,it)[it](e,"counters/setUnloadedCopilotCounters")}function ft(e){babelHelpers.classPrivateFieldLooseBase(this,it)[it](e,"counters/setUnloadedCollabCounters")}function pt(e,t){if(!Array.isArray(e)&&d.Type.isPlainObject(e)){e=[e]}const i={};const s=e.map((e=>u.convertObjectKeysToCamelCase(e)));s.forEach((e=>{i[e.chatId]=0}));void l.Core.getStore().dispatch(t,i)}function yt(e){return l.Core.getStore().getters["messages/getById"](e)}function It(e){return l.Core.getStore().getters["chats/get"](e)}function Nt(e){const t=babelHelpers.classPrivateFieldLooseBase(this,st)[st](e);const i=n.Utils.text.isUuidV4(t.id)||t.id>0;return i&&n.Utils.date.isToday(t.date)}function Ft(e){const t=[r.ChatType.openChannel];const{type:i}=babelHelpers.classPrivateFieldLooseBase(this,ot)[ot](e);return!t.includes(i)}function Ct(e,t){const i=t.state.collection[e.id];if(!i){t.commit("add",{...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,lt)[lt](e)})}t.commit("setRecentCollection",[e.id.toString()])}function bt(e){const t=babelHelpers.classPrivateFieldLooseBase(this,ct)[ct](e.id);return babelHelpers.classPrivateFieldLooseBase(this,Je)[Je]({dialogId:e.id.toString(),draft:{text:e.text.toString()},messageId:t})}function St(e){const t=`${r.FakeDraftMessagePrefix}-${e}`;void l.Core.getStore().dispatch("messages/store",{id:t,date:new Date});return t}function Tt(e){const t=l.Core.getStore().state.recent.collection[e.id];return t&&!d.Type.isStringFilled(e.text)&&t.messageId.toString().startsWith(r.FakeDraftMessagePrefix)}class vt extends c.BuilderModel{getName(){return"notifications"}getState(){return{collection:new Map,searchCollection:new Map,unreadCounter:0}}getElementState(){return{id:0,authorId:0,date:new Date,title:"",text:"",params:{},replaces:[],notifyButtons:[],sectionCode:r.NotificationTypesCodes.simple,read:false,settingName:"im|default"}}getGetters(){return{getSortedCollection:e=>[...e.collection.values()].sort(this.sortByType),getSearchResultCollection:e=>[...e.searchCollection.values()].sort(this.sortByType),getConfirmsCount:e=>[...e.collection.values()].filter((e=>e.sectionCode===r.NotificationTypesCodes.confirm)).length,getById:e=>t=>{if(d.Type.isString(t)){t=Number.parseInt(t,10)}const i=e.collection.get(t);if(!i){return false}return i},getCounter:e=>e.unreadCounter}}getActions(){return{initialSet:(e,t)=>{if(d.Type.isNumber(t.total_unread_count)){e.commit("setCounter",t.total_unread_count)}if(!d.Type.isArrayFilled(t.notifications)){return}const i=[];const s=[];const o=l.Core.getUserId();t.notifications.map((e=>vt.validate(e,o))).forEach((t=>{const o=e.state.collection.get(t.id);if(o){i.push({id:o.id,fields:{...t}})}else{s.push({...this.getElementState(),...t})}}));if(s.length>0){e.commit("add",s)}if(i.length>0){e.commit("update",i)}},set:(e,t)=>{if(!Array.isArray(t)&&d.Type.isPlainObject(t)){t=[t]}const i=[];const s=[];const o=l.Core.getUserId();t.map((e=>vt.validate(e,o))).forEach((t=>{const o=e.state.collection.get(t.id);if(o){i.push({id:o.id,fields:{...t}})}else{s.push({...this.getElementState(),...t})}}));if(s.length>0){e.commit("add",s)}if(i.length>0){e.commit("update",i)}},setSearchResult:(e,t)=>{const i=[];const s=[];let{notifications:o}=t;const a=!!t.skipValidation;if(!a){const e=l.Core.getUserId();o=o.map((t=>vt.validate(t,e)))}o.forEach((t=>{const o=e.state.searchCollection.get(t.id);if(o){i.push({id:o.id,fields:{...t}})}else{s.push({...this.getElementState(),...t})}}));if(s.length>0){e.commit("addSearchResult",s)}if(i.length>0){e.commit("updateSearchResult",i)}},read:(e,t)=>{t.ids.forEach((i=>{const s=e.state.collection.get(i);if(!s||s.read===t.read){return false}if(t.read){e.commit("decreaseCounter")}else{e.commit("increaseCounter")}e.commit("read",{id:s.id,read:t.read})}))},readAll:e=>{e.commit("readAll");e.commit("setCounter",0)},delete:(e,t)=>{const i=e.state.collection.get(t.id);if(!i){return}if(i.read===false){e.commit("decreaseCounter")}e.commit("delete",{id:i.id})},deleteFromSearch:(e,t)=>{const i=e.state.searchCollection.get(t.id);if(!i){return}e.commit("delete",{id:i.id})},clearSearchResult:e=>{e.commit("clearSearchResult")},setCounter:(e,t)=>{e.commit("setCounter",t)}}}getMutations(){return{add:(e,t)=>{t.forEach((t=>{e.collection.set(t.id,t)}))},addSearchResult:(e,t)=>{t.forEach((t=>{e.searchCollection.set(t.id,t)}))},update:(e,t)=>{t.forEach((t=>{e.collection.set(t.id,{...e.collection.get(t.id),...t.fields})}))},updateSearchResult:(e,t)=>{t.forEach((t=>{e.searchCollection.set(t.id,{...e.searchCollection.get(t.id),...t.fields})}))},delete:(e,t)=>{e.collection.delete(t.id);e.searchCollection.delete(t.id)},read:(e,t)=>{e.collection.set(t.id,{...e.collection.get(t.id),read:t.read});e.searchCollection.set(t.id,{...e.collection.get(t.id),read:t.read})},readAll:e=>{[...e.collection.values()].forEach((e=>{if(!e.read){e.read=true}}))},setCounter:(e,t)=>{e.unreadCounter=Number.parseInt(t,10)},decreaseCounter:e=>{if(e.unreadCounter>0){e.unreadCounter--}},increaseCounter:e=>{e.unreadCounter++},clearSearchResult:e=>{e.searchCollection.clear()}}}static validate(e){const t={};if(d.Type.isString(e.id)||d.Type.isNumber(e.id)){t.id=e.id}if(d.Type.isNumber(e.author_id)){t.authorId=e.author_id}else if(d.Type.isNumber(e.userId)){t.authorId=e.userId}if(!d.Type.isNil(e.date)){t.date=n.Utils.date.cast(e.date)}if(d.Type.isString(e.notify_title)){t.title=e.notify_title}else if(d.Type.isString(e.title)){t.title=e.title}if(d.Type.isString(e.text)||d.Type.isNumber(e.text)){t.text=d.Text.decode(e.text.toString())}if(d.Type.isObjectLike(e.params)){t.params=y(e.params)}if(d.Type.isArray(e.replaces)){t.replaces=e.replaces}if(!d.Type.isNil(e.notify_buttons)){t.notifyButtons=JSON.parse(e.notify_buttons)}else if(!d.Type.isNil(e.buttons)){t.notifyButtons=e.buttons.map((e=>({COMMAND:"notifyConfirm",COMMAND_PARAMS:`${t.id}|${e.VALUE}`,TEXT:`${e.TITLE}`,TYPE:"BUTTON",DISPLAY:"LINE",BG_COLOR:e.VALUE==="Y"?"#8bc84b":"#ef4b57",TEXT_COLOR:"#fff"})))}if(e.notify_type===r.NotificationTypesCodes.confirm||e.type===r.NotificationTypesCodes.confirm){t.sectionCode=r.NotificationTypesCodes.confirm}else{t.sectionCode=r.NotificationTypesCodes.simple}if(!d.Type.isNil(e.notify_read)){t.read=e.notify_read==="Y"}else if(!d.Type.isNil(e.read)){t.read=e.read==="Y"}if(d.Type.isString(e.setting_name)){t.settingName=e.setting_name}else if(d.Type.isString(e.settingName)){t.settingName=e.settingName}return t}sortByType(e,t){if(e.sectionCode===r.NotificationTypesCodes.confirm&&t.sectionCode!==r.NotificationTypesCodes.confirm){return-1}else if(e.sectionCode!==r.NotificationTypesCodes.confirm&&t.sectionCode===r.NotificationTypesCodes.confirm){return 1}else{return t.id-e.id}}}const Pt=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"authorId",targetFieldName:"authorId",checkFunction:d.Type.isNumber},{fieldName:"url",targetFieldName:"source",checkFunction:d.Type.isPlainObject,formatFunction:e=>{var t;return(t=e.source)!=null?t:""}},{fieldName:"dateCreate",targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"url",targetFieldName:"richData",checkFunction:d.Type.isPlainObject,formatFunction:e=>T(e.richData,Lt)}];const Lt=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"description",targetFieldName:"description",checkFunction:d.Type.isString},{fieldName:"link",targetFieldName:"link",checkFunction:d.Type.isString},{fieldName:"name",targetFieldName:"name",checkFunction:d.Type.isString},{fieldName:"previewUrl",targetFieldName:"previewUrl",checkFunction:d.Type.isString},{fieldName:"type",targetFieldName:"type",checkFunction:d.Type.isString}];class kt extends c.BuilderModel{getState(){return{collection:{},collectionSearch:{},counters:{},historyLimitExceededCollection:{}}}getElementState(){return{id:0,messageId:0,chatId:0,authorId:0,source:"",date:new Date,richData:{id:null,description:null,link:null,name:null,previewUrl:null,type:null}}}getChatState(){return{items:new Map,hasNextPage:true}}getGetters(){return{get:e=>t=>{if(!e.collection[t]){return[]}return[...e.collection[t].items.values()].sort(((e,t)=>t.id-e.id))},getSize:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].items.size},getCounter:e=>t=>{if(!e.counters[t]){return 0}return e.counters[t]},hasNextPage:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].hasNextPage},hasNextPageSearch:e=>t=>{if(!e.collectionSearch[t]){return false}return e.collectionSearch[t].hasNextPage},getSearchResultCollectionSize:e=>t=>{if(!e.collectionSearch[t]){return 0}return e.collectionSearch[t].items.size},getSearchResultCollection:e=>t=>{if(!e.collectionSearch[t]){return[]}return[...e.collectionSearch[t].items.values()].sort(((e,t)=>t.id-e.id))},isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{setCounter:(e,t)=>{if(!d.Type.isNumber(t.counter)||!d.Type.isNumber(t.chatId)){return}e.commit("setCounter",t)},set:(e,t)=>{const{chatId:i,links:s,hasNextPage:o,isHistoryLimitExceeded:a=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHasNextPage",{chatId:i,hasNextPage:o});e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:a});s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("add",{chatId:i,link:s})}))},setSearch:(e,t)=>{const{chatId:i,links:s,hasNextPage:o,isHistoryLimitExceeded:a=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHasNextPageSearch",{chatId:i,hasNextPage:o});e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:a});s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("addSearch",{chatId:i,link:s})}))},clearSearch:e=>{e.commit("clearSearch",{})},delete:(e,t)=>{const{chatId:i,id:s}=t;if(!d.Type.isNumber(s)||!d.Type.isNumber(i)){return}if(!e.state.collection[i]||!e.state.collection[i].items.has(s)){return}e.commit("delete",{chatId:i,id:s})}}}getMutations(){return{setHasNextPage:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].hasNextPage=s},setHasNextPageSearch:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].hasNextPage=s},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s},setCounter:(e,t)=>{const{chatId:i,counter:s}=t;e.counters[i]=s},add:(e,t)=>{const{chatId:i,link:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].items.set(s.id,s)},addSearch:(e,t)=>{const{chatId:i,link:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].items.set(s.id,s)},clearSearch:e=>{e.collectionSearch={}},delete:(e,t)=>{const{chatId:i,id:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(o){e.collectionSearch[i].items.delete(s)}e.collection[i].items.delete(s);e.counters[i]--}}}formatFields(e){return T(e,Pt)}}const Mt=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"authorId",targetFieldName:"authorId",checkFunction:d.Type.isNumber},{fieldName:"dateCreate",targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast}];class xt extends c.BuilderModel{getState(){return{collection:{},counters:{},collectionSearch:{},historyLimitExceededCollection:{}}}getElementState(){return{id:0,messageId:0,chatId:0,authorId:0,date:new Date}}getChatState(){return{items:new Map,hasNextPage:true,lastId:0}}getGetters(){return{get:e=>t=>{if(!e.collection[t]){return[]}return[...e.collection[t].items.values()].sort(((e,t)=>t.id-e.id))},getSize:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].items.size},getCounter:e=>t=>{if(e.counters[t]){return e.counters[t]}return 0},isFavoriteMessage:e=>(t,i)=>{if(!e.collection[t]){return false}const s=Object.fromEntries(e.collection[t].items);const o=Object.values(s).find((e=>e.messageId===i));return Boolean(o)},hasNextPage:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].hasNextPage},getLastId:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].lastId},getSearchResultCollectionLastId:e=>t=>{if(!e.collectionSearch[t]){return 0}return e.collectionSearch[t].lastId},hasNextPageSearch:e=>t=>{if(!e.collectionSearch[t]){return false}return e.collectionSearch[t].hasNextPage},getSearchResultCollection:e=>t=>{if(!e.collectionSearch[t]){return[]}return[...e.collectionSearch[t].items.values()].sort(((e,t)=>t.id-e.id))},isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{setCounter:(e,t)=>{if(!d.Type.isNumber(t.counter)||!d.Type.isNumber(t.chatId)){return}e.commit("setCounter",t)},set:(e,t)=>{if(d.Type.isNumber(t.favorites)){t.favorites=[t.favorites]}const{chatId:i,favorites:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});e.commit("setHasNextPage",{chatId:i,hasNextPage:o});e.commit("setLastId",{chatId:i,lastId:a});s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("add",{chatId:i,favorite:s})}))},delete:(e,t)=>{const{chatId:i,id:s}=t;if(!d.Type.isNumber(s)||!d.Type.isNumber(i)){return}if(!e.state.collection[i]||!e.state.collection[i].items.has(s)){return}e.commit("delete",{chatId:i,id:s})},deleteByMessageId:(e,t)=>{const{chatId:i,messageId:s}=t;if(!e.state.collection[i]){return}const o=e.state.collection[i].items;let a=null;for(const[e,t]of o){if(t.messageId===s){a=e;break}}if(!a){return}e.commit("delete",{chatId:i,id:a})},setSearch:(e,t)=>{const{chatId:i,favorites:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});e.commit("setHasNextPageSearch",{chatId:i,hasNextPage:o});e.commit("setLastIdSearch",{chatId:i,lastId:a});s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("addSearch",{chatId:i,favorite:s})}))},clearSearch:e=>{e.commit("clearSearch",{})}}}getMutations(){return{setHasNextPage:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].hasNextPage=s},setHasNextPageSearch:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].hasNextPage=s},setCounter:(e,t)=>{const{chatId:i,counter:s}=t;e.counters[i]=s},setLastId:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].lastId=s},add:(e,t)=>{const{chatId:i,favorite:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].items.set(s.id,s)},addSearch:(e,t)=>{const{chatId:i,favorite:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].items.set(s.id,s)},clearSearch:e=>{e.collectionSearch={}},setLastIdSearch:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].lastId=s},delete:(e,t)=>{const{chatId:i,id:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(o){e.collectionSearch[i].items.delete(s)}e.collection[i].items.delete(s);e.counters[i]--},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s}}}formatFields(e){return T(e,Mt)}}class Et extends c.BuilderModel{getState(){return{collection:{}}}getChatState(){return{users:new Set,hasNextPage:true,nextCursor:null,inited:false}}getGetters(){return{get:e=>t=>{if(!e.collection[t]){return[]}return[...e.collection[t].users]},getSize:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].users.size},hasNextPage:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].hasNextPage},getNextCursor:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].nextCursor},getInited:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].inited}}}getActions(){return{set:(e,t)=>{const{chatId:i,users:s,hasNextPage:o,nextCursor:a}=t;if(!d.Type.isNil(o)){e.commit("setHasNextPage",{chatId:i,hasNextPage:o})}e.commit("setInited",{chatId:i,inited:true});if(s.length>0){e.commit("set",{chatId:i,users:s})}},setNextCursor:(e,t)=>{e.commit("setNextCursor",t)},delete:(e,t)=>{const{chatId:i,userId:s}=t;if(!d.Type.isNumber(i)||!d.Type.isNumber(s)){return}if(!e.state.collection[i]){return}e.commit("delete",{userId:s,chatId:i})}}}getMutations(){return{set:(e,t)=>{const{chatId:i,users:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}s.forEach((t=>{e.collection[i].users.add(t)}))},setHasNextPage:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].hasNextPage=s},setNextCursor:(e,t)=>{const{chatId:i,nextCursor:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].nextCursor=s},setInited:(e,t)=>{const{chatId:i,inited:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].inited=s},delete:(e,t)=>{const{chatId:i,userId:s}=t;e.collection[i].users.delete(s)}}}}class Bt extends c.BuilderModel{getState(){return{historyLimitExceededCollection:{}}}getGetters(){return{isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s=false}=t;e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:s})}}}getMutations(){return{setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s}}}}const wt=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"authorId",targetFieldName:"authorId",checkFunction:d.Type.isNumber},{fieldName:"dateCreate",targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"task",targetFieldName:"task",checkFunction:d.Type.isPlainObject,formatFunction:e=>T(e,At)}];const At=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"title",targetFieldName:"title",checkFunction:d.Type.isString},{fieldName:"creatorId",targetFieldName:"creatorId",checkFunction:d.Type.isNumber},{fieldName:"responsibleId",targetFieldName:"responsibleId",checkFunction:d.Type.isNumber},{fieldName:"statusTitle",targetFieldName:"statusTitle",checkFunction:d.Type.isString},{fieldName:"deadline",targetFieldName:"deadline",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"state",targetFieldName:"state",checkFunction:d.Type.isString},{fieldName:"color",targetFieldName:"color",checkFunction:d.Type.isString},{fieldName:"source",targetFieldName:"source",checkFunction:d.Type.isString}];class Ht extends c.BuilderModel{getState(){return{collection:{},collectionSearch:{},historyLimitExceededCollection:{}}}getElementState(){return{id:0,messageId:0,chatId:0,authorId:0,date:new Date,task:{id:0,title:"",creatorId:0,responsibleId:0,status:0,statusTitle:"",deadline:new Date,state:"",color:"",source:""}}}getChatState(){return{items:new Map,hasNextPage:true,lastId:0}}getGetters(){return{get:e=>t=>{if(!e.collection[t]){return[]}return[...e.collection[t].items.values()].sort(((e,t)=>t.id-e.id))},getSearchResultCollection:e=>t=>{if(!e.collectionSearch[t]){return[]}return[...e.collectionSearch[t].items.values()].sort(((e,t)=>t.id-e.id))},getSize:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].items.size},hasNextPage:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].hasNextPage},getLastId:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].lastId},getSearchResultCollectionLastId:e=>t=>{if(!e.collectionSearch[t]){return false}return e.collectionSearch[t].lastId},isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{set:(e,t)=>{const{chatId:i,tasks:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});if(!d.Type.isNil(o)){e.commit("setHasNextPage",{chatId:i,hasNextPage:o})}if(!d.Type.isNil(a)){e.commit("setLastId",{chatId:i,lastId:a})}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("add",{chatId:i,task:s})}))},clearSearch:e=>{e.commit("clearSearch",{})},setSearch:(e,t)=>{const{chatId:i,tasks:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});if(!d.Type.isNil(o)){e.commit("setHasNextPageSearch",{chatId:i,hasNextPage:o})}if(!d.Type.isNil(a)){e.commit("setLastIdSearch",{chatId:i,lastId:a})}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("addSearch",{chatId:i,task:s})}))},delete:(e,t)=>{const{chatId:i,id:s}=t;if(!d.Type.isNumber(i)||!d.Type.isNumber(s)){return}if(!e.state.collection[i]){return}e.commit("delete",{id:s,chatId:i})}}}getMutations(){return{add:(e,t)=>{const{chatId:i,task:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].items.set(s.id,s)},addSearch:(e,t)=>{const{chatId:i,task:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].items.set(s.id,s)},delete:(e,t)=>{const{id:i,chatId:s}=t;const o=!d.Type.isNil(e.collectionSearch[s]);if(o){e.collectionSearch[s].items.delete(i)}e.collection[s].items.delete(i)},setHasNextPage:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].hasNextPage=s},setHasNextPageSearch:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].hasNextPage=s},setLastId:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].lastId=s},setLastIdSearch:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].lastId=s},clearSearch:e=>{e.collectionSearch={}},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s}}}formatFields(e){return T(e,wt)}}const Ot=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"authorId",targetFieldName:"authorId",checkFunction:d.Type.isNumber},{fieldName:"dateCreate",targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"calendar",targetFieldName:"meeting",checkFunction:d.Type.isPlainObject,formatFunction:e=>T(e,Ut)}];const Ut=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"title",targetFieldName:"title",checkFunction:d.Type.isString},{fieldName:"dateFrom",targetFieldName:"dateFrom",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"dateTo",targetFieldName:"dateTo",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:"source",targetFieldName:"source",checkFunction:d.Type.isString}];class jt extends c.BuilderModel{getState(){return{collection:{},collectionSearch:{},historyLimitExceededCollection:{}}}getElementState(){return{id:0,messageId:0,chatId:0,authorId:0,date:new Date,meeting:{id:0,title:"",dateFrom:new Date,dateTo:new Date,source:""}}}getChatState(){return{items:new Map,hasNextPage:true,lastId:0}}getGetters(){return{get:e=>t=>{if(!e.collection[t]){return[]}return[...e.collection[t].items.values()].sort(((e,t)=>t.id-e.id))},getSearchResultCollection:e=>t=>{if(!e.collectionSearch[t]){return[]}return[...e.collectionSearch[t].items.values()].sort(((e,t)=>t.id-e.id))},getSize:e=>t=>{if(!e.collection[t]){return 0}return e.collection[t].items.size},hasNextPage:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].hasNextPage},getLastId:e=>t=>{if(!e.collection[t]){return false}return e.collection[t].lastId},getSearchResultCollectionLastId:e=>t=>{if(!e.collectionSearch[t]){return false}return e.collectionSearch[t].lastId},isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{set:(e,t)=>{const{chatId:i,meetings:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});if(!d.Type.isNil(o)){e.commit("setHasNextPage",{chatId:i,hasNextPage:o})}if(!d.Type.isNil(a)){e.commit("setLastId",{chatId:i,lastId:a})}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("add",{chatId:i,meeting:s})}))},setSearch:(e,t)=>{const{chatId:i,meetings:s,hasNextPage:o,lastId:a,isHistoryLimitExceeded:n=false}=t;if(!d.Type.isNumber(i)){return}e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:n});if(!d.Type.isNil(o)){e.commit("setHasNextPageSearch",{chatId:i,hasNextPage:o})}if(!d.Type.isNil(a)){e.commit("setLastIdSearch",{chatId:i,lastId:a})}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("addSearch",{chatId:i,meeting:s})}))},delete:(e,t)=>{const{chatId:i,id:s}=t;if(!d.Type.isNumber(i)||!d.Type.isNumber(s)){return}if(!e.state.collection[i]){return}e.commit("delete",{id:s,chatId:i})},clearSearch:e=>{e.commit("clearSearch",{})}}}getMutations(){return{add:(e,t)=>{const{chatId:i,meeting:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].items.set(s.id,s)},addSearch:(e,t)=>{const{chatId:i,meeting:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].items.set(s.id,s)},delete:(e,t)=>{const{id:i,chatId:s}=t;const o=!d.Type.isNil(e.collectionSearch[s]);if(o){e.collectionSearch[s].items.delete(i)}e.collection[s].items.delete(i)},setHasNextPage:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].hasNextPage=s},setHasNextPageSearch:(e,t)=>{const{chatId:i,hasNextPage:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].hasNextPage=s},setLastId:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collection[i]);if(!o){e.collection[i]=this.getChatState()}e.collection[i].lastId=s},setLastIdSearch:(e,t)=>{const{chatId:i,lastId:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);if(!o){e.collectionSearch[i]=this.getChatState()}e.collectionSearch[i].lastId=s},clearSearch:e=>{e.collectionSearch={}},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s}}}formatFields(e){return T(e,Ot)}}const Rt=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"messageId",targetFieldName:"messageId",checkFunction:d.Type.isNumber},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"authorId",targetFieldName:"authorId",checkFunction:d.Type.isNumber},{fieldName:["dateCreate","date"],targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast},{fieldName:["fileId","id"],targetFieldName:"fileId",checkFunction:d.Type.isNumber}];class Dt extends c.BuilderModel{getState(){return{collection:{},collectionSearch:{},historyLimitExceededCollection:{}}}getElementState(){return{id:0,messageId:0,chatId:0,authorId:0,date:new Date,fileId:0}}getChatState(){return{items:new Map,hasNextPage:true,lastId:0}}getGetters(){return{get:e=>(t,i)=>{if(!e.collection[t]||!e.collection[t][i]){return[]}return[...e.collection[t][i].items.values()].sort(((e,t)=>t.id-e.id))},getSearchResultCollection:e=>(t,i)=>{if(!e.collectionSearch[t]||!e.collectionSearch[t][i]){return[]}return[...e.collectionSearch[t][i].items.values()].sort(((e,t)=>t.id-e.id))},getLatest:(e,t,i,s)=>t=>{if(!e.collection[t]){return[]}let i=[];let o=[];let a=[];let n=[];if(e.collection[t][r.SidebarFileGroups.media]){i=[...e.collection[t][r.SidebarFileGroups.media].items.values()]}if(e.collection[t][r.SidebarFileGroups.audio]){o=[...e.collection[t][r.SidebarFileGroups.audio].items.values()]}if(e.collection[t][r.SidebarFileGroups.file]){a=[...e.collection[t][r.SidebarFileGroups.file].items.values()]}if(e.collection[t][r.SidebarFileGroups.brief]){n=[...e.collection[t][r.SidebarFileGroups.brief].items.values()]}const l=[i,o,a,n].flat().sort(((e,t)=>t.id-e.id));return this.getTopThreeCompletedFiles(l,s)},getLatestUnsorted:(e,t,i,s)=>t=>{if(!e.collection[t]){return[]}let i=[];if(e.collection[t][r.SidebarFileGroups.fileUnsorted]){i=[...e.collection[t][r.SidebarFileGroups.fileUnsorted].items.values()]}const o=i.sort(((e,t)=>t.id-e.id));return this.getTopThreeCompletedFiles(o,s)},getSize:e=>(t,i)=>{if(!e.collection[t]||!e.collection[t][i]){return 0}return e.collection[t][i].items.size},hasNextPage:e=>(t,i)=>{if(!e.collection[t]||!e.collection[t][i]){return false}return e.collection[t][i].hasNextPage},hasNextPageSearch:e=>(t,i)=>{if(!e.collectionSearch[t]||!e.collectionSearch[t][i]){return false}return e.collectionSearch[t][i].hasNextPage},getLastId:e=>(t,i)=>{if(!e.collection[t]||!e.collection[t][i]){return false}return e.collection[t][i].lastId},getSearchResultCollectionLastId:e=>(t,i)=>{if(!e.collectionSearch[t]||!e.collectionSearch[t][i]){return false}return e.collectionSearch[t][i].lastId},isHistoryLimitExceeded:e=>t=>{var i;const s=l.Core.getStore().getters["application/tariffRestrictions/isHistoryAvailable"];if(s){return false}return(i=e.historyLimitExceededCollection[t])!=null?i:false}}}getActions(){return{set:(e,t)=>{const{chatId:i,files:s,group:o}=t;if(!d.Type.isArrayFilled(s)||!d.Type.isNumber(i)){return}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("add",{chatId:i,group:o,file:s})}))},setSearch:(e,t)=>{const{chatId:i,files:s,group:o}=t;if(!d.Type.isArrayFilled(s)||!d.Type.isNumber(i)){return}s.forEach((t=>{const s={...this.getElementState(),...this.formatFields(t)};e.commit("addSearch",{chatId:i,group:o,file:s})}))},delete:(e,t)=>{const{chatId:i,id:s}=t;if(!d.Type.isNumber(s)||!d.Type.isNumber(i)){return}if(!e.state.collection[i]){return}e.commit("delete",{chatId:i,id:s})},setHasNextPage:(e,t)=>{const{chatId:i,group:s,hasNextPage:o}=t;if(!d.Type.isNumber(i)){return}if(!e.state.collection[i]){return}e.commit("setHasNextPage",{chatId:i,group:s,hasNextPage:o})},setHasNextPageSearch:(e,t)=>{const{chatId:i,group:s,hasNextPage:o}=t;if(!d.Type.isNumber(i)){return}if(!e.state.collectionSearch[i]){return}e.commit("setHasNextPageSearch",{chatId:i,group:s,hasNextPage:o})},setLastId:(e,t)=>{const{chatId:i,group:s,lastId:o}=t;if(!d.Type.isNumber(i)){return}if(!e.state.collection[i]){return}e.commit("setLastId",{chatId:i,group:s,lastId:o})},setLastIdSearch:(e,t)=>{const{chatId:i,group:s,lastId:o}=t;if(!d.Type.isNumber(i)){return}if(!e.state.collectionSearch[i]){return}e.commit("setLastIdSearch",{chatId:i,group:s,lastId:o})},clearSearch:e=>{e.commit("clearSearch",{})},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s=false}=t;e.commit("setHistoryLimitExceeded",{chatId:i,isHistoryLimitExceeded:s})}}}getMutations(){return{add:(e,t)=>{const{chatId:i,file:s,group:o}=t;if(!e.collection[i]){e.collection[i]={}}if(!e.collection[i][o]){e.collection[i][o]=this.getChatState()}e.collection[i][o].items.set(s.id,s)},addSearch:(e,t)=>{const{chatId:i,file:s,group:o}=t;if(!e.collectionSearch[i]){e.collectionSearch[i]={}}if(!e.collectionSearch[i][o]){e.collectionSearch[i][o]=this.getChatState()}e.collectionSearch[i][o].items.set(s.id,s)},delete:(e,t)=>{const{chatId:i,id:s}=t;const o=!d.Type.isNil(e.collectionSearch[i]);Object.values(r.SidebarFileGroups).forEach((t=>{if(e.collection[i][t]&&e.collection[i][t].items.has(s)){e.collection[i][t].items.delete(s);if(o){e.collectionSearch[i][t].items.delete(s)}}}))},setHasNextPage:(e,t)=>{const{chatId:i,group:s,hasNextPage:o}=t;if(!e.collection[i]){e.collection[i]={}}const a=!d.Type.isNil(e.collection[i][s]);if(!a){e.collection[i][s]=this.getChatState()}e.collection[i][s].hasNextPage=o},setHasNextPageSearch:(e,t)=>{const{chatId:i,group:s,hasNextPage:o}=t;if(!e.collectionSearch[i]){e.collectionSearch[i]={}}const a=!d.Type.isNil(e.collectionSearch[i][s]);if(!a){e.collectionSearch[i][s]=this.getChatState()}e.collectionSearch[i][s].hasNextPage=o},setLastId:(e,t)=>{const{chatId:i,group:s,lastId:o}=t;if(!e.collection[i]){e.collection[i]={}}const a=!d.Type.isNil(e.collection[i][s]);if(!a){e.collection[i][s]=this.getChatState()}e.collection[i][s].lastId=o},setLastIdSearch:(e,t)=>{const{chatId:i,group:s,lastId:o}=t;if(!e.collectionSearch[i]){e.collectionSearch[i]={}}const a=!d.Type.isNil(e.collectionSearch[i][s]);if(!a){e.collectionSearch[i][s]=this.getChatState()}e.collectionSearch[i][s].lastId=o},clearSearch:e=>{e.collectionSearch={}},setHistoryLimitExceeded:(e,t)=>{const{chatId:i,isHistoryLimitExceeded:s}=t;if(e.historyLimitExceededCollection[i]&&!s){return}e.historyLimitExceededCollection[i]=s}}}formatFields(e){return T(e,Rt)}getTopThreeCompletedFiles(e,t){return e.filter((e=>{const i=t["files/get"](e.fileId,true);return i.progress===100})).slice(0,3)}}const Wt=[{fieldName:"dialogId",targetFieldName:"dialogId",checkFunction:d.Type.String},{fieldName:"chatId",targetFieldName:"chatId",checkFunction:d.Type.isNumber},{fieldName:"openSessionsLimit",targetFieldName:"openSessionsLimit",checkFunction:d.Type.isNumber},{fieldName:"status",targetFieldName:"status",checkFunction:d.Type.isString},{fieldName:"dateMessage",targetFieldName:"date",checkFunction:d.Type.isString,formatFunction:n.Utils.date.cast}];class Gt extends c.BuilderModel{getState(){return{isInited:false,isInitedDetail:false,chatsCount:0,unreadChats:new Set,openSessionsLimit:0,multidialogs:{}}}getElementState(){return{dialogId:"",chatId:0,status:"",date:new Date}}getGetters(){return{isInited:({isInited:e})=>e,isInitedDetail:({isInitedDetail:e})=>e,getOpenSessionsLimit:({openSessionsLimit:e})=>e,getChatsCount:({chatsCount:e})=>e,getTotalChatCounter:({unreadChats:e})=>{let t=0;e.forEach((e=>{t+=l.Core.getStore().getters["counters/getChatCounterByChatId"](e)}));return t},get:({multidialogs:e})=>t=>e[t],isSupport:()=>e=>{const t=l.Core.getStore().getters["users/bots/isSupport"](e);const i=l.Core.getStore().getters["chats/isSupport"](e);return i||t},hasNextPage:({chatsCount:e,multidialogs:t})=>e>Object.keys(t).length,getNumberMultidialogs:({multidialogs:e})=>Object.keys(e).length,getMultidialogsByStatus:({multidialogs:e})=>t=>Object.values(e).filter((e=>t.includes(e.status)))}}getActions(){return{setInited:(e,t)=>{e.commit("setInited",t)},setInitedDetail:(e,t)=>{e.commit("setInitedDetail",t)},addMultidialogs:(e,t)=>{if(!d.Type.isArray(t)){return}t.forEach((t=>{const i={...this.getElementState(),...this.formatFields(t)};e.commit("addMultidialog",i)}))},setOpenSessionsLimit:(e,t)=>{if(d.Type.isNumber(t)){e.commit("setOpenSessionsLimit",t)}},setChatsCount:(e,t)=>{if(d.Type.isNumber(t)){e.commit("setChatsCount",t)}},setUnreadChats:(e,t)=>{if(d.Type.isArray(t)){e.commit("setUnreadChats",t)}},set:(e,t)=>{const{unreadChats:i,multidialogs:s,chatsCount:o,openSessionsLimit:a}=t;e.dispatch("setUnreadChats",i);e.dispatch("setChatsCount",o);e.dispatch("setOpenSessionsLimit",a);e.dispatch("addMultidialogs",s)},deleteUnreadChats:(e,t)=>{e.commit("deleteUnreadChats",t)}}}getMutations(){return{setInited:(e,t)=>{e.isInited=t},setInitedDetail:(e,t)=>{e.isInitedDetail=t},addMultidialog:(e,t)=>{e.multidialogs[t.chatId]=t},setChatsCount:(e,t)=>{e.chatsCount=t},setOpenSessionsLimit:(e,t)=>{e.openSessionsLimit=t},setUnreadChats:(e,t)=>{t.forEach((t=>{e.unreadChats.add(t)}))},deleteUnreadChats:({unreadChats:e},t)=>{e.delete(t)}}}formatFields(e){return T(e,Wt)}}class Vt extends c.BuilderModel{getName(){return"sidebar"}getNestedModules(){return{members:Et,links:kt,favorites:xt,tasks:Ht,meetings:jt,files:Dt,multidialog:Gt,messageSearch:Bt}}getState(){return{initedList:new Set,isFilesMigrated:false,isLinksMigrated:false}}getGetters(){return{isInited:e=>t=>e.initedList.has(t),hasHistoryLimit:()=>e=>{const t=["sidebar/links/isHistoryLimitExceeded","sidebar/files/isHistoryLimitExceeded","sidebar/favorites/isHistoryLimitExceeded","sidebar/meetings/isHistoryLimitExceeded","sidebar/tasks/isHistoryLimitExceeded","sidebar/messageSearch/isHistoryLimitExceeded"].map((t=>l.Core.getStore().getters[t](e)));return t.some((e=>e))}}}getActions(){return{setInited:(e,t)=>{if(!d.Type.isNumber(t)){return}e.commit("setInited",t)},setFilesMigrated:(e,t)=>{if(!d.Type.isBoolean(t)){return}e.commit("setFilesMigrated",t)},setLinksMigrated:(e,t)=>{if(!d.Type.isBoolean(t)){return}e.commit("setLinksMigrated",t)}}}getMutations(){return{setInited:(e,t)=>{e.initedList.add(t)},setFilesMigrated:(e,t)=>{e.isFilesMigrated=t},setLinksMigrated:(e,t)=>{e.isLinksMigrated=t}}}}var Kt=babelHelpers.classPrivateFieldLooseKey("validate");var _t=babelHelpers.classPrivateFieldLooseKey("validateOptions");var zt=babelHelpers.classPrivateFieldLooseKey("validateLoadConfiguration");class Xt extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,zt,{value:qt});Object.defineProperty(this,_t,{value:$t});Object.defineProperty(this,Kt,{value:Yt})}getName(){return"market"}getState(){return{collection:new Map,placementCollection:{[r.PlacementType.contextMenu]:new Set,[r.PlacementType.navigation]:new Set,[r.PlacementType.textarea]:new Set,[r.PlacementType.sidebar]:new Set,[r.PlacementType.smilesSelector]:new Set}}}getElementState(){return{id:0,title:"",options:{role:"",extranet:"",context:null,width:null,height:null,color:null,iconName:null},placement:"",order:0,loadConfiguration:{ID:0,PLACEMENT:"",PLACEMENT_ID:0}}}getGetters(){return{getByPlacement:e=>t=>{const i=[...e.placementCollection[t].values()];return i.map((t=>e.collection.get(t)))},getById:e=>t=>e.collection.get(t)}}getActions(){return{set:(e,t)=>{const{items:i}=t;i.forEach((t=>{e.commit("setPlacementCollection",{placement:t.placement,id:t.id});e.commit("setCollection",t)}))}}}getMutations(){return{setPlacementCollection:(e,t)=>{e.placementCollection[t.placement].add(t.id)},setCollection:(e,t)=>{e.collection.set(t.id,{...this.getElementState(),...babelHelpers.classPrivateFieldLooseBase(this,Kt)[Kt](t)})}}}}function Yt(e){const t={};if(d.Type.isNumber(e.id)||d.Type.isStringFilled(e.id)){t.id=e.id.toString()}if(d.Type.isString(e.title)){t.title=e.title}t.options=babelHelpers.classPrivateFieldLooseBase(this,_t)[_t](e.options);if(d.Type.isString(e.placement)){t.placement=e.placement}if(d.Type.isNumber(e.order)){t.order=e.order}t.loadConfiguration=babelHelpers.classPrivateFieldLooseBase(this,zt)[zt](e.loadConfiguration);return t}function $t(e){const t={context:null,width:null,height:null,color:null,iconName:null};if(!d.Type.isPlainObject(e)){return t}if(d.Type.isArrayFilled(e.context)){t.context=e.context}if(d.Type.isNumber(e.width)){t.width=e.width}if(d.Type.isNumber(e.height)){t.height=e.height}if(d.Type.isStringFilled(e.color)){t.color=e.color}if(d.Type.isStringFilled(e.iconName)){t.iconName=e.iconName}return t}function qt(e){const t={ID:0,PLACEMENT:"",PLACEMENT_ID:0};if(!d.Type.isPlainObject(e)){return t}if(d.Type.isNumber(e.ID)){t.ID=e.ID}if(d.Type.isStringFilled(e.PLACEMENT)){t.PLACEMENT=e.PLACEMENT}if(d.Type.isNumber(e.PLACEMENT_ID)){t.PLACEMENT_ID=e.PLACEMENT_ID}return t}var Qt=babelHelpers.classPrivateFieldLooseKey("getChat");var Jt=babelHelpers.classPrivateFieldLooseKey("getChatByChatId");var Zt=babelHelpers.classPrivateFieldLooseKey("isChatMuted");var ei=babelHelpers.classPrivateFieldLooseKey("getRecentItemCounter");var ti=babelHelpers.classPrivateFieldLooseKey("getLoadedChatsCounter");class ii extends c.BuilderModel{constructor(...e){super(...e);Object.defineProperty(this,ti,{value:ri});Object.defineProperty(this,ei,{value:ni});Object.defineProperty(this,Zt,{value:ai});Object.defineProperty(this,Jt,{value:oi});Object.defineProperty(this,Qt,{value:si})}getName(){return"counters"}getState(){return{unloadedChatCounters:{},unloadedLinesCounters:{},unloadedCopilotCounters:{},unloadedCollabCounters:{},commentCounters:{}}}getGetters(){return{getUnloadedChatCounters:e=>e.unloadedChatCounters,getTotalChatCounter:e=>{const t=l.Core.getStore().getters["recent/getRecentCollection"];const i=babelHelpers.classPrivateFieldLooseBase(this,ti)[ti](t);let s=0;Object.values(e.unloadedChatCounters).forEach((e=>{s+=e}));const o=l.Core.getStore().getters["counters/getTotalCommentsCounter"];return i+s+o},getTotalCopilotCounter:e=>{const t=l.Core.getStore().getters["recent/getCopilotCollection"];const i=babelHelpers.classPrivateFieldLooseBase(this,ti)[ti](t);let s=0;Object.values(e.unloadedCopilotCounters).forEach((e=>{s+=e}));return i+s},getTotalCollabCounter:e=>{const t=l.Core.getStore().getters["recent/getCollabCollection"];const i=babelHelpers.classPrivateFieldLooseBase(this,ti)[ti](t);let s=0;Object.values(e.unloadedCollabCounters).forEach((e=>{s+=e}));return i+s},getTotalLinesCounter:e=>{let t=0;Object.values(e.unloadedLinesCounters).forEach((e=>{t+=e}));return t},getSpecificLinesCounter:e=>t=>{if(!e.unloadedLinesCounters[t]){return 0}return e.unloadedLinesCounters[t]},getTotalCommentsCounter:e=>{let t=0;Object.entries(e.commentCounters).forEach((([e,i])=>{const s=babelHelpers.classPrivateFieldLooseBase(this,Jt)[Jt](e);if(babelHelpers.classPrivateFieldLooseBase(this,Zt)[Zt](s)){return}Object.values(i).forEach((e=>{t+=e}))}));return t},getChannelComments:e=>t=>{if(!e.commentCounters[t]){return[]}return e.commentCounters[t]},getChannelCommentsCounter:e=>t=>{if(!e.commentCounters[t]){return 0}let i=0;Object.values(e.commentCounters[t]).forEach((e=>{i+=e}));return i},getChatCounterByChatId:e=>t=>{const i=l.Core.getStore().getters["recent/getRecentCollection"];const s=i.find((e=>{const i=this.store.getters["chats/get"](e.dialogId,true);return i.chatId===t}));if(!s){var o;return(o=e.unloadedChatCounters[t])!=null?o:0}return babelHelpers.classPrivateFieldLooseBase(this,ei)[ei](s)},getSpecificCommentsCounter:e=>t=>{var i;const{channelId:s,commentChatId:o}=t;if(!e.commentCounters[s]){return 0}return(i=e.commentCounters[s][o])!=null?i:0}}}getActions(){return{setUnloadedChatCounters:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("setUnloadedChatCounters",t)},setUnloadedLinesCounters:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("setUnloadedLinesCounters",t)},setUnloadedCopilotCounters:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("setUnloadedCopilotCounters",t)},setUnloadedCollabCounters:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("setUnloadedCollabCounters",t)},setCommentCounters:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("setCommentCounters",t)},readAllChannelComments:(e,t)=>{if(!d.Type.isNumber(t)){return}e.commit("readAllChannelComments",t)},deleteForChannel:(e,t)=>{if(!d.Type.isPlainObject(t)){return}e.commit("deleteForChannel",t)}}}getMutations(){return{setUnloadedChatCounters:(e,t)=>{Object.entries(t).forEach((([t,i])=>{if(i===0){delete e.unloadedChatCounters[t];return}e.unloadedChatCounters[t]=i}))},setUnloadedLinesCounters:(e,t)=>{Object.entries(t).forEach((([t,i])=>{if(i===0){delete e.unloadedLinesCounters[t];return}e.unloadedLinesCounters[t]=i}))},setUnloadedCopilotCounters:(e,t)=>{Object.entries(t).forEach((([t,i])=>{if(i===0){delete e.unloadedCopilotCounters[t];return}e.unloadedCopilotCounters[t]=i}))},setUnloadedCollabCounters:(e,t)=>{Object.entries(t).forEach((([t,i])=>{if(i===0){delete e.unloadedCollabCounters[t];return}e.unloadedCollabCounters[t]=i}))},setCommentCounters:(e,t)=>{Object.entries(t).forEach((([t,i])=>{if(!e.commentCounters[t]){e.commentCounters[t]={}}const s=e.commentCounters[t];Object.entries(i).forEach((([e,t])=>{if(t===0){delete s[e];return}s[e]=t}))}))},readAllChannelComments:(e,t)=>{delete e.commentCounters[t]},deleteForChannel:(e,t)=>{const{channelChatId:i,commentChatId:s}=t;if(!e.commentCounters[i]){return}if(!s){delete e.commentCounters[i];return}delete e.commentCounters[i][s]}}}}function si(e){return l.Core.getStore().getters["chats/get"](e,true)}function oi(e){return l.Core.getStore().getters["chats/getByChatId"](e,true)}function ai(e){return e.muteList.includes(l.Core.getUserId())}function ni(e){const t=babelHelpers.classPrivateFieldLooseBase(this,Qt)[Qt](e.dialogId);if(babelHelpers.classPrivateFieldLooseBase(this,Zt)[Zt](t)){return 0}const i=e.unread;if(t.counter===0&&i){return 1}return t.counter}function ri(e){let t=0;e.forEach((e=>{const i=babelHelpers.classPrivateFieldLooseBase(this,ei)[ei](e);t+=i}));return t}const li=[{fieldName:"recommendedRoles",targetFieldName:"recommendedRoles",checkFunction:d.Type.isArray},{fieldName:"roles",targetFieldName:"roles",checkFunction:d.Type.isPlainObject,formatFunction:e=>Object.values(e).map((e=>T(e,rolesFieldsConfig)))}];const ci=[{fieldName:"dialogId",targetFieldName:"dialogId",checkFunction:d.Type.isString},{fieldName:"role",targetFieldName:"role",checkFunction:d.Type.isString}];class di extends c.BuilderModel{getState(){return{collection:{}}}getElementState(){return{dialogId:"",role:""}}getGetters(){return{getRole:e=>t=>{const i=e.collection[t];if(!i){return null}return l.Core.getStore().getters["copilot/roles/getByCode"](i.role)},getRoleAvatar:(e,t)=>e=>{const i=t.getRole(e);if(!i){return""}return l.Core.getStore().getters["copilot/roles/getAvatar"](i.code)}}}getActions(){return{add:(e,t)=>{if(!t){return}const i=d.Type.isArrayFilled(t)?t:[t];i.forEach((t=>{const i={...this.getElementState(),...this.formatFields(t)};e.commit("add",i)}))}}}getMutations(){return{add:(e,t)=>{const{dialogId:i}=t;e.collection[i]=t}}}formatFields(e){return T(e,ci)}}const ui=[{fieldName:"id",targetFieldName:"id",checkFunction:d.Type.isNumber},{fieldName:"role",targetFieldName:"roleCode",checkFunction:d.Type.isString}];class mi extends c.BuilderModel{getState(){return{collection:{}}}getElementState(){return{id:0,roleCode:""}}getGetters(){return{getRole:e=>t=>{const i=e.collection[t];if(!i){return l.Core.getStore().getters["copilot/roles/getDefault"]}return l.Core.getStore().getters["copilot/roles/getByCode"](i.roleCode)},getPrompts:e=>t=>{const i=e.collection[t];if(!i){return[]}return l.Core.getStore().getters["copilot/roles/getPrompts"](i.roleCode)},getAvatar:(e,t)=>e=>{const i=t.getRole(e);if(!i){return""}return l.Core.getStore().getters["copilot/roles/getAvatar"](i.code)}}}getActions(){return{add:(e,t)=>{if(!d.Type.isArrayFilled(t)){return}t.forEach((t=>{const i={...this.getElementState(),...this.formatFields(t)};e.commit("add",i)}))}}}getMutations(){return{add:(e,t)=>{e.collection[t.id]=t}}}formatFields(e){return T(e,ui)}}const gi=[{fieldName:"avatar",targetFieldName:"avatar",checkFunction:d.Type.isPlainObject,formatFunction:e=>u.formatFieldsWithConfig(e,fi)},{fieldName:"code",targetFieldName:"code",checkFunction:d.Type.isString},{fieldName:["desc","description"],targetFieldName:"desc",checkFunction:d.Type.isString},{fieldName:"name",targetFieldName:"name",checkFunction:d.Type.isString},{fieldName:"default",targetFieldName:"default",checkFunction:d.Type.isBoolean},{fieldName:"prompts",targetFieldName:"prompts",checkFunction:d.Type.isArray,formatFunction:e=>e.map((e=>u.formatFieldsWithConfig(e,hi)))}];const hi=[{fieldName:"code",targetFieldName:"code",checkFunction:d.Type.isString},{fieldName:"promptType",targetFieldName:"promptType",checkFunction:d.Type.isString},{fieldName:"text",targetFieldName:"text",checkFunction:d.Type.isString},{fieldName:"title",targetFieldName:"title",checkFunction:d.Type.isString}];const fi=[{fieldName:"small",targetFieldName:"small",checkFunction:d.Type.isString},{fieldName:"medium",targetFieldName:"medium",checkFunction:d.Type.isString},{fieldName:"large",targetFieldName:"large",checkFunction:d.Type.isString}];const pi=Object.freeze({S:"small",M:"medium",L:"large"});class yi extends c.BuilderModel{getState(){return{roles:{}}}getElementState(){return{code:"",name:"",desc:"",default:false,avatar:{small:"",medium:"",large:""},prompts:[]}}getGetters(){return{get:e=>()=>Object.values(e.roles),getByCode:(e,t)=>i=>{var s;return(s=e.roles[i])!=null?s:t.getDefault},getPrompts:(e,t)=>i=>{if(!e.roles[i]){var s,o;return(s=(o=t.getDefault)==null?void 0:o.prompts)!=null?s:[]}return e.roles[i].prompts},getDefault:e=>Object.values(e.roles).find((e=>e.default)),getAvatar:(e,t)=>(i,s="M")=>{if(!e.roles[i]){var o,a;return(o=(a=t.getDefault)==null?void 0:a.prompts)!=null?o:[]}return e.roles[i].avatar[pi[s]]}}}getActions(){return{add:(e,t)=>{const i=Object.values(t);if(!d.Type.isArrayFilled(i)){return}i.forEach((t=>{const i={...this.getElementState(),...this.formatFields(t)};e.commit("add",i)}))}}}getMutations(){return{add:(e,t)=>{e.roles[t.code]=t}}}formatFields(e){return T(e,gi)}}const Ii=4;class Ni extends c.BuilderModel{getNestedModules(){return{roles:yi,messages:mi,chats:di}}getName(){return"copilot"}getState(){return{recommendedRoles:[],aiProvider:""}}getGetters(){return{getProvider:e=>e.aiProvider,getRecommendedRoles:e=>()=>{const t=e.recommendedRoles.map((e=>l.Core.getStore().getters["copilot/roles/getByCode"](e)));return t.slice(0,Ii)}}}getActions(){return{setRecommendedRoles:(e,t)=>{if(!d.Type.isArrayFilled(t)){return}e.commit("setRecommendedRoles",t)},setProvider:(e,t)=>{if(!d.Type.isStringFilled(t)){return}e.commit("setProvider",t)}}}getMutations(){return{setRecommendedRoles:(e,t)=>{e.recommendedRoles=t},setProvider:(e,t)=>{e.aiProvider=t}}}formatFields(e){return u.formatFieldsWithConfig(e,li)}}e.ApplicationModel=E;e.MessagesModel=le;e.ChatsModel=je;e.UsersModel=ze;e.FilesModel=Xe;e.RecentModel=ut;e.NotificationsModel=vt;e.SidebarModel=Vt;e.MarketModel=Xt;e.CountersModel=ii;e.CopilotModel=Ni;e.formatFieldsWithConfig=T;e.convertToNumber=h;e.convertToString=g;e.isNumberOrString=m;e.convertObjectKeysToCamelCase=y;e.prepareDraft=Ye;e.prepareInvitation=$e})(this.BX.Messenger.v2.Model=this.BX.Messenger.v2.Model||{},BX.Event,BX.Messenger.v2.Lib,BX.Messenger.v2.Lib,BX.Messenger.v2.Lib,BX.Messenger.v2.Lib,BX.Messenger.v2.Lib,BX.Messenger.v2.Const,BX.Messenger.v2.Application,BX.Vue3.Vuex,BX,BX.Messenger.v2.Model); //# sourceMappingURL=registry.bundle.map.js