function AdfSessionTimeoutHelper(){this.Init()}AdfObject.createSubclass(AdfSessionTimeoutHelper);AdfSessionTimeoutHelper.TimeoutWindowStates={NONE:0,CANCEL:1,LAUNCHED:2};AdfSessionTimeoutHelper.prototype.getTimeoutWindowState=function(){return this._timeoutWindowState};AdfSessionTimeoutHelper.prototype.Init=function(){AdfSessionTimeoutHelper.superclass.Init.call(this);this._timeoutWindowState=AdfSessionTimeoutHelper.TimeoutWindowStates.NONE;this._AFTimeOutGlassPane="AFTimeOutGlassPane"};
AdfSessionTimeoutHelper.prototype.__initializeSessionTimeoutTimer=function(a,b,d){this._setSessionTimeoutInWebLocalStorage(a);this._cancelAndRescheduleSessionTimeoutTimer(a,b,d);this._timeout=a;this._warningBeforeTimeout=b;this._newSessionURL=d;a=AdfAgent.AGENT;null==(a.isSessionStorageEnabled()?a.getSessionStorageProperty("oracle.adfinternal.view.rich.sessionKeysCleaned"):null)&&(this._timeoutWarningTimer=AdfPage.PAGE.scheduleTimer(this,this._cleanupLocalStorageSessionKeys,null,6E4),a.isSessionStorageEnabled()&&
a.setSessionStorageProperty("oracle.adfinternal.view.rich.sessionKeysCleaned","scheduled"))};
AdfSessionTimeoutHelper.prototype.__cancelSessionTimeoutTimer=function(){var a=AdfLogger.LOGGER;this._timeoutWarningTimer&&(AdfPage.PAGE.cancelTimer(this._timeoutWarningTimer),a.isLoggable(AdfLogger.INFO)&&a.info("Cancelled session timeout warning dialog timer with id ",this._timeoutWarningTimer),this._timeoutWarningTimer=null);this._timeoutTimer&&(AdfPage.PAGE.cancelTimer(this._timeoutTimer),a.isLoggable(AdfLogger.INFO)&&a.info("Cancelled final session timeout dialog timer with id ",this._timeoutTimer),
this._timeoutTimer=null)};AdfSessionTimeoutHelper.prototype.__startSessionTimeoutTimer=function(){this._setSessionTimeoutInWebLocalStorage(this._timeout);this._startSessionTimeoutTimer(this._timeout,this._warningBeforeTimeout,this._newSessionURL)};AdfSessionTimeoutHelper.prototype.__alertTimeout=function(){this._timeout=0;this._removeSessionTimeoutFromWebLocalStorage();this._cancelAndRescheduleSessionTimeoutTimer(this._timeout,this._warningBeforeTimeout,this._newSessionURL)};
AdfSessionTimeoutHelper.prototype.__recordUserActivity=function(a){"click"!=a.type&&"keypress"!=a.type||this._setActivityTimeInWebLocalStorage()};
AdfSessionTimeoutHelper.prototype._cleanupLocalStorageSessionKeys=function(){var a=AdfAgentHelper.getInstance();if(a.isLocalStorageEnabled()){var b=(new Date).getTime(),d=a.getLocalStorageKeys();AdfLogger.LOGGER.info("Cleaning expired session info from web local storage");for(var e=0;e<d.length;e++)if(0==d[e].indexOf("oracle.adfinternal.view.rich.sessionKey_")){var f=a.getLocalStorageProperty(d[e]);36E4<b-f&&(a.removeLocalStorageProperty(d[e]),f="oracle.adfinternal.view.rich.userActivityKey_"+d[e].split("_")[1],
a.removeLocalStorageProperty(f))}a=AdfAgent.AGENT;a.isSessionStorageEnabled()?a.setSessionStorageProperty("oracle.adfinternal.view.rich.sessionKeysCleaned","complete"):AdfLogger.LOGGER.info("Could not mark that we cleaned web local storage because session storage is not enabled")}};
AdfSessionTimeoutHelper.prototype._startSessionTimeoutTimer=function(a,b,d){d=(new Date).getTime();var e=AdfLogger.LOGGER,f=a-b;this._timeoutWindowState=AdfSessionTimeoutHelper.TimeoutWindowStates.NONE;0<f&&12E4<=b?(this._timeoutWarningTimer=AdfPage.PAGE.scheduleTimer(this,this._showSessionTimeoutWarningDialog,null,f),e.isLoggable(AdfLogger.INFO)&&e.info("Scheduled session timeout warning dialog timer with id ",this._timeoutWarningTimer," to be shown at : ",new Date(d+f))):(this._timeoutTimer=AdfPage.PAGE.scheduleTimer(this,
this._showFinalSessionTimeoutAlertDialog,null,a),e.isLoggable(AdfLogger.INFO)&&e.info("Scheduled final session timeout dialog timer with id ",this._timeoutTimer," to be shown at : ",new Date(d+a)))};AdfSessionTimeoutHelper.prototype._cancelAndRescheduleSessionTimeoutTimer=function(a,b,d){this.__cancelSessionTimeoutTimer();this._startSessionTimeoutTimer(a,b,d)};
AdfSessionTimeoutHelper.prototype._setSessionTimeoutInWebLocalStorage=function(a){var b=AdfAgentHelper.getInstance();if(b.isLocalStorageEnabled()){a=(new Date).getTime()+a;var d="oracle.adfinternal.view.rich.sessionKey_"+AdfPage.PAGE.getSessionIdentifier(),e=b.getLocalStorageProperty(d);if(null==e||e<a)b.setLocalStorageProperty(d,a),b=AdfLogger.LOGGER,b.isLoggable(AdfLogger.INFO)&&b.info("Web local storage for key ",d," reset to : ",new Date(a))}};
AdfSessionTimeoutHelper.prototype._setActivityTimeInWebLocalStorage=function(){var a=AdfAgentHelper.getInstance();if(a.isLocalStorageEnabled()){var b=new Date;this._setSessionTimeoutInWebLocalStorage(this._timeout);this._cancelAndRescheduleSessionTimeoutTimer(this._timeout,this._warningBeforeTimeout,this._newSessionURL);var d="oracle.adfinternal.view.rich.userActivityKey_"+AdfPage.PAGE.getSessionIdentifier();a.setLocalStorageProperty(d,b.getTime());a=AdfLogger.LOGGER;a.isLoggable(AdfLogger.INFO)&&
a.info("Last user activity on client for ",d," at ",b)}};
AdfSessionTimeoutHelper.prototype._isUserActiveOnClient=function(a){var b=AdfAgentHelper.getInstance();if(b.isLocalStorageEnabled()){var d="oracle.adfinternal.view.rich.userActivityKey_"+AdfPage.PAGE.getSessionIdentifier();if(b=b.getLocalStorageProperty(d))if(b=(new Date).getTime()-b,b<a)return d=AdfLogger.LOGGER,d.isLoggable(AdfLogger.INFO)&&d.info("User activity on client ",b/1E3," seconds ago. Duration checked for activity ",a/1E3," seconds"),!0}return!1};
AdfSessionTimeoutHelper.prototype._removeSessionTimeoutFromWebLocalStorage=function(a){a=AdfAgentHelper.getInstance();if(a.isLocalStorageEnabled()){var b="oracle.adfinternal.view.rich.sessionKey_"+AdfPage.PAGE.getSessionIdentifier();a.removeLocalStorageProperty(b)}};
AdfSessionTimeoutHelper.prototype._getTimeLeftToSessionTimeout=function(){var a=AdfAgentHelper.getInstance();if(a.isLocalStorageEnabled()){var b="oracle.adfinternal.view.rich.sessionKey_"+AdfPage.PAGE.getSessionIdentifier();if(a=a.getLocalStorageProperty(b))return a-(new Date).getTime()}return null};
AdfSessionTimeoutHelper.prototype._showSessionTimeoutWarningDialog=function(){var a=this._getTimeLeftToSessionTimeout();if(a&&(a<this._warningBeforeTimeout-2E3||a>this._warningBeforeTimeout+2E3))return this._cancelAndRescheduleSessionTimeoutTimer(a,this._warningBeforeTimeout,this._newSessionURL),-1;if(this._isUserActiveOnClient(this._timeout-this._warningBeforeTimeout))return this._extendSessionInServer(),-1;this._timeoutWarningTimer=null;a=AdfPage.PAGE;this._timeoutTimer&&(a.cancelTimer(this._timeoutTimer),
this._timeoutTimer=null);var b=AdfPage.PAGE.getLookAndFeel(),d;d=6E4<=this._warningBeforeTimeout?b.getTranslatedString("af_document.PRE_SESSION_TIMEOUT_MSG",Math.floor(this._warningBeforeTimeout/6E4)):b.getTranslatedString("af_document.PRE_SESSION_TIMEOUT_MSG_SECOND",this._warningBeforeTimeout/1E3);b=b.getTranslatedString("af_document.PRE_SESSION_TIMEOUT_CONFIRM_TITLE");null==b&&(b="Expiration Warning");var e=this.createCallback(this._handleSessionTimeoutWarningDialogOutcome);this._timeoutWindowState=
AdfSessionTimeoutHelper.TimeoutWindowStates.LAUNCHED;this._addAFTimeOutGlassPane();this._preSessionTimeoutWarningTime=(new Date).getTime();a.__confirm(b,d,e,this._warningBeforeTimeout,!0);return-1};
AdfSessionTimeoutHelper.prototype._handleSessionTimeoutWarningDialogOutcome=function(a){this._removeAFTimeOutGlassPane();this._timeoutWindowState=AdfSessionTimeoutHelper.TimeoutWindowStates.NONE;a.getOutcome()==AdfDialogEvent.OUTCOME_OK?this._extendSessionInServer():a.getOutcome()==AdfDialogEvent.OUTCOME_CANCEL&&(a=this._getTimeLeftToSessionTimeout(),a||(a=(new Date).getTime(),a=this._warningBeforeTimeout-(a-this._preSessionTimeoutWarningTime),this._preSessionTimeoutWarningTime=null),this._cancelAndRescheduleSessionTimeoutTimer(a,
this._warningBeforeTimeout,this._newSessionURL))};
AdfSessionTimeoutHelper.prototype._showFinalSessionTimeoutAlertDialog=function(){var a=this._getTimeLeftToSessionTimeout();if(a&&0<a&&0<a)return this._cancelAndRescheduleSessionTimeoutTimer(a,this._warningBeforeTimeout,this._newSessionURL),-1;if(this._isUserActiveOnClient(this._timeout))return this._extendSessionInServer(),-1;this._timeoutTimer=null;a=AdfPage.PAGE;this._timeoutWarningTimer&&(a.cancelTimer(this._timeoutWarningTimer),this._timeoutWarningTimer=null);var b=a.getLookAndFeel(),d=b.getTranslatedString("af_document.POST_SESSION_TIMEOUT_MSG");
this._newSessionURL&&(d+=" "+b.getTranslatedString("af_document.POST_SESSION_TIMEOUT_MSG_CONTINUE"));b=b.getTranslatedString("af_document.POST_SESSION_TIMEOUT_ALERT_TITLE");null==b&&(b="Window Expired");AdfDhtmlRichDialogService.getInstance().cancelAll();var e=a.getDocumentClientId(),e=AdfAgent.AGENT.getElementById(e);AdfDomUtils.setVisible(e,!1);e=this.createCallback(this._handleFinalSessionTimeoutAlert);this._addAFTimeOutGlassPane();this._timeoutWindowState=AdfSessionTimeoutHelper.TimeoutWindowStates.LAUNCHED;
a.__alert(b,d,e);return-1};
AdfSessionTimeoutHelper.prototype._handleFinalSessionTimeoutAlert=function(a){this._removeAFTimeOutGlassPane();this._timeoutTimer=null;a=AdfPage.PAGE;this._timeoutWindowState=AdfSessionTimeoutHelper.TimeoutWindowStates.NONE;if(this._newSessionURL)a.getDomWindow().location.replace(this._newSessionURL);else{var b=a.getLookAndFeel().getTranslatedString("af_document.POST_SESSION_TIMEOUT_MSG"),d=AdfAgent.AGENT,e=a.getDomDocument().createElement("div");AdfDomUtils.setVisible(e,!1);d.setTextContent(e,b);
b=a.getDocumentClientId();d.getElementById(b).parentNode.appendChild(e);AdfDomUtils.setVisible(e,!0);a.getDomWindow().setTimeout(a.createCallback(a.Dispose),1)}};AdfSessionTimeoutHelper.prototype._extendSessionInServer=function(){this._touchServerSession();AdfLogger.LOGGER.info("Extended session lifetime");this._setSessionTimeoutInWebLocalStorage(this._timeout);this._cancelAndRescheduleSessionTimeoutTimer(this._timeout,this._warningBeforeTimeout,this._newSessionURL)};
AdfSessionTimeoutHelper.prototype._touchServerSession=function(){var a=AdfPage.PAGE.getDomDocument().location.href,a=-1==a.indexOf("?")?a+"?":a+"\x26",a=a+("_afrTS\x3d"+(new Date).getTime()),b=new AdfXMLRequest;b.setSynchronous(!1);b.setRequestHeader("Content-Type","application/x-www-form-urlencoded");b.send(a,null);b.cleanup();delete b};
AdfSessionTimeoutHelper.prototype._addAFTimeOutGlassPane=function(){var a=AdfPage.PAGE.getDomDocument().getElementsByTagName("body")[0];AdfDomUtils.addCSSClassName(a,this._AFTimeOutGlassPane)};AdfSessionTimeoutHelper.prototype._removeAFTimeOutGlassPane=function(){var a=AdfPage.PAGE.getDomDocument().getElementsByTagName("body")[0];AdfDomUtils.removeCSSClassName(a,this._AFTimeOutGlassPane)};