diff --git a/docs/_static/preview/assets/index-Cql2ltA1.js b/docs/_static/preview/assets/index-Cql2ltA1.js new file mode 100644 index 00000000..dd6fd4b3 --- /dev/null +++ b/docs/_static/preview/assets/index-Cql2ltA1.js @@ -0,0 +1,15 @@ +var Oi=Object.defineProperty;var Di=(i,e,t)=>e in i?Oi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var A=(i,e,t)=>Di(i,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();const Hi="modulepreload",Vi=function(i,e){return new URL(i,e).href},Ut={},gt=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){const r=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.all(t.map(a=>{if(a=Vi(a,n),a in Ut)return;Ut[a]=!0;const f=a.endsWith(".css"),_=f?'[rel="stylesheet"]':"";if(!!n)for(let h=r.length-1;h>=0;h--){const p=r[h];if(p.href===a&&(!f||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${_}`))return;const d=document.createElement("link");if(d.rel=f?"stylesheet":Hi,f||(d.as="script",d.crossOrigin=""),d.href=a,l&&d.setAttribute("nonce",l),document.head.appendChild(d),f)return new Promise((h,p)=>{d.addEventListener("load",h),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${a}`)))})}))}return s.then(()=>e()).catch(r=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r})};function L(){}function pi(i){return i()}function Yt(){return Object.create(null)}function ae(i){i.forEach(pi)}function Et(i){return typeof i=="function"}function oe(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Ni(i){return Object.keys(i).length===0}function vi(i,...e){if(i==null){for(const n of e)n(void 0);return L}const t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function be(i,e,t){i.$$.on_destroy.push(vi(e,t))}function Bi(i,e,t){return i.set(t),e}function u(i,e){i.appendChild(e)}function I(i,e,t){i.insertBefore(e,t||null)}function S(i){i.parentNode&&i.parentNode.removeChild(i)}function _i(i,e){for(let t=0;ti.removeEventListener(e,t,n)}function Ct(i){return function(e){return e.preventDefault(),i.call(this,e)}}function Mt(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function c(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function yt(i){let e;return{p(...t){e=t,e.forEach(n=>i.push(n))},r(){e.forEach(t=>i.splice(i.indexOf(t),1))}}}function xi(i){return Array.from(i.childNodes)}function me(i,e){e=""+e,i.data!==e&&(i.data=e)}function le(i,e){i.value=e??""}function Z(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}function Xt(i,e,t){for(let n=0;n{const s=i.$$.callbacks[e];if(s){const r=zi(e,t,{cancelable:n});return s.slice().forEach(o=>{o.call(i,r)}),!r.defaultPrevented}return!0}}const xe=[],ke=[];let $e=[];const Gt=[],Ui=Promise.resolve();let kt=!1;function Yi(){kt||(kt=!0,Ui.then(bi))}function ft(i){$e.push(i)}const bt=new Set;let Ne=0;function bi(){if(Ne!==0)return;const i=Je;do{try{for(;Nei.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),$e=e}const ut=new Set;let Se;function Fe(){Se={r:0,c:[],p:Se}}function Pe(){Se.r||ae(Se.c),Se=Se.p}function D(i,e){i&&i.i&&(ut.delete(i),i.i(e))}function V(i,e,t,n){if(i&&i.o){if(ut.has(i))return;ut.add(i),Se.c.push(()=>{ut.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}function We(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function Ki(i,e){V(i,1,1,()=>{e.delete(i.key)})}function Zi(i,e,t,n,s,r,o,l,a,f,_,v){let d=i.length,h=r.length,p=d;const g={};for(;p--;)g[i[p].key]=p;const y=[],M=new Map,T=new Map,w=[];for(p=h;p--;){const P=v(s,r,p),b=t(P);let C=o.get(b);C?w.push(()=>C.p(P,e)):(C=f(b,P),C.c()),M.set(b,y[p]=C),b in g&&T.set(b,Math.abs(p-g[b]))}const F=new Set,H=new Set;function E(P){D(P,1),P.m(l,_),o.set(P.key,P),_=P.first,h--}for(;d&&h;){const P=y[h-1],b=i[d-1],C=P.key,O=b.key;P===b?(_=P.first,d--,h--):M.has(O)?!o.has(C)||F.has(C)?E(P):H.has(O)?d--:T.get(C)>T.get(O)?(H.add(C),E(P)):(F.add(O),d--):(a(b,o),d--)}for(;d--;){const P=i[d];M.has(P.key)||a(P,o)}for(;h;)E(y[h-1]);return ae(w),y}function we(i){i&&i.c()}function pe(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ft(()=>{const r=i.$$.on_mount.map(pi).filter(Et);i.$$.on_destroy?i.$$.on_destroy.push(...r):ae(r),i.$$.on_mount=[]}),s.forEach(ft)}function ve(i,e){const t=i.$$;t.fragment!==null&&(Gi(t.after_update),ae(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Qi(i,e){i.$$.dirty[0]===-1&&(xe.push(i),Yi(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const p=h.length?h[0]:d;return f.ctx&&s(f.ctx[v],f.ctx[v]=p)&&(!f.skip_bound&&f.bound[v]&&f.bound[v](p),_&&Qi(i,v)),d}):[],f.update(),_=!0,ae(f.before_update),f.fragment=n?n(f.ctx):!1,e.target){if(e.hydrate){const v=xi(e.target);f.fragment&&f.fragment.l(v),v.forEach(S)}else f.fragment&&f.fragment.c();e.intro&&D(i.$$.fragment),pe(i,e.target,e.anchor),bi()}Ze(a)}class ue{constructor(){A(this,"$$");A(this,"$$set")}$destroy(){ve(this,1),this.$destroy=L}$on(e,t){if(!Et(t))return L;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Ni(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ji="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ji);function en(i){let e,t;return{c(){e=$("svg"),t=$("path"),c(t,"fill-rule","evenodd"),c(t,"clip-rule","evenodd"),c(t,"d","M5.11634 0.889422C4.86506 -0.296474 3.17237 -0.296474 2.92109 0.889422C2.78291 1.54158 2.10994 1.93011 1.47607 1.72371C0.323418 1.34837 -0.522932 2.81429 0.378448 3.62484C0.87414 4.07059 0.87414 4.84767 0.378448 5.29341C-0.522931 6.10397 0.323418 7.56989 1.47607 7.19455C2.10994 6.98814 2.78291 7.37668 2.92109 8.02883C3.17237 9.21473 4.86506 9.21473 5.11634 8.02883C5.25452 7.37668 5.92749 6.98814 6.56136 7.19455C7.71401 7.56989 8.56036 6.10397 7.65898 5.29341C7.16329 4.84767 7.16329 4.07059 7.65898 3.62484C8.56036 2.81429 7.71401 1.34837 6.56136 1.72371C5.92749 1.93011 5.25452 1.54158 5.11634 0.889422ZM4.01883 6.33408C5.05436 6.33408 5.89383 5.49462 5.89383 4.45908C5.89383 3.42355 5.05436 2.58408 4.01883 2.58408C2.98329 2.58408 2.14383 3.42355 2.14383 4.45908C2.14383 5.49462 2.98329 6.33408 4.01883 6.33408Z"),c(t,"fill","currentColor"),c(e,"width","9"),c(e,"height","9"),c(e,"viewBox","0 0 9 9"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(n,s){I(n,e,s),u(e,t)},p:L,i:L,o:L,d(n){n&&S(e)}}}class tn extends ue{constructor(e){super(),ce(this,e,null,en,oe,{})}}function nn(i){let e,t,n,s,r,o,l,a,f,_,v,d,h,p,g,y,M;return{c(){e=$("svg"),t=$("g"),n=$("path"),s=$("path"),r=$("defs"),o=$("filter"),l=$("feFlood"),a=$("feBlend"),f=$("feGaussianBlur"),_=$("linearGradient"),v=$("stop"),d=$("stop"),h=$("stop"),p=$("linearGradient"),g=$("stop"),y=$("stop"),M=$("stop"),c(n,"fill-rule","evenodd"),c(n,"clip-rule","evenodd"),c(n,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(n,"fill","url(#paint0_linear_67_262)"),c(t,"opacity","0.5"),c(t,"filter","url(#filter0_f_67_262)"),c(s,"fill-rule","evenodd"),c(s,"clip-rule","evenodd"),c(s,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(s,"fill","url(#paint1_linear_67_262)"),c(l,"flood-opacity","0"),c(l,"result","BackgroundImageFix"),c(a,"mode","normal"),c(a,"in","SourceGraphic"),c(a,"in2","BackgroundImageFix"),c(a,"result","shape"),c(f,"stdDeviation","3.39785"),c(f,"result","effect1_foregroundBlur_67_262"),c(o,"id","filter0_f_67_262"),c(o,"x","3.2043"),c(o,"y","2.2043"),c(o,"width","36.0914"),c(o,"height","41.0914"),c(o,"filterUnits","userSpaceOnUse"),c(o,"color-interpolation-filters","sRGB"),c(v,"stop-color","#FFAA00"),c(d,"offset","0.514478"),c(d,"stop-color","#FFEB00"),c(h,"offset","1"),c(h,"stop-color","#98FF05"),c(_,"id","paint0_linear_67_262"),c(_,"x1","7.3769"),c(_,"y1","18.4566"),c(_,"x2","20.6583"),c(_,"y2","33.1038"),c(_,"gradientUnits","userSpaceOnUse"),c(g,"stop-color","#FFC834"),c(y,"offset","0.514478"),c(y,"stop-color","#FAF534"),c(M,"offset","1"),c(M,"stop-color","#B8FF38"),c(p,"id","paint1_linear_67_262"),c(p,"x1","7.3769"),c(p,"y1","18.4566"),c(p,"x2","20.6583"),c(p,"y2","33.1038"),c(p,"gradientUnits","userSpaceOnUse"),c(e,"width","44"),c(e,"height","44"),c(e,"viewBox","0 0 44 44"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(T,w){I(T,e,w),u(e,t),u(t,n),u(e,s),u(e,r),u(r,o),u(o,l),u(o,a),u(o,f),u(r,_),u(_,v),u(_,d),u(_,h),u(r,p),u(p,g),u(p,y),u(p,M)},p:L,i:L,o:L,d(T){T&&S(e)}}}class sn extends ue{constructor(e){super(),ce(this,e,null,nn,oe,{})}}const Be=[];function on(i,e){return{subscribe:dt(i,e).subscribe}}function dt(i,e=L){let t;const n=new Set;function s(l){if(oe(i,l)&&(i=l,t)){const a=!Be.length;for(const f of n)f[1](),Be.push(f,i);if(a){for(let f=0;f{n.delete(f),n.size===0&&t&&(t(),t=null)}}return{set:s,update:r,subscribe:o}}function wi(i,e,t){const n=!Array.isArray(i),s=n?[i]:i;if(!s.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const r=e.length<2;return on(t,(o,l)=>{let a=!1;const f=[];let _=0,v=L;const d=()=>{if(_)return;v();const p=e(n?f[0]:f,o,l);r?o(p):v=Et(p)?p:L},h=s.map((p,g)=>vi(p,y=>{f[g]=y,_&=~(1<{_|=1<console.error(`Error when writing value from persisted store "${i}" to ${d}`,E),g=(a=t==null?void 0:t.onParseError)!=null?a:(E,P)=>console.error(`Error when parsing ${E?'"'+E+'"':"value"} from persisted store "${i}"`,P),y=(f=t==null?void 0:t.beforeRead)!=null?f:E=>E,M=(_=t==null?void 0:t.beforeWrite)!=null?_:E=>E,T=typeof window<"u"&&typeof document<"u",w=T?rn(d):null;function F(E,P){const b=M(P);try{w==null||w.setItem(E,v.stringify(b))}catch(C){p(C)}}function H(){function E(O){try{return v.parse(O)}catch(z){g(O,z)}}const P=w==null?void 0:w.getItem(i);if(P==null)return e;const b=E(P);return b==null?e:y(b)}if(!wt[d][i]){const E=H(),P=dt(E,O=>{if(T&&d=="local"&&h){const z=J=>{if(J.key===i&&J.newValue){let x;try{x=v.parse(J.newValue)}catch(ee){g(J.newValue,ee);return}const Le=y(x);O(Le)}};return window.addEventListener("storage",z),()=>window.removeEventListener("storage",z)}}),{subscribe:b,set:C}=P;wt[d][i]={set(O){C(O),F(i,O)},update(O){return P.update(z=>{const J=O(z);return F(i,J),J})},reset(){this.set(e)},subscribe:b}}return wt[d][i]}function Kt(){return{collapseMode:"non-application",collapseCustomHide:"",collapseCustomShow:"",removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:.001,timeFormat:"absolute"}}const K=Pt("pyinstrument:viewOptionsCallStack",Kt(),{syncTabs:!0,beforeRead(i){return{...Kt(),...i}}}),Qe=Pt("pyinstrument:viewOptions",{viewMode:"call-stack"},{syncTabs:!1}),Ke=Pt("pyinstrument:viewOptionsTimeline",{removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:1e-4},{syncTabs:!0});class ln extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function an(i,e){const t=e*(i.length-1),n=Math.floor(t),s=Math.ceil(t),r=i[n],o=i[s],l=t-n;return un(l,{to:[r,o]})}function cn(i,e,t){return i===1/0?(console.warn("clamp: value is Infinity, returning `max`",i),t):i===-1/0?(console.warn("clamp: value is -Infinity, returning `min`",i),e):Number.isFinite(i)?it?t:i:(console.warn("clamp: value isn't finite, returning `min`",i),e)}function ze(i,e){const{from:t=[0,1],to:n=[0,1]}=e,s=e.clamp||!1;let r=(i-t[0])/(t[1]-t[0])*(n[1]-n[0])+n[0];return s&&(r=cn(r,Math.min(n[0],n[1]),Math.max(n[0],n[1]))),r}function un(i,e){return`rgb( + ${ze(i,{from:e.from,to:[e.to[0][0],e.to[1][0]],clamp:e.clamp})}, + ${ze(i,{from:e.from,to:[e.to[0][1],e.to[1][1]],clamp:e.clamp})}, + ${ze(i,{from:e.from,to:[e.to[0][2],e.to[1][2]],clamp:e.clamp})} + )`}function fn(i){if(i.substr(0,1)=="#"){var e=(i.length-1)/3,t=[17,1,.062272][e-1];return[Math.round(parseInt(i.substr(1,e),16)*t),Math.round(parseInt(i.substr(1+e,e),16)*t),Math.round(parseInt(i.substr(1+2*e,e),16)*t)]}else return i.split("(")[1].split(")")[0].split(",").map(n=>+n)}function dn(i,e,t={}){const{ignore:n=[],capture:s=!0}=t,r=window;if(!r)return()=>{};let o=!0,l=!1;const a=h=>n.some(p=>typeof p=="string"?Array.from(document.querySelectorAll(p)).some(g=>g===h.target||h.composedPath().includes(g)):p&&(h.target===p||h.composedPath().includes(p))),f=h=>{if(!(!i||i===h.target||h.composedPath().includes(i))){if(h.detail===0&&(o=!a(h)),!o){o=!0;return}e(h)}},_=h=>{l||(l=!0,setTimeout(()=>{l=!1},0),f(h))},v=h=>{o=!a(h)&&!!(i&&!h.composedPath().includes(i))};return r.addEventListener("click",_,{passive:!0,capture:s}),r.addEventListener("pointerdown",v,{passive:!0}),()=>{r.removeEventListener("click",_,{capture:s}),r.removeEventListener("pointerdown",v)}}function hn(i){const e=document.createElement("div");return e.appendChild(document.createTextNode(i)),e.innerHTML}function At(i){return hn(i).replace(/(\/|\\)/g,t=>`${t}`)}function mn(i,e){if(i.length==0)return null;let t=i[0],n=e(t);for(const s of i){const r=e(s);r>n&&(t=s,n=r)}return t}function ht(){return Math.random().toString(36).substring(2)}function pn(i){let e,t,n,s,r,o,l,a,f,_,v,d,h,p,g,y,M,T,w,F,H,E,P,b,C,O,z,J,x,Le,ee,Q,U,Ae,W,je,Ue,re,j,Ye,te,fe,de,_e,he,ye,Xe,Te,G,Ie,Ee,Ge,q,N,Y,It,it,Ot,Dt,Oe,Ce,Ht,De,nt,Vt,Nt,ge,Bt,xt,He,st,$t,Ve,ot,rt,ie,zt,qt,lt,at,ne,Wt,pt,vt,_t,jt;return pt=yt(i[5][0]),vt=yt(i[5][1]),{c(){e=m("div"),t=m("div"),n=m("div"),n.textContent="Collapse frames",s=k(),r=m("div"),o=m("div"),l=m("input"),a=k(),f=m("label"),_=R("Library code"),v=k(),d=m("div"),d.textContent="Code run from the Python stdlib, a virtualenv, or a conda env will be collapsed.",h=k(),p=m("div"),g=m("input"),y=k(),M=m("label"),T=R("Custom"),w=k(),F=m("div"),H=R(`Regex on the source file path. + `),E=m("div"),P=m("label"),P.textContent="Show",b=k(),C=m("input"),O=k(),z=m("label"),z.textContent="Hide",J=k(),x=m("input"),Le=R(` + If neither match, the library code rule is used.`),ee=k(),Q=m("div"),U=m("input"),Ae=k(),W=m("label"),je=R("Disabled"),Ue=k(),re=m("div"),j=m("div"),j.textContent="Remove frames",Ye=k(),te=m("div"),fe=m("div"),de=m("input"),_e=k(),he=m("label"),ye=R("importlib machinery"),Xe=k(),Te=m("div"),G=m("input"),Ie=k(),Ee=m("label"),Ge=R("Frames declaring __traceback_hide__"),q=k(),N=m("div"),Y=m("input"),It=k(),it=m("label"),Ot=R("pyinstrument frames"),Dt=k(),Oe=m("div"),Ce=m("input"),Ht=k(),De=m("span"),nt=m("label"),Vt=R("Frames with durations less than"),Nt=k(),ge=m("input"),Bt=R(` + % of the total time`),xt=k(),He=m("div"),st=m("div"),st.textContent="Time format",$t=k(),Ve=m("div"),ot=m("div"),rt=m("label"),ie=m("input"),zt=R(` + Absolute time in seconds`),qt=k(),lt=m("div"),at=m("label"),ne=m("input"),Wt=R(` + Percentage of the total run time`),c(n,"class","name svelte-1pecl4m"),c(l,"id",i[1]+"collapseModeAll"),c(l,"type","radio"),l.__value="non-application",le(l,l.__value),c(l,"class","svelte-1pecl4m"),c(f,"for",i[1]+"collapseModeAll"),c(d,"class","description svelte-1pecl4m"),c(o,"class","option svelte-1pecl4m"),c(g,"id",i[1]+"collapseModeCustom"),c(g,"type","radio"),g.__value="custom",le(g,g.__value),c(g,"class","svelte-1pecl4m"),c(M,"for",i[1]+"collapseModeCustom"),c(P,"for","collapseCustomShow"),c(P,"class","svelte-1pecl4m"),c(C,"id","collapseCustomShow"),c(C,"type","text"),c(C,"placeholder","myproject"),c(C,"spellcheck","false"),c(C,"autocapitalize","off"),c(C,"autocomplete","off"),c(C,"autocorrect","off"),c(C,"class","svelte-1pecl4m"),c(z,"for","collapseCustomHide"),c(z,"class","svelte-1pecl4m"),c(x,"id","collapseCustomHide"),c(x,"type","text"),c(x,"placeholder",".*/lib/.*"),c(x,"spellcheck","false"),c(x,"autocapitalize","off"),c(x,"autocomplete","off"),c(x,"autocorrect","off"),c(x,"class","svelte-1pecl4m"),c(E,"class","mini-input-grid svelte-1pecl4m"),c(F,"class","description svelte-1pecl4m"),c(p,"class","option svelte-1pecl4m"),c(U,"id",i[1]+"collapseModeDisabled"),c(U,"type","radio"),U.__value="disabled",le(U,U.__value),c(U,"class","svelte-1pecl4m"),c(W,"for",i[1]+"collapseModeDisabled"),c(Q,"class","option svelte-1pecl4m"),c(r,"class","body"),c(t,"class","option-group svelte-1pecl4m"),c(j,"class","name svelte-1pecl4m"),c(de,"id",i[1]+"removeImportlib"),c(de,"type","checkbox"),c(de,"class","svelte-1pecl4m"),c(he,"for",i[1]+"removeImportlib"),c(fe,"class","option svelte-1pecl4m"),c(G,"id",i[1]+"removeTracebackHide"),c(G,"type","checkbox"),c(G,"class","svelte-1pecl4m"),c(Ee,"for",i[1]+"removeTracebackHide"),c(Te,"class","option svelte-1pecl4m"),c(Y,"id",i[1]+"removePyinstrument"),c(Y,"type","checkbox"),c(Y,"class","svelte-1pecl4m"),c(it,"for",i[1]+"removePyinstrument"),c(N,"class","option svelte-1pecl4m"),c(Ce,"id",i[1]+"removeIrrelevant"),c(Ce,"type","checkbox"),c(Ce,"class","svelte-1pecl4m"),c(nt,"for",i[1]+"removeIrrelevant"),c(ge,"type","number"),ge.value=i[2](),c(ge,"min","0"),c(ge,"max","99"),c(ge,"step","0.01"),Z(ge,"width","4em"),c(ge,"class","svelte-1pecl4m"),c(Oe,"class","option svelte-1pecl4m"),c(te,"class","body"),c(re,"class","option-group svelte-1pecl4m"),c(st,"class","name svelte-1pecl4m"),c(ie,"type","radio"),ie.__value="absolute",le(ie,ie.__value),c(ie,"class","svelte-1pecl4m"),c(ot,"class","option svelte-1pecl4m"),c(ne,"type","radio"),ne.__value="proportion",le(ne,ne.__value),c(ne,"class","svelte-1pecl4m"),c(lt,"class","option svelte-1pecl4m"),c(Ve,"class","body"),c(He,"class","option-group svelte-1pecl4m"),c(e,"class","view-options-call-stack svelte-1pecl4m"),pt.p(ie,ne),vt.p(l,g,U)},m(X,se){I(X,e,se),u(e,t),u(t,n),u(t,s),u(t,r),u(r,o),u(o,l),l.checked=l.__value===i[0].collapseMode,u(o,a),u(o,f),u(f,_),u(o,v),u(o,d),u(r,h),u(r,p),u(p,g),g.checked=g.__value===i[0].collapseMode,u(p,y),u(p,M),u(M,T),u(p,w),u(p,F),u(F,H),u(F,E),u(E,P),u(E,b),u(E,C),le(C,i[0].collapseCustomShow),u(E,O),u(E,z),u(E,J),u(E,x),le(x,i[0].collapseCustomHide),u(F,Le),u(r,ee),u(r,Q),u(Q,U),U.checked=U.__value===i[0].collapseMode,u(Q,Ae),u(Q,W),u(W,je),u(e,Ue),u(e,re),u(re,j),u(re,Ye),u(re,te),u(te,fe),u(fe,de),de.checked=i[0].removeImportlib,u(fe,_e),u(fe,he),u(he,ye),u(te,Xe),u(te,Te),u(Te,G),G.checked=i[0].removeTracebackHide,u(Te,Ie),u(Te,Ee),u(Ee,Ge),u(te,q),u(te,N),u(N,Y),Y.checked=i[0].removePyinstrument,u(N,It),u(N,it),u(it,Ot),u(te,Dt),u(te,Oe),u(Oe,Ce),Ce.checked=i[0].removeIrrelevant,u(Oe,Ht),u(Oe,De),u(De,nt),u(nt,Vt),u(De,Nt),u(De,ge),u(De,Bt),u(e,xt),u(e,He),u(He,st),u(He,$t),u(He,Ve),u(Ve,ot),u(ot,rt),u(rt,ie),ie.checked=ie.__value===i[0].timeFormat,u(rt,zt),u(Ve,qt),u(Ve,lt),u(lt,at),u(at,ne),ne.checked=ne.__value===i[0].timeFormat,u(at,Wt),_t||(jt=[B(l,"change",i[4]),B(g,"change",i[6]),B(C,"input",i[7]),B(x,"input",i[8]),B(U,"change",i[9]),B(de,"change",i[10]),B(G,"change",i[11]),B(Y,"change",i[12]),B(Ce,"change",i[13]),B(ge,"input",i[3]),B(ie,"change",i[14]),B(ne,"change",i[15])],_t=!0)},p(X,[se]){se&1&&(l.checked=l.__value===X[0].collapseMode),se&1&&(g.checked=g.__value===X[0].collapseMode),se&1&&C.value!==X[0].collapseCustomShow&&le(C,X[0].collapseCustomShow),se&1&&x.value!==X[0].collapseCustomHide&&le(x,X[0].collapseCustomHide),se&1&&(U.checked=U.__value===X[0].collapseMode),se&1&&(de.checked=X[0].removeImportlib),se&1&&(G.checked=X[0].removeTracebackHide),se&1&&(Y.checked=X[0].removePyinstrument),se&1&&(Ce.checked=X[0].removeIrrelevant),se&1&&(ie.checked=ie.__value===X[0].timeFormat),se&1&&(ne.checked=ne.__value===X[0].timeFormat)},i:L,o:L,d(X){X&&S(e),pt.r(),vt.r(),_t=!1,ae(jt)}}}function vn(i,e,t){let n;be(i,K,w=>t(0,n=w));const s=ht();function r(){return(n.removeIrrelevantThreshold*100).toLocaleString(void 0,{maximumFractionDigits:4})}function o(w){Bi(K,n.removeIrrelevantThreshold=w.currentTarget.valueAsNumber/100,n)}const l=[[],[]];function a(){n.collapseMode=this.__value,K.set(n)}function f(){n.collapseMode=this.__value,K.set(n)}function _(){n.collapseCustomShow=this.value,K.set(n)}function v(){n.collapseCustomHide=this.value,K.set(n)}function d(){n.collapseMode=this.__value,K.set(n)}function h(){n.removeImportlib=this.checked,K.set(n)}function p(){n.removeTracebackHide=this.checked,K.set(n)}function g(){n.removePyinstrument=this.checked,K.set(n)}function y(){n.removeIrrelevant=this.checked,K.set(n)}function M(){n.timeFormat=this.__value,K.set(n)}function T(){n.timeFormat=this.__value,K.set(n)}return[n,s,r,o,a,l,f,_,v,d,h,p,g,y,M,T]}class _n extends ue{constructor(e){super(),ce(this,e,vn,pn,oe,{})}}function gn(i){let e,t,n,s,r,o,l,a,f,_,v,d,h,p,g,y,M,T,w,F,H,E,P,b;return{c(){e=m("div"),t=m("div"),n=m("div"),n.textContent="Remove frames",s=k(),r=m("div"),o=m("div"),l=m("input"),a=k(),f=m("label"),_=R("importlib machinery"),v=k(),d=m("div"),h=m("input"),p=k(),g=m("label"),y=R("Frames declaring __traceback_hide__"),M=k(),T=m("div"),w=m("input"),F=k(),H=m("label"),E=R("pyinstrument frames"),c(n,"class","name"),c(l,"id",i[1]+"removeImportlib"),c(l,"type","checkbox"),c(f,"for",i[1]+"removeImportlib"),c(o,"class","option"),c(h,"id",i[1]+"removeTracebackHide"),c(h,"type","checkbox"),c(g,"for",i[1]+"removeTracebackHide"),c(d,"class","option"),c(w,"id",i[1]+"removePyinstrument"),c(w,"type","checkbox"),c(H,"for",i[1]+"removePyinstrument"),c(T,"class","option"),c(r,"class","body"),c(t,"class","option-group"),c(e,"class","view-options-timeline svelte-vsz8zm")},m(C,O){I(C,e,O),u(e,t),u(t,n),u(t,s),u(t,r),u(r,o),u(o,l),l.checked=i[0].removeImportlib,u(o,a),u(o,f),u(f,_),u(r,v),u(r,d),u(d,h),h.checked=i[0].removeTracebackHide,u(d,p),u(d,g),u(g,y),u(r,M),u(r,T),u(T,w),w.checked=i[0].removePyinstrument,u(T,F),u(T,H),u(H,E),P||(b=[B(l,"change",i[2]),B(h,"change",i[3]),B(w,"change",i[4])],P=!0)},p(C,[O]){O&1&&(l.checked=C[0].removeImportlib),O&1&&(h.checked=C[0].removeTracebackHide),O&1&&(w.checked=C[0].removePyinstrument)},i:L,o:L,d(C){C&&S(e),P=!1,ae(b)}}}function bn(i,e,t){let n;be(i,Ke,a=>t(0,n=a));const s=ht();function r(){n.removeImportlib=this.checked,Ke.set(n)}function o(){n.removeTracebackHide=this.checked,Ke.set(n)}function l(){n.removePyinstrument=this.checked,Ke.set(n)}return[n,s,r,o,l]}class wn extends ue{constructor(e){super(),ce(this,e,bn,gn,oe,{})}}function yn(i){let e,t;return e=new wn({}),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Tn(i){let e,t;return e=new _n({}),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function kn(i){let e,t,n,s,r,o,l,a,f;const _=[Tn,yn],v=[];function d(h,p){return h[0].viewMode==="call-stack"?0:h[0].viewMode==="timeline"?1:-1}return~(l=d(i))&&(a=v[l]=_[l](i)),{c(){e=m("div"),t=m("div"),n=m("div"),s=R(i[3]),r=k(),o=m("div"),a&&a.c(),c(n,"class","title-row svelte-rpk7lo"),c(o,"class","body svelte-rpk7lo"),c(t,"class","box svelte-rpk7lo"),c(e,"class","view-options svelte-rpk7lo")},m(h,p){I(h,e,p),u(e,t),u(t,n),u(n,s),u(t,r),u(t,o),~l&&v[l].m(o,null),i[4](t),i[5](e),f=!0},p(h,[p]){(!f||p&8)&&me(s,h[3]);let g=l;l=d(h),l!==g&&(a&&(Fe(),V(v[g],1,1,()=>{v[g]=null}),Pe()),~l?(a=v[l],a||(a=v[l]=_[l](h),a.c()),D(a,1),a.m(o,null)):a=null)},i(h){f||(D(a),f=!0)},o(h){V(a),f=!1},d(h){h&&S(e),~l&&v[l].d(),i[4](null),i[5](null)}}}function An(i,e,t){let n;be(i,Qe,d=>t(0,n=d));const s=ji();function r(){s("close")}let o,l;Tt(()=>{if(l)return dn(l,r,{ignore:[".js-view-options-button"]})});function a(){if(!o||!l)return;const d=o.getBoundingClientRect(),p=l.getBoundingClientRect().width;d.right-p-20<0?t(2,l.style.right=`${d.right-p-20}px`,l):t(2,l.style.right="0",l)}Tt(()=>(a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)));let f="View options";function _(d){ke[d?"unshift":"push"](()=>{l=d,t(2,l)})}function v(d){ke[d?"unshift":"push"](()=>{o=d,t(1,o)})}return i.$$.update=()=>{i.$$.dirty&1&&(n.viewMode==="call-stack"?t(3,f="Call stack view options"):n.viewMode==="timeline"&&t(3,f="Timeline view options"))},[n,o,l,f,_,v]}class En extends ue{constructor(e){super(),ce(this,e,An,kn,oe,{})}}function Zt(i){let e,t;return e=new En({}),e.$on("close",i[9]),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p:L,i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Cn(i){let e,t,n,s,r,o,l,a,f=At(i[0].target_description)+"",_,v,d,h,p,g,y,M,T,w,F,H,E,P=i[0].sampleCount+"",b,C,O,z,J,x,Le,ee,Q,U,Ae,W,je,Ue,re,j,Ye,te,fe,de,_e,he,ye,Xe,Te,G,Ie,Ee,Ge;r=new sn({}),ye=new tn({});let q=i[1]&&Zt(i);return Ie=yt(i[7][0]),{c(){e=m("div"),t=m("div"),n=m("div"),s=m("div"),we(r.$$.fragment),o=k(),l=m("div"),a=m("div"),_=k(),v=m("div"),d=m("div"),h=m("span"),h.textContent="Recorded:",p=k(),g=m("span"),g.textContent=`${i[3]}`,y=k(),M=m("br"),T=k(),w=m("div"),F=m("span"),F.textContent="Samples:",H=k(),E=m("span"),b=R(P),C=k(),O=m("div"),z=m("span"),z.textContent="CPU utilization:",J=k(),x=m("span"),x.textContent=`${(i[4]*100).toFixed(0)}%`,Le=k(),ee=m("div"),Q=m("div"),U=R(`View: + `),Ae=m("label"),W=m("input"),je=R(` + Call stack`),Ue=k(),re=m("label"),j=m("input"),Ye=R(` + Timeline`),te=k(),fe=m("div"),de=k(),_e=m("div"),he=m("button"),we(ye.$$.fragment),Xe=R(` + View options`),Te=k(),q&&q.c(),c(s,"class","logo svelte-qdxst2"),c(a,"class","target-description svelte-qdxst2"),c(h,"class","metric-label svelte-qdxst2"),c(g,"class","metric-value svelte-qdxst2"),c(d,"class","metric date svelte-qdxst2"),c(M,"class","svelte-qdxst2"),c(F,"class","metric-label svelte-qdxst2"),c(E,"class","metric-value svelte-qdxst2"),c(w,"class","metric svelte-qdxst2"),c(z,"class","metric-label svelte-qdxst2"),c(x,"class","metric-value svelte-qdxst2"),c(O,"class","metric svelte-qdxst2"),c(v,"class","metrics svelte-qdxst2"),c(W,"type","radio"),W.__value="call-stack",le(W,W.__value),c(W,"class","svelte-qdxst2"),c(Ae,"class","svelte-qdxst2"),c(j,"type","radio"),j.__value="timeline",le(j,j.__value),c(j,"class","svelte-qdxst2"),c(re,"class","svelte-qdxst2"),c(Q,"class","toggle"),c(fe,"class","spacer"),Z(fe,"flex","1"),c(he,"class","js-view-options-button svelte-qdxst2"),c(_e,"class","button-container svelte-qdxst2"),c(ee,"class","view-options svelte-qdxst2"),c(l,"class","layout svelte-qdxst2"),c(n,"class","row svelte-qdxst2"),c(t,"class","margins"),c(e,"class","header svelte-qdxst2"),Ie.p(W,j)},m(N,Y){I(N,e,Y),u(e,t),u(t,n),u(n,s),pe(r,s,null),u(n,o),u(n,l),u(l,a),a.innerHTML=f,u(l,_),u(l,v),u(v,d),u(d,h),u(d,p),u(d,g),u(v,y),u(v,M),u(v,T),u(v,w),u(w,F),u(w,H),u(w,E),u(E,b),u(v,C),u(v,O),u(O,z),u(O,J),u(O,x),u(l,Le),u(l,ee),u(ee,Q),u(Q,U),u(Q,Ae),u(Ae,W),W.checked=W.__value===i[2].viewMode,u(Ae,je),u(Q,Ue),u(Q,re),u(re,j),j.checked=j.__value===i[2].viewMode,u(re,Ye),u(ee,te),u(ee,fe),u(ee,de),u(ee,_e),u(_e,he),pe(ye,he,null),u(he,Xe),u(_e,Te),q&&q.m(_e,null),G=!0,Ee||(Ge=[B(W,"change",i[6]),B(j,"change",i[8]),B(he,"click",Mt(Ct(i[5])))],Ee=!0)},p(N,[Y]){(!G||Y&1)&&f!==(f=At(N[0].target_description)+"")&&(a.innerHTML=f),(!G||Y&1)&&P!==(P=N[0].sampleCount+"")&&me(b,P),Y&4&&(W.checked=W.__value===N[2].viewMode),Y&4&&(j.checked=j.__value===N[2].viewMode),N[1]?q?(q.p(N,Y),Y&2&&D(q,1)):(q=Zt(N),q.c(),D(q,1),q.m(_e,null)):q&&(Fe(),V(q,1,1,()=>{q=null}),Pe())},i(N){G||(D(r.$$.fragment,N),D(ye.$$.fragment,N),D(q),G=!0)},o(N){V(r.$$.fragment,N),V(ye.$$.fragment,N),V(q),G=!1},d(N){N&&S(e),ve(r),ve(ye),q&&q.d(),Ie.r(),Ee=!1,ae(Ge)}}}function Mn(i,e,t){let n;be(i,Qe,h=>t(2,n=h));let{session:s}=e;const r=new Date(s.startTime*1e3).toLocaleString(void 0,{dateStyle:"long",timeStyle:"medium"}),o=s.cpuTime/s.duration;let l=!1;function a(h){t(1,l=!l)}const f=[[]];function _(){n.viewMode=this.__value,Qe.set(n)}function v(){n.viewMode=this.__value,Qe.set(n)}const d=()=>t(1,l=!1);return i.$$set=h=>{"session"in h&&t(0,s=h.session)},[s,l,n,r,o,a,_,f,v,d]}class Fn extends ue{constructor(e){super(),ce(this,e,Mn,Cn,oe,{session:0})}}const Pn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWmSURBVHgBtVc7i11VFF5rn3PvPKoLFlqmDGPhaGVpJQoWAZEEGxERFBsDgnY6KFpaWWrQysRGf4BgmSKQFCKWKQMKTqNzz2svv/XY55ybeycTCw+z736cs/f61rdee5hmz/Hx85c66m4QyTEzrdAo4cd6EuuJ2P4wtbmUgfZkCyRoWVcwyMI29ybW47sfhRfXf793+z4X4ZchPEl3F2esElYrbRVaEjQGEKGE3jcUofGwlIEBygoACAa0fmDrdV4AOAg6FV4+W49nUPdlEW4AElGNtqjZ+hqIdI2NAC7KuvAZloyJCR+IukGmF5A6iH/IbEBWLN2NevbBFQ6tCoAF3u7VggYQtQJyFlygOAADI74Jf669QDiWWh6xFRMUgLF6PAGYkcgGgGkBE/x8AiSVaykG0AUxlgm7BY0BUMAQL8R77LM96F98A98kBeu+kAdlgA0MntUGACmOFDQl5sm+Rai6lwpMLtiEgSVGE8wVFBkAB7XcU+rdJOoLSU0x8Aii3ta/0AWqMHjlM6LDPaYDHLSsnRn9pjMny2jBCDSu9H3tDqpCmw4C6lgHqAQmWB05uwwF8RCAQpU7jIbQYCElBsjAlabfqJdnD7lKwzVcIVVOgmKpF2g921pS8/QRvuETmwDEKZdwFHMocYHffYSfBc0opojVIomjx/dY64CkxVktMsgar16/IhbKygANruwWA+YDkURUcNHQaK5ps1XhBwaAzf6M9YzWq3Ac1EKACm80cB8KV6IdPsCR0aQAMBAaUkxXPyU6WDqlypKaSEOtmCCpDyAKFgu1gSecrhdar4n++VsiGUVWDHUpdJkYEPEkEyDc7paHTShXbkuNhqQfaF5wMt16lff69JYFFYT3A8AYgFxku5xtBtw9R7YsEiH85hcYLIsfuO0lfCCHvTtMWxszNRhDebp+LRsTGobFr0zBiO5tBnhWaZgiDwD5gi3Wiw+YcDAwoDfB+MaFq83RsP8M5zSYdFjsBwfh9YAjErbyQLHNVNUsH2Dl2odCh4dE+0vQXjtI9YG2z05zOKvSbdR3eKdtLTbugVKzoOQxC+7KA5NtJPiXEZaH5xDglMrOBMHTWxdWhA/QVqtgEdx3EtVwSkDOxE4GHESpCZzcHLe+4gg3HA7P69jpfvutTA0GTQNNkXAs5UYJVjC593keik/JBohzALjQsXbrJtRksRgntzm7nVX4GnZumtC4D23N4aIAZWdv9LyZv+3IA87AlHY1HQu9+q7Qwb7nAQ01FbQ+g5NBaNOKA2jdD0bg4+UjzCrbqu6IgrLB6aLRF6KWB0ZNUj15QvLCRVa8PNanqiq7pM7kbVXDEvdaipMmHIRfBa2//aYC9WI5vjH6ydLsB1ezpePiK9PhYcoLnjSK5kljNUWqvXppKdVxo4XFhIsJ93gXy/8clxIvt0X7i4XrU8+1D+wGgKPGW/UCzHfew9VsXywVZxbz8GYdKqS4rCTfZ/NZvD8WA/Yxu/aW661F7q+cIbsXVO6EcVf3b0t9SIXFx9N+kwEO3w8QVmhggq+/9xSroVdiv5TZlr0SanL6/KXOK5SaL9b/G4DRdDzONZbPuAjXS4bnfPWBPrJkjhzpYbdR8OeXz62nvBt3HD3z3F/2f0Fyx9O7XL2HAoj7YG33AK8Bag4TrJlOa0DrrVtrj7DsPBtKlgstsZGIcOW+B0wvlMP1EOqcCh1rTldb+/Xcw2woqbaLeh/Vbl7vH/Vgx08TABrehO53ccJKK1ZWP+gjpRqAKdaN8jxLs5r7Bx5TMBm18kjxOOZ0ub/3flUW/nzw4PSJp568CT0vYXq5aGJgslc4o7doPI6dcis2eUq950Ug1DqF9NvQ/uVf79y5v+E1IptedEInNj+iT2L9Nfv9jf7gI/pFdP4D5rfoaYw/Lv+pReVRq/JOEEXOee/PAf7/PP8C3bt510T4rIwAAAAASUVORK5CYII=",Qt=dt({}),Jt=dt({});function yi(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.15?"#D8CB2A":i>.05?"#7ED321":"#58984f"}function ei(i,e,t){const n=i.slice();return n[21]=e[t],n}function ti(i){let e,t,n,s,r,o,l,a,f,_,v,d,h,p,g,y,M;return{c(){e=m("div"),t=m("div"),n=$("svg"),s=$("path"),r=k(),o=m("div"),l=R(i[6]),a=k(),f=m("div"),_=R(i[4]),v=k(),d=m("div"),h=R(i[5]),p=k(),g=m("div"),c(s,"d","M.937-.016L5.793 4.84.937 9.696z"),c(s,"fill",i[8]),c(s,"fill-rule","evenodd"),c(s,"fill-opacity",".582"),c(n,"width","6"),c(n,"height","10"),c(t,"class","frame-triangle svelte-7e9kco"),Me(t,"rotate",!i[9]),Z(t,"visibility",i[0].children.length>0?"visible":"hidden"),c(o,"class","time svelte-7e9kco"),Z(o,"color",i[8]),Z(o,"font-weight",i[11]<.15?500:600),c(f,"class","name svelte-7e9kco"),c(d,"class","code-position svelte-7e9kco"),c(e,"class","frame-description svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),Me(e,"application-code",i[0].isApplicationCode),Me(e,"children-visible",!i[9]),Z(e,"padding-left",`${i[2]*35}px`),c(g,"class","visual-guide svelte-7e9kco"),Z(g,"left",`${i[2]*35+21}px`),Z(g,"background-color",i[8])},m(T,w){I(T,e,w),u(e,t),u(t,n),u(n,s),u(e,r),u(e,o),u(o,l),u(e,a),u(e,f),u(f,_),u(e,v),u(e,d),u(d,h),I(T,p,w),I(T,g,w),y||(M=[B(e,"keydown",i[14]),B(e,"click",Mt(Ct(i[12])))],y=!0)},p(T,w){w&256&&c(s,"fill",T[8]),w&512&&Me(t,"rotate",!T[9]),w&1&&Z(t,"visibility",T[0].children.length>0?"visible":"hidden"),w&64&&me(l,T[6]),w&256&&Z(o,"color",T[8]),w&16&&me(_,T[4]),w&32&&me(h,T[5]),w&1&&Me(e,"application-code",T[0].isApplicationCode),w&512&&Me(e,"children-visible",!T[9]),w&4&&Z(e,"padding-left",`${T[2]*35}px`),w&4&&Z(g,"left",`${T[2]*35+21}px`),w&256&&Z(g,"background-color",T[8])},d(T){T&&(S(e),S(p),S(g)),y=!1,ae(M)}}}function ii(i){let e,t,n,s,r=i[0].group.frames.length-1+"",o,l,a,f,_,v;return{c(){e=m("div"),t=m("div"),n=m("div"),n.innerHTML='',s=k(),o=R(r),l=R(" frames hidden ("),a=R(i[7]),f=R(")"),c(n,"class","group-triangle svelte-7e9kco"),Me(n,"rotate",i[10]),c(t,"class","group-header-button svelte-7e9kco"),c(e,"class","group-header svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),Z(e,"padding-left",`${i[2]*35}px`)},m(d,h){I(d,e,h),u(e,t),u(t,n),u(t,s),u(t,o),u(t,l),u(t,a),u(t,f),_||(v=[B(e,"keydown",i[15]),B(e,"click",Mt(Ct(i[13])))],_=!0)},p(d,h){h&1024&&Me(n,"rotate",d[10]),h&1&&r!==(r=d[0].group.frames.length-1+"")&&me(o,r),h&128&&me(a,d[7]),h&4&&Z(e,"padding-left",`${d[2]*35}px`)},d(d){d&&S(e),_=!1,ae(v)}}}function ni(i){let e,t=[],n=new Map,s,r=We(i[0].children);const o=l=>l[21].uuid;for(let l=0;l0&&ni(i);return{c(){e=m("div"),r&&r.c(),t=k(),o&&o.c(),n=k(),l&&l.c(),c(e,"class","frame svelte-7e9kco")},m(a,f){I(a,e,f),r&&r.m(e,null),u(e,t),o&&o.m(e,null),u(e,n),l&&l.m(e,null),s=!0},p(a,[f]){a[3]?r?r.p(a,f):(r=ti(a),r.c(),r.m(e,t)):r&&(r.d(1),r=null),a[0].group&&a[0].group.rootFrame==a[0]&&!a[9]?o?o.p(a,f):(o=ii(a),o.c(),o.m(e,n)):o&&(o.d(1),o=null),!a[9]&&a[0].children.length>0?l?(l.p(a,f),f&513&&D(l,1)):(l=ni(a),l.c(),D(l,1),l.m(e,null)):l&&(Fe(),V(l,1,1,()=>{l=null}),Pe())},i(a){s||(D(l),s=!0)},o(a){V(l),s=!1},d(a){a&&S(e),r&&r.d(),o&&o.d(),l&&l.d()}}}function Ti(){const i='a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])',e=document.querySelector(".call-stack-view");if(!e)throw new Error("callStackElement not found");var t=Array.prototype.filter.call(e.querySelectorAll(i),function(n){return n.offsetWidth>0||n.offsetHeight>0||n===document.activeElement});return t}function oi(){const i=Ti();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e+1];t&&t.focus()}}function ri(){const i=Ti();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e-1];t&&t.focus()}}function Rn(i,e,t){let n,s,r,o,l;be(i,Jt,b=>t(16,r=b)),be(i,Qt,b=>t(17,o=b)),be(i,K,b=>t(18,l=b));let{frame:a}=e,{rootFrame:f}=e,{indent:_=0}=e,v;const d=a.time/f.time;let h,p;a.isSynthetic||a.filePathShort==null?p="":a.lineNo==null||a.lineNo===0?p=a.filePathShort:p=`${a.filePathShort}:${a.lineNo}`;let g,y=null;if(a.group){const b=a.group.libraries;b.length<4?y=b.join(", "):y=`${b[0]}, ${b[1]}, ${b[2]}...`}let M;M=yi(d);function T(b){w(a,!s,b.altKey)}function w(b,C,O=!0){if(Jt.update(z=>({...z,[b.uuid]:C})),O)for(const z of b.children)w(z,C,!0),b.group&&b.group.rootFrame==b&&F(b.group.id,!C)}function F(b,C){Qt.update(O=>({...O,[b]:C}))}function H(){a.group&&F(a.group.id,!n)}function E(b){let C=!0;b.key==="Enter"||b.key===" "?T(b):b.key==="ArrowLeft"&&!s?w(a,!0,b.altKey):b.key==="ArrowRight"&&s?w(a,!1,b.altKey):b.key==="ArrowUp"?ri():b.key==="ArrowDown"?oi():C=!1,C&&(b.preventDefault(),b.stopPropagation())}function P(b){let C=!0;b.key==="Enter"||b.key===" "?H():b.key==="ArrowLeft"&&a.group?F(a.group.id,!1):b.key==="ArrowRight"&&a.group?F(a.group.id,!0):b.key==="ArrowUp"?ri():b.key==="ArrowDown"?oi():C=!1,C&&(b.preventDefault(),b.stopPropagation())}return i.$$set=b=>{"frame"in b&&t(0,a=b.frame),"rootFrame"in b&&t(1,f=b.rootFrame),"indent"in b&&t(2,_=b.indent)},i.$$.update=()=>{var b,C;if(i.$$.dirty&131073&&(a.group?o[a.group.id??""]||((b=a.group)==null?void 0:b.rootFrame)===a||a.children.filter(O=>!O.group).length>1?t(3,v=!0):t(3,v=!1):t(3,v=!0)),i.$$.dirty&1&&(a.className?t(4,h=`${a.className}.${a.function}`):t(4,h=a.function)),i.$$.dirty&262145)if(l.timeFormat==="absolute")t(6,g=a.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(l.timeFormat==="proportion")t(6,g=`${(d*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(10,n=o[((C=a.group)==null?void 0:C.id)??""]===!0),i.$$.dirty&65537&&t(9,s=r[a.uuid]===!0)},[a,f,_,v,h,p,g,y,M,s,n,d,T,H,E,P,r,o,l]}let ki=class extends ue{constructor(e){super(),ce(this,e,Rn,Ln,oe,{frame:0,rootFrame:1,indent:2})}};function Ai(i,e,t){let n=i;if(n!=null)for(const s of Object.keys(i)){let r=i[s];for(const o of e)if(r=o(r,t),!r){delete n[s];break}n[s]=r}return n}const Sn="\0",In="[await]",tt="[self]",On="[out-of-context]",Dn="[root]",Hn=[In,tt,On,Dn],Vn="c",Nn="h";class et{constructor(e,t){A(this,"uuid",ht());A(this,"identifier");A(this,"_identifierParts");A(this,"startTime");A(this,"time",0);A(this,"absorbedTime",0);A(this,"group",null);A(this,"attributes");A(this,"_children",[]);A(this,"parent",null);A(this,"context");var r;this.identifier=e.identifier,this._identifierParts=this.identifier.split(Sn),this.startTime=e.startTime??t.threadStartTime(e.thread_id),this.time=e.time??0,this.attributes=e.attributes??{},this.context=t;let n=this.startTime;const s=(r=e.children)==null?void 0:r.map(o=>(o.startTime===void 0&&(o={...o,startTime:n},n+=o.time??0),n=o.startTime+(o.time??0),new et(o,t)));s&&this.addChildren(s)}cloneDeep(){return new et(this,this.context)}get children(){return this._children}addChild(e,t={}){if(e.removeFromParent(),e.parent=this,t.after){const n=this._children.indexOf(t.after);if(n==-1)throw new Error("After frame not found");this._children.splice(n+1,0,e)}else this._children.push(e)}addChildren(e,t={}){e=e.slice(),t.after?(e.slice().reverse(),e.forEach(s=>this.addChild(s,t))):e.forEach(n=>this.addChild(n,t))}removeFromParent(){if(this.parent){const e=this.parent._children.indexOf(this);this.parent._children.splice(e,1),this.parent=null}}getAttributes(e){return Object.keys(this.attributes).filter(n=>n.startsWith(e)).map(n=>({data:n.slice(1),time:this.attributes[n]}))}getAttributeValue(e){const t=this.getAttributes(e);if(!t||t.length==0)return null;let n=0;for(let s=0;st[n].time&&(n=s);return t[n].data}get hasTracebackHide(){return this.getAttributeValue(Nn)=="1"}get function(){return this._identifierParts[0]}get filePath(){return this._identifierParts[1]??null}get lineNo(){const e=this._identifierParts[2];return e?parseInt(e):null}get isSynthetic(){return Hn.includes(this.identifier)}get filePathShort(){return this.isSynthetic&&this.parent?this.parent.filePathShort:this.filePath?this.context.shortenPath(this.filePath):null}get isApplicationCode(){if(this.isSynthetic)return!1;const e=this.filePath;return!e||this.context.sysPrefixes.some(n=>e.startsWith(n))?!1:e.startsWith("<")?e.startsWith(""||e==""?this.parent?this.parent.isApplicationCode:!0:!1:!0}get proportionOfParent(){return this.parent?this.time/this.parent.time:1}get className(){return this.getAttributeValue(Vn)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class Bn{constructor(e){A(this,"id");A(this,"rootFrame");A(this,"_frames",[]);this.id=ht(),this.rootFrame=e}addFrame(e){e.group&&e.group.removeFrame(e),this._frames.push(e),e.group=this}removeFrame(e){if(e.group!==this)throw new Error("Frame not in group.");const t=this._frames.indexOf(e);if(t===-1)throw new Error("Frame not found in group.");this._frames.splice(t,1),e.group=null}get frames(){return this._frames}get exitFrames(){const e=[];for(const t of this.frames){let n=!1;for(const s of t.children)if(s.group!=this){n=!0;break}n&&e.push(t)}return e}get libraries(){const e=[];for(const t of this.frames){const n=t.library;n&&(e.includes(n)||e.push(n))}return e}}function mt(i,e){const{replaceWith:t}=e,n=i.parent;if(!n)throw new Error("Cannot delete the root frame");if(t=="children")n.addChildren(i.children,{after:i});else if(t=="self_time")n.addChild(new et({identifier:tt,time:i.time},n.context),{after:i});else if(t=="nothing")n.absorbedTime+=i.time;else throw new ln(t);i.removeFromParent(),Lt(i,!0)}function xn(i,e){if(i.parent!==e.parent)throw new Error("Both frames must have the same parent.");e.absorbedTime+=i.absorbedTime,e.time+=i.time,Object.entries(i.attributes).forEach(([t,n])=>{e.attributes[t]!==void 0?e.attributes[t]+=n:e.attributes[t]=n}),e.addChildren(i.children),i.removeFromParent(),Lt(i,!1)}function Lt(i,e){if(e&&i.children&&i.children.forEach(t=>{Lt(t,!0)}),i.group){const t=i.group;t.removeFrame(i),t.frames.length===1&&t.removeFrame(t.frames[0])}}function Rt(i,e){if(!i)return null;for(const t of i.children)Rt(t),t.filePath&&t.filePath.includes("Ei(n)),i._children.sort((n,s)=>s.time-n.time),i}function Ci(i,e){if(!i)return null;const t=e.hideRegex,n=e.showRegex;function s(o){const l=o.filePath||"",a=n&&new RegExp(n).test(l),f=t&&new RegExp(t).test(l);return a?!1:f?!0:!o.isApplicationCode}function r(o,l){l.addFrame(o),o.children.forEach(a=>{s(a)&&r(a,l)})}return i.children.forEach(o=>{if(!o.group&&s(o)&&o.children.some(s)){const l=new Bn(o);r(o,l)}Ci(o,e)}),i}function Mi(i,e,t=!0){if(!i)return null;let n=null;for(const s of i.children)s.identifier===tt?n?(n.time+=s.time,s.removeFromParent()):n=s:n=null;return t&&i.children.forEach(s=>Mi(s,e,!0)),i}function Fi(i,e){return i?(i.children.length===1&&i.children[0].identifier===tt&&mt(i.children[0],{replaceWith:"nothing"}),i.children.forEach(t=>Fi(t)),i):null}function Pi(i,e,t=null){if(!i)return null;t===null&&(t=i.time,t<=0&&(t=1e-44));const n=e.filterThreshold??.01;for(const s of i.children.slice())s.time/tPi(s,e,t)),i}function Li(i,e){if(!i)return null;const t=l=>mn(l,a=>a.time),n=l=>{var a;return((a=l.filePath)==null?void 0:a.includes("pyinstrument/__main__.py"))&&l.children.length>0},s=l=>{var a;return l.proportionOfParent>.8&&((a=l.filePath)==null?void 0:a.includes(""))&&l.children.length>0},r=l=>{var a;return l.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(l.filePath??"")||((a=l.filePath)==null?void 0:a.includes("")))&&l.children.length>0};let o=i;if(!n(o)||(o=t(o.children),!s(o))||(o=t(o.children),!r(o)))return i;for(;r(o);)o=t(o.children);return o.removeFromParent(),o}function Ri(i,e){return i?(i.children.forEach(t=>Ri(t)),i.group&&i.group.frames.length<3&&i.group.removeFrame(i),i):null}function li(i,e,t){const n=i.slice();return n[11]=e[t][0],n[12]=e[t][1],n}function $n(i){let e,t,n=We(Object.entries(i[3])),s=[];for(let o=0;oV(s[o],1,1,()=>{s[o]=null});return{c(){e=m("div");for(let o=0;oAll frames were filtered out.',c(e,"class","margins")},m(t,n){I(t,e,n)},p:L,i:L,o:L,d(t){t&&S(e)}}}function qn(i){let e,t;return e=new ki({props:{frame:i[12],rootFrame:i[12]}}),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p(n,s){const r={};s&8&&(r.frame=n[12]),s&8&&(r.rootFrame=n[12]),e.$set(r)},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Wn(i){let e;return{c(){e=m("div"),e.innerHTML='
All frames were filtered out.
',c(e,"class","margins")},m(t,n){I(t,e,n)},p:L,i:L,o:L,d(t){t&&S(e)}}}function ai(i){let e,t,n,s;const r=[Wn,qn],o=[];function l(a,f){return a[12]?1:0}return e=l(i),t=o[e]=r[e](i),{c(){t.c(),n=gi()},m(a,f){o[e].m(a,f),I(a,n,f),s=!0},p(a,f){let _=e;e=l(a),e===_?o[e].p(a,f):(Fe(),V(o[_],1,1,()=>{o[_]=null}),Pe(),t=o[e],t?t.p(a,f):(t=o[e]=r[e](a),t.c()),D(t,1),t.m(n.parentNode,n))},i(a){s||(D(t),s=!0)},o(a){V(t),s=!1},d(a){a&&S(n),o[e].d(a)}}}function jn(i){let e,t,n,s,r,o,l;const a=[zn,$n],f=[];function _(v,d){return v[3]?1:0}return n=_(i),s=f[n]=a[n](i),{c(){e=m("div"),t=m("div"),s.c(),r=k(),o=m("div"),c(t,"class","scroll-inner svelte-1hebm9u"),c(o,"class","scroll-size-fixer svelte-1hebm9u"),c(e,"class","call-stack-view svelte-1hebm9u")},m(v,d){I(v,e,d),u(e,t),f[n].m(t,null),i[8](t),u(e,r),u(e,o),i[9](o),i[10](e),l=!0},p(v,[d]){let h=n;n=_(v),n===h?f[n].p(v,d):(Fe(),V(f[h],1,1,()=>{f[h]=null}),Pe(),s=f[n],s?s.p(v,d):(s=f[n]=a[n](v),s.c()),D(s,1),s.m(t,null))},i(v){l||(D(s),l=!0)},o(v){V(s),l=!1},d(v){v&&S(e),f[n].d(),i[8](null),i[9](null),i[10](null)}}}function Un(i,e,t){let n,{session:s}=e;const r=wi([K],([p])=>{const g=[p.removeImportlib?Rt:null,p.removeTracebackHide?St:null,Mi,Ei,Fi,p.removeIrrelevant?Pi:null,p.removePyinstrument?Li:null,p.collapseMode!=="disabled"?Ci:null,Ri].filter(M=>M!==null),y={filterThreshold:p.removeIrrelevantThreshold,hideRegex:p.collapseMode=="custom"?p.collapseCustomHide:void 0,showRegex:p.collapseMode=="custom"?p.collapseCustomShow:void 0};return{processors:g,options:y}});be(i,r,p=>t(7,n=p));let o,l,a;Tt(()=>{let p=0;const g=o;if(!g)throw new Error("element not set");if(!l)throw new Error("scrollInnerElement not set");if(!a)throw new Error("scrollSizeFixerElement not set");const y=new ResizeObserver(()=>{const T=l.getBoundingClientRect().height;T>p&&(p=T,t(2,a.style.top=`${p-1}px`,a))});y.observe(l);let M;return g.addEventListener("scroll",M=()=>{let T=g.scrollTop+g.clientHeight;const w=l.getBoundingClientRect().height;T{y.disconnect(),g.removeEventListener("scroll",M)}});let f,_=[];for(const p of Object.keys(s.rootFrames))_[p]=s.rootFrames[p].cloneDeep();function v(p){ke[p?"unshift":"push"](()=>{l=p,t(1,l)})}function d(p){ke[p?"unshift":"push"](()=>{a=p,t(2,a)})}function h(p){ke[p?"unshift":"push"](()=>{o=p,t(0,o)})}return i.$$set=p=>{"session"in p&&t(5,s=p.session)},i.$$.update=()=>{i.$$.dirty&192&&t(3,f=Ai(_,n.processors,n.options))},[o,l,a,f,r,s,_,n,v,d,h]}class Yn extends ue{constructor(e){super(),ce(this,e,Un,jn,oe,{session:5})}}class Xn{constructor(e){A(this,"mediaQueryList",null);this.onDevicePixelRatioChanged=e,this._onChange=this._onChange.bind(this),this.createMediaQueryList()}createMediaQueryList(){this.removeMediaQueryList();let e=`(resolution: ${window.devicePixelRatio}dppx)`;this.mediaQueryList=matchMedia(e),this.mediaQueryList.addEventListener("change",this._onChange)}removeMediaQueryList(){var e;(e=this.mediaQueryList)==null||e.removeEventListener("change",this._onChange),this.mediaQueryList=null}_onChange(e){this.onDevicePixelRatioChanged(),this.createMediaQueryList()}destroy(){this.removeMediaQueryList()}}class Gn{constructor(e){A(this,"canvas");A(this,"_size_observer");A(this,"_devicePixelRatioObserver");A(this,"drawAnimationRequest",null);this.container=e,getComputedStyle(e).position!="absolute"&&(e.style.position="relative"),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.container.appendChild(this.canvas),this.setCanvasSize=this.setCanvasSize.bind(this),this._size_observer=new ResizeObserver(this.setCanvasSize),this._size_observer.observe(e),this._devicePixelRatioObserver=new Xn(this.setCanvasSize),window.requestAnimationFrame(()=>{this.setCanvasSize()})}destroy(){this._size_observer.disconnect(),this._devicePixelRatioObserver.destroy(),this.canvas.remove(),this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null)}setNeedsRedraw(){this.drawAnimationRequest===null&&(this.drawAnimationRequest=window.requestAnimationFrame(()=>{this.drawAnimationRequest=null,this.canvasViewRedraw()}))}redrawIfNeeded(){this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null,this.canvasViewRedraw())}canvasViewRedraw(){const e=this.canvas.getContext("2d");e&&(e.resetTransform(),e.scale(window.devicePixelRatio,window.devicePixelRatio),this.redraw(e,{width:this.canvas.width/window.devicePixelRatio,height:this.canvas.height/window.devicePixelRatio}))}get width(){return this.canvas.width/window.devicePixelRatio}get height(){return this.canvas.height/window.devicePixelRatio}setCanvasSize(){const e=window.devicePixelRatio;this.canvas.height=this.container.clientHeight*e,this.canvas.width=this.container.clientWidth*e,this.canvasViewRedraw()}}function Kn(i){let e,t=i[2]=="self"?"self":"time",n,s,r,o=i[3](i[0].time)+"";return{c(){e=m("div"),n=R(t),s=k(),r=m("div"),c(e,"class","label svelte-ci3g2p"),c(r,"class","time-val svelte-ci3g2p")},m(l,a){I(l,e,a),u(e,n),I(l,s,a),I(l,r,a),r.innerHTML=o},p(l,a){a&4&&t!==(t=l[2]=="self"?"self":"time")&&me(n,t),a&1&&o!==(o=l[3](l[0].time)+"")&&(r.innerHTML=o)},d(l){l&&(S(e),S(s),S(r))}}}function Zn(i){let e,t,n,s,r=i[3](i[0].time)+"",o,l=i[0].selfTime/i[0].time>.001&&ci(i);return{c(){e=m("div"),e.textContent="time",t=k(),n=m("div"),s=m("div"),o=k(),l&&l.c(),c(e,"class","label svelte-ci3g2p"),c(s,"class","time-val svelte-ci3g2p"),c(n,"class","time-row svelte-ci3g2p")},m(a,f){I(a,e,f),I(a,t,f),I(a,n,f),u(n,s),s.innerHTML=r,u(n,o),l&&l.m(n,null)},p(a,f){f&1&&r!==(r=a[3](a[0].time)+"")&&(s.innerHTML=r),a[0].selfTime/a[0].time>.001?l?l.p(a,f):(l=ci(a),l.c(),l.m(n,null)):l&&(l.d(1),l=null)},d(a){a&&(S(e),S(t),S(n)),l&&l.d()}}}function ci(i){let e,t,n,s=i[3](i[0].selfTime)+"";return{c(){e=m("div"),e.textContent="self",t=k(),n=m("div"),c(e,"class","label svelte-ci3g2p"),c(n,"class","time-val svelte-ci3g2p")},m(r,o){I(r,e,o),I(r,t,o),I(r,n,o),n.innerHTML=s},p(r,o){o&1&&s!==(s=r[3](r[0].selfTime)+"")&&(n.innerHTML=s)},d(r){r&&(S(e),S(t),S(n))}}}function Qn(i){let e,t,n=i[0].name+"",s,r,o,l,a,f,_,v,d,h;function p(M,T){return M[2]=="both"?Zn:Kn}let g=p(i),y=g(i);return{c(){e=m("div"),t=m("div"),s=R(n),r=k(),y.c(),o=k(),l=m("div"),l.textContent="loc",a=k(),f=m("div"),_=m("div"),d=k(),h=new qi(!1),c(t,"class","name svelte-ci3g2p"),c(l,"class","label svelte-ci3g2p"),c(_,"class","location-color svelte-ci3g2p"),c(_,"style",v=`background: ${i[0].locationColor}`),h.a=null,c(f,"class","location-row"),c(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),c(e,"style",`font: ${Ii}; max-width: ${es}px;`)},m(M,T){I(M,e,T),u(e,t),u(t,s),u(e,r),y.m(e,null),u(e,o),u(e,l),u(e,a),u(e,f),u(f,_),u(f,d),h.m(i[1],f)},p(M,[T]){T&1&&n!==(n=M[0].name+"")&&me(s,n),g===(g=p(M))&&y?y.p(M,T):(y.d(1),y=g(M),y&&(y.c(),y.m(e,o))),T&1&&v!==(v=`background: ${M[0].locationColor}`)&&c(_,"style",v),T&2&&h.p(M[1])},i:L,o:L,d(M){M&&S(e),y.d()}}}function Si(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Jn(i,e){i.font=Ii;const t=Si(e)=="both"?140:70,n=i.measureText(e.name).width,s=i.measureText(e.location).width+46;let o=Math.max(t,n,s)+20;return o>310&&(o=310),o}const es=310,Ii="400 13px Source Sans Pro, sans-serif";function ts(i,e,t){let{f:n}=e,s,r;function o(l){return`${l.toFixed(3)}`}return i.$$set=l=>{"f"in l&&t(0,n=l.f)},i.$$.update=()=>{i.$$.dirty&1&&t(1,s=At(n.location)),i.$$.dirty&1&&t(2,r=Si(n))},[n,s,r,o]}class is extends ue{constructor(e){super(),ce(this,e,ts,Qn,oe,{f:0})}}const ns="#212325",ui=18,ss=17,Re=28,ct=17,fi=29,os=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"],rs=os.map(fn);class ls extends Gn{constructor(t){super(t);A(this,"zoom",1);A(this,"startT",0);A(this,"yOffset",0);A(this,"frames",{});A(this,"isZoomedIn",!1);A(this,"tooltipContainer");A(this,"tooltipComponent",null);A(this,"_rootFrames",null);A(this,"maxDepth",[]);A(this,"maxY",0);A(this,"tooltipLocation",null);A(this,"lastDrawWidth",0);A(this,"lastDrawHeight",0);A(this,"_libraryOrder",null);A(this,"_colors",[]);A(this,"_frameMaxT");A(this,"mouseLocation",null);A(this,"mouseDownLocation",null);A(this,"touches",{});this.onWheel=this.onWheel.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.windowMouseUp=this.windowMouseUp.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onTouchcancel=this.onTouchend.bind(this),this.canvas.addEventListener("wheel",this.onWheel),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseleave",this.onMouseLeave),this.canvas.addEventListener("mousedown",this.onMouseDown),this.canvas.addEventListener("touchstart",this.onTouchstart),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend),this.canvas.addEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer=document.createElement("div"),this.tooltipContainer.style.position="absolute",this.tooltipContainer.style.pointerEvents="none",this.container.appendChild(this.tooltipContainer)}destroy(){this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("touchstart",this.onTouchstart),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend),this.canvas.removeEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer.remove(),super.destroy()}setRootFrames(t){this._rootFrames=t,this.frames={},this._frameMaxT=void 0,this.maxDepth=[],this.maxY=0;for(const n of Object.keys(t)){let s=t[n];this._collectFrames(s,n,0),this.maxY+=this.maxDepth[n]+1}this.fitContents(),this.setNeedsRedraw()}_collectFrames(t,n,s){this.frames.hasOwnProperty(n)||(this.frames[n]=[],this.maxDepth[n]=0),this.frames[n].push({frame:t,depth:s,isApplicationCode:t.isApplicationCode,library:t.library,className:t.className,filePathShort:t.filePathShort}),this.maxDepth[n]=Math.max(this.maxDepth[n],s);for(const r of t.children)r.identifier!==tt&&this._collectFrames(r,n,s+1)}updateTooltip(t,n){var s;if(n){const r={name:this.frameName(n),time:n.frame.time,selfTime:this.frameSelfTime(n),totalTime:((s=this._rootFrames[n.frame.thread_id])==null?void 0:s.time)??1e-12,location:`${n.filePathShort}:${n.frame.lineNo}`,locationColor:this.colorForFrame(n)};if(this.tooltipComponent?this.tooltipComponent.$set({f:r}):this.tooltipComponent=new is({target:this.tooltipContainer,props:{f:r}}),this.tooltipLocation){const o={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},l=Jn(t,r),a=this.width-10-l;o.x>a&&(o.x=a);const _=this.height-10-60;o.y>_&&(o.y=_),this.tooltipContainer.style.left=`${o.x}px`,this.tooltipContainer.style.top=`${o.y}px`}}n||this.tooltipComponent&&(this.tooltipComponent.$destroy(),this.tooltipComponent=null)}redraw(t,n){const{width:s,height:r}=n;(s!==this.lastDrawWidth||r!==this.lastDrawHeight)&&(this.isZoomedIn?this.clampViewport():this.fitContents()),this.lastDrawWidth=s,this.lastDrawHeight=r,t.fillStyle=ns,t.fillRect(0,0,s,r),this.drawAxes(t);let o=0;for(const _ of Object.keys(this.frames)){for(const v of this.frames[_])this.drawFrame(t,v,o);o+=1+this.maxDepth[_]}t.globalAlpha=1;const l=this.maxYOffset>0||this.isZoomedIn,a=!!this.mouseDownLocation;this.canvas.style.cursor=a&&l?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let f=null;!a&&this.tooltipLocation&&(f=this.hitTest(this.tooltipLocation)),this.updateTooltip(t,f)}drawAxes(t){const n=Math.max(800,this.width)/this.zoom;if(n==0)return;const s=Math.log10(n);let r=Math.ceil(s)+2;r<0&&(r=0);const o=Math.ceil(s)-3,l=a=>ze(a,{from:[s,s-3],to:[.71,0],clamp:!0});for(let a=o;a.01){t.globalAlpha=h,t.font='13px "Source Sans Pro", sans-serif';let p=f.toFixed(a);p=="0"&&(p="0s");let g=d+10;t.fillText(p,_+3,g);let y=this.height+ct+10-this.yOffset;ythis.width)return;if(t.fillStyle=this.colorForFrame(n),t.globalAlpha=n.isApplicationCode?1:.5,l<2){t.fillRect(r,o,l,a);return}let _=this.frameName(n);const v=Math.floor(l/3.3);if(_.length>v&&(_=_.substring(0,v)),_.length==0){t.fillRect(r,o,l,a);return}t.save(),t.beginPath(),t.rect(r,o,l,a),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let d=r;d<0&&(d=0),t.fillText(_,d+2,o+13),t.restore()}_assignLibraryOrder(){const t={};for(const s of Object.keys(this.frames))for(const r of this.frames[s]){const l=r.frame.library??"";t[l]=(t[l]||0)+r.frame.time}const n=Object.keys(t);n.sort((s,r)=>t[r]-t[s]),this._libraryOrder=n}colorForLibraryIndex(t){if(this._colors[t]!==void 0)return this._colors[t];const n=Math.pow(2,Math.ceil(Math.log2(t+1))),r=(2*t-n+1)/n,o=an(rs,r);return this._colors[t]=o,o}libraryIndexForFrame(t){this._libraryOrder||this._assignLibraryOrder();const n=t.library||"";let s=this._libraryOrder.indexOf(n);return s===-1&&(s=this._libraryOrder.length,this._libraryOrder.push(n)),s}colorForFrame(t){const n=this.libraryIndexForFrame(t);return this.colorForLibraryIndex(n)}get frameMaxT(){if(this._frameMaxT===void 0){this._frameMaxT=0;for(const t of Object.keys(this.frames))this._frameMaxT=Math.max(this._frameMaxT,this.frames[t].reduce((n,s)=>Math.max(n,s.frame.startTime+s.frame.time),0))}return this._frameMaxT}get maxYOffset(){return Math.max(0,(this.maxY+1)*ui+ct*2+fi-this.height)}get minZoom(){return(this.width-2*Re)/this.frameMaxT}get maxZoom(){return 10/15e-8}fitContents(){this.startT=0,this.zoom=this.minZoom,this.isZoomedIn=!1}clampViewport(){this.zoomthis.maxZoom&&(this.zoom=this.maxZoom),this.startT<0&&(this.startT=0);const t=this.frameMaxT-(this.width-2*Re)/this.zoom;this.startT>t&&(this.startT=t),this.yOffset>this.maxYOffset&&(this.yOffset=this.maxYOffset)}frameDims(t,n){const s=(n+t.depth)*ui+ct+fi-this.yOffset,r=ss;let o=this.xForT(t.frame.startTime),a=this.xForT(t.frame.startTime+t.frame.time)-o;return a<1&&(a=1),a>1&&(a-=ze(a,{from:[1,3],to:[0,1],clamp:!0})),{x:o,y:s,w:a,h:r}}xForT(t){return(t-this.startT)*this.zoom+Re}tForX(t){return(t-Re)/this.zoom+this.startT}frameName(t){let n;return t.className?n=`${t.className}.${t.frame.function}`:t.frame.function==""?n=t.filePathShort??t.frame.filePath??"":n=t.frame.function,n}frameSelfTime(t){let n=t.frame.time;const s=t.frame.children.filter(r=>!r.isSynthetic);for(const r of s)n-=r.time;return n}hitTest(t){for(const n of Object.keys(this.frames))for(const s of this.frames[n]){const{x:r,y:o,w:l,h:a}=this.frameDims(s);if(t.x>=r&&t.x<=r+l&&t.y>=o&&t.y<=o+a)return s}return null}onWheel(t){const n=t.ctrlKey||t.metaKey,s=n?.01:.0023,r=this.tForX(t.offsetX);this.zoom*=1-t.deltaY*s,this.clampViewport(),this.startT=r-(t.offsetX-Re)/this.zoom,n||(this.startT+=t.deltaX/this.zoom),this.clampViewport(),this.setNeedsRedraw(),t.preventDefault()}onMouseMove(t){const n={x:t.offsetX,y:t.offsetY},s=this.mouseLocation;if(this.mouseLocation=n,s&&this.mouseDownLocation){const r={x:n.x-s.x,y:n.y-s.y};this.startT-=r.x/this.zoom,this.yOffset-=r.y,this.clampViewport()}this.tooltipLocation=n,this.setNeedsRedraw()}onMouseLeave(t){this.mouseLocation=null,this.tooltipLocation=null,this.setNeedsRedraw()}onMouseDown(t){(t.button===0||t.button===1)&&(this.mouseDownLocation={x:t.offsetX,y:t.offsetY},window.addEventListener("mouseup",this.windowMouseUp),this.setNeedsRedraw())}windowMouseUp(t){window.removeEventListener("mouseup",this.windowMouseUp),this.mouseDownLocation=null,this.setNeedsRedraw()}onTouchstart(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))this.touches[n.identifier]={x:n.clientX,y:n.clientY,downT:this.tForX(n.clientX),startDate:Date.now(),downX:n.clientX,downY:n.clientY}}onTouchmove(t){t.preventDefault(),t.stopPropagation();let n=0;for(const r of Array.from(t.changedTouches)){const o=this.touches[r.identifier];o&&(n+=r.clientY-o.y,this.touches[r.identifier]={...o,x:r.clientX,y:r.clientY})}const s=n/Object.keys(this.touches).length;this.yOffset-=s,this.adjustXAxisForTouches(),this.setNeedsRedraw()}onTouchend(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}onTouchcancel(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}adjustXAxisForTouches(){const t=Object.keys(this.touches).map(Number);if(t.length!=0){if(t.length==1){const n=this.touches[t[0]];this.startT=n.downT-(n.x-Re)/this.zoom}if(t.length>=2){const n=this.touches[t[0]],s=this.touches[t[1]],r=(s.x-n.x)/(s.downT-n.downT),o=n.downT-(n.x-Re)/r;this.startT=o,this.zoom=r}this.clampViewport()}}}function as(i){let e;return{c(){e=m("div"),e.innerHTML="",c(e,"class","timeline svelte-p2tt1k")},m(t,n){I(t,e,n),i[7](e)},p:L,i:L,o:L,d(t){t&&S(e),i[7](null)}}}function cs(i,e,t){let n,{session:s}=e;const r=wi([Ke],([v])=>({processors:[v.removeImportlib?Rt:null,v.removeTracebackHide?St:null,v.removePyinstrument?Li:null].filter(p=>p!==null),options:{}}));be(i,r,v=>t(6,n=v));let o,l=[];for(const v of Object.keys(s.rootFrames))l[v]=s.rootFrames[v].cloneDeep();let a=null,f=null;Wi(()=>{f==null||f.destroy()});function _(v){ke[v?"unshift":"push"](()=>{a=v,t(0,a)})}return i.$$set=v=>{"session"in v&&t(2,s=v.session)},i.$$.update=()=>{i.$$.dirty&80&&t(3,o=Ai(l,n.processors,n.options)),i.$$.dirty&1&&a&&t(5,f=new ls(a)),i.$$.dirty&40&&o&&f&&f.setRootFrames(o)},[a,r,s,o,l,f,n,_]}class us extends ue{constructor(e){super(),ce(this,e,cs,as,oe,{session:2})}}function fs(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=m("div"),t=R("Unknown view mode: "),s=R(n),c(e,"class","error")},m(r,o){I(r,e,o),u(e,t),u(e,s)},p(r,o){o&2&&n!==(n=r[1].viewMode+"")&&me(s,n)},i:L,o:L,d(r){r&&S(e)}}}function ds(i){let e,t;return e=new us({props:{session:i[0]}}),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function hs(i){let e,t;return e=new Yn({props:{session:i[0]}}),{c(){we(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function ms(i){let e;return{c(){e=m("div"),e.innerHTML='
No samples recorded.
',c(e,"class","margins")},m(t,n){I(t,e,n)},p:L,i:L,o:L,d(t){t&&S(e)}}}function ps(i){let e,t,n,s,r,o,l,a;n=new Fn({props:{session:i[0]}});const f=[ms,hs,ds,fs],_=[];function v(d,h){return d[0].rootFrames?d[1].viewMode==="call-stack"?1:d[1].viewMode==="timeline"?2:3:0}return o=v(i),l=_[o]=f[o](i),{c(){e=m("div"),t=m("div"),we(n.$$.fragment),s=k(),r=m("div"),l.c(),c(t,"class","header"),c(r,"class","body svelte-1vwroj7"),c(e,"class","app svelte-1vwroj7")},m(d,h){I(d,e,h),u(e,t),pe(n,t,null),u(e,s),u(e,r),_[o].m(r,null),a=!0},p(d,[h]){const p={};h&1&&(p.session=d[0]),n.$set(p);let g=o;o=v(d),o===g?_[o].p(d,h):(Fe(),V(_[g],1,1,()=>{_[g]=null}),Pe(),l=_[o],l?l.p(d,h):(l=_[o]=f[o](d),l.c()),D(l,1),l.m(r,null))},i(d){a||(D(n.$$.fragment,d),D(l),a=!0)},o(d){V(n.$$.fragment,d),V(l),a=!1},d(d){d&&S(e),ve(n),_[o].d()}}}function vs(i,e,t){let n;be(i,Qe,d=>t(1,n=d));let{session:s}=e;const r=document.createElement("link");r.rel="shortcut icon",r.href=Pn,document.head.appendChild(r);const o=document.createElement("link");o.rel="preload",o.as="style",o.onload=()=>{o.rel="stylesheet"},o.href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,600|Source+Sans+Pro:400,600&display=swap",document.head.appendChild(o);const l=s.rootFrames;let a=0;if(l!=null)for(const d of Object.keys(l)){const h=l[d];if(h!=null){const p=h.time;p>a&&(a=p)}}const f=a.toLocaleString(void 0,{maximumSignificantDigits:3});let _,v;return(v=/[^\s/]+(:\d+)?$/.exec(s.target_description))?_=v[0]:_=s.target_description,document.title=`${f}s - ${_} - pyinstrument`,i.$$set=d=>{"session"in d&&t(0,s=d.session)},[s,n]}class _s extends ue{constructor(e){super(),ce(this,e,vs,ps,oe,{session:0})}}class gs{constructor(e){A(this,"startTime");A(this,"threadStartTimes");A(this,"duration");A(this,"minInterval");A(this,"maxInterval");A(this,"sampleCount");A(this,"target_description");A(this,"cpuTime");A(this,"rootFrames");A(this,"sysPath");A(this,"sysPrefixes");A(this,"_shortenPathCache",{});this.startTime=e.session.start_time,this.threadStartTimes=e.session.thread_start_times,this.duration=e.session.duration,this.minInterval=e.session.min_interval,this.maxInterval=e.session.max_interval,this.sampleCount=e.session.sample_count,this.target_description=e.session.target_description,this.cpuTime=e.session.cpu_time,this.sysPath=e.session.sys_path,this.sysPrefixes=e.session.sys_prefixes,this.rootFrames={};for(const t of Object.keys(e.frame_trees))this.rootFrames[t]=new et(e.frame_trees[t],this)}shortenPath(e){if(this._shortenPathCache[e])return this._shortenPathCache[e];let t=e;if(qe(e).length>1)for(const s of this.sysPath){const r=bs(e,s);qe(r).length0&&e[0].endsWith(":")?e[0]:null}function bs(i,e){if(di(i)!=di(e))return i;const t=qe(i),n=qe(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}const ws={render(i,e){const t=new gs(e);return new _s({target:i,props:{session:t}})}};function hi(i,e,t){const n=i.slice();return n[10]=e[t],n}function mi(i){let e,t=i[10].name+"",n;return{c(){e=m("option"),n=R(t),e.__value=i[10],le(e,e.__value)},m(s,r){I(s,e,r),u(e,n)},p:L,d(s){s&&S(e)}}}function ys(i){let e,t,n=i[3].message+"",s;return{c(){e=m("div"),t=R("Error loading file: "),s=R(n)},m(r,o){I(r,e,o),u(e,t),u(e,s)},p(r,o){o&8&&n!==(n=r[3].message+"")&&me(s,n)},d(r){r&&S(e)}}}function Ts(i){let e;return{c(){e=m("div"),e.textContent="Loading..."},m(t,n){I(t,e,n)},p:L,d(t){t&&S(e)}}}function ks(i){let e,t,n,s,r,o,l,a,f,_,v,d,h,p,g=We(i[5]),y=[];for(let F=0;Fi[7].call(l)),c(r,"class","right"),c(t,"class","header svelte-1980ffz"),c(v,"class","result-element"),c(v,"style",d=i[1]?"":"display: none"),c(f,"class","body svelte-1980ffz"),c(e,"class","demo-app svelte-1980ffz")},m(F,H){I(F,e,H),u(e,t),u(t,n),u(t,s),u(t,r),u(r,o),u(r,l);for(let E=0;Egt(()=>import("./django_template_render-CIkNzFIy.js"),[],import.meta.url).then(h=>h.default),"../demo-data/sympy_calculation.json":()=>gt(()=>import("./sympy_calculation-B9Pn_4RL.js"),[],import.meta.url).then(h=>h.default),"../demo-data/wikipedia_article_word_count.json":()=>gt(()=>import("./wikipedia_article_word_count-CGt_pvsZ.js"),[],import.meta.url).then(h=>h.default)})).map(([h,p])=>({name:h.split("/").pop().split(".").slice(0,-1).join("."),promiseFn:p}));let r=s[0],o=null,l=null,a=!1,f=null,_;function v(){r=$i(this),t(0,r),t(5,s)}function d(h){ke[h?"unshift":"push"](()=>{_=h,t(2,_)})}return i.$$.update=()=>{i.$$.dirty&1&&(t(4,a=!0),t(3,l=null),t(1,o=null),r.promiseFn().then(h=>{t(1,o=h),t(3,l=null)}).catch(h=>{t(3,l=h)}).finally(()=>{t(4,a=!1)})),i.$$.dirty&70&&_&&o&&(f&&f.$destroy(),t(6,f=ws.render(_,o)))},[r,o,_,l,a,s,f,v,d]}class Es extends ue{constructor(e){super(),ce(this,e,As,ks,oe,{})}}new Es({target:document.body}); diff --git a/docs/_static/preview/assets/index-DhaBtkCM.js b/docs/_static/preview/assets/index-DhaBtkCM.js deleted file mode 100644 index 67b77838..00000000 --- a/docs/_static/preview/assets/index-DhaBtkCM.js +++ /dev/null @@ -1,15 +0,0 @@ -var Li=Object.defineProperty;var Ri=(i,e,t)=>e in i?Li(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var C=(i,e,t)=>Ri(i,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function t(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(s){if(s.ep)return;s.ep=!0;const o=t(s);fetch(s.href,o)}})();const Si="modulepreload",Ii=function(i,e){return new URL(i,e).href},jt={},_t=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),r=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));s=Promise.all(t.map(a=>{if(a=Ii(a,n),a in jt)return;jt[a]=!0;const d=a.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!n)for(let f=o.length-1;f>=0;f--){const g=o[f];if(g.href===a&&(!d||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${p}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Si,d||(m.as="script",m.crossOrigin=""),m.href=a,r&&m.setAttribute("nonce",r),document.head.appendChild(m),d)return new Promise((f,g)=>{m.addEventListener("load",f),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${a}`)))})}))}return s.then(()=>e()).catch(o=>{const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o})};function R(){}function hi(i){return i()}function Yt(){return Object.create(null)}function ae(i){i.forEach(hi)}function kt(i){return typeof i=="function"}function oe(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Oi(i){return Object.keys(i).length===0}function mi(i,...e){if(i==null){for(const n of e)n(void 0);return R}const t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function we(i,e,t){i.$$.on_destroy.push(mi(e,t))}function Di(i,e,t){return i.set(t),e}function u(i,e){i.appendChild(e)}function O(i,e,t){i.insertBefore(e,t||null)}function I(i){i.parentNode&&i.parentNode.removeChild(i)}function Hi(i,e){for(let t=0;ti.removeEventListener(e,t,n)}function Ct(i){return function(e){return e.preventDefault(),i.call(this,e)}}function Mt(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function c(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function yt(i){let e;return{p(...t){e=t,e.forEach(n=>i.push(n))},r(){e.forEach(t=>i.splice(i.indexOf(t),1))}}}function Ni(i){return Array.from(i.childNodes)}function me(i,e){e=""+e,i.data!==e&&(i.data=e)}function le(i,e){i.value=e??""}function Z(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}function Xt(i,e,t){for(let n=0;n{const s=i.$$.callbacks[e];if(s){const o=zi(e,t,{cancelable:n});return s.slice().forEach(l=>{l.call(i,o)}),!o.defaultPrevented}return!0}}const Ne=[],Ae=[];let Be=[];const Gt=[],Wi=Promise.resolve();let At=!1;function Ui(){At||(At=!0,Wi.then(pi))}function ut(i){Be.push(i)}const wt=new Set;let He=0;function pi(){if(He!==0)return;const i=Qe;do{try{for(;Hei.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),Be=e}const ct=new Set;let Le;function xe(){Le={r:0,c:[],p:Le}}function qe(){Le.r||ae(Le.c),Le=Le.p}function H(i,e){i&&i.i&&(ct.delete(i),i.i(e))}function $(i,e,t,n){if(i&&i.o){if(ct.has(i))return;ct.add(i),Le.c.push(()=>{ct.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}function dt(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function Xi(i,e){$(i,1,1,()=>{e.delete(i.key)})}function Gi(i,e,t,n,s,o,l,r,a,d,p,v){let m=i.length,f=o.length,g=m;const _={};for(;g--;)_[i[g].key]=g;const b=[],M=new Map,T=new Map,y=[];for(g=f;g--;){const P=v(s,o,g),w=t(P);let k=l.get(w);k?y.push(()=>k.p(P,e)):(k=d(w,P),k.c()),M.set(w,b[g]=k),w in _&&T.set(w,Math.abs(g-_[w]))}const F=new Set,D=new Set;function E(P){H(P,1),P.m(r,p),l.set(P.key,P),p=P.first,f--}for(;m&&f;){const P=b[f-1],w=i[m-1],k=P.key,S=w.key;P===w?(p=P.first,m--,f--):M.has(S)?!l.has(k)||F.has(k)?E(P):D.has(S)?m--:T.get(k)>T.get(S)?(D.add(k),E(P)):(F.add(S),m--):(a(w,l),m--)}for(;m--;){const P=i[m];M.has(P.key)||a(P,l)}for(;f;)E(b[f-1]);return ae(y),b}function be(i){i&&i.c()}function pe(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ut(()=>{const o=i.$$.on_mount.map(hi).filter(kt);i.$$.on_destroy?i.$$.on_destroy.push(...o):ae(o),i.$$.on_mount=[]}),s.forEach(ut)}function ve(i,e){const t=i.$$;t.fragment!==null&&(Yi(t.after_update),ae(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Ki(i,e){i.$$.dirty[0]===-1&&(Ne.push(i),Ui(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const g=f.length?f[0]:m;return d.ctx&&s(d.ctx[v],d.ctx[v]=g)&&(!d.skip_bound&&d.bound[v]&&d.bound[v](g),p&&Ki(i,v)),m}):[],d.update(),p=!0,ae(d.before_update),d.fragment=n?n(d.ctx):!1,e.target){if(e.hydrate){const v=Ni(e.target);d.fragment&&d.fragment.l(v),v.forEach(I)}else d.fragment&&d.fragment.c();e.intro&&H(i.$$.fragment),pe(i,e.target,e.anchor),pi()}Ke(a)}class ue{constructor(){C(this,"$$");C(this,"$$set")}$destroy(){ve(this,1),this.$destroy=R}$on(e,t){if(!kt(t))return R;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!Oi(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Zi="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Zi);function Qi(i){let e,t;return{c(){e=z("svg"),t=z("path"),c(t,"fill-rule","evenodd"),c(t,"clip-rule","evenodd"),c(t,"d","M5.11634 0.889422C4.86506 -0.296474 3.17237 -0.296474 2.92109 0.889422C2.78291 1.54158 2.10994 1.93011 1.47607 1.72371C0.323418 1.34837 -0.522932 2.81429 0.378448 3.62484C0.87414 4.07059 0.87414 4.84767 0.378448 5.29341C-0.522931 6.10397 0.323418 7.56989 1.47607 7.19455C2.10994 6.98814 2.78291 7.37668 2.92109 8.02883C3.17237 9.21473 4.86506 9.21473 5.11634 8.02883C5.25452 7.37668 5.92749 6.98814 6.56136 7.19455C7.71401 7.56989 8.56036 6.10397 7.65898 5.29341C7.16329 4.84767 7.16329 4.07059 7.65898 3.62484C8.56036 2.81429 7.71401 1.34837 6.56136 1.72371C5.92749 1.93011 5.25452 1.54158 5.11634 0.889422ZM4.01883 6.33408C5.05436 6.33408 5.89383 5.49462 5.89383 4.45908C5.89383 3.42355 5.05436 2.58408 4.01883 2.58408C2.98329 2.58408 2.14383 3.42355 2.14383 4.45908C2.14383 5.49462 2.98329 6.33408 4.01883 6.33408Z"),c(t,"fill","currentColor"),c(e,"width","9"),c(e,"height","9"),c(e,"viewBox","0 0 9 9"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(n,s){O(n,e,s),u(e,t)},p:R,i:R,o:R,d(n){n&&I(e)}}}class Ji extends ue{constructor(e){super(),ce(this,e,null,Qi,oe,{})}}function en(i){let e,t,n,s,o,l,r,a,d,p,v,m,f,g,_,b,M;return{c(){e=z("svg"),t=z("g"),n=z("path"),s=z("path"),o=z("defs"),l=z("filter"),r=z("feFlood"),a=z("feBlend"),d=z("feGaussianBlur"),p=z("linearGradient"),v=z("stop"),m=z("stop"),f=z("stop"),g=z("linearGradient"),_=z("stop"),b=z("stop"),M=z("stop"),c(n,"fill-rule","evenodd"),c(n,"clip-rule","evenodd"),c(n,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(n,"fill","url(#paint0_linear_67_262)"),c(t,"opacity","0.5"),c(t,"filter","url(#filter0_f_67_262)"),c(s,"fill-rule","evenodd"),c(s,"clip-rule","evenodd"),c(s,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(s,"fill","url(#paint1_linear_67_262)"),c(r,"flood-opacity","0"),c(r,"result","BackgroundImageFix"),c(a,"mode","normal"),c(a,"in","SourceGraphic"),c(a,"in2","BackgroundImageFix"),c(a,"result","shape"),c(d,"stdDeviation","3.39785"),c(d,"result","effect1_foregroundBlur_67_262"),c(l,"id","filter0_f_67_262"),c(l,"x","3.2043"),c(l,"y","2.2043"),c(l,"width","36.0914"),c(l,"height","41.0914"),c(l,"filterUnits","userSpaceOnUse"),c(l,"color-interpolation-filters","sRGB"),c(v,"stop-color","#FFAA00"),c(m,"offset","0.514478"),c(m,"stop-color","#FFEB00"),c(f,"offset","1"),c(f,"stop-color","#98FF05"),c(p,"id","paint0_linear_67_262"),c(p,"x1","7.3769"),c(p,"y1","18.4566"),c(p,"x2","20.6583"),c(p,"y2","33.1038"),c(p,"gradientUnits","userSpaceOnUse"),c(_,"stop-color","#FFC834"),c(b,"offset","0.514478"),c(b,"stop-color","#FAF534"),c(M,"offset","1"),c(M,"stop-color","#B8FF38"),c(g,"id","paint1_linear_67_262"),c(g,"x1","7.3769"),c(g,"y1","18.4566"),c(g,"x2","20.6583"),c(g,"y2","33.1038"),c(g,"gradientUnits","userSpaceOnUse"),c(e,"width","44"),c(e,"height","44"),c(e,"viewBox","0 0 44 44"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(T,y){O(T,e,y),u(e,t),u(t,n),u(e,s),u(e,o),u(o,l),u(l,r),u(l,a),u(l,d),u(o,p),u(p,v),u(p,m),u(p,f),u(o,g),u(g,_),u(g,b),u(g,M)},p:R,i:R,o:R,d(T){T&&I(e)}}}class tn extends ue{constructor(e){super(),ce(this,e,null,en,oe,{})}}const Ve=[];function nn(i,e){return{subscribe:ft(i,e).subscribe}}function ft(i,e=R){let t;const n=new Set;function s(r){if(oe(i,r)&&(i=r,t)){const a=!Ve.length;for(const d of n)d[1](),Ve.push(d,i);if(a){for(let d=0;d{n.delete(d),n.size===0&&t&&(t(),t=null)}}return{set:s,update:o,subscribe:l}}function vi(i,e,t){const n=!Array.isArray(i),s=n?[i]:i;if(!s.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const o=e.length<2;return nn(t,(l,r)=>{let a=!1;const d=[];let p=0,v=R;const m=()=>{if(p)return;v();const g=e(n?d[0]:d,l,r);o?l(g):v=kt(g)?g:R},f=s.map((g,_)=>mi(g,b=>{d[_]=b,p&=~(1<<_),a&&m()},()=>{p|=1<<_}));return a=!0,m(),function(){ae(f),v(),a=!1}})}var bt={local:{},session:{}};function sn(i){return i==="local"?localStorage:sessionStorage}function Pt(i,e,t){var n,s,o,l,r,a,d,p;t!=null&&t.onError&&console.warn("onError has been deprecated. Please use onWriteError instead");const v=(n=t==null?void 0:t.serializer)!=null?n:JSON,m=(s=t==null?void 0:t.storage)!=null?s:"local",f=(o=t==null?void 0:t.syncTabs)!=null?o:!0,g=(r=(l=t==null?void 0:t.onWriteError)!=null?l:t==null?void 0:t.onError)!=null?r:E=>console.error(`Error when writing value from persisted store "${i}" to ${m}`,E),_=(a=t==null?void 0:t.onParseError)!=null?a:(E,P)=>console.error(`Error when parsing ${E?'"'+E+'"':"value"} from persisted store "${i}"`,P),b=(d=t==null?void 0:t.beforeRead)!=null?d:E=>E,M=(p=t==null?void 0:t.beforeWrite)!=null?p:E=>E,T=typeof window<"u"&&typeof document<"u",y=T?sn(m):null;function F(E,P){const w=M(P);try{y==null||y.setItem(E,v.stringify(w))}catch(k){g(k)}}function D(){function E(S){try{return v.parse(S)}catch(x){_(S,x)}}const P=y==null?void 0:y.getItem(i);if(P==null)return e;const w=E(P);return w==null?e:b(w)}if(!bt[m][i]){const E=D(),P=ft(E,S=>{if(T&&m=="local"&&f){const x=J=>{if(J.key===i&&J.newValue){let B;try{B=v.parse(J.newValue)}catch(ee){_(J.newValue,ee);return}const Fe=b(B);S(Fe)}};return window.addEventListener("storage",x),()=>window.removeEventListener("storage",x)}}),{subscribe:w,set:k}=P;bt[m][i]={set(S){k(S),F(i,S)},update(S){return P.update(x=>{const J=S(x);return F(i,J),J})},reset(){this.set(e)},subscribe:w}}return bt[m][i]}function Kt(){return{collapseMode:"non-application",collapseCustomHide:"",collapseCustomShow:"",removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:.001,timeFormat:"absolute"}}const K=Pt("pyinstrument:viewOptionsCallStack",Kt(),{syncTabs:!0,beforeRead(i){return{...Kt(),...i}}}),Ze=Pt("pyinstrument:viewOptions",{viewMode:"call-stack"},{syncTabs:!1}),Ge=Pt("pyinstrument:viewOptionsTimeline",{removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:1e-4},{syncTabs:!0});class on extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function rn(i,e){const t=e*(i.length-1),n=Math.floor(t),s=Math.ceil(t),o=i[n],l=i[s],r=t-n;return an(r,{to:[o,l]})}function ln(i,e,t){return i===1/0?(console.warn("clamp: value is Infinity, returning `max`",i),t):i===-1/0?(console.warn("clamp: value is -Infinity, returning `min`",i),e):Number.isFinite(i)?it?t:i:(console.warn("clamp: value isn't finite, returning `min`",i),e)}function ze(i,e){const{from:t=[0,1],to:n=[0,1]}=e,s=e.clamp||!1;let o=(i-t[0])/(t[1]-t[0])*(n[1]-n[0])+n[0];return s&&(o=ln(o,Math.min(n[0],n[1]),Math.max(n[0],n[1]))),o}function an(i,e){return`rgb( - ${ze(i,{from:e.from,to:[e.to[0][0],e.to[1][0]],clamp:e.clamp})}, - ${ze(i,{from:e.from,to:[e.to[0][1],e.to[1][1]],clamp:e.clamp})}, - ${ze(i,{from:e.from,to:[e.to[0][2],e.to[1][2]],clamp:e.clamp})} - )`}function cn(i){if(i.substr(0,1)=="#"){var e=(i.length-1)/3,t=[17,1,.062272][e-1];return[Math.round(parseInt(i.substr(1,e),16)*t),Math.round(parseInt(i.substr(1+e,e),16)*t),Math.round(parseInt(i.substr(1+2*e,e),16)*t)]}else return i.split("(")[1].split(")")[0].split(",").map(n=>+n)}function un(i,e,t={}){const{ignore:n=[],capture:s=!0}=t,o=window;if(!o)return()=>{};let l=!0,r=!1;const a=f=>n.some(g=>typeof g=="string"?Array.from(document.querySelectorAll(g)).some(_=>_===f.target||f.composedPath().includes(_)):g&&(f.target===g||f.composedPath().includes(g))),d=f=>{if(!(!i||i===f.target||f.composedPath().includes(i))){if(f.detail===0&&(l=!a(f)),!l){l=!0;return}e(f)}},p=f=>{r||(r=!0,setTimeout(()=>{r=!1},0),d(f))},v=f=>{l=!a(f)&&!!(i&&!f.composedPath().includes(i))};return o.addEventListener("click",p,{passive:!0,capture:s}),o.addEventListener("pointerdown",v,{passive:!0}),()=>{o.removeEventListener("click",p,{capture:s}),o.removeEventListener("pointerdown",v)}}function dn(i){const e=document.createElement("div");return e.appendChild(document.createTextNode(i)),e.innerHTML}function Et(i){return dn(i).replace(/(\/|\\)/g,t=>`${t}`)}function fn(i,e){if(i.length==0)return null;let t=i[0],n=e(t);for(const s of i){const o=e(s);o>n&&(t=s,n=o)}return t}function ht(){return Math.random().toString(36).substring(2)}function hn(i){let e,t,n,s,o,l,r,a,d,p,v,m,f,g,_,b,M,T,y,F,D,E,P,w,k,S,x,J,B,Fe,ee,Q,j,Ee,W,We,Ue,re,U,je,te,de,fe,ge,he,ye,Ye,Te,G,Re,ke,Xe,q,V,Y,It,tt,Ot,Dt,Se,Ce,Ht,Ie,it,Vt,Nt,_e,Bt,zt,Oe,nt,$t,De,st,ot,ie,xt,qt,rt,lt,ne,Wt,pt,vt,gt,Ut;return pt=yt(i[5][0]),vt=yt(i[5][1]),{c(){e=h("div"),t=h("div"),n=h("div"),n.textContent="Collapse frames",s=A(),o=h("div"),l=h("div"),r=h("input"),a=A(),d=h("label"),p=L("Library code"),v=A(),m=h("div"),m.textContent="Code run from the Python stdlib, a virtualenv, or a conda env will be collapsed.",f=A(),g=h("div"),_=h("input"),b=A(),M=h("label"),T=L("Custom"),y=A(),F=h("div"),D=L(`Regex on the source file path. - `),E=h("div"),P=h("label"),P.textContent="Show",w=A(),k=h("input"),S=A(),x=h("label"),x.textContent="Hide",J=A(),B=h("input"),Fe=L(` - If neither match, the library code rule is used.`),ee=A(),Q=h("div"),j=h("input"),Ee=A(),W=h("label"),We=L("Disabled"),Ue=A(),re=h("div"),U=h("div"),U.textContent="Remove frames",je=A(),te=h("div"),de=h("div"),fe=h("input"),ge=A(),he=h("label"),ye=L("importlib machinery"),Ye=A(),Te=h("div"),G=h("input"),Re=A(),ke=h("label"),Xe=L("Frames declaring __traceback_hide__"),q=A(),V=h("div"),Y=h("input"),It=A(),tt=h("label"),Ot=L("pyinstrument frames"),Dt=A(),Se=h("div"),Ce=h("input"),Ht=A(),Ie=h("span"),it=h("label"),Vt=L("Frames with durations less than"),Nt=A(),_e=h("input"),Bt=L(` - % of the total time`),zt=A(),Oe=h("div"),nt=h("div"),nt.textContent="Time format",$t=A(),De=h("div"),st=h("div"),ot=h("label"),ie=h("input"),xt=L(` - Absolute time in seconds`),qt=A(),rt=h("div"),lt=h("label"),ne=h("input"),Wt=L(` - Percentage of the total run time`),c(n,"class","name svelte-1pecl4m"),c(r,"id",i[1]+"collapseModeAll"),c(r,"type","radio"),r.__value="non-application",le(r,r.__value),c(r,"class","svelte-1pecl4m"),c(d,"for",i[1]+"collapseModeAll"),c(m,"class","description svelte-1pecl4m"),c(l,"class","option svelte-1pecl4m"),c(_,"id",i[1]+"collapseModeCustom"),c(_,"type","radio"),_.__value="custom",le(_,_.__value),c(_,"class","svelte-1pecl4m"),c(M,"for",i[1]+"collapseModeCustom"),c(P,"for","collapseCustomShow"),c(P,"class","svelte-1pecl4m"),c(k,"id","collapseCustomShow"),c(k,"type","text"),c(k,"placeholder","myproject"),c(k,"spellcheck","false"),c(k,"autocapitalize","off"),c(k,"autocomplete","off"),c(k,"autocorrect","off"),c(k,"class","svelte-1pecl4m"),c(x,"for","collapseCustomHide"),c(x,"class","svelte-1pecl4m"),c(B,"id","collapseCustomHide"),c(B,"type","text"),c(B,"placeholder",".*/lib/.*"),c(B,"spellcheck","false"),c(B,"autocapitalize","off"),c(B,"autocomplete","off"),c(B,"autocorrect","off"),c(B,"class","svelte-1pecl4m"),c(E,"class","mini-input-grid svelte-1pecl4m"),c(F,"class","description svelte-1pecl4m"),c(g,"class","option svelte-1pecl4m"),c(j,"id",i[1]+"collapseModeDisabled"),c(j,"type","radio"),j.__value="disabled",le(j,j.__value),c(j,"class","svelte-1pecl4m"),c(W,"for",i[1]+"collapseModeDisabled"),c(Q,"class","option svelte-1pecl4m"),c(o,"class","body"),c(t,"class","option-group svelte-1pecl4m"),c(U,"class","name svelte-1pecl4m"),c(fe,"id",i[1]+"removeImportlib"),c(fe,"type","checkbox"),c(fe,"class","svelte-1pecl4m"),c(he,"for",i[1]+"removeImportlib"),c(de,"class","option svelte-1pecl4m"),c(G,"id",i[1]+"removeTracebackHide"),c(G,"type","checkbox"),c(G,"class","svelte-1pecl4m"),c(ke,"for",i[1]+"removeTracebackHide"),c(Te,"class","option svelte-1pecl4m"),c(Y,"id",i[1]+"removePyinstrument"),c(Y,"type","checkbox"),c(Y,"class","svelte-1pecl4m"),c(tt,"for",i[1]+"removePyinstrument"),c(V,"class","option svelte-1pecl4m"),c(Ce,"id",i[1]+"removeIrrelevant"),c(Ce,"type","checkbox"),c(Ce,"class","svelte-1pecl4m"),c(it,"for",i[1]+"removeIrrelevant"),c(_e,"type","number"),_e.value=i[2](),c(_e,"min","0"),c(_e,"max","99"),c(_e,"step","0.01"),Z(_e,"width","4em"),c(_e,"class","svelte-1pecl4m"),c(Se,"class","option svelte-1pecl4m"),c(te,"class","body"),c(re,"class","option-group svelte-1pecl4m"),c(nt,"class","name svelte-1pecl4m"),c(ie,"type","radio"),ie.__value="absolute",le(ie,ie.__value),c(ie,"class","svelte-1pecl4m"),c(st,"class","option svelte-1pecl4m"),c(ne,"type","radio"),ne.__value="proportion",le(ne,ne.__value),c(ne,"class","svelte-1pecl4m"),c(rt,"class","option svelte-1pecl4m"),c(De,"class","body"),c(Oe,"class","option-group svelte-1pecl4m"),c(e,"class","view-options-call-stack svelte-1pecl4m"),pt.p(ie,ne),vt.p(r,_,j)},m(X,se){O(X,e,se),u(e,t),u(t,n),u(t,s),u(t,o),u(o,l),u(l,r),r.checked=r.__value===i[0].collapseMode,u(l,a),u(l,d),u(d,p),u(l,v),u(l,m),u(o,f),u(o,g),u(g,_),_.checked=_.__value===i[0].collapseMode,u(g,b),u(g,M),u(M,T),u(g,y),u(g,F),u(F,D),u(F,E),u(E,P),u(E,w),u(E,k),le(k,i[0].collapseCustomShow),u(E,S),u(E,x),u(E,J),u(E,B),le(B,i[0].collapseCustomHide),u(F,Fe),u(o,ee),u(o,Q),u(Q,j),j.checked=j.__value===i[0].collapseMode,u(Q,Ee),u(Q,W),u(W,We),u(e,Ue),u(e,re),u(re,U),u(re,je),u(re,te),u(te,de),u(de,fe),fe.checked=i[0].removeImportlib,u(de,ge),u(de,he),u(he,ye),u(te,Ye),u(te,Te),u(Te,G),G.checked=i[0].removeTracebackHide,u(Te,Re),u(Te,ke),u(ke,Xe),u(te,q),u(te,V),u(V,Y),Y.checked=i[0].removePyinstrument,u(V,It),u(V,tt),u(tt,Ot),u(te,Dt),u(te,Se),u(Se,Ce),Ce.checked=i[0].removeIrrelevant,u(Se,Ht),u(Se,Ie),u(Ie,it),u(it,Vt),u(Ie,Nt),u(Ie,_e),u(Ie,Bt),u(e,zt),u(e,Oe),u(Oe,nt),u(Oe,$t),u(Oe,De),u(De,st),u(st,ot),u(ot,ie),ie.checked=ie.__value===i[0].timeFormat,u(ot,xt),u(De,qt),u(De,rt),u(rt,lt),u(lt,ne),ne.checked=ne.__value===i[0].timeFormat,u(lt,Wt),gt||(Ut=[N(r,"change",i[4]),N(_,"change",i[6]),N(k,"input",i[7]),N(B,"input",i[8]),N(j,"change",i[9]),N(fe,"change",i[10]),N(G,"change",i[11]),N(Y,"change",i[12]),N(Ce,"change",i[13]),N(_e,"input",i[3]),N(ie,"change",i[14]),N(ne,"change",i[15])],gt=!0)},p(X,[se]){se&1&&(r.checked=r.__value===X[0].collapseMode),se&1&&(_.checked=_.__value===X[0].collapseMode),se&1&&k.value!==X[0].collapseCustomShow&&le(k,X[0].collapseCustomShow),se&1&&B.value!==X[0].collapseCustomHide&&le(B,X[0].collapseCustomHide),se&1&&(j.checked=j.__value===X[0].collapseMode),se&1&&(fe.checked=X[0].removeImportlib),se&1&&(G.checked=X[0].removeTracebackHide),se&1&&(Y.checked=X[0].removePyinstrument),se&1&&(Ce.checked=X[0].removeIrrelevant),se&1&&(ie.checked=ie.__value===X[0].timeFormat),se&1&&(ne.checked=ne.__value===X[0].timeFormat)},i:R,o:R,d(X){X&&I(e),pt.r(),vt.r(),gt=!1,ae(Ut)}}}function mn(i,e,t){let n;we(i,K,y=>t(0,n=y));const s=ht();function o(){return(n.removeIrrelevantThreshold*100).toLocaleString(void 0,{maximumFractionDigits:4})}function l(y){Di(K,n.removeIrrelevantThreshold=y.currentTarget.valueAsNumber/100,n)}const r=[[],[]];function a(){n.collapseMode=this.__value,K.set(n)}function d(){n.collapseMode=this.__value,K.set(n)}function p(){n.collapseCustomShow=this.value,K.set(n)}function v(){n.collapseCustomHide=this.value,K.set(n)}function m(){n.collapseMode=this.__value,K.set(n)}function f(){n.removeImportlib=this.checked,K.set(n)}function g(){n.removeTracebackHide=this.checked,K.set(n)}function _(){n.removePyinstrument=this.checked,K.set(n)}function b(){n.removeIrrelevant=this.checked,K.set(n)}function M(){n.timeFormat=this.__value,K.set(n)}function T(){n.timeFormat=this.__value,K.set(n)}return[n,s,o,l,a,r,d,p,v,m,f,g,_,b,M,T]}class pn extends ue{constructor(e){super(),ce(this,e,mn,hn,oe,{})}}function vn(i){let e,t,n,s,o,l,r,a,d,p,v,m,f,g,_,b,M,T,y,F,D,E,P,w;return{c(){e=h("div"),t=h("div"),n=h("div"),n.textContent="Remove frames",s=A(),o=h("div"),l=h("div"),r=h("input"),a=A(),d=h("label"),p=L("importlib machinery"),v=A(),m=h("div"),f=h("input"),g=A(),_=h("label"),b=L("Frames declaring __traceback_hide__"),M=A(),T=h("div"),y=h("input"),F=A(),D=h("label"),E=L("pyinstrument frames"),c(n,"class","name"),c(r,"id",i[1]+"removeImportlib"),c(r,"type","checkbox"),c(d,"for",i[1]+"removeImportlib"),c(l,"class","option"),c(f,"id",i[1]+"removeTracebackHide"),c(f,"type","checkbox"),c(_,"for",i[1]+"removeTracebackHide"),c(m,"class","option"),c(y,"id",i[1]+"removePyinstrument"),c(y,"type","checkbox"),c(D,"for",i[1]+"removePyinstrument"),c(T,"class","option"),c(o,"class","body"),c(t,"class","option-group"),c(e,"class","view-options-timeline svelte-vsz8zm")},m(k,S){O(k,e,S),u(e,t),u(t,n),u(t,s),u(t,o),u(o,l),u(l,r),r.checked=i[0].removeImportlib,u(l,a),u(l,d),u(d,p),u(o,v),u(o,m),u(m,f),f.checked=i[0].removeTracebackHide,u(m,g),u(m,_),u(_,b),u(o,M),u(o,T),u(T,y),y.checked=i[0].removePyinstrument,u(T,F),u(T,D),u(D,E),P||(w=[N(r,"change",i[2]),N(f,"change",i[3]),N(y,"change",i[4])],P=!0)},p(k,[S]){S&1&&(r.checked=k[0].removeImportlib),S&1&&(f.checked=k[0].removeTracebackHide),S&1&&(y.checked=k[0].removePyinstrument)},i:R,o:R,d(k){k&&I(e),P=!1,ae(w)}}}function gn(i,e,t){let n;we(i,Ge,a=>t(0,n=a));const s=ht();function o(){n.removeImportlib=this.checked,Ge.set(n)}function l(){n.removeTracebackHide=this.checked,Ge.set(n)}function r(){n.removePyinstrument=this.checked,Ge.set(n)}return[n,s,o,l,r]}class _n extends ue{constructor(e){super(),ce(this,e,gn,vn,oe,{})}}function wn(i){let e,t;return e=new _n({}),{c(){be(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){$(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function bn(i){let e,t;return e=new pn({}),{c(){be(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){$(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function yn(i){let e,t,n,s,o,l,r,a,d;const p=[bn,wn],v=[];function m(f,g){return f[0].viewMode==="call-stack"?0:f[0].viewMode==="timeline"?1:-1}return~(r=m(i))&&(a=v[r]=p[r](i)),{c(){e=h("div"),t=h("div"),n=h("div"),s=L(i[3]),o=A(),l=h("div"),a&&a.c(),c(n,"class","title-row svelte-rpk7lo"),c(l,"class","body svelte-rpk7lo"),c(t,"class","box svelte-rpk7lo"),c(e,"class","view-options svelte-rpk7lo")},m(f,g){O(f,e,g),u(e,t),u(t,n),u(n,s),u(t,o),u(t,l),~r&&v[r].m(l,null),i[4](t),i[5](e),d=!0},p(f,[g]){(!d||g&8)&&me(s,f[3]);let _=r;r=m(f),r!==_&&(a&&(xe(),$(v[_],1,1,()=>{v[_]=null}),qe()),~r?(a=v[r],a||(a=v[r]=p[r](f),a.c()),H(a,1),a.m(l,null)):a=null)},i(f){d||(H(a),d=!0)},o(f){$(a),d=!1},d(f){f&&I(e),~r&&v[r].d(),i[4](null),i[5](null)}}}function Tn(i,e,t){let n;we(i,Ze,m=>t(0,n=m));const s=qi();function o(){s("close")}let l,r;Tt(()=>{if(r)return un(r,o,{ignore:[".js-view-options-button"]})});function a(){if(!l||!r)return;const m=l.getBoundingClientRect(),g=r.getBoundingClientRect().width;m.right-g-20<0?t(2,r.style.right=`${m.right-g-20}px`,r):t(2,r.style.right="0",r)}Tt(()=>(a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)));let d="View options";function p(m){Ae[m?"unshift":"push"](()=>{r=m,t(2,r)})}function v(m){Ae[m?"unshift":"push"](()=>{l=m,t(1,l)})}return i.$$.update=()=>{i.$$.dirty&1&&(n.viewMode==="call-stack"?t(3,d="Call stack view options"):n.viewMode==="timeline"&&t(3,d="Timeline view options"))},[n,l,r,d,p,v]}class An extends ue{constructor(e){super(),ce(this,e,Tn,yn,oe,{})}}function Zt(i){let e,t;return e=new An({}),e.$on("close",i[9]),{c(){be(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p:R,i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){$(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function En(i){let e,t,n,s,o,l,r,a,d=Et(i[0].target_description)+"",p,v,m,f,g,_,b,M,T,y,F,D,E,P=i[0].sampleCount+"",w,k,S,x,J,B,Fe,ee,Q,j,Ee,W,We,Ue,re,U,je,te,de,fe,ge,he,ye,Ye,Te,G,Re,ke,Xe;o=new tn({}),ye=new Ji({});let q=i[1]&&Zt(i);return Re=yt(i[7][0]),{c(){e=h("div"),t=h("div"),n=h("div"),s=h("div"),be(o.$$.fragment),l=A(),r=h("div"),a=h("div"),p=A(),v=h("div"),m=h("div"),f=h("span"),f.textContent="Recorded:",g=A(),_=h("span"),_.textContent=`${i[3]}`,b=A(),M=h("br"),T=A(),y=h("div"),F=h("span"),F.textContent="Samples:",D=A(),E=h("span"),w=L(P),k=A(),S=h("div"),x=h("span"),x.textContent="CPU utilization:",J=A(),B=h("span"),B.textContent=`${(i[4]*100).toFixed(0)}%`,Fe=A(),ee=h("div"),Q=h("div"),j=L(`View: - `),Ee=h("label"),W=h("input"),We=L(` - Call stack`),Ue=A(),re=h("label"),U=h("input"),je=L(` - Timeline`),te=A(),de=h("div"),fe=A(),ge=h("div"),he=h("button"),be(ye.$$.fragment),Ye=L(` - View options`),Te=A(),q&&q.c(),c(s,"class","logo svelte-qdxst2"),c(a,"class","target-description svelte-qdxst2"),c(f,"class","metric-label svelte-qdxst2"),c(_,"class","metric-value svelte-qdxst2"),c(m,"class","metric date svelte-qdxst2"),c(M,"class","svelte-qdxst2"),c(F,"class","metric-label svelte-qdxst2"),c(E,"class","metric-value svelte-qdxst2"),c(y,"class","metric svelte-qdxst2"),c(x,"class","metric-label svelte-qdxst2"),c(B,"class","metric-value svelte-qdxst2"),c(S,"class","metric svelte-qdxst2"),c(v,"class","metrics svelte-qdxst2"),c(W,"type","radio"),W.__value="call-stack",le(W,W.__value),c(W,"class","svelte-qdxst2"),c(Ee,"class","svelte-qdxst2"),c(U,"type","radio"),U.__value="timeline",le(U,U.__value),c(U,"class","svelte-qdxst2"),c(re,"class","svelte-qdxst2"),c(Q,"class","toggle"),c(de,"class","spacer"),Z(de,"flex","1"),c(he,"class","js-view-options-button svelte-qdxst2"),c(ge,"class","button-container svelte-qdxst2"),c(ee,"class","view-options svelte-qdxst2"),c(r,"class","layout svelte-qdxst2"),c(n,"class","row svelte-qdxst2"),c(t,"class","margins"),c(e,"class","header svelte-qdxst2"),Re.p(W,U)},m(V,Y){O(V,e,Y),u(e,t),u(t,n),u(n,s),pe(o,s,null),u(n,l),u(n,r),u(r,a),a.innerHTML=d,u(r,p),u(r,v),u(v,m),u(m,f),u(m,g),u(m,_),u(v,b),u(v,M),u(v,T),u(v,y),u(y,F),u(y,D),u(y,E),u(E,w),u(v,k),u(v,S),u(S,x),u(S,J),u(S,B),u(r,Fe),u(r,ee),u(ee,Q),u(Q,j),u(Q,Ee),u(Ee,W),W.checked=W.__value===i[2].viewMode,u(Ee,We),u(Q,Ue),u(Q,re),u(re,U),U.checked=U.__value===i[2].viewMode,u(re,je),u(ee,te),u(ee,de),u(ee,fe),u(ee,ge),u(ge,he),pe(ye,he,null),u(he,Ye),u(ge,Te),q&&q.m(ge,null),G=!0,ke||(Xe=[N(W,"change",i[6]),N(U,"change",i[8]),N(he,"click",Mt(Ct(i[5])))],ke=!0)},p(V,[Y]){(!G||Y&1)&&d!==(d=Et(V[0].target_description)+"")&&(a.innerHTML=d),(!G||Y&1)&&P!==(P=V[0].sampleCount+"")&&me(w,P),Y&4&&(W.checked=W.__value===V[2].viewMode),Y&4&&(U.checked=U.__value===V[2].viewMode),V[1]?q?(q.p(V,Y),Y&2&&H(q,1)):(q=Zt(V),q.c(),H(q,1),q.m(ge,null)):q&&(xe(),$(q,1,1,()=>{q=null}),qe())},i(V){G||(H(o.$$.fragment,V),H(ye.$$.fragment,V),H(q),G=!0)},o(V){$(o.$$.fragment,V),$(ye.$$.fragment,V),$(q),G=!1},d(V){V&&I(e),ve(o),ve(ye),q&&q.d(),Re.r(),ke=!1,ae(Xe)}}}function kn(i,e,t){let n;we(i,Ze,f=>t(2,n=f));let{session:s}=e;const o=new Date(s.startTime*1e3).toLocaleString(void 0,{dateStyle:"long",timeStyle:"medium"}),l=s.cpuTime/s.duration;let r=!1;function a(f){t(1,r=!r)}const d=[[]];function p(){n.viewMode=this.__value,Ze.set(n)}function v(){n.viewMode=this.__value,Ze.set(n)}const m=()=>t(1,r=!1);return i.$$set=f=>{"session"in f&&t(0,s=f.session)},[s,r,n,o,l,a,p,d,v,m]}class Cn extends ue{constructor(e){super(),ce(this,e,kn,En,oe,{session:0})}}const Mn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWmSURBVHgBtVc7i11VFF5rn3PvPKoLFlqmDGPhaGVpJQoWAZEEGxERFBsDgnY6KFpaWWrQysRGf4BgmSKQFCKWKQMKTqNzz2svv/XY55ybeycTCw+z736cs/f61rdee5hmz/Hx85c66m4QyTEzrdAo4cd6EuuJ2P4wtbmUgfZkCyRoWVcwyMI29ybW47sfhRfXf793+z4X4ZchPEl3F2esElYrbRVaEjQGEKGE3jcUofGwlIEBygoACAa0fmDrdV4AOAg6FV4+W49nUPdlEW4AElGNtqjZ+hqIdI2NAC7KuvAZloyJCR+IukGmF5A6iH/IbEBWLN2NevbBFQ6tCoAF3u7VggYQtQJyFlygOAADI74Jf669QDiWWh6xFRMUgLF6PAGYkcgGgGkBE/x8AiSVaykG0AUxlgm7BY0BUMAQL8R77LM96F98A98kBeu+kAdlgA0MntUGACmOFDQl5sm+Rai6lwpMLtiEgSVGE8wVFBkAB7XcU+rdJOoLSU0x8Aii3ta/0AWqMHjlM6LDPaYDHLSsnRn9pjMny2jBCDSu9H3tDqpCmw4C6lgHqAQmWB05uwwF8RCAQpU7jIbQYCElBsjAlabfqJdnD7lKwzVcIVVOgmKpF2g921pS8/QRvuETmwDEKZdwFHMocYHffYSfBc0opojVIomjx/dY64CkxVktMsgar16/IhbKygANruwWA+YDkURUcNHQaK5ps1XhBwaAzf6M9YzWq3Ac1EKACm80cB8KV6IdPsCR0aQAMBAaUkxXPyU6WDqlypKaSEOtmCCpDyAKFgu1gSecrhdar4n++VsiGUVWDHUpdJkYEPEkEyDc7paHTShXbkuNhqQfaF5wMt16lff69JYFFYT3A8AYgFxku5xtBtw9R7YsEiH85hcYLIsfuO0lfCCHvTtMWxszNRhDebp+LRsTGobFr0zBiO5tBnhWaZgiDwD5gi3Wiw+YcDAwoDfB+MaFq83RsP8M5zSYdFjsBwfh9YAjErbyQLHNVNUsH2Dl2odCh4dE+0vQXjtI9YG2z05zOKvSbdR3eKdtLTbugVKzoOQxC+7KA5NtJPiXEZaH5xDglMrOBMHTWxdWhA/QVqtgEdx3EtVwSkDOxE4GHESpCZzcHLe+4gg3HA7P69jpfvutTA0GTQNNkXAs5UYJVjC593keik/JBohzALjQsXbrJtRksRgntzm7nVX4GnZumtC4D23N4aIAZWdv9LyZv+3IA87AlHY1HQu9+q7Qwb7nAQ01FbQ+g5NBaNOKA2jdD0bg4+UjzCrbqu6IgrLB6aLRF6KWB0ZNUj15QvLCRVa8PNanqiq7pM7kbVXDEvdaipMmHIRfBa2//aYC9WI5vjH6ydLsB1ezpePiK9PhYcoLnjSK5kljNUWqvXppKdVxo4XFhIsJ93gXy/8clxIvt0X7i4XrU8+1D+wGgKPGW/UCzHfew9VsXywVZxbz8GYdKqS4rCTfZ/NZvD8WA/Yxu/aW661F7q+cIbsXVO6EcVf3b0t9SIXFx9N+kwEO3w8QVmhggq+/9xSroVdiv5TZlr0SanL6/KXOK5SaL9b/G4DRdDzONZbPuAjXS4bnfPWBPrJkjhzpYbdR8OeXz62nvBt3HD3z3F/2f0Fyx9O7XL2HAoj7YG33AK8Bag4TrJlOa0DrrVtrj7DsPBtKlgstsZGIcOW+B0wvlMP1EOqcCh1rTldb+/Xcw2woqbaLeh/Vbl7vH/Vgx08TABrehO53ccJKK1ZWP+gjpRqAKdaN8jxLs5r7Bx5TMBm18kjxOOZ0ub/3flUW/nzw4PSJp568CT0vYXq5aGJgslc4o7doPI6dcis2eUq950Ug1DqF9NvQ/uVf79y5v+E1IptedEInNj+iT2L9Nfv9jf7gI/pFdP4D5rfoaYw/Lv+pReVRq/JOEEXOee/PAf7/PP8C3bt510T4rIwAAAAASUVORK5CYII=",Qt=ft({}),Jt=ft({});function gi(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.15?"#D8CB2A":i>.05?"#7ED321":"#58984f"}function ei(i,e,t){const n=i.slice();return n[21]=e[t],n}function ti(i){let e,t,n,s,o,l,r,a,d,p,v,m,f,g,_,b,M;return{c(){e=h("div"),t=h("div"),n=z("svg"),s=z("path"),o=A(),l=h("div"),r=L(i[6]),a=A(),d=h("div"),p=L(i[4]),v=A(),m=h("div"),f=L(i[5]),g=A(),_=h("div"),c(s,"d","M.937-.016L5.793 4.84.937 9.696z"),c(s,"fill",i[8]),c(s,"fill-rule","evenodd"),c(s,"fill-opacity",".582"),c(n,"width","6"),c(n,"height","10"),c(t,"class","frame-triangle svelte-7e9kco"),Me(t,"rotate",!i[9]),Z(t,"visibility",i[0].children.length>0?"visible":"hidden"),c(l,"class","time svelte-7e9kco"),Z(l,"color",i[8]),Z(l,"font-weight",i[11]<.15?500:600),c(d,"class","name svelte-7e9kco"),c(m,"class","code-position svelte-7e9kco"),c(e,"class","frame-description svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),Me(e,"application-code",i[0].isApplicationCode),Me(e,"children-visible",!i[9]),Z(e,"padding-left",`${i[2]*35}px`),c(_,"class","visual-guide svelte-7e9kco"),Z(_,"left",`${i[2]*35+21}px`),Z(_,"background-color",i[8])},m(T,y){O(T,e,y),u(e,t),u(t,n),u(n,s),u(e,o),u(e,l),u(l,r),u(e,a),u(e,d),u(d,p),u(e,v),u(e,m),u(m,f),O(T,g,y),O(T,_,y),b||(M=[N(e,"keydown",i[14]),N(e,"click",Mt(Ct(i[12])))],b=!0)},p(T,y){y&256&&c(s,"fill",T[8]),y&512&&Me(t,"rotate",!T[9]),y&1&&Z(t,"visibility",T[0].children.length>0?"visible":"hidden"),y&64&&me(r,T[6]),y&256&&Z(l,"color",T[8]),y&16&&me(p,T[4]),y&32&&me(f,T[5]),y&1&&Me(e,"application-code",T[0].isApplicationCode),y&512&&Me(e,"children-visible",!T[9]),y&4&&Z(e,"padding-left",`${T[2]*35}px`),y&4&&Z(_,"left",`${T[2]*35+21}px`),y&256&&Z(_,"background-color",T[8])},d(T){T&&(I(e),I(g),I(_)),b=!1,ae(M)}}}function ii(i){let e,t,n,s,o=i[0].group.frames.length-1+"",l,r,a,d,p,v;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=A(),l=L(o),r=L(" frames hidden ("),a=L(i[7]),d=L(")"),c(n,"class","group-triangle svelte-7e9kco"),Me(n,"rotate",i[10]),c(t,"class","group-header-button svelte-7e9kco"),c(e,"class","group-header svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),Z(e,"padding-left",`${i[2]*35}px`)},m(m,f){O(m,e,f),u(e,t),u(t,n),u(t,s),u(t,l),u(t,r),u(t,a),u(t,d),p||(v=[N(e,"keydown",i[15]),N(e,"click",Mt(Ct(i[13])))],p=!0)},p(m,f){f&1024&&Me(n,"rotate",m[10]),f&1&&o!==(o=m[0].group.frames.length-1+"")&&me(l,o),f&128&&me(a,m[7]),f&4&&Z(e,"padding-left",`${m[2]*35}px`)},d(m){m&&I(e),p=!1,ae(v)}}}function ni(i){let e,t=[],n=new Map,s,o=dt(i[0].children);const l=r=>r[21].uuid;for(let r=0;r0&&ni(i);return{c(){e=h("div"),o&&o.c(),t=A(),l&&l.c(),n=A(),r&&r.c(),c(e,"class","frame svelte-7e9kco")},m(a,d){O(a,e,d),o&&o.m(e,null),u(e,t),l&&l.m(e,null),u(e,n),r&&r.m(e,null),s=!0},p(a,[d]){a[3]?o?o.p(a,d):(o=ti(a),o.c(),o.m(e,t)):o&&(o.d(1),o=null),a[0].group&&a[0].group.rootFrame==a[0]&&!a[9]?l?l.p(a,d):(l=ii(a),l.c(),l.m(e,n)):l&&(l.d(1),l=null),!a[9]&&a[0].children.length>0?r?(r.p(a,d),d&513&&H(r,1)):(r=ni(a),r.c(),H(r,1),r.m(e,null)):r&&(xe(),$(r,1,1,()=>{r=null}),qe())},i(a){s||(H(r),s=!0)},o(a){$(r),s=!1},d(a){a&&I(e),o&&o.d(),l&&l.d(),r&&r.d()}}}function _i(){const i='a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])',e=document.querySelector(".call-stack-view");if(!e)throw new Error("callStackElement not found");var t=Array.prototype.filter.call(e.querySelectorAll(i),function(n){return n.offsetWidth>0||n.offsetHeight>0||n===document.activeElement});return t}function oi(){const i=_i();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e+1];t&&t.focus()}}function ri(){const i=_i();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e-1];t&&t.focus()}}function Pn(i,e,t){let n,s,o,l,r;we(i,Jt,w=>t(16,o=w)),we(i,Qt,w=>t(17,l=w)),we(i,K,w=>t(18,r=w));let{frame:a}=e,{rootFrame:d}=e,{indent:p=0}=e,v;const m=a.time/d.time;let f,g;a.isSynthetic||a.filePathShort==null?g="":a.lineNo==null||a.lineNo===0?g=a.filePathShort:g=`${a.filePathShort}:${a.lineNo}`;let _,b=null;if(a.group){const w=a.group.libraries;w.length<4?b=w.join(", "):b=`${w[0]}, ${w[1]}, ${w[2]}...`}let M;M=gi(m);function T(w){y(a,!s,w.altKey)}function y(w,k,S=!0){if(Jt.update(x=>({...x,[w.uuid]:k})),S)for(const x of w.children)y(x,k,!0),w.group&&w.group.rootFrame==w&&F(w.group.id,!k)}function F(w,k){Qt.update(S=>({...S,[w]:k}))}function D(){a.group&&F(a.group.id,!n)}function E(w){let k=!0;w.key==="Enter"||w.key===" "?T(w):w.key==="ArrowLeft"&&!s?y(a,!0,w.altKey):w.key==="ArrowRight"&&s?y(a,!1,w.altKey):w.key==="ArrowUp"?ri():w.key==="ArrowDown"?oi():k=!1,k&&(w.preventDefault(),w.stopPropagation())}function P(w){let k=!0;w.key==="Enter"||w.key===" "?D():w.key==="ArrowLeft"&&a.group?F(a.group.id,!1):w.key==="ArrowRight"&&a.group?F(a.group.id,!0):w.key==="ArrowUp"?ri():w.key==="ArrowDown"?oi():k=!1,k&&(w.preventDefault(),w.stopPropagation())}return i.$$set=w=>{"frame"in w&&t(0,a=w.frame),"rootFrame"in w&&t(1,d=w.rootFrame),"indent"in w&&t(2,p=w.indent)},i.$$.update=()=>{var w,k;if(i.$$.dirty&131073&&(a.group?l[a.group.id??""]||((w=a.group)==null?void 0:w.rootFrame)===a||a.children.filter(S=>!S.group).length>1?t(3,v=!0):t(3,v=!1):t(3,v=!0)),i.$$.dirty&1&&(a.className?t(4,f=`${a.className}.${a.function}`):t(4,f=a.function)),i.$$.dirty&262145)if(r.timeFormat==="absolute")t(6,_=a.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(r.timeFormat==="proportion")t(6,_=`${(m*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(10,n=l[((k=a.group)==null?void 0:k.id)??""]===!0),i.$$.dirty&65537&&t(9,s=o[a.uuid]===!0)},[a,d,p,v,f,g,_,b,M,s,n,m,T,D,E,P,o,l,r]}let wi=class extends ue{constructor(e){super(),ce(this,e,Pn,Fn,oe,{frame:0,rootFrame:1,indent:2})}};function bi(i,e,t){let n=i;for(const s of e)if(n=s(n,t),!n)return null;return n}const Ln="\0",Rn="[await]",et="[self]",Sn="[out-of-context]",In="[root]",On=[Rn,et,Sn,In],Dn="c",Hn="h";class Je{constructor(e,t){C(this,"uuid",ht());C(this,"identifier");C(this,"_identifierParts");C(this,"startTime");C(this,"time",0);C(this,"absorbedTime",0);C(this,"group",null);C(this,"attributes");C(this,"_children",[]);C(this,"parent",null);C(this,"context");var o;this.identifier=e.identifier,this._identifierParts=this.identifier.split(Ln),this.startTime=e.startTime??0,this.time=e.time??0,this.attributes=e.attributes??{},this.context=t;let n=this.startTime;const s=(o=e.children)==null?void 0:o.map(l=>(l.startTime===void 0&&(l={...l,startTime:n},n+=l.time??0),n=l.startTime+(l.time??0),new Je(l,t)));s&&this.addChildren(s)}cloneDeep(){return new Je(this,this.context)}get children(){return this._children}addChild(e,t={}){if(e.removeFromParent(),e.parent=this,t.after){const n=this._children.indexOf(t.after);if(n==-1)throw new Error("After frame not found");this._children.splice(n+1,0,e)}else this._children.push(e)}addChildren(e,t={}){e=e.slice(),t.after?(e.slice().reverse(),e.forEach(s=>this.addChild(s,t))):e.forEach(n=>this.addChild(n,t))}removeFromParent(){if(this.parent){const e=this.parent._children.indexOf(this);this.parent._children.splice(e,1),this.parent=null}}getAttributes(e){return Object.keys(this.attributes).filter(n=>n.startsWith(e)).map(n=>({data:n.slice(1),time:this.attributes[n]}))}getAttributeValue(e){const t=this.getAttributes(e);if(!t||t.length==0)return null;let n=0;for(let s=0;st[n].time&&(n=s);return t[n].data}get hasTracebackHide(){return this.getAttributeValue(Hn)=="1"}get function(){return this._identifierParts[0]}get filePath(){return this._identifierParts[1]??null}get lineNo(){const e=this._identifierParts[2];return e?parseInt(e):null}get isSynthetic(){return On.includes(this.identifier)}get filePathShort(){return this.isSynthetic&&this.parent?this.parent.filePathShort:this.filePath?this.context.shortenPath(this.filePath):null}get isApplicationCode(){if(this.isSynthetic)return!1;const e=this.filePath;return!e||this.context.sysPrefixes.some(n=>e.startsWith(n))?!1:e.startsWith("<")?e.startsWith(""||e==""?this.parent?this.parent.isApplicationCode:!0:!1:!0}get proportionOfParent(){return this.parent?this.time/this.parent.time:1}get className(){return this.getAttributeValue(Dn)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class Vn{constructor(e){C(this,"id");C(this,"rootFrame");C(this,"_frames",[]);this.id=ht(),this.rootFrame=e}addFrame(e){e.group&&e.group.removeFrame(e),this._frames.push(e),e.group=this}removeFrame(e){if(e.group!==this)throw new Error("Frame not in group.");const t=this._frames.indexOf(e);if(t===-1)throw new Error("Frame not found in group.");this._frames.splice(t,1),e.group=null}get frames(){return this._frames}get exitFrames(){const e=[];for(const t of this.frames){let n=!1;for(const s of t.children)if(s.group!=this){n=!0;break}n&&e.push(t)}return e}get libraries(){const e=[];for(const t of this.frames){const n=t.library;n&&(e.includes(n)||e.push(n))}return e}}function mt(i,e){const{replaceWith:t}=e,n=i.parent;if(!n)throw new Error("Cannot delete the root frame");if(t=="children")n.addChildren(i.children,{after:i});else if(t=="self_time")n.addChild(new Je({identifier:et,time:i.time},n.context),{after:i});else if(t=="nothing")n.absorbedTime+=i.time;else throw new on(t);i.removeFromParent(),Lt(i,!0)}function Nn(i,e){if(i.parent!==e.parent)throw new Error("Both frames must have the same parent.");e.absorbedTime+=i.absorbedTime,e.time+=i.time,Object.entries(i.attributes).forEach(([t,n])=>{e.attributes[t]!==void 0?e.attributes[t]+=n:e.attributes[t]=n}),e.addChildren(i.children),i.removeFromParent(),Lt(i,!1)}function Lt(i,e){if(e&&i.children&&i.children.forEach(t=>{Lt(t,!0)}),i.group){const t=i.group;t.removeFrame(i),t.frames.length===1&&t.removeFrame(t.frames[0])}}function Rt(i,e){if(!i)return null;for(const t of i.children)Rt(t),t.filePath&&t.filePath.includes("yi(n)),i._children.sort((n,s)=>s.time-n.time),i}function Ti(i,e){if(!i)return null;const t=e.hideRegex,n=e.showRegex;function s(l){const r=l.filePath||"",a=n&&new RegExp(n).test(r),d=t&&new RegExp(t).test(r);return a?!1:d?!0:!l.isApplicationCode}function o(l,r){r.addFrame(l),l.children.forEach(a=>{s(a)&&o(a,r)})}return i.children.forEach(l=>{if(!l.group&&s(l)&&l.children.some(s)){const r=new Vn(l);o(l,r)}Ti(l,e)}),i}function Ai(i,e,t=!0){if(!i)return null;let n=null;for(const s of i.children)s.identifier===et?n?(n.time+=s.time,s.removeFromParent()):n=s:n=null;return t&&i.children.forEach(s=>Ai(s,e,!0)),i}function Ei(i,e){return i?(i.children.length===1&&i.children[0].identifier===et&&mt(i.children[0],{replaceWith:"nothing"}),i.children.forEach(t=>Ei(t)),i):null}function ki(i,e,t=null){if(!i)return null;t===null&&(t=i.time,t<=0&&(t=1e-44));const n=e.filterThreshold??.01;for(const s of i.children.slice())s.time/tki(s,e,t)),i}function Ci(i,e){if(!i)return null;const t=r=>fn(r,a=>a.time),n=r=>{var a;return((a=r.filePath)==null?void 0:a.includes("pyinstrument/__main__.py"))&&r.children.length>0},s=r=>{var a;return r.proportionOfParent>.8&&((a=r.filePath)==null?void 0:a.includes(""))&&r.children.length>0},o=r=>{var a;return r.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(r.filePath??"")||((a=r.filePath)==null?void 0:a.includes("")))&&r.children.length>0};let l=i;if(!n(l)||(l=t(l.children),!s(l))||(l=t(l.children),!o(l)))return i;for(;o(l);)l=t(l.children);return l.removeFromParent(),l}function Mi(i,e){return i?(i.children.forEach(t=>Mi(t)),i.group&&i.group.frames.length<3&&i.group.removeFrame(i),i):null}function Bn(i){let e,t,n;return t=new wi({props:{frame:i[3],rootFrame:i[3]}}),{c(){e=h("div"),be(t.$$.fragment),c(e,"class","call-stack-margins svelte-1hebm9u")},m(s,o){O(s,e,o),pe(t,e,null),n=!0},p(s,o){const l={};o&8&&(l.frame=s[3]),o&8&&(l.rootFrame=s[3]),t.$set(l)},i(s){n||(H(t.$$.fragment,s),n=!0)},o(s){$(t.$$.fragment,s),n=!1},d(s){s&&I(e),ve(t)}}}function zn(i){let e;return{c(){e=h("div"),e.innerHTML='
All frames were filtered out.
',c(e,"class","margins")},m(t,n){O(t,e,n)},p:R,i:R,o:R,d(t){t&&I(e)}}}function $n(i){let e,t,n,s,o,l,r;const a=[zn,Bn],d=[];function p(v,m){return v[3]?1:0}return n=p(i),s=d[n]=a[n](i),{c(){e=h("div"),t=h("div"),s.c(),o=A(),l=h("div"),c(t,"class","scroll-inner svelte-1hebm9u"),c(l,"class","scroll-size-fixer svelte-1hebm9u"),c(e,"class","call-stack-view svelte-1hebm9u")},m(v,m){O(v,e,m),u(e,t),d[n].m(t,null),i[7](t),u(e,o),u(e,l),i[8](l),i[9](e),r=!0},p(v,[m]){let f=n;n=p(v),n===f?d[n].p(v,m):(xe(),$(d[f],1,1,()=>{d[f]=null}),qe(),s=d[n],s?s.p(v,m):(s=d[n]=a[n](v),s.c()),H(s,1),s.m(t,null))},i(v){r||(H(s),r=!0)},o(v){$(s),r=!1},d(v){v&&I(e),d[n].d(),i[7](null),i[8](null),i[9](null)}}}function xn(i,e,t){let n,{session:s}=e;const o=vi([K],([f])=>{const g=[f.removeImportlib?Rt:null,f.removeTracebackHide?St:null,Ai,yi,Ei,f.removeIrrelevant?ki:null,f.removePyinstrument?Ci:null,f.collapseMode!=="disabled"?Ti:null,Mi].filter(b=>b!==null),_={filterThreshold:f.removeIrrelevantThreshold,hideRegex:f.collapseMode=="custom"?f.collapseCustomHide:void 0,showRegex:f.collapseMode=="custom"?f.collapseCustomShow:void 0};return{processors:g,options:_}});we(i,o,f=>t(6,n=f));let l,r,a;Tt(()=>{let f=0;const g=l;if(!g)throw new Error("element not set");if(!r)throw new Error("scrollInnerElement not set");if(!a)throw new Error("scrollSizeFixerElement not set");const _=new ResizeObserver(()=>{const M=r.getBoundingClientRect().height;M>f&&(f=M,t(2,a.style.top=`${f-1}px`,a))});_.observe(r);let b;return g.addEventListener("scroll",b=()=>{let M=g.scrollTop+g.clientHeight;const T=r.getBoundingClientRect().height;M{_.disconnect(),g.removeEventListener("scroll",b)}});let d;function p(f){Ae[f?"unshift":"push"](()=>{r=f,t(1,r)})}function v(f){Ae[f?"unshift":"push"](()=>{a=f,t(2,a)})}function m(f){Ae[f?"unshift":"push"](()=>{l=f,t(0,l)})}return i.$$set=f=>{"session"in f&&t(5,s=f.session)},i.$$.update=()=>{i.$$.dirty&96&&t(3,d=bi(s.rootFrame.cloneDeep(),n.processors,n.options))},[l,r,a,d,o,s,n,p,v,m]}class qn extends ue{constructor(e){super(),ce(this,e,xn,$n,oe,{session:5})}}class Wn{constructor(e){C(this,"mediaQueryList",null);this.onDevicePixelRatioChanged=e,this._onChange=this._onChange.bind(this),this.createMediaQueryList()}createMediaQueryList(){this.removeMediaQueryList();let e=`(resolution: ${window.devicePixelRatio}dppx)`;this.mediaQueryList=matchMedia(e),this.mediaQueryList.addEventListener("change",this._onChange)}removeMediaQueryList(){var e;(e=this.mediaQueryList)==null||e.removeEventListener("change",this._onChange),this.mediaQueryList=null}_onChange(e){this.onDevicePixelRatioChanged(),this.createMediaQueryList()}destroy(){this.removeMediaQueryList()}}class Un{constructor(e){C(this,"canvas");C(this,"_size_observer");C(this,"_devicePixelRatioObserver");C(this,"drawAnimationRequest",null);this.container=e,getComputedStyle(e).position!="absolute"&&(e.style.position="relative"),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.container.appendChild(this.canvas),this.setCanvasSize=this.setCanvasSize.bind(this),this._size_observer=new ResizeObserver(this.setCanvasSize),this._size_observer.observe(e),this._devicePixelRatioObserver=new Wn(this.setCanvasSize),window.requestAnimationFrame(()=>{this.setCanvasSize()})}destroy(){this._size_observer.disconnect(),this._devicePixelRatioObserver.destroy(),this.canvas.remove(),this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null)}setNeedsRedraw(){this.drawAnimationRequest===null&&(this.drawAnimationRequest=window.requestAnimationFrame(()=>{this.drawAnimationRequest=null,this.canvasViewRedraw()}))}redrawIfNeeded(){this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null,this.canvasViewRedraw())}canvasViewRedraw(){const e=this.canvas.getContext("2d");e&&(e.resetTransform(),e.scale(window.devicePixelRatio,window.devicePixelRatio),this.redraw(e,{width:this.canvas.width/window.devicePixelRatio,height:this.canvas.height/window.devicePixelRatio}))}get width(){return this.canvas.width/window.devicePixelRatio}get height(){return this.canvas.height/window.devicePixelRatio}setCanvasSize(){const e=window.devicePixelRatio;this.canvas.height=this.container.clientHeight*e,this.canvas.width=this.container.clientWidth*e,this.canvasViewRedraw()}}function jn(i){let e,t=i[2]=="self"?"self":"time",n,s,o,l=i[3](i[0].time)+"";return{c(){e=h("div"),n=L(t),s=A(),o=h("div"),c(e,"class","label svelte-ci3g2p"),c(o,"class","time-val svelte-ci3g2p")},m(r,a){O(r,e,a),u(e,n),O(r,s,a),O(r,o,a),o.innerHTML=l},p(r,a){a&4&&t!==(t=r[2]=="self"?"self":"time")&&me(n,t),a&1&&l!==(l=r[3](r[0].time)+"")&&(o.innerHTML=l)},d(r){r&&(I(e),I(s),I(o))}}}function Yn(i){let e,t,n,s,o=i[3](i[0].time)+"",l,r=i[0].selfTime/i[0].time>.001&&li(i);return{c(){e=h("div"),e.textContent="time",t=A(),n=h("div"),s=h("div"),l=A(),r&&r.c(),c(e,"class","label svelte-ci3g2p"),c(s,"class","time-val svelte-ci3g2p"),c(n,"class","time-row svelte-ci3g2p")},m(a,d){O(a,e,d),O(a,t,d),O(a,n,d),u(n,s),s.innerHTML=o,u(n,l),r&&r.m(n,null)},p(a,d){d&1&&o!==(o=a[3](a[0].time)+"")&&(s.innerHTML=o),a[0].selfTime/a[0].time>.001?r?r.p(a,d):(r=li(a),r.c(),r.m(n,null)):r&&(r.d(1),r=null)},d(a){a&&(I(e),I(t),I(n)),r&&r.d()}}}function li(i){let e,t,n,s=i[3](i[0].selfTime)+"";return{c(){e=h("div"),e.textContent="self",t=A(),n=h("div"),c(e,"class","label svelte-ci3g2p"),c(n,"class","time-val svelte-ci3g2p")},m(o,l){O(o,e,l),O(o,t,l),O(o,n,l),n.innerHTML=s},p(o,l){l&1&&s!==(s=o[3](o[0].selfTime)+"")&&(n.innerHTML=s)},d(o){o&&(I(e),I(t),I(n))}}}function Xn(i){let e,t,n=i[0].name+"",s,o,l,r,a,d,p,v,m,f;function g(M,T){return M[2]=="both"?Yn:jn}let _=g(i),b=_(i);return{c(){e=h("div"),t=h("div"),s=L(n),o=A(),b.c(),l=A(),r=h("div"),r.textContent="loc",a=A(),d=h("div"),p=h("div"),m=A(),f=new $i(!1),c(t,"class","name svelte-ci3g2p"),c(r,"class","label svelte-ci3g2p"),c(p,"class","location-color svelte-ci3g2p"),c(p,"style",v=`background: ${i[0].locationColor}`),f.a=null,c(d,"class","location-row"),c(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),c(e,"style",`font: ${Pi}; max-width: ${Kn}px;`)},m(M,T){O(M,e,T),u(e,t),u(t,s),u(e,o),b.m(e,null),u(e,l),u(e,r),u(e,a),u(e,d),u(d,p),u(d,m),f.m(i[1],d)},p(M,[T]){T&1&&n!==(n=M[0].name+"")&&me(s,n),_===(_=g(M))&&b?b.p(M,T):(b.d(1),b=_(M),b&&(b.c(),b.m(e,l))),T&1&&v!==(v=`background: ${M[0].locationColor}`)&&c(p,"style",v),T&2&&f.p(M[1])},i:R,o:R,d(M){M&&I(e),b.d()}}}function Fi(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Gn(i,e){i.font=Pi;const t=Fi(e)=="both"?140:70,n=i.measureText(e.name).width,s=i.measureText(e.location).width+46;let l=Math.max(t,n,s)+20;return l>310&&(l=310),l}const Kn=310,Pi="400 13px Source Sans Pro, sans-serif";function Zn(i,e,t){let{f:n}=e,s,o;function l(r){return`${r.toFixed(3)}`}return i.$$set=r=>{"f"in r&&t(0,n=r.f)},i.$$.update=()=>{i.$$.dirty&1&&t(1,s=Et(n.location)),i.$$.dirty&1&&t(2,o=Fi(n))},[n,s,o,l]}class Qn extends ue{constructor(e){super(),ce(this,e,Zn,Xn,oe,{f:0})}}const Jn="#212325",ai=18,es=17,Pe=28,at=17,ci=29,ts=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"],is=ts.map(cn);class ns extends Un{constructor(t){super(t);C(this,"zoom",1);C(this,"startT",0);C(this,"yOffset",0);C(this,"frames",[]);C(this,"isZoomedIn",!1);C(this,"tooltipContainer");C(this,"tooltipComponent",null);C(this,"_rootFrame",null);C(this,"maxDepth",0);C(this,"tooltipLocation",null);C(this,"lastDrawWidth",0);C(this,"lastDrawHeight",0);C(this,"_libraryOrder",null);C(this,"_colors",[]);C(this,"_frameMaxT");C(this,"mouseLocation",null);C(this,"mouseDownLocation",null);C(this,"touches",{});this.onWheel=this.onWheel.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.windowMouseUp=this.windowMouseUp.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onTouchcancel=this.onTouchend.bind(this),this.canvas.addEventListener("wheel",this.onWheel),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseleave",this.onMouseLeave),this.canvas.addEventListener("mousedown",this.onMouseDown),this.canvas.addEventListener("touchstart",this.onTouchstart),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend),this.canvas.addEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer=document.createElement("div"),this.tooltipContainer.style.position="absolute",this.tooltipContainer.style.pointerEvents="none",this.container.appendChild(this.tooltipContainer)}destroy(){this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("touchstart",this.onTouchstart),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend),this.canvas.removeEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer.remove(),super.destroy()}setRootFrame(t){this._rootFrame=t,this.frames=[],this._frameMaxT=void 0,this.maxDepth=0,this._collectFrames(t,0),this.fitContents(),this.setNeedsRedraw()}_collectFrames(t,n){this.frames.push({frame:t,depth:n,isApplicationCode:t.isApplicationCode,library:t.library,className:t.className,filePathShort:t.filePathShort}),this.maxDepth=Math.max(this.maxDepth,n);for(const s of t.children)s.identifier!==et&&this._collectFrames(s,n+1)}updateTooltip(t,n){var s;if(n){const o={name:this.frameName(n),time:n.frame.time,selfTime:this.frameSelfTime(n),totalTime:((s=this._rootFrame)==null?void 0:s.time)??1e-12,location:`${n.filePathShort}:${n.frame.lineNo}`,locationColor:this.colorForFrame(n)};if(this.tooltipComponent?this.tooltipComponent.$set({f:o}):this.tooltipComponent=new Qn({target:this.tooltipContainer,props:{f:o}}),this.tooltipLocation){const l={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},r=Gn(t,o),a=this.width-10-r;l.x>a&&(l.x=a);const p=this.height-10-60;l.y>p&&(l.y=p),this.tooltipContainer.style.left=`${l.x}px`,this.tooltipContainer.style.top=`${l.y}px`}}n||this.tooltipComponent&&(this.tooltipComponent.$destroy(),this.tooltipComponent=null)}redraw(t,n){const{width:s,height:o}=n;(s!==this.lastDrawWidth||o!==this.lastDrawHeight)&&(this.isZoomedIn?this.clampViewport():this.fitContents()),this.lastDrawWidth=s,this.lastDrawHeight=o,t.fillStyle=Jn,t.fillRect(0,0,s,o),this.drawAxes(t);for(const d of this.frames)this.drawFrame(t,d);t.globalAlpha=1;const l=this.maxYOffset>0||this.isZoomedIn,r=!!this.mouseDownLocation;this.canvas.style.cursor=r&&l?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let a=null;!r&&this.tooltipLocation&&(a=this.hitTest(this.tooltipLocation)),this.updateTooltip(t,a)}drawAxes(t){const n=Math.max(800,this.width)/this.zoom;if(n==0)return;const s=Math.log10(n);let o=Math.ceil(s)+2;o<0&&(o=0);const l=Math.ceil(s)-3,r=a=>ze(a,{from:[s,s-3],to:[.71,0],clamp:!0});for(let a=l;a.01){t.globalAlpha=f,t.font='13px "Source Sans Pro", sans-serif';let g=d.toFixed(a);g=="0"&&(g="0s");let _=m+10;t.fillText(g,p+3,_);let b=this.height+at+10-this.yOffset;bthis.width)return;if(t.fillStyle=this.colorForFrame(n),t.globalAlpha=n.isApplicationCode?1:.5,l<2){t.fillRect(s,o,l,r);return}let d=this.frameName(n);const p=Math.floor(l/3.3);if(d.length>p&&(d=d.substring(0,p)),d.length==0){t.fillRect(s,o,l,r);return}t.save(),t.beginPath(),t.rect(s,o,l,r),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let v=s;v<0&&(v=0),t.fillText(d,v+2,o+13),t.restore()}_assignLibraryOrder(){const t={};for(const s of this.frames){const l=s.frame.library??"";t[l]=(t[l]||0)+s.frame.time}const n=Object.keys(t);n.sort((s,o)=>t[o]-t[s]),this._libraryOrder=n}colorForLibraryIndex(t){if(this._colors[t]!==void 0)return this._colors[t];const n=Math.pow(2,Math.ceil(Math.log2(t+1))),o=(2*t-n+1)/n,l=rn(is,o);return this._colors[t]=l,l}libraryIndexForFrame(t){this._libraryOrder||this._assignLibraryOrder();const n=t.library||"";let s=this._libraryOrder.indexOf(n);return s===-1&&(s=this._libraryOrder.length,this._libraryOrder.push(n)),s}colorForFrame(t){const n=this.libraryIndexForFrame(t);return this.colorForLibraryIndex(n)}get frameMaxT(){return this._frameMaxT===void 0&&(this._frameMaxT=this.frames.reduce((t,n)=>Math.max(t,n.frame.startTime+n.frame.time),0)),this._frameMaxT}get maxYOffset(){return Math.max(0,(this.maxDepth+1)*ai+at*2+ci-this.height)}get minZoom(){return(this.width-2*Pe)/this.frameMaxT}get maxZoom(){return 10/15e-8}fitContents(){this.startT=0,this.zoom=this.minZoom,this.isZoomedIn=!1}clampViewport(){this.zoomthis.maxZoom&&(this.zoom=this.maxZoom),this.startT<0&&(this.startT=0);const t=this.frameMaxT-(this.width-2*Pe)/this.zoom;this.startT>t&&(this.startT=t),this.yOffset<0&&(this.yOffset=0),this.yOffset>this.maxYOffset&&(this.yOffset=this.maxYOffset)}frameDims(t){const n=t.depth*ai+at+ci-this.yOffset,s=es;let o=this.xForT(t.frame.startTime),r=this.xForT(t.frame.startTime+t.frame.time)-o;return r<1&&(r=1),r>1&&(r-=ze(r,{from:[1,3],to:[0,1],clamp:!0})),{x:o,y:n,w:r,h:s}}xForT(t){return(t-this.startT)*this.zoom+Pe}tForX(t){return(t-Pe)/this.zoom+this.startT}frameName(t){let n;return t.className?n=`${t.className}.${t.frame.function}`:t.frame.function==""?n=t.filePathShort??t.frame.filePath??"":n=t.frame.function,n}frameSelfTime(t){let n=t.frame.time;const s=t.frame.children.filter(o=>!o.isSynthetic);for(const o of s)n-=o.time;return n}hitTest(t){for(const n of this.frames){const{x:s,y:o,w:l,h:r}=this.frameDims(n);if(t.x>=s&&t.x<=s+l&&t.y>=o&&t.y<=o+r)return n}return null}onWheel(t){const n=t.ctrlKey||t.metaKey,s=n?.01:.0023,o=this.tForX(t.offsetX);this.zoom*=1-t.deltaY*s,this.clampViewport(),this.startT=o-(t.offsetX-Pe)/this.zoom,n||(this.startT+=t.deltaX/this.zoom),this.clampViewport(),this.setNeedsRedraw(),t.preventDefault()}onMouseMove(t){const n={x:t.offsetX,y:t.offsetY},s=this.mouseLocation;if(this.mouseLocation=n,s&&this.mouseDownLocation){const o={x:n.x-s.x,y:n.y-s.y};this.startT-=o.x/this.zoom,this.yOffset-=o.y,this.clampViewport()}this.tooltipLocation=n,this.setNeedsRedraw()}onMouseLeave(t){this.mouseLocation=null,this.tooltipLocation=null,this.setNeedsRedraw()}onMouseDown(t){(t.button===0||t.button===1)&&(this.mouseDownLocation={x:t.offsetX,y:t.offsetY},window.addEventListener("mouseup",this.windowMouseUp),this.setNeedsRedraw())}windowMouseUp(t){window.removeEventListener("mouseup",this.windowMouseUp),this.mouseDownLocation=null,this.setNeedsRedraw()}onTouchstart(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))this.touches[n.identifier]={x:n.clientX,y:n.clientY,downT:this.tForX(n.clientX),startDate:Date.now(),downX:n.clientX,downY:n.clientY}}onTouchmove(t){t.preventDefault(),t.stopPropagation();let n=0;for(const o of Array.from(t.changedTouches)){const l=this.touches[o.identifier];l&&(n+=o.clientY-l.y,this.touches[o.identifier]={...l,x:o.clientX,y:o.clientY})}const s=n/Object.keys(this.touches).length;this.yOffset-=s,this.adjustXAxisForTouches(),this.setNeedsRedraw()}onTouchend(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}onTouchcancel(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}adjustXAxisForTouches(){const t=Object.keys(this.touches).map(Number);if(t.length!=0){if(t.length==1){const n=this.touches[t[0]];this.startT=n.downT-(n.x-Pe)/this.zoom}if(t.length>=2){const n=this.touches[t[0]],s=this.touches[t[1]],o=(s.x-n.x)/(s.downT-n.downT),l=n.downT-(n.x-Pe)/o;this.startT=l,this.zoom=o}this.clampViewport()}}}function ss(i){let e;return{c(){e=h("div"),e.innerHTML="",c(e,"class","timeline svelte-p2tt1k")},m(t,n){O(t,e,n),i[6](e)},p:R,i:R,o:R,d(t){t&&I(e),i[6](null)}}}function os(i,e,t){let n,{session:s}=e;const o=vi([Ge],([p])=>({processors:[p.removeImportlib?Rt:null,p.removeTracebackHide?St:null,p.removePyinstrument?Ci:null].filter(f=>f!==null),options:{}}));we(i,o,p=>t(5,n=p));let l,r=null,a=null;xi(()=>{a==null||a.destroy()});function d(p){Ae[p?"unshift":"push"](()=>{r=p,t(0,r)})}return i.$$set=p=>{"session"in p&&t(2,s=p.session)},i.$$.update=()=>{i.$$.dirty&36&&t(3,l=bi(s.rootFrame.cloneDeep(),n.processors,n.options)),i.$$.dirty&1&&r&&t(4,a=new ns(r)),i.$$.dirty&24&&l&&a&&a.setRootFrame(l)},[r,o,s,l,a,n,d]}class rs extends ue{constructor(e){super(),ce(this,e,os,ss,oe,{session:2})}}function ls(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=L("Unknown view mode: "),s=L(n),c(e,"class","error")},m(o,l){O(o,e,l),u(e,t),u(e,s)},p(o,l){l&2&&n!==(n=o[1].viewMode+"")&&me(s,n)},i:R,o:R,d(o){o&&I(e)}}}function as(i){let e,t;return e=new rs({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p(n,s){const o={};s&1&&(o.session=n[0]),e.$set(o)},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){$(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function cs(i){let e,t;return e=new qn({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){pe(e,n,s),t=!0},p(n,s){const o={};s&1&&(o.session=n[0]),e.$set(o)},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){$(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function us(i){let e;return{c(){e=h("div"),e.innerHTML='
No samples recorded.
',c(e,"class","margins")},m(t,n){O(t,e,n)},p:R,i:R,o:R,d(t){t&&I(e)}}}function ds(i){let e,t,n,s,o,l,r,a;n=new Cn({props:{session:i[0]}});const d=[us,cs,as,ls],p=[];function v(m,f){return m[0].rootFrame?m[1].viewMode==="call-stack"?1:m[1].viewMode==="timeline"?2:3:0}return l=v(i),r=p[l]=d[l](i),{c(){e=h("div"),t=h("div"),be(n.$$.fragment),s=A(),o=h("div"),r.c(),c(t,"class","header"),c(o,"class","body svelte-1vwroj7"),c(e,"class","app svelte-1vwroj7")},m(m,f){O(m,e,f),u(e,t),pe(n,t,null),u(e,s),u(e,o),p[l].m(o,null),a=!0},p(m,[f]){const g={};f&1&&(g.session=m[0]),n.$set(g);let _=l;l=v(m),l===_?p[l].p(m,f):(xe(),$(p[_],1,1,()=>{p[_]=null}),qe(),r=p[l],r?r.p(m,f):(r=p[l]=d[l](m),r.c()),H(r,1),r.m(o,null))},i(m){a||(H(n.$$.fragment,m),H(r),a=!0)},o(m){$(n.$$.fragment,m),$(r),a=!1},d(m){m&&I(e),ve(n),p[l].d()}}}function fs(i,e,t){let n;we(i,Ze,v=>t(1,n=v));let{session:s}=e;const o=document.createElement("link");o.rel="shortcut icon",o.href=Mn,document.head.appendChild(o);const l=document.createElement("link");l.rel="preload",l.as="style",l.onload=()=>{l.rel="stylesheet"},l.href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,600|Source+Sans+Pro:400,600&display=swap",document.head.appendChild(l);const r=s.rootFrame,a=r==null?void 0:r.time.toLocaleString(void 0,{maximumSignificantDigits:3});let d,p;return(p=/[^\s/]+(:\d+)?$/.exec(s.target_description))?d=p[0]:d=s.target_description,document.title=`${a}s - ${d} - pyinstrument`,i.$$set=v=>{"session"in v&&t(0,s=v.session)},[s,n]}class hs extends ue{constructor(e){super(),ce(this,e,fs,ds,oe,{session:0})}}class ms{constructor(e){C(this,"startTime");C(this,"duration");C(this,"minInterval");C(this,"maxInterval");C(this,"sampleCount");C(this,"target_description");C(this,"cpuTime");C(this,"rootFrame");C(this,"sysPath");C(this,"sysPrefixes");C(this,"_shortenPathCache",{});this.startTime=e.session.start_time,this.duration=e.session.duration,this.minInterval=e.session.min_interval,this.maxInterval=e.session.max_interval,this.sampleCount=e.session.sample_count,this.target_description=e.session.target_description,this.cpuTime=e.session.cpu_time,this.sysPath=e.session.sys_path,this.sysPrefixes=e.session.sys_prefixes,this.rootFrame=new Je(e.frame_tree,this)}shortenPath(e){if(this._shortenPathCache[e])return this._shortenPathCache[e];let t=e;if($e(e).length>1)for(const s of this.sysPath){const o=ps(e,s);$e(o).length<$e(t).length&&(t=o)}return this._shortenPathCache[e]=t,t}}function $e(i){return i.split(/[/\\]/)}function ui(i){const e=$e(i);return e.length>0&&e[0].endsWith(":")?e[0]:null}function ps(i,e){if(ui(i)!=ui(e))return i;const t=$e(i),n=$e(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}const vs={render(i,e){const t=new ms(e);return new hs({target:i,props:{session:t}})}};function di(i,e,t){const n=i.slice();return n[10]=e[t],n}function fi(i){let e,t=i[10].name+"",n;return{c(){e=h("option"),n=L(t),e.__value=i[10],le(e,e.__value)},m(s,o){O(s,e,o),u(e,n)},p:R,d(s){s&&I(e)}}}function gs(i){let e,t,n=i[3].message+"",s;return{c(){e=h("div"),t=L("Error loading file: "),s=L(n)},m(o,l){O(o,e,l),u(e,t),u(e,s)},p(o,l){l&8&&n!==(n=o[3].message+"")&&me(s,n)},d(o){o&&I(e)}}}function _s(i){let e;return{c(){e=h("div"),e.textContent="Loading..."},m(t,n){O(t,e,n)},p:R,d(t){t&&I(e)}}}function ws(i){let e,t,n,s,o,l,r,a,d,p,v,m,f,g,_=dt(i[5]),b=[];for(let F=0;F<_.length;F+=1)b[F]=fi(di(i,_,F));function M(F,D){if(F[4])return _s;if(F[3])return gs}let T=M(i),y=T&&T(i);return{c(){e=h("div"),t=h("div"),n=h("div"),s=A(),o=h("div"),l=L(`Choose a demo profile: - `),r=h("select");for(let F=0;Fi[7].call(r)),c(o,"class","right"),c(t,"class","header svelte-1980ffz"),c(v,"class","result-element"),c(v,"style",m=i[1]?"":"display: none"),c(d,"class","body svelte-1980ffz"),c(e,"class","demo-app svelte-1980ffz")},m(F,D){O(F,e,D),u(e,t),u(t,n),u(t,s),u(t,o),u(o,l),u(o,r);for(let E=0;E_t(()=>import("./django_template_render-CIkNzFIy.js"),[],import.meta.url).then(f=>f.default),"../demo-data/sympy_calculation.json":()=>_t(()=>import("./sympy_calculation-B9Pn_4RL.js"),[],import.meta.url).then(f=>f.default),"../demo-data/wikipedia_article_word_count.json":()=>_t(()=>import("./wikipedia_article_word_count-CGt_pvsZ.js"),[],import.meta.url).then(f=>f.default)})).map(([f,g])=>({name:f.split("/").pop().split(".").slice(0,-1).join("."),promiseFn:g}));let o=s[0],l=null,r=null,a=!1,d=null,p;function v(){o=Bi(this),t(0,o),t(5,s)}function m(f){Ae[f?"unshift":"push"](()=>{p=f,t(2,p)})}return i.$$.update=()=>{i.$$.dirty&1&&(t(4,a=!0),t(3,r=null),t(1,l=null),o.promiseFn().then(f=>{t(1,l=f),t(3,r=null)}).catch(f=>{t(3,r=f)}).finally(()=>{t(4,a=!1)})),i.$$.dirty&70&&p&&l&&(d&&d.$destroy(),t(6,d=vs.render(p,l)))},[o,l,p,r,a,s,d,v,m]}class ys extends ue{constructor(e){super(),ce(this,e,bs,ws,oe,{})}}new ys({target:document.body}); diff --git a/docs/_static/preview/index.html b/docs/_static/preview/index.html index 2b78d52c..4595475d 100644 --- a/docs/_static/preview/index.html +++ b/docs/_static/preview/index.html @@ -5,7 +5,7 @@ Pyinstrument Demo - + diff --git a/html_renderer/src/App.svelte b/html_renderer/src/App.svelte index 9a44b130..e578587c 100644 --- a/html_renderer/src/App.svelte +++ b/html_renderer/src/App.svelte @@ -28,8 +28,20 @@ link.href = `https://fonts.googleapis.com/css?family=Source+Code+Pro:400,600|Source+Sans+Pro:400,600&display=swap`; document.head.appendChild(link); - const rootFrame = session.rootFrame; - const duration = rootFrame?.time.toLocaleString(undefined, {maximumSignificantDigits: 3}); + const rootFrames = session.rootFrames; + let maxTime = 0; + if (rootFrames != null) { + for (const thread_id of Object.keys(rootFrames)) { + const rootFrame = rootFrames[thread_id]; + if (rootFrame != null) { + const t = rootFrame.time; + if (t > maxTime) { + maxTime = t; + } + } + } + } + const duration = maxTime.toLocaleString(undefined, {maximumSignificantDigits: 3}); let name // let name = rootFrame?.function; // if (name == '') { @@ -53,7 +65,7 @@
- {#if !session.rootFrame} + {#if !session.rootFrames}
diff --git a/html_renderer/src/components/CallStackView.svelte b/html_renderer/src/components/CallStackView.svelte index a4292ba1..cd61eee0 100644 --- a/html_renderer/src/components/CallStackView.svelte +++ b/html_renderer/src/components/CallStackView.svelte @@ -75,13 +75,17 @@ } }); - let rootFrame: Frame|null - $: rootFrame = applyProcessors(session.rootFrame.cloneDeep(), $config.processors, $config.options) + let rootFrames: Frame[]|null + let clonedFrames: Frame[]|null = [] + for (const thread_id of Object.keys(session.rootFrames)) { + clonedFrames[thread_id] = session.rootFrames[thread_id].cloneDeep() + } + $: rootFrames = applyProcessors(clonedFrames, $config.processors, $config.options)
- {#if !rootFrame} + {#if !rootFrames}
All frames were filtered out. @@ -89,7 +93,17 @@
{:else}
- + {#each Object.entries(rootFrames) as [threadId, rootFrame]} + {#if !rootFrame} +
+
+ All frames were filtered out. +
+
+ {:else} + + {/if} + {/each}
{/if}
diff --git a/html_renderer/src/components/TimelineCanvasView.ts b/html_renderer/src/components/TimelineCanvasView.ts index ad792fbe..8fc82c4c 100644 --- a/html_renderer/src/components/TimelineCanvasView.ts +++ b/html_renderer/src/components/TimelineCanvasView.ts @@ -26,11 +26,16 @@ export interface TimelineFrame { className: string filePathShort: string | null } + +interface TimelineFrameMap { + [thread_id: string]: TimelineFrame[] +} + export default class TimelineCanvasView extends CanvasView { zoom: number = 1 // pixels per second startT: number = 0 // seconds yOffset: number = 0 // pixels - frames: TimelineFrame[] = [] + frames: TimelineFrameMap = {} // first index is per thread_id isZoomedIn: boolean = false tooltipContainer: HTMLElement @@ -75,20 +80,30 @@ export default class TimelineCanvasView extends CanvasView { super.destroy() } - _rootFrame: Frame | null = null - maxDepth = 0 - setRootFrame(rootFrame: Frame) { - this._rootFrame = rootFrame - this.frames = [] + _rootFrames: Frame[] | null = null + maxDepth: int[] = [] + maxY: int = 0 + setRootFrames(rootFrames: Frame[]) { + this._rootFrames = rootFrames + this.frames = {} this._frameMaxT = undefined - this.maxDepth = 0 - this._collectFrames(rootFrame, 0) + this.maxDepth = [] + this.maxY = 0 + for (const thread_id of Object.keys(rootFrames)) { + let rootFrame = rootFrames[thread_id] + this._collectFrames(rootFrame, thread_id, 0) + this.maxY += this.maxDepth[thread_id] + 1 + } this.fitContents() this.setNeedsRedraw() } - _collectFrames(frame: Frame, depth: number) { - this.frames.push({ + _collectFrames(frame: Frame, thread_id: string, depth: number) { + if (!this.frames.hasOwnProperty(thread_id)) { + this.frames[thread_id] = [] + this.maxDepth[thread_id] = 0 + } + this.frames[thread_id].push({ frame, depth, isApplicationCode: frame.isApplicationCode, @@ -96,11 +111,11 @@ export default class TimelineCanvasView extends CanvasView { className: frame.className, filePathShort: frame.filePathShort, }) - this.maxDepth = Math.max(this.maxDepth, depth) + this.maxDepth[thread_id] = Math.max(this.maxDepth[thread_id], depth) for (const child of frame.children) { if (child.identifier !== SELF_TIME_FRAME_IDENTIFIER) { // we don't render self time frames - this._collectFrames(child, depth + 1) + this._collectFrames(child, thread_id, depth + 1) } } } @@ -114,7 +129,7 @@ export default class TimelineCanvasView extends CanvasView { name: this.frameName(timelineFrame), time: timelineFrame.frame.time, selfTime: this.frameSelfTime(timelineFrame), - totalTime: this._rootFrame?.time ?? 1e-12, + totalTime: this._rootFrames[timelineFrame.frame.thread_id]?.time ?? 1e-12, location: `${timelineFrame.filePathShort}:${timelineFrame.frame.lineNo}`, locationColor: this.colorForFrame(timelineFrame), } @@ -197,8 +212,12 @@ export default class TimelineCanvasView extends CanvasView { this.drawAxes(ctx) // draw frames - for (const frame of this.frames) { - this.drawFrame(ctx, frame) + let depthOffset = 0 + for (const thread_id of Object.keys(this.frames)) { + for (const frame of this.frames[thread_id]) { + this.drawFrame(ctx, frame, depthOffset) + } + depthOffset += 1 + this.maxDepth[thread_id] } ctx.globalAlpha = 1 @@ -286,8 +305,8 @@ export default class TimelineCanvasView extends CanvasView { } } - drawFrame(ctx: CanvasRenderingContext2D, timelineFrame: TimelineFrame) { - const { x, y, w, h } = this.frameDims(timelineFrame) + drawFrame(ctx: CanvasRenderingContext2D, timelineFrame: TimelineFrame, depthOffset: int) { + const { x, y, w, h } = this.frameDims(timelineFrame, depthOffset) const endX = x + w if (endX < 0 || x > this.width) { // offscreen @@ -340,10 +359,12 @@ export default class TimelineCanvasView extends CanvasView { _assignLibraryOrder() { const librariesTotalTime: Record = {} - for (const timelineFrame of this.frames) { - const frame = timelineFrame.frame - const library = frame.library ?? '' - librariesTotalTime[library] = (librariesTotalTime[library] || 0) + timelineFrame.frame.time + for (const thread_id of Object.keys(this.frames)) { + for (const timelineFrame of this.frames[thread_id]) { + const frame = timelineFrame.frame + const library = frame.library ?? '' + librariesTotalTime[library] = (librariesTotalTime[library] || 0) + timelineFrame.frame.time + } } const libraries = Object.keys(librariesTotalTime) @@ -405,13 +426,17 @@ export default class TimelineCanvasView extends CanvasView { _frameMaxT: number|undefined get frameMaxT() { if (this._frameMaxT === undefined) { - this._frameMaxT = this.frames.reduce((max, frame) => Math.max(max, frame.frame.startTime + frame.frame.time), 0) + this._frameMaxT = 0 + for (const thread_id of Object.keys(this.frames)) { + this._frameMaxT = Math.max(this._frameMaxT, + this.frames[thread_id].reduce((max, frame) => Math.max(max, frame.frame.startTime + frame.frame.time), 0)) + } } return this._frameMaxT } get maxYOffset() { - return Math.max(0, (this.maxDepth+1) * FRAME_PITCH + Y_MARGIN*2 + Y_FRAME_INSET - this.height) + return Math.max(0, (this.maxY+1) * FRAME_PITCH + Y_MARGIN*2 + Y_FRAME_INSET - this.height) } get minZoom() { @@ -450,16 +475,16 @@ export default class TimelineCanvasView extends CanvasView { this.startT = maxStartT } - if (this.yOffset < 0) { - this.yOffset = 0 - } + //if (this.yOffset < 0) { + // this.yOffset = 0 + //} if (this.yOffset > this.maxYOffset) { this.yOffset = this.maxYOffset } } - frameDims(timelineFrame: TimelineFrame): { x: number; y: number; w: number; h: number } { - const y = timelineFrame.depth * FRAME_PITCH + Y_MARGIN + Y_FRAME_INSET - this.yOffset + frameDims(timelineFrame: TimelineFrame, depthOffset: int): { x: number; y: number; w: number; h: number } { + const y = (depthOffset + timelineFrame.depth) * FRAME_PITCH + Y_MARGIN + Y_FRAME_INSET - this.yOffset const h = FRAME_HEIGHT let x = this.xForT(timelineFrame.frame.startTime) const endX = this.xForT(timelineFrame.frame.startTime + timelineFrame.frame.time) @@ -507,10 +532,12 @@ export default class TimelineCanvasView extends CanvasView { } hitTest(loc: {x: number, y: number}): TimelineFrame | null { - for (const frame of this.frames) { - const { x: frameX, y: frameY, w, h } = this.frameDims(frame) - if (loc.x >= frameX && loc.x <= frameX + w && loc.y >= frameY && loc.y <= frameY + h) { - return frame + for (const thread_id of Object.keys(this.frames)) { + for (const frame of this.frames[thread_id]) { + const { x: frameX, y: frameY, w, h } = this.frameDims(frame) + if (loc.x >= frameX && loc.x <= frameX + w && loc.y >= frameY && loc.y <= frameY + h) { + return frame + } } } return null diff --git a/html_renderer/src/components/TimelineView.svelte b/html_renderer/src/components/TimelineView.svelte index f1f4e11e..018007e1 100644 --- a/html_renderer/src/components/TimelineView.svelte +++ b/html_renderer/src/components/TimelineView.svelte @@ -19,8 +19,12 @@ return {processors, options} }) - let rootFrame: Frame|null - $: rootFrame = applyProcessors(session.rootFrame.cloneDeep(), $config.processors, $config.options) + let rootFrames: Frame[]|null + let clonedFrames: Frame[]|null = [] + for (const thread_id of Object.keys(session.rootFrames)) { + clonedFrames[thread_id] = session.rootFrames[thread_id].cloneDeep() + } + $: rootFrames = applyProcessors(clonedFrames, $config.processors, $config.options) let rootElement: HTMLDivElement|null = null let timelineCanvasView: TimelineCanvasView|null = null @@ -32,8 +36,8 @@ timelineCanvasView?.destroy() }) - $: if (rootFrame && timelineCanvasView) { - timelineCanvasView.setRootFrame(rootFrame) + $: if (rootFrames && timelineCanvasView) { + timelineCanvasView.setRootFrames(rootFrames) } diff --git a/html_renderer/src/lib/dataTypes.ts b/html_renderer/src/lib/dataTypes.ts index a00c061c..f617f2f9 100644 --- a/html_renderer/src/lib/dataTypes.ts +++ b/html_renderer/src/lib/dataTypes.ts @@ -1,6 +1,7 @@ export interface SessionData { session: { start_time: number; + thread_start_times: {[thread_id: string] : number}; duration: number; min_interval: number; max_interval: number; @@ -11,10 +12,11 @@ export interface SessionData { sys_path: string; sys_prefixes: string[]; }; - frame_tree: FrameData; + frame_trees: FrameData[]; } export interface FrameData { + thread_id: string; identifier: string; time: number; attributes: {[name: string]: number}; diff --git a/html_renderer/src/lib/model/Frame.ts b/html_renderer/src/lib/model/Frame.ts index 52de5bb7..9782495f 100644 --- a/html_renderer/src/lib/model/Frame.ts +++ b/html_renderer/src/lib/model/Frame.ts @@ -56,7 +56,7 @@ export default class Frame { ) { this.identifier = data.identifier this._identifierParts = this.identifier.split(IDENTIFIER_SEP) - this.startTime = data.startTime ?? 0 + this.startTime = data.startTime ?? context.threadStartTime(data.thread_id) this.time = data.time ?? 0 this.attributes = data.attributes ?? {} this.context = context @@ -233,4 +233,5 @@ export default class Frame { interface FrameContext { shortenPath(path: string): string sysPrefixes: string[] + threadStartTime(thread_id: string): number } diff --git a/html_renderer/src/lib/model/Session.ts b/html_renderer/src/lib/model/Session.ts index 7116e9e9..0c273388 100644 --- a/html_renderer/src/lib/model/Session.ts +++ b/html_renderer/src/lib/model/Session.ts @@ -3,18 +3,20 @@ import Frame from "./Frame"; export default class Session { startTime: number; + threadStartTimes: {[thread_id: string]: number}; duration: number; minInterval: number; maxInterval: number; sampleCount: number; target_description: string; cpuTime: number; - rootFrame: Frame; + rootFrames: {[thread_id: string]: Frame}; sysPath: string; sysPrefixes: string[]; constructor(data: SessionData) { this.startTime = data.session.start_time; + this.threadStartTimes = data.session.thread_start_times; this.duration = data.session.duration; this.minInterval = data.session.min_interval; this.maxInterval = data.session.max_interval; @@ -23,7 +25,10 @@ export default class Session { this.cpuTime = data.session.cpu_time; this.sysPath = data.session.sys_path; this.sysPrefixes = data.session.sys_prefixes - this.rootFrame = new Frame(data.frame_tree, this) + this.rootFrames = {} + for (const thread_id of Object.keys(data.frame_trees)) { + this.rootFrames[thread_id] = new Frame(data.frame_trees[thread_id], this) + } } _shortenPathCache: {[path: string]: string} = {} @@ -47,6 +52,13 @@ export default class Session { this._shortenPathCache[path] = result return result } + + threadStartTime(thread_id: string): number { + if (this.threadStartTimes.hasOwnProperty(thread_id)) { + return this.threadStartTimes[thread_id] + } + return 0 + } } function pathSplit(path: string): string[] { diff --git a/html_renderer/src/lib/model/modelUtil.ts b/html_renderer/src/lib/model/modelUtil.ts index 6cace570..1a8ac64a 100644 --- a/html_renderer/src/lib/model/modelUtil.ts +++ b/html_renderer/src/lib/model/modelUtil.ts @@ -1,13 +1,21 @@ import type Frame from "./Frame" import type { Processor, ProcessorFunction, ProcessorOptions } from "./processors" -export function applyProcessors(rootFrame: Frame, processors: ProcessorFunction[], options: ProcessorOptions) { - let frame: Frame | null = rootFrame - for (const processor of processors) { - frame = processor(frame, options) - if (!frame) { - return null +export function applyProcessors(rootFrames: {[thread_id: string]: Frame} | null, + processors: ProcessorFunction[], options: ProcessorOptions) { + let frames: {[thread_id: string]: Frame} | null = rootFrames + if (frames != null) { + for (const thread_id of Object.keys(rootFrames)) { + let frame = rootFrames[thread_id] + for (const processor of processors) { + frame = processor(frame, options) + if (!frame) { + delete frames[thread_id] + break + } + } + frames[thread_id] = frame } } - return frame + return frames } diff --git a/pyinstrument/frame.py b/pyinstrument/frame.py index 53ecb966..42e68c16 100644 --- a/pyinstrument/frame.py +++ b/pyinstrument/frame.py @@ -54,6 +54,7 @@ class Frame: Object that represents a stack frame in the parsed tree """ + thread_id: str parent: Frame | None group: FrameGroup | None time: float @@ -68,12 +69,14 @@ class Frame: def __init__( self, + thread_id: str, identifier_or_frame_info: str = "", children: Sequence[Frame] | None = None, time: float = 0, context: FrameContext | None = None, ): identifier = frame_info_get_identifier(identifier_or_frame_info) + self.thread_id = thread_id self.identifier = identifier self.parent = None self.time = 0.0 @@ -121,11 +124,6 @@ def set_context(self, context: FrameContext | None): for child in self._children: child.set_context(context) - @staticmethod - def new_subclass_with_frame_info(frame_info: str) -> Frame: - # TODO remove me - return Frame(identifier_or_frame_info=frame_info) - @property def proportion_of_parent(self) -> float: if self.parent: @@ -332,7 +330,8 @@ def self_check(self, recursive: bool = True) -> None: child.self_check(recursive=True) def __repr__(self): - return "Frame(identifier=%s, time=%f, len(children)=%d), group=%r" % ( + return "Frame(thread_id=%s, identifier=%s, time=%f, len(children)=%d), group=%r" % ( + self.thread_id, self.identifier, self.time, len(self.children), @@ -346,6 +345,7 @@ def to_json_str(self): encode_str = typing.cast(Callable[[str], str], json.encoder.encode_basestring) # type: ignore property_decls: list[str] = [] + property_decls.append('"thread_id": %s' % encode_str(self.thread_id)) property_decls.append('"identifier": %s' % encode_str(self.identifier)) property_decls.append('"time": %f' % self.time) property_decls.append('"attributes": %s' % json.dumps(self.attributes)) diff --git a/pyinstrument/frame_ops.py b/pyinstrument/frame_ops.py index 8b9c490d..e26e0f5d 100644 --- a/pyinstrument/frame_ops.py +++ b/pyinstrument/frame_ops.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import List, Sequence, Tuple +from typing import Dict, List, Sequence, Tuple from pyinstrument.frame import ( DUMMY_ROOT_FRAME_IDENTIFIER, @@ -23,54 +23,65 @@ class IdentifierDoesntMatchException(ValueError): def build_frame_tree( frame_records: Sequence[FrameRecordType], context: FrameContext -) -> Frame | None: +) -> Dict[str, Frame | None] | None: if len(frame_records) == 0: return None - root_frame = Frame(identifier_or_frame_info=DUMMY_ROOT_FRAME_IDENTIFIER, context=context) - # put the root frame at the bottom of the stack - frame_stack: list[Frame] = [root_frame] + root_frames: Dict[str, Frame] = {} + frame_stacks: Dict[str, list[Frame]] = {} for frame_info_stack, time in frame_records: stack_depth = 0 - root_frame.record_time_from_frame_info(DUMMY_ROOT_FRAME_IDENTIFIER, time) + + thread_id = frame_info_get_identifier(frame_info_stack[0]) + + if thread_id not in root_frames: + thread_root = Frame( + thread_id=thread_id, + identifier_or_frame_info=DUMMY_ROOT_FRAME_IDENTIFIER, context=context) + root_frames[thread_id] = thread_root + frame_stacks[thread_id] = [thread_root] + + root_frames[thread_id].record_time_from_frame_info(DUMMY_ROOT_FRAME_IDENTIFIER, time) for stack_depth, frame_info in enumerate(frame_info_stack, start=1): frame_identifier = frame_info_get_identifier(frame_info) try: - frame = frame_stack[stack_depth] + frame = frame_stacks[thread_id][stack_depth] if frame.identifier != frame_identifier: # trim any frames after and including this one, and make a new frame - del frame_stack[stack_depth:] + del frame_stacks[thread_id][stack_depth:] raise IdentifierDoesntMatchException() except (IndexError, IdentifierDoesntMatchException): # create a new frame - parent = frame_stack[stack_depth - 1] - frame = Frame(identifier_or_frame_info=frame_info) + parent = frame_stacks[thread_id][stack_depth - 1] + frame = Frame(thread_id=thread_id, identifier_or_frame_info=frame_info) parent.add_child(frame) - assert len(frame_stack) == stack_depth - frame_stack.append(frame) + assert len(frame_stacks[thread_id]) == stack_depth + frame_stacks[thread_id].append(frame) frame.record_time_from_frame_info(frame_info=frame_info, time=time) # trim any extra frames - del frame_stack[stack_depth + 1 :] + del frame_stacks[thread_id][stack_depth + 1:] - final_frame = frame_stack[-1] + final_frame = frame_stacks[thread_id][-1] if not final_frame.is_synthetic_leaf: # record the self-time final_frame.add_child( - Frame(identifier_or_frame_info=SELF_TIME_FRAME_IDENTIFIER, time=time) + Frame(thread_id=thread_id, + identifier_or_frame_info=SELF_TIME_FRAME_IDENTIFIER, time=time) ) - if len(root_frame.children) == 1: - root_frame = root_frame.children[0] - root_frame.remove_from_parent() + for thread_id, root_frame in root_frames.items(): + if len(root_frames[thread_id].children) == 1: + root_frames[thread_id] = root_frame.children[0] + root_frames[thread_id].remove_from_parent() - return root_frame + return root_frames def delete_frame_from_tree( diff --git a/pyinstrument/profiler.py b/pyinstrument/profiler.py index f326a13f..74db4a28 100644 --- a/pyinstrument/profiler.py +++ b/pyinstrument/profiler.py @@ -7,13 +7,15 @@ import types from pathlib import Path from time import process_time -from typing import IO, Any +from typing import IO, Any, Dict from pyinstrument import renderers from pyinstrument.frame import AWAIT_FRAME_IDENTIFIER, OUT_OF_CONTEXT_FRAME_IDENTIFIER from pyinstrument.renderers.console import FlatTimeMode from pyinstrument.session import Session -from pyinstrument.stack_sampler import AsyncState, StackSampler, build_call_stack, get_stack_sampler +from pyinstrument.stack_sampler import (AsyncState, StackSampler, + StackSamplerSubscriberTarget, build_call_stack, + get_stack_sampler,) from pyinstrument.typing import LiteralStr from pyinstrument.util import file_supports_color, file_supports_unicode @@ -22,6 +24,8 @@ class ActiveProfilerSession: frame_records: list[tuple[list[str], float]] + thread_start_times: Dict[str, float] + first_start_time: float def __init__( self, @@ -30,13 +34,21 @@ def __init__( start_call_stack: list[str], target_description: str, interval: float, + child_threads: bool ) -> None: self.start_time = start_time + self.thread_start_times = {} self.start_process_time = start_process_time self.start_call_stack = start_call_stack self.frame_records = [] self.target_description = target_description - self.interval = interval + self.interval = interval, + self.child_threads = child_threads + + def record_thread_start(self, thread_id: str, time: float) -> None: + if not self.thread_start_times: + self.first_start_time = time + self.thread_start_times[thread_id] = time - self.first_start_time AsyncMode = LiteralStr["enabled", "disabled", "strict"] @@ -52,12 +64,15 @@ class Profiler: _interval: float _async_mode: AsyncMode use_timing_thread: bool | None + child_threads: bool | None + _subscriber_target: StackSamplerSubscriberTarget def __init__( self, interval: float = 0.001, async_mode: AsyncMode = "enabled", use_timing_thread: bool | None = None, + child_threads: bool | None = None ): """ Note the profiling will not start until :func:`start` is called. @@ -73,6 +88,11 @@ def __init__( self._active_session = None self._async_mode = async_mode self.use_timing_thread = use_timing_thread + self.child_threads = child_threads + self._subscriber_target = StackSamplerSubscriberTarget( + call_stack=self._sampler_saw_call_stack, + event=self._sampler_state_changed + ) @property def interval(self) -> float: @@ -152,14 +172,16 @@ def start( start_call_stack=build_call_stack(caller_frame, "initial", None), target_description=target_description, interval=self.interval, + child_threads=self.child_threads if self.child_threads is not None else False ) use_async_context = self.async_mode != "disabled" get_stack_sampler().subscribe( - self._sampler_saw_call_stack, + self._subscriber_target, desired_interval=self.interval, use_async_context=use_async_context, use_timing_thread=self.use_timing_thread, + child_threads=self.child_threads ) except: self._active_session = None @@ -176,7 +198,7 @@ def stop(self) -> Session: raise RuntimeError("This profiler is not currently running.") try: - get_stack_sampler().unsubscribe(self._sampler_saw_call_stack) + get_stack_sampler().unsubscribe(self._subscriber_target) except StackSampler.SubscriberNotFound: raise RuntimeError( "Failed to stop profiling. Make sure that you start/stop profiling on the same thread." @@ -190,6 +212,7 @@ def stop(self) -> Session: session = Session( frame_records=active_session.frame_records, start_time=active_session.start_time, + thread_start_times=active_session.thread_start_times, duration=time.time() - active_session.start_time, min_interval=active_session.interval, max_interval=active_session.interval, @@ -246,6 +269,19 @@ def __enter__(self): def __exit__(self, *args: Any): self.stop() + # pylint: disable=W0613 + def _sampler_state_changed( + self, + event: str, + thread_id: str, + time: float): + if not self._active_session: + raise RuntimeError( + "Received a state change without an active session. Please file an issue on pyinstrument Github describing how you made this happen!" + ) + if event == 'thread_start': + self._active_session.record_thread_start(thread_id, time) + # pylint: disable=W0613 def _sampler_saw_call_stack( self, diff --git a/pyinstrument/renderers/base.py b/pyinstrument/renderers/base.py index 53b5b47a..5ec5a2d6 100644 --- a/pyinstrument/renderers/base.py +++ b/pyinstrument/renderers/base.py @@ -1,7 +1,7 @@ from __future__ import annotations import contextlib -from typing import Any, List +from typing import Dict, Any, List from pyinstrument import processors from pyinstrument.frame import Frame @@ -108,11 +108,14 @@ def default_processors(self) -> ProcessorList: """ raise NotImplementedError() - def preprocess(self, root_frame: Frame | None) -> Frame | None: - frame = root_frame - for processor in self.processors: - frame = processor(frame, options=self.processor_options) - return frame + def preprocess(self, root_frames: Dict[str, Frame | None] | None) -> Dict[str, Frame | None] | None: + frames = root_frames + if frames is not None: + for thread_id, frame in frames.items(): + for processor in self.processors: + frame = processor(frame, options=self.processor_options) + frames[thread_id] = frame + return frames def render(self, session: Session) -> str: """ diff --git a/pyinstrument/renderers/console.py b/pyinstrument/renderers/console.py index 11ecc40c..0583bb89 100644 --- a/pyinstrument/renderers/console.py +++ b/pyinstrument/renderers/console.py @@ -63,18 +63,19 @@ def __init__( def render(self, session: Session) -> str: result = self.render_preamble(session) - frame = self.preprocess(session.root_frame()) + frames = self.preprocess(session.root_frames()) indent = ". " if self.short_mode else "" - if frame is None: + if frames is None: result += f"{indent}No samples were recorded.\n" else: - self.root_frame = frame + self.root_frames = frames - if self.flat: - result += self.render_frame_flat(self.root_frame, indent=indent) - else: - result += self.render_frame(self.root_frame, indent=indent, child_indent=indent) + for thread_id, root_frame in frames.items(): + if self.flat: + result += self.render_frame_flat(root_frame, indent=indent) + else: + result += self.render_frame(root_frame, indent=indent, child_indent=indent) result += f"{indent}\n" @@ -126,7 +127,7 @@ def should_render_frame_in_group(self, frame: Frame) -> bool: assert frame.group return ( frame.group.root == frame - or frame.total_self_time > 0.2 * self.root_frame.time + or frame.total_self_time > 0.2 * self.root_frames[frame.thread_id].time or frame in frame.group.exit_frames ) @@ -222,7 +223,7 @@ def walk(frame: Frame): if not self.show_all: # remove nodes that represent less than 0.1% of the total time id_time_pairs = [ - pair for pair in id_time_pairs if pair[1] / self.root_frame.time > 0.001 + pair for pair in id_time_pairs if pair[1] / self.root_frames[frame.thread_id].time > 0.001 ] result = "" @@ -235,7 +236,7 @@ def walk(frame: Frame): def frame_description(self, frame: Frame, *, override_time: float | None = None) -> str: time = override_time if override_time is not None else frame.time - time_color = self._ansi_color_for_time(time) + time_color = self._ansi_color_for_time(frame.thread_id, time) if self.time == "percent_of_total": time_str = f"{self.frame_proportion_of_total_time(time) * 100:.1f}%" @@ -260,13 +261,13 @@ def frame_description(self, frame: Frame, *, override_time: float | None = None) return f"{value_str} {function_str} {code_position_str}" - def frame_proportion_of_total_time(self, time: float) -> float: - if self.root_frame.time == 0: + def frame_proportion_of_total_time(self, thread_id: str, time: float) -> float: + if self.root_frames[thread_id].time == 0: return 1 - return time / self.root_frame.time + return time / self.root_frames[thread_id].time - def _ansi_color_for_time(self, time: float) -> str: - proportion_of_total = self.frame_proportion_of_total_time(time) + def _ansi_color_for_time(self, thread_id: str, time: float) -> str: + proportion_of_total = self.frame_proportion_of_total_time(thread_id, time) if proportion_of_total > 0.6: return self.colors.red diff --git a/pyinstrument/renderers/html.py b/pyinstrument/renderers/html.py index aa3a845b..4088c629 100644 --- a/pyinstrument/renderers/html.py +++ b/pyinstrument/renderers/html.py @@ -6,6 +6,7 @@ import urllib.parse import warnings import webbrowser +from typing import Callable, cast from pathlib import Path from pyinstrument.renderers.base import FrameRenderer, ProcessorList, Renderer @@ -119,9 +120,22 @@ def default_processors(self) -> ProcessorList: return [] def render(self, session: Session) -> str: + encode_str = cast(Callable[[str], str], json.encoder.encode_basestring) # type: ignore session_json = session.to_json(include_frame_records=False) session_json_str = json.dumps(session_json) - root_frame = session.root_frame() - root_frame = self.preprocess(root_frame) - frame_tree_json_str = root_frame.to_json_str() if root_frame else "null" - return '{"session": %s, "frame_tree": %s}' % (session_json_str, frame_tree_json_str) + root_frames = session.root_frames() + root_frames = self.preprocess(root_frames) + if root_frames is not None: + frame_trees_json_str = '' + keys = root_frames.keys() + key_count = 0 + for thread_id in keys: + root_frame = root_frames[thread_id] + frame_tree_json_str = root_frame.to_json_str() if root_frame else "null" + frame_trees_json_str += ' %s : %s%s ' % (encode_str(thread_id), frame_tree_json_str, + ',' if key_count < len(keys) - 1 else '') + key_count += 1 + return '{"session": %s, "frame_trees": {%s}}' % (session_json_str, frame_trees_json_str) + else: + return '{"session": %s, "frame_trees": %s}' % (session_json_str, "null") + diff --git a/pyinstrument/renderers/html_resources/app.js b/pyinstrument/renderers/html_resources/app.js index 07e51fd8..d53a8ee9 100644 --- a/pyinstrument/renderers/html_resources/app.js +++ b/pyinstrument/renderers/html_resources/app.js @@ -1,14 +1,14 @@ -var pyinstrumentHTMLRenderer=function(){"use strict";var is=Object.defineProperty;var ns=(F,ve,Pe)=>ve in F?is(F,ve,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):F[ve]=Pe;var A=(F,ve,Pe)=>ns(F,typeof ve!="symbol"?ve+"":ve,Pe);function F(){}function ve(i){return i()}function Pe(){return Object.create(null)}function oe(i){i.forEach(ve)}function pt(i){return typeof i=="function"}function re(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function ki(i){return Object.keys(i).length===0}function St(i,...e){if(i==null){for(const n of e)n(void 0);return F}const t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ge(i,e,t){i.$$.on_destroy.push(St(e,t))}function Ci(i,e,t){return i.set(t),e}function u(i,e){i.appendChild(e)}function S(i,e,t){i.insertBefore(e,t||null)}function L(i){i.parentNode&&i.parentNode.removeChild(i)}function h(i){return document.createElement(i)}function V(i){return document.createElementNS("http://www.w3.org/2000/svg",i)}function I(i){return document.createTextNode(i)}function b(){return I(" ")}function Mi(){return I("")}function N(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function vt(i){return function(e){return e.preventDefault(),i.call(this,e)}}function gt(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function a(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function _t(i){let e;return{p(...t){e=t,e.forEach(n=>i.push(n))},r(){e.forEach(t=>i.splice(i.indexOf(t),1))}}}function Fi(i){return Array.from(i.childNodes)}function _e(i,e){e=""+e,i.data!==e&&(i.data=e)}function ae(i,e){i.value=e??""}function j(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}function Ee(i,e,t){i.classList.toggle(e,!!t)}function Pi(i,e,{bubbles:t=!1,cancelable:n=!1}={}){return new CustomEvent(i,{detail:e,bubbles:t,cancelable:n})}class Ri{constructor(e=!1){A(this,"is_svg",!1);A(this,"e");A(this,"n");A(this,"t");A(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,n=null){this.e||(this.is_svg?this.e=V(t.nodeName):this.e=h(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(n)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{const s=i.$$.callbacks[e];if(s){const l=Pi(e,t,{cancelable:n});return s.slice().forEach(r=>{r.call(i,l)}),!l.defaultPrevented}return!0}}const Se=[],ke=[];let De=[];const Dt=[],Si=Promise.resolve();let yt=!1;function Di(){yt||(yt=!0,Si.then(Ht))}function Tt(i){De.push(i)}const At=new Set;let He=0;function Ht(){if(He!==0)return;const i=Ye;do{try{for(;Hei.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),De=e}const nt=new Set;let Re;function Oe(){Re={r:0,c:[],p:Re}}function Ve(){Re.r||oe(Re.c),Re=Re.p}function D(i,e){i&&i.i&&(nt.delete(i),i.i(e))}function x(i,e,t,n){if(i&&i.o){if(nt.has(i))return;nt.add(i),Re.c.push(()=>{nt.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}function Ot(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function Vi(i,e){x(i,1,1,()=>{e.delete(i.key)})}function Ni(i,e,t,n,s,l,r,o,c,d,v,p){let m=i.length,f=l.length,g=m;const w={};for(;g--;)w[i[g].key]=g;const E=[],C=new Map,y=new Map,k=[];for(g=f;g--;){const M=p(s,l,g),_=t(M);let T=r.get(_);T?k.push(()=>T.p(M,e)):(T=d(_,M),T.c()),C.set(_,E[g]=T),_ in w&&y.set(_,Math.abs(g-w[_]))}const H=new Set,W=new Set;function P(M){D(M,1),M.m(o,v),r.set(M.key,M),v=M.first,f--}for(;m&&f;){const M=E[f-1],_=i[m-1],T=M.key,R=_.key;M===_?(v=M.first,m--,f--):C.has(R)?!r.has(T)||H.has(T)?P(M):W.has(R)?m--:y.get(T)>y.get(R)?(W.add(T),P(M)):(H.add(R),m--):(c(_,r),m--)}for(;m--;){const M=i[m];C.has(M.key)||c(M,r)}for(;f;)P(E[f-1]);return oe(k),E}function we(i){i&&i.c()}function ce(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),Tt(()=>{const l=i.$$.on_mount.map(ve).filter(pt);i.$$.on_destroy?i.$$.on_destroy.push(...l):oe(l),i.$$.on_mount=[]}),s.forEach(Tt)}function ue(i,e){const t=i.$$;t.fragment!==null&&(Oi(t.after_update),oe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function xi(i,e){i.$$.dirty[0]===-1&&(Se.push(i),Di(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const g=f.length?f[0]:m;return d.ctx&&s(d.ctx[p],d.ctx[p]=g)&&(!d.skip_bound&&d.bound[p]&&d.bound[p](g),v&&xi(i,p)),m}):[],d.update(),v=!0,oe(d.before_update),d.fragment=n?n(d.ctx):!1,e.target){if(e.hydrate){const p=Fi(e.target);d.fragment&&d.fragment.l(p),p.forEach(L)}else d.fragment&&d.fragment.c();e.intro&&D(i.$$.fragment),ce(i,e.target,e.anchor),Ht()}Xe(c)}class fe{constructor(){A(this,"$$");A(this,"$$set")}$destroy(){ue(this,1),this.$destroy=F}$on(e,t){if(!pt(t))return F;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!ki(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const $i="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add($i);function Bi(i){let e,t;return{c(){e=V("svg"),t=V("path"),a(t,"fill-rule","evenodd"),a(t,"clip-rule","evenodd"),a(t,"d","M5.11634 0.889422C4.86506 -0.296474 3.17237 -0.296474 2.92109 0.889422C2.78291 1.54158 2.10994 1.93011 1.47607 1.72371C0.323418 1.34837 -0.522932 2.81429 0.378448 3.62484C0.87414 4.07059 0.87414 4.84767 0.378448 5.29341C-0.522931 6.10397 0.323418 7.56989 1.47607 7.19455C2.10994 6.98814 2.78291 7.37668 2.92109 8.02883C3.17237 9.21473 4.86506 9.21473 5.11634 8.02883C5.25452 7.37668 5.92749 6.98814 6.56136 7.19455C7.71401 7.56989 8.56036 6.10397 7.65898 5.29341C7.16329 4.84767 7.16329 4.07059 7.65898 3.62484C8.56036 2.81429 7.71401 1.34837 6.56136 1.72371C5.92749 1.93011 5.25452 1.54158 5.11634 0.889422ZM4.01883 6.33408C5.05436 6.33408 5.89383 5.49462 5.89383 4.45908C5.89383 3.42355 5.05436 2.58408 4.01883 2.58408C2.98329 2.58408 2.14383 3.42355 2.14383 4.45908C2.14383 5.49462 2.98329 6.33408 4.01883 6.33408Z"),a(t,"fill","currentColor"),a(e,"width","9"),a(e,"height","9"),a(e,"viewBox","0 0 9 9"),a(e,"fill","none"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(n,s){S(n,e,s),u(e,t)},p:F,i:F,o:F,d(n){n&&L(e)}}}class zi extends fe{constructor(e){super(),de(this,e,null,Bi,re,{})}}function Wi(i){let e,t,n,s,l,r,o,c,d,v,p,m,f,g,w,E,C;return{c(){e=V("svg"),t=V("g"),n=V("path"),s=V("path"),l=V("defs"),r=V("filter"),o=V("feFlood"),c=V("feBlend"),d=V("feGaussianBlur"),v=V("linearGradient"),p=V("stop"),m=V("stop"),f=V("stop"),g=V("linearGradient"),w=V("stop"),E=V("stop"),C=V("stop"),a(n,"fill-rule","evenodd"),a(n,"clip-rule","evenodd"),a(n,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),a(n,"fill","url(#paint0_linear_67_262)"),a(t,"opacity","0.5"),a(t,"filter","url(#filter0_f_67_262)"),a(s,"fill-rule","evenodd"),a(s,"clip-rule","evenodd"),a(s,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),a(s,"fill","url(#paint1_linear_67_262)"),a(o,"flood-opacity","0"),a(o,"result","BackgroundImageFix"),a(c,"mode","normal"),a(c,"in","SourceGraphic"),a(c,"in2","BackgroundImageFix"),a(c,"result","shape"),a(d,"stdDeviation","3.39785"),a(d,"result","effect1_foregroundBlur_67_262"),a(r,"id","filter0_f_67_262"),a(r,"x","3.2043"),a(r,"y","2.2043"),a(r,"width","36.0914"),a(r,"height","41.0914"),a(r,"filterUnits","userSpaceOnUse"),a(r,"color-interpolation-filters","sRGB"),a(p,"stop-color","#FFAA00"),a(m,"offset","0.514478"),a(m,"stop-color","#FFEB00"),a(f,"offset","1"),a(f,"stop-color","#98FF05"),a(v,"id","paint0_linear_67_262"),a(v,"x1","7.3769"),a(v,"y1","18.4566"),a(v,"x2","20.6583"),a(v,"y2","33.1038"),a(v,"gradientUnits","userSpaceOnUse"),a(w,"stop-color","#FFC834"),a(E,"offset","0.514478"),a(E,"stop-color","#FAF534"),a(C,"offset","1"),a(C,"stop-color","#B8FF38"),a(g,"id","paint1_linear_67_262"),a(g,"x1","7.3769"),a(g,"y1","18.4566"),a(g,"x2","20.6583"),a(g,"y2","33.1038"),a(g,"gradientUnits","userSpaceOnUse"),a(e,"width","44"),a(e,"height","44"),a(e,"viewBox","0 0 44 44"),a(e,"fill","none"),a(e,"xmlns","http://www.w3.org/2000/svg")},m(y,k){S(y,e,k),u(e,t),u(t,n),u(e,s),u(e,l),u(l,r),u(r,o),u(r,c),u(r,d),u(l,v),u(v,p),u(v,m),u(v,f),u(l,g),u(g,w),u(g,E),u(g,C)},p:F,i:F,o:F,d(y){y&&L(e)}}}class qi extends fe{constructor(e){super(),de(this,e,null,Wi,re,{})}}const Ne=[];function Ui(i,e){return{subscribe:st(i,e).subscribe}}function st(i,e=F){let t;const n=new Set;function s(o){if(re(i,o)&&(i=o,t)){const c=!Ne.length;for(const d of n)d[1](),Ne.push(d,i);if(c){for(let d=0;d{n.delete(d),n.size===0&&t&&(t(),t=null)}}return{set:s,update:l,subscribe:r}}function Vt(i,e,t){const n=!Array.isArray(i),s=n?[i]:i;if(!s.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const l=e.length<2;return Ui(t,(r,o)=>{let c=!1;const d=[];let v=0,p=F;const m=()=>{if(v)return;p();const g=e(n?d[0]:d,r,o);l?r(g):p=pt(g)?g:F},f=s.map((g,w)=>St(g,E=>{d[w]=E,v&=~(1<{v|=1<console.error(`Error when writing value from persisted store "${i}" to ${m}`,P),w=(c=t==null?void 0:t.onParseError)!=null?c:(P,M)=>console.error(`Error when parsing ${P?'"'+P+'"':"value"} from persisted store "${i}"`,M),E=(d=t==null?void 0:t.beforeRead)!=null?d:P=>P,C=(v=t==null?void 0:t.beforeWrite)!=null?v:P=>P,y=typeof window<"u"&&typeof document<"u",k=y?Yi(m):null;function H(P,M){const _=C(M);try{k==null||k.setItem(P,p.stringify(_))}catch(T){g(T)}}function W(){function P(R){try{return p.parse(R)}catch(B){w(R,B)}}const M=k==null?void 0:k.getItem(i);if(M==null)return e;const _=P(M);return _==null?e:E(_)}if(!Et[m][i]){const P=W(),M=st(P,R=>{if(y&&m=="local"&&f){const B=J=>{if(J.key===i&&J.newValue){let $;try{$=p.parse(J.newValue)}catch(ee){w(J.newValue,ee);return}const Le=E($);R(Le)}};return window.addEventListener("storage",B),()=>window.removeEventListener("storage",B)}}),{subscribe:_,set:T}=M;Et[m][i]={set(R){T(R),H(i,R)},update(R){return M.update(B=>{const J=R(B);return H(i,J),J})},reset(){this.set(e)},subscribe:_}}return Et[m][i]}function Nt(){return{collapseMode:"non-application",collapseCustomHide:"",collapseCustomShow:"",removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:.001,timeFormat:"absolute"}}const Z=kt("pyinstrument:viewOptionsCallStack",Nt(),{syncTabs:!0,beforeRead(i){return{...Nt(),...i}}}),Ge=kt("pyinstrument:viewOptions",{viewMode:"call-stack"},{syncTabs:!1}),je=kt("pyinstrument:viewOptionsTimeline",{removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:1e-4},{syncTabs:!0});class Xi extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function Gi(i,e){const t=e*(i.length-1),n=Math.floor(t),s=Math.ceil(t),l=i[n],r=i[s],o=t-n;return Zi(o,{to:[l,r]})}function ji(i,e,t){return i===1/0?(console.warn("clamp: value is Infinity, returning `max`",i),t):i===-1/0?(console.warn("clamp: value is -Infinity, returning `min`",i),e):Number.isFinite(i)?it?t:i:(console.warn("clamp: value isn't finite, returning `min`",i),e)}function xe(i,e){const{from:t=[0,1],to:n=[0,1]}=e,s=e.clamp||!1;let l=(i-t[0])/(t[1]-t[0])*(n[1]-n[0])+n[0];return s&&(l=ji(l,Math.min(n[0],n[1]),Math.max(n[0],n[1]))),l}function Zi(i,e){return`rgb( - ${xe(i,{from:e.from,to:[e.to[0][0],e.to[1][0]],clamp:e.clamp})}, - ${xe(i,{from:e.from,to:[e.to[0][1],e.to[1][1]],clamp:e.clamp})}, - ${xe(i,{from:e.from,to:[e.to[0][2],e.to[1][2]],clamp:e.clamp})} - )`}function Ki(i){if(i.substr(0,1)=="#"){var e=(i.length-1)/3,t=[17,1,.062272][e-1];return[Math.round(parseInt(i.substr(1,e),16)*t),Math.round(parseInt(i.substr(1+e,e),16)*t),Math.round(parseInt(i.substr(1+2*e,e),16)*t)]}else return i.split("(")[1].split(")")[0].split(",").map(n=>+n)}function Qi(i,e,t={}){const{ignore:n=[],capture:s=!0}=t,l=window;if(!l)return()=>{};let r=!0,o=!1;const c=f=>n.some(g=>typeof g=="string"?Array.from(document.querySelectorAll(g)).some(w=>w===f.target||f.composedPath().includes(w)):g&&(f.target===g||f.composedPath().includes(g))),d=f=>{if(!(!i||i===f.target||f.composedPath().includes(i))){if(f.detail===0&&(r=!c(f)),!r){r=!0;return}e(f)}},v=f=>{o||(o=!0,setTimeout(()=>{o=!1},0),d(f))},p=f=>{r=!c(f)&&!!(i&&!f.composedPath().includes(i))};return l.addEventListener("click",v,{passive:!0,capture:s}),l.addEventListener("pointerdown",p,{passive:!0}),()=>{l.removeEventListener("click",v,{capture:s}),l.removeEventListener("pointerdown",p)}}function Ji(i){const e=document.createElement("div");return e.appendChild(document.createTextNode(i)),e.innerHTML}function Ct(i){return Ji(i).replace(/(\/|\\)/g,t=>`${t}`)}function en(i,e){if(i.length==0)return null;let t=i[0],n=e(t);for(const s of i){const l=e(s);l>n&&(t=s,n=l)}return t}function ot(){return Math.random().toString(36).substring(2)}function tn(i){let e,t,n,s,l,r,o,c,d,v,p,m,f,g,w,E,C,y,k,H,W,P,M,_,T,R,B,J,$,Le,ee,Q,Y,Ce,q,Qe,Je,le,U,et,te,he,me,be,pe,Te,tt,Ae,K,Be,Me,it,z,O,X,fi,at,hi,mi,ze,Fe,pi,We,ct,vi,gi,ye,_i,wi,qe,ut,bi,Ue,dt,ft,ie,yi,Ti,ht,mt,ne,Ai,Rt,It,Lt,Ei;return Rt=_t(i[5][0]),It=_t(i[5][1]),{c(){e=h("div"),t=h("div"),n=h("div"),n.textContent="Collapse frames",s=b(),l=h("div"),r=h("div"),o=h("input"),c=b(),d=h("label"),v=I("Library code"),p=b(),m=h("div"),m.textContent="Code run from the Python stdlib, a virtualenv, or a conda env will be collapsed.",f=b(),g=h("div"),w=h("input"),E=b(),C=h("label"),y=I("Custom"),k=b(),H=h("div"),W=I(`Regex on the source file path. - `),P=h("div"),M=h("label"),M.textContent="Show",_=b(),T=h("input"),R=b(),B=h("label"),B.textContent="Hide",J=b(),$=h("input"),Le=I(` - If neither match, the library code rule is used.`),ee=b(),Q=h("div"),Y=h("input"),Ce=b(),q=h("label"),Qe=I("Disabled"),Je=b(),le=h("div"),U=h("div"),U.textContent="Remove frames",et=b(),te=h("div"),he=h("div"),me=h("input"),be=b(),pe=h("label"),Te=I("importlib machinery"),tt=b(),Ae=h("div"),K=h("input"),Be=b(),Me=h("label"),it=I("Frames declaring __traceback_hide__"),z=b(),O=h("div"),X=h("input"),fi=b(),at=h("label"),hi=I("pyinstrument frames"),mi=b(),ze=h("div"),Fe=h("input"),pi=b(),We=h("span"),ct=h("label"),vi=I("Frames with durations less than"),gi=b(),ye=h("input"),_i=I(` - % of the total time`),wi=b(),qe=h("div"),ut=h("div"),ut.textContent="Time format",bi=b(),Ue=h("div"),dt=h("div"),ft=h("label"),ie=h("input"),yi=I(` - Absolute time in seconds`),Ti=b(),ht=h("div"),mt=h("label"),ne=h("input"),Ai=I(` - Percentage of the total run time`),a(n,"class","name svelte-1pecl4m"),a(o,"id",i[1]+"collapseModeAll"),a(o,"type","radio"),o.__value="non-application",ae(o,o.__value),a(o,"class","svelte-1pecl4m"),a(d,"for",i[1]+"collapseModeAll"),a(m,"class","description svelte-1pecl4m"),a(r,"class","option svelte-1pecl4m"),a(w,"id",i[1]+"collapseModeCustom"),a(w,"type","radio"),w.__value="custom",ae(w,w.__value),a(w,"class","svelte-1pecl4m"),a(C,"for",i[1]+"collapseModeCustom"),a(M,"for","collapseCustomShow"),a(M,"class","svelte-1pecl4m"),a(T,"id","collapseCustomShow"),a(T,"type","text"),a(T,"placeholder","myproject"),a(T,"spellcheck","false"),a(T,"autocapitalize","off"),a(T,"autocomplete","off"),a(T,"autocorrect","off"),a(T,"class","svelte-1pecl4m"),a(B,"for","collapseCustomHide"),a(B,"class","svelte-1pecl4m"),a($,"id","collapseCustomHide"),a($,"type","text"),a($,"placeholder",".*/lib/.*"),a($,"spellcheck","false"),a($,"autocapitalize","off"),a($,"autocomplete","off"),a($,"autocorrect","off"),a($,"class","svelte-1pecl4m"),a(P,"class","mini-input-grid svelte-1pecl4m"),a(H,"class","description svelte-1pecl4m"),a(g,"class","option svelte-1pecl4m"),a(Y,"id",i[1]+"collapseModeDisabled"),a(Y,"type","radio"),Y.__value="disabled",ae(Y,Y.__value),a(Y,"class","svelte-1pecl4m"),a(q,"for",i[1]+"collapseModeDisabled"),a(Q,"class","option svelte-1pecl4m"),a(l,"class","body"),a(t,"class","option-group svelte-1pecl4m"),a(U,"class","name svelte-1pecl4m"),a(me,"id",i[1]+"removeImportlib"),a(me,"type","checkbox"),a(me,"class","svelte-1pecl4m"),a(pe,"for",i[1]+"removeImportlib"),a(he,"class","option svelte-1pecl4m"),a(K,"id",i[1]+"removeTracebackHide"),a(K,"type","checkbox"),a(K,"class","svelte-1pecl4m"),a(Me,"for",i[1]+"removeTracebackHide"),a(Ae,"class","option svelte-1pecl4m"),a(X,"id",i[1]+"removePyinstrument"),a(X,"type","checkbox"),a(X,"class","svelte-1pecl4m"),a(at,"for",i[1]+"removePyinstrument"),a(O,"class","option svelte-1pecl4m"),a(Fe,"id",i[1]+"removeIrrelevant"),a(Fe,"type","checkbox"),a(Fe,"class","svelte-1pecl4m"),a(ct,"for",i[1]+"removeIrrelevant"),a(ye,"type","number"),ye.value=i[2](),a(ye,"min","0"),a(ye,"max","99"),a(ye,"step","0.01"),j(ye,"width","4em"),a(ye,"class","svelte-1pecl4m"),a(ze,"class","option svelte-1pecl4m"),a(te,"class","body"),a(le,"class","option-group svelte-1pecl4m"),a(ut,"class","name svelte-1pecl4m"),a(ie,"type","radio"),ie.__value="absolute",ae(ie,ie.__value),a(ie,"class","svelte-1pecl4m"),a(dt,"class","option svelte-1pecl4m"),a(ne,"type","radio"),ne.__value="proportion",ae(ne,ne.__value),a(ne,"class","svelte-1pecl4m"),a(ht,"class","option svelte-1pecl4m"),a(Ue,"class","body"),a(qe,"class","option-group svelte-1pecl4m"),a(e,"class","view-options-call-stack svelte-1pecl4m"),Rt.p(ie,ne),It.p(o,w,Y)},m(G,se){S(G,e,se),u(e,t),u(t,n),u(t,s),u(t,l),u(l,r),u(r,o),o.checked=o.__value===i[0].collapseMode,u(r,c),u(r,d),u(d,v),u(r,p),u(r,m),u(l,f),u(l,g),u(g,w),w.checked=w.__value===i[0].collapseMode,u(g,E),u(g,C),u(C,y),u(g,k),u(g,H),u(H,W),u(H,P),u(P,M),u(P,_),u(P,T),ae(T,i[0].collapseCustomShow),u(P,R),u(P,B),u(P,J),u(P,$),ae($,i[0].collapseCustomHide),u(H,Le),u(l,ee),u(l,Q),u(Q,Y),Y.checked=Y.__value===i[0].collapseMode,u(Q,Ce),u(Q,q),u(q,Qe),u(e,Je),u(e,le),u(le,U),u(le,et),u(le,te),u(te,he),u(he,me),me.checked=i[0].removeImportlib,u(he,be),u(he,pe),u(pe,Te),u(te,tt),u(te,Ae),u(Ae,K),K.checked=i[0].removeTracebackHide,u(Ae,Be),u(Ae,Me),u(Me,it),u(te,z),u(te,O),u(O,X),X.checked=i[0].removePyinstrument,u(O,fi),u(O,at),u(at,hi),u(te,mi),u(te,ze),u(ze,Fe),Fe.checked=i[0].removeIrrelevant,u(ze,pi),u(ze,We),u(We,ct),u(ct,vi),u(We,gi),u(We,ye),u(We,_i),u(e,wi),u(e,qe),u(qe,ut),u(qe,bi),u(qe,Ue),u(Ue,dt),u(dt,ft),u(ft,ie),ie.checked=ie.__value===i[0].timeFormat,u(ft,yi),u(Ue,Ti),u(Ue,ht),u(ht,mt),u(mt,ne),ne.checked=ne.__value===i[0].timeFormat,u(mt,Ai),Lt||(Ei=[N(o,"change",i[4]),N(w,"change",i[6]),N(T,"input",i[7]),N($,"input",i[8]),N(Y,"change",i[9]),N(me,"change",i[10]),N(K,"change",i[11]),N(X,"change",i[12]),N(Fe,"change",i[13]),N(ye,"input",i[3]),N(ie,"change",i[14]),N(ne,"change",i[15])],Lt=!0)},p(G,[se]){se&1&&(o.checked=o.__value===G[0].collapseMode),se&1&&(w.checked=w.__value===G[0].collapseMode),se&1&&T.value!==G[0].collapseCustomShow&&ae(T,G[0].collapseCustomShow),se&1&&$.value!==G[0].collapseCustomHide&&ae($,G[0].collapseCustomHide),se&1&&(Y.checked=Y.__value===G[0].collapseMode),se&1&&(me.checked=G[0].removeImportlib),se&1&&(K.checked=G[0].removeTracebackHide),se&1&&(X.checked=G[0].removePyinstrument),se&1&&(Fe.checked=G[0].removeIrrelevant),se&1&&(ie.checked=ie.__value===G[0].timeFormat),se&1&&(ne.checked=ne.__value===G[0].timeFormat)},i:F,o:F,d(G){G&&L(e),Rt.r(),It.r(),Lt=!1,oe(Ei)}}}function nn(i,e,t){let n;ge(i,Z,k=>t(0,n=k));const s=ot();function l(){return(n.removeIrrelevantThreshold*100).toLocaleString(void 0,{maximumFractionDigits:4})}function r(k){Ci(Z,n.removeIrrelevantThreshold=k.currentTarget.valueAsNumber/100,n)}const o=[[],[]];function c(){n.collapseMode=this.__value,Z.set(n)}function d(){n.collapseMode=this.__value,Z.set(n)}function v(){n.collapseCustomShow=this.value,Z.set(n)}function p(){n.collapseCustomHide=this.value,Z.set(n)}function m(){n.collapseMode=this.__value,Z.set(n)}function f(){n.removeImportlib=this.checked,Z.set(n)}function g(){n.removeTracebackHide=this.checked,Z.set(n)}function w(){n.removePyinstrument=this.checked,Z.set(n)}function E(){n.removeIrrelevant=this.checked,Z.set(n)}function C(){n.timeFormat=this.__value,Z.set(n)}function y(){n.timeFormat=this.__value,Z.set(n)}return[n,s,l,r,c,o,d,v,p,m,f,g,w,E,C,y]}class sn extends fe{constructor(e){super(),de(this,e,nn,tn,re,{})}}function on(i){let e,t,n,s,l,r,o,c,d,v,p,m,f,g,w,E,C,y,k,H,W,P,M,_;return{c(){e=h("div"),t=h("div"),n=h("div"),n.textContent="Remove frames",s=b(),l=h("div"),r=h("div"),o=h("input"),c=b(),d=h("label"),v=I("importlib machinery"),p=b(),m=h("div"),f=h("input"),g=b(),w=h("label"),E=I("Frames declaring __traceback_hide__"),C=b(),y=h("div"),k=h("input"),H=b(),W=h("label"),P=I("pyinstrument frames"),a(n,"class","name"),a(o,"id",i[1]+"removeImportlib"),a(o,"type","checkbox"),a(d,"for",i[1]+"removeImportlib"),a(r,"class","option"),a(f,"id",i[1]+"removeTracebackHide"),a(f,"type","checkbox"),a(w,"for",i[1]+"removeTracebackHide"),a(m,"class","option"),a(k,"id",i[1]+"removePyinstrument"),a(k,"type","checkbox"),a(W,"for",i[1]+"removePyinstrument"),a(y,"class","option"),a(l,"class","body"),a(t,"class","option-group"),a(e,"class","view-options-timeline svelte-vsz8zm")},m(T,R){S(T,e,R),u(e,t),u(t,n),u(t,s),u(t,l),u(l,r),u(r,o),o.checked=i[0].removeImportlib,u(r,c),u(r,d),u(d,v),u(l,p),u(l,m),u(m,f),f.checked=i[0].removeTracebackHide,u(m,g),u(m,w),u(w,E),u(l,C),u(l,y),u(y,k),k.checked=i[0].removePyinstrument,u(y,H),u(y,W),u(W,P),M||(_=[N(o,"change",i[2]),N(f,"change",i[3]),N(k,"change",i[4])],M=!0)},p(T,[R]){R&1&&(o.checked=T[0].removeImportlib),R&1&&(f.checked=T[0].removeTracebackHide),R&1&&(k.checked=T[0].removePyinstrument)},i:F,o:F,d(T){T&&L(e),M=!1,oe(_)}}}function rn(i,e,t){let n;ge(i,je,c=>t(0,n=c));const s=ot();function l(){n.removeImportlib=this.checked,je.set(n)}function r(){n.removeTracebackHide=this.checked,je.set(n)}function o(){n.removePyinstrument=this.checked,je.set(n)}return[n,s,l,r,o]}class ln extends fe{constructor(e){super(),de(this,e,rn,on,re,{})}}function an(i){let e,t;return e=new ln({}),{c(){we(e.$$.fragment)},m(n,s){ce(e,n,s),t=!0},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){x(e.$$.fragment,n),t=!1},d(n){ue(e,n)}}}function cn(i){let e,t;return e=new sn({}),{c(){we(e.$$.fragment)},m(n,s){ce(e,n,s),t=!0},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){x(e.$$.fragment,n),t=!1},d(n){ue(e,n)}}}function un(i){let e,t,n,s,l,r,o,c,d;const v=[cn,an],p=[];function m(f,g){return f[0].viewMode==="call-stack"?0:f[0].viewMode==="timeline"?1:-1}return~(o=m(i))&&(c=p[o]=v[o](i)),{c(){e=h("div"),t=h("div"),n=h("div"),s=I(i[3]),l=b(),r=h("div"),c&&c.c(),a(n,"class","title-row svelte-rpk7lo"),a(r,"class","body svelte-rpk7lo"),a(t,"class","box svelte-rpk7lo"),a(e,"class","view-options svelte-rpk7lo")},m(f,g){S(f,e,g),u(e,t),u(t,n),u(n,s),u(t,l),u(t,r),~o&&p[o].m(r,null),i[4](t),i[5](e),d=!0},p(f,[g]){(!d||g&8)&&_e(s,f[3]);let w=o;o=m(f),o!==w&&(c&&(Oe(),x(p[w],1,1,()=>{p[w]=null}),Ve()),~o?(c=p[o],c||(c=p[o]=v[o](f),c.c()),D(c,1),c.m(r,null)):c=null)},i(f){d||(D(c),d=!0)},o(f){x(c),d=!1},d(f){f&&L(e),~o&&p[o].d(),i[4](null),i[5](null)}}}function dn(i,e,t){let n;ge(i,Ge,m=>t(0,n=m));const s=Li();function l(){s("close")}let r,o;bt(()=>{if(o)return Qi(o,l,{ignore:[".js-view-options-button"]})});function c(){if(!r||!o)return;const m=r.getBoundingClientRect(),g=o.getBoundingClientRect().width;m.right-g-20<0?t(2,o.style.right=`${m.right-g-20}px`,o):t(2,o.style.right="0",o)}bt(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)));let d="View options";function v(m){ke[m?"unshift":"push"](()=>{o=m,t(2,o)})}function p(m){ke[m?"unshift":"push"](()=>{r=m,t(1,r)})}return i.$$.update=()=>{i.$$.dirty&1&&(n.viewMode==="call-stack"?t(3,d="Call stack view options"):n.viewMode==="timeline"&&t(3,d="Timeline view options"))},[n,r,o,d,v,p]}class fn extends fe{constructor(e){super(),de(this,e,dn,un,re,{})}}function xt(i){let e,t;return e=new fn({}),e.$on("close",i[9]),{c(){we(e.$$.fragment)},m(n,s){ce(e,n,s),t=!0},p:F,i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){x(e.$$.fragment,n),t=!1},d(n){ue(e,n)}}}function hn(i){let e,t,n,s,l,r,o,c,d=Ct(i[0].target_description)+"",v,p,m,f,g,w,E,C,y,k,H,W,P,M=i[0].sampleCount+"",_,T,R,B,J,$,Le,ee,Q,Y,Ce,q,Qe,Je,le,U,et,te,he,me,be,pe,Te,tt,Ae,K,Be,Me,it;l=new qi({}),Te=new zi({});let z=i[1]&&xt(i);return Be=_t(i[7][0]),{c(){e=h("div"),t=h("div"),n=h("div"),s=h("div"),we(l.$$.fragment),r=b(),o=h("div"),c=h("div"),v=b(),p=h("div"),m=h("div"),f=h("span"),f.textContent="Recorded:",g=b(),w=h("span"),w.textContent=`${i[3]}`,E=b(),C=h("br"),y=b(),k=h("div"),H=h("span"),H.textContent="Samples:",W=b(),P=h("span"),_=I(M),T=b(),R=h("div"),B=h("span"),B.textContent="CPU utilization:",J=b(),$=h("span"),$.textContent=`${(i[4]*100).toFixed(0)}%`,Le=b(),ee=h("div"),Q=h("div"),Y=I(`View: - `),Ce=h("label"),q=h("input"),Qe=I(` - Call stack`),Je=b(),le=h("label"),U=h("input"),et=I(` - Timeline`),te=b(),he=h("div"),me=b(),be=h("div"),pe=h("button"),we(Te.$$.fragment),tt=I(` - View options`),Ae=b(),z&&z.c(),a(s,"class","logo svelte-qdxst2"),a(c,"class","target-description svelte-qdxst2"),a(f,"class","metric-label svelte-qdxst2"),a(w,"class","metric-value svelte-qdxst2"),a(m,"class","metric date svelte-qdxst2"),a(C,"class","svelte-qdxst2"),a(H,"class","metric-label svelte-qdxst2"),a(P,"class","metric-value svelte-qdxst2"),a(k,"class","metric svelte-qdxst2"),a(B,"class","metric-label svelte-qdxst2"),a($,"class","metric-value svelte-qdxst2"),a(R,"class","metric svelte-qdxst2"),a(p,"class","metrics svelte-qdxst2"),a(q,"type","radio"),q.__value="call-stack",ae(q,q.__value),a(q,"class","svelte-qdxst2"),a(Ce,"class","svelte-qdxst2"),a(U,"type","radio"),U.__value="timeline",ae(U,U.__value),a(U,"class","svelte-qdxst2"),a(le,"class","svelte-qdxst2"),a(Q,"class","toggle"),a(he,"class","spacer"),j(he,"flex","1"),a(pe,"class","js-view-options-button svelte-qdxst2"),a(be,"class","button-container svelte-qdxst2"),a(ee,"class","view-options svelte-qdxst2"),a(o,"class","layout svelte-qdxst2"),a(n,"class","row svelte-qdxst2"),a(t,"class","margins"),a(e,"class","header svelte-qdxst2"),Be.p(q,U)},m(O,X){S(O,e,X),u(e,t),u(t,n),u(n,s),ce(l,s,null),u(n,r),u(n,o),u(o,c),c.innerHTML=d,u(o,v),u(o,p),u(p,m),u(m,f),u(m,g),u(m,w),u(p,E),u(p,C),u(p,y),u(p,k),u(k,H),u(k,W),u(k,P),u(P,_),u(p,T),u(p,R),u(R,B),u(R,J),u(R,$),u(o,Le),u(o,ee),u(ee,Q),u(Q,Y),u(Q,Ce),u(Ce,q),q.checked=q.__value===i[2].viewMode,u(Ce,Qe),u(Q,Je),u(Q,le),u(le,U),U.checked=U.__value===i[2].viewMode,u(le,et),u(ee,te),u(ee,he),u(ee,me),u(ee,be),u(be,pe),ce(Te,pe,null),u(pe,tt),u(be,Ae),z&&z.m(be,null),K=!0,Me||(it=[N(q,"change",i[6]),N(U,"change",i[8]),N(pe,"click",gt(vt(i[5])))],Me=!0)},p(O,[X]){(!K||X&1)&&d!==(d=Ct(O[0].target_description)+"")&&(c.innerHTML=d),(!K||X&1)&&M!==(M=O[0].sampleCount+"")&&_e(_,M),X&4&&(q.checked=q.__value===O[2].viewMode),X&4&&(U.checked=U.__value===O[2].viewMode),O[1]?z?(z.p(O,X),X&2&&D(z,1)):(z=xt(O),z.c(),D(z,1),z.m(be,null)):z&&(Oe(),x(z,1,1,()=>{z=null}),Ve())},i(O){K||(D(l.$$.fragment,O),D(Te.$$.fragment,O),D(z),K=!0)},o(O){x(l.$$.fragment,O),x(Te.$$.fragment,O),x(z),K=!1},d(O){O&&L(e),ue(l),ue(Te),z&&z.d(),Be.r(),Me=!1,oe(it)}}}function mn(i,e,t){let n;ge(i,Ge,f=>t(2,n=f));let{session:s}=e;const l=new Date(s.startTime*1e3).toLocaleString(void 0,{dateStyle:"long",timeStyle:"medium"}),r=s.cpuTime/s.duration;let o=!1;function c(f){t(1,o=!o)}const d=[[]];function v(){n.viewMode=this.__value,Ge.set(n)}function p(){n.viewMode=this.__value,Ge.set(n)}const m=()=>t(1,o=!1);return i.$$set=f=>{"session"in f&&t(0,s=f.session)},[s,o,n,l,r,c,v,d,p,m]}class pn extends fe{constructor(e){super(),de(this,e,mn,hn,re,{session:0})}}const vn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWmSURBVHgBtVc7i11VFF5rn3PvPKoLFlqmDGPhaGVpJQoWAZEEGxERFBsDgnY6KFpaWWrQysRGf4BgmSKQFCKWKQMKTqNzz2svv/XY55ybeycTCw+z736cs/f61rdee5hmz/Hx85c66m4QyTEzrdAo4cd6EuuJ2P4wtbmUgfZkCyRoWVcwyMI29ybW47sfhRfXf793+z4X4ZchPEl3F2esElYrbRVaEjQGEKGE3jcUofGwlIEBygoACAa0fmDrdV4AOAg6FV4+W49nUPdlEW4AElGNtqjZ+hqIdI2NAC7KuvAZloyJCR+IukGmF5A6iH/IbEBWLN2NevbBFQ6tCoAF3u7VggYQtQJyFlygOAADI74Jf669QDiWWh6xFRMUgLF6PAGYkcgGgGkBE/x8AiSVaykG0AUxlgm7BY0BUMAQL8R77LM96F98A98kBeu+kAdlgA0MntUGACmOFDQl5sm+Rai6lwpMLtiEgSVGE8wVFBkAB7XcU+rdJOoLSU0x8Aii3ta/0AWqMHjlM6LDPaYDHLSsnRn9pjMny2jBCDSu9H3tDqpCmw4C6lgHqAQmWB05uwwF8RCAQpU7jIbQYCElBsjAlabfqJdnD7lKwzVcIVVOgmKpF2g921pS8/QRvuETmwDEKZdwFHMocYHffYSfBc0opojVIomjx/dY64CkxVktMsgar16/IhbKygANruwWA+YDkURUcNHQaK5ps1XhBwaAzf6M9YzWq3Ac1EKACm80cB8KV6IdPsCR0aQAMBAaUkxXPyU6WDqlypKaSEOtmCCpDyAKFgu1gSecrhdar4n++VsiGUVWDHUpdJkYEPEkEyDc7paHTShXbkuNhqQfaF5wMt16lff69JYFFYT3A8AYgFxku5xtBtw9R7YsEiH85hcYLIsfuO0lfCCHvTtMWxszNRhDebp+LRsTGobFr0zBiO5tBnhWaZgiDwD5gi3Wiw+YcDAwoDfB+MaFq83RsP8M5zSYdFjsBwfh9YAjErbyQLHNVNUsH2Dl2odCh4dE+0vQXjtI9YG2z05zOKvSbdR3eKdtLTbugVKzoOQxC+7KA5NtJPiXEZaH5xDglMrOBMHTWxdWhA/QVqtgEdx3EtVwSkDOxE4GHESpCZzcHLe+4gg3HA7P69jpfvutTA0GTQNNkXAs5UYJVjC593keik/JBohzALjQsXbrJtRksRgntzm7nVX4GnZumtC4D23N4aIAZWdv9LyZv+3IA87AlHY1HQu9+q7Qwb7nAQ01FbQ+g5NBaNOKA2jdD0bg4+UjzCrbqu6IgrLB6aLRF6KWB0ZNUj15QvLCRVa8PNanqiq7pM7kbVXDEvdaipMmHIRfBa2//aYC9WI5vjH6ydLsB1ezpePiK9PhYcoLnjSK5kljNUWqvXppKdVxo4XFhIsJ93gXy/8clxIvt0X7i4XrU8+1D+wGgKPGW/UCzHfew9VsXywVZxbz8GYdKqS4rCTfZ/NZvD8WA/Yxu/aW661F7q+cIbsXVO6EcVf3b0t9SIXFx9N+kwEO3w8QVmhggq+/9xSroVdiv5TZlr0SanL6/KXOK5SaL9b/G4DRdDzONZbPuAjXS4bnfPWBPrJkjhzpYbdR8OeXz62nvBt3HD3z3F/2f0Fyx9O7XL2HAoj7YG33AK8Bag4TrJlOa0DrrVtrj7DsPBtKlgstsZGIcOW+B0wvlMP1EOqcCh1rTldb+/Xcw2woqbaLeh/Vbl7vH/Vgx08TABrehO53ccJKK1ZWP+gjpRqAKdaN8jxLs5r7Bx5TMBm18kjxOOZ0ub/3flUW/nzw4PSJp568CT0vYXq5aGJgslc4o7doPI6dcis2eUq950Ug1DqF9NvQ/uVf79y5v+E1IptedEInNj+iT2L9Nfv9jf7gI/pFdP4D5rfoaYw/Lv+pReVRq/JOEEXOee/PAf7/PP8C3bt510T4rIwAAAAASUVORK5CYII=",$t=st({}),Bt=st({});function zt(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.15?"#D8CB2A":i>.05?"#7ED321":"#58984f"}function Wt(i,e,t){const n=i.slice();return n[21]=e[t],n}function qt(i){let e,t,n,s,l,r,o,c,d,v,p,m,f,g,w,E,C;return{c(){e=h("div"),t=h("div"),n=V("svg"),s=V("path"),l=b(),r=h("div"),o=I(i[6]),c=b(),d=h("div"),v=I(i[4]),p=b(),m=h("div"),f=I(i[5]),g=b(),w=h("div"),a(s,"d","M.937-.016L5.793 4.84.937 9.696z"),a(s,"fill",i[8]),a(s,"fill-rule","evenodd"),a(s,"fill-opacity",".582"),a(n,"width","6"),a(n,"height","10"),a(t,"class","frame-triangle svelte-7e9kco"),Ee(t,"rotate",!i[9]),j(t,"visibility",i[0].children.length>0?"visible":"hidden"),a(r,"class","time svelte-7e9kco"),j(r,"color",i[8]),j(r,"font-weight",i[11]<.15?500:600),a(d,"class","name svelte-7e9kco"),a(m,"class","code-position svelte-7e9kco"),a(e,"class","frame-description svelte-7e9kco"),a(e,"role","button"),a(e,"tabindex","0"),Ee(e,"application-code",i[0].isApplicationCode),Ee(e,"children-visible",!i[9]),j(e,"padding-left",`${i[2]*35}px`),a(w,"class","visual-guide svelte-7e9kco"),j(w,"left",`${i[2]*35+21}px`),j(w,"background-color",i[8])},m(y,k){S(y,e,k),u(e,t),u(t,n),u(n,s),u(e,l),u(e,r),u(r,o),u(e,c),u(e,d),u(d,v),u(e,p),u(e,m),u(m,f),S(y,g,k),S(y,w,k),E||(C=[N(e,"keydown",i[14]),N(e,"click",gt(vt(i[12])))],E=!0)},p(y,k){k&256&&a(s,"fill",y[8]),k&512&&Ee(t,"rotate",!y[9]),k&1&&j(t,"visibility",y[0].children.length>0?"visible":"hidden"),k&64&&_e(o,y[6]),k&256&&j(r,"color",y[8]),k&16&&_e(v,y[4]),k&32&&_e(f,y[5]),k&1&&Ee(e,"application-code",y[0].isApplicationCode),k&512&&Ee(e,"children-visible",!y[9]),k&4&&j(e,"padding-left",`${y[2]*35}px`),k&4&&j(w,"left",`${y[2]*35+21}px`),k&256&&j(w,"background-color",y[8])},d(y){y&&(L(e),L(g),L(w)),E=!1,oe(C)}}}function Ut(i){let e,t,n,s,l=i[0].group.frames.length-1+"",r,o,c,d,v,p;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=b(),r=I(l),o=I(" frames hidden ("),c=I(i[7]),d=I(")"),a(n,"class","group-triangle svelte-7e9kco"),Ee(n,"rotate",i[10]),a(t,"class","group-header-button svelte-7e9kco"),a(e,"class","group-header svelte-7e9kco"),a(e,"role","button"),a(e,"tabindex","0"),j(e,"padding-left",`${i[2]*35}px`)},m(m,f){S(m,e,f),u(e,t),u(t,n),u(t,s),u(t,r),u(t,o),u(t,c),u(t,d),v||(p=[N(e,"keydown",i[15]),N(e,"click",gt(vt(i[13])))],v=!0)},p(m,f){f&1024&&Ee(n,"rotate",m[10]),f&1&&l!==(l=m[0].group.frames.length-1+"")&&_e(r,l),f&128&&_e(c,m[7]),f&4&&j(e,"padding-left",`${m[2]*35}px`)},d(m){m&&L(e),v=!1,oe(p)}}}function Yt(i){let e,t=[],n=new Map,s,l=Ot(i[0].children);const r=o=>o[21].uuid;for(let o=0;o0&&Yt(i);return{c(){e=h("div"),l&&l.c(),t=b(),r&&r.c(),n=b(),o&&o.c(),a(e,"class","frame svelte-7e9kco")},m(c,d){S(c,e,d),l&&l.m(e,null),u(e,t),r&&r.m(e,null),u(e,n),o&&o.m(e,null),s=!0},p(c,[d]){c[3]?l?l.p(c,d):(l=qt(c),l.c(),l.m(e,t)):l&&(l.d(1),l=null),c[0].group&&c[0].group.rootFrame==c[0]&&!c[9]?r?r.p(c,d):(r=Ut(c),r.c(),r.m(e,n)):r&&(r.d(1),r=null),!c[9]&&c[0].children.length>0?o?(o.p(c,d),d&513&&D(o,1)):(o=Yt(c),o.c(),D(o,1),o.m(e,null)):o&&(Oe(),x(o,1,1,()=>{o=null}),Ve())},i(c){s||(D(o),s=!0)},o(c){x(o),s=!1},d(c){c&&L(e),l&&l.d(),r&&r.d(),o&&o.d()}}}function Gt(){const i='a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])',e=document.querySelector(".call-stack-view");if(!e)throw new Error("callStackElement not found");var t=Array.prototype.filter.call(e.querySelectorAll(i),function(n){return n.offsetWidth>0||n.offsetHeight>0||n===document.activeElement});return t}function jt(){const i=Gt();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e+1];t&&t.focus()}}function Zt(){const i=Gt();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e-1];t&&t.focus()}}function _n(i,e,t){let n,s,l,r,o;ge(i,Bt,_=>t(16,l=_)),ge(i,$t,_=>t(17,r=_)),ge(i,Z,_=>t(18,o=_));let{frame:c}=e,{rootFrame:d}=e,{indent:v=0}=e,p;const m=c.time/d.time;let f,g;c.isSynthetic||c.filePathShort==null?g="":c.lineNo==null||c.lineNo===0?g=c.filePathShort:g=`${c.filePathShort}:${c.lineNo}`;let w,E=null;if(c.group){const _=c.group.libraries;_.length<4?E=_.join(", "):E=`${_[0]}, ${_[1]}, ${_[2]}...`}let C;C=zt(m);function y(_){k(c,!s,_.altKey)}function k(_,T,R=!0){if(Bt.update(B=>({...B,[_.uuid]:T})),R)for(const B of _.children)k(B,T,!0),_.group&&_.group.rootFrame==_&&H(_.group.id,!T)}function H(_,T){$t.update(R=>({...R,[_]:T}))}function W(){c.group&&H(c.group.id,!n)}function P(_){let T=!0;_.key==="Enter"||_.key===" "?y(_):_.key==="ArrowLeft"&&!s?k(c,!0,_.altKey):_.key==="ArrowRight"&&s?k(c,!1,_.altKey):_.key==="ArrowUp"?Zt():_.key==="ArrowDown"?jt():T=!1,T&&(_.preventDefault(),_.stopPropagation())}function M(_){let T=!0;_.key==="Enter"||_.key===" "?W():_.key==="ArrowLeft"&&c.group?H(c.group.id,!1):_.key==="ArrowRight"&&c.group?H(c.group.id,!0):_.key==="ArrowUp"?Zt():_.key==="ArrowDown"?jt():T=!1,T&&(_.preventDefault(),_.stopPropagation())}return i.$$set=_=>{"frame"in _&&t(0,c=_.frame),"rootFrame"in _&&t(1,d=_.rootFrame),"indent"in _&&t(2,v=_.indent)},i.$$.update=()=>{var _,T;if(i.$$.dirty&131073&&(c.group?r[c.group.id??""]||((_=c.group)==null?void 0:_.rootFrame)===c||c.children.filter(R=>!R.group).length>1?t(3,p=!0):t(3,p=!1):t(3,p=!0)),i.$$.dirty&1&&(c.className?t(4,f=`${c.className}.${c.function}`):t(4,f=c.function)),i.$$.dirty&262145)if(o.timeFormat==="absolute")t(6,w=c.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(o.timeFormat==="proportion")t(6,w=`${(m*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(10,n=r[((T=c.group)==null?void 0:T.id)??""]===!0),i.$$.dirty&65537&&t(9,s=l[c.uuid]===!0)},[c,d,v,p,f,g,w,E,C,s,n,m,y,W,P,M,l,r,o]}let Kt=class extends fe{constructor(e){super(),de(this,e,_n,gn,re,{frame:0,rootFrame:1,indent:2})}};function Qt(i,e,t){let n=i;for(const s of e)if(n=s(n,t),!n)return null;return n}const wn="\0",bn="[await]",Ze="[self]",yn=[bn,Ze,"[out-of-context]","[root]"],Tn="c",An="h";class Ke{constructor(e,t){A(this,"uuid",ot());A(this,"identifier");A(this,"_identifierParts");A(this,"startTime");A(this,"time",0);A(this,"absorbedTime",0);A(this,"group",null);A(this,"attributes");A(this,"_children",[]);A(this,"parent",null);A(this,"context");var l;this.identifier=e.identifier,this._identifierParts=this.identifier.split(wn),this.startTime=e.startTime??0,this.time=e.time??0,this.attributes=e.attributes??{},this.context=t;let n=this.startTime;const s=(l=e.children)==null?void 0:l.map(r=>(r.startTime===void 0&&(r={...r,startTime:n},n+=r.time??0),n=r.startTime+(r.time??0),new Ke(r,t)));s&&this.addChildren(s)}cloneDeep(){return new Ke(this,this.context)}get children(){return this._children}addChild(e,t={}){if(e.removeFromParent(),e.parent=this,t.after){const n=this._children.indexOf(t.after);if(n==-1)throw new Error("After frame not found");this._children.splice(n+1,0,e)}else this._children.push(e)}addChildren(e,t={}){e=e.slice(),t.after?(e.slice().reverse(),e.forEach(s=>this.addChild(s,t))):e.forEach(n=>this.addChild(n,t))}removeFromParent(){if(this.parent){const e=this.parent._children.indexOf(this);this.parent._children.splice(e,1),this.parent=null}}getAttributes(e){return Object.keys(this.attributes).filter(n=>n.startsWith(e)).map(n=>({data:n.slice(1),time:this.attributes[n]}))}getAttributeValue(e){const t=this.getAttributes(e);if(!t||t.length==0)return null;let n=0;for(let s=0;st[n].time&&(n=s);return t[n].data}get hasTracebackHide(){return this.getAttributeValue(An)=="1"}get function(){return this._identifierParts[0]}get filePath(){return this._identifierParts[1]??null}get lineNo(){const e=this._identifierParts[2];return e?parseInt(e):null}get isSynthetic(){return yn.includes(this.identifier)}get filePathShort(){return this.isSynthetic&&this.parent?this.parent.filePathShort:this.filePath?this.context.shortenPath(this.filePath):null}get isApplicationCode(){if(this.isSynthetic)return!1;const e=this.filePath;return!e||this.context.sysPrefixes.some(n=>e.startsWith(n))?!1:e.startsWith("<")?e.startsWith(""||e==""?this.parent?this.parent.isApplicationCode:!0:!1:!0}get proportionOfParent(){return this.parent?this.time/this.parent.time:1}get className(){return this.getAttributeValue(Tn)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class En{constructor(e){A(this,"id");A(this,"rootFrame");A(this,"_frames",[]);this.id=ot(),this.rootFrame=e}addFrame(e){e.group&&e.group.removeFrame(e),this._frames.push(e),e.group=this}removeFrame(e){if(e.group!==this)throw new Error("Frame not in group.");const t=this._frames.indexOf(e);if(t===-1)throw new Error("Frame not found in group.");this._frames.splice(t,1),e.group=null}get frames(){return this._frames}get exitFrames(){const e=[];for(const t of this.frames){let n=!1;for(const s of t.children)if(s.group!=this){n=!0;break}n&&e.push(t)}return e}get libraries(){const e=[];for(const t of this.frames){const n=t.library;n&&(e.includes(n)||e.push(n))}return e}}function rt(i,e){const{replaceWith:t}=e,n=i.parent;if(!n)throw new Error("Cannot delete the root frame");if(t=="children")n.addChildren(i.children,{after:i});else if(t=="self_time")n.addChild(new Ke({identifier:Ze,time:i.time},n.context),{after:i});else if(t=="nothing")n.absorbedTime+=i.time;else throw new Xi(t);i.removeFromParent(),Mt(i,!0)}function kn(i,e){if(i.parent!==e.parent)throw new Error("Both frames must have the same parent.");e.absorbedTime+=i.absorbedTime,e.time+=i.time,Object.entries(i.attributes).forEach(([t,n])=>{e.attributes[t]!==void 0?e.attributes[t]+=n:e.attributes[t]=n}),e.addChildren(i.children),i.removeFromParent(),Mt(i,!1)}function Mt(i,e){if(e&&i.children&&i.children.forEach(t=>{Mt(t,!0)}),i.group){const t=i.group;t.removeFrame(i),t.frames.length===1&&t.removeFrame(t.frames[0])}}function Ft(i,e){if(!i)return null;for(const t of i.children)Ft(t),t.filePath&&t.filePath.includes("Jt(n)),i._children.sort((n,s)=>s.time-n.time),i}function ei(i,e){if(!i)return null;const t=e.hideRegex,n=e.showRegex;function s(r){const o=r.filePath||"",c=n&&new RegExp(n).test(o),d=t&&new RegExp(t).test(o);return c?!1:d?!0:!r.isApplicationCode}function l(r,o){o.addFrame(r),r.children.forEach(c=>{s(c)&&l(c,o)})}return i.children.forEach(r=>{if(!r.group&&s(r)&&r.children.some(s)){const o=new En(r);l(r,o)}ei(r,e)}),i}function ti(i,e,t=!0){if(!i)return null;let n=null;for(const s of i.children)s.identifier===Ze?n?(n.time+=s.time,s.removeFromParent()):n=s:n=null;return t&&i.children.forEach(s=>ti(s,e,!0)),i}function ii(i,e){return i?(i.children.length===1&&i.children[0].identifier===Ze&&rt(i.children[0],{replaceWith:"nothing"}),i.children.forEach(t=>ii(t)),i):null}function ni(i,e,t=null){if(!i)return null;t===null&&(t=i.time,t<=0&&(t=1e-44));const n=e.filterThreshold??.01;for(const s of i.children.slice())s.time/tni(s,e,t)),i}function si(i,e){if(!i)return null;const t=o=>en(o,c=>c.time),n=o=>{var c;return((c=o.filePath)==null?void 0:c.includes("pyinstrument/__main__.py"))&&o.children.length>0},s=o=>{var c;return o.proportionOfParent>.8&&((c=o.filePath)==null?void 0:c.includes(""))&&o.children.length>0},l=o=>{var c;return o.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(o.filePath??"")||((c=o.filePath)==null?void 0:c.includes("")))&&o.children.length>0};let r=i;if(!n(r)||(r=t(r.children),!s(r))||(r=t(r.children),!l(r)))return i;for(;l(r);)r=t(r.children);return r.removeFromParent(),r}function oi(i,e){return i?(i.children.forEach(t=>oi(t)),i.group&&i.group.frames.length<3&&i.group.removeFrame(i),i):null}function Cn(i){let e,t,n;return t=new Kt({props:{frame:i[3],rootFrame:i[3]}}),{c(){e=h("div"),we(t.$$.fragment),a(e,"class","call-stack-margins svelte-1hebm9u")},m(s,l){S(s,e,l),ce(t,e,null),n=!0},p(s,l){const r={};l&8&&(r.frame=s[3]),l&8&&(r.rootFrame=s[3]),t.$set(r)},i(s){n||(D(t.$$.fragment,s),n=!0)},o(s){x(t.$$.fragment,s),n=!1},d(s){s&&L(e),ue(t)}}}function Mn(i){let e;return{c(){e=h("div"),e.innerHTML='
All frames were filtered out.
',a(e,"class","margins")},m(t,n){S(t,e,n)},p:F,i:F,o:F,d(t){t&&L(e)}}}function Fn(i){let e,t,n,s,l,r,o;const c=[Mn,Cn],d=[];function v(p,m){return p[3]?1:0}return n=v(i),s=d[n]=c[n](i),{c(){e=h("div"),t=h("div"),s.c(),l=b(),r=h("div"),a(t,"class","scroll-inner svelte-1hebm9u"),a(r,"class","scroll-size-fixer svelte-1hebm9u"),a(e,"class","call-stack-view svelte-1hebm9u")},m(p,m){S(p,e,m),u(e,t),d[n].m(t,null),i[7](t),u(e,l),u(e,r),i[8](r),i[9](e),o=!0},p(p,[m]){let f=n;n=v(p),n===f?d[n].p(p,m):(Oe(),x(d[f],1,1,()=>{d[f]=null}),Ve(),s=d[n],s?s.p(p,m):(s=d[n]=c[n](p),s.c()),D(s,1),s.m(t,null))},i(p){o||(D(s),o=!0)},o(p){x(s),o=!1},d(p){p&&L(e),d[n].d(),i[7](null),i[8](null),i[9](null)}}}function Pn(i,e,t){let n,{session:s}=e;const l=Vt([Z],([f])=>{const g=[f.removeImportlib?Ft:null,f.removeTracebackHide?Pt:null,ti,Jt,ii,f.removeIrrelevant?ni:null,f.removePyinstrument?si:null,f.collapseMode!=="disabled"?ei:null,oi].filter(E=>E!==null),w={filterThreshold:f.removeIrrelevantThreshold,hideRegex:f.collapseMode=="custom"?f.collapseCustomHide:void 0,showRegex:f.collapseMode=="custom"?f.collapseCustomShow:void 0};return{processors:g,options:w}});ge(i,l,f=>t(6,n=f));let r,o,c;bt(()=>{let f=0;const g=r;if(!g)throw new Error("element not set");if(!o)throw new Error("scrollInnerElement not set");if(!c)throw new Error("scrollSizeFixerElement not set");const w=new ResizeObserver(()=>{const C=o.getBoundingClientRect().height;C>f&&(f=C,t(2,c.style.top=`${f-1}px`,c))});w.observe(o);let E;return g.addEventListener("scroll",E=()=>{let C=g.scrollTop+g.clientHeight;const y=o.getBoundingClientRect().height;C{w.disconnect(),g.removeEventListener("scroll",E)}});let d;function v(f){ke[f?"unshift":"push"](()=>{o=f,t(1,o)})}function p(f){ke[f?"unshift":"push"](()=>{c=f,t(2,c)})}function m(f){ke[f?"unshift":"push"](()=>{r=f,t(0,r)})}return i.$$set=f=>{"session"in f&&t(5,s=f.session)},i.$$.update=()=>{i.$$.dirty&96&&t(3,d=Qt(s.rootFrame.cloneDeep(),n.processors,n.options))},[r,o,c,d,l,s,n,v,p,m]}class Rn extends fe{constructor(e){super(),de(this,e,Pn,Fn,re,{session:5})}}class In{constructor(e){A(this,"mediaQueryList",null);this.onDevicePixelRatioChanged=e,this._onChange=this._onChange.bind(this),this.createMediaQueryList()}createMediaQueryList(){this.removeMediaQueryList();let e=`(resolution: ${window.devicePixelRatio}dppx)`;this.mediaQueryList=matchMedia(e),this.mediaQueryList.addEventListener("change",this._onChange)}removeMediaQueryList(){var e;(e=this.mediaQueryList)==null||e.removeEventListener("change",this._onChange),this.mediaQueryList=null}_onChange(e){this.onDevicePixelRatioChanged(),this.createMediaQueryList()}destroy(){this.removeMediaQueryList()}}class Ln{constructor(e){A(this,"canvas");A(this,"_size_observer");A(this,"_devicePixelRatioObserver");A(this,"drawAnimationRequest",null);this.container=e,getComputedStyle(e).position!="absolute"&&(e.style.position="relative"),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.container.appendChild(this.canvas),this.setCanvasSize=this.setCanvasSize.bind(this),this._size_observer=new ResizeObserver(this.setCanvasSize),this._size_observer.observe(e),this._devicePixelRatioObserver=new In(this.setCanvasSize),window.requestAnimationFrame(()=>{this.setCanvasSize()})}destroy(){this._size_observer.disconnect(),this._devicePixelRatioObserver.destroy(),this.canvas.remove(),this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null)}setNeedsRedraw(){this.drawAnimationRequest===null&&(this.drawAnimationRequest=window.requestAnimationFrame(()=>{this.drawAnimationRequest=null,this.canvasViewRedraw()}))}redrawIfNeeded(){this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null,this.canvasViewRedraw())}canvasViewRedraw(){const e=this.canvas.getContext("2d");e&&(e.resetTransform(),e.scale(window.devicePixelRatio,window.devicePixelRatio),this.redraw(e,{width:this.canvas.width/window.devicePixelRatio,height:this.canvas.height/window.devicePixelRatio}))}get width(){return this.canvas.width/window.devicePixelRatio}get height(){return this.canvas.height/window.devicePixelRatio}setCanvasSize(){const e=window.devicePixelRatio;this.canvas.height=this.container.clientHeight*e,this.canvas.width=this.container.clientWidth*e,this.canvasViewRedraw()}}function Sn(i){let e,t=i[2]=="self"?"self":"time",n,s,l,r=i[3](i[0].time)+"";return{c(){e=h("div"),n=I(t),s=b(),l=h("div"),a(e,"class","label svelte-ci3g2p"),a(l,"class","time-val svelte-ci3g2p")},m(o,c){S(o,e,c),u(e,n),S(o,s,c),S(o,l,c),l.innerHTML=r},p(o,c){c&4&&t!==(t=o[2]=="self"?"self":"time")&&_e(n,t),c&1&&r!==(r=o[3](o[0].time)+"")&&(l.innerHTML=r)},d(o){o&&(L(e),L(s),L(l))}}}function Dn(i){let e,t,n,s,l=i[3](i[0].time)+"",r,o=i[0].selfTime/i[0].time>.001&&ri(i);return{c(){e=h("div"),e.textContent="time",t=b(),n=h("div"),s=h("div"),r=b(),o&&o.c(),a(e,"class","label svelte-ci3g2p"),a(s,"class","time-val svelte-ci3g2p"),a(n,"class","time-row svelte-ci3g2p")},m(c,d){S(c,e,d),S(c,t,d),S(c,n,d),u(n,s),s.innerHTML=l,u(n,r),o&&o.m(n,null)},p(c,d){d&1&&l!==(l=c[3](c[0].time)+"")&&(s.innerHTML=l),c[0].selfTime/c[0].time>.001?o?o.p(c,d):(o=ri(c),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(c){c&&(L(e),L(t),L(n)),o&&o.d()}}}function ri(i){let e,t,n,s=i[3](i[0].selfTime)+"";return{c(){e=h("div"),e.textContent="self",t=b(),n=h("div"),a(e,"class","label svelte-ci3g2p"),a(n,"class","time-val svelte-ci3g2p")},m(l,r){S(l,e,r),S(l,t,r),S(l,n,r),n.innerHTML=s},p(l,r){r&1&&s!==(s=l[3](l[0].selfTime)+"")&&(n.innerHTML=s)},d(l){l&&(L(e),L(t),L(n))}}}function Hn(i){let e,t,n=i[0].name+"",s,l,r,o,c,d,v,p,m,f;function g(C,y){return C[2]=="both"?Dn:Sn}let w=g(i),E=w(i);return{c(){e=h("div"),t=h("div"),s=I(n),l=b(),E.c(),r=b(),o=h("div"),o.textContent="loc",c=b(),d=h("div"),v=h("div"),m=b(),f=new Ri(!1),a(t,"class","name svelte-ci3g2p"),a(o,"class","label svelte-ci3g2p"),a(v,"class","location-color svelte-ci3g2p"),a(v,"style",p=`background: ${i[0].locationColor}`),f.a=null,a(d,"class","location-row"),a(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),a(e,"style",`font: ${ai}; max-width: ${Vn}px;`)},m(C,y){S(C,e,y),u(e,t),u(t,s),u(e,l),E.m(e,null),u(e,r),u(e,o),u(e,c),u(e,d),u(d,v),u(d,m),f.m(i[1],d)},p(C,[y]){y&1&&n!==(n=C[0].name+"")&&_e(s,n),w===(w=g(C))&&E?E.p(C,y):(E.d(1),E=w(C),E&&(E.c(),E.m(e,r))),y&1&&p!==(p=`background: ${C[0].locationColor}`)&&a(v,"style",p),y&2&&f.p(C[1])},i:F,o:F,d(C){C&&L(e),E.d()}}}function li(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function On(i,e){i.font=ai;const t=li(e)=="both"?140:70,n=i.measureText(e.name).width,s=i.measureText(e.location).width+46;let r=Math.max(t,n,s)+20;return r>310&&(r=310),r}const Vn=310,ai="400 13px Source Sans Pro, sans-serif";function Nn(i,e,t){let{f:n}=e,s,l;function r(o){return`${o.toFixed(3)}`}return i.$$set=o=>{"f"in o&&t(0,n=o.f)},i.$$.update=()=>{i.$$.dirty&1&&t(1,s=Ct(n.location)),i.$$.dirty&1&&t(2,l=li(n))},[n,s,l,r]}class xn extends fe{constructor(e){super(),de(this,e,Nn,Hn,re,{f:0})}}const $n="#212325",ci=18,Bn=17,Ie=28,lt=17,ui=29,zn=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"].map(Ki);class Wn extends Ln{constructor(t){super(t);A(this,"zoom",1);A(this,"startT",0);A(this,"yOffset",0);A(this,"frames",[]);A(this,"isZoomedIn",!1);A(this,"tooltipContainer");A(this,"tooltipComponent",null);A(this,"_rootFrame",null);A(this,"maxDepth",0);A(this,"tooltipLocation",null);A(this,"lastDrawWidth",0);A(this,"lastDrawHeight",0);A(this,"_libraryOrder",null);A(this,"_colors",[]);A(this,"_frameMaxT");A(this,"mouseLocation",null);A(this,"mouseDownLocation",null);A(this,"touches",{});this.onWheel=this.onWheel.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.windowMouseUp=this.windowMouseUp.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onTouchcancel=this.onTouchend.bind(this),this.canvas.addEventListener("wheel",this.onWheel),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseleave",this.onMouseLeave),this.canvas.addEventListener("mousedown",this.onMouseDown),this.canvas.addEventListener("touchstart",this.onTouchstart),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend),this.canvas.addEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer=document.createElement("div"),this.tooltipContainer.style.position="absolute",this.tooltipContainer.style.pointerEvents="none",this.container.appendChild(this.tooltipContainer)}destroy(){this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("touchstart",this.onTouchstart),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend),this.canvas.removeEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer.remove(),super.destroy()}setRootFrame(t){this._rootFrame=t,this.frames=[],this._frameMaxT=void 0,this.maxDepth=0,this._collectFrames(t,0),this.fitContents(),this.setNeedsRedraw()}_collectFrames(t,n){this.frames.push({frame:t,depth:n,isApplicationCode:t.isApplicationCode,library:t.library,className:t.className,filePathShort:t.filePathShort}),this.maxDepth=Math.max(this.maxDepth,n);for(const s of t.children)s.identifier!==Ze&&this._collectFrames(s,n+1)}updateTooltip(t,n){var s;if(n){const l={name:this.frameName(n),time:n.frame.time,selfTime:this.frameSelfTime(n),totalTime:((s=this._rootFrame)==null?void 0:s.time)??1e-12,location:`${n.filePathShort}:${n.frame.lineNo}`,locationColor:this.colorForFrame(n)};if(this.tooltipComponent?this.tooltipComponent.$set({f:l}):this.tooltipComponent=new xn({target:this.tooltipContainer,props:{f:l}}),this.tooltipLocation){const r={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},o=On(t,l),c=this.width-10-o;r.x>c&&(r.x=c);const v=this.height-10-60;r.y>v&&(r.y=v),this.tooltipContainer.style.left=`${r.x}px`,this.tooltipContainer.style.top=`${r.y}px`}}n||this.tooltipComponent&&(this.tooltipComponent.$destroy(),this.tooltipComponent=null)}redraw(t,n){const{width:s,height:l}=n;(s!==this.lastDrawWidth||l!==this.lastDrawHeight)&&(this.isZoomedIn?this.clampViewport():this.fitContents()),this.lastDrawWidth=s,this.lastDrawHeight=l,t.fillStyle=$n,t.fillRect(0,0,s,l),this.drawAxes(t);for(const d of this.frames)this.drawFrame(t,d);t.globalAlpha=1;const r=this.maxYOffset>0||this.isZoomedIn,o=!!this.mouseDownLocation;this.canvas.style.cursor=o&&r?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let c=null;!o&&this.tooltipLocation&&(c=this.hitTest(this.tooltipLocation)),this.updateTooltip(t,c)}drawAxes(t){const n=Math.max(800,this.width)/this.zoom;if(n==0)return;const s=Math.log10(n);let l=Math.ceil(s)+2;l<0&&(l=0);const r=Math.ceil(s)-3,o=c=>xe(c,{from:[s,s-3],to:[.71,0],clamp:!0});for(let c=r;c.01){t.globalAlpha=f,t.font='13px "Source Sans Pro", sans-serif';let g=d.toFixed(c);g=="0"&&(g="0s");let w=m+10;t.fillText(g,v+3,w);let E=this.height+lt+10-this.yOffset;Ethis.width)return;if(t.fillStyle=this.colorForFrame(n),t.globalAlpha=n.isApplicationCode?1:.5,r<2){t.fillRect(s,l,r,o);return}let d=this.frameName(n);const v=Math.floor(r/3.3);if(d.length>v&&(d=d.substring(0,v)),d.length==0){t.fillRect(s,l,r,o);return}t.save(),t.beginPath(),t.rect(s,l,r,o),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let p=s;p<0&&(p=0),t.fillText(d,p+2,l+13),t.restore()}_assignLibraryOrder(){const t={};for(const s of this.frames){const r=s.frame.library??"";t[r]=(t[r]||0)+s.frame.time}const n=Object.keys(t);n.sort((s,l)=>t[l]-t[s]),this._libraryOrder=n}colorForLibraryIndex(t){if(this._colors[t]!==void 0)return this._colors[t];const n=Math.pow(2,Math.ceil(Math.log2(t+1))),l=(2*t-n+1)/n,r=Gi(zn,l);return this._colors[t]=r,r}libraryIndexForFrame(t){this._libraryOrder||this._assignLibraryOrder();const n=t.library||"";let s=this._libraryOrder.indexOf(n);return s===-1&&(s=this._libraryOrder.length,this._libraryOrder.push(n)),s}colorForFrame(t){const n=this.libraryIndexForFrame(t);return this.colorForLibraryIndex(n)}get frameMaxT(){return this._frameMaxT===void 0&&(this._frameMaxT=this.frames.reduce((t,n)=>Math.max(t,n.frame.startTime+n.frame.time),0)),this._frameMaxT}get maxYOffset(){return Math.max(0,(this.maxDepth+1)*ci+lt*2+ui-this.height)}get minZoom(){return(this.width-2*Ie)/this.frameMaxT}get maxZoom(){return 6666666666666667e-8}fitContents(){this.startT=0,this.zoom=this.minZoom,this.isZoomedIn=!1}clampViewport(){this.zoomthis.maxZoom&&(this.zoom=this.maxZoom),this.startT<0&&(this.startT=0);const t=this.frameMaxT-(this.width-2*Ie)/this.zoom;this.startT>t&&(this.startT=t),this.yOffset<0&&(this.yOffset=0),this.yOffset>this.maxYOffset&&(this.yOffset=this.maxYOffset)}frameDims(t){const n=t.depth*ci+lt+ui-this.yOffset,s=Bn;let l=this.xForT(t.frame.startTime),o=this.xForT(t.frame.startTime+t.frame.time)-l;return o<1&&(o=1),o>1&&(o-=xe(o,{from:[1,3],to:[0,1],clamp:!0})),{x:l,y:n,w:o,h:s}}xForT(t){return(t-this.startT)*this.zoom+Ie}tForX(t){return(t-Ie)/this.zoom+this.startT}frameName(t){let n;return t.className?n=`${t.className}.${t.frame.function}`:t.frame.function==""?n=t.filePathShort??t.frame.filePath??"":n=t.frame.function,n}frameSelfTime(t){let n=t.frame.time;const s=t.frame.children.filter(l=>!l.isSynthetic);for(const l of s)n-=l.time;return n}hitTest(t){for(const n of this.frames){const{x:s,y:l,w:r,h:o}=this.frameDims(n);if(t.x>=s&&t.x<=s+r&&t.y>=l&&t.y<=l+o)return n}return null}onWheel(t){const n=t.ctrlKey||t.metaKey,s=n?.01:.0023,l=this.tForX(t.offsetX);this.zoom*=1-t.deltaY*s,this.clampViewport(),this.startT=l-(t.offsetX-Ie)/this.zoom,n||(this.startT+=t.deltaX/this.zoom),this.clampViewport(),this.setNeedsRedraw(),t.preventDefault()}onMouseMove(t){const n={x:t.offsetX,y:t.offsetY},s=this.mouseLocation;if(this.mouseLocation=n,s&&this.mouseDownLocation){const l={x:n.x-s.x,y:n.y-s.y};this.startT-=l.x/this.zoom,this.yOffset-=l.y,this.clampViewport()}this.tooltipLocation=n,this.setNeedsRedraw()}onMouseLeave(t){this.mouseLocation=null,this.tooltipLocation=null,this.setNeedsRedraw()}onMouseDown(t){(t.button===0||t.button===1)&&(this.mouseDownLocation={x:t.offsetX,y:t.offsetY},window.addEventListener("mouseup",this.windowMouseUp),this.setNeedsRedraw())}windowMouseUp(t){window.removeEventListener("mouseup",this.windowMouseUp),this.mouseDownLocation=null,this.setNeedsRedraw()}onTouchstart(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))this.touches[n.identifier]={x:n.clientX,y:n.clientY,downT:this.tForX(n.clientX),startDate:Date.now(),downX:n.clientX,downY:n.clientY}}onTouchmove(t){t.preventDefault(),t.stopPropagation();let n=0;for(const l of Array.from(t.changedTouches)){const r=this.touches[l.identifier];r&&(n+=l.clientY-r.y,this.touches[l.identifier]={...r,x:l.clientX,y:l.clientY})}const s=n/Object.keys(this.touches).length;this.yOffset-=s,this.adjustXAxisForTouches(),this.setNeedsRedraw()}onTouchend(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}onTouchcancel(t){t.preventDefault(),t.stopPropagation();for(const n of Array.from(t.changedTouches))delete this.touches[n.identifier];this.setNeedsRedraw()}adjustXAxisForTouches(){const t=Object.keys(this.touches).map(Number);if(t.length!=0){if(t.length==1){const n=this.touches[t[0]];this.startT=n.downT-(n.x-Ie)/this.zoom}if(t.length>=2){const n=this.touches[t[0]],s=this.touches[t[1]],l=(s.x-n.x)/(s.downT-n.downT),r=n.downT-(n.x-Ie)/l;this.startT=r,this.zoom=l}this.clampViewport()}}}function qn(i){let e;return{c(){e=h("div"),e.innerHTML="",a(e,"class","timeline svelte-p2tt1k")},m(t,n){S(t,e,n),i[6](e)},p:F,i:F,o:F,d(t){t&&L(e),i[6](null)}}}function Un(i,e,t){let n,{session:s}=e;const l=Vt([je],([v])=>({processors:[v.removeImportlib?Ft:null,v.removeTracebackHide?Pt:null,v.removePyinstrument?si:null].filter(f=>f!==null),options:{}}));ge(i,l,v=>t(5,n=v));let r,o=null,c=null;Ii(()=>{c==null||c.destroy()});function d(v){ke[v?"unshift":"push"](()=>{o=v,t(0,o)})}return i.$$set=v=>{"session"in v&&t(2,s=v.session)},i.$$.update=()=>{i.$$.dirty&36&&t(3,r=Qt(s.rootFrame.cloneDeep(),n.processors,n.options)),i.$$.dirty&1&&o&&t(4,c=new Wn(o)),i.$$.dirty&24&&r&&c&&c.setRootFrame(r)},[o,l,s,r,c,n,d]}class Yn extends fe{constructor(e){super(),de(this,e,Un,qn,re,{session:2})}}function Xn(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=I("Unknown view mode: "),s=I(n),a(e,"class","error")},m(l,r){S(l,e,r),u(e,t),u(e,s)},p(l,r){r&2&&n!==(n=l[1].viewMode+"")&&_e(s,n)},i:F,o:F,d(l){l&&L(e)}}}function Gn(i){let e,t;return e=new Yn({props:{session:i[0]}}),{c(){we(e.$$.fragment)},m(n,s){ce(e,n,s),t=!0},p(n,s){const l={};s&1&&(l.session=n[0]),e.$set(l)},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){x(e.$$.fragment,n),t=!1},d(n){ue(e,n)}}}function jn(i){let e,t;return e=new Rn({props:{session:i[0]}}),{c(){we(e.$$.fragment)},m(n,s){ce(e,n,s),t=!0},p(n,s){const l={};s&1&&(l.session=n[0]),e.$set(l)},i(n){t||(D(e.$$.fragment,n),t=!0)},o(n){x(e.$$.fragment,n),t=!1},d(n){ue(e,n)}}}function Zn(i){let e;return{c(){e=h("div"),e.innerHTML='
No samples recorded.
',a(e,"class","margins")},m(t,n){S(t,e,n)},p:F,i:F,o:F,d(t){t&&L(e)}}}function Kn(i){let e,t,n,s,l,r,o,c;n=new pn({props:{session:i[0]}});const d=[Zn,jn,Gn,Xn],v=[];function p(m,f){return m[0].rootFrame?m[1].viewMode==="call-stack"?1:m[1].viewMode==="timeline"?2:3:0}return r=p(i),o=v[r]=d[r](i),{c(){e=h("div"),t=h("div"),we(n.$$.fragment),s=b(),l=h("div"),o.c(),a(t,"class","header"),a(l,"class","body svelte-1vwroj7"),a(e,"class","app svelte-1vwroj7")},m(m,f){S(m,e,f),u(e,t),ce(n,t,null),u(e,s),u(e,l),v[r].m(l,null),c=!0},p(m,[f]){const g={};f&1&&(g.session=m[0]),n.$set(g);let w=r;r=p(m),r===w?v[r].p(m,f):(Oe(),x(v[w],1,1,()=>{v[w]=null}),Ve(),o=v[r],o?o.p(m,f):(o=v[r]=d[r](m),o.c()),D(o,1),o.m(l,null))},i(m){c||(D(n.$$.fragment,m),D(o),c=!0)},o(m){x(n.$$.fragment,m),x(o),c=!1},d(m){m&&L(e),ue(n),v[r].d()}}}function Qn(i,e,t){let n;ge(i,Ge,p=>t(1,n=p));let{session:s}=e;const l=document.createElement("link");l.rel="shortcut icon",l.href=vn,document.head.appendChild(l);const r=document.createElement("link");r.rel="preload",r.as="style",r.onload=()=>{r.rel="stylesheet"},r.href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,600|Source+Sans+Pro:400,600&display=swap",document.head.appendChild(r);const o=s.rootFrame,c=o==null?void 0:o.time.toLocaleString(void 0,{maximumSignificantDigits:3});let d,v;return(v=/[^\s/]+(:\d+)?$/.exec(s.target_description))?d=v[0]:d=s.target_description,document.title=`${c}s - ${d} - pyinstrument`,i.$$set=p=>{"session"in p&&t(0,s=p.session)},[s,n]}class Jn extends fe{constructor(e){super(),de(this,e,Qn,Kn,re,{session:0})}}class es{constructor(e){A(this,"startTime");A(this,"duration");A(this,"minInterval");A(this,"maxInterval");A(this,"sampleCount");A(this,"target_description");A(this,"cpuTime");A(this,"rootFrame");A(this,"sysPath");A(this,"sysPrefixes");A(this,"_shortenPathCache",{});this.startTime=e.session.start_time,this.duration=e.session.duration,this.minInterval=e.session.min_interval,this.maxInterval=e.session.max_interval,this.sampleCount=e.session.sample_count,this.target_description=e.session.target_description,this.cpuTime=e.session.cpu_time,this.sysPath=e.session.sys_path,this.sysPrefixes=e.session.sys_prefixes,this.rootFrame=new Ke(e.frame_tree,this)}shortenPath(e){if(this._shortenPathCache[e])return this._shortenPathCache[e];let t=e;if($e(e).length>1)for(const s of this.sysPath){const l=ts(e,s);$e(l).length<$e(t).length&&(t=l)}return this._shortenPathCache[e]=t,t}}function $e(i){return i.split(/[/\\]/)}function di(i){const e=$e(i);return e.length>0&&e[0].endsWith(":")?e[0]:null}function ts(i,e){if(di(i)!=di(e))return i;const t=$e(i),n=$e(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}return{render(i,e){const t=new es(e);return new Jn({target:i,props:{session:t}})}}}(); +var pyinstrumentHTMLRenderer=function(){"use strict";var ln=Object.defineProperty;var an=(F,ve,Se)=>ve in F?ln(F,ve,{enumerable:!0,configurable:!0,writable:!0,value:Se}):F[ve]=Se;var T=(F,ve,Se)=>an(F,typeof ve!="symbol"?ve+"":ve,Se);function F(){}function ve(i){return i()}function Se(){return Object.create(null)}function oe(i){i.forEach(ve)}function vt(i){return typeof i=="function"}function re(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Fi(i){return Object.keys(i).length===0}function Ot(i,...e){if(i==null){for(const s of e)s(void 0);return F}const t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ge(i,e,t){i.$$.on_destroy.push(Ot(e,t))}function Pi(i,e,t){return i.set(t),e}function u(i,e){i.appendChild(e)}function L(i,e,t){i.insertBefore(e,t||null)}function S(i){i.parentNode&&i.parentNode.removeChild(i)}function Ri(i,e){for(let t=0;ti.removeEventListener(e,t,s)}function gt(i){return function(e){return e.preventDefault(),i.call(this,e)}}function _t(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function c(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function bt(i){let e;return{p(...t){e=t,e.forEach(s=>i.push(s))},r(){e.forEach(t=>i.splice(i.indexOf(t),1))}}}function Si(i){return Array.from(i.childNodes)}function _e(i,e){e=""+e,i.data!==e&&(i.data=e)}function ae(i,e){i.value=e??""}function G(i,e,t,s){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}function Ae(i,e,t){i.classList.toggle(e,!!t)}function Ii(i,e,{bubbles:t=!1,cancelable:s=!1}={}){return new CustomEvent(i,{detail:e,bubbles:t,cancelable:s})}class Li{constructor(e=!1){T(this,"is_svg",!1);T(this,"e");T(this,"n");T(this,"t");T(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,s=null){this.e||(this.is_svg?this.e=V(t.nodeName):this.e=h(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(s)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{const n=i.$$.callbacks[e];if(n){const a=Ii(e,t,{cancelable:s});return n.slice().forEach(o=>{o.call(i,a)}),!a.defaultPrevented}return!0}}const De=[],Ee=[];let He=[];const Ht=[],Hi=Promise.resolve();let Tt=!1;function xi(){Tt||(Tt=!0,Hi.then(xt))}function kt(i){He.push(i)}const At=new Set;let xe=0;function xt(){if(xe!==0)return;const i=Ye;do{try{for(;xei.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),He=e}const st=new Set;let Ie;function Ce(){Ie={r:0,c:[],p:Ie}}function Me(){Ie.r||oe(Ie.c),Ie=Ie.p}function O(i,e){i&&i.i&&(st.delete(i),i.i(e))}function D(i,e,t,s){if(i&&i.o){if(st.has(i))return;st.add(i),Ie.c.push(()=>{st.delete(i),s&&(t&&i.d(1),s())}),i.o(e)}else s&&s()}function nt(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function $i(i,e){D(i,1,1,()=>{e.delete(i.key)})}function Bi(i,e,t,s,n,a,o,r,l,f,g,p){let d=i.length,v=a.length,m=d;const b={};for(;m--;)b[i[m].key]=m;const E=[],C=new Map,w=new Map,k=[];for(m=v;m--;){const M=p(n,a,m),_=t(M);let A=o.get(_);A?k.push(()=>A.p(M,e)):(A=f(_,M),A.c()),C.set(_,E[m]=A),_ in b&&w.set(_,Math.abs(m-b[_]))}const H=new Set,W=new Set;function P(M){O(M,1),M.m(r,g),o.set(M.key,M),g=M.first,v--}for(;d&&v;){const M=E[v-1],_=i[d-1],A=M.key,R=_.key;M===_?(g=M.first,d--,v--):C.has(R)?!o.has(A)||H.has(A)?P(M):W.has(R)?d--:w.get(A)>w.get(R)?(W.add(A),P(M)):(H.add(R),d--):(l(_,o),d--)}for(;d--;){const M=i[d];C.has(M.key)||l(M,o)}for(;v;)P(E[v-1]);return oe(k),E}function be(i){i&&i.c()}function ce(i,e,t){const{fragment:s,after_update:n}=i.$$;s&&s.m(e,t),kt(()=>{const a=i.$$.on_mount.map(ve).filter(vt);i.$$.on_destroy?i.$$.on_destroy.push(...a):oe(a),i.$$.on_mount=[]}),n.forEach(kt)}function ue(i,e){const t=i.$$;t.fragment!==null&&(Ni(t.after_update),oe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function zi(i,e){i.$$.dirty[0]===-1&&(De.push(i),xi(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{const m=v.length?v[0]:d;return f.ctx&&n(f.ctx[p],f.ctx[p]=m)&&(!f.skip_bound&&f.bound[p]&&f.bound[p](m),g&&zi(i,p)),d}):[],f.update(),g=!0,oe(f.before_update),f.fragment=s?s(f.ctx):!1,e.target){if(e.hydrate){const p=Si(e.target);f.fragment&&f.fragment.l(p),p.forEach(S)}else f.fragment&&f.fragment.c();e.intro&&O(i.$$.fragment),ce(i,e.target,e.anchor),xt()}Ue(l)}class de{constructor(){T(this,"$$");T(this,"$$set")}$destroy(){ue(this,1),this.$destroy=F}$on(e,t){if(!vt(t))return F;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const n=s.indexOf(t);n!==-1&&s.splice(n,1)}}$set(e){this.$$set&&!Fi(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Wi="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Wi);function qi(i){let e,t;return{c(){e=V("svg"),t=V("path"),c(t,"fill-rule","evenodd"),c(t,"clip-rule","evenodd"),c(t,"d","M5.11634 0.889422C4.86506 -0.296474 3.17237 -0.296474 2.92109 0.889422C2.78291 1.54158 2.10994 1.93011 1.47607 1.72371C0.323418 1.34837 -0.522932 2.81429 0.378448 3.62484C0.87414 4.07059 0.87414 4.84767 0.378448 5.29341C-0.522931 6.10397 0.323418 7.56989 1.47607 7.19455C2.10994 6.98814 2.78291 7.37668 2.92109 8.02883C3.17237 9.21473 4.86506 9.21473 5.11634 8.02883C5.25452 7.37668 5.92749 6.98814 6.56136 7.19455C7.71401 7.56989 8.56036 6.10397 7.65898 5.29341C7.16329 4.84767 7.16329 4.07059 7.65898 3.62484C8.56036 2.81429 7.71401 1.34837 6.56136 1.72371C5.92749 1.93011 5.25452 1.54158 5.11634 0.889422ZM4.01883 6.33408C5.05436 6.33408 5.89383 5.49462 5.89383 4.45908C5.89383 3.42355 5.05436 2.58408 4.01883 2.58408C2.98329 2.58408 2.14383 3.42355 2.14383 4.45908C2.14383 5.49462 2.98329 6.33408 4.01883 6.33408Z"),c(t,"fill","currentColor"),c(e,"width","9"),c(e,"height","9"),c(e,"viewBox","0 0 9 9"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(s,n){L(s,e,n),u(e,t)},p:F,i:F,o:F,d(s){s&&S(e)}}}class ji extends de{constructor(e){super(),fe(this,e,null,qi,re,{})}}function Yi(i){let e,t,s,n,a,o,r,l,f,g,p,d,v,m,b,E,C;return{c(){e=V("svg"),t=V("g"),s=V("path"),n=V("path"),a=V("defs"),o=V("filter"),r=V("feFlood"),l=V("feBlend"),f=V("feGaussianBlur"),g=V("linearGradient"),p=V("stop"),d=V("stop"),v=V("stop"),m=V("linearGradient"),b=V("stop"),E=V("stop"),C=V("stop"),c(s,"fill-rule","evenodd"),c(s,"clip-rule","evenodd"),c(s,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(s,"fill","url(#paint0_linear_67_262)"),c(t,"opacity","0.5"),c(t,"filter","url(#filter0_f_67_262)"),c(n,"fill-rule","evenodd"),c(n,"clip-rule","evenodd"),c(n,"d","M30 9H10V11.5H30V9ZM30 19H12.5V21.5H30V19ZM12.5 14H32.5V16.5H12.5V14ZM20 24H12.5V26.5H20V24ZM12.5 29H20V31.5H12.5V29ZM22.5 34H10V36.5H22.5V34Z"),c(n,"fill","url(#paint1_linear_67_262)"),c(r,"flood-opacity","0"),c(r,"result","BackgroundImageFix"),c(l,"mode","normal"),c(l,"in","SourceGraphic"),c(l,"in2","BackgroundImageFix"),c(l,"result","shape"),c(f,"stdDeviation","3.39785"),c(f,"result","effect1_foregroundBlur_67_262"),c(o,"id","filter0_f_67_262"),c(o,"x","3.2043"),c(o,"y","2.2043"),c(o,"width","36.0914"),c(o,"height","41.0914"),c(o,"filterUnits","userSpaceOnUse"),c(o,"color-interpolation-filters","sRGB"),c(p,"stop-color","#FFAA00"),c(d,"offset","0.514478"),c(d,"stop-color","#FFEB00"),c(v,"offset","1"),c(v,"stop-color","#98FF05"),c(g,"id","paint0_linear_67_262"),c(g,"x1","7.3769"),c(g,"y1","18.4566"),c(g,"x2","20.6583"),c(g,"y2","33.1038"),c(g,"gradientUnits","userSpaceOnUse"),c(b,"stop-color","#FFC834"),c(E,"offset","0.514478"),c(E,"stop-color","#FAF534"),c(C,"offset","1"),c(C,"stop-color","#B8FF38"),c(m,"id","paint1_linear_67_262"),c(m,"x1","7.3769"),c(m,"y1","18.4566"),c(m,"x2","20.6583"),c(m,"y2","33.1038"),c(m,"gradientUnits","userSpaceOnUse"),c(e,"width","44"),c(e,"height","44"),c(e,"viewBox","0 0 44 44"),c(e,"fill","none"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(w,k){L(w,e,k),u(e,t),u(t,s),u(e,n),u(e,a),u(a,o),u(o,r),u(o,l),u(o,f),u(a,g),u(g,p),u(g,d),u(g,v),u(a,m),u(m,b),u(m,E),u(m,C)},p:F,i:F,o:F,d(w){w&&S(e)}}}class Ui extends de{constructor(e){super(),fe(this,e,null,Yi,re,{})}}const Ve=[];function Xi(i,e){return{subscribe:ot(i,e).subscribe}}function ot(i,e=F){let t;const s=new Set;function n(r){if(re(i,r)&&(i=r,t)){const l=!Ve.length;for(const f of s)f[1](),Ve.push(f,i);if(l){for(let f=0;f{s.delete(f),s.size===0&&t&&(t(),t=null)}}return{set:n,update:a,subscribe:o}}function Vt(i,e,t){const s=!Array.isArray(i),n=s?[i]:i;if(!n.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const a=e.length<2;return Xi(t,(o,r)=>{let l=!1;const f=[];let g=0,p=F;const d=()=>{if(g)return;p();const m=e(s?f[0]:f,o,r);a?o(m):p=vt(m)?m:F},v=n.map((m,b)=>Ot(m,E=>{f[b]=E,g&=~(1<{g|=1<console.error(`Error when writing value from persisted store "${i}" to ${d}`,P),b=(l=t==null?void 0:t.onParseError)!=null?l:(P,M)=>console.error(`Error when parsing ${P?'"'+P+'"':"value"} from persisted store "${i}"`,M),E=(f=t==null?void 0:t.beforeRead)!=null?f:P=>P,C=(g=t==null?void 0:t.beforeWrite)!=null?g:P=>P,w=typeof window<"u"&&typeof document<"u",k=w?Gi(d):null;function H(P,M){const _=C(M);try{k==null||k.setItem(P,p.stringify(_))}catch(A){m(A)}}function W(){function P(R){try{return p.parse(R)}catch(B){b(R,B)}}const M=k==null?void 0:k.getItem(i);if(M==null)return e;const _=P(M);return _==null?e:E(_)}if(!Et[d][i]){const P=W(),M=ot(P,R=>{if(w&&d=="local"&&v){const B=J=>{if(J.key===i&&J.newValue){let $;try{$=p.parse(J.newValue)}catch(ee){b(J.newValue,ee);return}const Oe=E($);R(Oe)}};return window.addEventListener("storage",B),()=>window.removeEventListener("storage",B)}}),{subscribe:_,set:A}=M;Et[d][i]={set(R){A(R),H(i,R)},update(R){return M.update(B=>{const J=R(B);return H(i,J),J})},reset(){this.set(e)},subscribe:_}}return Et[d][i]}function Nt(){return{collapseMode:"non-application",collapseCustomHide:"",collapseCustomShow:"",removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:.001,timeFormat:"absolute"}}const Z=Ct("pyinstrument:viewOptionsCallStack",Nt(),{syncTabs:!0,beforeRead(i){return{...Nt(),...i}}}),Xe=Ct("pyinstrument:viewOptions",{viewMode:"call-stack"},{syncTabs:!1}),Ge=Ct("pyinstrument:viewOptionsTimeline",{removeImportlib:!0,removeTracebackHide:!0,removePyinstrument:!0,removeIrrelevant:!0,removeIrrelevantThreshold:1e-4},{syncTabs:!0});class Zi extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function Ki(i,e){const t=e*(i.length-1),s=Math.floor(t),n=Math.ceil(t),a=i[s],o=i[n],r=t-s;return Ji(r,{to:[a,o]})}function Qi(i,e,t){return i===1/0?(console.warn("clamp: value is Infinity, returning `max`",i),t):i===-1/0?(console.warn("clamp: value is -Infinity, returning `min`",i),e):Number.isFinite(i)?it?t:i:(console.warn("clamp: value isn't finite, returning `min`",i),e)}function Ne(i,e){const{from:t=[0,1],to:s=[0,1]}=e,n=e.clamp||!1;let a=(i-t[0])/(t[1]-t[0])*(s[1]-s[0])+s[0];return n&&(a=Qi(a,Math.min(s[0],s[1]),Math.max(s[0],s[1]))),a}function Ji(i,e){return`rgb( + ${Ne(i,{from:e.from,to:[e.to[0][0],e.to[1][0]],clamp:e.clamp})}, + ${Ne(i,{from:e.from,to:[e.to[0][1],e.to[1][1]],clamp:e.clamp})}, + ${Ne(i,{from:e.from,to:[e.to[0][2],e.to[1][2]],clamp:e.clamp})} + )`}function es(i){if(i.substr(0,1)=="#"){var e=(i.length-1)/3,t=[17,1,.062272][e-1];return[Math.round(parseInt(i.substr(1,e),16)*t),Math.round(parseInt(i.substr(1+e,e),16)*t),Math.round(parseInt(i.substr(1+2*e,e),16)*t)]}else return i.split("(")[1].split(")")[0].split(",").map(s=>+s)}function ts(i,e,t={}){const{ignore:s=[],capture:n=!0}=t,a=window;if(!a)return()=>{};let o=!0,r=!1;const l=v=>s.some(m=>typeof m=="string"?Array.from(document.querySelectorAll(m)).some(b=>b===v.target||v.composedPath().includes(b)):m&&(v.target===m||v.composedPath().includes(m))),f=v=>{if(!(!i||i===v.target||v.composedPath().includes(i))){if(v.detail===0&&(o=!l(v)),!o){o=!0;return}e(v)}},g=v=>{r||(r=!0,setTimeout(()=>{r=!1},0),f(v))},p=v=>{o=!l(v)&&!!(i&&!v.composedPath().includes(i))};return a.addEventListener("click",g,{passive:!0,capture:n}),a.addEventListener("pointerdown",p,{passive:!0}),()=>{a.removeEventListener("click",g,{capture:n}),a.removeEventListener("pointerdown",p)}}function is(i){const e=document.createElement("div");return e.appendChild(document.createTextNode(i)),e.innerHTML}function Mt(i){return is(i).replace(/(\/|\\)/g,t=>`${t}`)}function ss(i,e){if(i.length==0)return null;let t=i[0],s=e(t);for(const n of i){const a=e(n);a>s&&(t=n,s=a)}return t}function rt(){return Math.random().toString(36).substring(2)}function ns(i){let e,t,s,n,a,o,r,l,f,g,p,d,v,m,b,E,C,w,k,H,W,P,M,_,A,R,B,J,$,Oe,ee,Q,Y,Fe,q,Qe,Je,le,j,et,te,he,me,we,pe,Te,tt,ke,K,Be,Pe,it,z,x,U,pi,ct,vi,gi,ze,Re,_i,We,ut,bi,wi,ye,yi,Ti,qe,ft,ki,je,dt,ht,ie,Ai,Ei,mt,pt,se,Ci,St,It,Lt,Mi;return St=bt(i[5][0]),It=bt(i[5][1]),{c(){e=h("div"),t=h("div"),s=h("div"),s.textContent="Collapse frames",n=y(),a=h("div"),o=h("div"),r=h("input"),l=y(),f=h("label"),g=I("Library code"),p=y(),d=h("div"),d.textContent="Code run from the Python stdlib, a virtualenv, or a conda env will be collapsed.",v=y(),m=h("div"),b=h("input"),E=y(),C=h("label"),w=I("Custom"),k=y(),H=h("div"),W=I(`Regex on the source file path. + `),P=h("div"),M=h("label"),M.textContent="Show",_=y(),A=h("input"),R=y(),B=h("label"),B.textContent="Hide",J=y(),$=h("input"),Oe=I(` + If neither match, the library code rule is used.`),ee=y(),Q=h("div"),Y=h("input"),Fe=y(),q=h("label"),Qe=I("Disabled"),Je=y(),le=h("div"),j=h("div"),j.textContent="Remove frames",et=y(),te=h("div"),he=h("div"),me=h("input"),we=y(),pe=h("label"),Te=I("importlib machinery"),tt=y(),ke=h("div"),K=h("input"),Be=y(),Pe=h("label"),it=I("Frames declaring __traceback_hide__"),z=y(),x=h("div"),U=h("input"),pi=y(),ct=h("label"),vi=I("pyinstrument frames"),gi=y(),ze=h("div"),Re=h("input"),_i=y(),We=h("span"),ut=h("label"),bi=I("Frames with durations less than"),wi=y(),ye=h("input"),yi=I(` + % of the total time`),Ti=y(),qe=h("div"),ft=h("div"),ft.textContent="Time format",ki=y(),je=h("div"),dt=h("div"),ht=h("label"),ie=h("input"),Ai=I(` + Absolute time in seconds`),Ei=y(),mt=h("div"),pt=h("label"),se=h("input"),Ci=I(` + Percentage of the total run time`),c(s,"class","name svelte-1pecl4m"),c(r,"id",i[1]+"collapseModeAll"),c(r,"type","radio"),r.__value="non-application",ae(r,r.__value),c(r,"class","svelte-1pecl4m"),c(f,"for",i[1]+"collapseModeAll"),c(d,"class","description svelte-1pecl4m"),c(o,"class","option svelte-1pecl4m"),c(b,"id",i[1]+"collapseModeCustom"),c(b,"type","radio"),b.__value="custom",ae(b,b.__value),c(b,"class","svelte-1pecl4m"),c(C,"for",i[1]+"collapseModeCustom"),c(M,"for","collapseCustomShow"),c(M,"class","svelte-1pecl4m"),c(A,"id","collapseCustomShow"),c(A,"type","text"),c(A,"placeholder","myproject"),c(A,"spellcheck","false"),c(A,"autocapitalize","off"),c(A,"autocomplete","off"),c(A,"autocorrect","off"),c(A,"class","svelte-1pecl4m"),c(B,"for","collapseCustomHide"),c(B,"class","svelte-1pecl4m"),c($,"id","collapseCustomHide"),c($,"type","text"),c($,"placeholder",".*/lib/.*"),c($,"spellcheck","false"),c($,"autocapitalize","off"),c($,"autocomplete","off"),c($,"autocorrect","off"),c($,"class","svelte-1pecl4m"),c(P,"class","mini-input-grid svelte-1pecl4m"),c(H,"class","description svelte-1pecl4m"),c(m,"class","option svelte-1pecl4m"),c(Y,"id",i[1]+"collapseModeDisabled"),c(Y,"type","radio"),Y.__value="disabled",ae(Y,Y.__value),c(Y,"class","svelte-1pecl4m"),c(q,"for",i[1]+"collapseModeDisabled"),c(Q,"class","option svelte-1pecl4m"),c(a,"class","body"),c(t,"class","option-group svelte-1pecl4m"),c(j,"class","name svelte-1pecl4m"),c(me,"id",i[1]+"removeImportlib"),c(me,"type","checkbox"),c(me,"class","svelte-1pecl4m"),c(pe,"for",i[1]+"removeImportlib"),c(he,"class","option svelte-1pecl4m"),c(K,"id",i[1]+"removeTracebackHide"),c(K,"type","checkbox"),c(K,"class","svelte-1pecl4m"),c(Pe,"for",i[1]+"removeTracebackHide"),c(ke,"class","option svelte-1pecl4m"),c(U,"id",i[1]+"removePyinstrument"),c(U,"type","checkbox"),c(U,"class","svelte-1pecl4m"),c(ct,"for",i[1]+"removePyinstrument"),c(x,"class","option svelte-1pecl4m"),c(Re,"id",i[1]+"removeIrrelevant"),c(Re,"type","checkbox"),c(Re,"class","svelte-1pecl4m"),c(ut,"for",i[1]+"removeIrrelevant"),c(ye,"type","number"),ye.value=i[2](),c(ye,"min","0"),c(ye,"max","99"),c(ye,"step","0.01"),G(ye,"width","4em"),c(ye,"class","svelte-1pecl4m"),c(ze,"class","option svelte-1pecl4m"),c(te,"class","body"),c(le,"class","option-group svelte-1pecl4m"),c(ft,"class","name svelte-1pecl4m"),c(ie,"type","radio"),ie.__value="absolute",ae(ie,ie.__value),c(ie,"class","svelte-1pecl4m"),c(dt,"class","option svelte-1pecl4m"),c(se,"type","radio"),se.__value="proportion",ae(se,se.__value),c(se,"class","svelte-1pecl4m"),c(mt,"class","option svelte-1pecl4m"),c(je,"class","body"),c(qe,"class","option-group svelte-1pecl4m"),c(e,"class","view-options-call-stack svelte-1pecl4m"),St.p(ie,se),It.p(r,b,Y)},m(X,ne){L(X,e,ne),u(e,t),u(t,s),u(t,n),u(t,a),u(a,o),u(o,r),r.checked=r.__value===i[0].collapseMode,u(o,l),u(o,f),u(f,g),u(o,p),u(o,d),u(a,v),u(a,m),u(m,b),b.checked=b.__value===i[0].collapseMode,u(m,E),u(m,C),u(C,w),u(m,k),u(m,H),u(H,W),u(H,P),u(P,M),u(P,_),u(P,A),ae(A,i[0].collapseCustomShow),u(P,R),u(P,B),u(P,J),u(P,$),ae($,i[0].collapseCustomHide),u(H,Oe),u(a,ee),u(a,Q),u(Q,Y),Y.checked=Y.__value===i[0].collapseMode,u(Q,Fe),u(Q,q),u(q,Qe),u(e,Je),u(e,le),u(le,j),u(le,et),u(le,te),u(te,he),u(he,me),me.checked=i[0].removeImportlib,u(he,we),u(he,pe),u(pe,Te),u(te,tt),u(te,ke),u(ke,K),K.checked=i[0].removeTracebackHide,u(ke,Be),u(ke,Pe),u(Pe,it),u(te,z),u(te,x),u(x,U),U.checked=i[0].removePyinstrument,u(x,pi),u(x,ct),u(ct,vi),u(te,gi),u(te,ze),u(ze,Re),Re.checked=i[0].removeIrrelevant,u(ze,_i),u(ze,We),u(We,ut),u(ut,bi),u(We,wi),u(We,ye),u(We,yi),u(e,Ti),u(e,qe),u(qe,ft),u(qe,ki),u(qe,je),u(je,dt),u(dt,ht),u(ht,ie),ie.checked=ie.__value===i[0].timeFormat,u(ht,Ai),u(je,Ei),u(je,mt),u(mt,pt),u(pt,se),se.checked=se.__value===i[0].timeFormat,u(pt,Ci),Lt||(Mi=[N(r,"change",i[4]),N(b,"change",i[6]),N(A,"input",i[7]),N($,"input",i[8]),N(Y,"change",i[9]),N(me,"change",i[10]),N(K,"change",i[11]),N(U,"change",i[12]),N(Re,"change",i[13]),N(ye,"input",i[3]),N(ie,"change",i[14]),N(se,"change",i[15])],Lt=!0)},p(X,[ne]){ne&1&&(r.checked=r.__value===X[0].collapseMode),ne&1&&(b.checked=b.__value===X[0].collapseMode),ne&1&&A.value!==X[0].collapseCustomShow&&ae(A,X[0].collapseCustomShow),ne&1&&$.value!==X[0].collapseCustomHide&&ae($,X[0].collapseCustomHide),ne&1&&(Y.checked=Y.__value===X[0].collapseMode),ne&1&&(me.checked=X[0].removeImportlib),ne&1&&(K.checked=X[0].removeTracebackHide),ne&1&&(U.checked=X[0].removePyinstrument),ne&1&&(Re.checked=X[0].removeIrrelevant),ne&1&&(ie.checked=ie.__value===X[0].timeFormat),ne&1&&(se.checked=se.__value===X[0].timeFormat)},i:F,o:F,d(X){X&&S(e),St.r(),It.r(),Lt=!1,oe(Mi)}}}function os(i,e,t){let s;ge(i,Z,k=>t(0,s=k));const n=rt();function a(){return(s.removeIrrelevantThreshold*100).toLocaleString(void 0,{maximumFractionDigits:4})}function o(k){Pi(Z,s.removeIrrelevantThreshold=k.currentTarget.valueAsNumber/100,s)}const r=[[],[]];function l(){s.collapseMode=this.__value,Z.set(s)}function f(){s.collapseMode=this.__value,Z.set(s)}function g(){s.collapseCustomShow=this.value,Z.set(s)}function p(){s.collapseCustomHide=this.value,Z.set(s)}function d(){s.collapseMode=this.__value,Z.set(s)}function v(){s.removeImportlib=this.checked,Z.set(s)}function m(){s.removeTracebackHide=this.checked,Z.set(s)}function b(){s.removePyinstrument=this.checked,Z.set(s)}function E(){s.removeIrrelevant=this.checked,Z.set(s)}function C(){s.timeFormat=this.__value,Z.set(s)}function w(){s.timeFormat=this.__value,Z.set(s)}return[s,n,a,o,l,r,f,g,p,d,v,m,b,E,C,w]}class rs extends de{constructor(e){super(),fe(this,e,os,ns,re,{})}}function ls(i){let e,t,s,n,a,o,r,l,f,g,p,d,v,m,b,E,C,w,k,H,W,P,M,_;return{c(){e=h("div"),t=h("div"),s=h("div"),s.textContent="Remove frames",n=y(),a=h("div"),o=h("div"),r=h("input"),l=y(),f=h("label"),g=I("importlib machinery"),p=y(),d=h("div"),v=h("input"),m=y(),b=h("label"),E=I("Frames declaring __traceback_hide__"),C=y(),w=h("div"),k=h("input"),H=y(),W=h("label"),P=I("pyinstrument frames"),c(s,"class","name"),c(r,"id",i[1]+"removeImportlib"),c(r,"type","checkbox"),c(f,"for",i[1]+"removeImportlib"),c(o,"class","option"),c(v,"id",i[1]+"removeTracebackHide"),c(v,"type","checkbox"),c(b,"for",i[1]+"removeTracebackHide"),c(d,"class","option"),c(k,"id",i[1]+"removePyinstrument"),c(k,"type","checkbox"),c(W,"for",i[1]+"removePyinstrument"),c(w,"class","option"),c(a,"class","body"),c(t,"class","option-group"),c(e,"class","view-options-timeline svelte-vsz8zm")},m(A,R){L(A,e,R),u(e,t),u(t,s),u(t,n),u(t,a),u(a,o),u(o,r),r.checked=i[0].removeImportlib,u(o,l),u(o,f),u(f,g),u(a,p),u(a,d),u(d,v),v.checked=i[0].removeTracebackHide,u(d,m),u(d,b),u(b,E),u(a,C),u(a,w),u(w,k),k.checked=i[0].removePyinstrument,u(w,H),u(w,W),u(W,P),M||(_=[N(r,"change",i[2]),N(v,"change",i[3]),N(k,"change",i[4])],M=!0)},p(A,[R]){R&1&&(r.checked=A[0].removeImportlib),R&1&&(v.checked=A[0].removeTracebackHide),R&1&&(k.checked=A[0].removePyinstrument)},i:F,o:F,d(A){A&&S(e),M=!1,oe(_)}}}function as(i,e,t){let s;ge(i,Ge,l=>t(0,s=l));const n=rt();function a(){s.removeImportlib=this.checked,Ge.set(s)}function o(){s.removeTracebackHide=this.checked,Ge.set(s)}function r(){s.removePyinstrument=this.checked,Ge.set(s)}return[s,n,a,o,r]}class cs extends de{constructor(e){super(),fe(this,e,as,ls,re,{})}}function us(i){let e,t;return e=new cs({}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function fs(i){let e,t;return e=new rs({}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function ds(i){let e,t,s,n,a,o,r,l,f;const g=[fs,us],p=[];function d(v,m){return v[0].viewMode==="call-stack"?0:v[0].viewMode==="timeline"?1:-1}return~(r=d(i))&&(l=p[r]=g[r](i)),{c(){e=h("div"),t=h("div"),s=h("div"),n=I(i[3]),a=y(),o=h("div"),l&&l.c(),c(s,"class","title-row svelte-rpk7lo"),c(o,"class","body svelte-rpk7lo"),c(t,"class","box svelte-rpk7lo"),c(e,"class","view-options svelte-rpk7lo")},m(v,m){L(v,e,m),u(e,t),u(t,s),u(s,n),u(t,a),u(t,o),~r&&p[r].m(o,null),i[4](t),i[5](e),f=!0},p(v,[m]){(!f||m&8)&&_e(n,v[3]);let b=r;r=d(v),r!==b&&(l&&(Ce(),D(p[b],1,1,()=>{p[b]=null}),Me()),~r?(l=p[r],l||(l=p[r]=g[r](v),l.c()),O(l,1),l.m(o,null)):l=null)},i(v){f||(O(l),f=!0)},o(v){D(l),f=!1},d(v){v&&S(e),~r&&p[r].d(),i[4](null),i[5](null)}}}function hs(i,e,t){let s;ge(i,Xe,d=>t(0,s=d));const n=Di();function a(){n("close")}let o,r;yt(()=>{if(r)return ts(r,a,{ignore:[".js-view-options-button"]})});function l(){if(!o||!r)return;const d=o.getBoundingClientRect(),m=r.getBoundingClientRect().width;d.right-m-20<0?t(2,r.style.right=`${d.right-m-20}px`,r):t(2,r.style.right="0",r)}yt(()=>(l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)));let f="View options";function g(d){Ee[d?"unshift":"push"](()=>{r=d,t(2,r)})}function p(d){Ee[d?"unshift":"push"](()=>{o=d,t(1,o)})}return i.$$.update=()=>{i.$$.dirty&1&&(s.viewMode==="call-stack"?t(3,f="Call stack view options"):s.viewMode==="timeline"&&t(3,f="Timeline view options"))},[s,o,r,f,g,p]}class ms extends de{constructor(e){super(),fe(this,e,hs,ds,re,{})}}function $t(i){let e,t;return e=new ms({}),e.$on("close",i[9]),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},p:F,i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function ps(i){let e,t,s,n,a,o,r,l,f=Mt(i[0].target_description)+"",g,p,d,v,m,b,E,C,w,k,H,W,P,M=i[0].sampleCount+"",_,A,R,B,J,$,Oe,ee,Q,Y,Fe,q,Qe,Je,le,j,et,te,he,me,we,pe,Te,tt,ke,K,Be,Pe,it;a=new Ui({}),Te=new ji({});let z=i[1]&&$t(i);return Be=bt(i[7][0]),{c(){e=h("div"),t=h("div"),s=h("div"),n=h("div"),be(a.$$.fragment),o=y(),r=h("div"),l=h("div"),g=y(),p=h("div"),d=h("div"),v=h("span"),v.textContent="Recorded:",m=y(),b=h("span"),b.textContent=`${i[3]}`,E=y(),C=h("br"),w=y(),k=h("div"),H=h("span"),H.textContent="Samples:",W=y(),P=h("span"),_=I(M),A=y(),R=h("div"),B=h("span"),B.textContent="CPU utilization:",J=y(),$=h("span"),$.textContent=`${(i[4]*100).toFixed(0)}%`,Oe=y(),ee=h("div"),Q=h("div"),Y=I(`View: + `),Fe=h("label"),q=h("input"),Qe=I(` + Call stack`),Je=y(),le=h("label"),j=h("input"),et=I(` + Timeline`),te=y(),he=h("div"),me=y(),we=h("div"),pe=h("button"),be(Te.$$.fragment),tt=I(` + View options`),ke=y(),z&&z.c(),c(n,"class","logo svelte-qdxst2"),c(l,"class","target-description svelte-qdxst2"),c(v,"class","metric-label svelte-qdxst2"),c(b,"class","metric-value svelte-qdxst2"),c(d,"class","metric date svelte-qdxst2"),c(C,"class","svelte-qdxst2"),c(H,"class","metric-label svelte-qdxst2"),c(P,"class","metric-value svelte-qdxst2"),c(k,"class","metric svelte-qdxst2"),c(B,"class","metric-label svelte-qdxst2"),c($,"class","metric-value svelte-qdxst2"),c(R,"class","metric svelte-qdxst2"),c(p,"class","metrics svelte-qdxst2"),c(q,"type","radio"),q.__value="call-stack",ae(q,q.__value),c(q,"class","svelte-qdxst2"),c(Fe,"class","svelte-qdxst2"),c(j,"type","radio"),j.__value="timeline",ae(j,j.__value),c(j,"class","svelte-qdxst2"),c(le,"class","svelte-qdxst2"),c(Q,"class","toggle"),c(he,"class","spacer"),G(he,"flex","1"),c(pe,"class","js-view-options-button svelte-qdxst2"),c(we,"class","button-container svelte-qdxst2"),c(ee,"class","view-options svelte-qdxst2"),c(r,"class","layout svelte-qdxst2"),c(s,"class","row svelte-qdxst2"),c(t,"class","margins"),c(e,"class","header svelte-qdxst2"),Be.p(q,j)},m(x,U){L(x,e,U),u(e,t),u(t,s),u(s,n),ce(a,n,null),u(s,o),u(s,r),u(r,l),l.innerHTML=f,u(r,g),u(r,p),u(p,d),u(d,v),u(d,m),u(d,b),u(p,E),u(p,C),u(p,w),u(p,k),u(k,H),u(k,W),u(k,P),u(P,_),u(p,A),u(p,R),u(R,B),u(R,J),u(R,$),u(r,Oe),u(r,ee),u(ee,Q),u(Q,Y),u(Q,Fe),u(Fe,q),q.checked=q.__value===i[2].viewMode,u(Fe,Qe),u(Q,Je),u(Q,le),u(le,j),j.checked=j.__value===i[2].viewMode,u(le,et),u(ee,te),u(ee,he),u(ee,me),u(ee,we),u(we,pe),ce(Te,pe,null),u(pe,tt),u(we,ke),z&&z.m(we,null),K=!0,Pe||(it=[N(q,"change",i[6]),N(j,"change",i[8]),N(pe,"click",_t(gt(i[5])))],Pe=!0)},p(x,[U]){(!K||U&1)&&f!==(f=Mt(x[0].target_description)+"")&&(l.innerHTML=f),(!K||U&1)&&M!==(M=x[0].sampleCount+"")&&_e(_,M),U&4&&(q.checked=q.__value===x[2].viewMode),U&4&&(j.checked=j.__value===x[2].viewMode),x[1]?z?(z.p(x,U),U&2&&O(z,1)):(z=$t(x),z.c(),O(z,1),z.m(we,null)):z&&(Ce(),D(z,1,1,()=>{z=null}),Me())},i(x){K||(O(a.$$.fragment,x),O(Te.$$.fragment,x),O(z),K=!0)},o(x){D(a.$$.fragment,x),D(Te.$$.fragment,x),D(z),K=!1},d(x){x&&S(e),ue(a),ue(Te),z&&z.d(),Be.r(),Pe=!1,oe(it)}}}function vs(i,e,t){let s;ge(i,Xe,v=>t(2,s=v));let{session:n}=e;const a=new Date(n.startTime*1e3).toLocaleString(void 0,{dateStyle:"long",timeStyle:"medium"}),o=n.cpuTime/n.duration;let r=!1;function l(v){t(1,r=!r)}const f=[[]];function g(){s.viewMode=this.__value,Xe.set(s)}function p(){s.viewMode=this.__value,Xe.set(s)}const d=()=>t(1,r=!1);return i.$$set=v=>{"session"in v&&t(0,n=v.session)},[n,r,s,a,o,l,g,f,p,d]}class gs extends de{constructor(e){super(),fe(this,e,vs,ps,re,{session:0})}}const _s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWmSURBVHgBtVc7i11VFF5rn3PvPKoLFlqmDGPhaGVpJQoWAZEEGxERFBsDgnY6KFpaWWrQysRGf4BgmSKQFCKWKQMKTqNzz2svv/XY55ybeycTCw+z736cs/f61rdee5hmz/Hx85c66m4QyTEzrdAo4cd6EuuJ2P4wtbmUgfZkCyRoWVcwyMI29ybW47sfhRfXf793+z4X4ZchPEl3F2esElYrbRVaEjQGEKGE3jcUofGwlIEBygoACAa0fmDrdV4AOAg6FV4+W49nUPdlEW4AElGNtqjZ+hqIdI2NAC7KuvAZloyJCR+IukGmF5A6iH/IbEBWLN2NevbBFQ6tCoAF3u7VggYQtQJyFlygOAADI74Jf669QDiWWh6xFRMUgLF6PAGYkcgGgGkBE/x8AiSVaykG0AUxlgm7BY0BUMAQL8R77LM96F98A98kBeu+kAdlgA0MntUGACmOFDQl5sm+Rai6lwpMLtiEgSVGE8wVFBkAB7XcU+rdJOoLSU0x8Aii3ta/0AWqMHjlM6LDPaYDHLSsnRn9pjMny2jBCDSu9H3tDqpCmw4C6lgHqAQmWB05uwwF8RCAQpU7jIbQYCElBsjAlabfqJdnD7lKwzVcIVVOgmKpF2g921pS8/QRvuETmwDEKZdwFHMocYHffYSfBc0opojVIomjx/dY64CkxVktMsgar16/IhbKygANruwWA+YDkURUcNHQaK5ps1XhBwaAzf6M9YzWq3Ac1EKACm80cB8KV6IdPsCR0aQAMBAaUkxXPyU6WDqlypKaSEOtmCCpDyAKFgu1gSecrhdar4n++VsiGUVWDHUpdJkYEPEkEyDc7paHTShXbkuNhqQfaF5wMt16lff69JYFFYT3A8AYgFxku5xtBtw9R7YsEiH85hcYLIsfuO0lfCCHvTtMWxszNRhDebp+LRsTGobFr0zBiO5tBnhWaZgiDwD5gi3Wiw+YcDAwoDfB+MaFq83RsP8M5zSYdFjsBwfh9YAjErbyQLHNVNUsH2Dl2odCh4dE+0vQXjtI9YG2z05zOKvSbdR3eKdtLTbugVKzoOQxC+7KA5NtJPiXEZaH5xDglMrOBMHTWxdWhA/QVqtgEdx3EtVwSkDOxE4GHESpCZzcHLe+4gg3HA7P69jpfvutTA0GTQNNkXAs5UYJVjC593keik/JBohzALjQsXbrJtRksRgntzm7nVX4GnZumtC4D23N4aIAZWdv9LyZv+3IA87AlHY1HQu9+q7Qwb7nAQ01FbQ+g5NBaNOKA2jdD0bg4+UjzCrbqu6IgrLB6aLRF6KWB0ZNUj15QvLCRVa8PNanqiq7pM7kbVXDEvdaipMmHIRfBa2//aYC9WI5vjH6ydLsB1ezpePiK9PhYcoLnjSK5kljNUWqvXppKdVxo4XFhIsJ93gXy/8clxIvt0X7i4XrU8+1D+wGgKPGW/UCzHfew9VsXywVZxbz8GYdKqS4rCTfZ/NZvD8WA/Yxu/aW661F7q+cIbsXVO6EcVf3b0t9SIXFx9N+kwEO3w8QVmhggq+/9xSroVdiv5TZlr0SanL6/KXOK5SaL9b/G4DRdDzONZbPuAjXS4bnfPWBPrJkjhzpYbdR8OeXz62nvBt3HD3z3F/2f0Fyx9O7XL2HAoj7YG33AK8Bag4TrJlOa0DrrVtrj7DsPBtKlgstsZGIcOW+B0wvlMP1EOqcCh1rTldb+/Xcw2woqbaLeh/Vbl7vH/Vgx08TABrehO53ccJKK1ZWP+gjpRqAKdaN8jxLs5r7Bx5TMBm18kjxOOZ0ub/3flUW/nzw4PSJp568CT0vYXq5aGJgslc4o7doPI6dcis2eUq950Ug1DqF9NvQ/uVf79y5v+E1IptedEInNj+iT2L9Nfv9jf7gI/pFdP4D5rfoaYw/Lv+pReVRq/JOEEXOee/PAf7/PP8C3bt510T4rIwAAAAASUVORK5CYII=",Bt=ot({}),zt=ot({});function Wt(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.15?"#D8CB2A":i>.05?"#7ED321":"#58984f"}function qt(i,e,t){const s=i.slice();return s[21]=e[t],s}function jt(i){let e,t,s,n,a,o,r,l,f,g,p,d,v,m,b,E,C;return{c(){e=h("div"),t=h("div"),s=V("svg"),n=V("path"),a=y(),o=h("div"),r=I(i[6]),l=y(),f=h("div"),g=I(i[4]),p=y(),d=h("div"),v=I(i[5]),m=y(),b=h("div"),c(n,"d","M.937-.016L5.793 4.84.937 9.696z"),c(n,"fill",i[8]),c(n,"fill-rule","evenodd"),c(n,"fill-opacity",".582"),c(s,"width","6"),c(s,"height","10"),c(t,"class","frame-triangle svelte-7e9kco"),Ae(t,"rotate",!i[9]),G(t,"visibility",i[0].children.length>0?"visible":"hidden"),c(o,"class","time svelte-7e9kco"),G(o,"color",i[8]),G(o,"font-weight",i[11]<.15?500:600),c(f,"class","name svelte-7e9kco"),c(d,"class","code-position svelte-7e9kco"),c(e,"class","frame-description svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),Ae(e,"application-code",i[0].isApplicationCode),Ae(e,"children-visible",!i[9]),G(e,"padding-left",`${i[2]*35}px`),c(b,"class","visual-guide svelte-7e9kco"),G(b,"left",`${i[2]*35+21}px`),G(b,"background-color",i[8])},m(w,k){L(w,e,k),u(e,t),u(t,s),u(s,n),u(e,a),u(e,o),u(o,r),u(e,l),u(e,f),u(f,g),u(e,p),u(e,d),u(d,v),L(w,m,k),L(w,b,k),E||(C=[N(e,"keydown",i[14]),N(e,"click",_t(gt(i[12])))],E=!0)},p(w,k){k&256&&c(n,"fill",w[8]),k&512&&Ae(t,"rotate",!w[9]),k&1&&G(t,"visibility",w[0].children.length>0?"visible":"hidden"),k&64&&_e(r,w[6]),k&256&&G(o,"color",w[8]),k&16&&_e(g,w[4]),k&32&&_e(v,w[5]),k&1&&Ae(e,"application-code",w[0].isApplicationCode),k&512&&Ae(e,"children-visible",!w[9]),k&4&&G(e,"padding-left",`${w[2]*35}px`),k&4&&G(b,"left",`${w[2]*35+21}px`),k&256&&G(b,"background-color",w[8])},d(w){w&&(S(e),S(m),S(b)),E=!1,oe(C)}}}function Yt(i){let e,t,s,n,a=i[0].group.frames.length-1+"",o,r,l,f,g,p;return{c(){e=h("div"),t=h("div"),s=h("div"),s.innerHTML='',n=y(),o=I(a),r=I(" frames hidden ("),l=I(i[7]),f=I(")"),c(s,"class","group-triangle svelte-7e9kco"),Ae(s,"rotate",i[10]),c(t,"class","group-header-button svelte-7e9kco"),c(e,"class","group-header svelte-7e9kco"),c(e,"role","button"),c(e,"tabindex","0"),G(e,"padding-left",`${i[2]*35}px`)},m(d,v){L(d,e,v),u(e,t),u(t,s),u(t,n),u(t,o),u(t,r),u(t,l),u(t,f),g||(p=[N(e,"keydown",i[15]),N(e,"click",_t(gt(i[13])))],g=!0)},p(d,v){v&1024&&Ae(s,"rotate",d[10]),v&1&&a!==(a=d[0].group.frames.length-1+"")&&_e(o,a),v&128&&_e(l,d[7]),v&4&&G(e,"padding-left",`${d[2]*35}px`)},d(d){d&&S(e),g=!1,oe(p)}}}function Ut(i){let e,t=[],s=new Map,n,a=nt(i[0].children);const o=r=>r[21].uuid;for(let r=0;r0&&Ut(i);return{c(){e=h("div"),a&&a.c(),t=y(),o&&o.c(),s=y(),r&&r.c(),c(e,"class","frame svelte-7e9kco")},m(l,f){L(l,e,f),a&&a.m(e,null),u(e,t),o&&o.m(e,null),u(e,s),r&&r.m(e,null),n=!0},p(l,[f]){l[3]?a?a.p(l,f):(a=jt(l),a.c(),a.m(e,t)):a&&(a.d(1),a=null),l[0].group&&l[0].group.rootFrame==l[0]&&!l[9]?o?o.p(l,f):(o=Yt(l),o.c(),o.m(e,s)):o&&(o.d(1),o=null),!l[9]&&l[0].children.length>0?r?(r.p(l,f),f&513&&O(r,1)):(r=Ut(l),r.c(),O(r,1),r.m(e,null)):r&&(Ce(),D(r,1,1,()=>{r=null}),Me())},i(l){n||(O(r),n=!0)},o(l){D(r),n=!1},d(l){l&&S(e),a&&a.d(),o&&o.d(),r&&r.d()}}}function Gt(){const i='a:not([disabled]), button:not([disabled]), input[type=text]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])',e=document.querySelector(".call-stack-view");if(!e)throw new Error("callStackElement not found");var t=Array.prototype.filter.call(e.querySelectorAll(i),function(s){return s.offsetWidth>0||s.offsetHeight>0||s===document.activeElement});return t}function Zt(){const i=Gt();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e+1];t&&t.focus()}}function Kt(){const i=Gt();var e=i.indexOf(document.activeElement);if(e>-1){var t=i[e-1];t&&t.focus()}}function ws(i,e,t){let s,n,a,o,r;ge(i,zt,_=>t(16,a=_)),ge(i,Bt,_=>t(17,o=_)),ge(i,Z,_=>t(18,r=_));let{frame:l}=e,{rootFrame:f}=e,{indent:g=0}=e,p;const d=l.time/f.time;let v,m;l.isSynthetic||l.filePathShort==null?m="":l.lineNo==null||l.lineNo===0?m=l.filePathShort:m=`${l.filePathShort}:${l.lineNo}`;let b,E=null;if(l.group){const _=l.group.libraries;_.length<4?E=_.join(", "):E=`${_[0]}, ${_[1]}, ${_[2]}...`}let C;C=Wt(d);function w(_){k(l,!n,_.altKey)}function k(_,A,R=!0){if(zt.update(B=>({...B,[_.uuid]:A})),R)for(const B of _.children)k(B,A,!0),_.group&&_.group.rootFrame==_&&H(_.group.id,!A)}function H(_,A){Bt.update(R=>({...R,[_]:A}))}function W(){l.group&&H(l.group.id,!s)}function P(_){let A=!0;_.key==="Enter"||_.key===" "?w(_):_.key==="ArrowLeft"&&!n?k(l,!0,_.altKey):_.key==="ArrowRight"&&n?k(l,!1,_.altKey):_.key==="ArrowUp"?Kt():_.key==="ArrowDown"?Zt():A=!1,A&&(_.preventDefault(),_.stopPropagation())}function M(_){let A=!0;_.key==="Enter"||_.key===" "?W():_.key==="ArrowLeft"&&l.group?H(l.group.id,!1):_.key==="ArrowRight"&&l.group?H(l.group.id,!0):_.key==="ArrowUp"?Kt():_.key==="ArrowDown"?Zt():A=!1,A&&(_.preventDefault(),_.stopPropagation())}return i.$$set=_=>{"frame"in _&&t(0,l=_.frame),"rootFrame"in _&&t(1,f=_.rootFrame),"indent"in _&&t(2,g=_.indent)},i.$$.update=()=>{var _,A;if(i.$$.dirty&131073&&(l.group?o[l.group.id??""]||((_=l.group)==null?void 0:_.rootFrame)===l||l.children.filter(R=>!R.group).length>1?t(3,p=!0):t(3,p=!1):t(3,p=!0)),i.$$.dirty&1&&(l.className?t(4,v=`${l.className}.${l.function}`):t(4,v=l.function)),i.$$.dirty&262145)if(r.timeFormat==="absolute")t(6,b=l.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(r.timeFormat==="proportion")t(6,b=`${(d*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(10,s=o[((A=l.group)==null?void 0:A.id)??""]===!0),i.$$.dirty&65537&&t(9,n=a[l.uuid]===!0)},[l,f,g,p,v,m,b,E,C,n,s,d,w,W,P,M,a,o,r]}let Qt=class extends de{constructor(e){super(),fe(this,e,ws,bs,re,{frame:0,rootFrame:1,indent:2})}};function Jt(i,e,t){let s=i;if(s!=null)for(const n of Object.keys(i)){let a=i[n];for(const o of e)if(a=o(a,t),!a){delete s[n];break}s[n]=a}return s}const ys="\0",Ts="[await]",Ze="[self]",ks=[Ts,Ze,"[out-of-context]","[root]"],As="c",Es="h";class Ke{constructor(e,t){T(this,"uuid",rt());T(this,"identifier");T(this,"_identifierParts");T(this,"startTime");T(this,"time",0);T(this,"absorbedTime",0);T(this,"group",null);T(this,"attributes");T(this,"_children",[]);T(this,"parent",null);T(this,"context");var a;this.identifier=e.identifier,this._identifierParts=this.identifier.split(ys),this.startTime=e.startTime??t.threadStartTime(e.thread_id),this.time=e.time??0,this.attributes=e.attributes??{},this.context=t;let s=this.startTime;const n=(a=e.children)==null?void 0:a.map(o=>(o.startTime===void 0&&(o={...o,startTime:s},s+=o.time??0),s=o.startTime+(o.time??0),new Ke(o,t)));n&&this.addChildren(n)}cloneDeep(){return new Ke(this,this.context)}get children(){return this._children}addChild(e,t={}){if(e.removeFromParent(),e.parent=this,t.after){const s=this._children.indexOf(t.after);if(s==-1)throw new Error("After frame not found");this._children.splice(s+1,0,e)}else this._children.push(e)}addChildren(e,t={}){e=e.slice(),t.after?(e.slice().reverse(),e.forEach(n=>this.addChild(n,t))):e.forEach(s=>this.addChild(s,t))}removeFromParent(){if(this.parent){const e=this.parent._children.indexOf(this);this.parent._children.splice(e,1),this.parent=null}}getAttributes(e){return Object.keys(this.attributes).filter(s=>s.startsWith(e)).map(s=>({data:s.slice(1),time:this.attributes[s]}))}getAttributeValue(e){const t=this.getAttributes(e);if(!t||t.length==0)return null;let s=0;for(let n=0;nt[s].time&&(s=n);return t[s].data}get hasTracebackHide(){return this.getAttributeValue(Es)=="1"}get function(){return this._identifierParts[0]}get filePath(){return this._identifierParts[1]??null}get lineNo(){const e=this._identifierParts[2];return e?parseInt(e):null}get isSynthetic(){return ks.includes(this.identifier)}get filePathShort(){return this.isSynthetic&&this.parent?this.parent.filePathShort:this.filePath?this.context.shortenPath(this.filePath):null}get isApplicationCode(){if(this.isSynthetic)return!1;const e=this.filePath;return!e||this.context.sysPrefixes.some(s=>e.startsWith(s))?!1:e.startsWith("<")?e.startsWith(""||e==""?this.parent?this.parent.isApplicationCode:!0:!1:!0}get proportionOfParent(){return this.parent?this.time/this.parent.time:1}get className(){return this.getAttributeValue(As)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class Cs{constructor(e){T(this,"id");T(this,"rootFrame");T(this,"_frames",[]);this.id=rt(),this.rootFrame=e}addFrame(e){e.group&&e.group.removeFrame(e),this._frames.push(e),e.group=this}removeFrame(e){if(e.group!==this)throw new Error("Frame not in group.");const t=this._frames.indexOf(e);if(t===-1)throw new Error("Frame not found in group.");this._frames.splice(t,1),e.group=null}get frames(){return this._frames}get exitFrames(){const e=[];for(const t of this.frames){let s=!1;for(const n of t.children)if(n.group!=this){s=!0;break}s&&e.push(t)}return e}get libraries(){const e=[];for(const t of this.frames){const s=t.library;s&&(e.includes(s)||e.push(s))}return e}}function lt(i,e){const{replaceWith:t}=e,s=i.parent;if(!s)throw new Error("Cannot delete the root frame");if(t=="children")s.addChildren(i.children,{after:i});else if(t=="self_time")s.addChild(new Ke({identifier:Ze,time:i.time},s.context),{after:i});else if(t=="nothing")s.absorbedTime+=i.time;else throw new Zi(t);i.removeFromParent(),Ft(i,!0)}function Ms(i,e){if(i.parent!==e.parent)throw new Error("Both frames must have the same parent.");e.absorbedTime+=i.absorbedTime,e.time+=i.time,Object.entries(i.attributes).forEach(([t,s])=>{e.attributes[t]!==void 0?e.attributes[t]+=s:e.attributes[t]=s}),e.addChildren(i.children),i.removeFromParent(),Ft(i,!1)}function Ft(i,e){if(e&&i.children&&i.children.forEach(t=>{Ft(t,!0)}),i.group){const t=i.group;t.removeFrame(i),t.frames.length===1&&t.removeFrame(t.frames[0])}}function Pt(i,e){if(!i)return null;for(const t of i.children)Pt(t),t.filePath&&t.filePath.includes("ei(s)),i._children.sort((s,n)=>n.time-s.time),i}function ti(i,e){if(!i)return null;const t=e.hideRegex,s=e.showRegex;function n(o){const r=o.filePath||"",l=s&&new RegExp(s).test(r),f=t&&new RegExp(t).test(r);return l?!1:f?!0:!o.isApplicationCode}function a(o,r){r.addFrame(o),o.children.forEach(l=>{n(l)&&a(l,r)})}return i.children.forEach(o=>{if(!o.group&&n(o)&&o.children.some(n)){const r=new Cs(o);a(o,r)}ti(o,e)}),i}function ii(i,e,t=!0){if(!i)return null;let s=null;for(const n of i.children)n.identifier===Ze?s?(s.time+=n.time,n.removeFromParent()):s=n:s=null;return t&&i.children.forEach(n=>ii(n,e,!0)),i}function si(i,e){return i?(i.children.length===1&&i.children[0].identifier===Ze&<(i.children[0],{replaceWith:"nothing"}),i.children.forEach(t=>si(t)),i):null}function ni(i,e,t=null){if(!i)return null;t===null&&(t=i.time,t<=0&&(t=1e-44));const s=e.filterThreshold??.01;for(const n of i.children.slice())n.time/tni(n,e,t)),i}function oi(i,e){if(!i)return null;const t=r=>ss(r,l=>l.time),s=r=>{var l;return((l=r.filePath)==null?void 0:l.includes("pyinstrument/__main__.py"))&&r.children.length>0},n=r=>{var l;return r.proportionOfParent>.8&&((l=r.filePath)==null?void 0:l.includes(""))&&r.children.length>0},a=r=>{var l;return r.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(r.filePath??"")||((l=r.filePath)==null?void 0:l.includes("")))&&r.children.length>0};let o=i;if(!s(o)||(o=t(o.children),!n(o))||(o=t(o.children),!a(o)))return i;for(;a(o);)o=t(o.children);return o.removeFromParent(),o}function ri(i,e){return i?(i.children.forEach(t=>ri(t)),i.group&&i.group.frames.length<3&&i.group.removeFrame(i),i):null}function li(i,e,t){const s=i.slice();return s[11]=e[t][0],s[12]=e[t][1],s}function Fs(i){let e,t,s=nt(Object.entries(i[3])),n=[];for(let o=0;oD(n[o],1,1,()=>{n[o]=null});return{c(){e=h("div");for(let o=0;oAll frames were filtered out.
',c(e,"class","margins")},m(t,s){L(t,e,s)},p:F,i:F,o:F,d(t){t&&S(e)}}}function Rs(i){let e,t;return e=new Qt({props:{frame:i[12],rootFrame:i[12]}}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},p(s,n){const a={};n&8&&(a.frame=s[12]),n&8&&(a.rootFrame=s[12]),e.$set(a)},i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function Ss(i){let e;return{c(){e=h("div"),e.innerHTML='
All frames were filtered out.
',c(e,"class","margins")},m(t,s){L(t,e,s)},p:F,i:F,o:F,d(t){t&&S(e)}}}function ai(i){let e,t,s,n;const a=[Ss,Rs],o=[];function r(l,f){return l[12]?1:0}return e=r(i),t=o[e]=a[e](i),{c(){t.c(),s=Dt()},m(l,f){o[e].m(l,f),L(l,s,f),n=!0},p(l,f){let g=e;e=r(l),e===g?o[e].p(l,f):(Ce(),D(o[g],1,1,()=>{o[g]=null}),Me(),t=o[e],t?t.p(l,f):(t=o[e]=a[e](l),t.c()),O(t,1),t.m(s.parentNode,s))},i(l){n||(O(t),n=!0)},o(l){D(t),n=!1},d(l){l&&S(s),o[e].d(l)}}}function Is(i){let e,t,s,n,a,o,r;const l=[Ps,Fs],f=[];function g(p,d){return p[3]?1:0}return s=g(i),n=f[s]=l[s](i),{c(){e=h("div"),t=h("div"),n.c(),a=y(),o=h("div"),c(t,"class","scroll-inner svelte-1hebm9u"),c(o,"class","scroll-size-fixer svelte-1hebm9u"),c(e,"class","call-stack-view svelte-1hebm9u")},m(p,d){L(p,e,d),u(e,t),f[s].m(t,null),i[8](t),u(e,a),u(e,o),i[9](o),i[10](e),r=!0},p(p,[d]){let v=s;s=g(p),s===v?f[s].p(p,d):(Ce(),D(f[v],1,1,()=>{f[v]=null}),Me(),n=f[s],n?n.p(p,d):(n=f[s]=l[s](p),n.c()),O(n,1),n.m(t,null))},i(p){r||(O(n),r=!0)},o(p){D(n),r=!1},d(p){p&&S(e),f[s].d(),i[8](null),i[9](null),i[10](null)}}}function Ls(i,e,t){let s,{session:n}=e;const a=Vt([Z],([m])=>{const b=[m.removeImportlib?Pt:null,m.removeTracebackHide?Rt:null,ii,ei,si,m.removeIrrelevant?ni:null,m.removePyinstrument?oi:null,m.collapseMode!=="disabled"?ti:null,ri].filter(C=>C!==null),E={filterThreshold:m.removeIrrelevantThreshold,hideRegex:m.collapseMode=="custom"?m.collapseCustomHide:void 0,showRegex:m.collapseMode=="custom"?m.collapseCustomShow:void 0};return{processors:b,options:E}});ge(i,a,m=>t(7,s=m));let o,r,l;yt(()=>{let m=0;const b=o;if(!b)throw new Error("element not set");if(!r)throw new Error("scrollInnerElement not set");if(!l)throw new Error("scrollSizeFixerElement not set");const E=new ResizeObserver(()=>{const w=r.getBoundingClientRect().height;w>m&&(m=w,t(2,l.style.top=`${m-1}px`,l))});E.observe(r);let C;return b.addEventListener("scroll",C=()=>{let w=b.scrollTop+b.clientHeight;const k=r.getBoundingClientRect().height;w{E.disconnect(),b.removeEventListener("scroll",C)}});let f,g=[];for(const m of Object.keys(n.rootFrames))g[m]=n.rootFrames[m].cloneDeep();function p(m){Ee[m?"unshift":"push"](()=>{r=m,t(1,r)})}function d(m){Ee[m?"unshift":"push"](()=>{l=m,t(2,l)})}function v(m){Ee[m?"unshift":"push"](()=>{o=m,t(0,o)})}return i.$$set=m=>{"session"in m&&t(5,n=m.session)},i.$$.update=()=>{i.$$.dirty&192&&t(3,f=Jt(g,s.processors,s.options))},[o,r,l,f,a,n,g,s,p,d,v]}class Os extends de{constructor(e){super(),fe(this,e,Ls,Is,re,{session:5})}}class Ds{constructor(e){T(this,"mediaQueryList",null);this.onDevicePixelRatioChanged=e,this._onChange=this._onChange.bind(this),this.createMediaQueryList()}createMediaQueryList(){this.removeMediaQueryList();let e=`(resolution: ${window.devicePixelRatio}dppx)`;this.mediaQueryList=matchMedia(e),this.mediaQueryList.addEventListener("change",this._onChange)}removeMediaQueryList(){var e;(e=this.mediaQueryList)==null||e.removeEventListener("change",this._onChange),this.mediaQueryList=null}_onChange(e){this.onDevicePixelRatioChanged(),this.createMediaQueryList()}destroy(){this.removeMediaQueryList()}}class Hs{constructor(e){T(this,"canvas");T(this,"_size_observer");T(this,"_devicePixelRatioObserver");T(this,"drawAnimationRequest",null);this.container=e,getComputedStyle(e).position!="absolute"&&(e.style.position="relative"),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.container.appendChild(this.canvas),this.setCanvasSize=this.setCanvasSize.bind(this),this._size_observer=new ResizeObserver(this.setCanvasSize),this._size_observer.observe(e),this._devicePixelRatioObserver=new Ds(this.setCanvasSize),window.requestAnimationFrame(()=>{this.setCanvasSize()})}destroy(){this._size_observer.disconnect(),this._devicePixelRatioObserver.destroy(),this.canvas.remove(),this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null)}setNeedsRedraw(){this.drawAnimationRequest===null&&(this.drawAnimationRequest=window.requestAnimationFrame(()=>{this.drawAnimationRequest=null,this.canvasViewRedraw()}))}redrawIfNeeded(){this.drawAnimationRequest!==null&&(window.cancelAnimationFrame(this.drawAnimationRequest),this.drawAnimationRequest=null,this.canvasViewRedraw())}canvasViewRedraw(){const e=this.canvas.getContext("2d");e&&(e.resetTransform(),e.scale(window.devicePixelRatio,window.devicePixelRatio),this.redraw(e,{width:this.canvas.width/window.devicePixelRatio,height:this.canvas.height/window.devicePixelRatio}))}get width(){return this.canvas.width/window.devicePixelRatio}get height(){return this.canvas.height/window.devicePixelRatio}setCanvasSize(){const e=window.devicePixelRatio;this.canvas.height=this.container.clientHeight*e,this.canvas.width=this.container.clientWidth*e,this.canvasViewRedraw()}}function xs(i){let e,t=i[2]=="self"?"self":"time",s,n,a,o=i[3](i[0].time)+"";return{c(){e=h("div"),s=I(t),n=y(),a=h("div"),c(e,"class","label svelte-ci3g2p"),c(a,"class","time-val svelte-ci3g2p")},m(r,l){L(r,e,l),u(e,s),L(r,n,l),L(r,a,l),a.innerHTML=o},p(r,l){l&4&&t!==(t=r[2]=="self"?"self":"time")&&_e(s,t),l&1&&o!==(o=r[3](r[0].time)+"")&&(a.innerHTML=o)},d(r){r&&(S(e),S(n),S(a))}}}function Vs(i){let e,t,s,n,a=i[3](i[0].time)+"",o,r=i[0].selfTime/i[0].time>.001&&ci(i);return{c(){e=h("div"),e.textContent="time",t=y(),s=h("div"),n=h("div"),o=y(),r&&r.c(),c(e,"class","label svelte-ci3g2p"),c(n,"class","time-val svelte-ci3g2p"),c(s,"class","time-row svelte-ci3g2p")},m(l,f){L(l,e,f),L(l,t,f),L(l,s,f),u(s,n),n.innerHTML=a,u(s,o),r&&r.m(s,null)},p(l,f){f&1&&a!==(a=l[3](l[0].time)+"")&&(n.innerHTML=a),l[0].selfTime/l[0].time>.001?r?r.p(l,f):(r=ci(l),r.c(),r.m(s,null)):r&&(r.d(1),r=null)},d(l){l&&(S(e),S(t),S(s)),r&&r.d()}}}function ci(i){let e,t,s,n=i[3](i[0].selfTime)+"";return{c(){e=h("div"),e.textContent="self",t=y(),s=h("div"),c(e,"class","label svelte-ci3g2p"),c(s,"class","time-val svelte-ci3g2p")},m(a,o){L(a,e,o),L(a,t,o),L(a,s,o),s.innerHTML=n},p(a,o){o&1&&n!==(n=a[3](a[0].selfTime)+"")&&(s.innerHTML=n)},d(a){a&&(S(e),S(t),S(s))}}}function Ns(i){let e,t,s=i[0].name+"",n,a,o,r,l,f,g,p,d,v;function m(C,w){return C[2]=="both"?Vs:xs}let b=m(i),E=b(i);return{c(){e=h("div"),t=h("div"),n=I(s),a=y(),E.c(),o=y(),r=h("div"),r.textContent="loc",l=y(),f=h("div"),g=h("div"),d=y(),v=new Li(!1),c(t,"class","name svelte-ci3g2p"),c(r,"class","label svelte-ci3g2p"),c(g,"class","location-color svelte-ci3g2p"),c(g,"style",p=`background: ${i[0].locationColor}`),v.a=null,c(f,"class","location-row"),c(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),c(e,"style",`font: ${fi}; max-width: ${Bs}px;`)},m(C,w){L(C,e,w),u(e,t),u(t,n),u(e,a),E.m(e,null),u(e,o),u(e,r),u(e,l),u(e,f),u(f,g),u(f,d),v.m(i[1],f)},p(C,[w]){w&1&&s!==(s=C[0].name+"")&&_e(n,s),b===(b=m(C))&&E?E.p(C,w):(E.d(1),E=b(C),E&&(E.c(),E.m(e,o))),w&1&&p!==(p=`background: ${C[0].locationColor}`)&&c(g,"style",p),w&2&&v.p(C[1])},i:F,o:F,d(C){C&&S(e),E.d()}}}function ui(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function $s(i,e){i.font=fi;const t=ui(e)=="both"?140:70,s=i.measureText(e.name).width,n=i.measureText(e.location).width+46;let o=Math.max(t,s,n)+20;return o>310&&(o=310),o}const Bs=310,fi="400 13px Source Sans Pro, sans-serif";function zs(i,e,t){let{f:s}=e,n,a;function o(r){return`${r.toFixed(3)}`}return i.$$set=r=>{"f"in r&&t(0,s=r.f)},i.$$.update=()=>{i.$$.dirty&1&&t(1,n=Mt(s.location)),i.$$.dirty&1&&t(2,a=ui(s))},[s,n,a,o]}class Ws extends de{constructor(e){super(),fe(this,e,zs,Ns,re,{f:0})}}const qs="#212325",di=18,js=17,Le=28,at=17,hi=29,Ys=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"].map(es);class Us extends Hs{constructor(t){super(t);T(this,"zoom",1);T(this,"startT",0);T(this,"yOffset",0);T(this,"frames",{});T(this,"isZoomedIn",!1);T(this,"tooltipContainer");T(this,"tooltipComponent",null);T(this,"_rootFrames",null);T(this,"maxDepth",[]);T(this,"maxY",0);T(this,"tooltipLocation",null);T(this,"lastDrawWidth",0);T(this,"lastDrawHeight",0);T(this,"_libraryOrder",null);T(this,"_colors",[]);T(this,"_frameMaxT");T(this,"mouseLocation",null);T(this,"mouseDownLocation",null);T(this,"touches",{});this.onWheel=this.onWheel.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.windowMouseUp=this.windowMouseUp.bind(this),this.onTouchstart=this.onTouchstart.bind(this),this.onTouchmove=this.onTouchmove.bind(this),this.onTouchend=this.onTouchend.bind(this),this.onTouchcancel=this.onTouchend.bind(this),this.canvas.addEventListener("wheel",this.onWheel),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseleave",this.onMouseLeave),this.canvas.addEventListener("mousedown",this.onMouseDown),this.canvas.addEventListener("touchstart",this.onTouchstart),this.canvas.addEventListener("touchmove",this.onTouchmove),this.canvas.addEventListener("touchend",this.onTouchend),this.canvas.addEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer=document.createElement("div"),this.tooltipContainer.style.position="absolute",this.tooltipContainer.style.pointerEvents="none",this.container.appendChild(this.tooltipContainer)}destroy(){this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("touchstart",this.onTouchstart),this.canvas.removeEventListener("touchmove",this.onTouchmove),this.canvas.removeEventListener("touchend",this.onTouchend),this.canvas.removeEventListener("touchcancel",this.onTouchcancel),this.tooltipContainer.remove(),super.destroy()}setRootFrames(t){this._rootFrames=t,this.frames={},this._frameMaxT=void 0,this.maxDepth=[],this.maxY=0;for(const s of Object.keys(t)){let n=t[s];this._collectFrames(n,s,0),this.maxY+=this.maxDepth[s]+1}this.fitContents(),this.setNeedsRedraw()}_collectFrames(t,s,n){this.frames.hasOwnProperty(s)||(this.frames[s]=[],this.maxDepth[s]=0),this.frames[s].push({frame:t,depth:n,isApplicationCode:t.isApplicationCode,library:t.library,className:t.className,filePathShort:t.filePathShort}),this.maxDepth[s]=Math.max(this.maxDepth[s],n);for(const a of t.children)a.identifier!==Ze&&this._collectFrames(a,s,n+1)}updateTooltip(t,s){var n;if(s){const a={name:this.frameName(s),time:s.frame.time,selfTime:this.frameSelfTime(s),totalTime:((n=this._rootFrames[s.frame.thread_id])==null?void 0:n.time)??1e-12,location:`${s.filePathShort}:${s.frame.lineNo}`,locationColor:this.colorForFrame(s)};if(this.tooltipComponent?this.tooltipComponent.$set({f:a}):this.tooltipComponent=new Ws({target:this.tooltipContainer,props:{f:a}}),this.tooltipLocation){const o={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},r=$s(t,a),l=this.width-10-r;o.x>l&&(o.x=l);const g=this.height-10-60;o.y>g&&(o.y=g),this.tooltipContainer.style.left=`${o.x}px`,this.tooltipContainer.style.top=`${o.y}px`}}s||this.tooltipComponent&&(this.tooltipComponent.$destroy(),this.tooltipComponent=null)}redraw(t,s){const{width:n,height:a}=s;(n!==this.lastDrawWidth||a!==this.lastDrawHeight)&&(this.isZoomedIn?this.clampViewport():this.fitContents()),this.lastDrawWidth=n,this.lastDrawHeight=a,t.fillStyle=qs,t.fillRect(0,0,n,a),this.drawAxes(t);let o=0;for(const g of Object.keys(this.frames)){for(const p of this.frames[g])this.drawFrame(t,p,o);o+=1+this.maxDepth[g]}t.globalAlpha=1;const r=this.maxYOffset>0||this.isZoomedIn,l=!!this.mouseDownLocation;this.canvas.style.cursor=l&&r?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let f=null;!l&&this.tooltipLocation&&(f=this.hitTest(this.tooltipLocation)),this.updateTooltip(t,f)}drawAxes(t){const s=Math.max(800,this.width)/this.zoom;if(s==0)return;const n=Math.log10(s);let a=Math.ceil(n)+2;a<0&&(a=0);const o=Math.ceil(n)-3,r=l=>Ne(l,{from:[n,n-3],to:[.71,0],clamp:!0});for(let l=o;l.01){t.globalAlpha=v,t.font='13px "Source Sans Pro", sans-serif';let m=f.toFixed(l);m=="0"&&(m="0s");let b=d+10;t.fillText(m,g+3,b);let E=this.height+at+10-this.yOffset;Ethis.width)return;if(t.fillStyle=this.colorForFrame(s),t.globalAlpha=s.isApplicationCode?1:.5,r<2){t.fillRect(a,o,r,l);return}let g=this.frameName(s);const p=Math.floor(r/3.3);if(g.length>p&&(g=g.substring(0,p)),g.length==0){t.fillRect(a,o,r,l);return}t.save(),t.beginPath(),t.rect(a,o,r,l),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let d=a;d<0&&(d=0),t.fillText(g,d+2,o+13),t.restore()}_assignLibraryOrder(){const t={};for(const n of Object.keys(this.frames))for(const a of this.frames[n]){const r=a.frame.library??"";t[r]=(t[r]||0)+a.frame.time}const s=Object.keys(t);s.sort((n,a)=>t[a]-t[n]),this._libraryOrder=s}colorForLibraryIndex(t){if(this._colors[t]!==void 0)return this._colors[t];const s=Math.pow(2,Math.ceil(Math.log2(t+1))),a=(2*t-s+1)/s,o=Ki(Ys,a);return this._colors[t]=o,o}libraryIndexForFrame(t){this._libraryOrder||this._assignLibraryOrder();const s=t.library||"";let n=this._libraryOrder.indexOf(s);return n===-1&&(n=this._libraryOrder.length,this._libraryOrder.push(s)),n}colorForFrame(t){const s=this.libraryIndexForFrame(t);return this.colorForLibraryIndex(s)}get frameMaxT(){if(this._frameMaxT===void 0){this._frameMaxT=0;for(const t of Object.keys(this.frames))this._frameMaxT=Math.max(this._frameMaxT,this.frames[t].reduce((s,n)=>Math.max(s,n.frame.startTime+n.frame.time),0))}return this._frameMaxT}get maxYOffset(){return Math.max(0,(this.maxY+1)*di+at*2+hi-this.height)}get minZoom(){return(this.width-2*Le)/this.frameMaxT}get maxZoom(){return 6666666666666667e-8}fitContents(){this.startT=0,this.zoom=this.minZoom,this.isZoomedIn=!1}clampViewport(){this.zoomthis.maxZoom&&(this.zoom=this.maxZoom),this.startT<0&&(this.startT=0);const t=this.frameMaxT-(this.width-2*Le)/this.zoom;this.startT>t&&(this.startT=t),this.yOffset>this.maxYOffset&&(this.yOffset=this.maxYOffset)}frameDims(t,s){const n=(s+t.depth)*di+at+hi-this.yOffset,a=js;let o=this.xForT(t.frame.startTime),l=this.xForT(t.frame.startTime+t.frame.time)-o;return l<1&&(l=1),l>1&&(l-=Ne(l,{from:[1,3],to:[0,1],clamp:!0})),{x:o,y:n,w:l,h:a}}xForT(t){return(t-this.startT)*this.zoom+Le}tForX(t){return(t-Le)/this.zoom+this.startT}frameName(t){let s;return t.className?s=`${t.className}.${t.frame.function}`:t.frame.function==""?s=t.filePathShort??t.frame.filePath??"":s=t.frame.function,s}frameSelfTime(t){let s=t.frame.time;const n=t.frame.children.filter(a=>!a.isSynthetic);for(const a of n)s-=a.time;return s}hitTest(t){for(const s of Object.keys(this.frames))for(const n of this.frames[s]){const{x:a,y:o,w:r,h:l}=this.frameDims(n);if(t.x>=a&&t.x<=a+r&&t.y>=o&&t.y<=o+l)return n}return null}onWheel(t){const s=t.ctrlKey||t.metaKey,n=s?.01:.0023,a=this.tForX(t.offsetX);this.zoom*=1-t.deltaY*n,this.clampViewport(),this.startT=a-(t.offsetX-Le)/this.zoom,s||(this.startT+=t.deltaX/this.zoom),this.clampViewport(),this.setNeedsRedraw(),t.preventDefault()}onMouseMove(t){const s={x:t.offsetX,y:t.offsetY},n=this.mouseLocation;if(this.mouseLocation=s,n&&this.mouseDownLocation){const a={x:s.x-n.x,y:s.y-n.y};this.startT-=a.x/this.zoom,this.yOffset-=a.y,this.clampViewport()}this.tooltipLocation=s,this.setNeedsRedraw()}onMouseLeave(t){this.mouseLocation=null,this.tooltipLocation=null,this.setNeedsRedraw()}onMouseDown(t){(t.button===0||t.button===1)&&(this.mouseDownLocation={x:t.offsetX,y:t.offsetY},window.addEventListener("mouseup",this.windowMouseUp),this.setNeedsRedraw())}windowMouseUp(t){window.removeEventListener("mouseup",this.windowMouseUp),this.mouseDownLocation=null,this.setNeedsRedraw()}onTouchstart(t){t.preventDefault(),t.stopPropagation();for(const s of Array.from(t.changedTouches))this.touches[s.identifier]={x:s.clientX,y:s.clientY,downT:this.tForX(s.clientX),startDate:Date.now(),downX:s.clientX,downY:s.clientY}}onTouchmove(t){t.preventDefault(),t.stopPropagation();let s=0;for(const a of Array.from(t.changedTouches)){const o=this.touches[a.identifier];o&&(s+=a.clientY-o.y,this.touches[a.identifier]={...o,x:a.clientX,y:a.clientY})}const n=s/Object.keys(this.touches).length;this.yOffset-=n,this.adjustXAxisForTouches(),this.setNeedsRedraw()}onTouchend(t){t.preventDefault(),t.stopPropagation();for(const s of Array.from(t.changedTouches))delete this.touches[s.identifier];this.setNeedsRedraw()}onTouchcancel(t){t.preventDefault(),t.stopPropagation();for(const s of Array.from(t.changedTouches))delete this.touches[s.identifier];this.setNeedsRedraw()}adjustXAxisForTouches(){const t=Object.keys(this.touches).map(Number);if(t.length!=0){if(t.length==1){const s=this.touches[t[0]];this.startT=s.downT-(s.x-Le)/this.zoom}if(t.length>=2){const s=this.touches[t[0]],n=this.touches[t[1]],a=(n.x-s.x)/(n.downT-s.downT),o=s.downT-(s.x-Le)/a;this.startT=o,this.zoom=a}this.clampViewport()}}}function Xs(i){let e;return{c(){e=h("div"),e.innerHTML="",c(e,"class","timeline svelte-p2tt1k")},m(t,s){L(t,e,s),i[7](e)},p:F,i:F,o:F,d(t){t&&S(e),i[7](null)}}}function Gs(i,e,t){let s,{session:n}=e;const a=Vt([Ge],([p])=>({processors:[p.removeImportlib?Pt:null,p.removeTracebackHide?Rt:null,p.removePyinstrument?oi:null].filter(m=>m!==null),options:{}}));ge(i,a,p=>t(6,s=p));let o,r=[];for(const p of Object.keys(n.rootFrames))r[p]=n.rootFrames[p].cloneDeep();let l=null,f=null;Oi(()=>{f==null||f.destroy()});function g(p){Ee[p?"unshift":"push"](()=>{l=p,t(0,l)})}return i.$$set=p=>{"session"in p&&t(2,n=p.session)},i.$$.update=()=>{i.$$.dirty&80&&t(3,o=Jt(r,s.processors,s.options)),i.$$.dirty&1&&l&&t(5,f=new Us(l)),i.$$.dirty&40&&o&&f&&f.setRootFrames(o)},[l,a,n,o,r,f,s,g]}class Zs extends de{constructor(e){super(),fe(this,e,Gs,Xs,re,{session:2})}}function Ks(i){let e,t,s=i[1].viewMode+"",n;return{c(){e=h("div"),t=I("Unknown view mode: "),n=I(s),c(e,"class","error")},m(a,o){L(a,e,o),u(e,t),u(e,n)},p(a,o){o&2&&s!==(s=a[1].viewMode+"")&&_e(n,s)},i:F,o:F,d(a){a&&S(e)}}}function Qs(i){let e,t;return e=new Zs({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},p(s,n){const a={};n&1&&(a.session=s[0]),e.$set(a)},i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function Js(i){let e,t;return e=new Os({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(s,n){ce(e,s,n),t=!0},p(s,n){const a={};n&1&&(a.session=s[0]),e.$set(a)},i(s){t||(O(e.$$.fragment,s),t=!0)},o(s){D(e.$$.fragment,s),t=!1},d(s){ue(e,s)}}}function en(i){let e;return{c(){e=h("div"),e.innerHTML='
No samples recorded.
',c(e,"class","margins")},m(t,s){L(t,e,s)},p:F,i:F,o:F,d(t){t&&S(e)}}}function tn(i){let e,t,s,n,a,o,r,l;s=new gs({props:{session:i[0]}});const f=[en,Js,Qs,Ks],g=[];function p(d,v){return d[0].rootFrames?d[1].viewMode==="call-stack"?1:d[1].viewMode==="timeline"?2:3:0}return o=p(i),r=g[o]=f[o](i),{c(){e=h("div"),t=h("div"),be(s.$$.fragment),n=y(),a=h("div"),r.c(),c(t,"class","header"),c(a,"class","body svelte-1vwroj7"),c(e,"class","app svelte-1vwroj7")},m(d,v){L(d,e,v),u(e,t),ce(s,t,null),u(e,n),u(e,a),g[o].m(a,null),l=!0},p(d,[v]){const m={};v&1&&(m.session=d[0]),s.$set(m);let b=o;o=p(d),o===b?g[o].p(d,v):(Ce(),D(g[b],1,1,()=>{g[b]=null}),Me(),r=g[o],r?r.p(d,v):(r=g[o]=f[o](d),r.c()),O(r,1),r.m(a,null))},i(d){l||(O(s.$$.fragment,d),O(r),l=!0)},o(d){D(s.$$.fragment,d),D(r),l=!1},d(d){d&&S(e),ue(s),g[o].d()}}}function sn(i,e,t){let s;ge(i,Xe,d=>t(1,s=d));let{session:n}=e;const a=document.createElement("link");a.rel="shortcut icon",a.href=_s,document.head.appendChild(a);const o=document.createElement("link");o.rel="preload",o.as="style",o.onload=()=>{o.rel="stylesheet"},o.href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,600|Source+Sans+Pro:400,600&display=swap",document.head.appendChild(o);const r=n.rootFrames;let l=0;if(r!=null)for(const d of Object.keys(r)){const v=r[d];if(v!=null){const m=v.time;m>l&&(l=m)}}const f=l.toLocaleString(void 0,{maximumSignificantDigits:3});let g,p;return(p=/[^\s/]+(:\d+)?$/.exec(n.target_description))?g=p[0]:g=n.target_description,document.title=`${f}s - ${g} - pyinstrument`,i.$$set=d=>{"session"in d&&t(0,n=d.session)},[n,s]}class nn extends de{constructor(e){super(),fe(this,e,sn,tn,re,{session:0})}}class on{constructor(e){T(this,"startTime");T(this,"threadStartTimes");T(this,"duration");T(this,"minInterval");T(this,"maxInterval");T(this,"sampleCount");T(this,"target_description");T(this,"cpuTime");T(this,"rootFrames");T(this,"sysPath");T(this,"sysPrefixes");T(this,"_shortenPathCache",{});this.startTime=e.session.start_time,this.threadStartTimes=e.session.thread_start_times,this.duration=e.session.duration,this.minInterval=e.session.min_interval,this.maxInterval=e.session.max_interval,this.sampleCount=e.session.sample_count,this.target_description=e.session.target_description,this.cpuTime=e.session.cpu_time,this.sysPath=e.session.sys_path,this.sysPrefixes=e.session.sys_prefixes,this.rootFrames={};for(const t of Object.keys(e.frame_trees))this.rootFrames[t]=new Ke(e.frame_trees[t],this)}shortenPath(e){if(this._shortenPathCache[e])return this._shortenPathCache[e];let t=e;if($e(e).length>1)for(const n of this.sysPath){const a=rn(e,n);$e(a).length<$e(t).length&&(t=a)}return this._shortenPathCache[e]=t,t}threadStartTime(e){return this.threadStartTimes.hasOwnProperty(e)?this.threadStartTimes[e]:0}}function $e(i){return i.split(/[/\\]/)}function mi(i){const e=$e(i);return e.length>0&&e[0].endsWith(":")?e[0]:null}function rn(i,e){if(mi(i)!=mi(e))return i;const t=$e(i),s=$e(e);let n=0;for(;n"..").concat(t.slice(n)).join("/")}return{render(i,e){const t=new on(e);return new nn({target:i,props:{session:t}})}}}(); diff --git a/pyinstrument/renderers/jsonrenderer.py b/pyinstrument/renderers/jsonrenderer.py index 5f33e490..ad65a9fe 100644 --- a/pyinstrument/renderers/jsonrenderer.py +++ b/pyinstrument/renderers/jsonrenderer.py @@ -63,7 +63,7 @@ def render_frame(self, frame: Frame | None): return "{%s}" % ",".join(property_decls) def render(self, session: Session): - frame = self.preprocess(session.root_frame()) + frames = self.preprocess(session.root_frames()) property_decls: list[str] = [] property_decls.append('"start_time": %f' % session.start_time) @@ -71,7 +71,8 @@ def render(self, session: Session): property_decls.append('"sample_count": %d' % session.sample_count) property_decls.append('"target_description": %s' % encode_str(session.target_description)) property_decls.append('"cpu_time": %f' % session.cpu_time) - property_decls.append('"root_frame": %s' % self.render_frame(frame)) + property_decls.append('"root_frames": {%s}' % ','.join( + self.render_frame(frame) for frame in frames)) return "{%s}\n" % ",".join(property_decls) diff --git a/pyinstrument/renderers/speedscope.py b/pyinstrument/renderers/speedscope.py index 6bb20581..2963c1cb 100644 --- a/pyinstrument/renderers/speedscope.py +++ b/pyinstrument/renderers/speedscope.py @@ -207,6 +207,7 @@ def render_frame(self, frame: Frame | None) -> list[SpeedscopeEvent]: return events_array def render(self, session: Session): + # FIXME: this is known broken with threads frame = self.preprocess(session.root_frame()) id_: str = time.strftime("%Y-%m-%dT%H-%M-%S", time.localtime(session.start_time)) diff --git a/pyinstrument/session.py b/pyinstrument/session.py index 255ca9de..3a8406df 100644 --- a/pyinstrument/session.py +++ b/pyinstrument/session.py @@ -4,7 +4,7 @@ import os import sys from collections import deque -from typing import Any +from typing import Dict, Any from pyinstrument.frame import Frame from pyinstrument.frame_info import frame_info_get_identifier @@ -25,6 +25,7 @@ def __init__( self, frame_records: list[FrameRecordType], start_time: float, + thread_start_times: Dict[str, float], duration: float, min_interval: float, max_interval: float, @@ -43,6 +44,7 @@ def __init__( """ self.frame_records = frame_records self.start_time = start_time + self.thread_start_times = thread_start_times self.duration = duration self.min_interval = min_interval self.max_interval = max_interval @@ -77,6 +79,7 @@ def save(self, filename: PathOrStr) -> None: def to_json(self, include_frame_records: bool = True): result: dict[str, Any] = { "start_time": self.start_time, + "thread_start_times": self.thread_start_times, "duration": self.duration, "min_interval": self.min_interval, "max_interval": self.max_interval, @@ -98,6 +101,7 @@ def from_json(json_dict: dict[str, Any]): return Session( frame_records=json_dict["frame_records"], start_time=json_dict["start_time"], + thread_start_times=json_dict["thread_start_times"], min_interval=json_dict.get("min_interval", 0.001), max_interval=json_dict.get("max_interval", 0.001), duration=json_dict["duration"], @@ -127,6 +131,7 @@ def combine(session1: Session, session2: Session) -> Session: return Session( frame_records=session1.frame_records + session2.frame_records, start_time=session1.start_time, + thread_start_times=session1.thread_start_times | session2.thread_start_times, min_interval=min(session1.min_interval, session2.min_interval), max_interval=max(session1.max_interval, session2.max_interval), duration=session1.duration + session2.duration, @@ -144,7 +149,11 @@ def combine(session1: Session, session2: Session) -> Session: def current_sys_prefixes() -> list[str]: return [sys.prefix, sys.base_prefix, sys.exec_prefix, sys.base_exec_prefix] + # FIXME: remove after converting all to this def root_frame(self, trim_stem: bool = True) -> Frame | None: + return None + + def root_frames(self, trim_stem: bool = True) -> Dict[str, Frame | None] | None: """ Parses the internal frame records and returns a tree of :class:`Frame` objects. This object can be rendered using a :class:`Renderer` @@ -152,15 +161,18 @@ def root_frame(self, trim_stem: bool = True) -> Frame | None: :rtype: A :class:`Frame` object, or None if the session is empty. """ - root_frame = build_frame_tree(self.frame_records, context=self) + root_frames = build_frame_tree(self.frame_records, context=self) - if root_frame is None: - return None + if root_frames is not None: + for thread_id, root_frame in root_frames.items(): + if root_frame is None: + return None - if trim_stem: - root_frame = self._trim_stem(root_frame) + if trim_stem: + root_frame = self._trim_stem(root_frame) + root_frames[thread_id] = root_frame - return root_frame + return root_frames def _trim_stem(self, frame: Frame): # trim the start of the tree before any branches. diff --git a/pyinstrument/stack_sampler.py b/pyinstrument/stack_sampler.py index e2042bf2..a3cc4d34 100644 --- a/pyinstrument/stack_sampler.py +++ b/pyinstrument/stack_sampler.py @@ -7,7 +7,8 @@ import timeit import types from contextvars import ContextVar -from typing import Any, Callable, List, NamedTuple, Optional +from dataclasses import dataclass +from typing import Any, Callable, Dict, List, NamedTuple, Optional from pyinstrument.low_level.stat_profile import ( get_frame_info, @@ -24,7 +25,15 @@ thread_locals = threading.local() -StackSamplerSubscriberTarget = Callable[[List[str], float, Optional["AsyncState"]], None] +SubscriberCallstackFn = Callable[[List[str], float, Optional["AsyncState"]], None] +SubscriberEventFn = Callable[[str, str, float], None] + + +@dataclass +class StackSamplerSubscriberTarget: + call_stack: SubscriberCallstackFn + event: SubscriberEventFn + IGNORE_OVERHEAD_WARNING = strtobool(os.environ.get("PYINSTRUMENT_IGNORE_OVERHEAD_WARNING", "0")) @@ -38,12 +47,14 @@ def __init__( bound_to_async_context: bool, async_state: AsyncState | None, use_timing_thread: bool | None = None, + child_threads: bool | None = None ) -> None: self.target = target self.desired_interval = desired_interval self.use_timing_thread = use_timing_thread self.bound_to_async_context = bound_to_async_context self.async_state = async_state + self.child_threads = child_threads active_profiler_context_var: ContextVar[object | None] = ContextVar( @@ -56,14 +67,18 @@ class StackSampler: subscribers: list[StackSamplerSubscriber] current_sampling_interval: float | None - last_profile_time: float + current_child_threads: bool | None + last_profile_time: Dict[str, float] + first_profile_time: float | None timer_func: Callable[[], float] | None has_warned_about_timing_overhead: bool def __init__(self) -> None: self.subscribers = [] self.current_sampling_interval = None - self.last_profile_time = 0.0 + self.current_child_threads = None + self.last_profile_time = {} + self.first_profile_time = None self.timer_func = None self.has_warned_about_timing_overhead = False @@ -74,6 +89,7 @@ def subscribe( desired_interval: float, use_timing_thread: bool | None = None, use_async_context: bool, + child_threads: bool | None = None ): if use_async_context: if active_profiler_context_var.get() is not None: @@ -89,6 +105,7 @@ def subscribe( use_timing_thread=use_timing_thread, bound_to_async_context=use_async_context, async_state=AsyncState("in_context") if use_async_context else None, + child_threads=child_threads ) ) self._update() @@ -121,15 +138,25 @@ def _update(self): raise ValueError( f"Profiler requested different timing thread preferences from a profiler that is already running." ) - use_timing_thread = next(iter(timing_thread_preferences), False) - if self.current_sampling_interval != min_subscribers_interval: + child_thread_preferences = set( + s.child_threads for s in self.subscribers if s.child_threads is not None + ) + if len(child_thread_preferences) > 1: + raise ValueError( + f"Profiler requested different child thread preferences from a profiler that is already running." + ) + child_threads = next(iter(child_thread_preferences), False) + + if (self.current_sampling_interval != min_subscribers_interval or + self.current_child_threads != child_threads): self._start_sampling( - interval=min_subscribers_interval, use_timing_thread=use_timing_thread + interval=min_subscribers_interval, use_timing_thread=use_timing_thread, + child_threads=child_threads ) - def _start_sampling(self, interval: float, use_timing_thread: bool): + def _start_sampling(self, interval: float, use_timing_thread: bool, child_threads: bool): if use_timing_thread and self.timer_func is not None: raise ValueError( f"Profiler requested to use the timing thread but this stack sampler is already using a custom timer function." @@ -151,21 +178,37 @@ def _start_sampling(self, interval: float, use_timing_thread: bool): self._check_timing_overhead(interval=interval, timer_type=timer_type) self.current_sampling_interval = interval - if self.last_profile_time == 0.0: - self.last_profile_time = self._timer() - - setstatprofile( - target=self._sample, - interval=interval, - context_var=active_profiler_context_var, - timer_type=timer_type, - timer_func=self.timer_func, - ) + self.current_child_threads = child_threads + if self.first_profile_time is None: + self.first_profile_time = self._timer() + + def _call_setstatprofile(*argv): + setstatprofile( + target=self._sample, + interval=interval, + context_var=active_profiler_context_var, + timer_type=timer_type, + timer_func=self.timer_func, + ) + thread_id = get_thread_id() + if thread_id not in self.last_profile_time: + self.last_profile_time[get_thread_id()] = self._timer() + for subscriber in self.subscribers: + subscriber.target.event( + 'thread_start', thread_id, self._timer()) + + _call_setstatprofile() + + if child_threads: + threading.setprofile(_call_setstatprofile) def _stop_sampling(self): setstatprofile(None) + if self.current_child_threads: + threading.setprofile(None) self.current_sampling_interval = None - self.last_profile_time = 0.0 + self.current_child_threads = None + self.last_profile_time = {} def _sample(self, frame: types.FrameType, event: str, arg: Any): if event == "context_changed": @@ -189,14 +232,19 @@ def _sample(self, frame: types.FrameType, event: str, arg: Any): subscriber.async_state = AsyncState("in_context") else: now = self._timer() - time_since_last_sample = now - self.last_profile_time + thread_id = get_thread_id() + last_time = (self.last_profile_time[thread_id] + if thread_id in self.last_profile_time + else self.first_profile_time) + time_since_last_sample = now - last_time call_stack = build_call_stack(frame, event, arg) for subscriber in self.subscribers: - subscriber.target(call_stack, time_since_last_sample, subscriber.async_state) + subscriber.target.call_stack( + call_stack, time_since_last_sample, subscriber.async_state) - self.last_profile_time = now + self.last_profile_time[thread_id] = now def _timer(self): if self.timer_func: @@ -279,6 +327,11 @@ def get_stack_sampler() -> StackSampler: return thread_locals.stack_sampler +def get_thread_id() -> str: + thread = threading.current_thread() + return "%s\x00%s\x00%i" % (thread.name, "", thread.ident) + + def build_call_stack(frame: types.FrameType | None, event: str, arg: Any) -> list[str]: call_stack: list[str] = [] @@ -300,9 +353,7 @@ def build_call_stack(frame: types.FrameType | None, event: str, arg: Any) -> lis call_stack.append(get_frame_info(frame)) frame = frame.f_back - thread = threading.current_thread() - thread_identifier = "%s\x00%s\x00%i" % (thread.name, "", thread.ident) - call_stack.append(thread_identifier) + call_stack.append(get_thread_id()) # we iterated from the leaf to the root, we actually want the call stack # starting at the root, so reverse this array