function AdfDhtmlActiveData(){this.Init()}AdfObject.createSubclass(AdfDhtmlActiveData);
AdfDhtmlActiveData.prototype.Init=function(){AdfDhtmlActiveData.superclass.Init.call(this);this._activeComponents={};this._serverTimeDifference=0;this._isWindowClosing=!1;this._lastPollTime=null;this._reconnectRetries=this._lastActiveDataActivityTime=0;this._restartInterval=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.restartInterval;this._maxReconnectionRetries=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.maxReconnectionRetries;this._reconnectWaitTime=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.reconnectWaitTime;
this._latencyThreshold=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.latencyThreshold;this._transport=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.transport;this._pollingInterval=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.pollingInterval;this._keepAliveInterval=AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG.keepAliveInterval;this._pollingTimer=null;this._totalPushIFrameContentSinceLastReset=0;this._adsConnectionStateListeners=[];this._messageCount=0};
AdfDhtmlActiveData.prototype.requestStatusChanged=function(a){a.getStatus()==AdfDataTransferRequestEvent.STATUS_COMPLETE&&200==a.getResponseStatusCode()&&a.isRichResponse()&&AdfPage.PAGE.requestStatusChanged(a)};AdfDhtmlActiveData._requestCallback=function(a){AdfLogger.LOGGER.finer("Request complete:",a);var b=AdfPage.PAGE.getDataTransferService(!0,!0);b&&b._handleRequestCallback(a)};
AdfDhtmlActiveData.prototype.initializeActiveForm=function(a,b){AdfAssert.assertBoolean(a);this._ACTIVE_FORM_URL=a?b+"/adwwls/wls.ads":"adw.jspx"};
AdfDhtmlActiveData.prototype.updateActiveDataComponents=function(a,b,d,e,f,g){AdfAssert.assertString(a);this._setMasterWindowId(a);this._setMasterPageId(b);AdfPage.PAGE.setPageId(d);var h=arguments.length;AdfAssert.assert(0==h%2,"An equal number of clientId and changeCount parameters are required");for(var k=this._activeComponents,l=4;l<h;l++){var m=arguments[l];AdfAssert.assertString(m);l++;var n=arguments[l];AdfAssert.assertNumber(n);var q=!(m in k);k[m]={};k[m].changeCount=n;if(e||q)AdfLogger.LOGGER.fine("Register active data on:",
m),this._admInitialized||this.initActivePage(),AdfPage.PAGE.updateStartActiveDataStateChange(e,m),(m=AdfPage.PAGE.findComponent(m))&&m.registerADSAccessibility()}};AdfDhtmlActiveData.prototype._registerWindowWithADSMaster=function(a){AdfAssert.assert(a);this._windowNameToWindow[a.name]=a};
AdfDhtmlActiveData.prototype._initializeADSIFrame=function(){var a=this._ACTIVE_FRAME_NAME,b=AdfPage.PAGE.getDomWindow(),a=b.frames[a];AdfPage.PAGE.getDomDocument();var d=this._ACTIVE_FORM_URL,d=d+("?action\x3d"+this._ESTABLISH_CHANNEL_ACTION+"\x26windowId\x3d"+AdfPage.PAGE.getWindowId()+"\x26pageId\x3d"+AdfPage.PAGE.getPageId()+"\x26replaceMasterWindowId\x3d"+this._replaceMasterWindowId+"\x26replaceMasterPageId\x3d"+this._replaceMasterPageId);AdfLogger.LOGGER.fine("Connecting for master window:",
AdfPage.PAGE.getWindowId()," in window:",b.name);this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.CONNECTING);a.location.replace(d)};
AdfDhtmlActiveData.prototype._processPushData=function(a,b,d,e,f,g){AdfAssert.assertString(a);AdfAssert.assert(void 0!==b);AdfAssert.assertNumber(d);AdfAssert.assertBoolean(g);AdfAssert.assertNumberOrNull(f);var h=AdfPage.PAGE.findComponent(a),k=!1;h?(e&&AdfLogger.LOGGER.fine("Event received beyond the configured threshold for component:",a),e=this._activeComponents[a].changeCount,void 0===e?AdfLogger.LOGGER.severe("Active data for unregistered component:",a):d>e?(k=h.processPushData(b,d),void 0!==
f&&(b=(new Date).getTime(),0==f%500&&AdfLogger.LOGGER.info("ADS: GENERAL: component finished processing event : "," windowId:",AdfPage.PAGE.getWindowId()," pageId:",AdfPage.PAGE.getPageId()," clientId:",a," eventId:",d," client time:",b," event number:",f),g&&AdfLogger.LOGGER.info("ADS: component finished processing event : "," windowId:",AdfPage.PAGE.getWindowId()," pageId:",AdfPage.PAGE.getPageId()," clientId:",a," eventId:",d," client time:",b)),this._activeComponents[a].changeCount=d):AdfLogger.LOGGER.fine("Old active data for",
a," declined")):AdfLogger.LOGGER.fine("No active component:",a," Deregestering component");return k};
AdfDhtmlActiveData.prototype.processActiveDataEvent=function(a,b,d,e,f,g,h,k,l){AdfAssert.assertString(a);AdfAssert.assertString(b);AdfAssert.assertString(d);AdfAssert.assertObject(e);AdfAssert.assertNumber(f);AdfAssert.assertNumber(g);AdfAssert.assertNumber(h);AdfAssert.assertNumber(l);AdfAssert.assertNumberOrNull(k);"STREAMING"==this._transport&&(this._totalPushIFrameContentSinceLastReset+=h,25E6<=this._totalPushIFrameContentSinceLastReset&&(AdfLogger.LOGGER.info("ADS: Reached max events threshold. Rloading the streming iframe."),
this._totalPushIFrameContentSinceLastReset=0,this._makeADSChannelRequest(!0,!0,!0)));this._lastActiveDataActivityTime=(new Date).getTime();this._messageCount++;void 0!==k&&(0==k%500&&AdfLogger.LOGGER.info("ADS: GENERAL: active data manager receives event : "," windowId:",a," pageId:",b," clientId:",d," eventId:",f," event generation time:",g," client time:",this._lastActiveDataActivityTime," event number:",k),l&&AdfLogger.LOGGER.info("ADS: active data manager receives event : "," windowId:",a," pageId:",
b," clientId:",d," eventId:",f," event generation time:",g," client time:",this._lastActiveDataActivityTime));if(h=this._getTargetPage(a))h.getPageId()==b?(a=this._getMilliSecondsBehind(g)>this._latencyThreshold,void 0!==k?h.getActiveDataSupport()._processPushData(d,e,f,a,k,1==l):h.getActiveDataSupport()._processPushData(d,e,f,a)):this._logPageMismatchReason(h.getPageId(),b,a)};
AdfDhtmlActiveData.prototype._logPageMismatchReason=function(a,b,d){var e=Number(a),f=Number(b);isNaN(e)?AdfLogger.LOGGER.error("Invalid target pageId: ",a," windowId: ",d):isNaN(f)?AdfLogger.LOGGER.error("Invalid request pageId: ",b," windowId: ",d):e<f?AdfLogger.LOGGER.error("Data update is newer than current page"," request pageId: ",b," current pageId: ",a," windowId: ",d):e>f&&AdfLogger.LOGGER.info("Old data update is discarded for pageId: ",b," current pageId: ",a," windowId: ",d)};
AdfDhtmlActiveData.prototype._getTargetPage=function(a){AdfAssert.assertString(a);if(a==AdfPage.PAGE.getWindowId())return AdfPage.PAGE;var b=null,d=this._windowNameToWindow;null!=d&&(b=d[a]);d=null;if(this._testAdfPageExistence(b))try{d=b.AdfPage.PAGE}catch(e){AdfLogger.LOGGER.fine("Could not access active window:",a)}return d};
AdfDhtmlActiveData.prototype._refreshPushComponent=function(a){AdfAssert.assertString(a);if(!(a in this._activeComponents))return AdfLogger.LOGGER.info("ADS: active data component is not refreshed because it's not active, clientId\x3d",a),!1;var b=AdfPage.PAGE.findComponent(a);if(b)return AdfPage.PAGE.addPartialTargets(b),!0;this._stopActiveData(a);AdfLogger.LOGGER.info("No active component:",a);return!1};
AdfDhtmlActiveData.prototype.restartAllPushComponents=function(){this._messageCount=1;var a=this._getRegistryMap(),b;for(b in a)if(currWindow=a[b],this._testAdfPageExistence(currWindow)){var d=currWindow.AdfPage.PAGE;d.isActiveDataSupported()&&d.getActiveDataSupport()._restartAllPushComponents()}};AdfDhtmlActiveData.prototype._restartAllPushComponents=function(){AdfPage.PAGE.__restartAllADSComponents()};
AdfDhtmlActiveData.prototype._notifyADSConnectionStateChange=function(a){AdfAssert.assert(this._masterWindowId==AdfPage.PAGE.getWindowId(),"_notifyADSConnectionStateChange should not be called on a non-master window");var b=void 0,d=this._getRegistryMap(),e;for(e in d)if(b=d[e],this._testAdfPageExistence(b))try{b.AdfPage.PAGE.getActiveDataSupport()._broadcastADSConnectionStateChange(a)}catch(f){AdfLogger.LOGGER.logErrorAsWarning(f,"Error broadcasting ADS connection state to window ",e)}};
AdfDhtmlActiveData.prototype._stopActiveData=function(a){AdfAssert.assertString(a);delete this._activeComponents[a];AdfPage.PAGE.updateStopActiveDataStateChange(a)};
AdfDhtmlActiveData.prototype._setBodyCursorForActivePage=function(){if(AdfAgent.AGENT.getPlatform()==AdfAgent.GECKO_PLATFORM){var a=AdfPage.PAGE.getDomDocument(),b=AdfPage.PAGE.getResourceURL("/afr/default_arrow_black.cur");AdfAgent.AGENT.getOS()==AdfAgent.WINDOWS_OS&&(b=AdfPage.PAGE.getResourceURL("/afr/default_arrow_white.cur"));a.body.style.cursor="url('"+b+"'), progress"}};AdfDhtmlActiveData.prototype.initActivePage=function(){this._admInitialized||null==this._getMasterWindowId()||this._initActivePage()};
AdfDhtmlActiveData.prototype._initActivePage=function(){var a=AdfPage.PAGE.getDomWindow();AdfAssert.assert(a.AdfDhtmlActiveData,"AdfActiveDataService JavaScript feature not loaded. Please make sure it is not blocked by ad block software.");var b=this._getMasterWindowId(),d=this._getMasterPageId(),e=AdfPage.PAGE.getPageId(),f=null,f=a.name?a.name:this._expectedWindowId;if(!this._admInitialized){this._setBodyCursorForActivePage();this._admInitialized=!0;this._initAdm();var g=this._wrapMasterWindowId(b);
if(b==AdfPage.PAGE.getWindowId())AdfLogger.LOGGER.info("self is master window: ",b),null==this._windowNameToWindow&&(this._windowNameToWindow={}),a.name=g,AdfPage.PAGE.setWindowId(f),this._setMasterWindowId(b),this._setReplaceMasterWindowId(b),AdfPage.PAGE.setPageId(e),this._setMasterPageId(d),this._setReplaceMasterPageId(d),this._setMasterWindowRef(a),this._registerWindowWithADSMaster(a),this._initializeADSIFrame();else if(a.name==g)this._claimMaster(b,d);else{AdfLogger.LOGGER.info("non-master window, needs to register with: ",
b);a.name=f;var g=null,h=this._getADSMasterWindow(b);null!=h?(g=h.AdfPage.PAGE,g.getActiveDataSupport()._registerWindowWithADSMaster(a),AdfPage.PAGE.setWindowId(f),this._setMasterWindowId(b),this._setReplaceMasterWindowId(b),AdfPage.PAGE.setPageId(e),this._setMasterPageId(d),this._setReplaceMasterPageId(d),this._setMasterWindowRef(h)):(AdfPage.PAGE.setWindowId(a.name),AdfPage.PAGE.setPageId(e),this._claimMaster(b,d))}}};
AdfDhtmlActiveData.prototype._initAdm=function(){AdfLogger.LOGGER.fine("Initialize active data manager");this._replaceMasterPageId=this._masterPageId=this._replaceMasterWindowId=this._masterWindowRef=this._masterWindowId=void 0;this._ESTABLISH_CHANNEL_ACTION="establishChannel";this._RECONNECT_ACTION="reconnect";this._POLL_EVENTS_ACTION="pollEvents";this._ACTIVE_FRAME_NAME="afr::PushIframe";this._ACTIVE_FORM_NAME="_activeDataForm";this._ACTIVE_WINDOW_REGISTRY_MAP=this._windowNameToWindow};
AdfDhtmlActiveData.prototype._getADSMasterWindow=function(a){AdfAssert.assertString(a);var b=AdfPage.PAGE.getDomWindow().open("",a,"height\x3d1,width\x3d1,top\x3d0,left\x3d0,status\x3dno,toolbar\x3dno,menubar\x3dno,location\x3dno");if(!this._testAdfPageExistence(b)||b.AdfPage.PAGE.getActiveDataSupport()._getMasterWindowId()!=a){AdfLogger.LOGGER.warning("can't get the master window for: ",a);try{var d=b.location;null!=d&&"about:blank"!=d&&"about:Tabs"!=d||b.close()}catch(e){}b=null}return b};
AdfDhtmlActiveData.prototype._getRegistryMap=function(){null==this._windowNameToWindow&&(this._windowNameToWindow={});return this._windowNameToWindow};AdfDhtmlActiveData.prototype._setMasterWindowId=function(a){this._masterWindowId=a};AdfDhtmlActiveData.prototype._getMasterWindowId=function(){return this._masterWindowId};AdfDhtmlActiveData.prototype._getMasterPageId=function(){return this._masterPageId};AdfDhtmlActiveData.prototype._setMasterPageId=function(a){this._masterPageId=a};
AdfDhtmlActiveData.prototype._setMasterWindowRef=function(a){this._masterWindowRef=a};AdfDhtmlActiveData.prototype._setReplaceMasterWindowId=function(a){this._replaceMasterWindowId=a};AdfDhtmlActiveData.prototype._setReplaceMasterPageId=function(a){this._replaceMasterPageId=a};AdfDhtmlActiveData.prototype._getActiveFrame=function(){return AdfPage.PAGE.getDomWindow().frames[this._ACTIVE_FRAME_NAME]};AdfDhtmlActiveData.prototype._getClientStateMap=function(){return this._activeComponents};
AdfDhtmlActiveData.prototype.onBeforeUnload=function(){this._isWindowClosing=!0;var a=this._getMasterWindowId();a&&(a==AdfPage.PAGE.getWindowId()&&1!=this._handlingFailover&&this._handleADSChannelMigration(),AdfPage.PAGE.__notifyWindowCloseImmediately(!1,""))};
AdfDhtmlActiveData.prototype._cancelADSTimers=function(){var a=AdfPage.PAGE,b=this._adsConnectionCheckTimer;if(b){try{a.cancelTimer(b)}catch(d){AdfLogger.LOGGER.logErrorAsInfo(d,"Error clearing connection check timer")}this._adsConnectionCheckTimer=null}if(b=this._pollingTimer){try{a.cancelTimer(b)}catch(d){AdfLogger.LOGGER.logErrorAsInfo(d,"Error clearing polling timer")}this._pollingTimer=null}};
AdfDhtmlActiveData.prototype._handleADSChannelMigration=function(){try{this._cancelADSTimers();var a=this._getRegistryMap(),b=this._findYoungestWindow(a);if(null==b)AdfLogger.LOGGER.fine("Could not find candidate window to migrate to");else{var d=b.AdfPage.PAGE,e=d.getActiveDataSupport(),f=e._getRegistryMap();AdfCollections.copyInto(f,a);b.name=this._wrapMasterWindowId(d.getWindowId());e._setReplaceMasterWindowId(page.getWindowId());e._setReplaceMasterPageId(page.getPageId());e._setMasterWindowId(d.getWindowId());
e._setMasterPageId(d.getPageId());d.scheduleTimer(e,e._createADSChannel,null,50)}}catch(g){AdfLogger.LOGGER.info("Can not migrate the active channel to other windows")}};AdfDhtmlActiveData.prototype._createADSChannel=function(a){this._makeADSChannelRequest(!0,a)};AdfDhtmlActiveData.prototype.registerWithNewMaster=function(a,b){AdfPage.PAGE.scheduleTimer(this,this._registerWithNewMaster,{wId:a,pId:b},3E3)};
AdfDhtmlActiveData.prototype._registerWithNewMaster=function(a){var b=a.wId;a=a.pId;AdfLogger.LOGGER.info("register with new master ",b);this._setMasterWindowId(b);this._setMasterPageId(a);try{var d=this._getADSMasterWindow(b);if(null!=d){this._setMasterWindowRef(d);var e=d.AdfPage.PAGE;if(null!=e){e.getActiveDataSupport()._registerWindowWithADSMaster(AdfPage.PAGE.getDomWindow());var f=this._getRegistryMap(),g=e.getActiveDataSupport()._getRegistryMap();AdfCollections.copyInto(g,f)}}else AdfLogger.LOGGER.fine("can't find the master page "+
b),this._claimMaster(b,a);this._pushChannelState!=AdfDhtmlPage.PushChannelStates.CONNECTED&&e.getActiveDataSupport()._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.CONNECTED);this._startGlobalActiveData();this._triedRegisterWithMaster=!1}catch(h){AdfLogger.LOGGER.info("ADS register with new master failed"),this._triedRegisterWithMaster?(this._claimMaster(b,a),this._triedRegisterWithMaster=!1,this._pushChannelState!=AdfDhtmlPage.PushChannelStates.CONNECTED&&e.getActiveDataSupport()._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.CONNECTED)):
(this._triedRegisterWithMaster=!0,this.registerWithNewMaster(b,a))}this._windowNameToWindow=null};AdfDhtmlActiveData.prototype._findYoungestWindow=function(a){var b=void 0,d=void 0,e=AdfPage.PAGE.getDomWindow(),f;for(f in a)b=a[f],b!=e&&this._testAdfPageExistence(b)&&(b.AdfPage.PAGE.getActiveDataSupport().isHAMigrated()||(d=a[f]));return d};
AdfDhtmlActiveData.prototype._createADSChannelParameterMap=function(a){var b=void 0;null==this._replaceMasterWindowId&&(this._replaceMasterWindowId=this._masterWindowId);b=void 0;b=1!=a?this._ESTABLISH_CHANNEL_ACTION:this._RECONNECT_ACTION;b={action:b,windowId:AdfPage.PAGE.getWindowId(),replaceMasterWindowId:this._replaceMasterWindowId,pageId:AdfPage.PAGE.getPageId(),replaceMasterPageId:this._replaceMasterPageId};a?b.messageCount=this._messageCount:this._messageCount=0;return b};
AdfDhtmlActiveData.prototype._createADSClientStateMap=function(a){var b={};if(a){a=this._getRegistryMap();for(var d in a){var e=a[d];try{if(this._testAdfPageExistence(e)){var f=e.AdfPage.PAGE,g=f.getPageId();b[d+":"+g]=f.getActiveDataSupport()._getClientStateMap()}}catch(h){AdfLogger.LOGGER.logErrorAsInfo(h,"Could not access active page:"+d)}}}else{d=AdfPage.PAGE.getDomWindow();try{this._testAdfPageExistence(d)&&(b[AdfPage.PAGE.getWindowId()]=this._getClientStateMap())}catch(h){AdfLogger.LOGGER.logErrorAsInfo(h,
"Could not access active page:"+d.name)}}return b};AdfDhtmlActiveData.prototype._makeADSChannelRequest=function(a,b,d){a=this._createADSChannelParameterMap(b);AdfPage.PAGE.getDomWindow();this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.RECONNECTING);this._sendADSChannelRequest(a,{},d)};
AdfDhtmlActiveData.prototype._claimMaster=function(a,b){AdfAssert.assertString(a);AdfAssert.assertString(b);var d=AdfPage.PAGE.getWindowId(),e=AdfPage.PAGE.getPageId();null==this._windowNameToWindow&&(this._windowNameToWindow={});this._setMasterWindowId(d);this._setReplaceMasterWindowId(a);this._setMasterPageId(e);this._setReplaceMasterPageId(b);d=AdfPage.PAGE.getDomWindow();this._setMasterWindowRef(d);this._registerWindowWithADSMaster(d);this._createADSChannel()};
AdfDhtmlActiveData.prototype._wrapMasterWindowId=function(a){return a.replace(/\//g,"S").replace(/-/g,"M").replace(/\./g,"D")};AdfDhtmlActiveData.prototype._testAdfPageExistence=function(a){var b=null;try{b=a.AdfPage.PAGE}catch(d){AdfLogger.LOGGER.logErrorAsInfo(d,"Could not access active window")}return null!=b?!0:!1};AdfDhtmlActiveData._DEFAULT_ACTIVEDATA_CONFIG={restartInterval:15,maxReconnectionRetries:10,reconnectWaitTime:1E4,latencyThreshold:1E4,transport:"STREAMING",pollingInterval:5E3,keepAliveInterval:1E4};
AdfDhtmlActiveData.prototype.initLongPolling=function(){var a=AdfPage.PAGE,b=a.__getUserInactivityTimeoutHelper();if(b&&b.hasTimedOut())return this._longPollingInitTimer||(this._longPollingInitTimer=a.scheduleTimer(this,this.initLongPolling,null,300)),300;this._longPollingInitTimer&&(a.cancelTimer(this._longPollingInitTimer),this._longPollingInitTimer=null);a={action:this._POLL_EVENTS_ACTION,windowId:a.getWindowId(),pageId:a.getPageId()};this._sendADSChannelRequest(a,null);this.setConnected()};
AdfDhtmlActiveData.prototype.setConfiguration=function(a){try{this._transport=a.transport,this._pollingInterval=a.pollingInterval,this._maxReconnectionRetries=a.maxReconnectionRetries,this._reconnectWaitTime=a.reconnectWaitTime,this._latencyThreshold=a.latencyThreshold,this._restartInterval=a.restartInterval,this._keepAliveInterval=a.keepAliveInterval}catch(b){AdfLogger.LOGGER.warning("Exception occurred while setting configuration. Name: "+b.name+", Message: "+b.message)}};
AdfDhtmlActiveData.prototype.refreshPushComponent=function(a,b,d){AdfAssert.assertString(a);AdfAssert.assertString(b);AdfAssert.assertString(d);this._lastActiveDataActivityTime=(new Date).getTime();this._messageCount++;b=null;var e=this._windowNameToWindow;null!=e&&(b=e[a]);if(this._testAdfPageExistence(b))try{b.AdfPage.PAGE.getActiveDataSupport()._refreshPushComponent(d)}catch(f){AdfLogger.LOGGER.fine("can't access the window ",a)}else AdfLogger.LOGGER.info("No window found for refreshing component: windowId \x3d ",
a)};
AdfDhtmlActiveData.prototype._sendADSChannelRequest=function(a,b,d){var e=AdfPage.PAGE.getDomWindow().frames[this._ACTIVE_FRAME_NAME],f="",g;for(g in a)f+="\x26"+g+"\x3d"+a[g];a=1;for(var h in b){g=b[h];if(!AdfCollections.isEmpty(g)){var f=f+("\x26pageKey"+a+"\x3d"+h),k;for(k in g)var l="componentIndex"+a,f=f+("\x26componentId"+a+"\x3d"+k),f=f+("\x26"+l+"\x3d"+g[k].changeCount)}a+=1}b=f.indexOf("\x26");0<f.length&&0==b&&(f=f.substring(1));f=this._ACTIVE_FORM_URL+"?"+f;"STREAMING"==this._transport?(1==
d&&(f+="\x26discEvt\x3dtrue"),2E3<f.length&&this._handleAllFailovers([]),e.location.replace(f)):this._pollingRequest=AdfPage.PAGE.getDataTransferService(!1,!0).sendPollingRequest(f,[this])};AdfDhtmlActiveData.prototype.setServerTimestamp=function(a){this._serverTimeDifference=AdfDhtmlActiveData._getTimeDifference(a);this._perfProfileEnabled&&AdfLogger.PROFILER_LOGGER.info("ADS: Server time difference: ",this._serverTimeDifference,";;")};
AdfDhtmlActiveData._getTimeDifference=function(a){return null==a?0:new Date-new Date(a)};AdfDhtmlActiveData.prototype._getMilliSecondsBehind=function(a){return AdfDhtmlActiveData._getTimeDifference(a)-this._serverTimeDifference};AdfDhtmlActiveData.prototype.recordActiveDataActivity=function(){this._messageCount++;var a=(new Date).getTime();this._lastActiveDataActivityTime=a;AdfLogger.LOGGER.finer(a,": got keep alive")};
AdfDhtmlActiveData.prototype._handleDisconnect=function(){AdfLogger.LOGGER.finer("ADS Channel Disconnected");this._reconnectRetries=0;this._isWindowClosing?AdfLogger.LOGGER.finer("Closing window ... will not try to reconnect"):(this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.RECONNECTING),this._reconnect())};
AdfDhtmlActiveData.prototype.setConnected=function(){AdfLogger.LOGGER.finer("ADS Channel Connected");this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.CONNECTED);"POLLING"==this._transport&&(this._pollSucceeded=!0);this._lastActiveDataActivityTime=this._reconnectRetries=0;var a=AdfPage.PAGE.getPageId();this._setMasterPageId(a);this._setReplaceMasterPageId(a);a=AdfPage.PAGE.getWindowId();this._setMasterWindowId(a);this._setReplaceMasterWindowId(a);"POLLING"==this._transport?this._startPolling():
(AdfPage.PAGE.getDomWindow(),this._prepareAdsConnectionTimer());AdfPage.PAGE.__perfTimings(!1,!1,!1,"ADS channel connected")};
AdfDhtmlActiveData.prototype.stop=function(){AdfLogger.LOGGER.finer("ADS stopped due to user inactivity timeout.");var a=AdfPage.PAGE;if("LONG_POLLING"==this._transport){if(this._pollingRequest)try{this._pollingRequest.abort(),delete this._pollingRequest,this._pollingRequest=null}catch(e){AdfLogger.LOGGER.fine("Failed to abort Long-Polling request due to error: ",e.message)}}else if("STREAMING"==this._transport){var b=this._ACTIVE_FRAME_NAME,d=a.getDomWindow();(b=d.frames[b])&&b.frameElement&&(b.frameElement.src=
"");AdfLogger.LOGGER.fine("Terminate the push channel for master window:",a.getWindowId()," in window:",d.name)}};AdfDhtmlActiveData.prototype._prepareAdsConnectionTimer=function(){this._adsConnectionCheckTimer&&AdfPage.PAGE.cancelTimer(this._adsConnectionCheckTimer);this._adsConnectionCheckTimer=AdfPage.PAGE.scheduleTimer(this,this.__checkAdsConnection,null,this._latencyThreshold+this._keepAliveInterval)};
AdfDhtmlActiveData.prototype.__checkAdsConnection=function(){var a=AdfPage.PAGE,b=a.__getUserInactivityTimeoutHelper();if(b&&b.hasTimedOut())return 300;var b=this._latencyThreshold,d=this._keepAliveInterval;if(this._pushChannelState==AdfDhtmlPage.PushChannelStates.CONNECTED&&this._getMasterWindowId()==AdfPage.PAGE.getWindowId()){var e=!1;"STREAMING"==this._transport&&(e="complete"==a.getDomWindow().frames[this._ACTIVE_FRAME_NAME].document.readyState);a=AdfDhtmlActiveData._getTimeDifference(this._lastActiveDataActivityTime);
(e||a>b+d)&&this._handleDisconnect()}return b+d};
AdfDhtmlActiveData.prototype._pollForEvents=function(){var a=AdfPage.PAGE.__getUserInactivityTimeoutHelper();if(!a||!a.hasTimedOut()){var a={action:this._POLL_EVENTS_ACTION,windowId:AdfPage.PAGE.getWindowId(),pageId:AdfPage.PAGE.getPageId()},b=this._createADSClientStateMap(!0);this._lastPollTime=(new Date).getTime();this._notifyADSConnectionStateChange(this._pollSucceeded?AdfDhtmlPage.PushChannelStates.CONNECTING:AdfDhtmlPage.PushChannelStates.RECONNECTING);this._pollSucceeded=!1;this._sendADSChannelRequest(a,
b)}};
AdfDhtmlActiveData.prototype._reconnect=function(){this._isWindowClosing?this._reconnectRetries=0:(AdfLogger.LOGGER.fine("Reconnect called ",this._reconnectRetries+1," time(s)"),this._pushChannelState!=AdfDhtmlPage.PushChannelStates.CONNECTED&&(this._reconnectRetries<=this._maxReconnectionRetries?(this._reconnectRetries++,AdfAgent.AGENT.getPlatform()==AdfAgent.GECKO_PLATFORM&&3<this._reconnectRetries&&AdfPage.PAGE.getDomWindow().stop(),this._createADSChannel(!0),AdfPage.PAGE.scheduleTimer(this,this._reconnect,
null,this._reconnectWaitTime)):(AdfLogger.LOGGER.warning("Cannot connect. Exceeded number of retries for reconnection"),this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.DISCONNECTED))))};AdfDhtmlActiveData.prototype.getADSConnectionState=function(){return this._pushChannelState};AdfDhtmlActiveData.prototype.addADSConnectionStateListener=function(a,b){AdfAssert.assertFunction(a);AdfAssert.assertObjectOrNull(b);this._adsConnectionStateListeners.push(a,b)};
AdfDhtmlActiveData.prototype.removeADSConnectionStateListener=function(a,b){AdfAssert.assertFunction(a);AdfAssert.assertObjectOrNull(b);var d=this._adsConnectionStateListeners;AdfAssert.assert(d,"adsConnectionStateListeners array must exist");for(var e=d.length,f=0;f<e;f++){var g=d[f];f++;g==a&&d[f]===b&&d.splice(f-1,2)}};
AdfDhtmlActiveData.prototype._broadcastADSConnectionStateChange=function(a){var b=this._pushChannelState;if(b==a)AdfLogger.LOGGER.finest("broadcastADSConnectionStateChange called without a change in state");else{this._pushChannelState=a;var d=this._adsConnectionStateListeners;if(d){var e=d.length;if(0<e)for(a=new AdfPropertyChangeEvent(this,"adsConnectionState",b,a),b=0;b<e;b++){var f=d[b];b++;var g=d[b];try{null!=g?f.call(g,a):f(a)}catch(h){AdfLogger.LOGGER.logErrorAsWarning(h,"Error broadcasting ADS connection state")}}}}};
AdfDhtmlActiveData.prototype._startPolling=function(){if(AdfPage.PAGE.isPPRNavigationEnabled()&&AdfCollections.isEmpty(this._getClientStateMap()))this._pollingTimer=AdfPage.PAGE.scheduleTimer(this,this._startPolling,null,this._pollingInterval);else{if(!this._pollSucceeded&&(this._reconnectRetries++,this._reconnectRetries>this._maxReconnectionRetries)){AdfLogger.LOGGER.warning("Cannot connect. Exceeded number of retries for reconnection");this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.DISCONNECTED);
return}this._notifyADSConnectionStateChange(AdfDhtmlPage.PushChannelStates.CONNECTED);if(null!=this._pollingTimer){try{clearTimeout(this._pollingTimer)}catch(d){}this._pollingTimer=null}var a=new Date,b=this._pollingInterval;null!=this._lastPollTime&&(b=a.getTime()-this._lastPollTime);a=0;b<this._pollingInterval&&(a=this._pollingInterval-b);200>=a?(this._pollForEvents(),this._pollingTimer=AdfPage.PAGE.scheduleTimer(this,this._startPolling,null,this._pollingInterval)):(AdfLogger.LOGGER.finer("Timer is fired much before the _pollingInterval, scheduling timer for ",
a),this._pollingTimer=AdfPage.PAGE.scheduleTimer(this,this._startPolling,null,a))}};AdfDhtmlActiveData.prototype.failover=function(a){this._handlingFailover=!0;this._handleAllFailovers(a)};AdfDhtmlActiveData.prototype._handleFailover=function(){this.setHAMigrated(!1);var a=AdfPage.PAGE.getDomWindow();this._isWindowClosing||a.location.reload(!0)};
AdfDhtmlActiveData.prototype._handleAllFailovers=function(a){var b=this._getRegistryMap(),d=void 0,e=AdfPage.PAGE.getDomWindow(),f=void 0;AdfCollections.isArray(a)||(d=a,a=[],a=a.concat(d));for(var g in b)-1==AdfCollections.indexOf(a,g)&&(d=b[g],d!=e?this._testAdfPageExistence(d)&&(d=d.AdfPage.PAGE,d.getActiveDataSupport().isHAMigrated()||d.getActiveDataSupport()._handleFailover()):f=!0);f&&this._testAdfPageExistence(e)&&e.AdfPage.PAGE.getActiveDataSupport()._handleFailover()};
AdfDhtmlActiveData.prototype.setHAMigrated=function(a){AdfAssert.assertBoolean(a);this._haMigrated=a};AdfDhtmlActiveData.prototype.isHAMigrated=function(){return this._haMigrated};AdfDhtmlActiveData.prototype.unmapComponent=function(a){a in this._activeComponents&&this._stopActiveData(a)};AdfDhtmlActiveData.prototype.populateStartActiveDataArray=function(a,b,d){var e=this._activeComponents;a.push(d);b.push(e[d].changeCount)};AdfDhtmlActiveData.prototype.getActiveComponents=function(){return this._activeComponents};
AdfDhtmlActiveData.prototype.reset=function(){this._cancelADSTimers();this._activeComponents={};this._admInitialized=!1};AdfDhtmlActiveData.prototype.setActiveComponents=function(a){this._activeComponents=a};