text: if(typeof BX.CrmTimelineManager==="undefined"){BX.CrmTimelineManager=function(){this._id="";this._settings={};this._container=null;this._ownerTypeId=0;this._ownerId=0;this._ownerInfo=null;this._progressSemantics="";this._commentEditor=null;this._waitEditor=null;this._smsEditor=null;this._chat=null;this._schedule=null;this._history=null;this._fixedHistory=null;this._activityEditor=null;this._menuBar=null;this._userId=0;this._readOnly=false;this._pullTagName=""};BX.CrmTimelineManager.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._ownerTypeId=parseInt(this.getSetting("ownerTypeId"));this._ownerId=parseInt(this.getSetting("ownerId"));this._ownerInfo=this.getSetting("ownerInfo");this._progressSemantics=BX.prop.getString(this._settings,"progressSemantics","");this._spotlightFastenShowed=this.getSetting("spotlightFastenShowed",true);var i=this.getSetting("containerId");if(!BX.type.isNotEmptyString(i)){throw"BX.CrmTimelineManager. A required parameter 'containerId' is missing."}this._container=BX(i);if(!BX.type.isElementNode(this._container)){throw"BX.CrmTimelineManager. Container node is not found."}this._editorContainer=BX(this.getSetting("editorContainer"));this._userId=BX.prop.getInteger(this._settings,"userId",0);this._readOnly=BX.prop.getBoolean(this._settings,"readOnly",false);var r=this.getSetting("activityEditorId");if(BX.type.isNotEmptyString(r)){this._activityEditor=BX.CrmActivityEditor.items[r];if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmTimeline. Activity editor instance is not found."}}var n=this.getSetting("ajaxId");var s=this.getSetting("currentUrl");var a=this.getSetting("serviceUrl");this._chat=BX.CrmEntityChat.create(this._id,{manager:this,container:this._container,data:this.getSetting("chatData"),isStubMode:this._ownerId<=0,readOnly:this._readOnly});this._schedule=BX.CrmSchedule.create(this._id,{manager:this,container:this._container,activityEditor:this._activityEditor,itemData:this.getSetting("scheduleData"),isStubMode:this._ownerId<=0,ajaxId:n,serviceUrl:a,currentUrl:s,userId:this._userId,readOnly:this._readOnly});this._fixedHistory=BX.CrmFixedHistory.create(this._id,{manager:this,container:this._container,editorContainer:this._editorContainer,activityEditor:this._activityEditor,itemData:this.getSetting("fixedData"),isStubMode:this._ownerId<=0,ajaxId:n,serviceUrl:a,currentUrl:s,userId:this._userId,readOnly:this._readOnly});this._history=BX.CrmHistory.create(this._id,{manager:this,container:this._container,fixedHistory:this._fixedHistory,activityEditor:this._activityEditor,itemData:this.getSetting("historyData"),navigation:this.getSetting("historyNavigation",{}),filterId:BX.prop.getString(this._settings,"historyFilterId",this._id),isFilterApplied:BX.prop.getBoolean(this._settings,"isHistoryFilterApplied",false),isStubMode:this._ownerId<=0,ajaxId:n,serviceUrl:a,currentUrl:s,userId:this._userId,readOnly:this._readOnly});this._schedule.setHistory(this._history);this._fixedHistory.setHistory(this._history);this._commentEditor=BX.CrmTimelineCommentEditor.create(this._id,{manager:this,ownerTypeId:this._ownerTypeId,ownerId:this._ownerId,serviceUrl:this.getSetting("serviceUrl"),container:this.getSetting("editorCommentContainer"),input:this.getSetting("editorCommentInput"),editorName:this.getSetting("editorCommentEditorName"),button:this.getSetting("editorCommentButton"),cancelButton:this.getSetting("editorCommentCancelButton")});this._commentEditor.setVisible(true);this._commentEditor.setHistory(this._history);if(this._readOnly){this._commentEditor.setVisible(false)}if(BX.prop.getBoolean(this._settings,"enableWait",false)){this._waitEditor=BX.CrmTimelineWaitEditor.create(this._id,{manager:this,ownerTypeId:this._ownerTypeId,ownerId:this._ownerId,serviceUrl:this.getSetting("serviceUrl"),config:this.getSetting("editorWaitConfig",{}),targetDates:this.getSetting("editorWaitTargetDates",[]),container:this.getSetting("editorWaitContainer"),configContainer:this.getSetting("editorWaitConfigContainer"),input:this.getSetting("editorWaitInput"),button:this.getSetting("editorWaitButton"),cancelButton:this.getSetting("editorWaitCancelButton")});this._waitEditor.setVisible(false)}if(BX.prop.getBoolean(this._settings,"enableSms",false)){this._smsEditor=BX.CrmTimelineSmsEditor.create(this._id,{manager:this,ownerTypeId:this._ownerTypeId,ownerId:this._ownerId,serviceUrl:this.getSetting("serviceUrl"),config:this.getSetting("editorSmsConfig",{}),container:this.getSetting("editorSmsContainer"),input:this.getSetting("editorSmsInput"),button:this.getSetting("editorSmsButton"),cancelButton:this.getSetting("editorSmsCancelButton")});this._smsEditor.setVisible(false)}if(BX.prop.getBoolean(this._settings,"enableRest",false)){this._restEditor=BX.CrmTimelineRestEditor.create(this._id,{manager:this,ownerTypeId:this._ownerTypeId,ownerId:this._ownerId,placement:BX.prop.getString(this._settings,"restPlacement","")})}this._chat.layout();this._schedule.layout();this._fixedHistory.layout();this._history.layout();this._pullTagName=BX.prop.getString(this._settings,"pullTagName","");if(this._pullTagName!==""){BX.addCustomEvent("onPullEvent-crm",BX.delegate(this.onPullEvent,this));this.extendWatch()}this._menuBar=BX.CrmTimelineMenuBar.create(this._id,{container:BX(this.getSetting("menuBarContainer")),ownerInfo:this._ownerInfo,activityEditor:this._activityEditor,commentEditor:this._commentEditor,waitEditor:this._waitEditor,smsEditor:this._smsEditor,restEditor:this._restEditor,readOnly:this._readOnly,manager:this});if(!this._readOnly){this._menuBar.setActiveItemById("comment")}BX.addCustomEvent(window,"Crm.EntityProgress.Change",BX.delegate(this.onEntityProgressChange,this));BX.ready(function(){window.addEventListener("scroll",BX.throttle(function(){BX.LazyLoad.onScroll()},80))})},extendWatch:function(){if(BX.type.isFunction(BX.PULL)&&this._pullTagName!==""){BX.PULL.extendWatch(this._pullTagName);window.setTimeout(BX.delegate(this.extendWatch,this),6e4)}},onPullEvent:function(t,e){if(this._pullTagName!==BX.prop.getString(e,"TAG","")){return}if(t==="timeline_chat_create"){this.processChatCreate(e)}else if(t==="timeline_activity_add"){this.processActivityExternalAdd(e)}else if(t==="timeline_activity_update"){this.processActivityExternalUpdate(e)}else if(t==="timeline_activity_delete"){this.processActivityExternalDelete(e)}else if(t==="timeline_comment_add"){this.processCommentExternalAdd(e)}else if(t==="timeline_link_add"){this.processLinkExternalAdd(e)}else if(t==="timeline_document_add"){this.processLinkExternalAdd(e)}else if(t==="timeline_document_update"){this.processDocumentExternalUpdate(e)}else if(t==="timeline_document_delete"){this.processDocumentExternalDelete(e)}else if(t==="timeline_comment_update"){this.processCommentExternalUpdate(e)}else if(t==="timeline_comment_delete"){this.processCommentExternalDelete(e)}else if(t==="timeline_changed_binding"){this.processChangeBinding(e)}else if(t==="timeline_item_change_fasten"){this.processItemChangeFasten(e)}else if(t==="timeline_item_update"){this.processItemExternalUpdate(e)}else if(t==="timeline_wait_add"){this.processWaitExternalAdd(e)}else if(t==="timeline_wait_update"){this.processWaitExternalUpdate(e)}else if(t==="timeline_wait_delete"){this.processWaitExternalDelete(e)}else if(t==="timeline_bizproc_status"){this.processBizprocStatus(e)}else if(t==="timeline_scoring_add"){this.processScoringExternalAdd(e)}},processChatCreate:function(t){if(this._chat){this._chat.setData(BX.prop.getObject(t,"CHAT_DATA",{}));this._chat.refreshLayout()}},processActivityExternalAdd:function(t){var e,i,r,n,s;e=BX.prop.getObject(t,"ENTITY",null);i=BX.prop.getObject(t,"SCHEDULE_ITEM",null);r=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e&&r&&!BX.type.isPlainObject(r["ASSOCIATED_ENTITY"])){r["ASSOCIATED_ENTITY"]=e}if(i!==null&&this._schedule.getItemByData(i)===null){n=this.addScheduleItem(i);n.addWrapperClass("crm-entity-stream-section-updated",1e3)}if(r!==null){s=this.addHistoryItem(r);BX.CrmTimelineItemExpand.create(s.getWrapper(),null).run()}},processActivityExternalUpdate:function(t){var e,i,r,n,s,a;e=BX.prop.getObject(t,"ENTITY",null);i=BX.prop.getObject(t,"SCHEDULE_ITEM",null);n=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e){if(n&&!BX.type.isPlainObject(n["ASSOCIATED_ENTITY"])){n["ASSOCIATED_ENTITY"]=e}var o=BX.prop.getInteger(e,"ID",0);var c=this._history.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.activity,o);for(var m=0,l=c.length;m<l;m++){s=c[m];s.setAssociatedEntityData(e);s.refreshLayout()}var h=this._fixedHistory.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.activity,o);for(var m=0,l=h.length;m<l;m++){a=h[m];a.setAssociatedEntityData(e);a.refreshLayout()}}if(i!==null){r=this._schedule.getItemByAssociatedEntity(BX.CrmEntityType.enumeration.activity,BX.prop.getInteger(i,"ASSOCIATED_ENTITY_ID"));if(r){r.setData(i);if(!r.isDone()){this._schedule.refreshItem(r)}else{if(n){this._schedule.transferItemToHistory(r,n);n=null}else{this._schedule.deleteItem(r)}}}else if(!BX.CrmScheduleItem.isDone(i)){r=this.addScheduleItem(i);r.addWrapperClass("crm-entity-stream-section-updated",1e3)}}if(n!==null){s=this._history.findItemById(BX.prop.getString(n,"ID"));if(!s){s=this.addHistoryItem(n);BX.CrmTimelineItemExpand.create(s.getWrapper(),null).run()}else{s.setData(n);s.refreshLayout();a=this._fixedHistory.findItemById(BX.prop.getString(n,"ID"));if(a){a.setData(n);a.refreshLayout()}}}},processActivityExternalDelete:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);var i=this._history.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.activity,e);for(var r=0,n=i.length;r<n;r++){this._history.deleteItem(i[r])}var s=this._fixedHistory.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.activity,e);for(var r=0,n=s.length;r<n;r++){this._fixedHistory.deleteItem(s[r])}var a=this._schedule.getItemByAssociatedEntity(BX.CrmEntityType.enumeration.activity,e);if(a){this._schedule.deleteItem(a)}},processCommentExternalAdd:function(t){var e,i;e=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e!==null){window.setTimeout(BX.delegate(function(){if(!this._history.findItemById(e["ID"])){i=this.addHistoryItem(e);BX.CrmTimelineItemExpand.create(i.getWrapper(),null).run()}},this),1500)}},processLinkExternalAdd:function(t){var e,i;e=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e!==null){i=this.addHistoryItem(e);BX.CrmTimelineItemExpand.create(i.getWrapper(),null).run()}},processCommentExternalUpdate:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);var i=BX.prop.getObject(t,"HISTORY_ITEM",null);var r=this._history.findItemById(e);if(r instanceof BX.CrmHistoryItemComment&&i!==null){r.setData(i);r.switchToViewMode()}var n=this._fixedHistory.findItemById(e);if(n instanceof BX.CrmHistoryItemComment&&i!==null){n.setData(i);n.switchToViewMode()}},processCommentExternalDelete:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);window.setTimeout(BX.delegate(function(){var t=this._history.findItemById(e);if(t instanceof BX.CrmHistoryItemComment)this._history.deleteItem(t);var i=this._fixedHistory.findItemById(e);if(i instanceof BX.CrmHistoryItemComment)this._fixedHistory.deleteItem(i)},this),1200)},processDocumentExternalDelete:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);window.setTimeout(BX.delegate(function(){var t=this._history.findItemById(e);if(t instanceof BX.CrmHistoryItemDocument)this._history.deleteItem(t);var i=this._fixedHistory.findItemById(e);if(i instanceof BX.CrmHistoryItemDocument)this._fixedHistory.deleteItem(i)},this),1200)},processDocumentExternalUpdate:function(t){var e=BX.prop.getObject(t,"HISTORY_ITEM",null);var i=BX.prop.getInteger(e,"ID",0);var r=this._history.findItemById(i);if(r instanceof BX.CrmHistoryItemDocument&&e!==null){r.setData(e);r.updateWrapper()}var n=this._fixedHistory.findItemById(i);if(n instanceof BX.CrmHistoryItemDocument&&e!==null){n.setData(e);n.updateWrapper()}},processChangeBinding:function(t){var e=BX.prop.getString(t,"OLD_ID",0);var i=BX.prop.getString(t,"NEW_ID",0);var r=this._history.findItemById(e);if(r instanceof BX.CrmHistoryItem){r._id=i;var n=r.getData();n.ID=i;r.setData(n)}var s=this._fixedHistory.findItemById(e);if(s instanceof BX.CrmHistoryItem){s._id=i;var a=s.getData();a.ID=i;s.setData(a)}},processItemChangeFasten:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);var i=BX.prop.getObject(t,"HISTORY_ITEM",null);window.setTimeout(BX.delegate(function(){var t=this._fixedHistory.findItemById(e);if(i["IS_FIXED"]==="N"&&t){t.onSuccessUnfasten()}else if(i["IS_FIXED"]==="Y"&&!t){var r=this._history.findItemById(e);if(r){r.onSuccessFasten()}else{var n=this._fixedHistory.createItem(this._data);n._isFixed=true;this._fixedHistory.addItem(n,0);n.layout()}}},this),1200)},processItemExternalUpdate:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);var i=BX.prop.getObject(t,"HISTORY_ITEM",null);var r=this._history.findItemById(e);if(r&&i!==null){r.setData(i);r.markAsTerminated(this._history.checkItemForTermination(r));r.refreshLayout();if(r.isTerminated()){BX.addClass(r._wrapper,"crm-entity-stream-section-last")}}},processWaitExternalAdd:function(t){var e=BX.prop.getObject(t,"SCHEDULE_ITEM",null);if(e!==null){this.addScheduleItem(e)}},processWaitExternalUpdate:function(t){var e,i,r,n,s;e=BX.prop.getObject(t,"ENTITY",null);i=BX.prop.getObject(t,"SCHEDULE_ITEM",null);n=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e){if(n&&!BX.type.isPlainObject(n["ASSOCIATED_ENTITY"])){n["ASSOCIATED_ENTITY"]=e}var a=BX.prop.getInteger(e,"ID",0);var o=this._history.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.wait,a);for(var c=0,m=o.length;c<m;c++){s=o[c];s.setAssociatedEntityData(e);s.refreshLayout()}}if(i!==null){r=this._schedule.getItemByAssociatedEntity(BX.CrmEntityType.enumeration.wait,BX.prop.getInteger(i,"ASSOCIATED_ENTITY_ID"));if(!r){this.addScheduleItem(i)}else{r.setData(i);if(!r.isDone()){this._schedule.refreshItem(r)}else{if(n){this._schedule.transferItemToHistory(r,n);n=null}else{this._schedule.deleteItem(r)}}}}if(n!==null){s=this._history.findItemById(BX.prop.getString(n,"ID"));if(!s){s=this.addHistoryItem(n);BX.CrmTimelineItemExpand.create(s.getWrapper(),null).run()}else{s.setData(n);s.refreshLayout()}}},processWaitExternalDelete:function(t){var e=BX.prop.getInteger(t,"ENTITY_ID",0);var i=this._history.getItemsByAssociatedEntity(BX.CrmEntityType.enumeration.wait,e);for(var r=0,n=i.length;r<n;r++){this._history.deleteItem(i[r])}var s=this._schedule.getItemByAssociatedEntity(BX.CrmEntityType.enumeration.wait,e);if(s){this._schedule.deleteItem(s)}},processBizprocStatus:function(t){var e,i;e=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e!==null){i=this.addHistoryItem(e);BX.CrmTimelineItemExpand.create(i.getWrapper(),null).run()}},processScoringExternalAdd:function(t){var e,i;e=BX.prop.getObject(t,"HISTORY_ITEM",null);if(e!==null){i=this.addHistoryItem(e);BX.CrmTimelineItemExpand.create(i.getWrapper(),null).run()}},onEntityProgressChange:function(t,e){if(BX.prop.getInteger(e,"entityTypeId",0)!==this._ownerTypeId||BX.prop.getInteger(e,"entityId",0)!==this._ownerId){return}var i=BX.prop.getString(e,"semantics","");if(i===this._progressSemantics){return}this._progressSemantics=i;this._schedule.refreshLayout()},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},getOwnerTypeId:function(){return this._ownerTypeId},getOwnerId:function(){return this._ownerId},getOwnerInfo:function(){return this._ownerInfo},isStubCounterEnabled:function(){if(this._ownerId<=0){return false}return(this._ownerTypeId===BX.CrmEntityType.enumeration.deal||this._ownerTypeId===BX.CrmEntityType.enumeration.lead)&&this._progressSemantics==="process"},getSchedule:function(){return this._schedule},getHistory:function(){return this._history},getFixedHistory:function(){return this._fixedHistory},getWaitEditor:function(){return this._waitEditor},getSmsEditor:function(){return this._smsEditor},processSheduleLayoutChange:function(){},processHistoryLayoutChange:function(){this._schedule.refreshLayout()},processEditingCompletion:function(t){if(this._waitEditor&&t===this._waitEditor){this._waitEditor.setVisible(false);this._commentEditor.setVisible(true);this._menuBar.setActiveItemById("comment")}if(this._smsEditor&&t===this._smsEditor){this._smsEditor.setVisible(false);this._commentEditor.setVisible(true);this._menuBar.setActiveItemById("comment")}},processEditingCancellation:function(t){if(this._waitEditor&&t===this._waitEditor){this._waitEditor.setVisible(false);this._commentEditor.setVisible(true);this._menuBar.setActiveItemById("comment")}if(this._smsEditor&&t===this._smsEditor){this._smsEditor.setVisible(false);this._commentEditor.setVisible(true);this._menuBar.setActiveItemById("comment")}},addScheduleItem:function(t){var e=this._schedule.createItem(t);var i=this._schedule.calculateItemIndex(e);var r=this._schedule.createAnchor(i);this._schedule.addItem(e,i);e.layout({anchor:r});return e},addHistoryItem:function(t){var e=this._history.createItem(t);var i=this._history.calculateItemIndex(e);var r=this._history.createAnchor(i);this._history.addItem(e,i);e.layout({anchor:r});return e},loadMediaPlayer:function(t,e,i,r,n){if(!n){n=0}var s=new BX.Fileman.Player(t,{sources:[{src:e,type:i}],isAudio:true,skin:"vjs-timeline_player-skin",width:350,height:30,duration:n,onInit:function(t){t.vjsPlayer.controlBar.removeChild("timeDivider");t.vjsPlayer.controlBar.removeChild("durationDisplay");t.vjsPlayer.controlBar.removeChild("fullscreenToggle");t.vjsPlayer.controlBar.addChild("timeDivider");t.vjsPlayer.controlBar.addChild("durationDisplay");if(!t.isPlaying()){t.play()}}});BX.cleanNode(r,false);r.appendChild(s.createElement());s.init()},onActivityCreated:function(t,e){},isSpotlightShowed:function(){return this._spotlightFastenShowed},setSpotlightShowed:function(){this._spotlightFastenShowed=true}};BX.CrmTimelineManager.instances={};BX.CrmTimelineManager.create=function(t,e){var i=new BX.CrmTimelineManager;i.initialize(t,e);this.instances[i.getId()]=i;return i}}if(typeof BX.CrmTimeline==="undefined"){BX.CrmTimeline=function(){this._id="";this._settings={};this._container=null;this._manager=null;this._activityEditor=null;this._userTimezoneOffset=null;this._serverTimezoneOffset=null;this._timeFormat="";this._year=0;this._isStubMode=false;this._userId=0;this._readOnly=false;this._serviceUrl=""};BX.CrmTimeline.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._container=BX(this.getSetting("container"));if(!BX.type.isElementNode(this._container)){throw"BX.CrmTimeline. Container node is not found."}this._editorContainer=BX(this.getSetting("editorContainer"));this._manager=this.getSetting("manager");if(!(this._manager instanceof BX.CrmTimelineManager)){throw"BX.CrmTimeline. Manager instance is not found."}var i=BX.message("FORMAT_DATETIME").replace(/:SS/,"");var r=BX.message("FORMAT_DATE");this._timeFormat=BX.date.convertBitrixFormat(BX.util.trim(i.replace(r,"")));this._year=(new Date).getFullYear();this._activityEditor=this.getSetting("activityEditor");this._isStubMode=BX.prop.getBoolean(this._settings,"isStubMode",false);this._readOnly=BX.prop.getBoolean(this._settings,"readOnly",false);this._userId=BX.prop.getInteger(this._settings,"userId",0);this._serviceUrl=BX.prop.getString(this._settings,"serviceUrl","");this.doInitialize()},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},doInitialize:function(){},layout:function(){},isStubMode:function(){return this._isStubMode},isReadOnly:function(){return this._readOnly},getUserId:function(){return this._userId},getServiceUrl:function(){return this._serviceUrl},refreshLayout:function(){},getManager:function(){return this._manager},getOwnerInfo:function(){return this._manager.getOwnerInfo()},reload:function(){var t=this.getSetting("currentUrl");var e=this.getSetting("ajaxId");if(e!==""){BX.ajax.insertToNode(BX.util.add_url_param(t,{bxajaxid:e}),"comp_"+e)}else{window.location=t}},getUserTimezoneOffset:function(){if(!this._userTimezoneOffset){this._userTimezoneOffset=parseInt(BX.message("USER_TZ_OFFSET"));if(isNaN(this._userTimezoneOffset)){this._userTimezoneOffset=0}}return this._userTimezoneOffset},getServerTimezoneOffset:function(){if(!this._serverTimezoneOffset){this._serverTimezoneOffset=parseInt(BX.message("SERVER_TZ_OFFSET"));if(isNaN(this._serverTimezoneOffset)){this._serverTimezoneOffset=0}}return this._serverTimezoneOffset},formatTime:function(t,e,i){return BX.date.format(this._timeFormat,t,e,i)},formatDate:function(t){return BX.date.format([["today","today"],["tommorow","tommorow"],["yesterday","yesterday"],["",t.getFullYear()===this._year?"j F":"j F Y"]],t)},cutOffText:function(t,e){if(!BX.type.isNumber(e)){e=0}if(e<=0||t.length<=e){return t}var i=e-1;var r=t.substring(i).search(/\s/i);if(r>0){i+=r}return t.substring(0,i)+"..."}}}if(typeof BX.CrmHistory==="undefined"){BX.CrmHistory=function(){BX.CrmHistory.superclass.constructor.apply(this);this._items=[];this._wrapper=null;this._fixedHistory=null;this._emptySection=null;this._currentDaySection=null;this._lastDaySection=null;this._lastDate=null;this._anchor=null;this._history=this;this._enableLoading=false;this._navigation=null;this._scrollHandler=null;this._loadingWaiter=null;this._filterId="";this._isFilterApplied=false;this._isFilterShown=false;this._isRequestRunning=false;this._filterButton=null;this._filterWrapper=null;this._filterResultStub=null};BX.extend(BX.CrmHistory,BX.CrmTimeline);BX.CrmHistory.prototype.doInitialize=function(){this._fixedHistory=this.getSetting("fixedHistory");this._ownerTypeId=this.getSetting("ownerTypeId");this._ownerId=this.getSetting("ownerId");this._serviceUrl=this.getSetting("serviceUrl","");if(!this.isStubMode()){var t=this.getSetting("itemData");if(!BX.type.isArray(t)){t=[]}var e,i,r;for(e=0,i=t.length;e<i;e++){r=this.createItem(t[e]);this._items.push(r)}this._navigation=this.getSetting("navigation",{});this._filterWrapper=BX("timeline-filter");this._filterId=BX.prop.getString(this._settings,"filterId",this._id);this._isFilterShown=this._filterWrapper&&BX.hasClass(this._filterWrapper,"crm-entity-stream-section-filter-show");this._isFilterApplied=BX.prop.getBoolean(this._settings,"isFilterApplied",false);BX.addCustomEvent("BX.Main.Filter:apply",this.onFilterApply.bind(this))}};BX.CrmHistory.prototype.layout=function(){this._wrapper=BX.create("DIV",{});this._container.appendChild(this._wrapper);var t=BX.prop.extractDate(new Date);var e,i,r;if(!this.isStubMode()){if(this._filterWrapper){var n=this._filterWrapper.querySelector(".crm-entity-stream-filter-close");if(n){BX.bind(n,"click",this.onFilterClose.bind(this))}}for(e=0,i=this._items.length;e<i;e++){r=this._items[e];r.setContainer(this._wrapper);var s=r.getCreatedDate();if(this._lastDate===null||this._lastDate.getTime()!==s.getTime()){this._lastDate=s;if(t.getTime()===s.getTime()){this._currentDaySection=this._lastDaySection=this.createCurrentDaySection();this._wrapper.appendChild(this._currentDaySection)}else{this._lastDaySection=this.createDaySection(this._lastDate);this._wrapper.appendChild(this._lastDaySection)}}r._lastDate=this._lastDate;r.layout()}this.enableLoading(this._items.length>0);this.refreshLayout()}else{this._currentDaySection=this._lastDaySection=this.createCurrentDaySection();this._wrapper.appendChild(this._currentDaySection);this._wrapper.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-createEntity crm-entity-stream-section-last"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-info"}}),BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}}),BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},text:BX.message("CRM_TIMELINE_HISTORY_STUB")})]})]})]}))}this._manager.processHistoryLayoutChange()};BX.CrmHistory.prototype.refreshLayout=function(){if(this._filterWrapper){if(this._wrapper.firstChild&&this._filterWrapper!==this._wrapper.firstChild){this._wrapper.insertBefore(this._filterWrapper,this._wrapper.firstChild)}else if(!this._wrapper.firstChild&&this._filterWrapper.parentNode!==this._wrapper){this._wrapper.appendChild(this._filterWrapper)}}this.adjustFilterButton();var t=this._items.length;if(t===0&&this._isFilterApplied){if(!this._filterEmptyResultSection){this._filterEmptyResultSection=this.createFilterEmptyResultSection()}this._wrapper.appendChild(this._filterEmptyResultSection);return}if(this._filterEmptyResultSection){this._filterEmptyResultSection=BX.remove(this._filterEmptyResultSection)}for(var e=0;e<t-1;e++){var i=this._items[e];if(i.isTerminated()){i.markAsTerminated(false)}}this._items[t-1].markAsTerminated(true)};BX.CrmHistory.prototype.calculateItemIndex=function(t){return 0};BX.CrmHistory.prototype.checkItemForTermination=function(t){return this.getLastItem()===t};BX.CrmHistory.prototype.hasContent=function(){return this._items.length>0||this._isFilterApplied||this._isStubMode};BX.CrmHistory.prototype.getLastItem=function(){return this._items.length>0?this._items[this._items.length-1]:null};BX.CrmHistory.prototype.getItemByIndex=function(t){return t<this._items.length?this._items[t]:null};BX.CrmHistory.prototype.getItemCount=function(){return this._items.length};BX.CrmHistory.prototype.removeItemByIndex=function(t){if(t<this._items.length){this._items.splice(t,1)}};BX.CrmHistory.prototype.getItemIndex=function(t){for(var e=0,i=this._items.length;e<i;e++){if(this._items[e]===t){return e}}return-1};BX.CrmHistory.prototype.getItemsByAssociatedEntity=function(t,e){if(!BX.type.isNumber(t)){t=parseInt(t)}if(!BX.type.isNumber(e)){e=parseInt(e)}if(isNaN(t)||t<=0||isNaN(e)||e<=0){return[]}var i=[];for(var r=0,n=this._items.length;r<n;r++){var s=this._items[r];if(s.getAssociatedEntityTypeId()===t&&s.getAssociatedEntityId()===e){i.push(s)}}return i};BX.CrmHistory.prototype.findItemById=function(t){t=t.toString();for(var e=0,i=this._items.length;e<i;e++){if(this._items[e].getId()===t){return this._items[e]}}return null};BX.CrmHistory.prototype.createFilterEmptyResultSection=function(){return BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-filter-empty"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-filter-empty"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-filter-empty-img"}}),BX.create("DIV",{attrs:{className:"crm-entity-stream-filter-empty-text"},text:this.getMessage("filterEmptyResultStub")})]})]})]})};BX.CrmHistory.prototype.adjustFilterButton=function(){if(!this._filterWrapper){return}if(!this._isFilterShown&&this._items.length===0){if(!this._emptySection){this._emptySection=this.createEmptySection()}this._wrapper.insertBefore(this._emptySection,this._filterWrapper)}else if(this._emptySection){this._emptySection=BX.remove(this._emptySection)}if(!this._filterButton){this._filterButton=BX.create("BUTTON",{attrs:{className:"crm-entity-stream-filter-label"},text:this.getMessage("filterButtonCaption")});BX.bind(this._filterButton,"click",function(t){this.showFilter()}.bind(this))}var t=this._wrapper.querySelector(".crm-entity-stream-section-today-label, .crm-entity-stream-section-planned-label, .crm-entity-stream-section-history-label");if(t){var e=t.querySelector(".crm-entity-stream-section-content");if(e){if(this._filterButton.parentNode!==e){e.appendChild(this._filterButton)}}}if(this._isFilterApplied){BX.addClass(this._filterButton,"crm-entity-stream-filter-label-active")}else{BX.removeClass(this._filterButton,"crm-entity-stream-filter-label-active")}};BX.CrmHistory.prototype.showFilter=function(t){if(!this._filterWrapper){return}BX.removeClass(this._filterWrapper,"crm-entity-stream-section-filter-hide");BX.addClass(this._filterWrapper,"crm-entity-stream-section-filter-show");this._isFilterShown=true;if(BX.prop.getBoolean(t,"enableAdjust",true)){this.adjustFilterButton()}};BX.CrmHistory.prototype.hideFilter=function(t){if(!this._filterWrapper){return}BX.removeClass(this._filterWrapper,"crm-entity-stream-section-filter-show");BX.addClass(this._filterWrapper,"crm-entity-stream-section-filter-hide");this._isFilterShown=false;if(BX.prop.getBoolean(t,"enableAdjust",true)){this.adjustFilterButton()}};BX.CrmHistory.prototype.onFilterClose=function(t){this.hideFilter();window.setTimeout(function(){var t=BX.Main.filterManager.getById(this._filterId);if(t){t.resetFilter()}}.bind(this),500)};BX.CrmHistory.prototype.createEmptySection=function(){return BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-planned-label"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"}})]})};BX.CrmHistory.prototype.createCurrentDaySection=function(){return BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-today-label"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-today-label"},text:this.formatDate(BX.prop.extractDate(new Date))})]})]})};BX.CrmHistory.prototype.createDaySection=function(t){return BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history-label"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-history-label"},text:this.formatDate(t)})]})]})};BX.CrmHistory.prototype.createAnchor=function(t){if(this._emptySection){this._emptySection=BX.remove(this._emptySection)}if(this._currentDaySection===null){this._currentDaySection=this.createCurrentDaySection();if(this._wrapper.firstChild){this._wrapper.insertBefore(this._currentDaySection,this._wrapper.firstChild)}else{this._wrapper.appendChild(this._currentDaySection)}}if(this._anchor===null){this._anchor=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-shadow"}});if(this._currentDaySection.nextSibling){this._wrapper.insertBefore(this._anchor,this._currentDaySection.nextSibling)}else{this._wrapper.appendChild(this._anchor)}}return this._anchor};BX.CrmHistory.prototype.createActivityItem=function(t){var e=BX.prop.getInteger(t,"TYPE_ID",BX.CrmTimelineType.undefined);var i=BX.prop.getInteger(t,"TYPE_CATEGORY_ID",0);if(e!==BX.CrmTimelineType.activity){return null}if(i===BX.CrmActivityType.email){return BX.CrmHistoryItemEmail.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}if(i===BX.CrmActivityType.call){return BX.CrmHistoryItemCall.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(i===BX.CrmActivityType.meeting){return BX.CrmHistoryItemMeeting.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(i===BX.CrmActivityType.task){return BX.CrmHistoryItemTask.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(i===BX.CrmActivityType.provider){var r=BX.prop.getString(BX.prop.getObject(t,"ASSOCIATED_ENTITY",{}),"PROVIDER_ID","");if(r==="CRM_WEBFORM"){return BX.CrmHistoryItemWebForm.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(r==="CRM_SMS"){return BX.CrmHistoryItemSms.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t,smsStatusDescriptions:this._manager.getSetting("smsStatusDescriptions",{}),smsStatusSemantics:this._manager.getSetting("smsStatusSemantics",{})})}else if(r==="CRM_REQUEST"){return BX.CrmHistoryItemActivityRequest.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(r==="IMOPENLINES_SESSION"){return BX.CrmHistoryItemOpenLine.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(r==="REST_APP"){return BX.CrmHistoryItemActivityRestApplication.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(r==="VISIT_TRACKER"){return BX.CrmHistoryItemVisit.create(t["ID"],{history:this,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}}return BX.CrmHistoryItemActivity.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})};BX.CrmHistory.prototype.createOrderEntityItem=function(t){var e=BX.prop.getInteger(t,"ASSOCIATED_ENTITY_TYPE_ID",0);var i=BX.prop.getInteger(t,"TYPE_CATEGORY_ID",0);if(e!==BX.CrmEntityType.enumeration.order){return null}if(i===BX.CrmTimelineType.creation){return BX.CrmHistoryItemOrderCreation.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}if(i===BX.CrmTimelineType.modification){return BX.CrmHistoryItemOrderModification.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}};BX.CrmHistory.prototype.createItem=function(t){var e=BX.prop.getInteger(t,"TYPE_ID",BX.CrmTimelineType.undefined);var i=BX.prop.getInteger(t,"TYPE_CATEGORY_ID",0);if(e===BX.CrmTimelineType.activity){return this.createActivityItem(t)}else if(e===BX.CrmTimelineType.order){return this.createOrderEntityItem(t)}else if(e===BX.CrmTimelineType.orderCheck){return BX.CrmHistoryItemOrcderCheck.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.creation){return BX.CrmHistoryItemCreation.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.restoration){return BX.CrmHistoryItemRestoration.create(t["ID"],{history:this._history,container:this._wrapper,data:t})}else if(e===BX.CrmTimelineType.link){return BX.CrmHistoryItemLink.create(t["ID"],{history:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.mark){return BX.CrmHistoryItemMark.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.comment){return BX.CrmHistoryItemComment.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.wait){return BX.CrmHistoryItemWait.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.document){return BX.CrmHistoryItemDocument.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.sender){return BX.CrmHistoryItemSender.create(t["ID"],{history:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.modification){return BX.CrmHistoryItemModification.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.conversion){return BX.CrmHistoryItemConversion.create(t["ID"],{history:this._history,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.bizproc){return BX.CrmHistoryItemBizproc.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(e===BX.CrmTimelineType.scoring){return BX.CrmHistoryItemScoring.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})}return BX.CrmHistoryItem.create(t["ID"],{history:this._history,fixedHistory:this._fixedHistory,container:this._wrapper,activityEditor:this._activityEditor,data:t})};BX.CrmHistory.prototype.addItem=function(t,e){if(!BX.type.isNumber(e)||e<0){e=this.calculateItemIndex(t)}if(e<this._items.length){this._items.splice(e,0,t)}else{this._items.push(t)}this.refreshLayout();this._manager.processHistoryLayoutChange()};BX.CrmHistory.prototype.deleteItem=function(t){var e=this.getItemIndex(t);if(e<0){return}t.clearLayout();this.removeItemByIndex(e);this.refreshLayout();this._manager.processHistoryLayoutChange()};BX.CrmHistory.prototype.resetLayout=function(){var t;for(t=this._items.length-1;t>=0;t--){this._items[t].clearLayout()}this._items=[];this._currentDaySection=this._lastDaySection=this._emptySection=this._filterEmptyResultSection=null;this._anchor=null;this._lastDate=null;var e=[];var i;for(t=0;i=this._wrapper.children[t];t++){if(i!==this._filterWrapper){e.push(i)}}for(t=0;i=e[t];t++){this._wrapper.removeChild(i)}};BX.CrmHistory.prototype.onWindowScroll=function(t){if(!this._loadingWaiter||!this._enableLoading||this._isRequestRunning){return}var e=this._loadingWaiter.getBoundingClientRect();if(e.top<=document.documentElement.clientHeight){this.loadItems()}};BX.CrmHistory.prototype.onFilterApply=function(t,e,i,r,n){if(t!==this._filterId){return}n.autoResolve=false;this._isFilterApplied=BX.prop.getString(e,"action","")==="apply";this._isRequestRunning=true;BX.CrmDataLoader.create(this._id,{serviceUrl:this.getSetting("serviceUrl",""),action:"GET_HISTORY_ITEMS",params:{GUID:this._id,OWNER_TYPE_ID:this._manager.getOwnerTypeId(),OWNER_ID:this._manager.getOwnerId()}}).load(function(t,e){this.resetLayout();this.bulkCreateItems(BX.prop.getArray(e,"HISTORY_ITEMS",[]));this.setNavigation(BX.prop.getObject(e,"HISTORY_NAVIGATION",{}));this.refreshLayout();if(this._items.length>0){this._manager.processHistoryLayoutChange()}r.fulfill();this._isRequestRunning=false}.bind(this))};BX.CrmHistory.prototype.bulkCreateItems=function(t){var e=t.length;if(e===0){return}if(this._filterEmptyResultSection){this._filterEmptyResultSection=BX.remove(this._filterEmptyResultSection)}var i=BX.prop.extractDate(new Date);var r,n;var s="";for(r=0;r<e;r++){var a=BX.prop.getInteger(t[r],"ID",0);if(a<=0){continue}s=BX.prop.getString(t[r],"CREATED_SERVER","");if(this.findItemById(a)!==null){continue}n=this.createItem(t[r]);this._items.push(n);var o=n.getCreatedDate();if(this._lastDate===null||this._lastDate.getTime()!==o.getTime()){this._lastDate=o;if(i.getTime()===o.getTime()){this._currentDaySection=this._lastDaySection=this.createCurrentDaySection();this._wrapper.appendChild(this._currentDaySection)}else{this._lastDaySection=this.createDaySection(this._lastDate);this._wrapper.appendChild(this._lastDaySection)}}n.layout()}};BX.CrmHistory.prototype.loadItems=function(){this._isRequestRunning=true;BX.CrmDataLoader.create(this._id,{serviceUrl:this.getSetting("serviceUrl",""),action:"GET_HISTORY_ITEMS",params:{GUID:this._id,OWNER_TYPE_ID:this._manager.getOwnerTypeId(),OWNER_ID:this._manager.getOwnerId(),NAVIGATION:this._navigation}}).load(function(t,e){this.bulkCreateItems(BX.prop.getArray(e,"HISTORY_ITEMS",[]));this.setNavigation(BX.prop.getObject(e,"HISTORY_NAVIGATION",{}));this.refreshLayout();if(this._items.length>0){this._manager.processHistoryLayoutChange()}this._isRequestRunning=false}.bind(this))};BX.CrmHistory.prototype.getNavigation=function(){return this._navigation};BX.CrmHistory.prototype.setNavigation=function(t){if(!BX.type.isPlainObject(t)){t={}}this._navigation=t;this.enableLoading(BX.prop.getString(this._navigation,"OFFSET_TIMESTAMP","")!=="")};BX.CrmHistory.prototype.isLoadingEnabled=function(){return this._enableLoading};BX.CrmHistory.prototype.enableLoading=function(t){t=!!t;if(this._enableLoading===t){return}this._enableLoading=t;if(this._enableLoading){if(this._items.length>0){this._loadingWaiter=this._items[this._items.length-1].getWrapper()}if(!this._scrollHandler){this._scrollHandler=BX.delegate(this.onWindowScroll,this);BX.bind(window,"scroll",this._scrollHandler)}}else{this._loadingWaiter=null;if(this._scrollHandler){BX.unbind(window,"scroll",this._scrollHandler);this._scrollHandler=null}}};BX.CrmHistory.prototype.getMessage=function(t){var e=BX.CrmHistory.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistory.messages==="undefined"){BX.CrmHistory.messages={}}BX.CrmHistory.instances={};BX.CrmHistory.create=function(t,e){var i=new BX.CrmHistory;i.initialize(t,e);this.instances[i.getId()]=i;return i}}if(typeof BX.CrmFixedHistory==="undefined"){BX.CrmFixedHistory=function(){BX.CrmFixedHistory.superclass.constructor.apply(this);this._items=[];this._wrapper=null;this._fixedHistory=this;this._history=this;this._isRequestRunning=false};BX.extend(BX.CrmFixedHistory,BX.CrmHistory);BX.CrmFixedHistory.prototype.doInitialize=function(){var t=BX.message("FORMAT_DATETIME").replace(/:SS/,"");this._timeFormat=BX.date.convertBitrixFormat(t);var e=this.getSetting("itemData");if(!BX.type.isArray(e)){e=[]}var i,r,n;for(i=0,r=e.length;i<r;i++){n=this.createItem(e[i]);n._isFixed=true;this._items.push(n)}};BX.CrmFixedHistory.prototype.setHistory=function(t){this._history=t};BX.CrmFixedHistory.prototype.checkItemForTermination=function(t){return false};BX.CrmFixedHistory.prototype.layout=function(){this._wrapper=BX.create("DIV",{});this.createAnchor();this._container.insertBefore(this._wrapper,this._editorContainer.nextElementSibling);for(var t=0;t<this._items.length;t++){this._items[t].setContainer(this._wrapper);this._items[t].layout()}this.refreshLayout();this._manager.processHistoryLayoutChange()};BX.CrmFixedHistory.prototype.refreshLayout=function(){};BX.CrmFixedHistory.prototype.formatDate=function(t){};BX.CrmFixedHistory.prototype.createCurrentDaySection=function(){};BX.CrmFixedHistory.prototype.createDaySection=function(t){};BX.CrmFixedHistory.prototype.createAnchor=function(t){this._anchor=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-fixed-anchor"}});this._wrapper.appendChild(this._anchor)};BX.CrmFixedHistory.prototype.onWindowScroll=function(t){};BX.CrmFixedHistory.prototype.onItemsLoad=function(t,e){};BX.CrmFixedHistory.prototype.loadItems=function(){this._isRequestRunning=true;BX.CrmDataLoader.create(this._id,{serviceUrl:this.getSetting("serviceUrl",""),action:"GET_FIXED_HISTORY_ITEMS",params:{OWNER_TYPE_ID:this._manager.getOwnerTypeId(),OWNER_ID:this._manager.getOwnerId(),LAST_ITEM_TIME:this._lastLoadedItemTimestamp}}).load(BX.delegate(this.onItemsLoad,this))};BX.CrmFixedHistory.instances={};BX.CrmFixedHistory.create=function(t,e){var i=new BX.CrmFixedHistory;i.initialize(t,e);this.instances[i.getId()]=i;return i}}if(typeof BX.CrmSchedule==="undefined"){BX.CrmSchedule=function(){BX.CrmSchedule.superclass.constructor.apply(this);this._items=[];this._history=null;this._wrapper=null;this._anchor=null;this._stub=null;this._timeFormat=""};BX.extend(BX.CrmSchedule,BX.CrmTimeline);BX.CrmSchedule.prototype.doInitialize=function(){var t=BX.message("FORMAT_DATETIME").replace(/:SS/,"");var e=BX.message("FORMAT_DATE");var i=BX.util.trim(t.replace(e,""));this._timeFormat=BX.date.convertBitrixFormat(i);if(!this.isStubMode()){var r=this.getSetting("itemData");if(!BX.type.isArray(r)){r=[]}var n,s,a;for(n=0,s=r.length;n<s;n++){a=this.createItem(r[n]);if(a){this._items.push(a)}}}};BX.CrmSchedule.prototype.layout=function(){this._wrapper=BX.create("DIV",{});this._container.appendChild(this._wrapper);var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-planned-label"},text:this.getMessage("planned")});var e="crm-entity-stream-section crm-entity-stream-section-planned-label";this._wrapper.appendChild(BX.create("DIV",{attrs:{className:e},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[t]})]}));if(this.isStubMode()){this.addStub()}else{var i=this._items.length;if(i===0){this.addStub()}else{for(var r=0;r<i;r++){var n=this._items[r];n.setContainer(this._wrapper);n.layout()}}}this.refreshLayout();this._manager.processSheduleLayoutChange()};BX.CrmSchedule.prototype.refreshLayout=function(){var t=this._items.length;if(t===0){this.addStub();if(this._history&&this._history.hasContent()){BX.removeClass(this._stub,"crm-entity-stream-section-last")}else{BX.addClass(this._stub,"crm-entity-stream-section-last")}var e=this._stub.querySelector(".crm-entity-stream-section-icon");if(e){if(this._manager.isStubCounterEnabled()){BX.addClass(e,"crm-entity-stream-section-counter")}else{BX.removeClass(e,"crm-entity-stream-section-counter")}}return}var i,r;if(this._history&&this._history.hasContent()){for(i=0;i<t;i++){r=this._items[i];if(r.isTerminated()){r.markAsTerminated(false)}}}else{if(t>1){for(i=0;i<t-1;i++){r=this._items[i];if(r.isTerminated()){r.markAsTerminated(false)}}}this._items[t-1].markAsTerminated(true)}};BX.CrmSchedule.prototype.formatDateTime=function(t){var e=new Date;return BX.date.format([["today","today, "+this._timeFormat],["tommorow","tommorow, "+this._timeFormat],["yesterday","yesterday, "+this._timeFormat],["",(t.getFullYear()===e.getFullYear()?"j F ":"j F Y ")+this._timeFormat]],t,e)};BX.CrmSchedule.prototype.checkItemForTermination=function(t){if(this._history&&this._history.getItemCount()>0){return false}return this.getLastItem()===t};BX.CrmSchedule.prototype.getLastItem=function(){return this._items.length>0?this._items[this._items.length-1]:null};BX.CrmSchedule.prototype.calculateItemIndex=function(t){var e,i;var r=t.getDeadline();if(r){for(e=0,i=this._items.length;e<i;e++){var n=this._items[e].getDeadline();if(!n||r<=n){return e}}}else{var s=t.getSourceId();for(e=0,i=this._items.length;e<i;e++){if(this._items[e].getDeadline()){continue}if(s<=this._items[e].getSourceId()){return e}}}return this._items.length};BX.CrmSchedule.prototype.getItemCount=function(){return this._items.length};BX.CrmSchedule.prototype.getItems=function(){return this._items};BX.CrmSchedule.prototype.getItemByAssociatedEntity=function(t,e){if(!BX.type.isNumber(t)){t=parseInt(t)}if(!BX.type.isNumber(e)){e=parseInt(e)}if(isNaN(t)||t<=0||isNaN(e)||e<=0){return null}for(var i=0,r=this._items.length;i<r;i++){var n=this._items[i];if(n.getAssociatedEntityTypeId()===t&&n.getAssociatedEntityId()===e){return n}}return null};BX.CrmSchedule.prototype.getItemByData=function(t){if(!BX.type.isPlainObject(t)){return null}return this.getItemByAssociatedEntity(BX.prop.getInteger(t,"ASSOCIATED_ENTITY_TYPE_ID",0),BX.prop.getInteger(t,"ASSOCIATED_ENTITY_ID",0))};BX.CrmSchedule.prototype.getItemIndex=function(t){for(var e=0,i=this._items.length;e<i;e++){if(this._items[e]===t){return e}}return-1};BX.CrmSchedule.prototype.getItemByIndex=function(t){return t<this._items.length?this._items[t]:null};BX.CrmSchedule.prototype.removeItemByIndex=function(t){if(t<this._items.length){this._items.splice(t,1)}};BX.CrmSchedule.prototype.createItem=function(t){var e=BX.prop.getInteger(t,"ASSOCIATED_ENTITY_TYPE_ID",0);var i=BX.prop.getInteger(t,"ASSOCIATED_ENTITY_ID",0);var r=BX.prop.getObject(t,"ASSOCIATED_ENTITY",{});var n=BX.CrmEntityType.resolveName(e)+"_"+i.toString();if(e===BX.CrmEntityType.enumeration.wait){return BX.CrmScheduleItemWait.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else{var s=BX.prop.getInteger(r,"TYPE_ID",0);var a=BX.prop.getString(r,"PROVIDER_ID","");if(s===BX.CrmActivityType.email){return BX.CrmScheduleItemEmail.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(s===BX.CrmActivityType.call){return BX.CrmScheduleItemCall.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(s===BX.CrmActivityType.meeting){return BX.CrmScheduleItemMeeting.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(s===BX.CrmActivityType.task){return BX.CrmScheduleItemTask.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(s===BX.CrmActivityType.provider){if(a==="CRM_WEBFORM"){return BX.CrmScheduleItemWebForm.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(a==="CRM_REQUEST"){return BX.CrmScheduleItemActivityRequest.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(a==="IMOPENLINES_SESSION"){return BX.CrmScheduleItemActivityOpenLine.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}else if(a==="REST_APP"){return BX.CrmScheduleItemActivityRestApplication.create(n,{schedule:this,container:this._wrapper,activityEditor:this._activityEditor,data:t})}}}return null};BX.CrmSchedule.prototype.addItem=function(t,e){if(!BX.type.isNumber(e)||e<0){e=this.calculateItemIndex(t)}if(e<this._items.length){this._items.splice(e,0,t)}else{this._items.push(t)}this.removeStub();this.refreshLayout();this._manager.processSheduleLayoutChange()};BX.CrmSchedule.prototype.getHistory=function(){return this._history};BX.CrmSchedule.prototype.setHistory=function(t){this._history=t};BX.CrmSchedule.prototype.createAnchor=function(t){this._anchor=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-shadow"}});if(t>=0&&t<this._items.length){this._wrapper.insertBefore(this._anchor,this._items[t].getWrapper())}else{this._wrapper.appendChild(this._anchor)}return this._anchor};BX.CrmSchedule.prototype.deleteItem=function(t){var e=this.getItemIndex(t);if(e<0){return}t.clearLayout();this.removeItemByIndex(e);this.refreshLayout();this._manager.processSheduleLayoutChange()};BX.CrmSchedule.prototype.refreshItem=function(t){var e=this.getItemIndex(t);if(e<0){return}this.removeItemByIndex(e);var i=this.createItem(t.getData());var r=this.calculateItemIndex(i);if(r===e){this.addItem(t,r);t.refreshLayout();t.addWrapperClass("crm-entity-stream-section-updated",1e3);return}var n=this.createAnchor(r);this.addItem(i,r);i.layout({add:false});var s=BX.CrmTimelineItemAnimation.create("",{initialItem:t,finalItem:i,anchor:n});s.run()};BX.CrmSchedule.prototype.transferItemToHistory=function(t,e){var i=this.getItemIndex(t);if(i<0){return}this.removeItemByIndex(i);this.refreshLayout();this._manager.processSheduleLayoutChange();var r=this._history.createItem(e);this._history.addItem(r,0);r.layout({add:false});var n=BX.CrmTimelineItemAnimationNew.create("",{initialItem:t,finalItem:r,anchor:this._history.createAnchor(),events:{complete:BX.delegate(this.onTransferComplete,this)}});n.run()};BX.CrmSchedule.prototype.onTransferComplete=function(){this._history.refreshLayout();if(this._items.length===0){this.addStub()}};BX.CrmSchedule.prototype.onItemMarkedAsDone=function(t,e){};BX.CrmSchedule.prototype.addStub=function(){if(!this._stub){var t="crm-entity-stream-section crm-entity-stream-section-planned crm-entity-stream-section-notTask";var e="crm-entity-stream-section-icon crm-entity-stream-section-icon-info";var i=this.getMessage("stub");var r=this._manager.getOwnerTypeId();if(r===BX.CrmEntityType.enumeration.lead){i=this.getMessage("leadStub")}else if(r===BX.CrmEntityType.enumeration.deal){i=this.getMessage("dealStub")}if(this._manager.isStubCounterEnabled()){e+=" crm-entity-stream-section-counter"}this._stub=BX.create("DIV",{attrs:{className:t},children:[BX.create("DIV",{attrs:{className:e}}),BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},text:i})]})]})]});this._wrapper.appendChild(this._stub)}if(this._history&&this._history.getItemCount()>0){BX.removeClass(this._stub,"crm-entity-stream-section-last")}else{BX.addClass(this._stub,"crm-entity-stream-section-last")}};BX.CrmSchedule.prototype.removeStub=function(){if(this._stub){this._stub=BX.remove(this._stub)}};BX.CrmSchedule.items={};BX.CrmSchedule.prototype.getMessage=function(t){var e=BX.CrmSchedule.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmSchedule.messages==="undefined"){BX.CrmSchedule.messages={}}BX.CrmSchedule.create=function(t,e){var i=new BX.CrmSchedule;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmEntityChatLayoutType==="undefined"){BX.CrmEntityChatLayoutType={none:0,invitation:1,summary:2}}if(typeof BX.CrmEntityChat==="undefined"){BX.CrmEntityChat=function(){BX.CrmEntityChat.superclass.constructor.apply(this);this._data=null;this._layoutType=BX.CrmEntityChatLayoutType.none;this._wrapper=null;this._contentWrapper=null;this._messageWrapper=null;this._messageDateNode=null;this._messageTexWrapper=null;this._messageTextNode=null;this._userWrapper=null;this._extraUserCounter=null;this._openChatHandler=BX.delegate(this.onOpenChat,this)};BX.extend(BX.CrmEntityChat,BX.CrmTimeline);BX.CrmEntityChat.prototype.doInitialize=function(){this._data=BX.prop.getObject(this._settings,"data",{})};BX.CrmEntityChat.prototype.getData=function(){return this._data};BX.CrmEntityChat.prototype.setData=function(t){this._data=BX.type.isPlainObject(t)?t:{}};BX.CrmEntityChat.prototype.isEnabled=function(){return BX.prop.getBoolean(this._data,"ENABLED",true)};BX.CrmEntityChat.prototype.getChatId=function(){return BX.prop.getInteger(this._data,"CHAT_ID",0)};BX.CrmEntityChat.prototype.getUserId=function(){var t=parseInt(top.BX.message("USER_ID"));return!isNaN(t)?t:0};BX.CrmEntityChat.prototype.getMessageData=function(){return BX.prop.getObject(this._data,"MESSAGE",{})};BX.CrmEntityChat.prototype.setMessageData=function(t){this._data["MESSAGE"]=BX.type.isPlainObject(t)?t:{}};BX.CrmEntityChat.prototype.getUserInfoData=function(){return BX.prop.getObject(this._data,"USER_INFOS",{})};BX.CrmEntityChat.prototype.setUserInfoData=function(t){this._data["USER_INFOS"]=BX.type.isPlainObject(t)?t:{}};BX.CrmEntityChat.prototype.hasUserInfo=function(t){return t>0&&BX.type.isPlainObject(this.getUserInfoData()[t])};BX.CrmEntityChat.prototype.getUserInfo=function(t){var e=this.getUserInfoData();return t>0&&BX.type.isPlainObject(e[t])?e[t]:null};BX.CrmEntityChat.prototype.removeUserInfo=function(t){var e=this.getUserInfoData();if(t>0&&BX.type.isPlainObject(e[t])){delete e[t]}};BX.CrmEntityChat.prototype.setUnreadMessageCounter=function(t,e){var i=this.getUserInfoData();if(t>0&&BX.type.isPlainObject(i[t])){i[t]["counter"]=e}};BX.CrmEntityChat.prototype.layout=function(){if(!this.isEnabled()||this.isStubMode()){return}this._wrapper=BX.create("div",{props:{className:"crm-entity-stream-section crm-entity-stream-section-live-im"}});this._container.appendChild(this._wrapper);this._wrapper.appendChild(BX.create("div",{props:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-live-im"}}));this._contentWrapper=BX.create("div",{props:{className:"crm-entity-stream-content-live-im-detail"}});this._wrapper.appendChild(BX.create("div",{props:{className:"crm-entity-stream-section-content"},children:[BX.create("div",{props:{className:"crm-entity-stream-content-event"},children:[this._contentWrapper]})]}));this._userWrapper=BX.create("div",{props:{className:"crm-entity-stream-live-im-user-avatars"}});this._contentWrapper.appendChild(BX.create("div",{props:{className:"crm-entity-stream-live-im-users"},children:[this._userWrapper]}));this._extraUserCounter=BX.create("div",{props:{className:"crm-entity-stream-live-im-user-counter"}});this._contentWrapper.appendChild(this._extraUserCounter);this._layoutType=BX.CrmEntityChatLayoutType.none;if(this.getChatId()>0){this.renderSummary()}else{this.renderInvitation()}BX.bind(this._contentWrapper,"click",this._openChatHandler);BX.addCustomEvent("onPullEvent-im",this.onChatEvent.bind(this))};BX.CrmEntityChat.prototype.refreshLayout=function(){BX.cleanNode(this._contentWrapper);this._userWrapper=BX.create("div",{props:{className:"crm-entity-stream-live-im-user-avatars"}});this._contentWrapper.appendChild(BX.create("div",{props:{className:"crm-entity-stream-live-im-users"},children:[this._userWrapper]}));this._extraUserCounter=BX.create("div",{props:{className:"crm-entity-stream-live-im-user-counter"}});this._contentWrapper.appendChild(this._extraUserCounter);this._layoutType=BX.CrmEntityChatLayoutType.none;if(this.getChatId()>0){this.renderSummary()}else{this.renderInvitation()}};BX.CrmEntityChat.prototype.renderInvitation=function(){this._layoutType=BX.CrmEntityChatLayoutType.invitation;this.refreshUsers();this._messageTextNode=BX.create("div",{props:{className:"crm-entity-stream-live-im-user-invite-text"}});this._contentWrapper.appendChild(this._messageTextNode);this._messageTextNode.innerHTML=this.getMessage("invite")};BX.CrmEntityChat.prototype.renderSummary=function(){this._layoutType=BX.CrmEntityChatLayoutType.summary;this.refreshUsers();this._contentWrapper.appendChild(BX.create("div",{props:{className:"crm-entity-stream-live-im-separator"}}));this._messageWrapper=BX.create("div",{props:{className:"crm-entity-stream-live-im-messanger"}});this._contentWrapper.appendChild(this._messageWrapper);this._messageDateNode=BX.create("div",{props:{className:"crm-entity-stream-live-im-time"}});this._messageWrapper.appendChild(this._messageDateNode);this._messageTexWraper=BX.create("div",{props:{className:"crm-entity-stream-live-im-message"}});this._messageWrapper.appendChild(this._messageTexWraper);this._messageTextNode=BX.create("div",{props:{className:"crm-entity-stream-live-im-message-text"}});this._messageTexWraper.appendChild(this._messageTextNode);this._messageCounterNode=BX.create("div",{props:{className:"crm-entity-stream-live-im-message-counter"}});this._messageWrapper.appendChild(this._messageCounterNode);this.refreshSummary()};BX.CrmEntityChat.prototype.refreshUsers=function(){BX.cleanNode(this._userWrapper);var t=this.getUserInfoData();var e=Object.values(t);if(e.length===0){this._userWrapper.appendChild(BX.create("span",{props:{className:"crm-entity-stream-live-im-user-avatar ui-icon ui-icon-common-user"},children:[BX.create("i")]}))}else{var i=e.length>=3?3:e.length;for(var r=0;r<i;r++){var n=e[r];var s=BX.create("i");var a=BX.prop.getString(n,"avatar","");if(a!==""){s.style.backgroundImage="url("+a+")"}this._userWrapper.appendChild(BX.create("span",{props:{className:"crm-entity-stream-live-im-user-avatar ui-icon ui-icon-common-user"},children:[s]}))}}if(this._layoutType===BX.CrmEntityChatLayoutType.summary){if(e.length>3){this._extraUserCounter.display="";this._extraUserCounter.innerHTML="+"+(e.length-3).toString()}else{if(this._extraUserCounter.innerHTML!==""){this._extraUserCounter.innerHTML=""}this._extraUserCounter.display="none"}}else{if(this._extraUserCounter.innerHTML!==""){this._extraUserCounter.innerHTML=""}this._extraUserCounter.display="none";this._userWrapper.appendChild(BX.create("span",{props:{className:"crm-entity-stream-live-im-user-invite-btn"}}))}};BX.CrmEntityChat.prototype.refreshSummary=function(){if(this._layoutType!==BX.CrmEntityChatLayoutType.summary){return}var t=this.getMessageData();var e=BX.prop.getString(t,"date","");if(e===""){this._messageDateNode.innerHTML=""}else{var i=new Date(e).getTime()/1e3+this.getServerTimezoneOffset()+this.getUserTimezoneOffset();var r=(new Date).getTime()/1e3+this.getServerTimezoneOffset()+this.getUserTimezoneOffset();this._messageDateNode.innerHTML=this.formatTime(i,r,true)}var n=BX.prop.getString(t,"text","");var s=BX.prop.getObject(t,"params",{});if(n===""){this._messageTextNode.innerHTML=""}else{if(typeof top.BX.MessengerCommon!=="undefined"){n=top.BX.MessengerCommon.purifyText(n,s)}this._messageTextNode.innerHTML=n}var a=0;var o=this.getUserId();if(o>0){a=BX.prop.getInteger(BX.prop.getObject(BX.prop.getObject(this._data,"USER_INFOS",{}),o,null),"counter",0)}this._messageCounterNode.innerHTML=a.toString();this._messageCounterNode.style.display=a>0?"":"none"};BX.CrmEntityChat.prototype.refreshUsersAnimated=function(){BX.removeClass(this._userWrapper,"crm-entity-stream-live-im-message-show");BX.addClass(this._userWrapper,"crm-entity-stream-live-im-message-hide");window.setTimeout(function(){this.refreshUsers();window.setTimeout(function(){BX.removeClass(this._userWrapper,"crm-entity-stream-live-im-message-hide");BX.addClass(this._userWrapper,"crm-entity-stream-live-im-message-show")}.bind(this),50)}.bind(this),500)};BX.CrmEntityChat.prototype.refreshSummaryAnimated=function(){BX.removeClass(this._messageWrapper,"crm-entity-stream-live-im-message-show");BX.addClass(this._messageWrapper,"crm-entity-stream-live-im-message-hide");window.setTimeout(function(){this.refreshSummary();window.setTimeout(function(){BX.removeClass(this._messageWrapper,"crm-entity-stream-live-im-message-hide");BX.addClass(this._messageWrapper,"crm-entity-stream-live-im-message-show")}.bind(this),50)}.bind(this),500)};BX.CrmEntityChat.prototype.onOpenChat=function(t){if(typeof top.BXIM==="undefined"){return}var e="";var i=this.getChatId();if(i>0&&this.hasUserInfo(this.getUserId())){e="chat"+i.toString()}else{var r=this.getOwnerInfo();var n=BX.prop.getInteger(r,"ENTITY_ID",0);var s=BX.prop.getString(r,"ENTITY_TYPE_NAME","");if(s!==""&&n>0){e="crm|"+s+"|"+n.toString()}}if(e!==""){top.BXIM.openMessengerSlider(e,{RECENT:"N",MENU:"N"})}};BX.CrmEntityChat.prototype.onChatEvent=function(t,e,i){var r=this.getChatId();if(r<=0||r!==BX.prop.getInteger(e,"chatId",0)){return}if(t==="chatUserAdd"){this.setUserInfoData(BX.mergeEx(this.getUserInfoData(),BX.prop.getObject(e,"users",{})));this.refreshUsersAnimated()}else if(t==="chatUserLeave"){this.removeUserInfo(BX.prop.getInteger(e,"userId",0));this.refreshUsersAnimated()}else if(t==="messageChat"){this.setMessageData(BX.prop.getObject(e,"message",{}));this.setUnreadMessageCounter(this.getUserId(),BX.prop.getInteger(e,"counter",0));this.refreshSummaryAnimated()}else if(t==="messageUpdate"||t==="messageDelete"){if(t==="messageDelete"){delete e["date"]}var n=this.getMessageData();if(BX.prop.getInteger(n,"id",0)===BX.prop.getInteger(e,"id",0)){this.setMessageData(BX.mergeEx(n,e));this.refreshSummaryAnimated()}}else if(t==="readMessageChat"){this.setUnreadMessageCounter(this.getUserId(),0);this.refreshSummaryAnimated()}else if(t==="unreadMessageChat"){this.setUnreadMessageCounter(this.getUserId(),BX.prop.getInteger(e,"counter",0));this.refreshSummaryAnimated()}};BX.CrmEntityChat.items={};BX.CrmEntityChat.prototype.getMessage=function(t){return BX.prop.getString(BX.CrmEntityChat.messages,t,t)};if(typeof BX.CrmEntityChat.messages==="undefined"){BX.CrmEntityChat.messages={}}BX.CrmEntityChat.create=function(t,e){var i=new BX.CrmEntityChat;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmTimelineBaseEditor==="undefined"){BX.CrmTimelineBaseEditor=function(){this._id="";this._settings={};this._manager=null;this._ownerTypeId=0;this._ownerId=0;this._container=null;this._input=null;this._saveButton=null;this._cancelButton=null;this._ghostInput=null;this._saveButtonHandler=BX.delegate(this.onSaveButtonClick,this);this._cancelButtonHandler=BX.delegate(this.onCancelButtonClick,this);this._focusHandler=BX.delegate(this.onFocus,this);this._blurHandler=BX.delegate(this.onBlur,this);this._keyupHandler=BX.delegate(this.resizeForm,this);this._isVisible=true;this._hideButtonsOnBlur=true};BX.CrmTimelineBaseEditor.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._manager=this.getSetting("manager");if(!(this._manager instanceof BX.CrmTimelineManager)){throw"BX.CrmTimelineBaseEditor. Manager instance is not found."}this._ownerTypeId=this.getSetting("ownerTypeId",0);this._ownerId=this.getSetting("ownerId",0);this._container=BX(this.getSetting("container"));this._input=BX(this.getSetting("input"));this._saveButton=BX(this.getSetting("button"));this._cancelButton=BX(this.getSetting("cancelButton"));BX.bind(this._saveButton,"click",this._saveButtonHandler);if(this._cancelButton){BX.bind(this._cancelButton,"click",this._cancelButtonHandler)}BX.bind(this._input,"focus",this._focusHandler);BX.bind(this._input,"blur",this._blurHandler);BX.bind(this._input,"keyup",this._keyupHandler);this.doInitialize()},doInitialize:function(){},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},setVisible:function(t){t=!!t;if(this._isVisible===t){return}this._isVisible=t;this._container.style.display=t?"":"none"},isVisible:function(){return this._isVisible},onFocus:function(t){BX.addClass(this._container,"focus")},onBlur:function(t){if(!this._hideButtonsOnBlur){return}if(this._input.value===""){window.setTimeout(BX.delegate(function(){BX.removeClass(this._container,"focus");this._input.style.minHeight=""},this),200)}},onSaveButtonClick:function(t){this.save()},onCancelButtonClick:function(){this.cancel();this._manager.processEditingCancellation(this)},save:function(){},cancel:function(){},release:function(){if(this._ghostInput){this._ghostInput=BX.remove(this._ghostInput)}},ensureGhostCreated:function(){if(this._ghostInput){return this._ghostInput}this._ghostInput=BX.create("div",{props:{className:"crm-entity-stream-content-new-comment-textarea-shadow"},text:this._input.value});this._ghostInput.style.width=this._input.offsetWidth+"px";document.body.appendChild(this._ghostInput);return this._ghostInput},resizeForm:function(){var t=this.ensureGhostCreated();var e=getComputedStyle(this._input);var i=parseInt(e.paddingBottom)+parseInt(e.paddingTop)+parseInt(e.borderTopWidth)+parseInt(e.borderBottomWidth)||0;t.innerHTML=this._input.value.replace(/[\r\n]{1}/g,"<br>");this._input.style.minHeight=t.scrollHeight+i+"px"}}}if(typeof BX.CrmTimelineCommentEditor==="undefined"){BX.CrmTimelineCommentEditor=function(){BX.CrmTimelineCommentEditor.superclass.constructor.apply(this);this._history=null;this._serviceUrl="";this._postForm=null;this._editor=null;this._isRequestRunning=false;this._isLocked=false};BX.extend(BX.CrmTimelineCommentEditor,BX.CrmTimelineBaseEditor);BX.CrmTimelineCommentEditor.prototype.doInitialize=function(){this._serviceUrl=this.getSetting("serviceUrl","");BX.unbind(this._input,"blur",this._blurHandler);BX.unbind(this._input,"keyup",this._keyupHandler)};BX.CrmTimelineCommentEditor.prototype.loadEditor=function(){this._editorName="CrmTimeLineComment0";if(this._postForm)return;BX.ajax.runAction("crm.api.timeline.loadEditor",{data:{name:this._editorName}}).then(this.onLoadEditorSuccess.bind(this))};BX.CrmTimelineCommentEditor.prototype.onLoadEditorSuccess=function(t){var e=BX.prop.getString(BX.prop.getObject(t,"data",{}),"html","");BX.html(this._editorContainer,e).then(BX.delegate(this.showEditor,this))};BX.CrmTimelineCommentEditor.prototype.showEditor=function(){if(LHEPostForm){window.setTimeout(BX.delegate(function(){this._postForm=LHEPostForm.getHandler(this._editorName);this._editor=BXHtmlEditor.Get(this._editorName);BX.onCustomEvent(this._postForm.eventNode,"OnShowLHE",[true])},this),100)}};BX.CrmTimelineCommentEditor.prototype.getHistory=function(){return this._history};BX.CrmTimelineCommentEditor.prototype.setHistory=function(t){this._history=t};BX.CrmTimelineCommentEditor.prototype.onFocus=function(t){this._input.style.display="none";if(this._editor&&this._postForm){this._postForm.eventNode.style.display="block";this._editor.Focus()}else{if(!BX.type.isDomNode(this._editorContainer)){this._editorContainer=BX.create("div",{attrs:{className:"crm-entity-stream-section-comment-editor"}});this._editorContainer.appendChild(BX.create("DIV",{attrs:{className:"crm-timeline-wait"}}));this._container.appendChild(this._editorContainer)}window.setTimeout(BX.delegate(function(){this.loadEditor()},this),100)}BX.addClass(this._container,"focus")};BX.CrmTimelineCommentEditor.prototype.save=function(){var t="";var e=[];if(this._postForm){t=this._postForm.oEditor.GetContent();var i=[];for(var r in this._postForm.arFiles){if(this._postForm.arFiles.hasOwnProperty(r)){var n=this._postForm.arFiles[r];i.indexOf(n)===-1?i.push(n):null}}for(var s=0,a=i.length;s<a;s++){for(var o in this._postForm.controllers[i[s]].values){if(this._postForm.controllers[i[s]].values.hasOwnProperty(o)&&e.indexOf(o)===-1){e.push(o)}}}}else{t=this._input.value}if(t===""){if(!this.emptyCommentMessage){this.emptyCommentMessage=new BX.PopupWindow("timeline_empty_new_comment_"+this._ownerId,this._saveButton,{content:BX.message("CRM_TIMELINE_EMPTY_COMMENT_MESSAGE"),darkMode:true,autoHide:true,zIndex:990,angle:{position:"top",offset:77},closeByEsc:true,bindOptions:{forceBindPosition:true}})}this.emptyCommentMessage.show();return}if(this._isRequestRunning||this._isLocked){return}this._isRequestRunning=this._isLocked=true;BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"SAVE_COMMENT",TEXT:t,OWNER_TYPE_ID:this._ownerTypeId,OWNER_ID:this._ownerId,ATTACHMENTS:e},onsuccess:BX.delegate(this.onSaveSuccess,this),onfailure:BX.delegate(this.onSaveFailure,this)})};BX.CrmTimelineCommentEditor.prototype.cancel=function(){this._input.value="";this._input.style.minHeight="";if(BX.type.isDomNode(this._editorContainer))this._postForm.eventNode.style.display="none";this._input.style.display="block";BX.removeClass(this._container,"focus");this.release()};BX.CrmTimelineCommentEditor.prototype.onSaveSuccess=function(t){this._isRequestRunning=false;if(this._postForm){this._postForm.reinit();for(var e in this._postForm.controllers){if(this._postForm.controllers.hasOwnProperty(e)){this._postForm.controllers[e].values={}}}}this.cancel();var i=BX.prop.getObject(t,"HISTORY_ITEM");var r=this._history.createItem(i);this._history.addItem(r,0);var n=this._history.createAnchor();r.layout({anchor:n});var s=BX.CrmCommentAnimation.create(r.getWrapper(),n,BX.pos(this._input),{start:BX.delegate(this.onAnimationStart,this),complete:BX.delegate(this.onAnimationComplete,this)});s.run()};BX.CrmTimelineCommentEditor.prototype.onSaveFailure=function(){this._isRequestRunning=this._isLocked=false};BX.CrmTimelineCommentEditor.prototype.onAnimationStart=function(){this._input.value=""};BX.CrmTimelineCommentEditor.prototype.onAnimationComplete=function(){this._isLocked=false;BX.removeClass(this._container,"focus");this._input.style.minHeight="";this._manager.processEditingCompletion(this);this.release();this._history._anchor=null;this._history.refreshLayout()};BX.CrmTimelineCommentEditor.items={};BX.CrmTimelineCommentEditor.create=function(t,e){var i=new BX.CrmTimelineCommentEditor;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmTimelineWaitType==="undefined"){BX.CrmTimelineWaitType={undefined:0,after:1,before:2,names:{after:"after",before:"before"},resolveTypeId:function(t){if(t===this.names.after){return this.after}else if(t===this.names.before){return this.before}return this.undefined}}}if(typeof BX.CrmTimelineWaitHelper==="undefined"){BX.CrmTimelineWaitHelper={getDurationText:function(t,e){e=!!e;var i="D";if(e){var r="";if(t%7===0){t=t/7;i="W"}}if(i==="W"){r=BX.CrmMessageHelper.getCurrent().getNumberDeclension(t,this.getMessage("weekNominative"),this.getMessage("weekGenitiveSingular"),this.getMessage("weekGenitivePlural"))}else{r=BX.CrmMessageHelper.getCurrent().getNumberDeclension(t,this.getMessage("dayNominative"),this.getMessage("dayGenitiveSingular"),this.getMessage("dayGenitivePlural"))}if(e){r=t.toString()+" "+r}return r},getMessage:function(t){return this.messages.hasOwnProperty(t)?this.messages[t]:t}};if(typeof BX.CrmTimelineWaitHelper.messages==="undefined"){BX.CrmTimelineWaitHelper.messages={}}}if(typeof BX.CrmTimelineWaitEditor==="undefined"){BX.CrmTimelineWaitEditor=function(){BX.CrmTimelineWaitEditor.superclass.constructor.apply(this);this._serviceUrl="";this._isRequestRunning=false;this._isLocked=false;this._hideButtonsOnBlur=false;this._type=BX.CrmTimelineWaitType.after;this._duration=1;this._target="";this._configContainer=null;this._configSelector=null;this._isMenuShown=false;this._menu=null;this._configDialog=null};BX.extend(BX.CrmTimelineWaitEditor,BX.CrmTimelineBaseEditor);BX.CrmTimelineWaitEditor.prototype.doInitialize=function(){this._configContainer=BX(this.getSetting("configContainer"));this._serviceUrl=this.getSetting("serviceUrl","");var t=BX.prop.getObject(this._settings,"config",{});this._type=BX.CrmTimelineWaitType.resolveTypeId(BX.prop.getString(t,"type",BX.CrmTimelineWaitType.names.after));this._duration=BX.prop.getInteger(t,"duration",1);this._target=BX.prop.getString(t,"target","");this._targetDates=BX.prop.getArray(this._settings,"targetDates",[]);this.layoutConfigurationSummary()};BX.CrmTimelineWaitEditor.prototype.getDurationText=function(t,e){return BX.CrmTimelineWaitHelper.getDurationText(t,e)};BX.CrmTimelineWaitEditor.prototype.getTargetDateCaption=function(t){for(var e=0,i=this._targetDates.length;e<i;e++){var r=this._targetDates[e];if(r["name"]===t){return r["caption"]}}return""};BX.CrmTimelineWaitEditor.prototype.onSelectorClick=function(t){if(!this._isMenuShown){this.openMenu()}else{this.closeMenu()}t.preventDefault?t.preventDefault():t.returnValue=false};BX.CrmTimelineWaitEditor.prototype.openMenu=function(){if(this._isMenuShown){return}var t=BX.delegate(this.onMenuItemClick,this);var e=[{id:"day_1",text:this.getMessage("oneDay"),onclick:t},{id:"day_2",text:this.getMessage("twoDays"),onclick:t},{id:"day_3",text:this.getMessage("threeDays"),onclick:t},{id:"week_1",text:this.getMessage("oneWeek"),onclick:t},{id:"week_2",text:this.getMessage("twoWeek"),onclick:t},{id:"week_3",text:this.getMessage("threeWeeks"),onclick:t}];var i={id:"custom",text:this.getMessage("custom"),items:[]};i["items"].push({id:"afterDays",text:this.getMessage("afterDays"),onclick:t});if(this._targetDates.length>0){i["items"].push({id:"beforeDate",text:this.getMessage("beforeDate"),onclick:t})}e.push(i);BX.PopupMenu.show(this._id,this._configSelector,e,{offsetTop:0,offsetLeft:36,angle:{position:"top",offset:0},events:{onPopupShow:BX.delegate(this.onMenuShow,this),onPopupClose:BX.delegate(this.onMenuClose,this),onPopupDestroy:BX.delegate(this.onMenuDestroy,this)}});this._menu=BX.PopupMenu.currentItem};BX.CrmTimelineWaitEditor.prototype.closeMenu=function(){if(!this._isMenuShown){return}if(this._menu){this._menu.close()}};BX.CrmTimelineWaitEditor.prototype.onMenuItemClick=function(t,e){this.closeMenu();if(e.id==="afterDays"||e.id==="beforeDate"){this.openConfigDialog(e.id==="afterDays"?BX.CrmTimelineWaitType.after:BX.CrmTimelineWaitType.before);return}var i={type:BX.CrmTimelineWaitType.after};if(e.id==="day_1"){i["duration"]=1}else if(e.id==="day_2"){i["duration"]=2}else if(e.id==="day_3"){i["duration"]=3}if(e.id==="week_1"){i["duration"]=7}else if(e.id==="week_2"){i["duration"]=14}else if(e.id==="week_3"){i["duration"]=21}this.saveConfiguration(i)};BX.CrmTimelineWaitEditor.prototype.openConfigDialog=function(t){if(!this._configDialog){this._configDialog=BX.CrmTimelineWaitConfigurationDialog.create("",{targetDates:this._targetDates,onSave:BX.delegate(this.onConfigDialogSave,this),onCancel:BX.delegate(this.onConfigDialogCancel,this)})}this._configDialog.setType(t);this._configDialog.setDuration(this._duration);var e=this._target;if(e===""&&this._targetDates.length>0){e=this._targetDates[0]["name"]}this._configDialog.setTarget(e);this._configDialog.open()};BX.CrmTimelineWaitEditor.prototype.onConfigDialogSave=function(t,e){this.saveConfiguration(e);this._configDialog.close()};BX.CrmTimelineWaitEditor.prototype.onConfigDialogCancel=function(t){this._configDialog.close()};BX.CrmTimelineWaitEditor.prototype.onMenuShow=function(){this._isMenuShown=true};BX.CrmTimelineWaitEditor.prototype.onMenuClose=function(){if(this._menu&&this._menu.popupWindow){this._menu.popupWindow.destroy()}};BX.CrmTimelineWaitEditor.prototype.onMenuDestroy=function(){this._isMenuShown=false;this._menu=null;if(typeof BX.PopupMenu.Data[this._id]!=="undefined"){delete BX.PopupMenu.Data[this._id]}};BX.CrmTimelineWaitEditor.prototype.saveConfiguration=function(t){this._type=BX.prop.getInteger(t,"type",BX.CrmTimelineWaitType.after);this._duration=BX.prop.getInteger(t,"duration",0);if(this._duration<=0){this._duration=1}this._target=this._type===BX.CrmTimelineWaitType.before?BX.prop.getString(t,"target",""):"";var e=this._manager.getId().toLowerCase();BX.userOptions.save("crm.timeline.wait",e,"type",this._type===BX.CrmTimelineWaitType.after?"after":"before");BX.userOptions.save("crm.timeline.wait",e,"duration",this._duration);BX.userOptions.save("crm.timeline.wait",e,"target",this._target);this.layoutConfigurationSummary()};BX.CrmTimelineWaitEditor.prototype.getSummaryHtml=function(){if(this._type===BX.CrmTimelineWaitType.before){return this.getMessage("completionTypeBefore").replace("#DURATION#",this.getDurationText(this._duration,true)).replace("#TARGET_DATE#",this.getTargetDateCaption(this._target))}return this.getMessage("completionTypeAfter").replace("#DURATION#",this.getDurationText(this._duration,true))};BX.CrmTimelineWaitEditor.prototype.getSummaryText=function(){return BX.util.strip_tags(this.getSummaryHtml())};BX.CrmTimelineWaitEditor.prototype.layoutConfigurationSummary=function(){this._configContainer.innerHTML=this.getSummaryHtml();this._configSelector=this._configContainer.querySelector("a");if(this._configSelector){BX.bind(this._configSelector,"click",BX.delegate(this.onSelectorClick,this))}};BX.CrmTimelineWaitEditor.prototype.postpone=function(t,e,i){BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"POSTPONE_WAIT",DATA:{ID:t,OFFSET:e}},onsuccess:i})};BX.CrmTimelineWaitEditor.prototype.complete=function(t,e,i){BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"COMPLETE_WAIT",DATA:{ID:t,COMPLETED:e?"Y":"N"}},onsuccess:i})};BX.CrmTimelineWaitEditor.prototype.save=function(){if(this._isRequestRunning||this._isLocked){return}var t=this.getSummaryText();var e=BX.util.trim(this._input.value);if(e!==""){t+="\n"+e}var i={ID:0,typeId:this._type,duration:this._duration,targetFieldName:this._target,subject:"",description:t,completed:0,ownerType:BX.CrmEntityType.resolveName(this._ownerTypeId),ownerID:this._ownerId};BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"SAVE_WAIT",DATA:i},onsuccess:BX.delegate(this.onSaveSuccess,this),onfailure:BX.delegate(this.onSaveFailure,this)});this._isRequestRunning=this._isLocked=true};BX.CrmTimelineWaitEditor.prototype.cancel=function(){this._input.value="";this._input.style.minHeight="";this.release()};BX.CrmTimelineWaitEditor.prototype.onSaveSuccess=function(t){this._isRequestRunning=this._isLocked=false;var e=BX.prop.getString(t,"ERROR","");if(e!==""){alert(e);return}this._input.value="";this._input.style.minHeight="";this._manager.processEditingCompletion(this);this.release()};BX.CrmTimelineWaitEditor.prototype.onSaveFailure=function(){this._isRequestRunning=this._isLocked=false};BX.CrmTimelineWaitEditor.prototype.getMessage=function(t){var e=BX.CrmTimelineWaitEditor.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmTimelineWaitEditor.messages==="undefined"){BX.CrmTimelineWaitEditor.messages={}}BX.CrmTimelineWaitEditor.items={};BX.CrmTimelineWaitEditor.create=function(t,e){var i=new BX.CrmTimelineWaitEditor;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmTimelineSmsEditor==="undefined"){BX.CrmTimelineSmsEditor=function(){BX.CrmTimelineSmsEditor.superclass.constructor.apply(this);this._history=null;this._serviceUrl="";this._isRequestRunning=false;this._isLocked=false;this._senderId=null;this._from=null;this._commEntityTypeId=null;this._commEntityId=null;this._to=null;this._canUse=null;this._canSendMessage=null;this._manageUrl="";this._senders=[];this._fromList=[];this._toList=[];this._defaults={};this._communications=[];this._menu=null;this._isMenuShown=false;this._shownMenuId=null};BX.extend(BX.CrmTimelineSmsEditor,BX.CrmTimelineBaseEditor);BX.CrmTimelineSmsEditor.prototype.doInitialize=function(){this._serviceUrl=BX.util.remove_url_param(this.getSetting("serviceUrl",""),["sessid","site"]);var t=BX.prop.getObject(this._settings,"config",{});this._canUse=BX.prop.getBoolean(t,"canUse",false);this._canSendMessage=BX.prop.getBoolean(t,"canSendMessage",false);this._manageUrl=BX.prop.getString(t,"manageUrl","");this._senders=BX.prop.getArray(t,"senders",[]);this._defaults=BX.prop.getObject(t,"defaults",{senderId:null,from:null});this._communications=BX.prop.getArray(t,"communications",[]);this._isSalescenterEnabled=BX.prop.getBoolean(t,"isSalescenterEnabled",false);this._senderSelectorNode=this._container.querySelector('[data-role="sender-selector"]');this._fromContainerNode=this._container.querySelector('[data-role="from-container"]');this._fromSelectorNode=this._container.querySelector('[data-role="from-selector"]');this._clientContainerNode=this._container.querySelector('[data-role="client-container"]');this._clientSelectorNode=this._container.querySelector('[data-role="client-selector"]');this._toSelectorNode=this._container.querySelector('[data-role="to-selector"]');this._messageLengthCounterNode=this._container.querySelector('[data-role="message-length-counter"]');this._salescenterStarter=this._container.querySelector('[data-role="salescenter-starter"]');if(this._canUse&&this._canSendMessage){this.initSenderSelector();this.initFromSelector();this.initClientContainer();this.initClientSelector();this.initToSelector();this.initMessageLengthCounter()}if(this._isSalescenterEnabled){this.initSalescenterApplication()}};BX.CrmTimelineSmsEditor.prototype.initSenderSelector=function(){var t=this._defaults.senderId;var e=this._senders[0].canUse?this._senders[0]:null;var i=null;var r=[];var n=this.onSenderSelectorClick.bind(this);for(var s=0;s<this._senders.length;++s){if(this._senders[s].canUse&&this._senders[s].fromList.length&&(this._senders[s].id===t||!e)){e=this._senders[s]}if(this._senders[s].id==="rest"){i=this._senders[s];continue}r.push({text:this._senders[s].name,sender:this._senders[s],onclick:n,className:!this._senders[s].canUse||!this._senders[s].fromList.length?"crm-timeline-popup-menu-item-disabled menu-popup-no-icon":""})}if(i){if(i.fromList.length>0){r.push({delimiter:true});for(s=0;s<i.fromList.length;++s){r.push({text:i.fromList[s].name,sender:i,from:i.fromList[s],onclick:n})}}r.push({delimiter:true},{text:BX.message("CRM_TIMELINE_SMS_REST_MARKETPLACE"),href:"/marketplace/category/crm_robot_sms/",target:"_blank"})}if(e){this.setSender(e)}BX.bind(this._senderSelectorNode,"click",this.openMenu.bind(this,"sender",this._senderSelectorNode,r))};BX.CrmTimelineSmsEditor.prototype.onSenderSelectorClick=function(t,e){if(e.sender){if(!e.sender.canUse||!e.sender.fromList.length){window.open(e.sender.manageUrl);return}this.setSender(e.sender,true);var i=e.from?e.from:e.sender.fromList[0];this.setFrom(i,true)}this._menu.close()};BX.CrmTimelineSmsEditor.prototype.setSender=function(t,e){this._senderId=t.id;this._fromList=t.fromList;this._senderSelectorNode.textContent=t.shortName?t.shortName:t.name;var i=t.id==="rest"?"hide":"show";BX[i](this._fromContainerNode);if(e){BX.userOptions.save("crm","sms_manager_editor","senderId",this._senderId)}};BX.CrmTimelineSmsEditor.prototype.initFromSelector=function(){if(this._fromList.length>0){var t=this._defaults.from||this._fromList[0].id;var e=null;for(var i=0;i<this._fromList.length;++i){if(this._fromList[i].id===t||!e){e=this._fromList[i]}}if(e){this.setFrom(e)}}BX.bind(this._fromSelectorNode,"click",this.onFromSelectorClick.bind(this))};BX.CrmTimelineSmsEditor.prototype.onFromSelectorClick=function(t){var e=[];var i=this.onFromSelectorItemClick.bind(this);for(var r=0;r<this._fromList.length;++r){e.push({text:this._fromList[r].name,from:this._fromList[r],onclick:i})}this.openMenu("from_"+this._senderId,this._fromSelectorNode,e,t)};BX.CrmTimelineSmsEditor.prototype.onFromSelectorItemClick=function(t,e){if(e.from){this.setFrom(e.from,true)}this._menu.close()};BX.CrmTimelineSmsEditor.prototype.setFrom=function(t,e){this._from=t.id;if(this._senderId==="rest"){this._senderSelectorNode.textContent=t.name}else{this._fromSelectorNode.textContent=t.name}if(e){BX.userOptions.save("crm","sms_manager_editor","from",this._from)}};BX.CrmTimelineSmsEditor.prototype.initClientContainer=function(){if(this._communications.length===0){BX.hide(this._clientContainerNode)}};BX.CrmTimelineSmsEditor.prototype.initClientSelector=function(){var t=[];var e=this.onClientSelectorClick.bind(this);for(var i=0;i<this._communications.length;++i){t.push({text:this._communications[i].caption,client:this._communications[i],onclick:e});if(i===0){this.setClient(this._communications[i])}}BX.bind(this._clientSelectorNode,"click",this.openMenu.bind(this,"comm",this._clientSelectorNode,t))};BX.CrmTimelineSmsEditor.prototype.onClientSelectorClick=function(t,e){if(e.client){this.setClient(e.client)}this._menu.close()};BX.CrmTimelineSmsEditor.prototype.setClient=function(t){this._commEntityTypeId=t.entityTypeId;this._commEntityId=t.entityId;this._clientSelectorNode.textContent=t.caption;this._toList=t.phones;this.setTo(t.phones[0])};BX.CrmTimelineSmsEditor.prototype.initToSelector=function(){BX.bind(this._toSelectorNode,"click",this.onToSelectorClick.bind(this))};BX.CrmTimelineSmsEditor.prototype.onToSelectorClick=function(t){var e=[];var i=this.onToSelectorItemClick.bind(this);for(var r=0;r<this._toList.length;++r){e.push({text:this._toList[r].valueFormatted||this._toList[r].value,to:this._toList[r],onclick:i})}this.openMenu("to_"+this._commEntityTypeId+"_"+this._commEntityId,this._toSelectorNode,e,t)};BX.CrmTimelineSmsEditor.prototype.onToSelectorItemClick=function(t,e){if(e.to){this.setTo(e.to)}this._menu.close()};BX.CrmTimelineSmsEditor.prototype.setTo=function(t){this._to=t.value;this._toSelectorNode.textContent=t.valueFormatted||t.value};BX.CrmTimelineSmsEditor.prototype.openMenu=function(t,e,i,r){if(this._shownMenuId===t){return}if(this._shownMenuId!==null&&this._menu){this._menu.close();this._shownMenuId=null}BX.PopupMenu.show(this._id+t,e,i,{offsetTop:0,offsetLeft:36,angle:{position:"top",offset:0},events:{onPopupClose:BX.delegate(this.onMenuClose,this)}});this._menu=BX.PopupMenu.currentItem;r.preventDefault()};BX.CrmTimelineSmsEditor.prototype.onMenuClose=function(){this._shownMenuId=null;this._menu=null};BX.CrmTimelineSmsEditor.prototype.initMessageLengthCounter=function(){this._messageLengthMax=parseInt(this._messageLengthCounterNode.getAttribute("data-length-max"));BX.bind(this._input,"keyup",this.setMessageLengthCounter.bind(this))};BX.CrmTimelineSmsEditor.prototype.setMessageLengthCounter=function(){var t=this._input.value.length;this._messageLengthCounterNode.textContent=t;var e=t>=this._messageLengthMax?"addClass":"removeClass";BX[e](this._messageLengthCounterNode,"crm-entity-stream-content-sms-symbol-counter-number-overhead")};BX.CrmTimelineSmsEditor.prototype.save=function(){var t=this._input.value;if(t===""){return}if(!this._communications.length){alert(BX.message("CRM_TIMELINE_SMS_ERROR_NO_COMMUNICATIONS"));return}if(this._isRequestRunning||this._isLocked){return}this._isRequestRunning=this._isLocked=true;BX.ajax({url:BX.util.add_url_param(this._serviceUrl,{action:"save_sms_message",sender:this._senderId}),method:"POST",dataType:"json",data:{site:BX.message("SITE_ID"),sessid:BX.bitrix_sessid(),ACTION:"SAVE_SMS_MESSAGE",SENDER_ID:this._senderId,MESSAGE_FROM:this._from,MESSAGE_TO:this._to,MESSAGE_BODY:t,OWNER_TYPE_ID:this._ownerTypeId,OWNER_ID:this._ownerId,TO_ENTITY_TYPE_ID:this._commEntityTypeId,TO_ENTITY_ID:this._commEntityId},onsuccess:BX.delegate(this.onSaveSuccess,this),onfailure:BX.delegate(this.onSaveFailure,this)})};BX.CrmTimelineSmsEditor.prototype.cancel=function(){this._input.value="";this.setMessageLengthCounter();this._input.style.minHeight="";this.release()};BX.CrmTimelineSmsEditor.prototype.onSaveSuccess=function(t){this._isRequestRunning=this._isLocked=false;var e=BX.prop.getString(t,"ERROR","");if(e!==""){alert(e);return}this._input.value="";this.setMessageLengthCounter();this._input.style.minHeight="";this._manager.processEditingCompletion(this);this.release()};BX.CrmTimelineSmsEditor.prototype.onSaveFailure=function(){this._isRequestRunning=this._isLocked=false};BX.CrmTimelineSmsEditor.prototype.initSalescenterApplication=function(){BX.bind(this._salescenterStarter,"click",this.startSalescenterApplication.bind(this))};BX.CrmTimelineSmsEditor.prototype.startSalescenterApplication=function(){BX.loadExt("salescenter.manager").then(function(){BX.Salescenter.Manager.openApplication({disableSendButton:this._canSendMessage?"":"y",context:"sms",ownerTypeId:this._ownerTypeId,ownerId:this._ownerId}).then(function(t){if(t&&t.get("action")){if(t.get("action")==="sendPage"&&t.get("page")&&t.get("page").url){this._input.focus();this._input.value=this._input.value+t.get("page").name+" "+t.get("page").url;this.setMessageLengthCounter()}else if(t.get("action")==="sendPayment"&&t.get("order")){this._input.focus();this._input.value=this._input.value+t.get("order").title+" "+t.get("order").url;this.setMessageLengthCounter()}}}.bind(this))}.bind(this))};BX.CrmTimelineSmsEditor.items={};BX.CrmTimelineSmsEditor.create=function(t,e){var i=new BX.CrmTimelineSmsEditor;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmTimelineRestEditor==="undefined"){BX.CrmTimelineRestEditor=function(){BX.CrmTimelineRestEditor.superclass.constructor.apply(this);this._interfaceInitialized=false};BX.extend(BX.CrmTimelineRestEditor,BX.CrmTimelineBaseEditor);BX.CrmTimelineRestEditor.prototype.action=function(t){if(!this._interfaceInitialized){this._interfaceInitialized=true;this.initializeInterface()}if(t==="activity_rest_applist"){BX.rest.Marketplace.open({PLACEMENT:this.getSetting("placement","")});top.BX.addCustomEvent(top,"Rest:AppLayout:ApplicationInstall",BX.proxy(this.fireUpdateEvent,this))}else{var e=t.replace("activity_rest_","");var i=e.split("_");BX.rest.AppLayout.openApplication(i[0],{ID:this._ownerId},{PLACEMENT:this.getSetting("placement",""),PLACEMENT_ID:i[1]})}};BX.CrmTimelineRestEditor.prototype.initializeInterface=function(){if(!!top.BX.rest&&!!top.BX.rest.AppLayout){var t=this._manager._ownerTypeId,e=this._manager._ownerId;var i=top.BX.rest.AppLayout.initializePlacement(this.getSetting("placement",""));i.prototype.reloadData=function(i,r){BX.Crm.EntityEvent.fireUpdate(t,e,"");r()}}};BX.CrmTimelineRestEditor.prototype.fireUpdateEvent=function(){var t=this._manager._ownerTypeId,e=this._manager._ownerId;setTimeout(function(){console.log("fireUpdate",e,t);BX.Crm.EntityEvent.fire(BX.Crm.EntityEvent.names.invalidate,t,e,"")},3e3)};BX.CrmTimelineRestEditor.items={};BX.CrmTimelineRestEditor.create=function(t,e){var i=new BX.CrmTimelineRestEditor;i.initialize(t,e);this.items[i.getId()]=i;return i}}if(typeof BX.CrmTimelineWaitConfigurationDialog==="undefined"){BX.CrmTimelineWaitConfigurationDialog=function(){this._id="";this._settings={};this._type=BX.CrmTimelineWaitType.undefined;this._duration=0;this._target="";this._targetDates=null;this._container=null;this._durationMeasureNode=null;this._durationInput=null;this._targetDateNode=null;this._popup=null};BX.CrmTimelineWaitConfigurationDialog.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._type=BX.prop.getInteger(this._settings,"type",BX.CrmTimelineWaitType.after);this._duration=BX.prop.getInteger(this._settings,"duration",1);this._target=BX.prop.getString(this._settings,"target","");this._targetDates=BX.prop.getArray(this._settings,"targetDates",[]);this._menuId=this._id+"_target_date_sel"},getId:function(){return this._id},getType:function(){return this._type},setType:function(t){this._type=t},getDuration:function(){return this._duration},setDuration:function(t){this._duration=t},getTarget:function(){return this._target},setTarget:function(t){this._target=t},getMessage:function(t){var e=BX.CrmTimelineWaitConfigurationDialog.messages;return e.hasOwnProperty(t)?e[t]:t},getDurationText:function(t,e){return BX.CrmTimelineWaitHelper.getDurationText(t,e)},getTargetDateCaption:function(t){for(var e=0,i=this._targetDates.length;e<i;e++){var r=this._targetDates[e];if(r["name"]===t){return r["caption"]}}return""},open:function(){this._popup=new BX.PopupWindow(this._id,this._configSelector,{autoHide:true,draggable:false,bindOptions:{forceBindPosition:false},closeByEsc:true,zIndex:0,content:this.prepareDialogContent(),events:{onPopupShow:BX.delegate(this.onPopupShow,this),onPopupClose:BX.delegate(this.onPopupClose,this),onPopupDestroy:BX.delegate(this.onPopupDestroy,this)},buttons:[new BX.PopupWindowButton({text:this.getMessage("select"),className:"popup-window-button-accept",events:{click:BX.delegate(this.onSaveButtonClick,this)}}),new BX.PopupWindowButtonLink({text:BX.message("JS_CORE_WINDOW_CANCEL"),events:{click:BX.delegate(this.onCancelButtonClick,this)}})]});this._popup.show()},close:function(){if(this._popup){this._popup.close()}},prepareDialogContent:function(){var t=BX.create("div",{attrs:{className:"crm-wait-popup-select-block"}});var e=BX.create("div",{attrs:{className:"crm-wait-popup-select-wrapper"}});t.appendChild(e);this._durationInput=BX.create("input",{attrs:{type:"text",className:"crm-wait-popup-settings-input",value:this._duration},events:{keyup:BX.delegate(this.onDurationChange,this)}});this._durationMeasureNode=BX.create("span",{attrs:{className:"crm-wait-popup-settings-title"},text:this.getDurationText(this._duration,false)});if(this._type===BX.CrmTimelineWaitType.after){e.appendChild(BX.create("span",{attrs:{className:"crm-wait-popup-settings-title"},text:this.getMessage("prefixTypeAfter")}));e.appendChild(this._durationInput);e.appendChild(this._durationMeasureNode)}else{e.appendChild(BX.create("span",{attrs:{className:"crm-wait-popup-settings-title"},text:this.getMessage("prefixTypeBefore")}));e.appendChild(this._durationInput);e.appendChild(this._durationMeasureNode);e.appendChild(BX.create("span",{attrs:{className:"crm-wait-popup-settings-title"},text:" "+this.getMessage("targetPrefixTypeBefore")}));this._targetDateNode=BX.create("span",{attrs:{className:"crm-automation-popup-settings-link"},text:this.getTargetDateCaption(this._target),events:{click:BX.delegate(this.toggleTargetMenu,this)}});e.appendChild(this._targetDateNode)}return t},onDurationChange:function(){var t=parseInt(this._durationInput.value);if(isNaN(t)||t<=0){t=1}this._duration=t;this._durationMeasureNode.innerHTML=BX.util.htmlspecialchars(this.getDurationText(t,false))},toggleTargetMenu:function(){if(this.isTargetMenuOpened()){this.closeTargetMenu()}else{this.openTargetMenu()}},isTargetMenuOpened:function(){return!!BX.PopupMenu.getMenuById(this._menuId)},openTargetMenu:function(){var t=[];for(var e=0,i=this._targetDates.length;e<i;e++){var r=this._targetDates[e];t.push({text:r["caption"],title:r["caption"],value:r["name"],onclick:BX.delegate(this.onTargetSelect,this)})}BX.PopupMenu.show(this._menuId,this._targetDateNode,t,{zIndex:200,autoHide:true,offsetLeft:BX.pos(this._targetDateNode)["width"]/2,angle:{position:"top",offset:0}})},closeTargetMenu:function(){BX.PopupMenu.destroy(this._menuId)},onPopupShow:function(t,e){},onPopupClose:function(){if(this._popup){this._popup.destroy()}this.closeTargetMenu()},onPopupDestroy:function(){if(this._popup){this._popup=null}},onSaveButtonClick:function(t){var e=BX.prop.getFunction(this._settings,"onSave",null);if(!e){return}var i={type:this._type};i["duration"]=this._duration;i["target"]=this._type===BX.CrmTimelineWaitType.before?this._target:"";e(this,i)},onCancelButtonClick:function(t){var e=BX.prop.getFunction(this._settings,"onCancel",null);if(e){e(this)}},onTargetSelect:function(t,e){var i=BX.prop.getString(e,"value","");if(i!==""){this._target=i;this._targetDateNode.innerHTML=BX.util.htmlspecialchars(this.getTargetDateCaption(i))}this.closeTargetMenu();t.preventDefault?t.preventDefault():t.returnValue=false}};if(typeof BX.CrmTimelineWaitConfigurationDialog.messages==="undefined"){BX.CrmTimelineWaitConfigurationDialog.messages={}}BX.CrmTimelineWaitConfigurationDialog.create=function(t,e){var i=new BX.CrmTimelineWaitConfigurationDialog;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineType==="undefined"){BX.CrmTimelineType={undefined:0,activity:1,creation:2,modification:3,link:4,mark:6,comment:7,wait:8,bizproc:9,conversion:10,sender:11,document:12,restoration:13,order:14,orderCheck:15,scoring:16}}if(typeof BX.CrmTimelineAction==="undefined"){BX.CrmTimelineAction=function(){this._id="";this._settings={};this._container=null};BX.CrmTimelineAction.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._container=this.getSetting("container");if(!BX.type.isElementNode(this._container)){throw"BX.CrmTimelineAction: Could not find container."}this.doInitialize()},doInitialize:function(){},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},layout:function(){this.doLayout()},doLayout:function(){}}}if(typeof BX.CrmTimelineActivityAction==="undefined"){BX.CrmTimelineActivityAction=function(){BX.CrmTimelineActivityAction.superclass.constructor.apply(this);this._activityEditor=null;this._entityData=null;this._item=null;this._isEnabled=true};BX.extend(BX.CrmTimelineActivityAction,BX.CrmTimelineAction);BX.CrmTimelineActivityAction.prototype.doInitialize=function(){this._entityData=this.getSetting("entityData");if(!BX.type.isPlainObject(this._entityData)){throw"BX.CrmTimelineActivityAction. A required parameter 'entityData' is missing."}this._activityEditor=this.getSetting("activityEditor");if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmTimelineActivityAction. A required parameter 'activityEditor' is missing."}this._item=this.getSetting("item");this._isEnabled=this.getSetting("enabled",true)};BX.CrmTimelineActivityAction.prototype.getActivityId=function(){return BX.prop.getInteger(this._entityData,"ID",0)};BX.CrmTimelineActivityAction.prototype.loadActivityCommunications=function(t){this._activityEditor.getActivityCommunications(this.getActivityId(),function(e){if(BX.type.isFunction(t)){t(e)}},true)};BX.CrmTimelineActivityAction.prototype.getItemData=function(){return this._item?this._item.getData():null}}if(typeof BX.CrmTimelineEmailAction==="undefined"){BX.CrmTimelineEmailAction=function(){BX.CrmTimelineEmailAction.superclass.constructor.apply(this);this._clickHandler=BX.delegate(this.onClick,this);this._saveHandler=BX.delegate(this.onSave,this)};BX.extend(BX.CrmTimelineEmailAction,BX.CrmTimelineActivityAction);BX.CrmTimelineEmailAction.prototype.onClick=function(t){var e={ownerType:BX.CrmEntityType.resolveName(BX.prop.getInteger(this._entityData,"OWNER_TYPE_ID",0)),ownerID:BX.prop.getInteger(this._entityData,"OWNER_ID",0),ownerUrl:BX.prop.getString(this._entityData,"OWNER_URL",""),ownerTitle:BX.prop.getString(this._entityData,"OWNER_TITLE",""),originalMessageID:BX.prop.getInteger(this._entityData,"ID",0),messageType:"RE"};if(BX.CrmActivityProvider&&top.BX.Bitrix24&&top.BX.Bitrix24.Slider){var i=this._activityEditor.addEmail(e);i.addOnSave(this._saveHandler)}else{this.loadActivityCommunications(BX.delegate(function(t){e["communications"]=BX.type.isArray(t)?t:[];e["communicationsLoaded"]=true;BX.CrmActivityEmail.prepareReply(e);var i=this._activityEditor.addEmail(e);i.addOnSave(this._saveHandler)},this))}return BX.PreventDefault(t)};BX.CrmTimelineEmailAction.prototype.onSave=function(t,e){if(BX.type.isFunction(this._item.onActivityCreate)){this._item.onActivityCreate(t,e)}}}if(typeof BX.CrmTimelineCallAction==="undefined"){BX.CrmTimelineCallAction=function(){BX.CrmTimelineCallAction.superclass.constructor.apply(this);this._clickHandler=BX.delegate(this.onClick,this);this._menu=null;this._isMenuShown=false;this._menuItems=null};BX.extend(BX.CrmTimelineCallAction,BX.CrmTimelineActivityAction);BX.CrmTimelineCallAction.prototype.getButton=function(){return null};BX.CrmTimelineCallAction.prototype.onClick=function(t){if(typeof window.top["BXIM"]==="undefined"){window.alert(this.getMessage("telephonyNotSupported"));return}var e="";var i=this.getItemData();var r=BX.prop.getArray(i,"PHONE",[]);if(r.length===1){this.addCall(r[0]["VALUE"])}else if(r.length>1){this.showMenu()}else{var n=BX.prop.getObject(this._entityData,"COMMUNICATION",null);if(n){if(BX.prop.getString(n,"TYPE")==="PHONE"){e=BX.prop.getString(n,"VALUE");if(e){this.addCall(e)}}}}return BX.PreventDefault(t)};BX.CrmTimelineCallAction.prototype.showMenu=function(){if(this._isMenuShown){return}this.prepareMenuItems();if(!this._menuItems||this._menuItems.length===0){return}this._menu=new BX.PopupMenuWindow(this._id,this._container,this._menuItems,{offsetTop:0,offsetLeft:16,events:{onPopupShow:BX.delegate(this.onMenuShow,this),onPopupClose:BX.delegate(this.onMenuClose,this),onPopupDestroy:BX.delegate(this.onMenuDestroy,this)}});this._menu.popupWindow.show()};BX.CrmTimelineCallAction.prototype.closeMenu=function(){if(!this._isMenuShown){return}if(this._menu){this._menu.close()}};BX.CrmTimelineCallAction.prototype.prepareMenuItems=function(){if(this._menuItems){return}var t=this.getItemData();var e=BX.prop.getArray(t,"PHONE",[]);var i=BX.delegate(this.onMenuItemClick,this);this._menuItems=[];if(e.length===0){return}for(var r=0,n=e.length;r<n;r++){var s=BX.prop.getString(e[r],"VALUE");var a=BX.prop.getString(e[r],"VALUE_FORMATTED");var o=BX.prop.getString(e[r],"COMPLEX_NAME");var c=(o?o+": ":"")+(a?a:s);if(s!==""){this._menuItems.push({id:s,text:c,onclick:i})}}};BX.CrmTimelineCallAction.prototype.onMenuItemClick=function(t,e){this.closeMenu();this.addCall(e.id)};BX.CrmTimelineCallAction.prototype.onMenuShow=function(){this._isMenuShown=true};BX.CrmTimelineCallAction.prototype.onMenuClose=function(){this._isMenuShown=false;this._menu.popupWindow.destroy()};BX.CrmTimelineCallAction.prototype.onMenuDestroy=function(){this._menu=null};BX.CrmTimelineCallAction.prototype.addCall=function(t){var e=BX.prop.getObject(this._entityData,"COMMUNICATION",null);var i=parseInt(BX.prop.getString(e,"ENTITY_TYPE_ID","0"));if(isNaN(i)){i=0}var r=parseInt(BX.prop.getString(e,"ENTITY_ID","0"));if(isNaN(r)){r=0}var n=0;var s=0;var a=BX.prop.getObject(this._settings,"ownerInfo");if(a){n=BX.prop.getInteger(a,"ENTITY_TYPE_ID",0);s=BX.prop.getInteger(a,"ENTITY_ID",0)}if(n<=0||s<=0){n=BX.prop.getInteger(this._entityData,"OWNER_TYPE_ID",0);s=BX.prop.getInteger(this._entityData,"OWNER_ID","0")}if(n<=0||s<=0){n=i;s=r}var o=parseInt(BX.prop.getString(this._entityData,"ID","0"));if(isNaN(o)){o=0}var c={ENTITY_TYPE_NAME:BX.CrmEntityType.resolveName(i),ENTITY_ID:r,AUTO_FOLD:true};if(n!==i||s!==r){c["BINDINGS"]=[{OWNER_TYPE_NAME:BX.CrmEntityType.resolveName(n),OWNER_ID:s}]}if(o>0){c["SRC_ACTIVITY_ID"]=o}window.top["BXIM"].phoneTo(t,c)};BX.CrmTimelineCallAction.prototype.getMessage=function(t){var e=BX.CrmTimelineCallAction.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmTimelineCallAction.messages==="undefined"){BX.CrmTimelineCallAction.messages={}}}if(typeof BX.CrmTimelineOpenLineAction==="undefined"){BX.CrmTimelineOpenLineAction=function(){BX.CrmTimelineOpenLineAction.superclass.constructor.apply(this);this._clickHandler=BX.delegate(this.onClick,this);this._button=null};BX.extend(BX.CrmTimelineOpenLineAction,BX.CrmTimelineActivityAction);BX.CrmTimelineOpenLineAction.prototype.getButton=function(){return this._button};BX.CrmTimelineOpenLineAction.prototype.onClick=function(){if(typeof window.top["BXIM"]==="undefined"){window.alert(this.getMessage("openLineNotSupported"));return}var t="";var e=BX.prop.getObject(this._entityData,"COMMUNICATION",null);if(e){if(BX.prop.getString(e,"TYPE")==="IM"){t=BX.prop.getString(e,"VALUE")}}if(t!==""){window.top["BXIM"].openMessengerSlider(t,{RECENT:"N",MENU:"N"})}};BX.CrmTimelineOpenLineAction.prototype.doLayout=function(){this._button=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-action-reply-btn"},events:{click:this._clickHandler}});this._container.appendChild(this._button)};BX.CrmTimelineOpenLineAction.prototype.getMessage=function(t){var e=BX.CrmTimelineOpenLineAction.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmTimelineOpenLineAction.messages==="undefined"){BX.CrmTimelineOpenLineAction.messages={}}}if(typeof BX.CrmHistoryEmailAction==="undefined"){BX.CrmHistoryEmailAction=function(){BX.CrmHistoryEmailAction.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryEmailAction,BX.CrmTimelineEmailAction);BX.CrmHistoryEmailAction.prototype.doLayout=function(){this._container.appendChild(BX.create("A",{attrs:{className:"crm-entity-stream-content-action-reply-btn"},events:{click:this._clickHandler}}))};BX.CrmHistoryEmailAction.create=function(t,e){var i=new BX.CrmHistoryEmailAction;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryCallAction==="undefined"){BX.CrmHistoryCallAction=function(){BX.CrmHistoryCallAction.superclass.constructor.apply(this);this._button=null};BX.extend(BX.CrmHistoryCallAction,BX.CrmTimelineCallAction);BX.CrmHistoryCallAction.prototype.getButton=function(){return this._button};BX.CrmHistoryCallAction.prototype.doLayout=function(){this._button=BX.create("A",{attrs:{className:"crm-entity-stream-content-action-reply-btn"},events:{click:this._clickHandler}});this._container.appendChild(this._button)};BX.CrmHistoryCallAction.create=function(t,e){var i=new BX.CrmHistoryCallAction;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryOpenLineAction==="undefined"){BX.CrmHistoryOpenLineAction=function(){BX.CrmHistoryOpenLineAction.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryOpenLineAction,BX.CrmTimelineOpenLineAction);BX.CrmHistoryOpenLineAction.create=function(t,e){var i=new BX.CrmHistoryOpenLineAction;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleEmailAction==="undefined"){BX.CrmScheduleEmailAction=function(){BX.CrmScheduleEmailAction.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleEmailAction,BX.CrmTimelineEmailAction);BX.CrmScheduleEmailAction.prototype.doLayout=function(){this._container.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-action-reply-btn"},events:{click:this._clickHandler}}))};BX.CrmScheduleEmailAction.create=function(t,e){var i=new BX.CrmScheduleEmailAction;i.initialize(t,e);return i}}if(typeof BX.CrmSchedulePostponeController==="undefined"){BX.CrmSchedulePostponeController=function(){this._item=null};BX.CrmSchedulePostponeController.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._item=BX.prop.get(this._settings,"item",null)},getTitle:function(){return this.getMessage("title")},getCommandList:function(){return[{name:"postpone_hour_1",title:this.getMessage("forOneHour")},{name:"postpone_hour_2",title:this.getMessage("forTwoHours")},{name:"postpone_hour_3",title:this.getMessage("forThreeHours")},{name:"postpone_day_1",title:this.getMessage("forOneDay")},{name:"postpone_day_2",title:this.getMessage("forTwoDays")},{name:"postpone_day_3",title:this.getMessage("forThreeDays")}]},processCommand:function(t){if(t.indexOf("postpone")!==0){return false}var e=0;if(t==="postpone_hour_1"){e=3600}else if(t==="postpone_hour_2"){e=7200}else if(t==="postpone_hour_3"){e=10800}else if(t==="postpone_day_1"){e=86400}else if(t==="postpone_day_2"){e=172800}else if(t==="postpone_day_3"){e=259200}if(e>0&&this._item){this._item.postpone(e)}return true},getMessage:function(t){var e=BX.CrmSchedulePostponeController.messages;return e.hasOwnProperty(t)?e[t]:t}};if(typeof BX.CrmSchedulePostponeController.messages==="undefined"){BX.CrmSchedulePostponeController.messages={}}BX.CrmSchedulePostponeController.create=function(t,e){var i=new BX.CrmSchedulePostponeController;i.initialize(t,e);return i}}if(typeof BX.CrmSchedulePostponeAction==="undefined"){BX.CrmSchedulePostponeAction=function(){BX.CrmSchedulePostponeAction.superclass.constructor.apply(this);this._button=null;this._clickHandler=BX.delegate(this.onClick,this);this._isMenuShown=false;this._menu=false};BX.extend(BX.CrmSchedulePostponeAction,BX.CrmTimelineActivityAction);BX.CrmSchedulePostponeAction.prototype.doLayout=function(){this._button=BX.create("DIV",{attrs:{className:this._isEnabled?"crm-entity-stream-planned-action-aside":"crm-entity-stream-planned-action-aside-disabled"},text:this.getMessage("postpone")});if(this._isEnabled){BX.bind(this._button,"click",this._clickHandler)}this._container.appendChild(this._button)};BX.CrmSchedulePostponeAction.prototype.openMenu=function(){if(this._isMenuShown){return}var t=BX.delegate(this.onMenuItemClick,this);var e=[{id:"hour_1",text:this.getMessage("forOneHour"),onclick:t},{id:"hour_2",text:this.getMessage("forTwoHours"),onclick:t},{id:"hour_3",text:this.getMessage("forThreeHours"),onclick:t},{id:"day_1",text:this.getMessage("forOneDay"),onclick:t},{id:"day_2",text:this.getMessage("forTwoDays"),onclick:t},{id:"day_3",text:this.getMessage("forThreeDays"),onclick:t}];BX.PopupMenu.show(this._id,this._button,e,{offsetTop:0,offsetLeft:16,events:{onPopupShow:BX.delegate(this.onMenuShow,this),onPopupClose:BX.delegate(this.onMenuClose,this),onPopupDestroy:BX.delegate(this.onMenuDestroy,this)}});this._menu=BX.PopupMenu.currentItem};BX.CrmSchedulePostponeAction.prototype.closeMenu=function(){if(!this._isMenuShown){return}if(this._menu){this._menu.close()}};BX.CrmSchedulePostponeAction.prototype.onClick=function(){if(!this._isEnabled){return}if(this._isMenuShown){this.closeMenu()}else{this.openMenu()}};BX.CrmSchedulePostponeAction.prototype.onMenuItemClick=function(t,e){this.closeMenu();var i=0;if(e.id==="hour_1"){i=3600}else if(e.id==="hour_2"){i=7200}else if(e.id==="hour_3"){i=10800}else if(e.id==="day_1"){i=86400}else if(e.id==="day_2"){i=172800}else if(e.id==="day_3"){i=259200}if(i>0&&this._item){this._item.postpone(i)}};BX.CrmSchedulePostponeAction.prototype.onMenuShow=function(){this._isMenuShown=true};BX.CrmSchedulePostponeAction.prototype.onMenuClose=function(){if(this._menu&&this._menu.popupWindow){this._menu.popupWindow.destroy()}};BX.CrmSchedulePostponeAction.prototype.onMenuDestroy=function(){this._isMenuShown=false;this._menu=null;if(typeof BX.PopupMenu.Data[this._id]!=="undefined"){delete BX.PopupMenu.Data[this._id]}};BX.CrmSchedulePostponeAction.prototype.getMessage=function(t){var e=BX.CrmSchedulePostponeAction.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmSchedulePostponeAction.messages==="undefined"){BX.CrmSchedulePostponeAction.messages={}}BX.CrmSchedulePostponeAction.create=function(t,e){var i=new BX.CrmSchedulePostponeAction;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleCallAction==="undefined"){BX.CrmScheduleCallAction=function(){BX.CrmScheduleCallAction.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleCallAction,BX.CrmTimelineCallAction);BX.CrmScheduleCallAction.prototype.doLayout=function(){this._container.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-action-reply-btn"},events:{click:this._clickHandler}}))};BX.CrmScheduleCallAction.create=function(t,e){var i=new BX.CrmScheduleCallAction;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleOpenLineAction==="undefined"){BX.CrmScheduleOpenLineAction=function(){BX.CrmScheduleOpenLineAction.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleOpenLineAction,BX.CrmTimelineOpenLineAction);BX.CrmScheduleOpenLineAction.create=function(t,e){var i=new BX.CrmScheduleOpenLineAction;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineItem==="undefined"){BX.CrmTimelineItem=function(){this._id="";this._settings={};this._data={};this._container=null;this._wrapper=null;this._typeCategoryId=null;this._associatedEntityData=null;this._associatedEntityTypeId=null;this._associatedEntityId=null;this._isContextMenuShown=false;this._contextMenuButton=null;this._activityEditor=null;this._actions=[];this._actionContainer=null;this._isTerminated=false};BX.CrmTimelineItem.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._container=this.getSetting("container");if(!BX.type.isPlainObject(e["data"])){throw"BX.CrmTimelineItem. A required parameter 'data' is missing."}this._data=e["data"];this._activityEditor=this.getSetting("activityEditor");this.doInitialize()},doInitialize:function(){},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},getData:function(){return this._data},setData:function(t){if(BX.type.isPlainObject(t)){this._data=t;this.clearCachedData()}},getAssociatedEntityData:function(){if(this._associatedEntityData===null){this._associatedEntityData=BX.type.isPlainObject(this._data["ASSOCIATED_ENTITY"])?this._data["ASSOCIATED_ENTITY"]:{}}return this._associatedEntityData},getAssociatedEntityTypeId:function(){if(this._associatedEntityTypeId===null){this._associatedEntityTypeId=BX.prop.getInteger(this._data,"ASSOCIATED_ENTITY_TYPE_ID",0)}return this._associatedEntityTypeId},getAssociatedEntityId:function(){if(this._associatedEntityId===null){this._associatedEntityId=BX.prop.getInteger(this._data,"ASSOCIATED_ENTITY_ID",0)}return this._associatedEntityId},setAssociatedEntityData:function(t){if(!BX.type.isPlainObject(t)){t={}}this._data["ASSOCIATED_ENTITY"]=t;this.clearCachedData()},hasPermissions:function(){var t=this.getAssociatedEntityData();return BX.type.isPlainObject(t["PERMISSIONS"])},getPermissions:function(){return BX.prop.getObject(this.getAssociatedEntityData(),"PERMISSIONS",{})},setPermissions:function(t){if(!BX.type.isPlainObject(this._data["ASSOCIATED_ENTITY"])){this._data["ASSOCIATED_ENTITY"]={}}this._data["ASSOCIATED_ENTITY"]["PERMISSIONS"]=t;this.clearCachedData()},getTextDataParam:function(t){return BX.prop.getString(this._data,t,"")},getObjectDataParam:function(t){return BX.prop.getObject(this._data,t,{})},getArrayDataParam:function(t){return BX.prop.getArray(this._data,t,[])},getTypeId:function(){return BX.CrmTimelineType.undefined},getTypeCategoryId:function(){if(this._typeCategoryId===null){this._typeCategoryId=BX.prop.getInteger(this._data,"TYPE_CATEGORY_ID",0)}return this._typeCategoryId},getContainer:function(){return this._container},setContainer:function(t){this._container=BX.type.isElementNode(t)?t:null},getWrapper:function(){return this._wrapper},addWrapperClass:function(t,e){if(!this._wrapper){return}BX.addClass(this._wrapper,t);if(BX.type.isNumber(e)&&e>=0){window.setTimeout(BX.delegate(function(){this.removeWrapperClass(t)},this),e)}},removeWrapperClass:function(t,e){if(!this._wrapper){return}BX.removeClass(this._wrapper,t);if(BX.type.isNumber(e)&&e>=0){window.setTimeout(BX.delegate(function(){this.addWrapperClass(t)},this),e)}},layout:function(t){if(!BX.type.isElementNode(this._container)){throw"BX.CrmTimelineItem. Container is not assigned."}this.prepareLayout(t);this.prepareActions();var e=this._actions.length;for(var i=0;i<e;i++){this._actions[i].layout()}this.showActions(e>0)},prepareLayout:function(t){},prepareActions:function(){},showActions:function(t){},clearLayout:function(){this._wrapper=BX.remove(this._wrapper)},refreshLayout:function(){var t=this._wrapper.previousSibling;this._wrapper=BX.remove(this._wrapper);this.layout({anchor:t})},clearCachedData:function(){this._typeCategoryId=null;this._associatedEntityData=null;this._associatedEntityTypeId=null;this._associatedEntityId=null},isDone:function(){return false},markAsDone:function(t){},isTerminated:function(){return this._isTerminated},markAsTerminated:function(t){t=!!t;if(this._isTerminated===t){return}this._isTerminated=t;if(!this._wrapper){return}if(t){BX.addClass(this._wrapper,"crm-entity-stream-section-last")}else{BX.removeClass(this._wrapper,"crm-entity-stream-section-last")}},view:function(){},edit:function(){},fasten:function(){},unfasten:function(){},remove:function(){},cutOffText:function(t,e){if(!BX.type.isNumber(e)){e=0}if(e<=0||t.length<=e){return t}var i=e-1;var r=t.substring(i).search(/\s/i);if(r>0){i+=r}return t.substring(0,i)},prepareCutOffElements:function(t,e,i){if(!BX.type.isNumber(e)){e=0}if(e<=0||t.length<=e){return[BX.util.htmlspecialchars(t)]}var r=e-1;var n=t.substring(r).search(/\s/i);if(n>0){r+=n}return[BX.util.htmlspecialchars(t.substring(0,r))+"&hellip;&nbsp;",BX.create("A",{attrs:{className:"crm-entity-stream-content-letter-more",href:"#"},events:{click:i},text:this.getMessage("details")})]},prepareAuthorLayout:function(){var t=this.getObjectDataParam("AUTHOR",null);if(!t){return null}var e=BX.prop.getString(t,"SHOW_URL","");if(e===""){return null}var i=BX.create("A",{attrs:{className:"crm-entity-stream-content-detail-employee",href:e,target:"_blank",title:BX.prop.getString(t,"FORMATTED_NAME","")}});var r=BX.prop.getString(t,"IMAGE_URL","");if(r!==""){i.style.backgroundImage="url('"+r+"')";i.style.backgroundSize="21px"}return i},onActivityCreate:function(t,e){}};BX.CrmTimelineItem.userTimezoneOffset=null;BX.CrmTimelineItem.getUserTimezoneOffset=function(){if(!this.userTimezoneOffset){this.userTimezoneOffset=parseInt(BX.message("USER_TZ_OFFSET"));if(isNaN(this.userTimezoneOffset)){this.userTimezoneOffset=0}}return this.userTimezoneOffset};BX.CrmTimelineItem.prototype.isContextMenuEnabled=function(){return false};BX.CrmTimelineItem.prototype.prepareContextMenuButton=function(){this._contextMenuButton=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-context-menu"},events:{click:BX.delegate(this.onContextMenuButtonClick,this)}});return this._contextMenuButton};BX.CrmTimelineItem.prototype.onContextMenuButtonClick=function(t){if(!this._isContextMenuShown){this.openContextMenu()}else{this.closeContextMenu()}};BX.CrmTimelineItem.prototype.openContextMenu=function(){var t=this.prepareContextMenuItems();if(t.length===0){return}BX.PopupMenu.show(this._id,this._contextMenuButton,t,{offsetTop:0,offsetLeft:16,angle:{position:"top",offset:0},events:{onPopupShow:BX.delegate(this.onContextMenuShow,this),onPopupClose:BX.delegate(this.onContextMenuClose,this),onPopupDestroy:BX.delegate(this.onContextMenuDestroy,this)}});this._contextMenu=BX.PopupMenu.currentItem};BX.CrmTimelineItem.prototype.closeContextMenu=function(){if(this._contextMenu){this._contextMenu.close()}};BX.CrmTimelineItem.prototype.prepareContextMenuItems=function(){return[]};BX.CrmTimelineItem.prototype.onContextMenuShow=function(){this._isContextMenuShown=true;BX.addClass(this._contextMenuButton,"active")};BX.CrmTimelineItem.prototype.onContextMenuClose=function(){if(this._contextMenu){this._contextMenu.popupWindow.destroy()}};BX.CrmTimelineItem.prototype.onContextMenuDestroy=function(){this._isContextMenuShown=false;BX.removeClass(this._contextMenuButton,"active");this._contextMenu=null;if(typeof BX.PopupMenu.Data[this._id]!=="undefined"){delete BX.PopupMenu.Data[this._id]}};BX.CrmTimelineItem.prototype.getMessage=function(t){var e=BX.CrmTimelineItem.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmTimelineItem.messages==="undefined"){BX.CrmTimelineItem.messages={}}}if(typeof BX.Crm.TimelineEditorMode==="undefined"){BX.Crm.TimelineEditorMode={view:1,edit:2}}if(typeof BX.CrmHistoryItem==="undefined"){BX.CrmHistoryItem=function(){BX.CrmHistoryItem.superclass.constructor.apply(this);this._history=null;this._fixedHistory=null;this._typeId=null;this._createdTime=null;this._isFixed=false;this._headerClickHandler=BX.delegate(this.onHeaderClick,this)};BX.extend(BX.CrmHistoryItem,BX.CrmTimelineItem);BX.CrmHistoryItem.prototype.doInitialize=function(){this._history=this.getSetting("history");this._fixedHistory=this.getSetting("fixedHistory")};BX.CrmHistoryItem.prototype.getTypeId=function(){if(this._typeId===null){this._typeId=BX.prop.getInteger(this._data,"TYPE_ID",BX.CrmTimelineType.undefined)}return this._typeId};BX.CrmHistoryItem.prototype.getTitle=function(){return""};BX.CrmHistoryItem.prototype.isContextMenuEnabled=function(){return!this.isReadOnly()};BX.CrmHistoryItem.prototype.getCreatedTimestamp=function(){return this.getTextDataParam("CREATED_SERVER")};BX.CrmHistoryItem.prototype.getCreatedTime=function(){if(this._createdTime===null){var t=BX.parseDate(this.getCreatedTimestamp(),false,"YYYY-MM-DD","YYYY-MM-DD HH:MI:SS");this._createdTime=new Date(t.getTime()+1e3*BX.CrmTimelineItem.getUserTimezoneOffset())}return this._createdTime};BX.CrmHistoryItem.prototype.getCreatedDate=function(){return BX.prop.extractDate(new Date(this.getCreatedTime().getTime()))};BX.CrmHistoryItem.prototype.getOwnerInfo=function(){return this._history?this._history.getOwnerInfo():null};BX.CrmHistoryItem.prototype.getOwnerTypeId=function(){return BX.prop.getInteger(this.getOwnerInfo(),"ENTITY_TYPE_ID",BX.CrmEntityType.enumeration.undefined)};BX.CrmHistoryItem.prototype.getOwnerId=function(){return BX.prop.getInteger(this.getOwnerInfo(),"ENTITY_ID",0)};BX.CrmHistoryItem.prototype.isReadOnly=function(){return this._history.isReadOnly()};BX.CrmHistoryItem.prototype.isEditable=function(){return!this.isReadOnly()};BX.CrmHistoryItem.prototype.isDone=function(){var t=this.getTypeId();if(t===BX.CrmTimelineType.activity){var e=this.getAssociatedEntityData();return BX.CrmActivityStatus.isFinal(BX.prop.getInteger(e,"STATUS",0))}return false};BX.CrmHistoryItem.prototype.isFixed=function(){return this._isFixed};BX.CrmHistoryItem.prototype.fasten=function(t){if(this._fixedHistory._items.length>=3){if(!this.fastenLimitPopup){this.fastenLimitPopup=new BX.PopupWindow("timeline_fasten_limit_popup_"+this._id,this._switcher,{content:BX.message("CRM_TIMELINE_FASTEN_LIMIT_MESSAGE"),darkMode:true,autoHide:true,zIndex:990,angle:true,closeByEsc:true,bindOptions:{forceBindPosition:true}})}this.fastenLimitPopup.show();this.closeContextMenu();return}BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"CHANGE_FASTEN_ITEM",VALUE:"Y",OWNER_TYPE_ID:this.getOwnerTypeId(),OWNER_ID:this.getOwnerId(),ID:this._id},onsuccess:BX.delegate(this.onSuccessFasten,this)});this.closeContextMenu()};BX.CrmHistoryItem.prototype.onSuccessFasten=function(t){if(BX.type.isNotEmptyString(t.ERROR))return;if(!this.isFixed()){this._data.IS_FIXED="Y";var e=this._fixedHistory.createItem(this._data);e._isFixed=true;this._fixedHistory.addItem(e,0);e.layout({add:false});this.refreshLayout();var i=BX.CrmTimelineItemFasten.create("",{initialItem:this,finalItem:e,anchor:this._fixedHistory._anchor});i.run()}this.closeContextMenu()};BX.CrmHistoryItem.prototype.onFinishFasten=function(t){};BX.CrmHistoryItem.prototype.unfasten=function(t){BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"CHANGE_FASTEN_ITEM",VALUE:"N",OWNER_TYPE_ID:this.getOwnerTypeId(),OWNER_ID:this.getOwnerId(),ID:this._id},onsuccess:BX.delegate(this.onSuccessUnfasten,this)});this.closeContextMenu()};BX.CrmHistoryItem.prototype.onSuccessUnfasten=function(t){if(BX.type.isNotEmptyString(t.ERROR))return;var e=null;var i=null;if(this.isFixed()){e=this;i=this._history.findItemById(this._id)}else{e=this._fixedHistory.findItemById(this._id);i=this}if(e){var r=this._fixedHistory.getItemIndex(e);e.clearAnimate();this._fixedHistory.removeItemByIndex(r);if(i){i._data.IS_FIXED="N";i.refreshLayout();BX.LazyLoad.showImages()}}};BX.CrmHistoryItem.prototype.clearAnimate=function(){if(!BX.type.isDomNode(this._wrapper))return;var t=BX.pos(this._wrapper);var e=new BX.easing({duration:1e3,start:{height:t.height,opacity:1,marginBottom:15},finish:{height:0,opacity:0,marginBottom:0},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._wrapper.style.height=t.height+"px";this._wrapper.style.opacity=t.opacity;this._wrapper.style.marginBottom=t.marginBottom},this),complete:BX.proxy(function(){this.clearLayout()},this)});e.animate()};BX.CrmHistoryItem.prototype.getWrapperClassName=function(){return""};BX.CrmHistoryItem.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-info"};BX.CrmHistoryItem.prototype.prepareContentDetails=function(){return[]};BX.CrmHistoryItem.prototype.prepareContent=function(){var t=this.getWrapperClassName();if(t!==""){t="crm-entity-stream-section crm-entity-stream-section-history"+" "+t}else{t="crm-entity-stream-section crm-entity-stream-section-history"}var e=BX.create("DIV",{attrs:{className:t}});e.appendChild(BX.create("DIV",{attrs:{className:this.getIconClassName()}}));var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[i]}));var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}),BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})]});i.appendChild(r);i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:this.prepareContentDetails()}));var n=this.prepareAuthorLayout();if(n){i.appendChild(n)}return e};BX.CrmHistoryItem.prototype.prepareLayout=function(t){this._wrapper=this.prepareContent();if(this._wrapper){var e=BX.type.isPlainObject(t)?BX.prop.getBoolean(t,"add",true):true;if(e){var i=BX.type.isPlainObject(t)&&BX.type.isElementNode(t["anchor"])?t["anchor"]:null;if(i&&i.nextSibling){this._container.insertBefore(this._wrapper,i.nextSibling)}else{this._container.appendChild(this._wrapper)}}this.markAsTerminated(this._history.checkItemForTermination(this))}};BX.CrmHistoryItem.prototype.onHeaderClick=function(t){this.view();t.preventDefault?t.preventDefault():t.returnValue=false};BX.CrmHistoryItem.prototype.prepareTitleLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},text:this.getTitle()})};BX.CrmHistoryItem.prototype.prepareFixedSwitcherLayout=function(){var t=this.getTextDataParam("IS_FIXED")==="Y";this._switcher=BX.create("span",{attrs:{className:"crm-entity-stream-section-top-fixed-btn"},events:{click:t?BX.delegate(this.unfasten,this):BX.delegate(this.fasten,this)}});if(t)BX.addClass(this._switcher,"crm-entity-stream-section-top-fixed-btn-active");if(!this.isReadOnly()&&!t){var e=this._history.getManager();if(!e.isSpotlightShowed()){e.setSpotlightShowed();BX.addClass(this._switcher,"crm-entity-stream-section-top-fixed-btn-spotlight");var i=new BX.SpotLight({targetElement:this._switcher,targetVertex:"middle-center",lightMode:false,id:"CRM_TIMELINE_FASTEN_SWITCHER",zIndex:900,top:-3,left:-1,autoSave:true,content:BX.message("CRM_TIMELINE_SPOTLIGHT_FASTEN_MESSAGE")});i.show()}}return this._switcher};BX.CrmHistoryItem.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())}));return t};BX.CrmHistoryItem.prototype.onActivityCreate=function(t,e){this._history.getManager().onActivityCreated(t,e)};BX.CrmHistoryItem.prototype.formatTime=function(t){if(this.isFixed()){return this._fixedHistory.formatTime(t)}return this._history.formatTime(t)};BX.CrmHistoryItem.create=function(t,e){var i=new BX.CrmHistoryItem;i.initialize(t,e);return i};BX.CrmHistoryItem.isCounterEnabled=function(t){if(!BX.type.isDate(t)){return false}var e=new Date;e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0);e=e.getTime();var i=new Date;i.setHours(23);i.setMinutes(59);i.setSeconds(59);i.setMilliseconds(999);i=i.getTime();var r=t.getTime();return r<e||r>=e&&r<=i}}if(typeof BX.CrmHistoryItemActivity==="undefined"){BX.CrmHistoryItemActivity=function(){BX.CrmHistoryItemActivity.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemActivity,BX.CrmHistoryItem);BX.CrmHistoryItemActivity.prototype.doInitialize=function(){BX.CrmHistoryItemActivity.superclass.doInitialize.apply(this);if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmHistoryItemActivity. The field 'activityEditor' is not assigned."}};BX.CrmHistoryItemActivity.prototype.getTitle=function(){return BX.prop.getString(this.getAssociatedEntityData(),"SUBJECT","")};BX.CrmHistoryItemActivity.prototype.getTypeDescription=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getInteger(t,"DIRECTION",0);var i=this.getTypeCategoryId();if(i===BX.CrmActivityType.email){return this.getMessage(e===BX.CrmActivityDirection.incoming?"incomingEmail":"outgoingEmail")}else if(i===BX.CrmActivityType.call){return this.getMessage(e===BX.CrmActivityDirection.incoming?"incomingCall":"outgoingCall")}else if(i===BX.CrmActivityType.meeting){return this.getMessage("meeting")}else if(i===BX.CrmActivityType.task){return this.getMessage("task")}else if(i===BX.CrmActivityType.provider){var r=BX.prop.getString(t,"PROVIDER_ID","");if(r==="CRM_WEBFORM"){return this.getMessage("webform")}else if(r==="CRM_SMS"){return this.getMessage("sms")}else if(r==="CRM_REQUEST"){return this.getMessage("activityRequest")}else if(r==="IMOPENLINES_SESSION"){return this.getMessage("openLine")}else if(r==="REST_APP"){return this.getMessage("restApplication")}else if(r==="VISIT_TRACKER"){return this.getMessage("visit")}}return""};BX.CrmHistoryItemActivity.prototype.prepareTitleLayout=function(){return BX.create("A",{attrs:{href:"#",className:"crm-entity-stream-content-event-title"},events:{click:this._headerClickHandler},text:this.getTypeDescription()})};BX.CrmHistoryItemActivity.prototype.prepareTimeLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})};BX.CrmHistoryItemActivity.prototype.prepareMarkLayout=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getInteger(t,"MARK_TYPE_ID",0);if(e<=0){return null}var i="";if(e===2){i="SuccessMark"}else if(e===3){i="RenewMark"}if(i===""){return null}var r="";var n=this.getTypeCategoryId();if(n===BX.CrmActivityType.email){r=this.getMessage("email"+i)}else if(n===BX.CrmActivityType.call){r=this.getMessage("call"+i)}else if(n===BX.CrmActivityType.meeting){r=this.getMessage("meeting"+i)}else if(n===BX.CrmActivityType.task){r=this.getMessage("task"+i)}if(r===""){return null}return BX.create("SPAN",{props:{className:"crm-entity-stream-content-event-skipped"},text:r})};BX.CrmHistoryItemActivity.prototype.prepareActions=function(){if(this.isReadOnly()){return}var t=this.getTypeCategoryId();if(t===BX.CrmActivityType.email){this._actions.push(BX.CrmHistoryEmailAction.create("email",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor}))}};BX.CrmHistoryItemActivity.prototype.prepareContextMenuItems=function(){if(this._isMenuShown){return}var t=[];if(!this.isReadOnly()){if(this.isEditable()){t.push({id:"edit",text:this.getMessage("menuEdit"),onclick:BX.delegate(this.edit,this)})}t.push({id:"remove",text:this.getMessage("menuDelete"),onclick:BX.delegate(this.processRemoval,this)});if(this.isFixed()||this._fixedHistory.findItemById(this._id))t.push({id:"unfasten",text:this.getMessage("menuUnfasten"),onclick:BX.delegate(this.unfasten,this)});else t.push({id:"fasten",text:this.getMessage("menuFasten"),onclick:BX.delegate(this.fasten,this)})}return t};BX.CrmHistoryItemActivity.prototype.view=function(){this.closeContextMenu();var t=this.getAssociatedEntityData();var e=BX.prop.getInteger(t,"ID",0);if(e>0){this._activityEditor.viewActivity(e)}};BX.CrmHistoryItemActivity.prototype.edit=function(){this.closeContextMenu();var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.activity){var e=this.getAssociatedEntityData();var i=BX.prop.getInteger(e,"ID",0);if(i>0){this._activityEditor.editActivity(i)}}};BX.CrmHistoryItemActivity.prototype.processRemoval=function(){this.closeContextMenu();this._detetionConfirmDlgId="entity_timeline_deletion_"+this.getId()+"_confirm";var t=BX.Crm.ConfirmationDialog.get(this._detetionConfirmDlgId);if(!t){t=BX.Crm.ConfirmationDialog.create(this._detetionConfirmDlgId,{title:this.getMessage("removeConfirmTitle"),content:this.getRemoveMessage()})}t.open().then(BX.delegate(this.onRemovalConfirm,this),BX.delegate(this.onRemovalCancel,this))};BX.CrmHistoryItemActivity.prototype.getRemoveMessage=function(){return this.getMessage("removeConfirm")};BX.CrmHistoryItemActivity.prototype.onRemovalConfirm=function(t){if(BX.prop.getBoolean(t,"cancel",true)){return}this.remove()};BX.CrmHistoryItemActivity.prototype.onRemovalCancel=function(){};BX.CrmHistoryItemActivity.prototype.remove=function(){var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.activity){var e=this.getAssociatedEntityData();var i=BX.prop.getInteger(e,"ID",0);if(i>0){var r=this._activityEditor;var n=r.getItemById(i);if(n){r.deleteActivity(i,true)}else{var s=BX.util.add_url_param(r.getSetting("serviceUrl",""),{id:i,action:"get_activity",ownertype:r.getSetting("ownerType",""),ownerid:r.getSetting("ownerID","")});BX.ajax({url:s,method:"POST",dataType:"json",data:{ACTION:"GET_ACTIVITY",ID:i,OWNER_TYPE:r.getSetting("ownerType",""),OWNER_ID:r.getSetting("ownerID","")},onsuccess:BX.delegate(function(t){if(typeof t["ACTIVITY"]!=="undefined"){r._handleActivityChange(t["ACTIVITY"]);window.setTimeout(BX.delegate(this.remove,this),500)}},this),onfailure:function(t){}})}}}};if(typeof BX.CrmHistoryItemActivity.messages==="undefined"){BX.CrmHistoryItemActivity.messages={}}BX.CrmHistoryItemActivity.create=function(t,e){var i=new BX.CrmHistoryItemActivity;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemComment==="undefined"){BX.CrmHistoryItemComment=function(){BX.CrmHistoryItemComment.superclass.constructor.apply(this);this._isCollapsed=false;this._isMenuShown=false;this._isFixed=false;this._hasFiles=false;this._postForm=null;this._editor=null;this._commentMessage="";this._mode=BX.Crm.TimelineEditorMode.view};BX.extend(BX.CrmHistoryItemComment,BX.CrmHistoryItem);BX.CrmHistoryItemComment.prototype.doInitialize=function(){BX.CrmHistoryItemComment.superclass.doInitialize.apply(this);this._hasFiles=this.getTextDataParam("HAS_FILES")==="Y"};BX.CrmHistoryItemComment.prototype.getTitle=function(){return this.getMessage("comment")};BX.CrmHistoryItemComment.prototype.prepareContent=function(){var t=this.getTextDataParam("COMMENT","");var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-comment"}});if(this.isReadOnly()){BX.addClass(e,"crm-entity-stream-section-comment-read-only")}if(this.isFixed())BX.addClass(e,"crm-entity-stream-section-top-fixed");e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-comment"}}));if(this.isContextMenuEnabled()){e.appendChild(this.prepareContextMenuButton())}var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var r=this.prepareHeaderLayout();i.appendChild(r);if(!this.isReadOnly())e.appendChild(this.prepareFixedSwitcherLayout());var n=[];if(this._mode!==BX.Crm.TimelineEditorMode.edit){this._commentWrapper=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"}});BX.html(this._commentWrapper,this.getTextDataParam("COMMENT",""));n.push(this._commentWrapper);if(!this.isReadOnly()){BX.bind(this._commentWrapper,"click",BX.delegate(this.switchToEditMode,this));BX.bind(r,"click",BX.delegate(this.switchToEditMode,this))}}else{if(!BX.type.isDomNode(this._editorContainer))this._editorContainer=BX.create("div",{attrs:{className:"crm-entity-stream-section-comment-editor"}});n.push(this._editorContainer);var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-comment-edit-btn-container"},children:[BX.create("button",{attrs:{className:"ui-btn ui-btn-xs ui-btn-primary"},html:this.getMessage("send"),events:{click:BX.delegate(this.save,this)}}),BX.create("a",{attrs:{className:"ui-btn ui-btn-xs ui-btn-link"},html:this.getMessage("cancel"),events:{click:BX.delegate(this.switchToViewMode,this)}})]});n.push(s)}i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:n}));var a=this.prepareAuthorLayout();if(a){i.appendChild(a)}var o=this.getTextDataParam("TEXT","");var c=this.getTextDataParam("HAS_INLINE_ATTACHMENT","")==="Y";if(o.length<=128&&!c||this._mode===BX.Crm.TimelineEditorMode.edit){this._isCollapsed=false;e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[i]}))}else{this._isCollapsed=true;e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content crm-entity-stream-section-content-collapsed"},children:[i]}));e.querySelector(".crm-entity-stream-content-event").appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content-expand-btn-container"},children:[BX.create("A",{attrs:{className:"crm-entity-stream-section-content-expand-btn",href:"#"},events:{click:BX.delegate(this.onExpandButtonClick,this)},text:this.getMessage("expand")})]}))}if(this._mode===BX.Crm.TimelineEditorMode.view&&this._hasFiles){this._textLoaded=false;this._fileBlock=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-files-inner"},children:[BX.create("DIV",{attrs:{className:"crm-timeline-wait"}})]});e.querySelector(".crm-entity-stream-section-content").appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-files"},children:[this._fileBlock]}));BX.ready(BX.delegate(function(){window.setTimeout(BX.delegate(function(){this.loadContent(this._fileBlock,"GET_FILE_BLOCK")},this),100)},this))}return e};BX.CrmHistoryItemComment.prototype.prepareActions=function(){if(this._mode===BX.Crm.TimelineEditorMode.view&&BX.type.isDomNode(this._commentWrapper)){this.registerImages(this._commentWrapper);if(!BX.getClass("BX.Disk.apiVersion")){BX.viewElementBind(this._commentWrapper,{showTitle:true},function(t){return BX.type.isElementNode(t)&&(t.getAttribute("data-bx-viewer")||t.getAttribute("data-bx-image"))})}}};BX.CrmHistoryItemComment.prototype.loadContent=function(t,e){if(!BX.type.isDomNode(t))return;BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"GET_COMMENT_CONTENT",ID:this.getId(),ENTITY_TYPE_ID:this.getOwnerTypeId(),ENTITY_ID:this.getOwnerId(),TYPE:e},onsuccess:BX.delegate(function(i){if(BX.type.isNotEmptyString(i.ERROR)&&e==="GET_FILE_BLOCK"){BX.remove(t);return}if(BX.type.isNotEmptyString(i.BLOCK)){var r=BX.html(t,i.BLOCK);r.then(BX.delegate(function(){this.registerImages(t);BX.LazyLoad.showImages()},this))}},this)})};BX.CrmHistoryItemComment.prototype.loadEditor=function(){this._editorName="CrmTimeLineComment"+this._id+BX.util.getRandomString(4);if(this._postForm){this._postForm.oEditor.SetContent(this._commentMessage);this._editor.ReInitIframe();return}actionData={data:{id:this._id,name:this._editorName}};BX.ajax.runAction("crm.api.timeline.loadEditor",actionData).then(this.onLoadEditorSuccess.bind(this)).catch(this.switchToViewMode.bind(this))};BX.CrmHistoryItemComment.prototype.onLoadEditorSuccess=function(t){if(!BX.type.isDomNode(this._editorContainer))this._editorContainer=BX.create("div",{attrs:{className:"crm-entity-stream-section-comment-editor"}});var e=BX.prop.getString(BX.prop.getObject(t,"data",{}),"html","");BX.html(this._editorContainer,e).then(BX.delegate(this.showEditor,this))};BX.CrmHistoryItemComment.prototype.showEditor=function(){if(LHEPostForm){window.setTimeout(BX.delegate(function(){this._postForm=LHEPostForm.getHandler(this._editorName);this._editor=BXHtmlEditor.Get(this._editorName);BX.onCustomEvent(this._postForm.eventNode,"OnShowLHE",[true]);this._commentMessage=this._postForm.oEditor.GetContent()},this),0)}};BX.CrmHistoryItemComment.prototype.onFinishFasten=function(){this.registerImages(this._commentWrapper);if(BX.type.isDomNode(this._fileBlock))this.registerImages(this._fileBlock);BX.LazyLoad.showImages()};BX.CrmHistoryItemComment.prototype.registerImages=function(t){var e=t.querySelectorAll('[data-bx-viewer="image"]');var i=e.length;if(i>0){var r=[];for(var n=0;n<i;++n){if(BX.type.isDomNode(e[n])){e[n].id+=BX.util.getRandomString(4);r.push(e[n].id)}}if(r.length>0){BX.LazyLoad.registerImages(r)}}BX.LazyLoad.registerImages(r)};BX.CrmHistoryItemComment.prototype.ensureGhostCreated=function(){if(this._ghostInput){return this._ghostInput}this._ghostInput=BX.create("div",{props:{className:"crm-entity-stream-content-new-comment-textarea-shadow"},text:this._input.value});this._ghostInput.style.width=this._input.offsetWidth+"px";document.body.appendChild(this._ghostInput);return this._ghostInput};BX.CrmHistoryItemComment.prototype.toggleMode=function(t){this._mode=parseInt(t);this._hasFiles=this.getTextDataParam("HAS_FILES")==="Y";this.refreshLayout();this.closeContextMenu()};BX.CrmHistoryItemComment.prototype.switchToViewMode=function(t){this.toggleMode(BX.Crm.TimelineEditorMode.view)};BX.CrmHistoryItemComment.prototype.switchToEditMode=function(t){var e=t.target.tagName.toLowerCase();if(e==="a"||e==="img"||BX.hasClass(t.target,"feed-con-file-changes-link-more")||BX.hasClass(t.target,"feed-com-file-inline")){return}this.toggleMode(BX.Crm.TimelineEditorMode.edit);window.setTimeout(BX.delegate(function(){this.loadEditor()},this),100)};BX.CrmHistoryItemComment.prototype.prepareContextMenuItems=function(){if(this._isMenuShown){return}var t=[];if(!this.isReadOnly()){if(this._mode!==BX.Crm.TimelineEditorMode.edit){t.push({id:"edit",text:this.getMessage("menuEdit"),onclick:BX.delegate(this.switchToEditMode,this)})}else{t.push({id:"cancel",text:this.getMessage("menuCancel"),onclick:BX.delegate(this.switchToViewMode,this)})}t.push({id:"remove",text:this.getMessage("menuDelete"),onclick:BX.delegate(this.processRemoval,this)});if(this.isFixed()||this._fixedHistory.findItemById(this._id))t.push({id:"unfasten",text:this.getMessage("menuUnfasten"),onclick:BX.delegate(this.unfasten,this)});else t.push({id:"fasten",text:this.getMessage("menuFasten"),onclick:BX.delegate(this.fasten,this)})}return t};BX.CrmHistoryItemComment.prototype.save=function(t){var e=[];var i="";if(this._postForm){i=this._postForm.oEditor.GetContent();this._commentMessage=i;var r=[];for(var n in this._postForm.arFiles){if(this._postForm.arFiles.hasOwnProperty(n)){var s=this._postForm.arFiles[n];r.indexOf(s)===-1?r.push(s):null}}for(var a=0,o=r.length;a<o;a++){for(var c in this._postForm.controllers[r[a]].values){if(this._postForm.controllers[r[a]].values.hasOwnProperty(c)&&e.indexOf(c)===-1){e.push(c)}}}}else{i=this._input.value}if(!BX.type.isNotEmptyString(i)){if(!this.emptyCommentMessage){this.emptyCommentMessage=new BX.PopupWindow("timeline_empty_comment_"+this._id,t.target,{content:BX.message("CRM_TIMELINE_EMPTY_COMMENT_MESSAGE"),darkMode:true,autoHide:true,zIndex:990,angle:{position:"top",offset:77},closeByEsc:true,bindOptions:{forceBindPosition:true}})}this.emptyCommentMessage.show();return}if(this._isRequestRunning&&BX.type.isNotEmptyString(i)){return}this._isRequestRunning=true;BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"UPDATE_COMMENT",ID:this.getId(),TEXT:i,OWNER_TYPE_ID:this.getOwnerTypeId(),OWNER_ID:this.getOwnerId(),ATTACHMENTS:e},onsuccess:BX.delegate(this.onSaveSuccess,this),onfailure:BX.delegate(this.onRequestFailure,this)})};BX.CrmHistoryItemComment.prototype.processRemoval=function(){this.closeContextMenu();this._detetionConfirmDlgId="entity_timeline_deletion_"+this.getId()+"_confirm";var t=BX.Crm.ConfirmationDialog.get(this._detetionConfirmDlgId);if(!t){t=BX.Crm.ConfirmationDialog.create(this._detetionConfirmDlgId,{title:this.getMessage("removeConfirmTitle"),content:this.getMessage("commentRemove")})}t.open().then(BX.delegate(this.onRemovalConfirm,this),BX.delegate(this.onRemovalCancel,this))};BX.CrmHistoryItemComment.prototype.onRemovalConfirm=function(t){if(BX.prop.getBoolean(t,"cancel",true)){return}this.remove()};BX.CrmHistoryItemComment.prototype.onRemovalCancel=function(){};BX.CrmHistoryItemComment.prototype.remove=function(t){if(this._isRequestRunning){return}var e=this._history._manager.getHistory();var i=e.findItemById(this._id);if(i instanceof BX.CrmHistoryItemComment)i.clearAnimate();var r=this._history._manager.getFixedHistory();var n=r.findItemById(this._id);if(n instanceof BX.CrmHistoryItemComment)n.clearAnimate();this._isRequestRunning=true;BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"DELETE_COMMENT",OWNER_TYPE_ID:this.getOwnerTypeId(),OWNER_ID:this.getOwnerId(),ID:this.getId()},onsuccess:BX.delegate(this.onRemoveSuccess,this),onfailure:BX.delegate(this.onRequestFailure,this)})};BX.CrmHistoryItemComment.prototype.onSaveSuccess=function(t){this._isRequestRunning=false;var e=BX.prop.getObject(t,"HISTORY_ITEM");var i=this._fixedHistory.findItemById(this._id);if(i instanceof BX.CrmHistoryItemComment){if(!BX.type.isNotEmptyString(e["IS_FIXED"]))e["IS_FIXED"]="Y";i.setData(e);i._id=BX.prop.getString(e,"ID");i.switchToViewMode()}var r=this._history.findItemById(this._id);if(r instanceof BX.CrmHistoryItemComment){r.setData(e);r._id=BX.prop.getString(e,"ID");r.switchToViewMode()}};BX.CrmHistoryItemComment.prototype.onRemoveSuccess=function(t){};BX.CrmHistoryItemComment.prototype.onRequestFailure=function(t){this._isRequestRunning=this._isLocked=false};BX.CrmHistoryItemComment.prototype.onExpandButtonClick=function(t){if(!this._wrapper){return BX.PreventDefault(t)}var e=this._wrapper.querySelector("div.crm-entity-stream-section-content");if(!e){return BX.PreventDefault(t)}if(this._hasFiles&&BX.type.isDomNode(this._commentWrapper)&&!this._textLoaded){this._textLoaded=true;this.loadContent(this._commentWrapper,"GET_TEXT")}var i=e.querySelector(".crm-entity-stream-content-event");if(this._isCollapsed){i.style.maxHeight=i.scrollHeight+130+"px";BX.removeClass(e,"crm-entity-stream-section-content-collapsed");BX.addClass(e,"crm-entity-stream-section-content-expand");setTimeout(BX.delegate(function(){i.style.maxHeight=""},this),300)}else{i.style.maxHeight=i.clientHeight+"px";BX.removeClass(e,"crm-entity-stream-section-content-expand");BX.addClass(e,"crm-entity-stream-section-content-collapsed");setTimeout(BX.delegate(function(){i.style.maxHeight=""},this),0)}this._isCollapsed=!this._isCollapsed;var r=e.querySelector("a.crm-entity-stream-section-content-expand-btn");if(r){r.innerHTML=this.getMessage(this._isCollapsed?"expand":"collapse")}return BX.PreventDefault(t)};BX.CrmHistoryItemComment.create=function(t,e){var i=new BX.CrmHistoryItemComment;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemModification==="undefined"){BX.CrmHistoryItemModification=function(){BX.CrmHistoryItemModification.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemModification,BX.CrmHistoryItem);BX.CrmHistoryItemModification.prototype.getMessage=function(t){var e=BX.CrmHistoryItemModification.messages;return e.hasOwnProperty(t)?e[t]:t};BX.CrmHistoryItemModification.prototype.getTitle=function(){return this.getTextDataParam("TITLE")};BX.CrmHistoryItemModification.prototype.prepareContent=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-info"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-info"}}));var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var i=this.prepareHeaderLayout();var r=[];if(BX.type.isNotEmptyString(this.getTextDataParam("START_NAME"))){r.push(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detain-info-status"},text:this.getTextDataParam("START_NAME")}));r.push(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-info-separator-icon"}}))}if(BX.type.isNotEmptyString(this.getTextDataParam("FINISH_NAME"))){r.push(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detain-info-status"},text:this.getTextDataParam("FINISH_NAME")}))}e.appendChild(i);e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-info"},children:r})]}));var n=this.prepareAuthorLayout();if(n){e.appendChild(n)}t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[e]}));return t};if(typeof BX.CrmHistoryItemModification.messages==="undefined"){BX.CrmHistoryItemModification.messages={}}BX.CrmHistoryItemModification.create=function(t,e){var i=new BX.CrmHistoryItemModification;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemMark==="undefined"){BX.CrmHistoryItemMark=function(){BX.CrmHistoryItemMark.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemMark,BX.CrmHistoryItem);BX.CrmHistoryItemMark.prototype.doInitialize=function(){BX.CrmHistoryItemMark.superclass.doInitialize.apply(this);if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmHistoryItemMark. The field 'activityEditor' is not assigned."}};BX.CrmHistoryItemMark.prototype.getMessage=function(t){var e=BX.CrmHistoryItemMark.messages;return e.hasOwnProperty(t)?e[t]:t};BX.CrmHistoryItemMark.prototype.getTitle=function(){var t="";var e=this.getAssociatedEntityData();var i=this.getAssociatedEntityTypeId();var r=this.getTypeCategoryId();if(i===BX.CrmEntityType.enumeration.activity){var n=BX.prop.getInteger(e,"TYPE_ID",0);var s=BX.prop.getInteger(e,"DIRECTION",0);var a=BX.prop.getString(e,"PROVIDER_ID","");if(n===BX.CrmActivityType.email){if(r===2){t=this.getMessage((s===BX.CrmActivityDirection.incoming?"incomingEmail":"outgoingEmail")+"SuccessMark")}else if(r===3){t=this.getMessage((s===BX.CrmActivityDirection.incoming?"incomingEmail":"outgoingEmail")+"RenewMark")}}else if(n===BX.CrmActivityType.call){if(r===2){t=this.getMessage((s===BX.CrmActivityDirection.incoming?"incomingCall":"outgoingCall")+"SuccessMark")}else if(r===3){t=this.getMessage((s===BX.CrmActivityDirection.incoming?"incomingCall":"outgoingCall")+"RenewMark")}}else if(n===BX.CrmActivityType.meeting){if(r===2){t=this.getMessage("meetingSuccessMark")}else if(r===3){t=this.getMessage("meetingRenewMark")}}else if(n===BX.CrmActivityType.task){if(r===2){t=this.getMessage("taskSuccessMark")}else if(r===3){t=this.getMessage("taskRenewMark")}}else if(n===BX.CrmActivityType.provider){if(a==="CRM_REQUEST"){if(r===2){t=this.getMessage("requestSuccessMark")}else if(r===3){t=this.getMessage("requestRenewMark")}}else if(r===2){t=this.getMessage("webformSuccessMark")}else if(r===3){t=this.getMessage("webformRenewMark")}}}else if(i===BX.CrmEntityType.enumeration.deal){if(r===2){t=this.getMessage("dealSuccessMark")}else if(r===5){t=this.getMessage("dealFailedMark")}}else if(i===BX.CrmEntityType.enumeration.order){if(r===2){t=this.getMessage("orderSuccessMark")}else if(r===5){t=this.getMessage("orderFailedMark")}}return t};BX.CrmHistoryItemMark.prototype.prepareTitleLayout=function(){var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.order){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},text:this.getTitle()})}else{return BX.create("A",{attrs:{href:"#",className:"crm-entity-stream-content-event-title"},events:{click:this._headerClickHandler},text:this.getTitle()})}};BX.CrmHistoryItemMark.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=this.getAssociatedEntityTypeId();var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-completed"}});var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var n=this.prepareHeaderLayout();if(e===BX.CrmEntityType.enumeration.activity){var s=BX.prop.getInteger(t,"TYPE_ID",0);var a="crm-entity-stream-section-icon";if(s===BX.CrmActivityType.email){a+=" crm-entity-stream-section-icon-email"}else if(s===BX.CrmActivityType.call){a+=" crm-entity-stream-section-icon-call"}else if(s===BX.CrmActivityType.meeting){a+=" crm-entity-stream-section-icon-meeting"}else if(s===BX.CrmActivityType.task){a+=" crm-entity-stream-section-icon-task"}else if(s===BX.CrmActivityType.provider){var o=BX.prop.getString(t,"PROVIDER_ID","");if(o==="CRM_WEBFORM"){a+=" crm-entity-stream-section-icon-crmForm"}}i.appendChild(BX.create("DIV",{attrs:{className:a}}));r.appendChild(n);var c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});r.appendChild(c);c.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.cutOffText(BX.prop.getString(t,"SUBJECT",""),128)})]}));var m=this.getTextDataParam("SUMMARY");if(m!==""){c.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},text:m}))}}else if(e===BX.CrmEntityType.enumeration.order){i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-info"}}));r.appendChild(n);r.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},text:this.cutOffText(this.getTextDataParam("MESSAGE"),128)}))}else{i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-info"}}));r.appendChild(n);r.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},text:this.cutOffText(BX.prop.getString(t,"TITLE",""),128)}))}var l=this.prepareAuthorLayout();if(l){r.appendChild(l)}i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[r]}));return i};BX.CrmHistoryItemMark.prototype.view=function(){var t=this.getAssociatedEntityData();var e=this.getAssociatedEntityTypeId();if(e===BX.CrmEntityType.enumeration.activity){var i=BX.prop.getInteger(t,"ID",0);if(i>0){this._activityEditor.viewActivity(i)}}else{var r=BX.prop.getString(t,"SHOW_URL","");if(r!==""){BX.Crm.Page.open(r)}}};if(typeof BX.CrmHistoryItemMark.messages==="undefined"){BX.CrmHistoryItemMark.messages={}}BX.CrmHistoryItemMark.create=function(t,e){var i=new BX.CrmHistoryItemMark;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemCreation==="undefined"){BX.CrmHistoryItemCreation=function(){BX.CrmHistoryItemCreation.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemCreation,BX.CrmHistoryItem);BX.CrmHistoryItemCreation.prototype.doInitialize=function(){BX.CrmHistoryItemCreation.superclass.doInitialize.apply(this);if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmHistoryItemCreation. The field 'activityEditor' is not assigned."}};BX.CrmHistoryItemCreation.prototype.getTitle=function(){var t=this.getAssociatedEntityTypeId();var e=this.getAssociatedEntityData();if(t===BX.CrmEntityType.enumeration.activity){var i=BX.prop.getInteger(e,"TYPE_ID");var r=this.getMessage(i===BX.CrmActivityType.task?"task":"activity");return r.replace(/#TITLE#/gi,this.cutOffText(BX.prop.getString(e,"SUBJECT")),64)}var n=this.getMessage(BX.CrmEntityType.resolveName(this.getAssociatedEntityTypeId()).toLowerCase());if(!BX.type.isNotEmptyString(n)){n=this.getTextDataParam("TITLE")}return n};BX.CrmHistoryItemCreation.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-createEntity"};BX.CrmHistoryItemCreation.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityTypeId();var e=this.getAssociatedEntityId();var i=this.getAssociatedEntityData();if(t===BX.CrmEntityType.enumeration.activity){var r=BX.create("A",{attrs:{href:"#"},html:this.cutOffText(BX.prop.getString(i,"DESCRIPTION_RAW"),128)});BX.bind(r,"click",this._headerClickHandler);return[r]}var n=BX.prop.getString(i,"TITLE");var s=BX.prop.getString(i,"SHOW_URL","");if(n!==""){var a=[];if(s===""||t===this.getOwnerTypeId()&&e===this.getOwnerId()){a.push(BX.create("SPAN",{text:n}))}else{a.push(BX.create("A",{attrs:{href:s},text:n}))}var o=this.getTextDataParam("LEGEND");if(o!==""){a.push(BX.create("BR"));a.push(BX.create("SPAN",{text:o}))}var c=this.getObjectDataParam("BASE");var m=BX.prop.getObject(c,"ENTITY_INFO");if(m){a.push(BX.create("BR"));a.push(BX.create("SPAN",{text:BX.prop.getString(c,"CAPTION")+": "}));a.push(BX.create("A",{attrs:{href:BX.prop.getString(m,"SHOW_URL","#")},text:BX.prop.getString(m,"TITLE","")}))}return a}return[]};BX.CrmHistoryItemCreation.prototype.view=function(){var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.activity){var e=this.getAssociatedEntityData();var i=BX.prop.getInteger(e,"ID",0);if(i>0){this._activityEditor.viewActivity(i)}}};BX.CrmHistoryItemCreation.prototype.getMessage=function(t){var e=BX.CrmHistoryItemCreation.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistoryItemCreation.messages==="undefined"){BX.CrmHistoryItemCreation.messages={}}BX.CrmHistoryItemCreation.create=function(t,e){var i=new BX.CrmHistoryItemCreation;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemRestoration==="undefined"){BX.CrmHistoryItemRestoration=function(){BX.CrmHistoryItemRestoration.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemRestoration,BX.CrmHistoryItem);BX.CrmHistoryItemRestoration.prototype.getTitle=function(){return this.getTextDataParam("TITLE")};BX.CrmHistoryItemRestoration.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-restoreEntity"};BX.CrmHistoryItemRestoration.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"TITLE");return e!==""?[BX.create("SPAN",{text:e})]:[]};BX.CrmHistoryItemRestoration.prototype.getMessage=function(t){var e=BX.CrmHistoryItemRestoration.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistoryItemRestoration.messages==="undefined"){BX.CrmHistoryItemRestoration.messages={}}BX.CrmHistoryItemRestoration.create=function(t,e){var i=new BX.CrmHistoryItemRestoration;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemLink==="undefined"){BX.CrmHistoryItemLink=function(){BX.CrmHistoryItemLink.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemLink,BX.CrmHistoryItem);BX.CrmHistoryItemLink.prototype.getTitle=function(){return this.getMessage(BX.CrmEntityType.resolveName(this.getAssociatedEntityTypeId()).toLowerCase())};BX.CrmHistoryItemLink.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-createEntity"};BX.CrmHistoryItemLink.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityData();var e=[];e.push(BX.create("A",{attrs:{href:BX.prop.getString(t,"SHOW_URL","#")},text:BX.prop.getString(t,"TITLE")}));return e};BX.CrmHistoryItemLink.prototype.getMessage=function(t){var e=BX.CrmHistoryItemLink.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistoryItemLink.messages==="undefined"){BX.CrmHistoryItemLink.messages={}}BX.CrmHistoryItemLink.create=function(t,e){var i=new BX.CrmHistoryItemLink;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemEmail==="undefined"){BX.CrmHistoryItemEmail=function(){BX.CrmHistoryItemEmail.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemEmail,BX.CrmHistoryItemActivity);BX.CrmHistoryItemEmail.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());var e=this.getAssociatedEntityData();var i=BX.prop.getObject(e,"EMAIL_INFO",null);var r=i!==null?BX.prop.getString(i,"STATUS_TEXT",""):"";if(r!==""){t.appendChild(BX.create("SPAN",{props:{className:"crm-entity-stream-content-event-skipped"},text:r}))}var n=this.prepareMarkLayout();if(n){t.appendChild(n)}t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemEmail.prototype.prepareContextMenuItems=function(){if(this._isMenuShown){return}var t=[];if(!this.isReadOnly()){t.push({id:"view",text:this.getMessage("menuView"),onclick:BX.delegate(this.view,this)});t.push({id:"remove",text:this.getMessage("menuDelete"),onclick:BX.delegate(this.processRemoval,this)});if(this.isFixed()||this._fixedHistory.findItemById(this._id))t.push({id:"unfasten",text:this.getMessage("menuUnfasten"),onclick:BX.delegate(this.unfasten,this)});else t.push({id:"fasten",text:this.getMessage("menuFasten"),onclick:BX.delegate(this.fasten,this)})}return t};BX.CrmHistoryItemEmail.prototype.reply=function(){};BX.CrmHistoryItemEmail.prototype.replyAll=function(){};BX.CrmHistoryItemEmail.prototype.forward=function(){};BX.CrmHistoryItemEmail.prototype.getRemoveMessage=function(){var t=BX.util.htmlspecialchars(this.getTitle());return this.getMessage("emailRemove").replace("#TITLE#",t)};BX.CrmHistoryItemEmail.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.prop.getObject(t,"COMMUNICATION",{});var r=BX.prop.getString(i,"TITLE","");var n=BX.prop.getString(i,"SHOW_URL","");var s=BX.prop.getString(i,"VALUE","");var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-email"}});a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-email"}}));if(this.isFixed())BX.addClass(a,"crm-entity-stream-section-top-fixed");var o=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[o]}));var c=this.prepareHeaderLayout();o.appendChild(c);if(this.isContextMenuEnabled()){o.appendChild(this.prepareContextMenuButton())}var m=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-email"}});o.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:[m]}));m.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-email-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-email-to"}});m.appendChild(l);if(r!==""){if(n!==""){l.appendChild(BX.create("A",{attrs:{href:n},text:r}))}else{l.appendChild(BX.create("SPAN",{text:r}))}}if(s!==""){if(r!==""){l.appendChild(BX.create("SPAN",{text:" "}))}l.appendChild(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-email-address"},text:s}))}m.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-email-fragment"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));var h=this.prepareAuthorLayout();if(h){o.appendChild(h)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});o.appendChild(this._actionContainer);if(!this.isReadOnly())o.appendChild(this.prepareFixedSwitcherLayout());return a};BX.CrmHistoryItemEmail.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmHistoryEmailAction.create("email",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor}))};BX.CrmHistoryItemEmail.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemEmail.create=function(t,e){var i=new BX.CrmHistoryItemEmail;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemCall==="undefined"){BX.CrmHistoryItemCall=function(){BX.CrmHistoryItemCall.superclass.constructor.apply(this);this._playerDummyClickHandler=BX.delegate(this.onPlayerDummyClick,this);this._playerWrapper=null;this._transcriptWrapper=null;this._mediaFileInfo=null};BX.extend(BX.CrmHistoryItemCall,BX.CrmHistoryItemActivity);BX.CrmHistoryItemCall.prototype.getTypeDescription=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getObject(t,"CALL_INFO",null);var i=e!==null?BX.prop.getString(e,"CALL_TYPE_TEXT",""):"";if(i!==""){return i}var r=BX.prop.getInteger(t,"DIRECTION",0);return this.getMessage(r===BX.CrmActivityDirection.incoming?"incomingCall":"outgoingCall")};BX.CrmHistoryItemCall.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());var e=this.getAssociatedEntityData();var i=BX.prop.getObject(e,"CALL_INFO",null);var r=i!==null;var n=r?BX.prop.getBoolean(i,"SUCCESSFUL",false):false;var s=r?BX.prop.getString(i,"STATUS_TEXT",""):"";if(r){t.appendChild(BX.create("DIV",{attrs:{className:n?"crm-entity-stream-content-event-successful":"crm-entity-stream-content-event-missing"},text:s}))}t.appendChild(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())}));return t};BX.CrmHistoryItemCall.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.prop.getObject(t,"COMMUNICATION",{});var r=BX.prop.getString(i,"TITLE","");var n=BX.prop.getString(i,"SHOW_URL","");var s=BX.prop.getString(i,"VALUE","");var a=BX.prop.getString(i,"FORMATTED_VALUE",s);var o=BX.prop.getObject(t,"CALL_INFO",null);var c=o!==null;var m=c?BX.prop.getString(o,"DURATION_TEXT",""):"";var l=c?BX.prop.getBoolean(o,"HAS_TRANSCRIPT",""):"";var h=c?BX.prop.getBoolean(o,"TRANSCRIPT_PENDING",""):"";var p=c?BX.prop.getString(o,"CALL_ID",""):"";var d=c?BX.prop.getString(o,"COMMENT",""):"";var u=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-call"}});u.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-call"}}));if(this.isFixed())BX.addClass(u,"crm-entity-stream-section-top-fixed");var y=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});u.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[y]}));var f=this.prepareHeaderLayout();y.appendChild(f);if(this.isContextMenuEnabled()){y.appendChild(this.prepareContextMenuButton())}var g=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});y.appendChild(g);g.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));g.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));if(c){var B=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-call"}});g.appendChild(B);this._mediaFileInfo=BX.prop.getObject(t,"MEDIA_FILE_INFO",null);if(this._mediaFileInfo!==null){this._playerWrapper=BX.create("DIV",{attrs:{className:"crm-audio-cap-wrap-container"}});this._playerWrapper.appendChild(BX.create("DIV",{attrs:{className:"crm-audio-cap-wrap"},children:[BX.create("DIV",{attrs:{className:"crm-audio-cap-time"},text:m})],events:{click:this._playerDummyClickHandler}}));B.appendChild(this._playerWrapper)}if(l){this._transcriptWrapper=BX.create("DIV",{attrs:{className:"crm-audio-transcript-wrap-container"},events:{click:function(t){if(BX.Voximplant&&BX.Voximplant.Transcript){BX.Voximplant.Transcript.create({callId:p}).show()}}},children:[BX.create("DIV",{attrs:{className:"crm-audio-transcript-icon"}}),BX.create("DIV",{attrs:{className:"crm-audio-transcript-conversation"},text:BX.message("CRM_TIMELINE_CALL_TRANSCRIPT")})]});B.appendChild(this._transcriptWrapper)}else if(h){this._transcriptWrapper=BX.create("DIV",{attrs:{className:"crm-audio-transcript-wrap-container-pending"},children:[BX.create("DIV",{attrs:{className:"crm-audio-transcript-icon-pending"},html:'<svg class="crm-transcript-loader-circular" viewBox="25 25 50 50"><circle class="crm-transcript-loader-path" cx="50" cy="50" r="20" fill="none" stroke-miterlimit="10"></circle></svg>'}),BX.create("DIV",{attrs:{className:"crm-audio-transcript-conversation"},text:BX.message("CRM_TIMELINE_CALL_TRANSCRIPT_PENDING")})]});B.appendChild(this._transcriptWrapper)}if(d){g.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},text:d}))}}var C=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});g.appendChild(C);if(r!==""){if(n!==""){C.appendChild(BX.create("A",{attrs:{href:n},text:r}))}else{C.appendChild(BX.create("SPAN",{text:r}))}}if(a!==""){if(r!==""){C.appendChild(BX.create("SPAN",{text:" "}))}C.appendChild(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-email-address"},text:a}))}var _=this.prepareAuthorLayout();if(_){y.appendChild(_)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});y.appendChild(this._actionContainer);if(!this.isReadOnly())y.appendChild(this.prepareFixedSwitcherLayout());return u};BX.CrmHistoryItemCall.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmHistoryCallAction.create("call",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor,ownerInfo:this._history.getOwnerInfo()}))};BX.CrmHistoryItemCall.prototype.getRemoveMessage=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getInteger(t,"DIRECTION",0);var i=e===BX.CrmActivityDirection.incoming?"incomingCallRemove":"outgoingCallRemove";var r=BX.util.htmlspecialchars(this.getTitle());return this.getMessage(i).replace("#TITLE#",r)};BX.CrmHistoryItemCall.prototype.onPlayerDummyClick=function(t){var e=this._playerWrapper.querySelector(".crm-audio-cap-wrap");if(e){BX.addClass(e,"crm-audio-cap-wrap-loader")}this._history.getManager().loadMediaPlayer("history_"+this.getId(),this._mediaFileInfo["URL"],this._mediaFileInfo["TYPE"],this._playerWrapper,this._mediaFileInfo["DURATION"])};BX.CrmHistoryItemCall.create=function(t,e){var i=new BX.CrmHistoryItemCall;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemMeeting==="undefined"){BX.CrmHistoryItemMeeting=function(){BX.CrmHistoryItemMeeting.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemMeeting,BX.CrmHistoryItemActivity);BX.CrmHistoryItemMeeting.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());var e=this.prepareMarkLayout();if(e){t.appendChild(e)}t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemMeeting.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.prop.getObject(t,"COMMUNICATION",{});var r=BX.prop.getString(i,"TITLE","");var n=BX.prop.getString(i,"SHOW_URL","");var s=BX.prop.getString(i,"VALUE","");var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-meeting"}});a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-meeting"}}));if(this.isContextMenuEnabled()){a.appendChild(this.prepareContextMenuButton())}if(this.isFixed())BX.addClass(a,"crm-entity-stream-section-top-fixed");var o=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[o]}));var c=this.prepareHeaderLayout();o.appendChild(c);var m=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});o.appendChild(m);m.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));m.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});m.appendChild(l);if(r!==""){l.appendChild(BX.create("SPAN",{text:this.getMessage("reciprocal")+": "}));if(n!==""){l.appendChild(BX.create("A",{attrs:{href:n},text:r}))}else{l.appendChild(BX.create("SPAN",{text:r}))}}l.appendChild(BX.create("SPAN",{text:" "+s}));var h=this.prepareAuthorLayout();if(h){o.appendChild(h)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});o.appendChild(this._actionContainer);if(!this.isReadOnly())o.appendChild(this.prepareFixedSwitcherLayout());return a};BX.CrmHistoryItemMeeting.prototype.getRemoveMessage=function(){var t=BX.util.htmlspecialchars(this.getTitle());return this.getMessage("meetingRemove").replace("#TITLE#",t)};BX.CrmHistoryItemMeeting.prototype.prepareActions=function(){};BX.CrmHistoryItemMeeting.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemMeeting.create=function(t,e){var i=new BX.CrmHistoryItemMeeting;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemTask==="undefined"){BX.CrmHistoryItemTask=function(){BX.CrmHistoryItemTask.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemTask,BX.CrmHistoryItemActivity);BX.CrmHistoryItemTask.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());var e=this.prepareMarkLayout();if(e){t.appendChild(e)}t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemTask.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.prop.getObject(t,"COMMUNICATION",{});var r=BX.prop.getString(i,"TITLE","");var n=BX.prop.getString(i,"SHOW_URL","");var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-task"}});s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-task"}}));if(this.isContextMenuEnabled()){s.appendChild(this.prepareContextMenuButton())}if(this.isFixed())BX.addClass(s,"crm-entity-stream-section-top-fixed");var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[a]}));var o=this.prepareHeaderLayout();a.appendChild(o);var c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});a.appendChild(c);c.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));c.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));var m=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});c.appendChild(m);if(r!==""){m.appendChild(BX.create("SPAN",{text:this.getMessage("reciprocal")+": "}));if(n!==""){m.appendChild(BX.create("A",{attrs:{href:n},text:r}))}else{m.appendChild(BX.create("SPAN",{text:r}))}}var l=this.prepareAuthorLayout();if(l){a.appendChild(l)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});a.appendChild(this._actionContainer);if(!this.isReadOnly())a.appendChild(this.prepareFixedSwitcherLayout());return s};BX.CrmHistoryItemTask.prototype.prepareActions=function(){};BX.CrmHistoryItemTask.prototype.getRemoveMessage=function(){var t=BX.util.htmlspecialchars(this.getTitle());return this.getMessage("taskRemove").replace("#TITLE#",t)};BX.CrmHistoryItemTask.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemTask.create=function(t,e){var i=new BX.CrmHistoryItemTask;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemWebForm==="undefined"){BX.CrmHistoryItemWebForm=function(){BX.CrmHistoryItemWebForm.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemWebForm,BX.CrmHistoryItemActivity);BX.CrmHistoryItemWebForm.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemWebForm.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-crmForm"}});e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-crmForm"}}));var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[i]}));if(this.isFixed())BX.addClass(e,"crm-entity-stream-section-top-fixed");var r=this.prepareHeaderLayout();i.appendChild(r);var n=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});i.appendChild(n);n.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));var s=this.prepareAuthorLayout();if(s){i.appendChild(s)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});i.appendChild(this._actionContainer);if(!this.isReadOnly())i.appendChild(this.prepareFixedSwitcherLayout());return e};BX.CrmHistoryItemWebForm.prototype.prepareActions=function(){};BX.CrmHistoryItemWebForm.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemWebForm.create=function(t,e){var i=new BX.CrmHistoryItemWebForm;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemWait==="undefined"){BX.CrmHistoryItemWait=function(){BX.CrmHistoryItemWait.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemWait,BX.CrmHistoryItem);BX.CrmHistoryItemWait.prototype.getTitle=function(){return this.getMessage("wait")};BX.CrmHistoryItemWait.prototype.prepareTitleLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]})};BX.CrmHistoryItemWait.prototype.prepareTimeLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})};BX.CrmHistoryItemWait.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemWait.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=BX.util.trim(e);e=BX.util.strip_tags(e);e=BX.util.nl2br(e)}var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-wait"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-complete"}}));var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[r]}));var n=this.prepareHeaderLayout();r.appendChild(n);var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},html:e});r.appendChild(s);var a=this.prepareAuthorLayout();if(a){r.appendChild(a)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});r.appendChild(this._actionContainer);return i};BX.CrmHistoryItemWait.prototype.prepareActions=function(){};BX.CrmHistoryItemWait.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemWait.create=function(t,e){var i=new BX.CrmHistoryItemWait;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemDocument==="undefined"){BX.CrmHistoryItemDocument=function(){BX.CrmHistoryItemDocument.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemDocument,BX.CrmHistoryItem);BX.CrmHistoryItemDocument.prototype.getTitle=function(){return this.getMessage("document")};BX.CrmHistoryItemDocument.prototype.prepareTitleLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:BX.delegate(this.editDocument,this)},text:this.getTitle()})]})};BX.CrmHistoryItemDocument.prototype.prepareTimeLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})};BX.CrmHistoryItemDocument.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemDocument.prototype.prepareContent=function(){var t=this.getTextDataParam("COMMENT","");var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-document"}});if(this.isFixed()){BX.addClass(e,"crm-entity-stream-section-top-fixed")}e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-document"}}));if(this.isContextMenuEnabled()){e.appendChild(this.prepareContextMenuButton())}if(!this.isReadOnly()){e.appendChild(this.prepareFixedSwitcherLayout())}var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[i]}));var r=this.prepareHeaderLayout();i.appendChild(r);var n=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},html:t});var s=BX.findChildByClassName(n,"document-title-link");if(s){BX.bind(s,"click",BX.proxy(this.editDocument,this))}i.appendChild(n);var a=this.prepareAuthorLayout();if(a){i.appendChild(a)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});i.appendChild(this._actionContainer);return e};BX.CrmHistoryItemDocument.prototype.prepareActions=function(){};BX.CrmHistoryItemDocument.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemDocument.prototype.prepareContextMenuItems=function(){if(this._isMenuShown){return}var t=[];if(!this.isReadOnly()){t.push({id:"edit",text:this.getMessage("menuEdit"),onclick:BX.delegate(this.editDocument,this)});t.push({id:"remove",text:this.getMessage("menuDelete"),onclick:BX.delegate(this.confirmDelete,this)});if(this.isFixed()||this._fixedHistory.findItemById(this._id)){t.push({id:"unfasten",text:this.getMessage("menuUnfasten"),onclick:BX.delegate(this.unfasten,this)})}else{t.push({id:"fasten",text:this.getMessage("menuFasten"),onclick:BX.delegate(this.fasten,this)})}}return t};BX.CrmHistoryItemDocument.prototype.confirmDelete=function(){this.closeContextMenu();this._detetionConfirmDlgId="entity_timeline_deletion_"+this.getId()+"_confirm";var t=BX.Crm.ConfirmationDialog.get(this._detetionConfirmDlgId);if(!t){t=BX.Crm.ConfirmationDialog.create(this._detetionConfirmDlgId,{title:this.getMessage("removeConfirmTitle"),content:this.getMessage("documentRemove")})}t.open().then(BX.delegate(this.onConfirmDelete,this),BX.DoNothing)};BX.CrmHistoryItemDocument.prototype.onConfirmDelete=function(t){if(BX.prop.getBoolean(t,"cancel",true)){return}this.deleteDocument()};BX.CrmHistoryItemDocument.prototype.deleteDocument=function(){if(this._isRequestRunning){return}this._isRequestRunning=true;BX.ajax({url:this._history._serviceUrl,method:"POST",dataType:"json",data:{ACTION:"DELETE_DOCUMENT",OWNER_TYPE_ID:this.getOwnerTypeId(),OWNER_ID:this.getOwnerId(),ID:this.getId()},onsuccess:BX.delegate(function(t){this._isRequestRunning=false;if(BX.type.isNotEmptyString(t.ERROR)){alert(t.ERROR)}else{var e=this._history.findItemById(this._id);if(e instanceof BX.CrmHistoryItemDocument){e.clearAnimate()}var i=this._fixedHistory.findItemById(this._id);if(i instanceof BX.CrmHistoryItemDocument){i.clearAnimate()}}},this),onfailure:BX.delegate(function(){this._isRequestRunning=false},this)})};BX.CrmHistoryItemDocument.prototype.editDocument=function(){var t=this.getData().DOCUMENT_ID||0;if(t>0){var e="/bitrix/components/bitrix/crm.document.view/slider.php";e=BX.util.add_url_param(e,{documentId:t});if(BX.SidePanel){BX.SidePanel.Instance.open(e,{width:980})}else{top.location.href=e}}};BX.CrmHistoryItemDocument.prototype.updateWrapper=function(){var t=this.getWrapper();if(t){var e=BX.findChildByClassName(t,"crm-entity-stream-content-detail");if(e){BX.adjust(e,{html:this.getTextDataParam("COMMENT","")});var i=BX.findChildByClassName(e,"document-title-link");if(i){BX.bind(i,"click",BX.proxy(this.editDocument,this))}}}};BX.CrmHistoryItemDocument.create=function(t,e){var i=new BX.CrmHistoryItemDocument;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemSender==="undefined"){BX.CrmHistoryItemSender=function(){BX.CrmHistoryItemSender.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemSender,BX.CrmHistoryItem);BX.CrmHistoryItemSender.prototype.getDataSetting=function(t){var e=this.getObjectDataParam("SETTINGS")||{};return e[t]||null};BX.CrmHistoryItemSender.prototype.getMessage=function(t){var e=BX.CrmHistoryItemSender.messages;return e.hasOwnProperty(t)?e[t]:t};BX.CrmHistoryItemSender.prototype.getTitle=function(){return this.getDataSetting("messageName")};BX.CrmHistoryItemSender.prototype.prepareTitleLayout=function(){var t=this;return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},children:[this.isRemoved()?BX.create("SPAN",{text:this.getTitle()}):BX.create("A",{attrs:{href:""},events:{click:function(e){if(BX.SidePanel){BX.SidePanel.Instance.open(t.getDataSetting("path"))}else{top.location.href=t.getDataSetting("path")}e.preventDefault();e.stopPropagation()}},text:this.getTitle()})]})};BX.CrmHistoryItemSender.prototype.prepareTimeLayout=function(){return BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})};BX.CrmHistoryItemSender.prototype.prepareStatusLayout=function(){var t,e;if(this.getDataSetting("isUnsub")){e=this.getMessage("unsub");t="crm-entity-stream-content-event-missing"}else if(this.getDataSetting("isClick")){e=this.getMessage("click");t="crm-entity-stream-content-event-successful"}else{e=this.getMessage("read");t="crm-entity-stream-content-event-skipped"}return BX.create("SPAN",{attrs:{className:t},text:e})};BX.CrmHistoryItemSender.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());if(this.getDataSetting("isRead")||this.getDataSetting("isUnsub")){t.appendChild(this.prepareStatusLayout())}t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemSender.prototype.isRemoved=function(){return!this.getDataSetting("letterTitle")};BX.CrmHistoryItemSender.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=this.isRemoved()?this.getMessage("removed"):this.getMessage("title")+": "+this.getDataSetting("letterTitle");var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-wait"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-complete"}}));var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[r]}));var n=this.prepareHeaderLayout();r.appendChild(n);var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},html:e});r.appendChild(s);var a=this.prepareAuthorLayout();if(a){r.appendChild(a)}return i};BX.CrmHistoryItemSender.create=function(t,e){var i=new BX.CrmHistoryItemSender;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemBizproc==="undefined"){BX.CrmHistoryItemBizproc=function(){BX.CrmHistoryItemBizproc.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemBizproc,BX.CrmHistoryItem);BX.CrmHistoryItemBizproc.prototype.getTitle=function(){return this.getMessage("bizproc")};BX.CrmHistoryItemBizproc.prototype.prepareContent=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-bp"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-bp"}}));var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var i=this.prepareHeaderLayout();e.appendChild(i);e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},html:this.prepareContentTextHtml()})]}));var r=this.prepareAuthorLayout();if(r){e.appendChild(r)}t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[e]}));return t};BX.CrmHistoryItemBizproc.prototype.prepareContentTextHtml=function(){var t=this.getTextDataParam("TYPE");if(t==="ACTIVITY_ERROR"){return"<strong>#TITLE#</strong>: #ERROR_TEXT#".replace("#TITLE#",BX.util.htmlspecialchars(this.getTextDataParam("ACTIVITY_TITLE"))).replace("#ERROR_TEXT#",BX.util.htmlspecialchars(this.getTextDataParam("ERROR_TEXT")))}var e=this.getTextDataParam("WORKFLOW_TEMPLATE_NAME");var i=this.getTextDataParam("WORKFLOW_STATUS_NAME");if(!e||i!=="Created"&&i!=="Completed"&&i!=="Terminated"){return BX.util.htmlspecialchars(this.getTextDataParam("COMMENT"))}var r=BX.message("CRM_TIMELINE_BIZPROC_CREATED");if(i==="Completed"){r=BX.message("CRM_TIMELINE_BIZPROC_COMPLETED")}else if(i==="Terminated"){r=BX.message("CRM_TIMELINE_BIZPROC_TERMINATED")}return BX.util.htmlspecialchars(r).replace("#NAME#","<strong>"+BX.util.htmlspecialchars(e)+"</strong>")};BX.CrmHistoryItemBizproc.create=function(t,e){var i=new BX.CrmHistoryItemBizproc;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemSms==="undefined"){BX.CrmHistoryItemSms=function(){BX.CrmHistoryItemSms.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemSms,BX.CrmHistoryItemActivity);BX.CrmHistoryItemSms.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareMessageStatusLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemSms.prototype.prepareMessageStatusLayout=function(){return this._messageStatusNode=BX.create("SPAN")};BX.CrmHistoryItemSms.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getObject(t,"COMMUNICATION",{});var i=BX.prop.getString(e,"TITLE","");var r=BX.prop.getString(e,"SHOW_URL","");var n=BX.prop.getString(e,"VALUE","");var s=BX.prop.getObject(t,"SMS_INFO",{});var a="crm-entity-stream-section-sms";var o=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history"+" "+a}});o.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-sms"}}));if(this.isFixed())BX.addClass(o,"crm-entity-stream-section-top-fixed");var c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});o.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[c]}));var m=this.prepareHeaderLayout();c.appendChild(m);var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});c.appendChild(l);var h=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-sms"}});if(s.senderId){var p=s.senderId;var d=s.senderShortName;if(p==="rest"&&s.fromName){d=s.fromName}var u=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-sms-status"},children:[BX.message("CRM_TIMELINE_SMS_SENDER")+" ",BX.create("STRONG",{text:d})]});if(p!=="rest"&&s.fromName){u.innerHTML+=" "+BX.message("CRM_TIMELINE_SMS_FROM")+" ";u.appendChild(BX.create("STRONG",{text:s.fromName}))}h.appendChild(u)}if(s.statusId!==""){this.setMessageStatus(s.statusId,s.errorText)}var y=BX.util.htmlspecialchars(t["DESCRIPTION_RAW"]).replace(/\r\n|\r|\n/g,"<br/>");var f=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-sms-fragment"}});f.appendChild(BX.create("SPAN",{html:y}));h.appendChild(f);l.appendChild(h);var g=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"},text:BX.message("CRM_TIMELINE_SMS_TO")+" "});l.appendChild(g);if(i!==""){if(r!==""){g.appendChild(BX.create("A",{attrs:{href:r},text:i}))}else{g.appendChild(BX.create("SPAN",{text:i}))}}g.appendChild(BX.create("SPAN",{text:" "+n}));var B=this.prepareAuthorLayout();if(B){c.appendChild(B)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});c.appendChild(this._actionContainer);if(!this.isReadOnly())c.appendChild(this.prepareFixedSwitcherLayout());return o};BX.CrmHistoryItemSms.prototype.prepareActions=function(){};BX.CrmHistoryItemSms.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemSms.prototype.setMessageStatus=function(t,e){t=parseInt(t);if(isNaN(t)||!this._messageStatusNode)return;var i=this.getSetting("smsStatusDescriptions",{});if(i.hasOwnProperty(t)){this._messageStatusNode.textContent=i[t];this.setMessageStatusErrorText(e);var r=this.getMessageStatusSemantic(t);this.setMessageStatusSemantic(r)}};BX.CrmHistoryItemSms.prototype.setMessageStatusSemantic=function(t){var e={process:"crm-entity-stream-content-event-process",success:"crm-entity-stream-content-event-successful",failure:"crm-entity-stream-content-event-missing"};for(var i in e){var r=i===t?"addClass":"removeClass";BX[r](this._messageStatusNode,e[i])}};BX.CrmHistoryItemSms.prototype.setMessageStatusErrorText=function(t){if(!t){this._messageStatusNode.removeAttribute("title");BX.removeClass(this._messageStatusNode,"crm-entity-stream-content-event-error-tip")}else{this._messageStatusNode.setAttribute("title",t);BX.addClass(this._messageStatusNode,"crm-entity-stream-content-event-error-tip")}};BX.CrmHistoryItemSms.prototype.getMessageStatusSemantic=function(t){var e=this.getSetting("smsStatusSemantics",{});return e.hasOwnProperty(t)?e[t]:"failure"};BX.CrmHistoryItemSms.prototype.subscribe=function(){if(!BX.CrmSmsWatcher)return;var t=this.getAssociatedEntityData();var e=BX.prop.getObject(t,"SMS_INFO",{});if(e.id){BX.CrmSmsWatcher.subscribeOnMessageUpdate(e.id,this.onMessageUpdate.bind(this))}};BX.CrmHistoryItemSms.prototype.onMessageUpdate=function(t){if(t.STATUS_ID){this.setMessageStatus(t.STATUS_ID,t.EXEC_ERROR)}};BX.CrmHistoryItemSms.create=function(t,e){var i=new BX.CrmHistoryItemSms;i.initialize(t,e);i.subscribe();return i}}if(typeof BX.CrmHistoryItemActivityRequest==="undefined"){BX.CrmHistoryItemActivityRequest=function(){BX.CrmHistoryItemActivityRequest.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemActivityRequest,BX.CrmHistoryItemActivity);BX.CrmHistoryItemActivityRequest.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemActivityRequest.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-today crm-entity-stream-section-robot"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-robot"}}));if(this.isContextMenuEnabled()){i.appendChild(this.prepareContextMenuButton())}if(this.isFixed())BX.addClass(i,"crm-entity-stream-section-top-fixed");var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[r]}));var n=this.prepareHeaderLayout();r.appendChild(n);var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});r.appendChild(s);s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));var a=this.prepareAuthorLayout();if(a){r.appendChild(a)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});r.appendChild(this._actionContainer);if(!this.isReadOnly())r.appendChild(this.prepareFixedSwitcherLayout());return i};BX.CrmHistoryItemActivityRequest.prototype.prepareActions=function(){};BX.CrmHistoryItemActivityRequest.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemActivityRequest.prototype.isEditable=function(){return false};BX.CrmHistoryItemActivityRequest.create=function(t,e){var i=new BX.CrmHistoryItemActivityRequest;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemActivityRestApplication==="undefined"){BX.CrmHistoryItemActivityRestApplication=function(){BX.CrmHistoryItemActivityRestApplication.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemActivityRestApplication,BX.CrmHistoryItemActivity);BX.CrmHistoryItemActivityRestApplication.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemActivityRestApplication.prototype.getTypeDescription=function(){var t=this.getAssociatedEntityData();if(t["APP_TYPE"]&&t["APP_TYPE"]["NAME"]){return t["APP_TYPE"]["NAME"]}return BX.CrmHistoryItemActivityRestApplication.superclass.getTypeDescription.apply(this)};BX.CrmHistoryItemActivityRestApplication.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-today crm-entity-stream-section-rest"}});var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-rest"}});i.appendChild(r);if(t["APP_TYPE"]&&t["APP_TYPE"]["ICON_SRC"]){if(r){r.style.backgroundImage="url("+t["APP_TYPE"]["ICON_SRC"]+")";r.style.backgroundPosition="center center"}}if(this.isFixed())BX.addClass(i,"crm-entity-stream-section-top-fixed");var n=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[n]}));var s=this.prepareHeaderLayout();n.appendChild(s);var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});n.appendChild(a);a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));a.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},children:this.prepareCutOffElements(e,128,this._headerClickHandler)}));var o=this.prepareAuthorLayout();if(o){n.appendChild(o)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});n.appendChild(this._actionContainer);if(!this.isReadOnly())n.appendChild(this.prepareFixedSwitcherLayout());return i};BX.CrmHistoryItemActivityRestApplication.prototype.prepareActions=function(){};BX.CrmHistoryItemActivityRestApplication.prototype.showActions=function(t){if(this._actionContainer){this._actionContainer.style.display=t?"":"none"}};BX.CrmHistoryItemActivityRestApplication.create=function(t,e){var i=new BX.CrmHistoryItemActivityRestApplication;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemOpenLine==="undefined"){BX.CrmHistoryItemOpenLine=function(){BX.CrmHistoryItemOpenLine.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemOpenLine,BX.CrmHistoryItemActivity);BX.CrmHistoryItemOpenLine.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());t.appendChild(this.prepareTimeLayout());return t};BX.CrmHistoryItemOpenLine.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"DESCRIPTION_RAW","");if(e!==""){e=e.replace(/^\s+/,"")}var i=BX.prop.getObject(t,"COMMUNICATION",{});var r=BX.prop.getString(i,"TITLE","");var n=BX.prop.getString(i,"SHOW_URL","");var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-IM"}});s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-IM"}}));if(this.isContextMenuEnabled()){s.appendChild(this.prepareContextMenuButton())}if(this.isFixed())BX.addClass(s,"crm-entity-stream-section-top-fixed");var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});s.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[a]}));var o=this.prepareHeaderLayout();a.appendChild(o);var c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});a.appendChild(c);c.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}));var m=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-IM"}});c.appendChild(m);var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-IM-messages"}});m.appendChild(l);var h=BX.prop.getObject(this.getAssociatedEntityData(),"OPENLINE_INFO",null);if(h){var p=BX.prop.getArray(h,"MESSAGES",[]);for(var d=0,u=p.length;d<u;d++){var y=p[d];var f=BX.prop.getBoolean(y,"IS_EXTERNAL",true);l.appendChild(BX.create("DIV",{attrs:{className:f?"crm-entity-stream-content-detail-IM-message-incoming":"crm-entity-stream-content-detail-IM-message-outgoing"},text:BX.prop.getString(y,"MESSAGE","")}))}}var g=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});c.appendChild(g);if(r!==""){g.appendChild(BX.create("SPAN",{text:this.getMessage("reciprocal")+": "}));if(n!==""){g.appendChild(BX.create("A",{attrs:{href:n},text:r}))}else{g.appendChild(BX.create("SPAN",{text:r}))}}var B=this.prepareAuthorLayout();if(B){a.appendChild(B)}this._actionContainer=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-action"}});a.appendChild(this._actionContainer);if(!this.isReadOnly())a.appendChild(this.prepareFixedSwitcherLayout());return s};BX.CrmHistoryItemOpenLine.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmHistoryOpenLineAction.create("openline",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor,ownerInfo:this._history.getOwnerInfo()}))};BX.CrmHistoryItemOpenLine.prototype.view=function(){if(typeof window.top["BXIM"]==="undefined"){window.alert(this.getMessage("openLineNotSupported"));return}var t="";var e=BX.prop.getObject(this.getAssociatedEntityData(),"COMMUNICATION",null);if(e){if(BX.prop.getString(e,"TYPE")==="IM"){t=BX.prop.getString(e,"VALUE")}}if(t!==""){window.top["BXIM"].openMessengerSlider(t,{RECENT:"N",MENU:"N"})}};BX.CrmHistoryItemOpenLine.create=function(t,e){var i=new BX.CrmHistoryItemOpenLine;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemConversion==="undefined"){BX.CrmHistoryItemConversion=function(){BX.CrmHistoryItemConversion.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemConversion,BX.CrmHistoryItem);BX.CrmHistoryItemConversion.prototype.getMessage=function(t){var e=BX.CrmHistoryItemConversion.messages;return e.hasOwnProperty(t)?e[t]:t};BX.CrmHistoryItemConversion.prototype.getTitle=function(){return this.getTextDataParam("TITLE")};BX.CrmHistoryItemConversion.prototype.prepareContent=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-convert crm-entity-stream-section-history"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-convert"}}));var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var i=this.prepareHeaderLayout();e.appendChild(i);var r=[];var n=this.getArrayDataParam("ENTITIES");for(var s=0,a=n.length;s<a;s++){var o=n[s];var c;if(BX.prop.getString(o,"SHOW_URL","")===""){c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-convert"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detain-convert-status"},children:[BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-status-text"},text:BX.CrmEntityType.getNotFoundMessage(o["ENTITY_TYPE_ID"])})]})]})}else{c=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-convert"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detain-convert-status"},children:[BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-status-text"},text:BX.CrmEntityType.getCaption(o["ENTITY_TYPE_ID"])})]}),BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-detail-convert-separator-icon"}}),BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detain-convert-status"},children:[BX.create("A",{attrs:{className:"crm-entity-stream-content-detail-target",href:o["SHOW_URL"]},text:o["TITLE"]})]})]})}r.push(c)}e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:r}));var m=this.prepareAuthorLayout();if(m){e.appendChild(m)}t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[e]}));return t};if(typeof BX.CrmHistoryItemConversion.messages==="undefined"){BX.CrmHistoryItemConversion.messages={}}BX.CrmHistoryItemConversion.create=function(t,e){var i=new BX.CrmHistoryItemConversion;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemVisit==="undefined"){BX.CrmHistoryItemVisit=function(){BX.CrmHistoryItemVisit.superclass.constructor.apply(this);this._playerDummyClickHandler=BX.delegate(this.onPlayerDummyClick,this);this._playerWrapper=null;this._transcriptWrapper=null;this._mediaFileInfo=null};BX.extend(BX.CrmHistoryItemVisit,BX.CrmHistoryItemActivity);BX.CrmHistoryItemVisit.prototype.prepareHeaderLayout=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"}});t.appendChild(this.prepareTitleLayout());var e=this.getAssociatedEntityData();var i=BX.prop.getObject(e,"VISIT_INFO",{});var r=BX.prop.getInteger(i,"RECORD_LENGTH",0);var n=BX.prop.getString(i,"RECORD_LENGTH_FORMATTED_FULL","");t.appendChild(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:(r>0?n+", "+BX.message("CRM_TIMELINE_VISIT_AT")+" ":"")+this.formatTime(this.getCreatedTime())}));return t};BX.CrmHistoryItemVisit.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getObject(t,"COMMUNICATION",{});var i=BX.prop.getString(e,"TITLE","");var r=BX.prop.getString(e,"SHOW_URL","");var n=BX.prop.getString(e,"VALUE","");var s=BX.prop.getString(e,"FORMATTED_VALUE",n);var a=BX.prop.getObject(t,"VISIT_INFO",{});var o=BX.prop.getInteger(a,"RECORD_LENGTH",0);var c=BX.prop.getString(a,"RECORD_LENGTH_FORMATTED_SHORT","");var m=BX.prop.getString(a,"VK_PROFILE","");var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-visit"}});l.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-visit"}}));var h=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});l.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[h]}));var p=this.prepareHeaderLayout();h.appendChild(p);if(this.isContextMenuEnabled()){h.appendChild(this.prepareContextMenuButton())}var d=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});h.appendChild(d);this._mediaFileInfo=BX.prop.getObject(t,"MEDIA_FILE_INFO",null);if(this._mediaFileInfo!==null&&o>0){this._playerWrapper=BX.create("DIV",{attrs:{className:"crm-audio-cap-wrap-container"}});this._playerWrapper.appendChild(BX.create("DIV",{attrs:{className:"crm-audio-cap-wrap"},children:[BX.create("DIV",{attrs:{className:"crm-audio-cap-time"},text:c})],events:{click:this._playerDummyClickHandler}}));d.appendChild(this._playerWrapper)}var u=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});d.appendChild(u);if(i!==""){u.appendChild(document.createTextNode(BX.message("CRM_TIMELINE_VISIT_WITH")+" "));if(r!==""){u.appendChild(BX.create("A",{attrs:{href:r},text:i}))}else{u.appendChild(BX.create("SPAN",{text:i}))}}if(BX.type.isNotEmptyString(m)){u.appendChild(document.createTextNode(" "));u.appendChild(BX.create("a",{attrs:{className:"crm-entity-stream-content-detail-additional",target:"_blank",href:this.getVkProfileUrl(m)},text:BX.message("CRM_TIMELINE_VISIT_VKONTAKTE_PROFILE")}))}var y=this.prepareAuthorLayout();if(y){h.appendChild(y)}return l};BX.CrmHistoryItemVisit.prototype.onPlayerDummyClick=function(t){var e=this._playerWrapper.querySelector(".crm-audio-cap-wrap");if(e){BX.addClass(e,"crm-audio-cap-wrap-loader")}this._history.getManager().loadMediaPlayer("history_"+this.getId(),this._mediaFileInfo["URL"],this._mediaFileInfo["TYPE"],this._playerWrapper,this._mediaFileInfo["DURATION"])};BX.CrmHistoryItemVisit.prototype.getVkProfileUrl=function(t){return"https://vk.com/"+BX.util.htmlspecialchars(t)};BX.CrmHistoryItemVisit.create=function(t,e){var i=new BX.CrmHistoryItemVisit;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemScoring==="undefined"){BX.CrmHistoryItemScoring=function(){BX.CrmHistoryItemScoring.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemScoring,BX.CrmHistoryItem);BX.CrmHistoryItemScoring.prototype.prepareContent=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-scoring"},events:{click:function(){var t="/crm/ml/#entity#/#id#/detail";var e=this.getOwnerTypeId();var i=this.getOwnerId();var r;if(e==1){r="lead"}else if(e==2){r="deal"}else{return}t=t.replace("#entity#",r);t=t.replace("#id#",i);if(BX.SidePanel){BX.SidePanel.Instance.open(t,{width:840})}else{top.location.href=t}}.bind(this)}});var e=BX.prop.getObject(this._data,"SCORING_INFO",null);if(!e){return t}var i=BX.prop.getNumber(e,"SCORE",0);var r=BX.prop.getNumber(e,"SCORE_DELTA",0);i=Math.round(i*100);r=Math.round(r*100);var n=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-total-result"},text:i+"%"});var s=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-total-icon crm-entity-stream-content-scoring-total-icon-success"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-total"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-total-text"},text:BX.message("CRM_TIMELINE_SCORING_TITLE")}),n,s]}),BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-event"},children:[r!==0?BX.create("DIV",{attrs:{className:"crm-entity-stream-content-scoring-event-offset"},text:(r>0?"+":"")+r+"%"}):null]})]}));return t};BX.CrmHistoryItemScoring.create=function(t,e){var i=new BX.CrmHistoryItemScoring;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemOrderCreation==="undefined"){BX.CrmHistoryItemOrderCreation=function(){BX.CrmHistoryItemOrderCreation.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemOrderCreation,BX.CrmHistoryItem);BX.CrmHistoryItemOrderCreation.prototype.doInitialize=function(){BX.CrmHistoryItemOrderCreation.superclass.doInitialize.apply(this);if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmHistoryItemOrderCreation. The field 'activityEditor' is not assigned."}};BX.CrmHistoryItemOrderCreation.prototype.getTitle=function(){var t=this.getMessage(BX.CrmEntityType.resolveName(this.getAssociatedEntityTypeId()).toLowerCase());if(!BX.type.isNotEmptyString(t)){t=this.getTextDataParam("TITLE")}return t};BX.CrmHistoryItemOrderCreation.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-createOrderEntity"};BX.CrmHistoryItemOrderCreation.prototype.getHeaderChildren=function(){var t=this.getMessage("unpaid");var e="crm-entity-stream-content-event-not-paid";var i=this.getObjectDataParam("FIELDS");if(BX.prop.get(i,"DONE")==="Y"){t=this.getMessage("done");e="crm-entity-stream-content-event-done"}else if(BX.prop.get(i,"CANCELED")==="Y"){t=this.getMessage("canceled");e="crm-entity-stream-content-event-canceled"}else if(BX.prop.get(i,"PAID")==="Y"){t=this.getMessage("paid");e="crm-entity-stream-content-event-paid"}return[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}),BX.create("SPAN",{attrs:{className:e},text:t}),BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})]};BX.CrmHistoryItemOrderCreation.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityData();var e=this.getAssociatedEntityTypeId();var i=this.getAssociatedEntityId();var r=BX.prop.getString(t,"TITLE");var n=BX.prop.getString(t,"SHOW_URL","");var s=[];if(r!==""){if(n===""||e===this.getOwnerTypeId()&&i===this.getOwnerId()){s.push(BX.create("SPAN",{text:r}))}else{s.push(BX.create("A",{attrs:{href:n},text:r}))}var a=BX.prop.getString(t,"LEGEND","");if(a!==""){s.push(BX.create("SPAN",{html:" "+a}))}}return s};BX.CrmHistoryItemOrderCreation.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-store"};BX.CrmHistoryItemOrderCreation.prototype.prepareContent=function(){wrapperClassName="crm-entity-stream-section crm-entity-stream-section-history";var t=BX.create("DIV",{attrs:{className:wrapperClassName}});t.appendChild(BX.create("DIV",{attrs:{className:this.getIconClassName()}}));var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[e]}));var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:this.getHeaderChildren()});e.appendChild(i);e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:this.prepareContentDetails()}));var r=this.prepareAuthorLayout();if(r){e.appendChild(r)}return t};BX.CrmHistoryItemOrderCreation.prototype.getMessage=function(t){var e=BX.CrmHistoryItemOrderCreation.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistoryItemOrderCreation.messages==="undefined"){BX.CrmHistoryItemOrderCreation.messages={}}BX.CrmHistoryItemOrderCreation.create=function(t,e){var i=new BX.CrmHistoryItemOrderCreation;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemOrderModification==="undefined"){BX.CrmHistoryItemOrderModification=function(){BX.CrmHistoryItemOrderModification.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemOrderModification,BX.CrmHistoryItem);BX.CrmHistoryItemOrderModification.prototype.getMessage=function(t){var e=BX.CrmHistoryItemOrderModification.messages;return e.hasOwnProperty(t)?e[t]:t};BX.CrmHistoryItemOrderModification.prototype.getTitle=function(){return this.getTextDataParam("TITLE")};BX.CrmHistoryItemOrderModification.prototype.getStatusInfo=function(){var t={};var e=classCode=null;var i=this.getTextDataParam("CHANGED_ENTITY");var r=this.getObjectDataParam("FIELDS");if(i===BX.CrmEntityType.names.order){if(BX.prop.get(r,"ORDER_CANCELED")==="Y"){e="canceled";classCode="not-paid"}else if(BX.prop.get(r,"ORDER_DONE")==="Y"){e="done";classCode="done"}}if(i===BX.CrmEntityType.names.orderpayment){e=BX.prop.get(r,"ORDER_PAID")==="Y"?"paid":"unpaid";classCode=BX.prop.get(r,"ORDER_PAID")==="Y"?"paid":"not-paid"}else if(i===BX.CrmEntityType.names.ordershipment){e=BX.prop.get(r,"ORDER_DEDUCTED")==="Y"?"deducted":"unshipped";classCode=BX.prop.get(r,"ORDER_DEDUCTED")==="Y"?"shipped":"not-shipped"}if(e){t.className="crm-entity-stream-content-event-"+classCode;t.message=this.getMessage(e)}return t};BX.CrmHistoryItemOrderModification.prototype.getHeaderChildren=function(){var t=[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]})];var e=this.getStatusInfo();if(BX.type.isNotEmptyObject(e)){t.push(BX.create("SPAN",{attrs:{className:e.className},text:e.message}))}t.push(BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())}));return t};BX.CrmHistoryItemOrderModification.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityData();var e=this.getAssociatedEntityTypeId();var i=this.getAssociatedEntityId();var r=BX.prop.getString(t,"TITLE");var n=BX.prop.getString(t,"SHOW_URL","");var s=[];if(r!==""){var a=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"}});if(n===""||e===this.getOwnerTypeId()&&i===this.getOwnerId()){a.appendChild(BX.create("SPAN",{text:r}))}else{a.appendChild(BX.create("A",{attrs:{href:n},text:r}))}var o=BX.prop.getString(t,"LEGEND");if(o!==""){a.appendChild(BX.create("SPAN",{html:" "+o}))}s.push(a)}s=s.concat(this.prepareAdditionalContent());return s};BX.CrmHistoryItemOrderModification.prototype.prepareAdditionalContent=function(){var t=this.getAssociatedEntityData();var e=subnodes=[];var i="";var r=this.getTextDataParam("CHANGED_ENTITY");if(r===BX.CrmEntityType.names.orderpayment||r===BX.CrmEntityType.names.order){var n=BX.prop.get(t,"PAYMENTS_INFO",{});e=this.getObjectDataParam("FIELDS");var s=BX.prop.getObject(e,"PAYMENTS_FIELDS");for(var a in s){if(!s.hasOwnProperty(a)){continue}if(BX.type.isNotEmptyObject(n[a])){payment=n[a];messageCode=BX.prop.getString(s[a],"PAID")==="Y"?"orderPaymentLegendPaid":"orderPaymentLegendUnpaid";i=" "+this.getMessage(messageCode);i=i.replace("#SUM_WITH_CURRENCY#",BX.prop.getString(payment,"SUM_WITH_CURRENCY")).replace("#PAY_SYSTEM_NAME#",BX.util.htmlspecialchars(BX.prop.getString(payment,"PAY_SYSTEM_NAME")));paymentNode=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-payment-info"},children:[BX.create("A",{attrs:{href:BX.prop.getString(payment,"SHOW_URL")},text:this.getMessage("orderPayment")}),BX.create("SPAN",{html:i})]});subnodes.push(paymentNode)}}}else if(r===BX.CrmEntityType.names.ordershipment){var o=BX.prop.get(t,"SHIPMENTS_INFO",{});e=this.getObjectDataParam("FIELDS");var c=BX.prop.getObject(e,"SHIPMENTS_FIELDS");for(var a in c){if(!c.hasOwnProperty(a)){continue}if(BX.type.isNotEmptyObject(o[a])){var m=o[a];messageCode=BX.prop.getString(c[a],"DEDUCTED")==="Y"?"orderShipmentLegendDeducted":"orderShipmentLegendUnshipped";deliveryName=BX.util.htmlspecialchars(BX.prop.getString(m,"DELIVERY_NAME"));i=" "+this.getMessage(messageCode).replace("#DELIVERY_NAME#",deliveryName);shipmentNode=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-payment-info"},children:[BX.create("A",{attrs:{href:BX.prop.getString(m,"SHOW_URL")},text:this.getMessage("orderShipment")}),BX.create("SPAN",{html:i})]});subnodes.push(shipmentNode)}}}return subnodes};BX.CrmHistoryItemOrderModification.prototype.prepareContent=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-history"}});t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon crm-entity-stream-section-icon-store"}}));var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:this.getHeaderChildren()});var r=this.prepareContentDetails();e.appendChild(i);e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:r}));var n=this.prepareAuthorLayout();if(n){e.appendChild(n)}t.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[e]}));return t};if(typeof BX.CrmHistoryItemOrderModification.messages==="undefined"){BX.CrmHistoryItemOrderModification.messages={}}BX.CrmHistoryItemOrderModification.create=function(t,e){var i=new BX.CrmHistoryItemOrderModification;i.initialize(t,e);return i}}if(typeof BX.CrmHistoryItemOrcderCheck==="undefined"){BX.CrmHistoryItemOrcderCheck=function(){BX.CrmHistoryItemOrcderCheck.superclass.constructor.apply(this)};BX.extend(BX.CrmHistoryItemOrcderCheck,BX.CrmHistoryItem);BX.CrmHistoryItemOrcderCheck.prototype.doInitialize=function(){BX.CrmHistoryItemOrcderCheck.superclass.doInitialize.apply(this);if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmHistoryItemOrcderCheck. The field 'activityEditor' is not assigned."}};BX.CrmHistoryItemOrcderCheck.prototype.getTitle=function(){return this.getMessage("orderCheck")};BX.CrmHistoryItemOrcderCheck.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-createOrderEntity"};BX.CrmHistoryItemOrcderCheck.prototype.getHeaderChildren=function(){var t=this.getMessage("printed");var e="crm-entity-stream-content-event-successful";if(this.getTextDataParam("PRINTED")!=="Y"){t=this.getMessage("unprinted");e="crm-entity-stream-content-event-missing"}return[BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:this.getTitle()})]}),BX.create("SPAN",{attrs:{className:e},text:t}),BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:this.formatTime(this.getCreatedTime())})]};BX.CrmHistoryItemOrcderCheck.prototype.prepareContentDetails=function(){var t=this.getAssociatedEntityData();var e=this.getTextDataParam("TITLE");var i=BX.prop.getString(t,"SHOW_URL","");var r=[];if(e!==""){var n=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"}});n.appendChild(BX.create("A",{attrs:{href:i},events:{click:BX.delegate(function(t){BX.Crm.Page.openSlider(i,{width:500});t.preventDefault?t.preventDefault():t.returnValue=false},this)},text:e}));var s=this.getTextDataParam("LEGEND");if(s!==""){n.appendChild(BX.create("SPAN",{text:" "+s}))}r.push(n)}var a=BX.prop.getString(t,"LIST_URL","");if(a){r.push(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-payment-info"},children:[BX.create("A",{attrs:{href:a},text:this.getMessage("listLink")})]}))}return r};BX.CrmHistoryItemOrcderCheck.prototype.prepareContent=function(){var t=this.getAssociatedEntityData();wrapperClassName="crm-entity-stream-section crm-entity-stream-section-history crm-entity-stream-section-createOrderEntity";var e=BX.create("DIV",{attrs:{className:wrapperClassName}});e.appendChild(BX.create("DIV",{attrs:{className:this.getIconClassName()}}));var i=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});e.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"},children:[i]}));var r=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:this.getHeaderChildren()});i.appendChild(r);i.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"},children:this.prepareContentDetails()}));var n=this.prepareAuthorLayout();if(n){i.appendChild(n)}return e};BX.CrmHistoryItemOrcderCheck.prototype.getMessage=function(t){var e=BX.CrmHistoryItemOrcderCheck.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.CrmHistoryItemOrcderCheck.messages==="undefined"){BX.CrmHistoryItemOrcderCheck.messages={}}BX.CrmHistoryItemOrcderCheck.create=function(t,e){var i=new BX.CrmHistoryItemOrcderCheck;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItem==="undefined"){BX.CrmScheduleItem=function(){BX.CrmScheduleItem.superclass.constructor.apply(this);this._schedule=null;this._deadlineNode=null;this._headerClickHandler=BX.delegate(this.onHeaderClick,this);this._setAsDoneButtonHandler=BX.delegate(this.onSetAsDoneButtonClick,this)};BX.extend(BX.CrmScheduleItem,BX.CrmTimelineItem);BX.CrmScheduleItem.prototype.doInitialize=function(){this._schedule=this.getSetting("schedule");if(!(this._activityEditor instanceof BX.CrmActivityEditor)){throw"BX.CrmScheduleItem. The field 'activityEditor' is not assigned."}if(this.hasPermissions()&&!this.verifyPermissions()){this.loadPermissions()}};BX.CrmScheduleItem.prototype.getTypeId=function(){return BX.CrmTimelineType.undefined};BX.CrmScheduleItem.prototype.verifyPermissions=function(){var t=BX.prop.getInteger(this.getPermissions(),"USER_ID",0);return t<=0||t===this._schedule.getUserId()};BX.CrmScheduleItem.prototype.loadPermissions=function(){BX.ajax({url:this._schedule.getServiceUrl(),method:"POST",dataType:"json",data:{ACTION:"GET_PERMISSIONS",TYPE_ID:this.getTypeId(),ID:this.getAssociatedEntityId()},onsuccess:this.onPermissionsLoad.bind(this)})};BX.CrmScheduleItem.prototype.onPermissionsLoad=function(t){var e=BX.prop.getObject(t,"PERMISSIONS",null);if(!e){return}this.setPermissions(e);window.setTimeout(function(){this.refreshLayout()}.bind(this),0)};BX.CrmScheduleItem.prototype.getDeadline=function(){return null};BX.CrmScheduleItem.prototype.hasDeadline=function(){return BX.type.isDate(this.getDeadline())};BX.CrmScheduleItem.prototype.isCounterEnabled=function(){var t=this.getDeadline();return t&&BX.CrmHistoryItem.isCounterEnabled(t)};BX.CrmScheduleItem.prototype.getSourceId=function(){return BX.prop.getInteger(this.getAssociatedEntityData(),"ID",0)};BX.CrmScheduleItem.prototype.onSetAsDoneCompleted=function(t){if(!BX.prop.getBoolean(t,"COMPLETED")){return}this.markAsDone(true);this._schedule.onItemMarkedAsDone(this,{historyItemData:BX.prop.getObject(t,"HISTORY_ITEM")})};BX.CrmScheduleItem.prototype.onPosponeCompleted=function(t){};BX.CrmScheduleItem.prototype.refreshDeadline=function(){this._deadlineNode.innerHTML=this.formatDateTime(this.getDeadline())};BX.CrmScheduleItem.prototype.formatDateTime=function(t){return this._schedule.formatDateTime(t)};BX.CrmScheduleItem.prototype.getWrapperClassName=function(){return""};BX.CrmScheduleItem.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon"};BX.CrmScheduleItem.prototype.isReadOnly=function(){return this._schedule.isReadOnly()};BX.CrmScheduleItem.prototype.isEditable=function(){return!this.isReadOnly()};BX.CrmScheduleItem.prototype.canPostpone=function(){if(this.isReadOnly()){return false}var t=BX.prop.getObject(this.getAssociatedEntityData(),"PERMISSIONS",{});return BX.prop.getBoolean(t,"POSTPONE",false)};BX.CrmScheduleItem.prototype.isDone=function(){return BX.CrmActivityStatus.isFinal(BX.prop.getInteger(this.getAssociatedEntityData(),"STATUS",0))};BX.CrmScheduleItem.prototype.canComplete=function(){if(this.isReadOnly()){return false}var t=BX.prop.getObject(this.getAssociatedEntityData(),"PERMISSIONS",{});return BX.prop.getBoolean(t,"COMPLETE",false)};BX.CrmScheduleItem.prototype.setAsDone=function(t){};BX.CrmScheduleItem.prototype.prepareContent=function(t){return null};BX.CrmScheduleItem.prototype.prepareLayout=function(t){this._wrapper=this.prepareContent(t);if(this._wrapper){var e=BX.type.isPlainObject(t)?BX.prop.getBoolean(t,"add",true):true;if(e){var i=BX.type.isPlainObject(t)&&BX.type.isElementNode(t["anchor"])?t["anchor"]:null;if(i&&i.nextSibling){this._container.insertBefore(this._wrapper,i.nextSibling)}else{this._container.appendChild(this._wrapper)}}this.markAsTerminated(this._schedule.checkItemForTermination(this))}};BX.CrmScheduleItem.prototype.onHeaderClick=function(t){this.view();t.preventDefault?t.preventDefault():t.returnValue=false};BX.CrmScheduleItem.prototype.onSetAsDoneButtonClick=function(t){if(this.canComplete()){this.setAsDone(!this.isDone())}};BX.CrmScheduleItem.prototype.onActivityCreate=function(t,e){this._schedule.getManager().onActivityCreated(t,e)};BX.CrmScheduleItem.isDone=function(t){var e=BX.prop.getObject(t,"ASSOCIATED_ENTITY",{});return BX.CrmActivityStatus.isFinal(BX.prop.getInteger(e,"STATUS",0))};BX.CrmScheduleItem.create=function(t,e){var i=new BX.CrmScheduleItem;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemActivity==="undefined"){BX.CrmScheduleItemActivity=function(){BX.CrmScheduleItemActivity.superclass.constructor.apply(this);this._postponeController=null};BX.extend(BX.CrmScheduleItemActivity,BX.CrmScheduleItem);BX.CrmScheduleItemActivity.prototype.getTypeId=function(){return BX.CrmTimelineType.activity};BX.CrmScheduleItemActivity.prototype.isDone=function(){var t=BX.prop.getInteger(this.getAssociatedEntityData(),"STATUS");return t===BX.CrmActivityStatus.completed||t===BX.CrmActivityStatus.autoCompleted};BX.CrmScheduleItemActivity.prototype.setAsDone=function(t){t=!!t;if(this.isDone()===t){return}var e=BX.prop.getInteger(this.getAssociatedEntityData(),"ID",0);if(e>0){this._activityEditor.setActivityCompleted(e,t,BX.delegate(this.onSetAsDoneCompleted,this))}};BX.CrmScheduleItemActivity.prototype.postpone=function(t){var e=this.getSourceId();if(e>0&&t>0){this._activityEditor.postponeActivity(e,t,BX.delegate(this.onPosponeCompleted,this))}};BX.CrmScheduleItemActivity.prototype.view=function(){var t=BX.prop.getInteger(this.getAssociatedEntityData(),"ID",0);if(t>0){this._activityEditor.viewActivity(t)}};BX.CrmScheduleItemActivity.prototype.edit=function(){this.closeContextMenu();var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.activity){var e=this.getAssociatedEntityData();var i=BX.prop.getInteger(e,"ID",0);if(i>0){this._activityEditor.editActivity(i)}}};BX.CrmScheduleItemActivity.prototype.processRemoval=function(){this.closeContextMenu();this._detetionConfirmDlgId="entity_timeline_deletion_"+this.getId()+"_confirm";var t=BX.Crm.ConfirmationDialog.get(this._detetionConfirmDlgId);if(!t){t=BX.Crm.ConfirmationDialog.create(this._detetionConfirmDlgId,{title:this.getMessage("removeConfirmTitle"),content:this.getRemoveMessage()})}t.open().then(BX.delegate(this.onRemovalConfirm,this),BX.delegate(this.onRemovalCancel,this))};BX.CrmScheduleItemActivity.prototype.getRemoveMessage=function(){return this.getMessage("removeConfirm")};BX.CrmScheduleItemActivity.prototype.onRemovalConfirm=function(t){if(BX.prop.getBoolean(t,"cancel",true)){return}this.remove()};BX.CrmScheduleItemActivity.prototype.onRemovalCancel=function(){};BX.CrmScheduleItemActivity.prototype.remove=function(){var t=this.getAssociatedEntityTypeId();if(t===BX.CrmEntityType.enumeration.activity){var e=this.getAssociatedEntityData();var i=BX.prop.getInteger(e,"ID",0);if(i>0){var r=this._activityEditor;var n=r.getItemById(i);if(n){r.deleteActivity(i,true)}else{var s=r.getSetting("ownerType","");var a=r.getSetting("ownerID","");var o=BX.util.add_url_param(r.getSetting("serviceUrl",""),{id:i,action:"get_activity",ownertype:s,ownerid:a});BX.ajax({url:o,method:"POST",dataType:"json",data:{ACTION:"GET_ACTIVITY",ID:i,OWNER_TYPE:s,OWNER_ID:a},onsuccess:BX.delegate(function(t){if(typeof t["ACTIVITY"]!=="undefined"){r._handleActivityChange(t["ACTIVITY"]);window.setTimeout(BX.delegate(this.remove,this),500)}},this),onfailure:function(t){}})}}}};BX.CrmScheduleItemActivity.prototype.getDeadline=function(){var t=this.getAssociatedEntityData();var e=BX.parseDate(t["DEADLINE_SERVER"],false,"YYYY-MM-DD","YYYY-MM-DD HH:MI:SS");if(!e){return null}return new Date(e.getTime()+1e3*BX.CrmTimelineItem.getUserTimezoneOffset())};BX.CrmScheduleItemActivity.prototype.markAsDone=function(t){t=!!t;this.getAssociatedEntityData()["STATUS"]=t?BX.CrmActivityStatus.completed:BX.CrmActivityStatus.waiting};BX.CrmScheduleItemActivity.prototype.getPrepositionText=function(t){return this.getMessage(t===BX.CrmActivityDirection.incoming?"from":"to")};BX.CrmScheduleItemActivity.prototype.getTypeDescription=function(t){return""};BX.CrmScheduleItemActivity.prototype.isContextMenuEnabled=function(){return!!this.getDeadline()&&this.canPostpone()||this.canComplete()};BX.CrmScheduleItemActivity.prototype.prepareContent=function(t){var e=this.getDeadline();var i=e?this.formatDateTime(e):this.getMessage("termless");var r=this.getAssociatedEntityData();var n=BX.prop.getInteger(r,"DIRECTION",0);var s=this.isDone();var a=BX.prop.getString(r,"SUBJECT","");var o=BX.prop.getString(r,"DESCRIPTION_RAW","");var c=BX.prop.getObject(r,"COMMUNICATION",{});var m=BX.prop.getString(c,"TITLE","");var l=BX.prop.getString(c,"SHOW_URL","");var h=BX.prop.getString(c,"TYPE","")!==""?BX.prop.getString(c,"VALUE",""):"";var p=this.getWrapperClassName();if(p!==""){p="crm-entity-stream-section crm-entity-stream-section-planned"+" "+p}else{p="crm-entity-stream-section crm-entity-stream-section-planned"}var d=BX.create("DIV",{attrs:{className:p}});var u=this.getIconClassName();if(this.isCounterEnabled()){u+=" crm-entity-stream-section-counter"}d.appendChild(BX.create("DIV",{attrs:{className:u}}));if(this.isContextMenuEnabled()){d.appendChild(this.prepareContextMenuButton())}var y=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"}});d.appendChild(y);if(o!==""){o=o.replace(/^\s+/,"")}var f=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});y.appendChild(f);this._deadlineNode=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:i});var g=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:[BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},text:this.getTypeDescription(n)}),this._deadlineNode]});f.appendChild(g);var B=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});f.appendChild(B);B.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-title"},children:[BX.create("A",{attrs:{href:"#"},events:{click:this._headerClickHandler},text:a})]}));B.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},text:this.cutOffText(o,128)}));var C=this.prepareDetailNodes();if(BX.type.isArray(C)){for(var _=0,X=C.length;_<X;_++){B.appendChild(C[_])}}var I=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});if(m!==""){I.appendChild(BX.create("SPAN",{text:this.getPrepositionText(n)+": "}));if(l!==""){I.appendChild(BX.create("A",{attrs:{href:l},text:m}))}else{I.appendChild(BX.create("SPAN",{text:m}))}}if(h!==""){var v=this.prepareCommunicationNode(h);if(v){I.appendChild(v)}}B.appendChild(I);var T=BX.create("INPUT",{attrs:{type:"checkbox",className:"crm-entity-stream-planned-apply-btn",checked:s},events:{change:this._setAsDoneButtonHandler}});if(!this.canComplete()){T.disabled=true}var E=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-planned-action"},children:[T]});f.appendChild(E);var S=this.prepareAuthorLayout();if(S){f.appendChild(S)}this._actionContainer=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-action"}});f.appendChild(this._actionContainer);return d};BX.CrmScheduleItemActivity.prototype.prepareCommunicationNode=function(t){return BX.create("SPAN",{text:" "+t})};BX.CrmScheduleItemActivity.prototype.prepareDetailNodes=function(){return[]};BX.CrmScheduleItemActivity.prototype.prepareContextMenuItems=function(){var t=[];if(!this.isReadOnly()){if(this.isEditable()){t.push({id:"edit",text:this.getMessage("menuEdit"),onclick:BX.delegate(this.edit,this)})}t.push({id:"remove",text:this.getMessage("menuDelete"),onclick:BX.delegate(this.processRemoval,this)})}var e=BX.delegate(this.onContextMenuItemSelect,this);if(!this._postponeController){this._postponeController=BX.CrmSchedulePostponeController.create("",{item:this})}var i={id:"postpone",text:this._postponeController.getTitle(),items:[]};var r=this._postponeController.getCommandList();for(var n=0,s=r.length;n<s;n++){var a=r[n];i.items.push({id:a["name"],text:a["title"],onclick:e})}t.push(i);return t};BX.CrmScheduleItemActivity.prototype.onContextMenuItemSelect=function(t,e){this.closeContextMenu();if(this._postponeController){this._postponeController.processCommand(e.id)}}}if(typeof BX.CrmScheduleItemEmail==="undefined"){BX.CrmScheduleItemEmail=function(){BX.CrmScheduleItemEmail.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemEmail,BX.CrmScheduleItemActivity);BX.CrmScheduleItemEmail.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-email"};BX.CrmScheduleItemEmail.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-email"};BX.CrmScheduleItemEmail.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmScheduleEmailAction.create("email",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor}))};BX.CrmScheduleItemEmail.prototype.getTypeDescription=function(t){return this.getMessage(t===BX.CrmActivityDirection.incoming?"incomingEmail":"outgoingEmail")};BX.CrmScheduleItemEmail.prototype.getRemoveMessage=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"SUBJECT","");e=BX.util.htmlspecialchars(e);return this.getMessage("emailRemove").replace("#TITLE#",e)};BX.CrmScheduleItemEmail.prototype.isEditable=function(){return false};BX.CrmScheduleItemEmail.create=function(t,e){var i=new BX.CrmScheduleItemEmail;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemCall==="undefined"){BX.CrmScheduleItemCall=function(){BX.CrmScheduleItemCall.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemCall,BX.CrmScheduleItemActivity);BX.CrmScheduleItemCall.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-call"};BX.CrmScheduleItemCall.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-call"};BX.CrmScheduleItemCall.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmScheduleCallAction.create("call",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor,ownerInfo:this._schedule.getOwnerInfo()}))};BX.CrmScheduleItemCall.prototype.getTypeDescription=function(t){var e=this.getAssociatedEntityData();var i=BX.prop.getObject(e,"CALL_INFO",null);var r=i!==null?BX.prop.getString(i,"CALL_TYPE_TEXT",""):"";if(r!==""){return r}return this.getMessage(t===BX.CrmActivityDirection.incoming?"incomingCall":"outgoingCall")};BX.CrmScheduleItemCall.prototype.getRemoveMessage=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getInteger(t,"DIRECTION",0);var i=BX.prop.getString(t,"SUBJECT","");var r=e===BX.CrmActivityDirection.incoming?"incomingCallRemove":"outgoingCallRemove";i=BX.util.htmlspecialchars(i);return this.getMessage(r).replace("#TITLE#",i)};BX.CrmScheduleItemCall.create=function(t,e){var i=new BX.CrmScheduleItemCall;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemMeeting==="undefined"){BX.CrmScheduleItemMeeting=function(){BX.CrmScheduleItemMeeting.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemMeeting,BX.CrmScheduleItemActivity);BX.CrmScheduleItemMeeting.prototype.getWrapperClassName=function(){return""};BX.CrmScheduleItemMeeting.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-meeting"};BX.CrmScheduleItemMeeting.prototype.prepareActions=function(){};BX.CrmScheduleItemMeeting.prototype.getPrepositionText=function(){return this.getMessage("reciprocal")};BX.CrmScheduleItemMeeting.prototype.getRemoveMessage=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"SUBJECT","");e=BX.util.htmlspecialchars(e);return this.getMessage("meetingRemove").replace("#TITLE#",e)};BX.CrmScheduleItemMeeting.prototype.getTypeDescription=function(){return this.getMessage("meeting")};BX.CrmScheduleItemMeeting.create=function(t,e){var i=new BX.CrmScheduleItemMeeting;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemTask==="undefined"){BX.CrmScheduleItemTask=function(){BX.CrmScheduleItemTask.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemTask,BX.CrmScheduleItemActivity);BX.CrmScheduleItemTask.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-planned-task"};BX.CrmScheduleItemTask.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-task"};BX.CrmScheduleItemTask.prototype.getTypeDescription=function(){return this.getMessage("task")};BX.CrmScheduleItemTask.prototype.getPrepositionText=function(t){return this.getMessage("reciprocal")};BX.CrmScheduleItemTask.prototype.getRemoveMessage=function(){var t=this.getAssociatedEntityData();var e=BX.prop.getString(t,"SUBJECT","");e=BX.util.htmlspecialchars(e);return this.getMessage("taskRemove").replace("#TITLE#",e)};BX.CrmScheduleItemTask.create=function(t,e){var i=new BX.CrmScheduleItemTask;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemWebForm==="undefined"){BX.CrmScheduleItemWebForm=function(){BX.CrmScheduleItemWebForm.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemWebForm,BX.CrmScheduleItemActivity);BX.CrmScheduleItemWebForm.prototype.getWrapperClassName=function(){return""};BX.CrmScheduleItemWebForm.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-crmForm"};BX.CrmScheduleItemWebForm.prototype.prepareActions=function(){};BX.CrmScheduleItemWebForm.prototype.getPrepositionText=function(){return this.getMessage("from")};BX.CrmScheduleItemWebForm.prototype.getTypeDescription=function(){return this.getMessage("webform")};BX.CrmScheduleItemWebForm.create=function(t,e){var i=new BX.CrmScheduleItemWebForm;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemWait==="undefined"){BX.CrmScheduleItemWait=function(){BX.CrmScheduleItemWait.superclass.constructor.apply(this);this._postponeController=null};BX.extend(BX.CrmScheduleItemWait,BX.CrmScheduleItem);BX.CrmScheduleItemWait.prototype.getTypeId=function(){return BX.CrmTimelineType.wait};BX.CrmScheduleItemWait.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-wait"};BX.CrmScheduleItemWait.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-wait"};BX.CrmScheduleItemWait.prototype.prepareActions=function(){};BX.CrmScheduleItemWait.prototype.isCounterEnabled=function(){return false};BX.CrmScheduleItemWait.prototype.getDeadline=function(){var t=this.getAssociatedEntityData();var e=BX.parseDate(t["DEADLINE_SERVER"],false,"YYYY-MM-DD","YYYY-MM-DD HH:MI:SS");if(!e){return null}return new Date(e.getTime()+1e3*BX.CrmTimelineItem.getUserTimezoneOffset())};BX.CrmScheduleItemWait.prototype.isDone=function(){return BX.prop.getString(this.getAssociatedEntityData(),"COMPLETED","N")==="Y"};BX.CrmScheduleItemWait.prototype.setAsDone=function(t){t=!!t;if(this.isDone()===t){return}var e=this.getAssociatedEntityId();if(e>0){var i=this._schedule.getManager().getWaitEditor();if(i){i.complete(e,t,BX.delegate(this.onSetAsDoneCompleted,this))}}};BX.CrmScheduleItemWait.prototype.postpone=function(t){var e=this.getAssociatedEntityId();if(e>0&&t>0){var i=this._schedule.getManager().getWaitEditor();if(i){i.postpone(e,t,BX.delegate(this.onPosponeCompleted,this))}}};BX.CrmScheduleItemWait.prototype.isContextMenuEnabled=function(){return!!this.getDeadline()&&this.canPostpone()};BX.CrmScheduleItemWait.prototype.prepareContent=function(){var t=this.getDeadline();var e=t?this.formatDateTime(t):this.getMessage("termless");var i=this.getAssociatedEntityData();var r=this.isDone();var n=BX.prop.getString(i,"DESCRIPTION_RAW","");var s=this.getWrapperClassName();if(s!==""){s="crm-entity-stream-section crm-entity-stream-section-planned"+" "+s}else{s="crm-entity-stream-section crm-entity-stream-section-planned"}var a=BX.create("DIV",{attrs:{className:s}});var o=this.getIconClassName();if(this.isCounterEnabled()){o+=" crm-entity-stream-section-counter"}a.appendChild(BX.create("DIV",{attrs:{className:o}}));if(this.isContextMenuEnabled()){a.appendChild(this.prepareContextMenuButton())}var c=BX.create("DIV",{attrs:{className:"crm-entity-stream-section-content"}});a.appendChild(c);if(n!==""){n=BX.util.trim(n);n=BX.util.strip_tags(n);n=this.cutOffText(n,512);n=BX.util.nl2br(n)}var m=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-event"}});c.appendChild(m);this._deadlineNode=BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-time"},text:e});var l=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-header"},children:[BX.create("SPAN",{attrs:{className:"crm-entity-stream-content-event-title"},text:this.getMessage("wait")}),this._deadlineNode]});m.appendChild(l);var h=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail"}});m.appendChild(h);h.appendChild(BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-description"},html:n}));var p=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-contact-info"}});h.appendChild(p);var d=BX.create("INPUT",{attrs:{type:"checkbox",className:"crm-entity-stream-planned-apply-btn",checked:r},events:{change:this._setAsDoneButtonHandler}});if(!this.canComplete()){d.disabled=true}var u=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-planned-action"},children:[d]});m.appendChild(u);var y=this.prepareAuthorLayout();if(y){m.appendChild(y)}this._actionContainer=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-action"}});m.appendChild(this._actionContainer);return a};BX.CrmScheduleItemWait.prototype.prepareContextMenuItems=function(){var t=[];var e=BX.delegate(this.onContextMenuItemSelect,this);if(!this._postponeController){this._postponeController=BX.CrmSchedulePostponeController.create("",{item:this})}var i={id:"postpone",text:this._postponeController.getTitle(),items:[]};var r=this._postponeController.getCommandList();for(var n=0,s=r.length;n<s;n++){var a=r[n];i.items.push({id:a["name"],text:a["title"],onclick:e})}t.push(i);return t};BX.CrmScheduleItemWait.prototype.onContextMenuItemSelect=function(t,e){this.closeContextMenu();if(this._postponeController){this._postponeController.processCommand(e.id)}};BX.CrmScheduleItemWait.prototype.getTypeDescription=function(){return this.getMessage("wait")};BX.CrmScheduleItemWait.create=function(t,e){var i=new BX.CrmScheduleItemWait;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemActivityRequest==="undefined"){BX.CrmScheduleItemActivityRequest=function(){BX.CrmScheduleItemActivityRequest.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemActivityRequest,BX.CrmScheduleItemActivity);BX.CrmScheduleItemActivityRequest.prototype.getWrapperClassName=function(){return""};BX.CrmScheduleItemActivityRequest.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-robot"};BX.CrmScheduleItemActivityRequest.prototype.getTypeDescription=function(){return this.getMessage("activityRequest")};BX.CrmScheduleItemActivityRequest.prototype.isEditable=function(){return false};BX.CrmScheduleItemActivityRequest.create=function(t,e){var i=new BX.CrmScheduleItemActivityRequest;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemActivityRestApplication==="undefined"){BX.CrmScheduleItemActivityRestApplication=function(){BX.CrmScheduleItemActivityRestApplication.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemActivityRestApplication,BX.CrmScheduleItemActivity);BX.CrmScheduleItemActivityRestApplication.prototype.getWrapperClassName=function(){return""};BX.CrmScheduleItemActivityRestApplication.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-rest"};BX.CrmScheduleItemActivityRestApplication.prototype.prepareContent=function(t){var e=BX.CrmScheduleItemActivityRestApplication.superclass.prepareContent.apply(this,t);var i=this.getAssociatedEntityData();if(i["APP_TYPE"]&&i["APP_TYPE"]["ICON_SRC"]){var r=e.querySelector('[class="'+this.getIconClassName()+'"]');if(r){r.style.backgroundImage="url("+i["APP_TYPE"]["ICON_SRC"]+")";r.style.backgroundPosition="center center"}}return e};BX.CrmScheduleItemActivityRestApplication.prototype.getTypeDescription=function(){var t=this.getAssociatedEntityData();if(t["APP_TYPE"]&&t["APP_TYPE"]["NAME"]){return t["APP_TYPE"]["NAME"]}return this.getMessage("restApplication")};BX.CrmScheduleItemActivityRestApplication.create=function(t,e){var i=new BX.CrmScheduleItemActivityRestApplication;i.initialize(t,e);return i}}if(typeof BX.CrmScheduleItemActivityOpenLine==="undefined"){BX.CrmScheduleItemActivityOpenLine=function(){BX.CrmScheduleItemActivityOpenLine.superclass.constructor.apply(this)};BX.extend(BX.CrmScheduleItemActivityOpenLine,BX.CrmScheduleItemActivity);BX.CrmScheduleItemActivityOpenLine.prototype.getWrapperClassName=function(){return"crm-entity-stream-section-IM"};BX.CrmScheduleItemActivityOpenLine.prototype.getIconClassName=function(){return"crm-entity-stream-section-icon crm-entity-stream-section-icon-IM"};BX.CrmScheduleItemActivityOpenLine.prototype.prepareActions=function(){if(this.isReadOnly()){return}this._actions.push(BX.CrmScheduleOpenLineAction.create("openline",{item:this,container:this._actionContainer,entityData:this.getAssociatedEntityData(),activityEditor:this._activityEditor,ownerInfo:this._schedule.getOwnerInfo()}))};BX.CrmScheduleItemActivityOpenLine.prototype.getTypeDescription=function(){return this.getMessage("openLine")};BX.CrmScheduleItemActivityOpenLine.prototype.getPrepositionText=function(t){return this.getMessage("reciprocal")};BX.CrmScheduleItemActivityOpenLine.prototype.prepareCommunicationNode=function(t){return null};BX.CrmScheduleItemActivityOpenLine.prototype.prepareDetailNodes=function(){var t=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-IM"}});var e=BX.create("DIV",{attrs:{className:"crm-entity-stream-content-detail-IM-messages"}});t.appendChild(e);var i=BX.prop.getObject(this.getAssociatedEntityData(),"OPENLINE_INFO",null);if(i){var r=BX.prop.getArray(i,"MESSAGES",[]);for(var n=0,s=r.length;n<s;n++){var a=r[n];var o=BX.prop.getBoolean(a,"IS_EXTERNAL",true);e.appendChild(BX.create("DIV",{attrs:{className:o?"crm-entity-stream-content-detail-IM-message-incoming":"crm-entity-stream-content-detail-IM-message-outgoing"},text:BX.prop.getString(a,"MESSAGE","")}))}}return[t]};BX.CrmScheduleItemActivityOpenLine.prototype.view=function(){if(typeof window.top["BXIM"]==="undefined"){window.alert(this.getMessage("openLineNotSupported"));return}var t="";var e=BX.prop.getObject(this.getAssociatedEntityData(),"COMMUNICATION",null);if(e){if(BX.prop.getString(e,"TYPE")==="IM"){t=BX.prop.getString(e,"VALUE")}}if(t!==""){window.top["BXIM"].openMessengerSlider(t,{RECENT:"N",MENU:"N"})}};BX.CrmScheduleItemActivityOpenLine.create=function(t,e){var i=new BX.CrmScheduleItemActivityOpenLine;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineItemAnimation==="undefined"){BX.CrmTimelineItemAnimation=function(){this._id="";this._settings={};this._initialItem=null;this._finalItem=null;this._events=null};BX.CrmTimelineItemAnimation.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._initialItem=this.getSetting("initialItem");this._finalItem=this.getSetting("finalItem");this._anchor=this.getSetting("anchor");this._events=this.getSetting("events",{})},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},run:function(){this._node=this._initialItem.getWrapper();var t=BX.pos(this._node);this._initialYPosition=t.top;this._initialXPosition=t.left;this._initialWidth=this._node.offsetWidth;this._initialHeight=this._node.offsetHeight;this._anchorYPosition=BX.pos(this._anchor).top;this.createStub();this.createGhost();this.moveGhost()},createStub:function(){this._stub=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-planned crm-entity-stream-section-shadow"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon"}}),BX.create("DIV",{props:{className:"crm-entity-stream-section-content"},style:{height:this._initialHeight+"px"}})]});this._node.parentNode.insertBefore(this._stub,this._node)},createGhost:function(){this._ghostNode=this._node;this._ghostNode.style.position="absolute";this._ghostNode.style.width=this._initialWidth+"px";this._ghostNode.style.height=this._initialHeight+"px";this._ghostNode.style.top=this._initialYPosition+"px";this._ghostNode.style.left=this._initialXPosition+"px";document.body.appendChild(this._ghostNode);setTimeout(BX.proxy(function(){BX.addClass(this._ghostNode,"crm-entity-stream-section-casper")},this),20)},moveGhost:function(){var t=this._ghostNode;var e=new BX.easing({duration:500,start:{top:this._initialYPosition},finish:{top:this._anchorYPosition},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(e){t.style.top=e.top+"px"},this)});setTimeout(BX.proxy(function(){e.animate();t.style.boxShadow=""},this),500);var i=new BX.easing({duration:500,start:{height:0},finish:{height:this._initialHeight+20},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._anchor.style.height=t.height+"px"},this),complete:BX.proxy(function(){if(BX.type.isFunction(this._events["complete"])){this._events["complete"]()}this.addHistoryItem();this.removeGhost()},this)});setTimeout(function(){i.animate()},500)},addHistoryItem:function(){var t=this._finalItem.getWrapper();this._anchor.parentNode.insertBefore(t,this._anchor.nextSibling);this._finalItemHeight=this._anchor.offsetHeight-t.offsetHeight;this._anchor.style.height=0;t.style.marginBottom=this._finalItemHeight+"px"},removeGhost:function(){var t=this._ghostNode;var e=this._finalItem.getWrapper();t.style.overflow="hidden";var i=new BX.easing({duration:70,start:{opacity:100,height:t.offsetHeight,marginBottom:this._finalItemHeight},finish:{opacity:0,height:e.offsetHeight,marginBottom:20},step:BX.proxy(function(i){t.style.opacity=i.opacity/100;t.style.height=i.height+"px";e.style.marginBottom=i.marginBottom+"px"},this),complete:BX.proxy(function(){t.remove();e.style.marginBottom="";this.collapseStub()},this)});i.animate()},collapseStub:function(){var t=new BX.easing({duration:500,start:{opacity:100,height:this._initialHeight,marginBottom:15},finish:{opacity:0,height:0,marginBottom:0},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._stub.style.height=t.height+"px";this._stub.style.marginBottom=t.marginBottom+"px";this._stub.style.opacity=t.opacity/100},this),complete:BX.proxy(function(){this.inited=false},this)});t.animate()}};BX.CrmTimelineItemAnimation.create=function(t,e){var i=new BX.CrmTimelineItemAnimation;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineItemAnimationNew==="undefined"){BX.CrmTimelineItemAnimationNew=function(){this._id="";this._settings={};this._initialItem=null;this._finalItem=null;this._events=null};BX.CrmTimelineItemAnimationNew.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._initialItem=this.getSetting("initialItem");this._finalItem=this.getSetting("finalItem");this._anchor=this.getSetting("anchor");this._events=this.getSetting("events",{})},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},addHistoryItem:function(){var t=this._finalItem.getWrapper();this._anchor.parentNode.insertBefore(t,this._anchor.nextSibling)},run:function(){this._node=this._initialItem.getWrapper();this.createStub();BX.addClass(this._node,"crm-entity-stream-section-animate-start");this._startPosition=BX.pos(this._stub);this._node.style.position="absolute";this._node.style.width=this._startPosition.width+"px";this._node.style.height=this._startPosition.height+"px";this._node.style.top=this._startPosition.top+"px";this._node.style.left=this._startPosition.left+"px";this._node.style.zIndex=960;document.body.appendChild(this._node);var t=BX.CrmTimelineItemShift.create(this._node,this._anchor,this._startPosition,this._stub,{complete:BX.delegate(this.finish,this)});t.run()},createStub:function(){this._stub=BX.create("DIV",{attrs:{className:"crm-entity-stream-section crm-entity-stream-section-planned crm-entity-stream-section-shadow"},children:[BX.create("DIV",{attrs:{className:"crm-entity-stream-section-icon"}}),BX.create("DIV",{props:{className:"crm-entity-stream-section-content"},style:{height:this._initialItem._wrapper.clientHeight+"px"}})]});this._node.parentNode.insertBefore(this._stub,this._node)},finish:function(){var t=this._stub.querySelector(".crm-entity-stream-section-content");this._anchor.style.height=0;setTimeout(BX.delegate(function(){BX.removeClass(this._node,"crm-entity-stream-section-animate-start")},this),0);this._node.style.opacity=0;setTimeout(BX.delegate(function(){t.style.height=0;t.style.opacity=0;t.style.paddingTop=0;t.style.paddingBottom=0},this),120);setTimeout(BX.delegate(function(){BX.remove(this._stub);BX.remove(this._node);this.addHistoryItem();if(BX.type.isFunction(this._events["complete"])){this._events["complete"]()}},this),420)}};BX.CrmTimelineItemAnimationNew.create=function(t,e){var i=new BX.CrmTimelineItemAnimationNew;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineItemExpand==="undefined"){BX.CrmTimelineItemExpand=function(){this._node=null;this._callback=null};BX.CrmTimelineItemExpand.prototype={initialize:function(t,e){this._node=t;this._callback=BX.type.isFunction(e)?e:null},run:function(){var t=BX.pos(this._node);this._node.style.height=0;this._node.style.opacity=0;this._node.style.overflow="hidden";new BX.easing({duration:150,start:{height:0},finish:{height:t.height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.delegate(this.onNodeHeightStep,this),complete:BX.delegate(this.onNodeHeightComplete,this)}).animate()},onNodeHeightStep:function(t){this._node.style.height=t.height+"px"},onNodeHeightComplete:function(){this._node.style.overflow="";new BX.easing({duration:150,start:{opacity:0},finish:{opacity:100},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.delegate(this.onNodeOpacityStep,this),complete:BX.delegate(this.onNodeOpacityComplete,this)}).animate()},onNodeOpacityStep:function(t){this._node.style.opacity=t.opacity/100},onNodeOpacityComplete:function(){this._node.style.height="";this._node.style.opacity="";if(this._callback){this._callback()}}};BX.CrmTimelineItemExpand.create=function(t,e){var i=new BX.CrmTimelineItemExpand;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineItemExtract==="undefined"){BX.CrmTimelineItemExtract=function(){this._node=null;this._shadowNode=null;this._events=null};BX.CrmTimelineItemExtract.prototype={initialize:function(t,e,i){this._node=t;this._shadowNode=e;this._events=BX.type.isPlainObject(i)?i:{}},run:function(){},finish:function(){}};BX.CrmTimelineItemExtract.create=function(t,e,i){var r=new BX.CrmTimelineItemExtract;r.initialize(t,e,i);return r}}if(typeof BX.CrmTimelineItemShift==="undefined"){BX.CrmTimelineItemShift=function(){this._node=null;this._anchor=null;this._nodeParent=null;this._startPosition=null;this._events=null};BX.CrmTimelineItemShift.prototype={initialize:function(t,e,i,r,n){this._node=t;this._shadowNode=r;this._anchor=e;this._nodeParent=t.parentNode;this._startPosition=i;this._events=BX.type.isPlainObject(n)?n:{}},run:function(){this._anchorPosition=BX.pos(this._anchor);setTimeout(BX.proxy(function(){BX.addClass(this._node,"crm-entity-stream-section-casper")},this),0);var t=new BX.easing({duration:1500,start:{top:this._startPosition.top,height:0},finish:{top:this._anchorPosition.top,height:this._startPosition.height+20},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._node.style.top=t.top+"px";this._anchor.style.height=t.height+"px"},this),complete:BX.proxy(function(){this.finish()},this)});t.animate()},finish:function(){if(BX.type.isFunction(this._events["complete"])){this._events["complete"]()}if(this._shadowNode!==false){}}};BX.CrmTimelineItemShift.create=function(t,e,i,r,n){var s=new BX.CrmTimelineItemShift;s.initialize(t,e,i,r,n);return s}}if(typeof BX.CrmCommentAnimation==="undefined"){BX.CrmCommentAnimation=function(){this._node=null;this._anchor=null;this._nodeParent=null;this._startPosition=null;this._events=null};BX.CrmCommentAnimation.prototype={initialize:function(t,e,i,r){this._node=t;this._anchor=e;this._nodeParent=t.parentNode;this._startPosition=i;this._events=BX.type.isPlainObject(r)?r:{}},run:function(){BX.addClass(this._node,"crm-entity-stream-section-animate-start");this._node.style.position="absolute";this._node.style.width=this._startPosition.width+"px";this._node.style.height=this._startPosition.height+"px";this._node.style.top=this._startPosition.top-30+"px";this._node.style.left=this._startPosition.left+"px";this._node.style.opacity=0;this._node.style.zIndex=960;document.body.appendChild(this._node);var t=new BX.easing({duration:350,start:{opacity:0},finish:{opacity:100},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._node.style.opacity=t.opacity/100},this),complete:BX.proxy(function(){if(BX.type.isFunction(this._events["start"])){this._events["start"]()}var t=BX.CrmTimelineItemShift.create(this._node,this._anchor,this._startPosition,false,{complete:BX.delegate(this.finish,this)});t.run()},this)});t.animate();if(BX.type.isFunction(this._events["complete"])){this._events["complete"]()}},finish:function(){this._node.style.position="";this._node.style.width="";this._node.style.height="";this._node.style.top="";this._node.style.left="";this._node.style.opacity="";this._node.style.zIndex="";this._anchor.style.height="";this._anchor.parentNode.insertBefore(this._node,this._anchor.nextSibling);setTimeout(BX.delegate(function(){BX.removeClass(this._node,"crm-entity-stream-section-animate-start");BX.remove(this._anchor)},this),0)}};BX.CrmCommentAnimation.create=function(t,e,i,r){var n=new BX.CrmCommentAnimation;n.initialize(t,e,i,r);return n}}if(typeof BX.CrmTimelineItemFasten==="undefined"){BX.CrmTimelineItemFasten=function(){this._id="";this._settings={};this._initialItem=null;this._finalItem=null;this._events=null};BX.CrmTimelineItemFasten.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._initialItem=this.getSetting("initialItem");this._finalItem=this.getSetting("finalItem");this._anchor=this.getSetting("anchor");this._events=this.getSetting("events",{})},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},addFixedHistoryItem:function(){var t=this._finalItem.getWrapper();BX.addClass(t,"crm-entity-stream-section-animate-start");this._anchor.parentNode.insertBefore(t,this._anchor.nextSibling);setTimeout(BX.delegate(function(){BX.removeClass(t,"crm-entity-stream-section-animate-start")},this),0);this._finalItem.onFinishFasten()},run:function(){var t=this._initialItem.getWrapper();this._clone=t.cloneNode(true);BX.addClass(this._clone,"crm-entity-stream-section-animate-start crm-entity-stream-section-top-fixed");this._startPosition=BX.pos(t);this._clone.style.position="absolute";this._clone.style.width=this._startPosition.width+"px";var e=this._startPosition.height;var i=65;var r=18;if(e<r+i)e=r+i;this._clone.style.height=e+"px";this._clone.style.top=this._startPosition.top+"px";this._clone.style.left=this._startPosition.left+"px";this._clone.style.zIndex=960;document.body.appendChild(this._clone);setTimeout(BX.proxy(function(){BX.addClass(this._clone,"crm-entity-stream-section-casper")},this),0);this._anchorPosition=BX.pos(this._anchor);var n={top:this._anchorPosition.top,height:e+15,opacity:1};var s=this._startPosition.top-this._anchorPosition.bottom;var a=2*(document.body.clientHeight+this._startPosition.height);if(s>a){n.top=this._startPosition.top-a;n.opacity=0}var o=Math.abs(n.top-this._startPosition.top)*2;o=o<1500?1500:o;var c=new BX.easing({duration:o,start:{top:this._startPosition.top,height:0,opacity:1},finish:n,transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:BX.proxy(function(t){this._clone.style.top=t.top+"px";this._clone.style.opacity=t.opacity;this._anchor.style.height=t.height+"px"},this),complete:BX.proxy(function(){this.finish()},this)});c.animate()},finish:function(){this._anchor.style.height=0;this.addFixedHistoryItem();BX.remove(this._clone);if(BX.type.isFunction(this._events["complete"])){this._events["complete"]()}}};BX.CrmTimelineItemFasten.create=function(t,e){var i=new BX.CrmTimelineItemFasten;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineMenuBar==="undefined"){BX.CrmTimelineMenuBar=function(){this._id="";this._ownerInfo=null;this._container=null;this._items=null;this._moreButton=null;this._activityEditor=null;this._commentEditor=null;this._waitEditor=null;this._smsEditor=null;this._readOnly=false;this._menu=null;this._isMenuShown=false;this._manager=null};BX.CrmTimelineMenuBar.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._ownerInfo=BX.prop.getObject(this._settings,"ownerInfo");if(!this._ownerInfo){throw"BX.CrmTimelineMenuBar. A required parameter 'ownerInfo' is missing."}this._activityEditor=BX.prop.get(this._settings,"activityEditor",null);this._commentEditor=BX.prop.get(this._settings,"commentEditor");this._waitEditor=BX.prop.get(this._settings,"waitEditor");this._smsEditor=BX.prop.get(this._settings,"smsEditor");this._restEditor=BX.prop.get(this._settings,"restEditor");this._manager=BX.prop.get(this._settings,"manager");if(!(this._manager instanceof BX.CrmTimelineManager)){throw"BX.CrmTimeline. Manager instance is not found."}this._container=BX.prop.getElementNode(this._settings,"container");if(!this._container){throw"BX.CrmTimelineMenuBar. A required parameter 'container' is missing."}this._readOnly=BX.prop.getBoolean(this._settings,"readOnly",false);this._items=[];var i=this._container.querySelectorAll(".crm-entity-stream-section-new-action");for(var r=0,n=i.length;r<n;r++){var s=i[r];var a=BX.CrmTimelineMenuBarItem.create(s.getAttribute("data-item-id"),{container:s,owner:this});this._items.push(a)}this._moreButton=this._container.querySelector(".crm-entity-stream-section-new-action-more");if(this._moreButton){BX.bind(this._moreButton,"click",BX.delegate(this.onMoreButtonClick,this))}this.adjust();BX.bind(window,"resize",BX.delegate(this.onResize,this))},getId:function(){return this._id},getItemById:function(t){for(var e=0,i=this._items.length;e<i;e++){var r=this._items[e];if(r.getId()===t){return r}}return null},setActiveItemById:function(t){for(var e=0,i=this._items.length;e<i;e++){var r=this._items[e];r.setActive(r.getId()===t)}},setActiveItem:function(t){for(var e=0,i=this._items.length;e<i;e++){var r=this._items[e];r.setActive(r===t)}},adjust:function(){if(this._moreButton){this._moreButton.style.display=this.getInvisibleItems().length>0?"":"none"}},processItemSelection:function(t){if(this._readOnly){return}var e=null;var i=t.getId();if(i==="call"){e=new BX.Crm.Activity.Planner;e.showEdit({TYPE_ID:BX.CrmActivityType.call,OWNER_TYPE_ID:this._ownerInfo["ENTITY_TYPE_ID"],OWNER_ID:this._ownerInfo["ENTITY_ID"]})}if(i==="meeting"){e=new BX.Crm.Activity.Planner;e.showEdit({TYPE_ID:BX.CrmActivityType.meeting,OWNER_TYPE_ID:this._ownerInfo["ENTITY_TYPE_ID"],OWNER_ID:this._ownerInfo["ENTITY_ID"]})}else if(i==="email"){this._activityEditor.addEmail({ownerType:this._ownerInfo["ENTITY_TYPE_NAME"],ownerID:this._ownerInfo["ENTITY_ID"],ownerUrl:this._ownerInfo["SHOW_URL"],ownerTitle:this._ownerInfo["TITLE"],subject:""})}else if(i==="task"){this._activityEditor.addTask({ownerType:this._ownerInfo["ENTITY_TYPE_NAME"],ownerID:this._ownerInfo["ENTITY_ID"]})}else if(i==="comment"&&this._commentEditor){if(this._waitEditor){this._waitEditor.setVisible(false)}if(this._smsEditor){this._smsEditor.setVisible(false)}this._commentEditor.setVisible(true);this.setActiveItem(t)}else if(i==="wait"&&this._waitEditor){if(this._commentEditor){this._commentEditor.setVisible(false)}if(this._smsEditor){this._smsEditor.setVisible(false)}this._waitEditor.setVisible(true);this.setActiveItem(t)}else if(i==="sms"&&this._smsEditor){if(this._commentEditor){this._commentEditor.setVisible(false)}if(this._waitEditor){this._waitEditor.setVisible(false)}this._smsEditor.setVisible(true);this.setActiveItem(t)}else if(i==="visit"){var r=this._manager.getSetting("visitParameters");r["OWNER_TYPE"]=this._ownerInfo["ENTITY_TYPE_NAME"];r["OWNER_ID"]=this._ownerInfo["ENTITY_ID"];BX.CrmActivityVisit.create(r).showEdit()}else if(i.match(/^activity_rest_/)){if(this._restEditor){this._restEditor.action(i)}}},getInvisibleItems:function(){var t=[];for(var e=0,i=this._items.length;e<i;e++){var r=this._items[e];if(!r.isVisible()){t.push(r)}}return t},openMenu:function(){var t=this.getInvisibleItems();if(t.length===0){return}var e=BX.delegate(this.onMenuItemSelect,this);var i=[];for(var r=0,n=t.length;r<n;r++){var s=t[r];i.push({id:s.getId(),text:s.getTitle(),onclick:e})}BX.PopupMenu.show(this._id,this._moreButton,i,{offsetTop:0,offsetLeft:16,angle:{position:"top",offset:0},events:{onPopupShow:BX.delegate(this.onContextMenuShow,this),onPopupClose:BX.delegate(this.onContextMenuClose,this),onPopupDestroy:BX.delegate(this.onContextMenuDestroy,this)}});this._menu=BX.PopupMenu.currentItem},closeMenu:function(){if(this._menu){this._menu.close()}},onMoreButtonClick:function(t){if(!this._isMenuShown){this.openMenu()}else{this.closeMenu()}t.preventDefault?t.preventDefault():t.returnValue=false},onMenuItemSelect:function(t,e){var i=this.getItemById(e.id);if(i){this.processItemSelection(i)}this.closeMenu()},onContextMenuShow:function(){this._isMenuShown=true},onContextMenuClose:function(){if(this._menu){this._menu.popupWindow.destroy()}},onContextMenuDestroy:function(){this._isMenuShown=false;this._menu=null;if(typeof BX.PopupMenu.Data[this._id]!=="undefined"){delete BX.PopupMenu.Data[this._id]}},onResize:function(t){if(this._isMenuShown){this.closeMenu()}this.adjust()}};BX.CrmTimelineMenuBar.create=function(t,e){var i=new BX.CrmTimelineMenuBar;i.initialize(t,e);return i}}if(typeof BX.CrmTimelineMenuBarItem==="undefined"){BX.CrmTimelineMenuBarItem=function(){this._id="";this._owner=null;this._container=null;this._isActive=false};BX.CrmTimelineMenuBarItem.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._container=BX.prop.getElementNode(this._settings,"container");if(!this._container){throw"BX.CrmTimelineMenuBarItem. Container node is not found."}BX.bind(this._container,"click",BX.delegate(this.onClick,this));this._isActive=BX.hasClass(this._container,"crm-entity-stream-section-new-action-active");this._owner=BX.prop.get(this._settings,"owner");if(!this._owner){throw"BX.CrmTimelineMenuBarItem. Owner is not found."}},getId:function(){return this._id},isActive:function(){return this._isActive},setActive:function(t){t=!!t;this._isActive=t;if(t){BX.addClass(this._container,"crm-entity-stream-section-new-action-active")}else{BX.removeClass(this._container,"crm-entity-stream-section-new-action-active")}},isVisible:function(){return this._container.offsetTop===0},getTitle:function(){var t=this._container.getAttribute("data-item-title");if(!BX.type.isNotEmptyString(t)){t=this._container.innerHTML}return BX.util.htmlspecialcharsback(t)},onClick:function(t){this._owner.processItemSelection(this);t.preventDefault?t.preventDefault():t.returnValue=false}};BX.CrmTimelineMenuBarItem.create=function(t,e){var i=new BX.CrmTimelineMenuBarItem;i.initialize(t,e);return i}}if(typeof BX.CrmSmsWatcher==="undefined"){BX.CrmSmsWatcher={_pullTagName:"MESSAGESERVICE",_pullInited:false,_listeners:{},initPull:function(){if(this._pullInited)return;BX.addCustomEvent("onPullEvent-messageservice",this.onPullEvent.bind(this));this.extendWatch();this._pullInited=true},subscribeOnMessageUpdate:function(t,e){this.initPull();this._listeners[t]=e},fireExternalStatusUpdate:function(t,e){var i=this._listeners[t];if(i){i(e)}},onPullEvent:function(t,e){if(t==="message_update"){for(var i=0;i<e.messages.length;++i){var r=e.messages[i];this.fireExternalStatusUpdate(r["ID"],r)}}},extendWatch:function(){if(BX.type.isFunction(BX.PULL)){BX.PULL.extendWatch(this._pullTagName);window.setTimeout(this.extendWatch.bind(this),6e4)}}}}
  //# sourceMappingURL=script.map.js