const f=8;function p(s){let o;try{o=new URL(s).pathname}catch{o=(s.split("?")[0]??s).replace(/^https?:\/\/[^/]+/i,"")}return o===""?"/":o.split("/").map(n=>n===""?n:/^\d+$/.test(n)?"{id}":/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)?"{uuid}":/^[0-9a-f]{24,}$/i.test(n)?"{hex}":n).join("/")}function c(s,o){if(s.length===0)return 0;const n=Math.max(1,Math.ceil(o*s.length));return s[Math.min(n,s.length)-1]}function d(s){if(!s||s.capturing!==!0)return{endpoints:[],totalRequests:0,observed:!1,note:"Telemetry capture was off, so no requests were watched. This is not the same as the application making none."};const o=new Map;for(const r of s.requests){const e=p(r.url),u=`${r.method} ${e}`,h=o.get(u)??{method:r.method,path:e,rows:[]};h.rows.push(r),o.set(u,h)}const n=[...o.values()].map(r=>{const e=r.rows,u=new Map;for(const t of e)u.set(t.status,(u.get(t.status)??0)+1);const h=e.filter(t=>!t.failed&&t.status>=200&&t.status<400).length,l=e.filter(t=>t.failed||t.status===0).length,a=e.filter(t=>!t.failed&&t.status>0).map(t=>t.duration).sort((t,i)=>t-i);return{method:r.method,path:r.path,requests:e.length,successRate:e.length===0?0:h/e.length,errorRate:e.length===0?0:(e.length-h)/e.length,noResponse:l,statuses:[...u.entries()].map(([t,i])=>({status:t,count:i})).sort((t,i)=>i.count-t.count),...a.length>=8?{latency:{p50:c(a,.5),p95:c(a,.95),p99:c(a,.99)}}:{durations:a},slowest:a.length===0?0:a[a.length-1],sampleSize:e.length,traceIds:[...new Set(e.map(t=>t.traceId).filter(t=>typeof t=="string"))].slice(0,10)}}).sort((r,e)=>e.errorRate-r.errorRate||e.requests-r.requests);return{endpoints:n,totalRequests:s.requests.length,observed:!0,note:n.length===0?"Capture was on and no requests were recorded during this execution.":`Observed behaviour across ${String(s.requests.length)} request${s.requests.length===1?"":"s"}. This describes what happened, not what the API guarantees.`}}export{f as M,p as e,d as o};
//# sourceMappingURL=chunk-Dp5WJOsV.js.map
