1import{bc as J,b4 as q,bv as K,bw as X,bx as x,by as Q,bz as b,b6 as P,bA as W,bB as v,bC as Y,bq as Z,bp as $,bD as ee,bE as te,bF as ne}from"./BfSjgb_p.js";function se(e){let n=0;for(const i of e)i.stackId!==void 0&&n++;return n}const g=new Map;function re(e,n){g.set(n,e)}function oe(e){return g.get(e)}function _(e){for(const n of g.keys())n<e&&g.delete(n)}function ae({rawRumEvent:e,startTime:n}){if(e.type!==J.LONG_TASK)return;const i=e.long_task.id;re(i,n)}const ie=(e,n,i)=>{const{profilingEndpointBuilder:r,applicationId:l}=n,p=le(e,n,i),c=ue(e,p),f=r.build("fetch",c);return q("Sending profile to public profiling intake",{profilingIntakeURL:f,applicationId:l,sessionId:i}),fetch(f,{body:c.data,method:"POST"})};function le(e,n,i){const r=K(n),l=de(e,n.applicationId,i),p=ce(r);return{...l,attachments:["wall-time.json"],start:new Date(e.startClocks.timeStamp).toISOString(),end:new Date(e.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:p.join(","),_dd:{clock_drift:X()}}}function ce(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}function ue(e,n){const i=new Blob([JSON.stringify(e)],{type:"application/json"}),r=new FormData;return r.append("event",new Blob([JSON.stringify(n)],{type:"application/json"}),"event.json"),r.append("wall-time.json",i,"wall-time.json"),{data:r,bytesCount:0}}function de(e,n,i){const r={application:{id:n}};i&&(r.session={id:i});const l=Array.from(new Set(e.views.map(c=>c.viewId)));l.length&&(r.view={id:l});const p=e.longTasks.map(c=>c.id).filter(c=>c!==void 0);return p.length&&(r.long_task={id:p}),r}const pe={sendProfile:ie},fe=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function me(e){return e?e.replace(fe,"/?"):"/"}const O=(e,n)=>e||me(n),be={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3,minNumberOfSamples:50};function ge(e,n,i,r,l=be){const p=x(Q.LONG_ANIMATION_FRAME);let c;const f=[];let o={state:"stopped"};function L(t){o.state!=="running"&&(c=t?{startClocks:t.startClocks,viewId:t.id,viewName:O(t.name,document.location.pathname)}:void 0,f.push(P(e,window,"visibilitychange",R).stop,P(e,window,"beforeunload",j).stop),m())}async function D(){await k("stopped"),f.forEach(t=>t()),_(b().relative),r.set({status:"stopped",error_reason:void 0})}function N(t){if(t.state==="running")return{cleanupTasks:t.cleanupTasks,observer:t.observer};const s=[];let a;if(e.trackLongTasks){a=new PerformanceObserver(A),a.observe({entryTypes:[B()]});const u=n.subscribe(12,h=>{ae(h)});s.push(()=>a?.disconnect()),s.push(u.unsubscribe)}const d=n.subscribe(2,u=>{y({viewId:u.id,viewName:O(u.name,document.location.pathname),startClocks:u.startClocks})});return s.push(d.unsubscribe),{cleanupTasks:s,observer:a}}function m(){const t=W().Profiler;if(!t)throw r.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");T(o).catch(v);const{cleanupTasks:s,observer:a}=N(o);let d;try{d=new t({sampleInterval:l.sampleIntervalMs,maxBufferSize:Math.round(l.collectIntervalMs*1.5/l.sampleIntervalMs)})}catch(u){u instanceof Error&&u.message.includes("disabled by Document Policy")?(Y.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",u),r.set({status:"error",error_reason:"missing-document-policy-header"})):r.set({status:"error",error_reason:"unexpected-exception"});return}r.set({status:"running",error_reason:void 0}),o={state:"running",startClocks:b(),profiler:d,timeoutId:Z(m,l.collectIntervalMs),longTasks:[],views:[],cleanupTasks:s,observer:a},y(c),d.addEventListener("samplebufferfull",w)}async function T(t){var s,a;if(t.state!=="running")return;E((a=(s=t.observer)===null||s===void 0?void 0:s.takeRecords())!==null&&a!==void 0?a:[]),$(t.timeoutId),t.profiler.removeEventListener("samplebufferfull",w);const{startClocks:d,longTasks:u,views:h}=t,V=b();await t.profiler.stop().then(I=>{const S=b(),G=u.length>0,H=ee(d.timeStamp,S.timeStamp)<l.minProfileDurationMs,z=se(I.samples)<l.minNumberOfSamples;!G&&(H||z)||(M(Object.assign(I,{startClocks:d,endClocks:S,clocksOrigin:te(),longTasks:u,views:h,sampleInterval:l.sampleIntervalMs})),_(V.relative))}).catch(v)}async function k(t){o.state==="running"&&(o.cleanupTasks.forEach(s=>s()),await T(o),o={state:t})}function y(t){o.state!=="running"||!t||o.views.push(t)}function M(t){var s;const a=(s=i.findTrackedSession())===null||s===void 0?void 0:s.id;pe.sendProfile(t,e,a).catch(v)}function w(){m()}function A(t){E(t.getEntries())}function E(t){if(o.state==="running")for(const s of t){if(s.duration<l.sampleIntervalMs)continue;const a=ne(s.startTime),d=oe(a.relative);o.longTasks.push({id:d,duration:s.duration,entryType:s.entryType,startClocks:a})}}function R(){document.visibilityState==="hidden"&&o.state==="running"?k("paused").catch(v):document.visibilityState==="visible"&&o.state==="paused"&&m()}function j(){m()}function B(){return p?"long-animation-frame":"longtask"}function C(){return o.state==="stopped"}function F(){return o.state==="running"}function U(){return o.state==="paused"}return{start:L,stop:D,isStopped:C,isRunning:F,isPaused:U}}export{be as DEFAULT_RUM_PROFILER_CONFIGURATION,ge as createRumProfiler};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.