!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="97e15bd0-2195-3e70-8154-e057b1f0e962")}catch(e){}}(); define(["require","exports","./c_init_data_debug_panel","./c_flux_action_type","./c_pap-events_enums_flexible_sharing_entry_point_variant-utils","./e_core_exception"],(function(e,t,r,s,i,n){"use strict";class a extends s.Message{constructor(e){super(),this.originalUrl="",this.currentUrl="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new a).fromBinary(e,t)}static fromJson(e,t){return(new a).fromJson(e,t)}static fromJsonString(e,t){return(new a).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(a,e,t)}}a.runtime=s.proto3,a.typeName="edison.prefetch.PrefetchArgs",a.fields=s.proto3.util.newFieldList((()=>[{no:10,name:"original_url",kind:"scalar",T:9},{no:11,name:"current_url",kind:"scalar",T:9}]));const o={DEBUG:!1,IDLE_TIMEOUT:200,NETWORK_TIMEOUT:6e4};class c{static format(){for(var e=arguments.length,t=new Array(e),r=0;r{c.debug("AjaxIdleObservable.next()",e),this.subscribers.forEach((t=>t(e)))},this.startCleanupTimeout=()=>{if(0===o.NETWORK_TIMEOUT)return;this.abortCleanupTimeout();this.cleanupTimeout=window.setTimeout((()=>{c.warn("AjaxIdleObservable","::","Timed out waiting for requests to resolve.","Make sure that incrementAjaxCount() is always matched with decrementAjaxCount().","::","pendingRequests =",this.pendingRequests),this.didNetworkTimeOut=!0,this.pendingRequests=0,this.next("IDLE")}),o.NETWORK_TIMEOUT)},this.abortCleanupTimeout=()=>{window.clearTimeout(this.cleanupTimeout),this.cleanupTimeout=void 0},this.increment=()=>{this.startCleanupTimeout(),0===this.pendingRequests&&this.next("BUSY"),this.pendingRequests+=1},this.decrement=()=>{this.abortCleanupTimeout(),1===this.pendingRequests?this.next("IDLE"):this.startCleanupTimeout(),this.pendingRequests=Math.max(this.pendingRequests-1,0),this.pendingRequests<10&&c.debug("AjaxIdleObservable.decrement()","::","pendingRequests =",this.pendingRequests)},this.subscribe=e=>{this.subscribers.add(e);return()=>{this.subscribers.delete(e)}}}}class l{constructor(){this.pendingResources=new Set,this.subscribers=new Set,this.didNetworkTimeOut=!1,this.next=e=>{c.debug("ResourceLoadingIdleObservable.next()",e),this.subscribers.forEach((t=>t(e)))},this.startCleanupTimeout=()=>{if(0===o.NETWORK_TIMEOUT)return;this.abortCleanupTimeout();this.cleanupTimeout=window.setTimeout((()=>{c.warn("ResourceLoadingIdleObservable","::","Timed out waiting for resources to resolve.","Consider filing a bug report if this continues to occur.","::","pendingResources =",this.pendingResources),this.didNetworkTimeOut=!0,this.pendingResources=new Set,this.next("IDLE")}),o.NETWORK_TIMEOUT)},this.abortCleanupTimeout=()=>{window.clearTimeout(this.cleanupTimeout),this.cleanupTimeout=void 0},this.add=e=>{e instanceof HTMLImageElement&&!e.src||e instanceof HTMLImageElement&&e.complete||e instanceof HTMLLinkElement&&!e.href||e instanceof HTMLScriptElement&&!e.src||e instanceof HTMLIFrameElement&&(!e.src||"about:blank"===e.src)||(this.startCleanupTimeout(),0===this.pendingResources.size&&this.next("BUSY"),this.pendingResources.add(e))},this.remove=e=>{this.abortCleanupTimeout(),this.pendingResources.delete(e),0===this.pendingResources.size?this.next("IDLE"):this.startCleanupTimeout(),this.pendingResources.size<10&&c.debug("ResourceLoadingIdleObservable.remove()","::","pendingResources =",this.pendingResources)},this.subscribe=e=>{this.subscribers.add(e);return()=>{this.subscribers.delete(e)}},"undefined"!=typeof window&&(null===window||void 0===window?void 0:window.MutationObserver)&&window.addEventListener("load",(()=>{new MutationObserver((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{e instanceof HTMLScriptElement||e instanceof HTMLLinkElement||e instanceof HTMLImageElement||e instanceof HTMLIFrameElement?this.add(e):e.hasChildNodes()&&e instanceof HTMLElement&&e.querySelectorAll("img").forEach(this.add)}))}))})).observe(window.document.documentElement,{childList:!0,subtree:!0}),["load","error"].forEach((e=>{window.document.addEventListener(e,(e=>{(e.target instanceof HTMLScriptElement||e.target instanceof HTMLLinkElement||e.target instanceof HTMLImageElement||e.target instanceof HTMLIFrameElement)&&this.remove(e.target)}),{capture:!0})}))}))}}class u{constructor(){this.ajaxIdleObservable=new d,this.resourceLoadingIdleObservable=new l,this.subscribers=new Set,this.ajaxIdle=!0,this.scriptLoadingIdle=!0,this.handleUpdate=e=>t=>{const r=this.ajaxIdle&&this.scriptLoadingIdle;"AJAX"===e&&(this.ajaxIdle="IDLE"===t),"RESOURCE_LOADING"===e&&(this.scriptLoadingIdle="IDLE"===t);const s=this.ajaxIdle&&this.scriptLoadingIdle;r!==s&&this.next(s?"IDLE":"BUSY")},this.next=e=>{c.debug("NetworkIdleObservable.next()",e),this.subscribers.forEach((t=>t(e)))},this.incrementAjaxCount=()=>this.ajaxIdleObservable.increment(),this.decrementAjaxCount=()=>this.ajaxIdleObservable.decrement(),this.isIdle=()=>this.ajaxIdle&&this.scriptLoadingIdle,this.didNetworkTimeOut=()=>this.ajaxIdleObservable.didNetworkTimeOut||this.resourceLoadingIdleObservable.didNetworkTimeOut,this.resetDidNetworkTimeOut=()=>{this.ajaxIdleObservable.didNetworkTimeOut=!1,this.resourceLoadingIdleObservable.didNetworkTimeOut=!1},this.subscribe=e=>{this.subscribers.add(e);return()=>{this.subscribers.delete(e)}},this.ajaxIdleObservable.subscribe(this.handleUpdate("AJAX")),this.resourceLoadingIdleObservable.subscribe(this.handleUpdate("RESOURCE_LOADING"))}}let m;const h=()=>(m||(m=new u),m);class g{constructor(e){this.mutationObserverConfig={attributeFilter:["hidden","style","src"],attributeOldValue:!0,attributes:!0,childList:!0,subtree:!0},this.mutations=new Map,this.mutationObserverCallback=e=>{c.debug("InViewportMutationObserver.mutationObserverCallback()","::","mutations =",e),e.forEach((e=>{e.timestamp=performance.now();let t=null;if(e.target instanceof Element&&(t=e.target),e.target instanceof Text&&(t=e.target.parentElement),t)if("childList"===e.type)e.addedNodes.forEach((t=>{t instanceof HTMLElement&&(this.intersectionObserver.observe(t),this.mutations.set(t,e)),t instanceof Text&&null!=t.parentElement&&(this.intersectionObserver.observe(t.parentElement),this.mutations.set(t.parentElement,e))}));else this.intersectionObserver.observe(t),this.mutations.set(t,e)}))},this.intersectionObserverCallback=e=>{c.debug("InViewportMutationObserver.intersectionObserverCallback()","::","entries =",e),e.forEach((e=>{const t=this.mutations.get(e.target);e.isIntersecting&&null!=t&&(c.info("InViewportMutationObserver.callback()","::","mutation =",t),this.callback(t)),this.mutations.delete(e.target),this.intersectionObserver.unobserve(e.target)}))},this.callback=e,this.mutationObserver=new MutationObserver(this.mutationObserverCallback),this.intersectionObserver=new IntersectionObserver(this.intersectionObserverCallback)}observe(e){c.info("InViewportMutationObserver.observe()","::","target =",e),this.mutationObserver.observe(e,this.mutationObserverConfig)}disconnect(){c.info("InViewportMutationObserver.disconnect()"),this.mutationObserver.disconnect(),this.intersectionObserver.disconnect()}}function p(e){const t=h();let r,s=t.isIdle();const i=e=>{s="IDLE"===e,s?(e=>{var t;(null!==(t=window.requestIdleCallback)&&void 0!==t?t:window.setTimeout)((()=>{window.requestAnimationFrame((()=>window.requestAnimationFrame(e)))}))})(n):(window.clearTimeout(r),r=void 0)},n=()=>{c.debug("requestAllIdleCallback.handleCpuIdle()"),s&&!r&&a()},a=()=>{r=window.setTimeout((()=>{const r=t.didNetworkTimeOut();t.resetDidNetworkTimeOut(),c.info("requestAllIdleCallback: ALL IDLE"),e(r),d()}),o.IDLE_TIMEOUT)},d=t.subscribe(i);s&&i("IDLE")}class f{constructor(e){this.imageLoadTimes=new Map,this.lastImageLoadTimestamp=0,this.intersectionObserverCallback=e=>{e.forEach((e=>{const t=e.target,r=this.imageLoadTimes.get(t);e.isIntersecting&&null!=r&&(c.info("InViewportImageObserver.callback()","::","timestamp =",r),this.callback(r,t)),this.intersectionObserver.unobserve(t),this.imageLoadTimes.delete(t)}))},this.handleLoadOrErrorEvent=e=>{(e.target instanceof HTMLImageElement||e.target instanceof HTMLIFrameElement)&&(c.debug("InViewportImageObserver.handleLoadOrErrorEvent()","::","event =",e),this.imageLoadTimes.set(e.target,e.timeStamp),this.intersectionObserver.observe(e.target))},this.callback=e,this.intersectionObserver=new IntersectionObserver(this.intersectionObserverCallback)}observe(){c.info("InViewportImageObserver.observe()"),document.addEventListener("load",this.handleLoadOrErrorEvent,{capture:!0}),document.addEventListener("error",this.handleLoadOrErrorEvent,{capture:!0})}disconnect(){c.info("InViewportImageObserver.disconnect()"),this.lastImageLoadTimestamp=0,this.imageLoadTimes.clear(),this.intersectionObserver.disconnect(),document.removeEventListener("load",this.handleLoadOrErrorEvent),document.removeEventListener("error",this.handleLoadOrErrorEvent)}}const v=()=>{var e;return(null===(e=window.performance.getEntriesByType("navigation")[0])||void 0===e?void 0:e.type)||(()=>{const e=window.performance.navigation.type;return 2===e?"back_forward":1===e?"reload":"navigate"})()};class w{constructor(){if(this.debug=!1,this.idleTimeout=200,this.lastImageLoadTimestamp=-1,this.navigationCount=0,this.observations=new Map,this.successSubscribers=new Set,this.errorSubscribers=new Set,this.onTTVC=(e,t)=>(this.successSubscribers.add(e),t&&this.errorSubscribers.add(t),()=>{this.successSubscribers.delete(e),t&&this.errorSubscribers.delete(t)}),!w.isSupportedEnvironment())throw new Error("VisuallyCompleteCalculator: This browser/runtime is not supported.");this.inViewportMutationObserver=new g((e=>{var t,r,s;(null!==(t=e.timestamp)&&void 0!==t?t:0)>=(null!==(s=null===(r=this.lastMutation)||void 0===r?void 0:r.timestamp)&&void 0!==s?s:0)&&(this.lastMutation=e)})),this.inViewportImageObserver=new f(((e,t)=>{e>=this.lastImageLoadTimestamp&&(this.lastImageLoadTimestamp=e,this.lastImageLoadTarget=t)}))}static isSupportedEnvironment(){var e;return void 0!==window&&"MutationObserver"in window&&"IntersectionObserver"in window&&"function"==typeof document.querySelectorAll&&(null===(e=window.performance)||void 0===e?void 0:e.timing)}cancel(e){const t=this.observations.get(this.observations.size);t&&"ACTIVE"===t.state&&(t.cancel("MANUAL_CANCELLATION",e),t.state="CANCELLED")}async start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,s;const i=this.navigationCount+=1;c.info("VisuallyCompleteCalculator.start()","::","index =",i);const n=this.observations.get(i-1);n&&"ACTIVE"===n.state&&n.cancel("NEW_MEASUREMENT");let a=t?"back_forward":e>0?"script":v();const o=(()=>{var e;return(null===(e=window.performance.getEntriesByType("navigation")[0])||void 0===e?void 0:e.activationStart)||0})();o>e&&(e=o,a="prerender");const d=(t,r)=>{const s=this.observations.get(i);if(!s||"ACTIVE"!==s.state)return;s.state="CANCELLED";const n=performance.now();this.error(Object.assign({start:e,end:n,duration:n-e,cancellationReason:t,navigationType:a,lastVisibleChange:this.getLastVisibleChange()},r&&{eventType:r.type,eventTarget:r.target||void 0}),s)},l={index:i,state:"ACTIVE",cancel:d};this.observations.set(i,l);const u=e=>d("USER_INTERACTION",e),m=e=>d("NEW_NAVIGATION",e),h=e=>d("VISIBILITY_CHANGE",e);this.inViewportImageObserver.observe(),this.inViewportMutationObserver.observe(document.documentElement),window.addEventListener("pagehide",m),window.addEventListener("visibilitychange",h),window.setTimeout((()=>{window.addEventListener("click",u),window.addEventListener("keydown",u)}),0),await("complete"===document.readyState?Promise.resolve():new Promise((e=>{const t=()=>{e(),window.removeEventListener("load",t)};window.addEventListener("load",t)})));const g=await new Promise(p);if("ACTIVE"===l.state){l.state="COMPLETED";const t=Math.max(e,this.lastImageLoadTimestamp,null!==(s=null===(r=this.lastMutation)||void 0===r?void 0:r.timestamp)&&void 0!==s?s:0);this.next({start:e,end:t,duration:t-e,detail:{navigationType:a,didNetworkTimeOut:g,lastVisibleChange:this.getLastVisibleChange()}},l)}else c.debug("VisuallyCompleteCalculator: Measurement discarded","::","index =",i);window.removeEventListener("pagehide",m),window.removeEventListener("visibilitychange",h),window.removeEventListener("click",u),window.removeEventListener("keydown",u),i===this.navigationCount&&(this.inViewportImageObserver.disconnect(),this.inViewportMutationObserver.disconnect())}next(e,t){var r,s;e.end>Number.MAX_SAFE_INTEGER?c.warn("VisuallyCompleteCalculator.next()","::","This browser reported a time larger than MAX_SAFE_INTEGER. We are ignoring it.","::",e):(c.debug("VisuallyCompleteCalculator.next()","::","lastImageLoadTimestamp =",this.lastImageLoadTimestamp,"lastMutationTimestamp =",null!==(s=null===(r=this.lastMutation)||void 0===r?void 0:r.timestamp)&&void 0!==s?s:0,"::","index =",t.index),c.info("TTVC:",e,"::","index =",t.index),this.successSubscribers.forEach((t=>t(e))))}error(e,t){c.debug("VisuallyCompleteCalculator.error()","::","cancellationReason =",e.cancellationReason,"::","eventType =",e.eventType||"none","::","index =",t.index),this.errorSubscribers.forEach((t=>t(e)))}getLastVisibleChange(){var e,t;return this.lastImageLoadTimestamp>(null!==(t=null===(e=this.lastMutation)||void 0===e?void 0:e.timestamp)&&void 0!==t?t:0)?this.lastImageLoadTarget:this.lastMutation}}let b;let E;const T=h().incrementAjaxCount,S=h().decrementAjaxCount;var P,_;function y(){const e=window.performance?window.performance.now():0;return Math.floor(e)}function I(){const e={};return"number"==typeof window.EDISON_METRICS_JS_EXECUTION_START&&(e[P.JsExecutionStart]=window.EDISON_METRICS_JS_EXECUTION_START),"number"==typeof window.EDISON_METRICS_REQUIRE_LOAD_CALLBACK_TIME&&(e[P.RequireLoadCallbackTime]=window.EDISON_METRICS_REQUIRE_LOAD_CALLBACK_TIME),"number"==typeof window.EDISON_METRICS_INIT_PAGE_MODULE_LOAD_TIME&&(e[P.InitPageModuleLoadTime]=window.EDISON_METRICS_INIT_PAGE_MODULE_LOAD_TIME),"number"==typeof window.EDISON_METRICS_PRELOAD_MODULES_LOAD_TIME&&(e[P.PreloadModulesLoadTime]=window.EDISON_METRICS_PRELOAD_MODULES_LOAD_TIME),e}!function(e){e.JsExecutionStart="js_execution_start",e.RequireLoadCallbackTime="require_load_callback_time",e.InitPageModuleLoadTime="init_page_module_load_time",e.PreloadModulesLoadTime="preload_modules_load_time",e.InitReceived="init_received",e.RenderStarted="render_started",e.RenderComplete="render_complete",e.FirstCssPreloadReceived="first_css_preload_received",e.LastCssPreloadReceived="last_css_preload_received",e.ServerSidePrefetchStartedReceived="server_side_prefetch_started_received",e.DoneStreamingReceived="done_streaming_received",e.StreamedPrefetchWaitTime="streamed_prefetch_wait_time"}(P||(P={})),function(e){e.PageLoadComplete="page_load_complete",e.ErrorPageShown="error_page_shown"}(_||(_={}));class L{constructor(e){this.AMP_NAMESPACE="web_timing",this.marked={};const{atlasservlet:t,pageName:r,performanceNow:s=y,getLazyMetricsReporter:i}=e;this.atlasservlet=t,this.pageName=r,this.performanceNow=s,this.lazyMetricsReporter=i?i():null;let n=()=>{};this.renderCompletePromise=new Promise((e=>{n=e})),this.renderCompleteResolveFn=n,this.eventTimings={},this.streamedPrefetchRequestTimingQueues={},this.streamedPrefetchResponseTimings={}}recordEventTime(e){this.eventTimings[e]=this.performanceNow()}recordEventTimeOnce(e){this.eventTimings[e]||this.recordEventTime(e)}getTags(e){return{atlasservlet:this.atlasservlet,edison_page_name:this.pageName,...e}}recordInitReceived(){this.recordEventTimeOnce(P.InitReceived)}recordRenderStarted(){this.recordEventTimeOnce(P.RenderStarted)}recordRenderComplete(){this.recordEventTimeOnce(P.RenderComplete),this.renderCompleteResolveFn()}recordCssPreloadReceived(){this.recordEventTimeOnce(P.FirstCssPreloadReceived),this.recordEventTime(P.LastCssPreloadReceived)}recordServerSidePrefetchStartedReceived(){this.recordEventTimeOnce(P.ServerSidePrefetchStartedReceived)}recordDoneStreamingReceived(){this.recordEventTimeOnce(P.DoneStreamingReceived)}async saveEventTimings(){if(!this.lazyMetricsReporter)return;await this.renderCompletePromise;const e=await this.lazyMetricsReporter,t={...I(),...this.eventTimings};for(const[s,i]of Object.entries(t)){const t=this.getTags();e.createStats({ns:this.AMP_NAMESPACE,name:`edison/${s}`},t).recordDuration(i,r.TimeUnit.MILLISECONDS)}}async recordStreamedPrefetchRequestTime(e,t){this.streamedPrefetchRequestTimingQueues[e]||(this.streamedPrefetchRequestTimingQueues[e]=[]),this.streamedPrefetchRequestTimingQueues[e].push({loggingIdentifier:t,requestTime:this.performanceNow(),processed:!1}),await this.flushPrefetchTimingRecordQueue()}async recordStreamedPrefetchResponseTime(e,t){this.streamedPrefetchResponseTimings[e]||(this.streamedPrefetchResponseTimings[e]={responseTime:this.performanceNow(),failed:t},await this.flushPrefetchTimingRecordQueue())}markPageLoadSuccess(){this.recordPageMarker(_.PageLoadComplete,{result:"success"})}markPageLoadFailed(){this.recordPageMarker(_.PageLoadComplete,{result:"error"})}markErrorPageShown(){const e=!!this.marked[_.PageLoadComplete];e||this.markPageLoadFailed(),this.recordPageMarker(_.ErrorPageShown,{page_load_completed:e.toString()})}async recordPageMarker(e,t={}){try{const s=await this.lazyMetricsReporter;if(this.marked[e])return;const i=null==s?void 0:s.createCounter({ns:this.AMP_NAMESPACE,name:`edison/page/${e}`},this.getTags({browser:r.getBrowserShortName(),source:r.is_mobile_or_tablet()?"mobile":"web",...t}));null==i||i.increment(),null==i||i.record(),this.marked[e]=!0}catch{console.error("Fail to record page event: ",e)}}async flushPrefetchTimingRecordQueue(){if(!this.lazyMetricsReporter)return;const e=await this.lazyMetricsReporter,t={};for(const[s,i]of Object.entries(this.streamedPrefetchRequestTimingQueues)){const n=this.streamedPrefetchResponseTimings[s];if(n)for(const s of i){const{loggingIdentifier:i,requestTime:a}=s,{responseTime:o,failed:c}=n;if(t[i]||(t[i]=0),t[i]++,s.processed)continue;const d=`${i}_${t[i]}`,l=this.getTags({prefetch_id:d,failed:`${c}`}),u=e.createStats({ns:this.AMP_NAMESPACE,name:`edison/${P.StreamedPrefetchWaitTime}`},l),m=Math.max(o-a,0);if(u.recordDuration(m,r.TimeUnit.MILLISECONDS),s.processed=!0,window.performance)try{window.performance.measure(`edison:${P.StreamedPrefetchWaitTime}:${i}`,{start:0,end:o,detail:{prefetchId:d}})}catch(e){}}}}}class C extends s.Message{constructor(e){super(),this.type={case:void 0},s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new C).fromBinary(e,t)}static fromJson(e,t){return(new C).fromJson(e,t)}static fromJsonString(e,t){return(new C).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(C,e,t)}}C.runtime=s.proto3,C.typeName="edison.prefetch.Prefetch",C.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"pending",kind:"message",T:O,oneof:"type"},{no:2,name:"result",kind:"message",T:R,oneof:"type"}]));class O extends s.Message{constructor(e){super(),this.requestKeys=[],s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new O).fromBinary(e,t)}static fromJson(e,t){return(new O).fromJson(e,t)}static fromJsonString(e,t){return(new O).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(O,e,t)}}O.runtime=s.proto3,O.typeName="edison.prefetch.Prefetch.Pending",O.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"request_keys",kind:"scalar",T:9,repeated:!0}]));class R extends s.Message{constructor(e){super(),this.requestKey="",this.response=new Uint8Array(0),this.error="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new R).fromBinary(e,t)}static fromJson(e,t){return(new R).fromJson(e,t)}static fromJsonString(e,t){return(new R).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(R,e,t)}}R.runtime=s.proto3,R.typeName="edison.prefetch.Prefetch.Result",R.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"request_key",kind:"scalar",T:9},{no:2,name:"response",kind:"scalar",T:12},{no:3,name:"error",kind:"scalar",T:9}]));const M={typeName:"edison.prefetch.PrefetchService",methods:{streamPrefetches:{name:"StreamPrefetches",I:a,O:C,kind:i.MethodKind.ServerStreaming}}};class A extends s.Message{constructor(e){super(),this.isFromOfficeIp=!1,s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new A).fromBinary(e,t)}static fromJson(e,t){return(new A).fromJson(e,t)}static fromJsonString(e,t){return(new A).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(A,e,t)}}A.runtime=s.proto3,A.typeName="edison_dws2.PrefetchArguments",A.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"is_from_office_ip",kind:"scalar",T:8},{no:2,name:"proto_arguments",kind:"message",T:s.Any}]));class k extends s.Message{constructor(e){super(),this.rpcProxyUrl="",this.atlasservlet="",this.pageName="",this.pageLifecycle="",this.activeUserId=s.protoInt64.zero,this.activeTeamId=s.protoInt64.zero,this.authRole=0,this.authActionType=0,this.uriPath="",this.legacyController="",this.legacyAction="",this.isOfficeIp=!1,this.staticRepoRev="",this.dws2RepoRev="",this.streamingEnabled=!1,this.isBuildTimePrefetchesEnabled=!1,this.isCssPreloadEnabled=!1,this.isReactNextEnabled=!1,this.entryPointModuleName="",this.isDws2Stage=!1,this.originalUrl="",this.originalReferer="",this.prefetchVersion=0,this.isProd=!1,this.gates={},this.browserId="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new k).fromBinary(e,t)}static fromJson(e,t){return(new k).fromJson(e,t)}static fromJsonString(e,t){return(new k).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(k,e,t)}}k.runtime=s.proto3,k.typeName="edison_dws2.EdisonInitParams",k.fields=s.proto3.util.newFieldList((()=>[{no:22,name:"rpc_proxy_url",kind:"scalar",T:9},{no:2,name:"atlasservlet",kind:"scalar",T:9},{no:3,name:"page_name",kind:"scalar",T:9},{no:15,name:"page_lifecycle",kind:"scalar",T:9},{no:4,name:"active_user_id",kind:"scalar",T:4},{no:5,name:"active_team_id",kind:"scalar",T:4},{no:31,name:"auth_role",kind:"scalar",T:13},{no:32,name:"auth_action_type",kind:"scalar",T:13},{no:6,name:"uri_path",kind:"scalar",T:9},{no:9,name:"legacy_controller",kind:"scalar",T:9},{no:10,name:"legacy_action",kind:"scalar",T:9},{no:11,name:"is_office_ip",kind:"scalar",T:8},{no:12,name:"static_repo_rev",kind:"scalar",T:9},{no:13,name:"dws2_repo_rev",kind:"scalar",T:9},{no:14,name:"streaming_enabled",kind:"scalar",T:8},{no:30,name:"is_build_time_prefetches_enabled",kind:"scalar",T:8},{no:36,name:"is_css_preload_enabled",kind:"scalar",T:8},{no:39,name:"is_react_next_enabled",kind:"scalar",T:8},{no:25,name:"entry_point_module_name",kind:"scalar",T:9},{no:27,name:"is_dws2_stage",kind:"scalar",T:8},{no:28,name:"original_url",kind:"scalar",T:9},{no:29,name:"original_referer",kind:"scalar",T:9},{no:33,name:"prefetchVersion",kind:"scalar",T:5},{no:34,name:"is_prod",kind:"scalar",T:8},{no:35,name:"gates",kind:"map",K:9,V:{kind:"scalar",T:8}},{no:38,name:"browserId",kind:"scalar",T:9}]));class x extends s.Message{constructor(e){super(),this.type={case:void 0},this.b64RequestKey="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new x).fromBinary(e,t)}static fromJson(e,t){return(new x).fromJson(e,t)}static fromJsonString(e,t){return(new x).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(x,e,t)}}x.runtime=s.proto3,x.typeName="edison_dws2.EdisonRequest",x.fields=s.proto3.util.newFieldList((()=>[{no:2,name:"service_method_prefetch",kind:"message",T:N,oneof:"type"},{no:3,name:"css_preload",kind:"message",T:q,oneof:"type"},{no:5,name:"module_preload",kind:"message",T:D,oneof:"type"},{no:4,name:"b64_request_key",kind:"scalar",T:9}]));class N extends s.Message{constructor(e){super(),this.service="",this.method="",this.initialPageAtlasservlet="",this.initialPageName="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new N).fromBinary(e,t)}static fromJson(e,t){return(new N).fromJson(e,t)}static fromJsonString(e,t){return(new N).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(N,e,t)}}N.runtime=s.proto3,N.typeName="edison_dws2.EdisonRequest.ServiceMethodPrefetch",N.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"service",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"proto_arguments",kind:"message",T:s.Any},{no:5,name:"initial_page_atlasservlet",kind:"scalar",T:9},{no:6,name:"initial_page_name",kind:"scalar",T:9}]));class q extends s.Message{constructor(e){super(),this.cssPaths=[],s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new q).fromBinary(e,t)}static fromJson(e,t){return(new q).fromJson(e,t)}static fromJsonString(e,t){return(new q).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(q,e,t)}}q.runtime=s.proto3,q.typeName="edison_dws2.EdisonRequest.CssPreload",q.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"css_paths",kind:"scalar",T:9,repeated:!0}]));class D extends s.Message{constructor(e){super(),this.modulePaths=[],s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new D).fromBinary(e,t)}static fromJson(e,t){return(new D).fromJson(e,t)}static fromJsonString(e,t){return(new D).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(D,e,t)}}D.runtime=s.proto3,D.typeName="edison_dws2.EdisonRequest.ModulePreload",D.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"module_paths",kind:"scalar",T:9,repeated:!0}]));class j extends s.Message{constructor(e){super(),this.encodedProto="",s.proto3.util.initPartial(e,this)}static fromBinary(e,t){return(new j).fromBinary(e,t)}static fromJson(e,t){return(new j).fromJson(e,t)}static fromJsonString(e,t){return(new j).fromJsonString(e,t)}static equals(e,t){return s.proto3.util.equals(j,e,t)}}j.runtime=s.proto3,j.typeName="edison_dws2.InitProps",j.fields=s.proto3.util.newFieldList((()=>[{no:1,name:"encodedProto",kind:"scalar",T:9}]));class J{constructor(){this.pendingPrefetches={},this.metadataCache={},this.resultsCache={}}async get(e,t){if(this.isReady(e))return this.resultsCache[e].getter();if(!this.pendingPrefetches[e]){let r=()=>{};const s=new Promise((e=>{r=e}));this.pendingPrefetches[e]={promise:s,resolve:r},t&&(this.metadataCache[e]=t)}return await this.pendingPrefetches[e].promise,this.resultsCache[e].getter()}getMetadata(e){if(!this.metadataCache[e])throw new Error("Metadata does not exist for key");return this.metadataCache[e]}has(e){return!!this.pendingPrefetches[e]||!!this.resultsCache[e]}set(e,t){this.pendingPrefetches[e]&&(this.pendingPrefetches[e].resolve(),delete this.pendingPrefetches[e]),this.resultsCache[e]={getter:t}}delete(e){delete this.pendingPrefetches[e],delete this.metadataCache[e],delete this.resultsCache[e]}clear(){this.pendingPrefetches={},this.metadataCache={},this.resultsCache={}}listAllKeys(){return Array.from(new Set([...this.listPendingKeys(),...this.listCachedKeys()]))}listCachedKeys(){return Object.keys(this.resultsCache)}listPendingKeys(){return Object.keys(this.pendingPrefetches)}isPending(e){return!this.isReady(e)&&!!this.pendingPrefetches[e]}isReady(e){return!!this.resultsCache[e]}}class B extends Error{}var U;function V(){if("undefined"==typeof jest&&!s.isServerSide())return async()=>{const{getMetricsReporter:t}=await new Promise((function(t,r){e(["./c_src_sink_index"],t,r)})).then((function(e){return e.index_esnext}));return t()}}t.EdisonPrefetchStatus=void 0,(U=t.EdisonPrefetchStatus||(t.EdisonPrefetchStatus={}))[U.PendingStreaming=0]="PendingStreaming",U[U.PendingAjax=1]="PendingAjax",U[U.StreamedAndNotConsumed=2]="StreamedAndNotConsumed",U[U.StreamedAndConsumed=3]="StreamedAndConsumed",U[U.FetchedByAjax=4]="FetchedByAjax";class K{setEntryInPrefetchLog(e,t,r,s){for(const i of this.prefetchLog)if(i.requestKey===e&&i.status===t)return i.status=r,void(s&&Object.assign(i,s))}constructor(){this.isDoneStreaming=!1,this.isServerSidePrefetchStarted=!1,this.streamingEnabled=!0,this.buildTimePrefetchesEnabled=!1,this.cssPreloadEnabled=!1,this.reactNextEnabled=!1,this.consumedPrefetches={},this.prefetchCacheMgr=new J,this.pendingServerSidePrefetchKeys=[],this.prefetchLog=[],this.metrics=new L({atlasservlet:s.getAtlasservlet(),pageName:s.getPageName(),getLazyMetricsReporter:V()}),this.metrics.recordInitReceived()}static getSingleton(){return K.instance||(K.instance=new K),K.instance}static reset(){K.instance=null}static setIsStreamingEnabled(e){K.getSingleton().streamingEnabled=e}static setIsBuildTimePrefetchesEnabled(e){K.getSingleton().buildTimePrefetchesEnabled=e}static getIsBuildTimePrefetchesEnabled(){return K.getSingleton().buildTimePrefetchesEnabled}static setIsCSSPreloadEnabled(e){K.getSingleton().cssPreloadEnabled=e}static getIsCSSPreloadEnabled(){return K.getSingleton().cssPreloadEnabled}static setIsReactNextEnabled(e){K.getSingleton().reactNextEnabled=e}static getIsReactNextEnabled(){return K.getSingleton().reactNextEnabled}static getPrefetchLog(){return[...K.getSingleton().prefetchLog]}static getMetrics(){return K.getSingleton().metrics}static getStaticRevision(){return s.getRepoRev()}static async _grpcWebAjax(e,r,n,a,o){T();try{const c=i.createEdisonGrpcWebTransport(),{message:d}=await c.unary({typeName:r},{name:n,I:a.getType(),O:o},void 0,void 0,void 0,a);return K.getSingleton().setEntryInPrefetchLog(e,t.EdisonPrefetchStatus.PendingAjax,t.EdisonPrefetchStatus.FetchedByAjax,{failed:!1,result:s.protoBase64.enc(d.toBinary())}),d}finally{S()}}static async _prefetch(e,r,i,n){const a=K.getSingleton(),o=new x({type:{case:"serviceMethodPrefetch",value:{service:e,method:r,protoArguments:s.wrapInAny(i),initialPageAtlasservlet:s.getAtlasservlet(),initialPageName:s.getPageName()}}}),c=`${e}.${r}`;if(o.b64RequestKey)throw new Error("The EdisonRequest proto message parameter to prefetchHelper must not have a b64PrefetchKey set (it is computed here so we make sure it is the same between browser and streaming reactserver).");const d=s.marshalProto(o),l=a.prefetchCacheMgr.has(d);if(!s.isServedByEdisonWebServer()||!a.streamingEnabled||a.consumedPrefetches[d]||a.isServerSidePrefetchStarted&&!a.pendingServerSidePrefetchKeys.includes(d)&&!l||a.isDoneStreaming&&!l)return a.prefetchLog.push({edisonRequest:o,requestKey:d,status:t.EdisonPrefetchStatus.PendingAjax,isAjax:!0,isAfterStreaming:a.isDoneStreaming}),K._grpcWebAjax(d,e,r,i,n);l?a.setEntryInPrefetchLog(d,t.EdisonPrefetchStatus.StreamedAndNotConsumed,t.EdisonPrefetchStatus.StreamedAndConsumed):a.prefetchLog.push({edisonRequest:o,requestKey:d,status:t.EdisonPrefetchStatus.PendingStreaming}),a.metrics.recordStreamedPrefetchRequestTime(d,c),a.consumedPrefetches[d]=!0;const u=await a.prefetchCacheMgr.get(d,{service:e,method:r,outputType:n,input:i});return"string"==typeof u?s.unmarshalProto(u,n):u}static async fetch(e,t,r){if(s.isServerSide())return new Promise((()=>{}));const i=e.methods[(n=t,n.charAt(0).toLowerCase()+n.slice(1))].O;var n;const o=s.getRequestOriginalUrl(),c=new a({originalUrl:o,currentUrl:o,...r||{}});return await this._prefetch(e.typeName,t,c,i)}static preloadJSModules(e){if(s.isServerSide()){const t=new x({type:{case:"modulePreload",value:{modulePaths:e}}}),r=s.marshalProto(t);window.ReactserverEdisonClient.sendEdisonRequest(r)}}static resetPendingPrefetches(){const e=K.getSingleton();e.prefetchCacheMgr.listAllKeys().filter((t=>!e.consumedPrefetches[t])).forEach((r=>{e.consumedPrefetches[r]=!0,e.prefetchCacheMgr.delete(r),e.setEntryInPrefetchLog(r,t.EdisonPrefetchStatus.StreamedAndNotConsumed,t.EdisonPrefetchStatus.StreamedAndConsumed)}))}static registerStreamedPrefetch(e,r,i=!1){const n=K.getSingleton();if(n.isDoneStreaming)throw new Error("Cannot register new streamed prefetch after marking that we are done streaming.");if(n.metrics.recordStreamedPrefetchResponseTime(e,i),n.prefetchCacheMgr.has(e))n.setEntryInPrefetchLog(e,t.EdisonPrefetchStatus.PendingStreaming,t.EdisonPrefetchStatus.StreamedAndConsumed,{result:r,failed:i,isAjax:!1,isAfterStreaming:!1});else{const a=s.unmarshalProto(e,x),o={requestKey:e,status:t.EdisonPrefetchStatus.StreamedAndNotConsumed,failed:i,result:r,isAjax:!1,isAfterStreaming:!1,edisonRequest:a};n.prefetchLog.push(o)}n.prefetchCacheMgr.set(e,(()=>{if(i)throw new B(r);return r}))}static markServerSidePrefetchStarted(e){if(!Array.isArray(e))throw new Error("requestKeys must be an array");const r=K.getSingleton();r.isServerSidePrefetchStarted=!0,r.pendingServerSidePrefetchKeys=e,r.metrics.recordServerSidePrefetchStartedReceived();r.prefetchCacheMgr.listPendingKeys().filter((t=>!e.includes(t))).forEach((async e=>{r.setEntryInPrefetchLog(e,t.EdisonPrefetchStatus.PendingStreaming,t.EdisonPrefetchStatus.PendingAjax),K.performGrpcWebAjaxForPendingRequest(e)}))}static doneStreaming(){const e=K.getSingleton();e.isDoneStreaming||(e.metrics.recordDoneStreamingReceived(),e.metrics.saveEventTimings(),e.prefetchCacheMgr.listPendingKeys().forEach((async r=>{e.setEntryInPrefetchLog(r,t.EdisonPrefetchStatus.PendingStreaming,t.EdisonPrefetchStatus.PendingAjax,{isAjax:!0,isAfterStreaming:!0}),K.performGrpcWebAjaxForPendingRequest(r)})),e.pendingServerSidePrefetchKeys=[],e.isDoneStreaming=!0)}static getPrefetchCounts(){return K.getSingleton().prefetchLog.reduce(((e,{isAjax:t,isAfterStreaming:r})=>("boolean"==typeof t&&"boolean"==typeof r&&(r?e.numPrefetchesRequestedAfterDoneStreaming++:e.numPrefetchesRequestedBeforeDoneStreaming++,t?e.numPrefetchesByAjax++:e.numPrefetchesStreamed++),e)),{numPrefetchesRequestedAfterDoneStreaming:0,numPrefetchesRequestedBeforeDoneStreaming:0,numPrefetchesByAjax:0,numPrefetchesStreamed:0})}static async loadPrefetches(){const e=i.createEdisonGRPCWebPromiseClient(M,"/dws2/rpc/"),t=s.getRequestOriginalUrl(),r=new a({originalUrl:t,currentUrl:t}),n=new Set;try{for await(const t of e.streamPrefetches(r))if("pending"===t.type.case&&(K.markServerSidePrefetchStarted(t.type.value.requestKeys),t.type.value.requestKeys.forEach((e=>n.add(e)))),"result"===t.type.case){const{requestKey:e,response:r,error:i}=t.type.value;n.delete(e),i?K.registerStreamedPrefetch(e,i,!0):K.registerStreamedPrefetch(e,s.protoBase64.enc(r),!1)}}catch(e){n.forEach((t=>{K.registerStreamedPrefetch(t,e.toString(),!0)}))}finally{K.doneStreaming()}}static async performGrpcWebAjaxForPendingRequest(e){const t=K.getSingleton();if(!t.prefetchCacheMgr.has(e))throw new Error("Input request key does not match any pending prefetch request");try{const{service:r,method:s,input:i,outputType:n}=t.prefetchCacheMgr.getMetadata(e),a=await K._grpcWebAjax(e,r,s,i,n);t.prefetchCacheMgr.set(e,(()=>a))}catch(r){t.prefetchCacheMgr.set(e,(()=>{throw r}))}}}K.instance=null;var F=Object.freeze({__proto__:null,Edison:K,get EdisonPrefetchStatus(){return t.EdisonPrefetchStatus},PrefetchError:B});t.Edison=K,t.EdisonInitParams=k,t.InitProps=j,t.PrefetchArgs=a,t.PrefetchError=B,t.decrementAjaxCount=S,t.edison_esnext=F,t.incrementAjaxCount=T,t.init=e=>{var t;(e=>{(null==e?void 0:e.debug)&&(o.DEBUG=e.debug),(null==e?void 0:e.idleTimeout)&&(o.IDLE_TIMEOUT=e.idleTimeout),(null==e?void 0:e.networkTimeout)&&(o.NETWORK_TIMEOUT=e.networkTimeout)})(e),c.info("init()"),b||(b=new w),E=b,t=()=>{E.start(),window.addEventListener("locationchange",(e=>{E.start(e.timeStamp)})),window.addEventListener("pageshow",(e=>{e.persisted&&E.start(e.timeStamp,!0)}))},document.prerendering?window.addEventListener("prerenderingchange",t,!0):t()},t.onTTVC=(e,t)=>null==E?void 0:E.onTTVC(e,t),t.start=()=>null==E?void 0:E.start(performance.now())})); //# sourceMappingURL=e_edison.js-vfli2sUWJ.map //# debugId=97e15bd0-2195-3e70-8154-e057b1f0e962