Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/calendar/sync/manager/dist/ |
Upload File : |
this.BX=this.BX||{};this.BX.Calendar=this.BX.Calendar||{};this.BX.Calendar.Sync=this.BX.Calendar.Sync||{};(function(exports,ui_designTokens,ui_buttons,ui_tour,main_popup,main_core_events,calendar_util,main_core){"use strict";const isConnectionItemProperty=Symbol.for("BX.Calendar.Sync.Manager.ConnectionItem.isConnectionItem");class ConnectionItem{constructor(e){this[isConnectionItemProperty]=true;this.syncDate=main_core.Type.isDate(e.syncDate)?e.syncDate:new Date;this.connectionName=e.connectionName;this.status=e.status;this.connected=e.connected;this.addParams=e.addParams;this.type=e.type;this.id=e.type;this.userName=e.userName;this.accountName=e.accountName}static createInstance(e){return new this(e)}static isConnectionItem(e){return main_core.Type.isObject(e)&&e[isConnectionItemProperty]===true}getSyncDate(){return this.syncDate}getConnectionName(){return this.connectionName}getSyncStatus(){return this.status}getConnectStatus(){return this.connected}getStatus(){if(this.connected){return this.status?"success":"failed"}else{return"not_connected"}}getClassLabel(){return this.type}getSections(){return this.addParams.sections}getId(){return this.addParams.id}getConnectionAccountName(){return this.userName}getType(){return this.type}setId(e){this.addParams.id=e}setStatus(e){this.status=e}setUserName(e){this.userName=e}setConnected(e){this.connected=e}setSyncDate(e){this.syncDate=e}getAccountName(){return this.accountName}}class ConnectionProvider extends main_core_events.EventEmitter{constructor(e){super();this.MENU_WIDTH=200;this.MENU_PADDING=7;this.MENU_INDEX=3020;this.SLIDER_WIDTH=606;this.STATUS_SYNCHRONIZING="synchronizing";this.STATUS_SUCCESS="success";this.STATUS_FAILED="failed";this.STATUS_REFUSED="refused";this.STATUS_PENDING="pending";this.STATUS_NOT_CONNECTED="not_connected";this.ERROR_CODE="error";this.STATUS_LIST=[this.STATUS_SYNCHRONIZING,this.STATUS_SUCCESS,this.STATUS_FAILED,this.STATUS_REFUSED,this.STATUS_PENDING,this.STATUS_NOT_CONNECTED];this.WAITING_MODE_MAX_TIME=36e4;this.setEventNamespace("BX.Calendar.Sync.Manager.ConnectionProvider");this.status=e.status;this.connected=e.connected;this.userName=e.userName||"";this.connectionOriginalName=e.connectionOriginalName||"";this.mainPanel=e.mainPanel===true;this.pendingStatus=e.pendingStatus===true;this.gridTitle=e.gridTitle;this.gridColor=e.gridColor;this.gridIcon=e.gridIcon;this.type=e.type;this.viewClassification=e.viewClassification;this.templateClass=e.templateClass;this.connections=[];this.id=e.id||"";this.isStartedReconnecting=false}static createInstance(e){return new this(e)}isActive(){return this.connected}hasMenu(){return false}doSupportReconnectionScenario(){return false}setAdditionalParams(e){this.additionalParams=e}setSyncDate(e){e=parseInt(e);if(e>60){this.syncDate=new Date((new Date).getTime()-e*1e3)}else if(!isNaN(e)){this.syncDate=new Date}else{this.syncDate=null}if(this.getConnection()){this.getConnection().syncDate=this.syncDate}}getSyncDate(){return this.syncDate}setSections(e){this.sections=e}setStatus(e){if(this.STATUS_LIST.includes(e)){this.status=e;if(!this.connected&&(e===this.STATUS_SUCCESS||e===this.STATUS_FAILED)){this.connected=true}else if(this.connected&&e===this.STATUS_NOT_CONNECTED){this.connected=false}}return this}getGridTitle(){return this.gridTitle}getGridColor(){return this.gridColor}getGridIcon(){return this.gridIcon}clearConnections(){this.connections=[]}setConnections(){this.connections.push(ConnectionItem.createInstance({syncDate:this.getSyncDate(),connectionName:this.connectionName,status:this.status,connected:this.connected,userName:this.userName,addParams:{sections:this.sections,id:this.id||this.type},type:this.type,accountName:this.getAccountName()}))}getAccountName(){return this.getType()}setInterfaceUnit(e){this.interfaceUnit=e}getInterfaceUnit(){return this.interfaceUnit}getConnections(){return this.connections}getName(){return this.connectionOriginalName}getConnection(){return this.connections[0]}getType(){return this.type}getViewClassification(){return this.viewClassification}getConnectStatus(){return this.connected}getSyncStatus(){return this.status}getStatus(){if(this.getWizardSyncMode()){return"synchronizing"}if(this.connected){const e=this.status?"success":"failed";if(e==="failed"&&this.isGoogleApplicationRefused){return"refused"}return e}else if(this.pendingStatus){return"pending"}else{return"not_connected"}}getTemplateClass(){return this.templateClass}openSlider(e){BX.SidePanel.Instance.open(e.sliderId,{contentCallback(t){return new Promise(((t,n)=>{t(e.content)}))},data:e.data||{},cacheable:e.cacheable,width:this.SLIDER_WIDTH,allowChangeHistory:false,events:{onLoad:e=>{this.itemSlider=e.getSlider()}}})}closeSlider(){if(this.itemSlider){this.itemSlider.close()}}openInfoConnectionSlider(e=null){const t=this.getClassTemplateItem().createInstance(this,e).getInfoConnectionContent();this.openSlider({sliderId:"calendar:item-sync-connect-"+this.type,content:t,cacheable:false,data:{provider:this}})}openActiveConnectionSlider(e){const t=this.getClassTemplateItem().createInstance(this,e);if(this.type==="google"){t.getSectionsForGoogle().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else if(this.type==="icloud"){t.getSectionsForIcloud().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else if(this.type==="office365"){t.getSectionsForOffice365().then((()=>{this.openActiveConnectionSliderVendor(t,e)}))}else{this.openActiveConnectionSliderVendor(t,e)}}openActiveConnectionSliderVendor(e,t){const n=e.getActiveConnectionContent();this.openSlider({sliderId:"calendar:item-sync-"+t.id,content:n,cacheable:false,data:{provider:this,connection:t,itemInterface:e}})}getClassTemplateItem(){const e=main_core.Reflection.getClass(this.getTemplateClass());if(main_core.Type.isFunction(e)){return e}return null}getConnectionById(e){const t=this.getConnections();if(t.length>0){const n=t.filter((t=>t.getId()==e));if(n){return n[0]}}return null}getSyncPanelTitle(){return this.gridTitle}getSyncPanelLogo(){return"--"+this.type}setWizardSyncMode(e){this.wizardSyncMode=e}getWizardSyncMode(){return this.wizardSyncMode}setWizardState(e){const t=this.getActiveWizard();if(t){if(e.status===this.ERROR_CODE){t.setErrorState(e)}else{t.handleUpdateState(e)}}}setUserName(e=""){this.userName=e;if(this.getConnection()){this.getConnection().setUserName(e)}}setActiveWizard(e){this.activeWizard=e;e.subscribe("onConnectionCreated",this.handleCreatedConnection.bind(this));e.subscribe("onClose",this.handleCloseWizard.bind(this));e.subscribe("startWizardWaitingMode",this.startWaitingMode.bind(this));e.subscribe("endWizardWaitingMode",this.endWaitingMode.bind(this))}getActiveWizard(){return this.activeWizard||null}startWaitingMode(){this.emit("onStartWaitingMode");this.waitingModeReserveTimeout=setTimeout((()=>{if(this.getActiveWizard()&&this.getActiveWizard().getSlider()){BX.reload()}}),this.WAITING_MODE_MAX_TIME)}endWaitingMode(){this.emit("onEndWaitingMode");if(this.waitingModeReserveTimeout){clearTimeout(this.waitingModeReserveTimeout);this.waitingModeReserveTimeout=null}}handleCreatedConnection(){if(this.isStartedReconnecting){this.setWizardSyncMode(false)}this.setStatus(this.STATUS_SUCCESS);this.getInterfaceUnit().setSyncStatus(this.STATUS_SUCCESS);BX.ajax.runAction("calendar.api.syncajax.clearSuccessfulConnectionNotifier",{data:{accountType:this.getType()}});const e=calendar_util.Util.getCalendarContext();if(e){e.syncInterface.refreshDebounce()}if(this.isReconnecting()){this.handleCloseWizard();this.endReconnecting()}}startReconnecting(){if(this.doSupportReconnectionScenario()){this.isStartedReconnecting=true}}endReconnecting(){if(this.doSupportReconnectionScenario()){this.isStartedReconnecting=false}}isReconnecting(){return this.isStartedReconnecting}handleCloseWizard(){const e=this.getActiveWizard();this.setWizardSyncMode(false);if(e&&e.isSyncFinished()){this.setStatus(this.STATUS_SUCCESS);this.getInterfaceUnit().setSyncStatus(this.STATUS_SUCCESS)}else{this.setStatus(this.STATUS_SYNCHRONIZING);this.getInterfaceUnit().setSyncStatus(this.STATUS_SYNCHRONIZING);BX.SidePanel.Instance.getOpenSliders().forEach((e=>{if(["calendar:sync-slider","calendar:section-slider"].includes(e.getUrl())){e.close()}}))}this.getInterfaceUnit().refreshButton();this.emit("onEndWaitingMode");this.emit("onCloseSyncWizard");if(e){e.unsubscribeAll()}}refresh(e){this.status=e.syncInfo.status||false;this.connected=e.syncInfo.connected||false;this.id=e.syncInfo.id||null;if(e.syncLink){this.syncLink=e.syncLink}this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.clearConnections();this.setConnections()}getFailedConnectionName(){return this.getType()}getFirstFailedConnection(){return this.getFailedConnections()[0]}getFailedConnectionsCount(){return this.getFailedConnections().length}getFailedConnections(){return this.connections.filter((e=>e.status===false))}}var _guide=babelHelpers.classPrivateFieldLooseKey("guide");class SyncStatusPopupV2 extends main_core_events.EventEmitter{constructor(e){var t,n;super();Object.defineProperty(this,_guide,{writable:true,value:void 0});this.setEventNamespace("BX.Calendar.Sync.Interface.SyncStatusPopupV2");const s=e.node;const i=e.failedConnection;this.node=s;babelHelpers.classPrivateFieldLooseBase(this,_guide)[_guide]=new ui_tour.Guide({steps:[{target:this.node,title:main_core.Loc.getMessage("CALENDAR_SYNC_MANAGER_AHA_TITLE"),text:this.getText(i),article:null}],onEvents:true,autoHide:true,overlay:false});babelHelpers.classPrivateFieldLooseBase(this,_guide)[_guide].start();this.setAsShown(i);const o=(t=babelHelpers.classPrivateFieldLooseBase(this,_guide)[_guide].getPopup())==null?void 0:(n=t.getPopupContainer())==null?void 0:n.querySelector('[data-id="calendar-sync-manager__aha-link"]');if(o){main_core.Event.bind(o,"click",(()=>{e.onSyncPanelOpen();babelHelpers.classPrivateFieldLooseBase(this,_guide)[_guide].close()}))}babelHelpers.classPrivateFieldLooseBase(this,_guide)[_guide].getPopup().setWidth(390)}static createInstance(e){const t=SyncStatusPopupV2.getNotShownFailedConnection(e);const n=e.status==="failed";const s=e.syncErrors>0;return n&&s&&t?new this({failedConnection:t,...e}):null}static getNotShownFailedConnection(e){return SyncStatusPopupV2.getFailedConnections(e).find((e=>!SyncStatusPopupV2.alreadyShown(e)))}static getFailedConnections(e){const t=[];for(const n in e.connectionsProviders){if(Object.prototype.hasOwnProperty.call(e.connectionsProviders,n)&&e.connectionsProviders[n].getStatus()==="failed"){t.push(...SyncStatusPopupV2.getFailedConnectionsFromProvider(e.connectionsProviders[n]));break}}return t}static getFailedConnectionsFromProvider(e){var t;return(t=e.getConnections())==null?void 0:t.filter((e=>e.getStatus()==="failed"))}static alreadyShown(e){if(main_core.Type.isUndefined(window.localStorage)){return true}const t=`${SyncStatusPopupV2.SYNC_POPUP_KEY}_${e.getConnectionName()}`;const n=window.localStorage.getItem(t);if(!n){return false}const s=JSON.parse(n);const i=new Date;return i.getTime()<s.expire}getText(e){const t=main_core.Text.encode(e.getConnectionName());const n=main_core.Text.encode(e.getAccountName()).trim();const s=`<span class="calendar-sync-manager__aha-content-element-type">${n}</span>`;return`\n\t\t\t<div class="calendar-sync-manager__aha-content">\n\t\t\t\t<div class="calendar-sync-manager__aha-content-element">\n\t\t\t\t\t${main_core.Loc.getMessage("CALENDAR_SYNC_MANAGER_AHA_TEXT_1",{"#PROVIDER_NAME#":t})}\n\t\t\t\t</div>\n\t\t\t\t<div class="calendar-sync-manager__aha-content-element">\n\t\t\t\t\t${main_core.Loc.getMessage("CALENDAR_SYNC_MANAGER_AHA_TEXT_2",{"#PROVIDER#":s})}\n\t\t\t\t</div>\n\t\t\t\t<div class="calendar-sync-manager__aha-link" data-id="calendar-sync-manager__aha-link">\n\t\t\t\t\t${main_core.Loc.getMessage("CALENDAR_SYNC_MANAGER_AHA_LINK")}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t`}setAsShown(e){if(main_core.Type.isUndefined(window.localStorage)){return}const t=new Date;const n=`${SyncStatusPopupV2.SYNC_POPUP_KEY}_${e.getConnectionName()}`;const s={expire:t.getTime()+SyncStatusPopupV2.SYNC_POPUP_TTL};window.localStorage.setItem(n,JSON.stringify(s))}}SyncStatusPopupV2.SYNC_POPUP_KEY="sync_popup";SyncStatusPopupV2.SYNC_POPUP_TTL=3600*24*30*1e3;SyncStatusPopupV2.IS_RUN_REFRESH=false;let _=e=>e,_t;class SyncButton{constructor(e){this.handleClick=()=>{clearTimeout(this.buttonEnterTimeout);(window.top.BX||window.BX).Runtime.loadExtension("calendar.sync.interface").then((e=>{if(!main_core.Dom.hasClass(this.button.button,"ui-btn-clock")){this.syncPanel=new e.SyncPanel({connectionsProviders:this.connectionsProviders,userId:this.userId,status:this.status});this.syncPanel.openSlider()}}))};this.connectionsProviders=e.connectionsProviders;this.wrapper=e.wrapper;this.userId=e.userId;this.status=e.status;this.isGoogleApplicationRefused=e.isGoogleApplicationRefused;this.counters=e.counters;this.payAttentionToNewSharingFeature=e.payAttentionToNewSharingFeature;this.buttonEnterTimeout=null}static createInstance(e){return new this(e)}show(){var e,t;const n=this.getButtonData();this.button=new ui_buttons.Button({round:true,text:n.text,size:ui_buttons.ButtonSize.EXTRA_SMALL,color:n.color,counter:(e=n.counter)!=null?e:0,leftCounter:n.counter?{value:(t=n.counter)!=null?t:0}:"",icon:n.icon||"",className:`ui-btn-themes ${n.iconClass||""}`,onclick:this.handleClick,dataset:{id:"calendar_sync_button"}});this.button.renderTo(this.wrapper);if(!this.payAttentionToNewSharingFeature){this.showAhaMoment(this.button)}}showAhaMoment(e){setTimeout((()=>{var t;SyncStatusPopupV2.createInstance({status:this.status,syncErrors:(t=this.counters.sync_errors)!=null?t:0,connectionsProviders:this.connectionsProviders,node:e.getContainer(),id:"calendar-sync-v2__dialog",onSyncPanelOpen:this.handleClick})}),1e3)}showGoogleApplicationRefusedPopup(){const e=new main_popup.Popup({bindElement:this.button.getContainer(),borderRadius:"3px",className:"calendar-popup-ui-tour-animate",content:main_core.Tag.render(_t||(_t=_` <div class="calendar-sync-popup-status-refused"> <div class="calendar-sync-popup-status-refused-title"> ${0} </div> <div class="calendar-sync-popup-status-refused-text"> ${0} </div> </div> `),main_core.Loc.getMessage("CAL_SYNC_INFO_STATUS_REFUSED_POPUP_TITLE"),main_core.Loc.getMessage("CAL_SYNC_INFO_STATUS_REFUSED_POPUP_TEXT")),width:400,angle:{offset:this.button.getContainer().offsetWidth/2,position:"top"},closeIcon:true,autoHide:true});setTimeout((()=>{e.show();BX.ajax.runAction("calendar.api.syncajax.disableShowGoogleApplicationRefused")}),1e3)}refresh(e,t=null){var n;this.status=e;this.counters=t!=null?t:this.counters;const s=this.getButtonData();this.button.setColor(s.color);this.button.setText(s.text);this.button.removeClass("ui-btn-icon-fail ui-btn-icon-success ui-btn-clock calendar-sync-btn-icon-refused calendar-sync-btn-counter");this.button.addClass(s.iconClass);this.button.setCounter((n=s.counter)!=null?n:0)}getButtonData(){if(this.status==="refused"){return{text:main_core.Loc.getMessage("CAL_BUTTON_STATUS_FAILED_RECONNECT"),color:ui_buttons.ButtonColor.LIGHT_BORDER,icon:ui_buttons.ButtonIcon.REFRESH,iconClass:"calendar-sync-btn-icon-refused"}}switch(this.status){case"success":{return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNCHRONIZATION"),color:ui_buttons.ButtonColor.LIGHT_BORDER,icon:ui_buttons.ButtonIcon.CHECK,iconClass:"ui-btn-icon-success"}}case"failed":{return{text:main_core.Loc.getMessage("STATUS_BUTTON_FAILED"),color:ui_buttons.ButtonColor.LIGHT_BORDER,counter:this.counters.sync_errors||1,iconClass:"calendar-sync-btn-counter"}}case"synchronizing":{return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNCHRONIZATION"),color:ui_buttons.ButtonColor.LIGHT_BORDER,iconClass:"ui-btn-clock"}}default:{return{text:main_core.Loc.getMessage("STATUS_BUTTON_SYNC_CALENDAR_NEW"),color:ui_buttons.ButtonColor.PRIMARY}}}}getSyncPanel(){return this.syncPanel}setConnectionProviders(e){this.connectionsProviders=e}}class GoogleProvider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||"",connectionOriginalName:e.syncInfo.connectionName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_GOOGLE"),gridColor:"#387ced",gridIcon:"/bitrix/images/calendar/sync/google.svg",type:"google",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.GoogleTemplate",mainPanel:e.mainPanel});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_GOOGLE");this.isSetSyncGoogleSettings=e.isSetSyncGoogleSettings;this.syncLink=e.syncLink;this.isGoogleApplicationRefused=e.isGoogleApplicationRefused;this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}doSupportReconnectionScenario(){return true}getSyncLink(){return this.syncLink}hasSetSyncGoogleSettings(){return this.isSetSyncGoogleSettings}saveConnection(){BX.ajax.runAction("calendar.api.syncajax.createGoogleConnection",{data:{}}).then((e=>{var t;if((e==null?void 0:(t=e.data)==null?void 0:t.status)===this.ERROR_CODE){var n,s;if(this.isGoogleApplicationRefused){this.setStatus(this.STATUS_REFUSED)}else{this.setStatus(this.STATUS_FAILED)}this.setWizardState({status:this.ERROR_CODE,vendorName:this.type,accountName:e==null?void 0:(n=e.data)==null?void 0:(s=n.googleApiStatus)==null?void 0:s.googleCalendarPrimaryId})}else{var i,o;this.setWizardState({stage:"connection_created",vendorName:this.type,accountName:e==null?void 0:(i=e.data)==null?void 0:(o=i.googleApiStatus)==null?void 0:o.googleCalendarPrimaryId})}this.emit("onSyncInfoUpdated",new main_core.Event.BaseEvent({data:{syncInfo:e.data.syncInfo}}))}),(e=>{if(this.isGoogleApplicationRefused){this.setStatus(this.STATUS_REFUSED)}else{this.setStatus(this.STATUS_FAILED)}this.setWizardState({status:this.ERROR_CODE,vendorName:this.type})}))}}class Office365Provider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||e.syncInfo.connectionName||"",connectionOriginalName:e.syncInfo.connectionName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_OFFICE365"),gridColor:"#fc1d1d",gridIcon:"/bitrix/images/calendar/sync/office365.svg",type:"office365",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.Office365template",mainPanel:true});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_OFFICE365");this.syncLink=e.syncLink||"";this.isSetSyncOffice365Settings=e.isSetSyncOffice365Settings;this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}doSupportReconnectionScenario(){return true}getSyncLink(){return this.syncLink}hasSetSyncOffice365Settings(){return this.isSetSyncOffice365Settings}saveConnection(){return new Promise((e=>{BX.ajax.runAction("calendar.api.syncajax.createOffice365Connection").then((t=>{var n,s;if((t==null?void 0:(n=t.data)==null?void 0:n.status)===this.provider.ERROR_CODE){this.setStatus(this.provider.STATUS_FAILED);this.setWizardState({status:this.provider.ERROR_CODE,vendorName:this.provider.type})}else if(t!=null&&(s=t.data)!=null&&s.connectionId){this.setStatus(this.provider.STATUS_SUCCESS);this.getConnection().setId(t.data.connectionId);this.getConnection().setStatus(true);this.getConnection().setConnected(true);this.getConnection().setSyncDate(new Date)}e(t.data)}),(t=>{this.setStatus(this.provider.STATUS_FAILED);this.setWizardState({status:this.provider.ERROR_CODE,vendorName:this.provider.type});e(t.errors)}))}))}}class ICloudProvider extends ConnectionProvider{constructor(e){super({id:e.syncInfo.id||null,status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,userName:e.syncInfo.userName||"",connectionOriginalName:e.syncInfo.connectionName||"",gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_ICLOUD"),gridColor:"#948f8f",gridIcon:"/bitrix/images/calendar/sync/icloud.svg",type:"icloud",interfaceClassName:"",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.IcloudTemplate",mainPanel:true});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_ICLOUD");this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}doSupportReconnectionScenario(){return true}getFailedConnectionName(){return"iCloud"}}class AndroidProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_ANDROID"),gridColor:"#9ece03",gridIcon:"/bitrix/images/calendar/sync/android.svg",type:"android",viewClassification:"mobile",templateClass:"BX.Calendar.Sync.Interface.AndroidTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_ANDROID");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}}class CaldavConnection extends ConnectionProvider{constructor(e){super(e)}doSupportReconnectionScenario(){return true}static calculateStatus(e){if(e.length===0){return false}for(let t in e){if(this.isFailedConnections(e[t])){return false}}return true}static isFailedConnections(e){if(e.syncInfo.connected===true&&e.syncInfo.status===false){return true}return false}hasMenu(){return this.connected}showMenu(e){if(this.menu){this.menu.destroy()}const t=this.getMenuItems();t.push(...this.getMenuItemConnect());this.menu=this.getMenu(e,t);this.addMenuHandler();this.menu.show()}addMenuHandler(){if(this.menu){this.menu.getMenuContainer().addEventListener("click",(()=>{this.menu.close()}))}}getMenuItems(){const e=[];this.connections.forEach((t=>{t.type=this.type;t.id=t.addParams.id;t.text=t.connectionName;t.onclick=()=>{this.openActiveConnectionSlider(t)};e.push(t)}));return e}getMenuItemConnect(){return[{delimiter:true},{id:"connect",text:main_core.Loc.getMessage("ADD_MENU_CONNECTION"),onclick:()=>{this.openInfoConnectionSlider()}}]}getMenu(e,t){return new(window.top.BX||window.BX).Main.Menu({className:"calendar-sync-popup-status",bindElement:e,items:t,width:this.MENU_WIDTH,padding:this.MENU_PADDING,zIndexAbsolute:this.MENU_INDEX,autoHide:true,closeByEsc:true,offsetTop:5,id:this.getType()+"-menu"})}setConnections(){if(this.connectionsSyncInfo.length>0){this.connectionsSyncInfo.forEach((e=>{this.connections.push(ConnectionItem.createInstance({connectionName:e.syncInfo.connectionName,status:e.syncInfo.status,connected:e.syncInfo.connected,addParams:{sections:e.sections,id:e.syncInfo.id,userName:e.syncInfo.userName,server:e.syncInfo.server},type:this.type,accountName:this.getAccountName(e)}))}))}}getAccountName(e){return e.syncInfo.connectionName}getFailedConnectionName(){var e;const t=(e=this.getFirstFailedConnection().connectionName)==null?void 0:e.trim();return main_core.Type.isStringFilled(t)?t:super.getFailedConnectionName()}}class CaldavProvider extends CaldavConnection{constructor(e){super({status:e.status,connected:e.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_CALDAV"),gridColor:"#1eae43",gridIcon:"/bitrix/images/calendar/sync/caldav.svg",type:"caldav",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.CaldavTemplate"});this.connectionsSyncInfo=e.connections;if(e.connections&&e.connections[0]&&e.connections[0].syncInfo){this.setSyncDate(e.connections[0].syncInfo.syncOffset)}this.setConnections()}}class ExchangeProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status||false,connected:e.syncInfo.connected||false,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_EXCHANGE"),gridColor:"#54d0df",gridIcon:"/bitrix/images/calendar/sync/exchange.svg",type:"exchange",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.ExchangeTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_EXCHANGE");this.setSyncDate(e.syncInfo.syncOffset);this.setSections(e.sections);this.setConnections()}}class IphoneProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_IPHONE"),gridColor:"#2fc6f6",gridIcon:"/bitrix/images/calendar/sync/iphone.svg",type:"iphone",viewClassification:"mobile",templateClass:"BX.Calendar.Sync.Interface.IphoneTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_IPHONE");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}}class MacProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_MAC"),gridColor:"#ff5752",gridIcon:"/bitrix/images/calendar/sync/mac.svg",type:"mac",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.MacTemplate"});this.portalAddress=e.portalAddress;this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_MAC");this.setSyncDate(e.syncInfo.syncOffset);this.setConnections()}getPortalAddress(){return this.portalAddress}}class OutlookProvider extends ConnectionProvider{constructor(e){super({status:e.syncInfo.status,connected:e.syncInfo.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_OUTLOOK"),gridColor:"#ffa900",gridIcon:"/bitrix/images/calendar/sync/outlook.svg",type:"outlook",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.OutlookTemplate"});this.setSyncDate(e.syncInfo.syncOffset);this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_OUTLOOK");this.sections=e.sections;this.infoBySections=e.infoBySections;this.setConnections()}hasMenu(){return this.sections.length>0}showMenu(e){if(this.hasMenu()){if(this.menu){this.menu.destroy()}const t=this.getConnection().getSections();t.forEach((e=>{if(this.infoBySections[e.id]){e.className="calendar-sync-outlook-popup-item"}e.onclick=()=>{this.connectToOutlook(e)}}));this.menu=new(window.top.BX||window.BX).Main.Menu({className:"calendar-sync-popup-status",bindElement:e,items:t,padding:7,autoHide:true,closeByEsc:true,zIndexAbsolute:3020,id:this.getType()+"-menu",offsetLeft:-40});this.menu.getMenuContainer().addEventListener("click",(()=>{this.menu.close()}));this.menu.show()}}connectToOutlook(section){if(section.id){BX.ajax.runAction("calendar.api.syncajax.getOutlookLink",{data:{id:section.id}}).then((response=>{const url=response.data.result;eval(url)}))}}}class YandexProvider extends CaldavConnection{constructor(e){super({status:e.status,connected:e.connected,gridTitle:main_core.Loc.getMessage("CALENDAR_TITLE_YANDEX"),gridColor:"#f9c500",gridIcon:"/bitrix/images/calendar/sync/yandex.svg",type:"yandex",viewClassification:"web",templateClass:"BX.Calendar.Sync.Interface.YandexTemplate"});this.connectionName=main_core.Loc.getMessage("CALENDAR_TITLE_YANDEX");this.connectionsSyncInfo=e.connections;if(e.connections&&e.connections[0]&&e.connections[0].syncInfo){this.setSyncDate(e.connections[0].syncInfo.syncOffset)}this.setConnections()}getAccountName(e){return main_core.Loc.getMessage("CALENDAR_TITLE_YANDEX")}}let _$1=e=>e,_t$1,_t2,_t3,_t4,_t5;class SyncStatusPopup extends main_core_events.EventEmitter{constructor(e){super();this.setEventNamespace("BX.Calendar.Sync.Interface.SyncStatusPopup");this.connections=e.connections;this.withUpdateButton=e.withUpdateButton;this.node=e.node;this.id=e.id;this.isGoogleApplicationRefused=e.isGoogleApplicationRefused;this.init()}static createInstance(e){return new this(e)}init(){this.setPopupContent()}createPopup(){this.popup=new main_popup.Popup({className:this.id,bindElement:this.node,content:this.container,angle:true,width:360,offsetLeft:60,offsetTop:5,padding:7,darkMode:true,autoHide:true,zIndexAbsolute:3010})}show(){this.createPopup();this.popup.show()}setPopupContent(){this.container=main_core.Tag.render(_t$1||(_t$1=_$1` <div class="calendar-sync-popup-list"></div> `));this.connections.forEach((e=>{if(e.getConnectStatus()!==true){return}const t={};t.syncTime=this.getFormattedTime(e.getSyncDate());t.classStatus=e.getSyncStatus()?"calendar-sync-popup-item-status-success":"calendar-sync-popup-item-status-fail";if(e.id==="google"&&!e.getSyncStatus()&&this.isGoogleApplicationRefused){t.classStatus="calendar-sync-popup-item-status-refused";t.syncTime=null}t.classLable="calendar-sync-popup-item-text-"+e.getClassLabel();t.title=e.getConnectionName();const n=this.getSyncElement(t);this.container.append(n)}));if(this.withUpdateButton){this.container.append(this.getContentRefreshBlock());if(SyncStatusPopup.IS_RUN_REFRESH){this.showRefreshStatus()}}return this.container}hide(){this.popup.destroy()}getContainer(){return this.container}getPopup(){return this.popup}getFormattedTime(e){const t=new Date;let n=e;if(main_core.Type.isDate(e)){n=Math.round(e.getTime()/1e3);let s=parseInt((t-e)/1e3);if(s<60){return main_core.Loc.getMessage("CAL_JUST")}}return BX.date.format([["tommorow","tommorow, H:i:s"],["i","iago"],["H","Hago"],["d","dago"],["m100","mago"],["m","mago"],["-",""]],n)}getSyncElement(e){return main_core.Tag.render(_t2||(_t2=_$1` <div class="calendar-sync-popup-item"> <span class="calendar-sync-popup-item-text ${0}">${0}</span> <div class="calendar-sync-popup-item-detail"> <span class="calendar-sync-popup-item-time">${0}</span> <span class="calendar-sync-popup-item-status ${0}"></span> </div> </div> `),e.classLable,BX.util.htmlspecialchars(e.title),e.syncTime,e.classStatus)}refresh(e){this.connections=e;this.popup.setContent(this.setPopupContent());this.setRefreshStatusBlock()}setRefreshStatusBlock(){setTimeout((()=>{this.removeRefreshStatusBlock();this.enableRefreshButton();SyncStatusPopup.IS_RUN_REFRESH=false}),12e4)}removeRefreshStatusBlock(){if(main_core.Type.isElementNode(this.refreshStatusBlock)){this.refreshStatusBlock.remove()}}enableRefreshButton(){if(main_core.Type.isElementNode(this.refreshButton)){this.refreshButton.className="calendar-sync-popup-footer-btn"}}disableRefreshButton(){if(main_core.Type.isElementNode(this.refreshButton)){this.refreshButton.className="calendar-sync-popup-footer-btn calendar-sync-popup-footer-btn-disabled"}}getContentRefreshBlock(){this.footerWrapper=main_core.Tag.render(_t3||(_t3=_$1` <div class="calendar-sync-popup-footer-wrap"> ${0} </div> `),this.getContentRefreshButton());return this.footerWrapper}getContentRefreshButton(){this.refreshButton=main_core.Tag.render(_t4||(_t4=_$1` <button class="calendar-sync-popup-footer-btn">${0}</button> `),main_core.Loc.getMessage("CAL_REFRESH"));this.refreshButton.addEventListener("click",(()=>{main_core.Dom.addClass(this.refreshButton,"calendar-sync-popup-footer-btn-load");SyncStatusPopup.IS_RUN_REFRESH=true;this.refreshButton.innerText=main_core.Loc.getMessage("CAL_REFRESHING");this.runRefresh()}));return this.refreshButton}showRefreshStatus(){this.disableRefreshButton();this.footerWrapper.prepend(this.getRefreshStatus())}getRefreshStatus(){this.refreshStatusBlock=main_core.Tag.render(_t5||(_t5=_$1` <span class="calendar-sync-popup-footer-status">${0}</span> `),main_core.Loc.getMessage("CAL_REFRESH_JUST"));return this.refreshStatusBlock}runRefresh(){this.emit("onRefresh",{})}getId(){return this.id}}SyncStatusPopup.IS_RUN_REFRESH=false;class Manager extends main_core_events.EventEmitter{constructor(e){super();this.status="not_connected";this.STATUS_SUCCESS="success";this.STATUS_FAILED="failed";this.STATUS_REFUSED="refused";this.STATUS_NOT_CONNECTED="not_connected";this.WIZARD_SYNC_MODE="wizard_sync_mode";this.STATUS_SYNCHRONIZING="synchronizing";this.WAITING_MODE_PERIODIC_TIMEOUT=5e3;this.REFRESH_DELAY=300;this.REFRESH_CONTENT_DELAY=300;this.WIZARD_SLIDER_PREFIX="calendar:sync-wizard";this.setEventNamespace("BX.Calendar.Sync.Manager.Manager");this.isGoogleApplicationRefused=e.calendar.util.config.isGoogleApplicationRefused==="Y";this.showGoogleApplicationRefused=e.calendar.util.config.showGoogleApplicationRefused==="Y";this.wrapper=e.wrapper;this.setSyncInfo(e.syncInfo);this.userId=e.userId;this.syncLinks=e.syncLinks;this.sections=e.sections;this.portalAddress=e.portalAddress;this.isRuZone=e.isRuZone;this.calendarInstance=e.calendar;this.isSetSyncGoogleSettings=e.isSetSyncGoogleSettings;this.isSetSyncOffice365Settings=e.isSetSyncOffice365Settings;this.refreshDebounce=main_core.Runtime.debounce(this.refresh,this.REFRESH_DELAY,this);this.refreshContentDebounce=main_core.Runtime.debounce(this.refreshContent,this.REFRESH_CONTENT_DELAY,this);this.payAttentionToNewSharingFeature=e.payAttentionToNewSharingFeature;this.init();this.subscribeOnEvent()}subscribeOnEvent(){main_core_events.EventEmitter.subscribe("BX.Calendar.Sync.Interface.SyncStatusPopup:onRefresh",(e=>{this.refreshDebounce(e)}));main_core_events.EventEmitter.subscribe("BX.Calendar.Sync.Interface.InterfaceTemplate:onRefresh",(e=>{this.onRefresh(e.data.data,e.data.event)}));main_core_events.EventEmitter.subscribe("BX.Calendar.Sync.Interface.InterfaceTemplate:reDrawCalendarGrid",(e=>{this.reDrawCalendarGrid()}));window.addEventListener("message",(e=>{if(e.data.title==="googleOAuthSuccess"){window.location.reload()}}))}showSyncButton(){var e;this.syncButton=new SyncButton({status:this.status,wrapper:this.wrapper,connectionsProviders:this.connectionsProviders,userId:this.userId,isGoogleApplicationRefused:this.isGoogleApplicationRefused,counters:(e=this.syncInfo.counters)!=null?e:{},payAttentionToNewSharingFeature:this.payAttentionToNewSharingFeature});this.syncButton.show();if(this.needToShowGoogleRefusedPopup()){this.syncButton.showGoogleApplicationRefusedPopup();this.showGoogleApplicationRefused=false}}init(){this.connectionsProviders={};const e=[];const t=[];const n=this.syncInfo;this.sectionsByType=this.sortSections();for(let s in n){if(n.hasOwnProperty(s)){switch(n[s].type){case"yandex":e.push({syncInfo:n[s],sections:this.sectionsByType.caldav["caldav"+n[s].id],isRuZone:this.isRuZone});break;case"caldav":t.push({syncInfo:n[s],sections:this.sectionsByType.caldav["caldav"+n[s].id]});break}}}this.connectionsProviders={google:this.getGoogleProvider(),icloud:this.getIcloudProvider(),office365:this.getOffice365Provider(),caldav:this.getCaldavProvider(t),iphone:this.getIphoneProvider(),android:this.getAndroidProvider(),mac:this.getMacProvider()};if(this.isRuZone){this.connectionsProviders.yandex=this.getYandexProvider(e)}if(!BX.browser.IsMac()&&n.hasOwnProperty("outlook")){this.connectionsProviders.outlook=this.getOutlookProvider()}if(n.hasOwnProperty("exchange")){this.connectionsProviders.exchange=this.getExchangeProvider()}this.status=this.getSummarySyncStatus();this.subscribeEventHandlers()}setSyncMode(e){this.syncMode=e}getSyncMode(){return this.syncMode}isWizardSyncMode(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)&&this.connectionsProviders[e].getWizardSyncMode()){return true}}return false}isSyncInProcess(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)&&this.connectionsProviders[e].getSyncStatus()===this.STATUS_SYNCHRONIZING){return true}}return false}sortSections(){const e=this.sections;const t=[];const n=[];const s=[];const i={};const o=[];const c=[];i.caldav={};e.forEach((e=>{if(e.belongsToView()&&e.data.OUTLOOK_JS&&e.data["EXTERNAL_TYPE"]==="local"){o.push({id:e.id,connectURL:e.data.OUTLOOK_JS,text:e.name})}if(e.data["IS_EXCHANGE"]===true){t.push(e.data)}else if(e.data["GAPI_CALENDAR_ID"]&&e.data["CAL_DAV_CON"]&&e.data["EXTERNAL_TYPE"]!=="local"){n.push(e.data)}else if(e.data["EXTERNAL_TYPE"]==="icloud"){s.push(e.data)}else if(e.data["EXTERNAL_TYPE"]==="office365"){c.push(e.data)}else if(e.data["CAL_DAV_CON"]&&e.data["CAL_DAV_CAL"]){i.caldav["caldav"+e.data["CAL_DAV_CON"]]=e.data}}));i.google=n;i.icloud=s;i.office365=c;i.exchange=t;i.outlook=o;return i}refresh(e){return new Promise((t=>{BX.ajax.runAction("calendar.api.syncajax.updateConnection",{data:{type:"user",requestUid:calendar_util.Util.registerRequestId()}}).then((n=>{this.onRefresh(n.data,e);t()}))}))}onRefresh(e,t={}){this.setSyncInfo(e);this.status=this.getSummarySyncStatus();if(this.needToShowGoogleRefusedPopup()){this.syncButton.showGoogleApplicationRefusedPopup();this.showGoogleApplicationRefused=false}const n=t&&t.getTarget?t.getTarget():null;this.refreshContent(n,t)}refreshContent(e={},t={}){this.init();this.refreshCalendarGrid();if(this.syncButton){this.syncButton.refresh(this.status,this.syncInfo.counters);this.syncButton.setConnectionProviders(this.connectionsProviders)}if(e){this.refreshActivePopup(e);this.refreshOpenSliders(e)}else{this.refreshOpenSliders({},t)}}refreshCalendarGrid(){this.calendarInstance.reload()}refreshActivePopup(e){if(e instanceof SyncStatusPopup&&e.getId()==="calendar-syncPanel-status"){e.refresh(this.getConnections())}else if(this.syncButton.popup instanceof SyncStatusPopup&&this.syncButton.popup.getId()==="calendar-sync-button-status"){this.syncButton.popup.refresh(this.getConnections())}}refreshOpenSliders(e={},t={}){const n=BX.SidePanel.Instance.getOpenSliders();if(n.length>0){n.forEach((n=>{if(n.getUrl()==="calendar:auxiliary-sync-slider"){this.refreshMainSlider(this.syncButton.getSyncPanel())}else if(n.getUrl()==="calendar:sync-slider"&&t.doRefreshMainSlider){this.refreshMainSlider(this.syncButton.getSyncPanel())}else if(n.getUrl().indexOf("calendar:item-sync-")!==-1){this.refreshConnectionSlider(n,e)}}))}}refreshConnectionSlider(e,t){let n=undefined;const s=e.getData().get("itemInterface");const i=e.getData().get("connection");if(i){n=this.connectionsProviders[i.getType()].getConnectionById(i.getId())}if(t instanceof SyncStatusPopup&&n){t.refresh([n])}if(s&&n){s.refresh(n)}e.reload()}refreshMainSlider(e){e.refresh(this.status,this.connectionsProviders)}getConnections(){const e=[];const t=Object.values(this.connectionsProviders);t.forEach((t=>{const n=t.getConnections();if(n.length>0){n.forEach((t=>{if(t.getConnectStatus()===true){e.push(t)}}))}}));return e}reDrawCalendarGrid(){this.calendarInstance.reloadDebounce()}updateSyncStatus(e){for(let t in e.syncInfo){if(e.syncInfo.hasOwnProperty(t)&&this.syncInfo[t]){this.syncInfo[t]={...this.syncInfo[t],...e.syncInfo[t]}}}this.status=this.STATUS_SUCCESS;this.refreshContentDebounce()}addSyncConnection(e){for(const t in e.syncInfo){if(["yandex","caldav"].includes(e.syncInfo[t].type)){BX.reload()}if(BX.Calendar.Util.checkRequestId(e.requestUid)){if(this.syncInfo[t]){this.syncInfo[t]={...this.syncInfo[t],...e.syncInfo[t]}}}}this.status=this.STATUS_SUCCESS;this.refreshContentDebounce()}deleteSyncConnection(e){if(!BX.Calendar.Util.checkRequestId(e.requestUid)){return}if(e.connectionId){for(const t in this.syncInfo){if(this.syncInfo.hasOwnProperty(t)&&this.syncInfo[t]&&parseInt(this.syncInfo[t].id)===parseInt(e.connectionId)){delete this.syncInfo[t]}}}if(e.syncInfo){for(const t in e.syncInfo){if(this.syncInfo[t]){delete this.syncInfo[t]}}}if(this.status!==this.STATUS_NOT_CONNECTED){this.status=this.STATUS_SUCCESS}this.refreshDebounce()}getProviderById(e){let t;for(let n in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(n)&&this.connectionsProviders[n].connected&&["google","caldav","yandex","icloud","office365"].includes(n)){t=this.connectionsProviders[n].getConnectionById(e);if(t){return[this.connectionsProviders[n],t]}}}return[undefined,undefined]}processSyncConnection(e){for(let t in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(t)&&this.connectionsProviders[t].getWizardSyncMode()&&t===(e==null?void 0:e.vendorName)){if(e.accountName){this.connectionsProviders[t].setUserName(e.accountName)}this.connectionsProviders[t].setWizardState(e);break}}}handlePullEvent(e){let t=this.isWizardSyncMode();switch(e.command){case"refresh_sync_status":if(!t){this.updateSyncStatus(e)}break;case"add_sync_connection":if(!t){this.addSyncConnection(e)}break;case"delete_sync_connection":if(!t){this.deleteSyncConnection(e)}break;case"process_sync_connection":if(t){this.processSyncConnection(e)}break}}setSyncInfo(e){this.syncInfo=e}subscribeEventHandlers(){for(let e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)){this.connectionsProviders[e].unsubscribeAll("onStartWaitingMode");this.connectionsProviders[e].unsubscribeAll("onEndWaitingMode");this.connectionsProviders[e].unsubscribeAll("onCloseSyncWizard");this.connectionsProviders[e].subscribe("onStartWaitingMode",this.handleStartWaitingMode.bind(this));this.connectionsProviders[e].subscribe("onEndWaitingMode",this.handleEndWaitingMode.bind(this));this.connectionsProviders[e].subscribe("onCloseSyncWizard",this.handleCloseSyncWizard.bind(this));this.connectionsProviders[e].subscribe("onReconnecting",this.handleReconnecting.bind(this))}}}handleCloseSyncWizard(){if(this.isSyncInProcess()){if(this.syncButton){this.syncButton.refresh(this.STATUS_SYNCHRONIZING)}}else{this.refreshContentDebounce()}}handleReconnecting(){if(this.isSyncInProcess()&&this.syncButton){this.syncButton.refresh(this.STATUS_SYNCHRONIZING)}}handleStartWaitingMode(){this.doPeriodicRefresh()}handleEndWaitingMode(){this.stopPeriodicRefresh()}doPeriodicRefresh(){if(!this.hasOpenedWizard()){return}if(calendar_util.Util.documentIsDisplayingNow()){this.refresh().then((()=>{this.refreshTimeout=setTimeout(this.doPeriodicRefresh.bind(this),this.WAITING_MODE_PERIODIC_TIMEOUT)}))}else{this.refreshTimeout=setTimeout(this.doPeriodicRefresh.bind(this),this.WAITING_MODE_PERIODIC_TIMEOUT)}}stopPeriodicRefresh(){if(this.refreshTimeout){clearInterval(this.refreshTimeout);this.refreshTimeout=null}}openSyncPanel(){this.syncButton.handleClick()}getSummarySyncStatus(){let e=this.STATUS_NOT_CONNECTED;if(this.isStatusFailed()){return this.STATUS_FAILED}for(let t in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(t)){if([this.STATUS_SUCCESS].includes(this.connectionsProviders[t].getStatus())){e=this.connectionsProviders[t].getStatus();break}}}if(e===this.STATUS_NOT_CONNECTED&&this.hasRefusedStatus()){e=this.STATUS_REFUSED}return e}isStatusFailed(){for(const e in this.connectionsProviders){if(Object.prototype.hasOwnProperty.call(this.connectionsProviders,e)){if(this.STATUS_FAILED===this.connectionsProviders[e].getStatus()){return true}}}return false}needToShowGoogleRefusedPopup(){return this.syncButton&&this.isGoogleApplicationRefused&&this.showGoogleApplicationRefused&&this.hasRefusedStatus()}hasRefusedStatus(){for(const e in this.connectionsProviders){if(this.connectionsProviders.hasOwnProperty(e)){if(this.connectionsProviders[e].getStatus()===this.STATUS_REFUSED){return true}}}return false}getGoogleProvider(){if(!this.googleProvider){this.googleProvider=GoogleProvider.createInstance({syncInfo:this.syncInfo.google||{},sections:this.sectionsByType.google||{},syncLink:this.syncLinks.google||null,isSetSyncGoogleSettings:this.isSetSyncGoogleSettings,mainPanel:true,isGoogleApplicationRefused:this.isGoogleApplicationRefused})}else{this.googleProvider.refresh({syncInfo:this.syncInfo.google||{},sections:this.sectionsByType.google||{},syncLink:this.syncLinks.google||null})}return this.googleProvider}getOffice365Provider(){if(!this.office365Provider){this.office365Provider=Office365Provider.createInstance({syncInfo:this.syncInfo.office365||{},sections:this.sectionsByType.office365||{},syncLink:this.syncLinks.office365||null,isSetSyncOffice365Settings:this.isSetSyncOffice365Settings,mainPanel:true})}else{this.office365Provider.refresh({syncInfo:this.syncInfo.office365||{},sections:this.sectionsByType.office365||{},syncLink:this.syncLinks.office365||null})}return this.office365Provider}getIcloudProvider(){if(!this.icloudProvider){this.icloudProvider=ICloudProvider.createInstance({syncInfo:this.syncInfo.icloud||{},sections:this.sectionsByType.icloud||{},mainPanel:true})}else{this.icloudProvider.refresh({syncInfo:this.syncInfo.icloud||{},sections:this.sectionsByType.icloud||{}})}return this.icloudProvider}getCaldavProvider(e){return CaldavProvider.createInstance({status:CaldavConnection.calculateStatus(e),connected:e.length>0,connections:e})}getIphoneProvider(){return IphoneProvider.createInstance({syncInfo:this.syncInfo.iphone})}getAndroidProvider(){return AndroidProvider.createInstance({syncInfo:this.syncInfo.android})}getMacProvider(){return MacProvider.createInstance({syncInfo:this.syncInfo.mac,portalAddress:this.portalAddress})}getYandexProvider(e){return YandexProvider.createInstance({status:CaldavConnection.calculateStatus(e),connected:e.length>0,connections:e})}getOutlookProvider(){return OutlookProvider.createInstance({syncInfo:this.syncInfo.outlook,sections:this.sectionsByType.outlook,infoBySections:this.syncInfo.outlook.infoBySections||{}})}getExchangeProvider(){return ExchangeProvider.createInstance({syncInfo:this.syncInfo.exchange,sections:this.sectionsByType.exchange})}hasOpenedWizard(){const e=BX.SidePanel.Instance.getOpenSliders();for(let t in e){if(e.hasOwnProperty(t)&&e[t].getUrl().indexOf(this.WIZARD_SLIDER_PREFIX)!==-1){return true}}return false}}exports.Manager=Manager;exports.SyncButton=SyncButton;exports.SyncStatusPopup=SyncStatusPopup;exports.SyncStatusPopupV2=SyncStatusPopupV2;exports.ConnectionItem=ConnectionItem})(this.BX.Calendar.Sync.Manager=this.BX.Calendar.Sync.Manager||{},BX,BX.UI,BX.UI.Tour,BX.Main,BX.Event,BX.Calendar,BX); //# sourceMappingURL=manager.bundle.map.js