(function(){"use strict";const w=(s,e,r)=>{const t=e.parent;for(let o=((t==null?void 0:t.row)||-1)+1;;++o){let n=s[o];if(!n)n=[],s.push(n);else if(!n.every(({startTime:i,endTime:l})=>i+r>e.endTime||l-r<e.startTime))continue;e.row=o,n.push(e);break}};let h=0;self.addEventListener("message",s=>{const e=s.data;switch(h=Math.max(h,(e==null?void 0:e.requestId)||0),e.type){case"calculateSpanPositions":g(e.root);break;case"filterSpans":T(e.root,e.filter);break}});const p=(s,e)=>{if("parent"in s){const t=s;t.row=-1,t.isVisible=!0,e.push(t)}const r=s.children.slice().sort((t,o)=>t.startTime-o.startTime||o.duration-t.duration);for(const t of r)p(t,e)},g=s=>{const e=h,r=[],t=[];p(s,t);let o=Date.now()-10,n=-64,i=0;const l=()=>{for(const a of r)a.sort((c,f)=>c.startTime-f.startTime);const u={requestId:e,type:"setRowsResult",rows:r,isEnd:!t.length};postMessage(u),o=Date.now(),n=i};for(;;){const u=t.shift();if(!u){l();return}w(r,u,.001),++i,(Date.now()-o>=15||i-n>=256)&&l()}},d=new RegExp("(?<=^|\\s)(?<pair>(?<key>[\\w.]+):(?<value>\\S*))","g"),T=(s,e)=>{const r=h,t=new Set,o=e.replace(d,"").replace(/\s{2,}/g," ").trim(),n=[];for(const a of e.matchAll(d)){const{key:c="",value:f=""}=a.groups||{};n.push([c,f.toLocaleLowerCase()])}const i=a=>a.name.toLocaleLowerCase().includes(o)||a.spanId.toLocaleLowerCase().includes(o)?n.every(([f,L])=>{const m=a.attributes[f];return m?String(m).toLocaleLowerCase().includes(L):!1}):!1,l=a=>{for(const c of a.children)i(c.span)&&t.add(c.span.spanId),l(c)};l(s),postMessage({requestId:r,type:"updateHighlight",matches:t})}})();
