{"version":3,"file":"c_teams_idle_timeout_pagelet.after-display.js","sources":["../../../../metaserver/static/js/teams/idle.ts","../../../../metaserver/static/js/teams/idle_timeout.ts","../../../../metaserver/static/js/teams/idle_timeout_pagelet.after-display.ts"],"sourcesContent":["const EVENTS_ARRAY = [\n 'keypress',\n 'keydown',\n 'click',\n 'contextmenu',\n 'dblclick',\n 'mousemove',\n 'scroll',\n 'touchmove',\n 'touchstart',\n];\n\nexport enum ReportMode {\n Standard = 1,\n Advanced = 2,\n}\n\nconst DEFAULT_ACTIVITY_REPORT_IN_SEC = 5;\n\nexport interface Options {\n activityReportInSec?: number;\n activityReportMode?: ReportMode;\n detectFramesInSec?: number;\n onActivity?: () =\u003e void;\n onEnterFrame?: () =\u003e void;\n onReportUserIsActive?: () =\u003e void;\n onReportUserIsIdle?: () =\u003e void;\n}\n\nexport class Idle {\n userReportedActive: boolean = false; // used for advanced mode\n userIsActive: boolean = false; //used for standard mode\n userMouseIsInFrame: boolean = false;\n attachedFrames: HTMLElement[] = [];\n activityReportMode: ReportMode = ReportMode.Advanced;\n activityReportInSec: number = DEFAULT_ACTIVITY_REPORT_IN_SEC;\n detectFramesInSec: number = -1;\n onActivity: () =\u003e void = () =\u003e {};\n onEnterFrame: () =\u003e void = () =\u003e {};\n onReportUserIsActive: () =\u003e void = () =\u003e {};\n onReportUserIsIdle: () =\u003e void = () =\u003e {};\n\n constructor(options: Options) {\n this.overrideDefaultsWithOptions(options);\n\n EVENTS_ARRAY.forEach((event) =\u003e {\n window.addEventListener(event, this.onUserActivity, false);\n });\n\n setInterval(this.onTimerTick.bind(this), this.activityReportInSec * 1000);\n\n if (this.detectFramesInSec \u003e 0) {\n setInterval(this.attachListenerToNewFrames, this.detectFramesInSec * 1000);\n }\n\n // activity signal is sent when the page loaded\n this.reportActivity();\n }\n\n attachListenerToNewFrames = () =\u003e {\n const frames = Array.prototype.slice.call(window.document.getElementsByTagName('frame'));\n const iframes = Array.prototype.slice.call(window.document.getElementsByTagName('iframe'));\n const allFrames = frames.concat(iframes);\n for (const frame of allFrames) {\n if (this.attachedFrames.indexOf(frame) \u003c 0) {\n frame.addEventListener('mouseenter', this.onMouseEntersFrame.bind(this), this, false);\n this.attachedFrames.push(frame);\n // We can't know if the mouse is within the new frame already, so we guess it is.\n // If its not we would find out upon any user activity\n this.userMouseIsInFrame = true;\n }\n }\n };\n\n onUserActivity = () =\u003e {\n this.onActivity();\n this.userIsActive = true;\n\n if (this.activityReportMode === ReportMode.Advanced \u0026\u0026 !this.userReportedActive) {\n this.reportActivity();\n }\n // user is active =\u003e user is not in a frame\n this.userMouseIsInFrame = false;\n };\n\n public onMouseEntersFrame() {\n this.onEnterFrame();\n this.userMouseIsInFrame = true;\n }\n\n private onTimerTick() {\n this.userReportedActive = false;\n if (\n (this.activityReportMode === ReportMode.Standard \u0026\u0026 this.userIsActive) ||\n (this.userMouseIsInFrame \u0026\u0026 this.isPageVisible())\n ) {\n this.reportActivity();\n } else {\n this.onReportUserIsIdle();\n }\n }\n\n private reportActivity() {\n this.onReportUserIsActive();\n this.userReportedActive = true;\n this.userIsActive = false;\n }\n\n private overrideDefaultsWithOptions(options: Options) {\n this.activityReportInSec = options.activityReportInSec || this.activityReportInSec;\n this.activityReportMode = options.activityReportMode || this.activityReportMode;\n this.detectFramesInSec = options.detectFramesInSec || this.detectFramesInSec;\n this.onActivity = options.onActivity || this.onActivity;\n this.onEnterFrame = options.onEnterFrame || this.onEnterFrame;\n this.onReportUserIsActive = options.onReportUserIsActive || this.onReportUserIsActive;\n this.onReportUserIsIdle = options.onReportUserIsIdle || this.onReportUserIsIdle;\n }\n\n private isPageVisible() {\n // return true for \"visible\" / \"prerender\" / \"undefined\" (unsupported browsers)\n return window.document.visibilityState !== 'hidden';\n }\n}\n","import * as ajax from 'metaserver/static/js/deprecated_ajax/ajax';\nimport type {Options} from 'metaserver/static/js/teams/idle';\nimport {Idle} from 'metaserver/static/js/teams/idle';\nimport {GetUrlForRefreshIdleSessionCookie} from 'js/deprecated_ajax_stubs/gen/api_auth/WebAuthWeb';\n\nconst FRAME_DETACTION_IN_SEC = 30;\n\nexport function startIdleTimeoutMonitor(activityReportInSec: number) {\n const options: Options = {\n onReportUserIsActive: () =\u003e {\n ajax.SilentBackgroundRequest({\n url: GetUrlForRefreshIdleSessionCookie(),\n data: {},\n });\n },\n activityReportInSec: activityReportInSec,\n detectFramesInSec: FRAME_DETACTION_IN_SEC,\n };\n\n new Idle(options);\n}\n","import {startIdleTimeoutMonitor} from 'metaserver/static/js/teams/idle_timeout';\n\n/**\n * This module reimplements the _load_idle_timeout_script portion of x_blank_page\n * as a separate pagelet. This module is intended to be invoked with require_and_configure_js\n * (or in the future, the JsModuleInit pagelet chunk helper).\n */\nexport function initialize_module({activityReportInSec}: {activityReportInSec: number}): void {\n startIdleTimeoutMonitor(activityReportInSec);\n}\n"],"names":["EVENTS_ARRAY","ReportMode","Idle","constructor","options","this","userReportedActive","userIsActive","userMouseIsInFrame","attachedFrames","activityReportMode","Advanced","activityReportInSec","detectFramesInSec","onActivity","onEnterFrame","onReportUserIsActive","onReportUserIsIdle","attachListenerToNewFrames","frames","Array","prototype","slice","call","window","document","getElementsByTagName","iframes","allFrames","concat","frame","indexOf","addEventListener","onMouseEntersFrame","bind","push","onUserActivity","reportActivity","overrideDefaultsWithOptions","forEach","event","setInterval","onTimerTick","Standard","isPageVisible","visibilityState","FRAME_DETACTION_IN_SEC","ajax.SilentBackgroundRequest","url","GetUrlForRefreshIdleSessionCookie","data","startIdleTimeoutMonitor"],"mappings":";mkBAAA,MAAMA,EAAe,CACnB,WACA,UACA,QACA,cACA,WACA,YACA,SACA,YACA,cAGF,IAAYC,GAAZ,SAAYA,GACVA,EAAAA,EAAA,SAAA,GAAA,WACAA,EAAAA,EAAA,SAAA,GAAA,UACD,CAHD,CAAYA,IAAAA,EAGX,CAAA,UAcYC,EAaX,WAAAC,CAAYC,GAZZC,KAAAC,oBAA8B,EAC9BD,KAAAE,cAAwB,EACxBF,KAAkBG,oBA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