');return i.attr("data-id",e.id),i.attr("data-name",e.name),i.attr("data-x",e.x),i.attr("data-y",e.y),i.attr("data-height",e.height),i.attr("data-width",e.width),i.css("height",e.height*this.getThemeManager().getParam("dashboardCellHeight")+"px"),t.attr("data-id",e.id),t.attr("data-name",e.name),t.append(i),t}saveLayout(e){this.layoutReadOnly||(e={...e||{},dashboardLayout:this.dashboardLayout},this.getPreferences().save(e,{patch:!0}),this.getPreferences().trigger("update"))}removeDashlet(i){let e=!1,t=(this.isFallbackMode()&&(this.initGridstack(),e=!0),this.$gridstack.find('.grid-stack-item[data-id="'+i+'"]')),s=(this.grid.removeWidget(t.get(0),!0),this.dashboardLayout[this.currentTab].layout),a=(s.forEach((e,t)=>{e.id===i&&s.splice(t,1)}),{});var l;a.dashletsOptions=this.getPreferences().get("dashletsOptions")||{},delete a.dashletsOptions[i],a.dashboardLayout=this.dashboardLayout,this.layoutReadOnly||(this.getPreferences().save(a,{patch:!0}),this.getPreferences().trigger("update"),~(l=this.dashletIdList.indexOf(i))&&this.dashletIdList.splice(l,l),this.clearView("dashlet-"+i),this.setupCurrentTabLayout(),e&&this.initFallbackMode())}addDashlet(e){let t=!1;this.isFallbackMode()&&(this.initGridstack(),t=!0);var i="d"+Math.floor(1000001*Math.random()).toString();let s=this.prepareGridstackItem(i,e);this.grid.addWidget(s.get(0),{x:0,y:0,w:2*this.WIDTH_MULTIPLIER,h:2}),this.createDashletView(i,e,e,e=>{this.fetchLayout(),this.saveLayout(),this.setupCurrentTabLayout(),e.getView("body")&&e.getView("body").afterAdding&&e.getView("body").afterAdding.call(e.getView("body")),t&&this.initFallbackMode()})}createDashletView(t,i,s,a){let e={id:t,name:i};return s&&(e.label=s),this.createView("dashlet-"+t,"views/dashlet",{label:i,name:i,id:t,selector:'> .dashlets .dashlet-container[data-id="'+t+'"]',readOnly:this.dashletsReadOnly,locked:this.getPreferences().get("dashboardLocked")},e=>{this.dashletIdList.push(t),e.render(),this.listenToOnce(e,"change",()=>{this.clearView(t),this.createDashletView(t,i,s)}),this.listenToOnce(e,"remove-dashlet",()=>{this.removeDashlet(t)}),a&&a.call(this,e)})}editTabs(){var e=this.getPreferences().get("dashboardLocked");this.createView("editTabs","views/modals/edit-dashboard",{dashboardLayout:this.dashboardLayout,dashboardLocked:e,fromDashboard:!0},e=>{e.render(),this.listenToOnce(e,"after:save",a=>{e.close();let l=[];a.dashboardTabList.forEach(t=>{let i=[],s=null,e=(this.dashboardLayout.forEach(e=>{e.name===t&&(i=e.layout,s=e.id)}),{name:t=t in a.renameMap?a.renameMap[t]:t,layout:i});s&&(e.id=s),l.push(e)}),this.dashletIdList.forEach(e=>{this.clearView("dashlet-"+e)}),this.dashboardLayout=l,this.saveLayout({dashboardLocked:a.dashboardLocked}),this.storeCurrentTab(0),this.currentTab=0,this.setupCurrentTabLayout(),this.reRender()})})}}e.default=s}),define("views/collapsed-modal",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{templateContent=`
`;events={'click [data-action="expand"]':function(){this.expand()},'click [data-action="close"]':function(){this.close()}};data(){let e=this.title;return{title:e=this.duplicateNumber?this.title+" "+this.duplicateNumber:e}}setup(){this.title=this.options.title||"no-title",this.duplicateNumber=this.options.duplicateNumber||null}expand(){this.trigger("expand")}close(){this.trigger("close")}}e.default=s}),define("views/collapsed-modal-bar",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{maxNumberToDisplay=3;templateContent=`
{{#each dataList}}
{{var key ../this}}
{{/each}}
`;data(){return{dataList:this.getDataList()}}init(){this.on("render",()=>{0===$(".collapsed-modal-bar").length&&$("
").addClass("collapsed-modal-bar").appendTo("body")})}setup(){this.lastNumber=0,this.numberList=[]}getDataList(){let i=[],e=Espo.Utils.clone(this.numberList);return(e=this.numberList.length>this.maxNumberToDisplay?e.slice(this.numberList.length-this.maxNumberToDisplay):e).reverse().forEach((e,t)=>{i.push({number:e.toString(),key:"key-"+e,index:t})}),i}calculateDuplicateNumber(t){let i=0;return this.numberList.forEach(e=>{e=this.getModalViewByNumber(e);e&&e.title===t&&i++}),0===i?null:i}getModalViewByNumber(e){return this.getView("key-"+e)}addModalView(t,e){let i=this.lastNumber;this.numberList.push(this.lastNumber);var s="key-"+i;this.createView(s,"views/collapsed-modal",{title:e.title,duplicateNumber:this.calculateDuplicateNumber(e.title),selector:'[data-number="'+i+'"]'}).then(e=>{this.listenToOnce(e,"close",()=>{this.removeModalView(i)}),this.listenToOnce(e,"expand",()=>{this.removeModalView(i,!0),setTimeout(()=>{var e="dialog-"+i;this.setView(e,t),t.setSelector(t.containerSelector),this.getView(e).render()},5)}),this.reRender(!0)}),this.lastNumber++}removeModalView(e,t){var i="key-"+e,s=this.numberList.indexOf(e);~s&&this.numberList.splice(s,1),this.isRendered()&&this.$el.find('.collapsed-modal[data-number="'+e+'"]').remove(),t||this.reRender(),this.clearView(i)}}e.default=s}),define("views/clear-cache",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{template="clear-cache";el="> body";events={'click .action[data-action="clearLocalCache"]':function(){this.clearLocalCache()},'click .action[data-action="returnToApplication"]':function(){this.returnToApplication()}};data(){return{cacheIsEnabled:!!this.options.cache}}clearLocalCache(){this.options.cache.clear(),this.$el.find('.action[data-action="clearLocalCache"]').remove(),this.$el.find(".message-container").removeClass("hidden"),this.$el.find(".message-container span").html(this.translate("Cache has been cleared")),this.$el.find('.action[data-action="returnToApplication"]').removeClass("hidden")}returnToApplication(){this.getRouter().navigate("",{trigger:!0})}}e.default=s}),define("views/about",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{template="about";data(){return{version:this.getConfig().get("version")}}}e.default=s}),define("views/stream/panel",["exports","views/record/panels/relationship","jquery-textcomplete"],function(e,t,i){"use strict";function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=s(t),i=s(i);class a extends t.default{template="stream/panel";postingMode=!1;postDisabled=!1;relatedListFiltersDisabled=!0;layoutName=null;filterList=["all","posts","updates"];additionalEvents={'focus textarea[data-name="post"]':function(){this.enablePostingMode(!0)},"click button.post":function(){this.post()},'click .action[data-action="switchInternalMode"]':function(e){this.isInternalNoteMode=!this.isInternalNoteMode;e=$(e.currentTarget);this.isInternalNoteMode?e.addClass("enabled"):e.removeClass("enabled")},'keydown textarea[data-name="post"]':function(e){"Control+Enter"===Espo.Utils.getKeyFromKeyEvent(e)&&(e.stopPropagation(),e.preventDefault(),this.post())},'input textarea[data-name="post"]':function(){this.controlPreviewButton(),this.controlPostButtonAvailability(this.$textarea.val())},'click .action[data-action="preview"]':function(){this.preview()}};data(){let e=super.data();return e.postDisabled=this.postDisabled,e.placeholderText=this.placeholderText,e.allowInternalNotes=this.allowInternalNotes,e}controlPreviewButton(){this.$previewButton=this.$previewButton||this.$el.find(".stream-post-preview"),""===this.$textarea.val()?this.$previewButton.addClass("hidden"):this.$previewButton.removeClass("hidden")}enablePostingMode(t){var i;this.$el.find(".buttons-panel").removeClass("hide"),this.postingMode||(this.$textarea.val()&&this.$textarea.val().length&&this.getView("postField").controlTextareaHeight(),i=!1,$("body").on("click.stream-panel",e=>{!t||i?$(e.target).parent().hasClass("remove-attachment")||$.contains(this.$postContainer.get(0),e.target)||""===this.$textarea.val()&&($(e.target).closest(".popover-content").get(0)||(this.seed.get("attachmentsIds")||[]).length||this.getView("attachments")&&this.getView("attachments").isUploading||this.disablePostingMode()):i=!0})),this.postingMode=!0,this.controlPreviewButton()}disablePostingMode(){this.postingMode=!1,this.$textarea.val(""),this.hasView("attachments")&&this.getView("attachments").empty(),this.$el.find(".buttons-panel").addClass("hide"),$("body").off("click.stream-panel"),this.$textarea.prop("rows",1)}setup(){this.events={...this.additionalEvents,...this.events},this.scope=this.model.entityType,this.filter=this.getStoredFilter(),this.setupTitle(),this.placeholderText=this.translate("writeYourCommentHere","messages"),this.allowInternalNotes=!1,this.getUser().isPortal()||(this.allowInternalNotes=this.getMetadata().get(["clientDefs",this.scope,"allowInternalNotes"])),this.isInternalNoteMode=!1,this.storageTextKey="stream-post-"+this.model.entityType+"-"+this.model.id,this.storageAttachmentsKey="stream-post-attachments-"+this.model.entityType+"-"+this.model.id,this.storageIsInernalKey="stream-post-is-internal-"+this.model.entityType+"-"+this.model.id,this.on("remove",()=>{this.storeControl(),$(window).off("beforeunload.stream-"+this.cid)}),$(window).off("beforeunload.stream-"+this.cid),$(window).on("beforeunload.stream-"+this.cid,()=>{this.storeControl()});var t=this.getSessionStorage().get(this.storageAttachmentsKey);this.setupActions(),this.wait(!0),this.getModelFactory().create("Note",e=>{this.seed=e,t&&(this.hasStoredAttachments=!0,this.seed.set({attachmentsIds:t.idList,attachmentsNames:t.names,attachmentsTypes:t.types})),this.allowInternalNotes&&(this.getMetadata().get(["entityDefs","Note","fields","isInternal","default"])&&(this.isInternalNoteMode=!0),this.getSessionStorage().has(this.storageIsInernalKey)&&(this.isInternalNoteMode=this.getSessionStorage().get(this.storageIsInernalKey))),this.isInternalNoteMode&&this.seed.set("isInternal",!0),this.createView("postField","views/note/fields/post",{selector:".textarea-container",name:"post",mode:"edit",params:{required:!0,rowsMin:1,rows:25},model:this.seed,placeholderText:this.placeholderText,noResize:!0},e=>{this.initPostEvents(e)}),this.createCollection(()=>{this.wait(!1)}),this.listenTo(this.seed,"change:attachmentsIds",()=>{this.controlPostButtonAvailability()})}),this.defs.hidden||this.subscribeToWebSocket(),this.once("show",()=>{this.isSubscribedToWebSocket||this.subscribeToWebSocket()}),this.once("remove",()=>{this.isSubscribedToWebSocket&&this.unsubscribeFromWebSocket()})}subscribeToWebSocket(){var e;this.getHelper().webSocketManager&&"User"!==this.model.entityType&&(e="streamUpdate."+this.model.entityType+"."+this.model.id,this.streamUpdateWebSocketTopic=e,this.isSubscribedToWebSocket=!0,this.getHelper().webSocketManager.subscribe(e,(e,t)=>{if(t.createdById!==this.getUser().id)if(t.noteId){let e=this.collection.get(t.noteId);void(e&&e.fetch())}else this.collection.fetchNew()}))}unsubscribeFromWebSocket(){this.getHelper().webSocketManager.unsubscribe(this.streamUpdateWebSocketTopic)}setupTitle(){this.title=this.translate("Stream"),this.titleHtml=this.title,this.filter&&"all"!==this.filter&&(this.titleHtml+=" · "+this.translate(this.filter,"filters","Note"))}storeControl(){var e=!1,t=(this.$textarea&&this.$textarea.length&&((t=this.$textarea.val()).length?(this.getSessionStorage().set(this.storageTextKey,t),e=!0):this.hasStoredText&&this.getSessionStorage().clear(this.storageTextKey)),this.seed.get("attachmentsIds")||[]);t.length?(this.getSessionStorage().set(this.storageAttachmentsKey,{idList:t,names:this.seed.get("attachmentsNames")||{},types:this.seed.get("attachmentsTypes")||{}}),e=!0):this.hasStoredAttachments&&this.getSessionStorage().clear(this.storageAttachmentsKey),e?this.getSessionStorage().set(this.storageIsInernalKey,this.isInternalNoteMode):this.getSessionStorage().clear(this.storageIsInernalKey)}createCollection(t,i){this.getCollectionFactory().create("Note",e=>{(this.collection=e).url=this.model.entityType+"/"+this.model.id+"/stream",e.maxSize=this.getConfig().get("recordsPerPageSmall")||5,this.setFilter(this.filter),t.call(i)})}initPostEvents(e){this.listenTo(e,"add-files",e=>{this.getView("attachments").uploadFiles(e),this.postingMode||this.enablePostingMode()})}afterRender(){this.$textarea=this.$el.find('textarea[data-name="post"]'),this.$attachments=this.$el.find("div.attachments"),this.$postContainer=this.$el.find(".post-container"),this.$postButton=this.$el.find("button.post");var e=this.getSessionStorage().get(this.storageTextKey);e&&e.length&&(this.hasStoredText=!0,this.$textarea.val(e)),this.controlPostButtonAvailability(e),this.isInternalNoteMode&&this.$el.find('.action[data-action="switchInternalMode"]').addClass("enabled");let t=this.collection,i=(this.listenToOnce(t,"sync",()=>{this.createView("list","views/stream/record/list",{selector:"> .list-container",collection:t,model:this.model},e=>{e.render()}),this.stopListening(this.model,"all"),this.stopListening(this.model,"destroy"),setTimeout(()=>{this.listenTo(this.model,"all",e=>{~["sync","after:relate"].indexOf(e)&&t.fetchNew()}),this.listenTo(this.model,"destroy",()=>{this.stopListening(this.model,"all")})},500)}),this.defs.hidden?this.once("show",()=>t.fetch()):t.fetch(),this.getAcl().getPermissionLevel("assignmentPermission"));"no"!==i&&(this.$textarea.textcomplete([{match:/(^|\s)@(\w*)$/,index:2,search:(e,t)=>{0!==e.length?Espo.Ajax.getRequest((e=>{e="User?orderBy=name&limit=7&q="+e+"&"+$.param({primaryFilter:"active"});return"team"===i&&(e+="&"+$.param({boolFilterList:["onlyMyTeam"]})),e})(e)).then(e=>t(e.list)):t([])},template:e=>this.getHelper().escapeString(e.name)+'
@'+this.getHelper().escapeString(e.userName)+"",replace:e=>"$1@"+e.userName}]),this.once("remove",()=>{this.$textarea.length&&this.$textarea.textcomplete("destroy")}));var e=this.$el.find(".buttons-panel a.stream-post-info"),s=this.translate("infoMention","messages","Stream"),a=this.translate("infoSyntax","messages","Stream");let l=[],o=([["code","`{text}`"],["multilineCode","```{text}```"],["strongText","**{text}**"],["emphasizedText","*{text}*"],["deletedText","~~{text}~~"],["blockquote","> {text}"],["link","[{text}](url)"]].forEach(e=>{var t=this.translate(e[0],"syntaxItems","Stream"),e=e[1].replace("{text}",t);l.push(e)}),$("
").append(l.map(e=>$("- ").text(e))));s=this.getHelper().transformMarkdownInlineText(s)+"
"+this.getHelper().transformMarkdownInlineText(a)+":
"+o.get(0).outerHTML;Espo.Ui.popover(e,{content:s},this),this.createView("attachments","views/stream/fields/attachment-multiple",{model:this.seed,mode:"edit",selector:"div.attachments-container",defs:{name:"attachments"}},e=>{e.render()})}afterPost(){this.$el.find("textarea.note").prop("rows",1)}post(){let t=this.$textarea.val();this.disablePostButton(),this.$textarea.prop("disabled",!0),this.getModelFactory().create("Note",e=>this.getView("attachments").validateReady()?(this.$textarea.prop("disabled",!1),void this.enablePostButton()):""===t.trim()&&0===(this.seed.get("attachmentsIds")||[]).length?(this.notify("Post cannot be empty","error"),this.$textarea.prop("disabled",!1),this.controlPostButtonAvailability(),void this.$textarea.focus()):(e.set("post",t),e.set("attachmentsIds",Espo.Utils.clone(this.seed.get("attachmentsIds")||[])),e.set("type","Post"),e.set("isInternal",this.isInternalNoteMode),this.prepareNoteForPost(e),Espo.Ui.notify(" ... "),void e.save(null).then(()=>{Espo.Ui.success(this.translate("Posted")),this.collection.fetchNew(),this.$textarea.prop("disabled",!1),this.disablePostingMode(),this.afterPost(),this.getPreferences().get("followEntityOnStreamPost")&&this.model.set("isFollowed",!0),this.getSessionStorage().clear(this.storageTextKey),this.getSessionStorage().clear(this.storageAttachmentsKey),this.getSessionStorage().clear(this.storageIsInernalKey)}).catch(()=>{this.$textarea.prop("disabled",!1),this.controlPostButtonAvailability()})))}prepareNoteForPost(e){e.set("parentId",this.model.id),e.set("parentType",this.model.entityType)}getButtonList(){return[]}setupActions(){this.actionList=[],this.actionList.push({action:"viewPostList",html:$("").append($("").text(this.translate("View List"))," · ",$("").text(this.translate("posts","filters","Note"))).get(0).innerHTML,onClick:()=>this.actionViewPostList()}),this.actionList.push(!1),this.filterList.forEach(e=>{var t="all"===e?!this.filter:e===this.filter;this.actionList.push({action:"selectFilter",html:$("").append($("").addClass("check-icon fas fa-check pull-right").addClass(t?"":" hidden"),$("