"use strict";(globalThis.wpRiseJsonp=globalThis.wpRiseJsonp||[]).push([["profiler"],{67084(ie,N,c){c.d(N,{createRumProfiler:()=>G});var g=c(58817),O=c(97641),R=c(78651),m=c(78265),I=c(74828),V=c(41743),A=c(82020);function L(t){let s=0;for(const o of t)o.stackId!==void 0&&s++;return s}const j=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function U(t){return t?t.replace(j,"/?"):"/"}const P=(t,s)=>t||U(s);var B=c(87417);function F(t,s,o){const{ids:a,names:p}=x(t.views),f=t.longTasks.map(l=>l.id).filter(l=>l!==void 0),d={application:{id:s}};return o&&(d.session={id:o}),a.length&&(d.view={id:a,name:p}),f.length&&(d.long_task={id:f}),d}function x(t){const s={ids:[],names:[]};for(const o of t)s.ids.push(o.viewId),o.viewName&&s.names.push(o.viewName);return s.names=Array.from(new Set(s.names)),s}function H(t,s,o){return{event:J(t,s,o),"wall-time.json":t}}function J(t,s,o){const a=(0,B.m5)(s),p=F(t,s.applicationId,o),f=z(a);return{...p,attachments:["wall-time.json"],start:new Date(t.startClocks.timeStamp).toISOString(),end:new Date(t.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:f.join(","),_dd:{clock_drift:(0,m.TP)()}}}function z(t){return t.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}const C={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3,minNumberOfSamples:50};function G(t,s,o,a,p,f,d,l=C){const X=(0,A.wP)(t,s,f,6);let b;const E=[];let n={state:"stopped",stateReason:"initializing"};s.subscribe(9,()=>{S("session-expired")}),s.subscribe(10,()=>{n.state==="stopped"&&n.stateReason==="session-expired"&&T()});function T(){if(n.state==="running")return;const e=d.findView();b=e?{startClocks:e.startClocks,viewId:e.id,viewName:P(e.name,document.location.pathname)}:void 0,E.push((0,g.q)(t,window,"visibilitychange",$).stop,(0,g.q)(t,window,"beforeunload",q).stop),v()}function Z(){S("stopped-by-user")}function S(e){Q(e),E.forEach(i=>i()),a.set({status:"stopped",error_reason:void 0})}function K(e){if(e.state==="running")return{cleanupTasks:e.cleanupTasks};const i=[],u=s.subscribe(2,r=>{const h={viewId:r.id,viewName:P(r.name,document.location.pathname),startClocks:r.startClocks};k(h),b=h});return i.push(u.unsubscribe),{cleanupTasks:i}}function v(){const e=(0,O.VZ)().Profiler;if(!e)throw a.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");n.state==="running"&&w(n);const{cleanupTasks:i}=K(n);let u;try{u=new e({sampleInterval:l.sampleIntervalMs,maxBufferSize:Math.round(l.collectIntervalMs*1.5/l.sampleIntervalMs)})}catch(r){r instanceof Error&&r.message.includes("disabled by Document Policy")?(R.Vy.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",r),a.set({status:"error",error_reason:"missing-document-policy-header"})):a.set({status:"error",error_reason:"unexpected-exception"});return}a.set({status:"running",error_reason:void 0}),n={state:"running",startClocks:(0,m.M8)(),profiler:u,timeoutId:(0,I.wg)(v,l.collectIntervalMs),views:[],cleanupTasks:i,longTasks:[]},k(b),u.addEventListener("samplebufferfull",y)}function w(e){(0,I.DJ)(e.timeoutId),e.profiler.removeEventListener("samplebufferfull",y);const{startClocks:i,views:u}=e;e.profiler.stop().then(r=>{const h=(0,m.M8)(),D=(0,m.vk)(i.timeStamp,h.timeStamp),M=p.findLongTasks(i.relative,D),se=D<l.minProfileDurationMs,ne=L(r.samples)<l.minNumberOfSamples;M.length===0&&(se||ne)||Y(Object.assign(r,{startClocks:i,endClocks:h,clocksOrigin:(0,m.Oc)(),longTasks:M,views:u,sampleInterval:l.sampleIntervalMs}))}).catch(V.Dx)}function Q(e){if(n.state==="paused"){n={state:"stopped",stateReason:e};return}if(n.state!=="running")return;const i=n;n={state:"stopped",stateReason:e},i.cleanupTasks.forEach(u=>u()),w(i)}function W(){if(n.state!=="running")return;const e=n;n={state:"paused"},e.cleanupTasks.forEach(i=>i()),w(e)}function k(e){n.state!=="running"||!e||n.views.push(e)}function Y(e){var i;const u=(i=o.findTrackedSession())===null||i===void 0?void 0:i.id,r=H(e,t,u);X.send(r)}function y(){v()}function $(){document.visibilityState==="hidden"&&n.state==="running"?W():document.visibilityState==="visible"&&n.state==="paused"&&v()}function q(){v()}function _(){return n.state==="stopped"}function ee(){return n.state==="running"}function te(){return n.state==="paused"}return{start:T,stop:Z,isStopped:_,isRunning:ee,isPaused:te}}}}]);
