From 974a843009fa1318d38ff1abbb8f3234a96ebc12 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 29 Sep 2024 17:01:24 +0100 Subject: [PATCH] Fix dodgy scrolling in iframe --- .../preview/assets/{index-mbGRX7NE.js => index-DmM09tqM.js} | 2 +- docs/_static/preview/index.html | 2 +- html_renderer/src/components/CallStackView.svelte | 2 +- pyinstrument/renderers/html_resources/app.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename docs/_static/preview/assets/{index-mbGRX7NE.js => index-DmM09tqM.js} (70%) diff --git a/docs/_static/preview/assets/index-mbGRX7NE.js b/docs/_static/preview/assets/index-DmM09tqM.js similarity index 70% rename from docs/_static/preview/assets/index-mbGRX7NE.js rename to docs/_static/preview/assets/index-DmM09tqM.js index 4880ecb0..c11e9236 100644 --- a/docs/_static/preview/assets/index-mbGRX7NE.js +++ b/docs/_static/preview/assets/index-DmM09tqM.js @@ -11,5 +11,5 @@ var Pi=Object.defineProperty;var Li=(i,e,t)=>e in i?Pi(i,e,{enumerable:!0,config `),Ae=h("label"),W=h("input"),We=L(` Call stack`),Ue=y(),re=h("label"),U=h("input"),je=L(` Timeline`),te=y(),de=h("div"),fe=y(),ve=h("div"),he=h("button"),be(ye.$$.fragment),Ye=L(` - View options`),Te=y(),q&&q.c(),a(s,"class","logo svelte-qdxst2"),a(c,"class","target-description svelte-qdxst2"),a(p,"class","metric-label svelte-qdxst2"),a(w,"class","metric-value svelte-qdxst2"),a(f,"class","metric date svelte-qdxst2"),a(T,"class","svelte-qdxst2"),a(M,"class","metric-label svelte-qdxst2"),a(E,"class","metric-value svelte-qdxst2"),a(k,"class","metric svelte-qdxst2"),a(N,"class","metric-label svelte-qdxst2"),a(B,"class","metric-value svelte-qdxst2"),a(P,"class","metric svelte-qdxst2"),a(m,"class","metrics svelte-qdxst2"),a(W,"type","radio"),W.__value="call-stack",le(W,W.__value),a(W,"class","svelte-qdxst2"),a(Ae,"class","svelte-qdxst2"),a(U,"type","radio"),U.__value="timeline",le(U,U.__value),a(U,"class","svelte-qdxst2"),a(re,"class","svelte-qdxst2"),a(J,"class","toggle"),a(de,"class","spacer"),Q(de,"flex","1"),a(he,"class","js-view-options-button svelte-qdxst2"),a(ve,"class","button-container svelte-qdxst2"),a(ee,"class","view-options svelte-qdxst2"),a(l,"class","layout svelte-qdxst2"),a(n,"class","row svelte-qdxst2"),a(t,"class","margins"),a(e,"class","header svelte-qdxst2"),Re.p(W,U)},m(V,X){S(V,e,X),u(e,t),u(t,n),u(n,s),me(r,s,null),u(n,o),u(n,l),u(l,c),c.innerHTML=d,u(l,v),u(l,m),u(m,f),u(f,p),u(f,g),u(f,w),u(m,b),u(m,T),u(m,A),u(m,k),u(k,M),u(k,H),u(k,E),u(E,D),u(m,_),u(m,P),u(P,N),u(P,j),u(P,B),u(l,Fe),u(l,ee),u(ee,J),u(J,Y),u(J,Ae),u(Ae,W),W.checked=W.__value===i[2].viewMode,u(Ae,We),u(J,Ue),u(J,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,ve),u(ve,he),me(ye,he,null),u(he,Ye),u(ve,Te),q&&q.m(ve,null),K=!0,Ee||(Xe=[$(W,"change",i[6]),$(U,"change",i[8]),$(he,"click",Mt(kt(i[5])))],Ee=!0)},p(V,[X]){(!K||X&1)&&d!==(d=Et(V[0].target_description)+"")&&(c.innerHTML=d),(!K||X&1)&&F!==(F=V[0].sampleCount+"")&&we(D,F),X&4&&(W.checked=W.__value===V[2].viewMode),X&4&&(U.checked=U.__value===V[2].viewMode),V[1]?q?(q.p(V,X),X&2&&O(q,1)):(q=Zt(V),q.c(),O(q,1),q.m(ve,null)):q&&(ze(),z(q,1,1,()=>{q=null}),qe())},i(V){K||(O(r.$$.fragment,V),O(ye.$$.fragment,V),O(q),K=!0)},o(V){z(r.$$.fragment,V),z(ye.$$.fragment,V),z(q),K=!1},d(V){V&&I(e),pe(r),pe(ye),q&&q.d(),Re.r(),Ee=!1,ae(Xe)}}}function En(i,e,t){let n;_e(i,Ze,p=>t(2,n=p));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 c(p){t(1,l=!l)}const d=[[]];function v(){n.viewMode=this.__value,Ze.set(n)}function m(){n.viewMode=this.__value,Ze.set(n)}const f=()=>t(1,l=!1);return i.$$set=p=>{"session"in p&&t(0,s=p.session)},[s,l,n,r,o,c,v,d,m,f]}class Cn extends ue{constructor(e){super(),ce(this,e,En,An,oe,{session:0})}}const kn="data:image/png;base64,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",Qt=ft({}),Jt=ft({});function gi(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.2?"#D8CB2A":"#7ED321"}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,c,d,v,m,f,p,g,w,b;return{c(){e=h("div"),t=h("div"),n=x("svg"),s=x("path"),r=y(),o=h("div"),l=L(i[5]),c=y(),d=h("div"),v=L(i[4]),m=y(),f=h("div"),f.textContent=`${i[11]}`,p=y(),g=h("div"),a(s,"d","M.937-.016L5.793 4.84.937 9.696z"),a(s,"fill",i[7]),a(s,"fill-rule","evenodd"),a(s,"fill-opacity",".582"),a(n,"width","6"),a(n,"height","10"),a(t,"class","frame-triangle svelte-14yvyii"),ke(t,"rotate",!i[8]),Q(t,"visibility",i[0].children.length>0?"visible":"hidden"),a(o,"class","time svelte-14yvyii"),Q(o,"color",i[7]),Q(o,"font-weight",i[10]<.2?500:600),a(d,"class","name svelte-14yvyii"),a(f,"class","code-position svelte-14yvyii"),a(e,"class","frame-description svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),ke(e,"application-code",i[0].isApplicationCode),ke(e,"children-visible",!i[8]),Q(e,"padding-left",`${i[2]*35}px`),a(g,"class","visual-guide svelte-14yvyii"),Q(g,"left",`${i[2]*35+21}px`),Q(g,"backgroundColor",i[7])},m(T,A){S(T,e,A),u(e,t),u(t,n),u(n,s),u(e,r),u(e,o),u(o,l),u(e,c),u(e,d),u(d,v),u(e,m),u(e,f),S(T,p,A),S(T,g,A),w||(b=[$(e,"keydown",i[14]),$(e,"click",Mt(kt(i[12])))],w=!0)},p(T,A){A&128&&a(s,"fill",T[7]),A&256&&ke(t,"rotate",!T[8]),A&1&&Q(t,"visibility",T[0].children.length>0?"visible":"hidden"),A&32&&we(l,T[5]),A&128&&Q(o,"color",T[7]),A&16&&we(v,T[4]),A&1&&ke(e,"application-code",T[0].isApplicationCode),A&256&&ke(e,"children-visible",!T[8]),A&4&&Q(e,"padding-left",`${T[2]*35}px`),A&4&&Q(g,"left",`${T[2]*35+21}px`),A&128&&Q(g,"backgroundColor",T[7])},d(T){T&&(I(e),I(p),I(g)),w=!1,ae(b)}}}function ii(i){let e,t,n,s,r=i[0].group.frames.length+"",o,l,c,d,v,m;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=y(),o=L(r),l=L(" frames hidden ("),c=L(i[6]),d=L(")"),a(n,"class","group-triangle svelte-14yvyii"),ke(n,"rotate",i[9]),a(t,"class","group-header-button svelte-14yvyii"),a(e,"class","group-header svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Q(e,"padding-left",`${i[2]*35}px`)},m(f,p){S(f,e,p),u(e,t),u(t,n),u(t,s),u(t,o),u(t,l),u(t,c),u(t,d),v||(m=[$(e,"keydown",i[15]),$(e,"click",Mt(kt(i[13])))],v=!0)},p(f,p){p&512&&ke(n,"rotate",f[9]),p&1&&r!==(r=f[0].group.frames.length+"")&&we(o,r),p&64&&we(c,f[6]),p&4&&Q(e,"padding-left",`${f[2]*35}px`)},d(f){f&&I(e),v=!1,ae(m)}}}function ni(i){let e,t=[],n=new Map,s,r=dt(i[0].children);const o=l=>l[21].uuid;for(let l=0;l0&&ni(i);return{c(){e=h("div"),r&&r.c(),t=y(),o&&o.c(),n=y(),l&&l.c(),a(e,"class","frame svelte-14yvyii")},m(c,d){S(c,e,d),r&&r.m(e,null),u(e,t),o&&o.m(e,null),u(e,n),l&&l.m(e,null),s=!0},p(c,[d]){c[3]?r?r.p(c,d):(r=ti(c),r.c(),r.m(e,t)):r&&(r.d(1),r=null),c[0].group&&c[0].group.rootFrame==c[0]&&!c[8]?o?o.p(c,d):(o=ii(c),o.c(),o.m(e,n)):o&&(o.d(1),o=null),!c[8]&&c[0].children.length>0?l?(l.p(c,d),d&257&&O(l,1)):(l=ni(c),l.c(),O(l,1),l.m(e,null)):l&&(ze(),z(l,1,1,()=>{l=null}),qe())},i(c){s||(O(l),s=!0)},o(c){z(l),s=!1},d(c){c&&I(e),r&&r.d(),o&&o.d(),l&&l.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 Fn(i,e,t){var D;let n,s,r,o,l;_e(i,Jt,_=>t(16,r=_)),_e(i,Qt,_=>t(17,o=_)),_e(i,Z,_=>t(18,l=_));let{frame:c}=e,{rootFrame:d}=e,{indent:v=0}=e,m;const f=c.time/d.time;let p;const g=`${c.filePathShort}:${(D=c.lineNo)==null?void 0:D.toString().padEnd(4," ")}`;let w,b=null;if(c.group){const _=c.group.libraries;_.length<4?b=_.join(", "):b=`${_[0]}, ${_[1]}, ${_[2]}...`}let T;T=gi(f);function A(_){k(c,!s,_.altKey)}function k(_,P,N=!0){if(Jt.update(j=>({...j,[_.uuid]:P})),N)for(const j of _.children)k(j,P,!0),_.group&&_.group.rootFrame==_&&M(_.group.id,!P)}function M(_,P){Qt.update(N=>({...N,[_]:P}))}function H(){c.group&&M(c.group.id,!n)}function E(_){let P=!0;_.key==="Enter"||_.key===" "?A(_):_.key==="ArrowLeft"&&!s?k(c,!0,_.altKey):_.key==="ArrowRight"&&s?k(c,!1,_.altKey):_.key==="ArrowUp"?ri():_.key==="ArrowDown"?oi():P=!1,P&&(_.preventDefault(),_.stopPropagation())}function F(_){let P=!0;_.key==="Enter"||_.key===" "?H():_.key==="ArrowLeft"&&c.group?M(c.group.id,!1):_.key==="ArrowRight"&&c.group?M(c.group.id,!0):_.key==="ArrowUp"?ri():_.key==="ArrowDown"?oi():P=!1,P&&(_.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 _,P;if(i.$$.dirty&131073&&(c.group?o[c.group.id??""]||((_=c.group)==null?void 0:_.rootFrame)===c||c.children.filter(N=>!N.group).length>1?t(3,m=!0):t(3,m=!1):t(3,m=!0)),i.$$.dirty&1&&(c.className?t(4,p=`${c.className}.${c.function}`):t(4,p=c.function)),i.$$.dirty&262145)if(l.timeFormat==="absolute")t(5,w=c.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(l.timeFormat==="proportion")t(5,w=`${(f*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(9,n=o[((P=c.group)==null?void 0:P.id)??""]===!0),i.$$.dirty&65537&&t(8,s=r[c.uuid]===!0)},[c,d,v,m,p,w,b,T,s,n,f,g,A,H,E,F,r,o,l]}let wi=class extends ue{constructor(e){super(),ce(this,e,Fn,Mn,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 Pn="\0",Ln="[await]",et="[self]",Rn="[out-of-context]",In="[root]",Sn=[Ln,et,Rn,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 r;this.identifier=e.identifier,this._identifierParts=this.identifier.split(Pn),this.startTime=e.startTime??0,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 Je(o,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 Sn.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 On{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 sn(t);i.removeFromParent(),Lt(i,!0)}function Vn(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(o){const l=o.filePath||"",c=n&&new RegExp(n).test(l),d=t&&new RegExp(t).test(l);return c?!1:d?!0:!o.isApplicationCode}function r(o,l){l.addFrame(o),o.children.forEach(c=>{s(c)&&r(c,l)})}return i.children.forEach(o=>{if(!o.group&&s(o)&&o.children.some(s)){const l=new On(o);r(o,l)}Ti(o,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 Ci(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/tCi(s,e,t)),i}function ki(i,e){if(!i)return null;const t=l=>dn(l,c=>c.time),n=l=>{var c;return((c=l.filePath)==null?void 0:c.includes("pyinstrument/__main__.py"))&&l.children.length>0},s=l=>{var c;return l.proportionOfParent>.8&&((c=l.filePath)==null?void 0:c.includes(""))&&l.children.length>0},r=l=>{var c;return l.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(l.filePath??"")||((c=l.filePath)==null?void 0:c.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 Nn(i){let e,t,n;return t=new wi({props:{frame:i[2],rootFrame:i[2]}}),{c(){e=h("div"),be(t.$$.fragment),a(e,"class","call-stack-margins svelte-16921do")},m(s,r){S(s,e,r),me(t,e,null),n=!0},p(s,r){const o={};r&4&&(o.frame=s[2]),r&4&&(o.rootFrame=s[2]),t.$set(o)},i(s){n||(O(t.$$.fragment,s),n=!0)},o(s){z(t.$$.fragment,s),n=!1},d(s){s&&I(e),pe(t)}}}function $n(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:R,i:R,o:R,d(t){t&&I(e)}}}function Bn(i){let e,t,n,s,r;const o=[$n,Nn],l=[];function c(d,v){return d[2]?1:0}return n=c(i),s=l[n]=o[n](i),{c(){e=h("div"),t=h("div"),s.c(),a(t,"class","scroll-inner svelte-16921do"),a(e,"class","call-stack-view svelte-16921do")},m(d,v){S(d,e,v),u(e,t),l[n].m(t,null),i[6](t),i[7](e),r=!0},p(d,[v]){let m=n;n=c(d),n===m?l[n].p(d,v):(ze(),z(l[m],1,1,()=>{l[m]=null}),qe(),s=l[n],s?s.p(d,v):(s=l[n]=o[n](d),s.c()),O(s,1),s.m(t,null))},i(d){r||(O(s),r=!0)},o(d){z(s),r=!1},d(d){d&&I(e),l[n].d(),i[6](null),i[7](null)}}}function xn(i,e,t){let n,{session:s}=e;const r=vi([Z],([m])=>{const f=[m.removeImportlib?Rt:null,m.removeTracebackHide?It:null,Ai,yi,Ei,m.removeIrrelevant?Ci:null,m.removePyinstrument?ki:null,m.collapseMode!=="disabled"?Ti:null].filter(g=>g!==null),p={filterThreshold:m.removeIrrelevantThreshold,hideRegex:m.collapseMode=="custom"?m.collapseCustomHide:void 0,showRegex:m.collapseMode=="custom"?m.collapseCustomShow:void 0};return{processors:f,options:p}});_e(i,r,m=>t(5,n=m));let o,l;Tt(()=>{const m=o;if(!m)throw new Error("element not set");let f;return m.addEventListener("scroll",f=()=>{t(1,l.style.minHeight=`${m.scrollTop+m.clientHeight}px`,l)}),f(),()=>{m.removeEventListener("scroll",f)}});let c;function d(m){Me[m?"unshift":"push"](()=>{l=m,t(1,l)})}function v(m){Me[m?"unshift":"push"](()=>{o=m,t(0,o)})}return i.$$set=m=>{"session"in m&&t(4,s=m.session)},i.$$.update=()=>{i.$$.dirty&48&&t(2,c=bi(s.rootFrame.cloneDeep(),n.processors,n.options))},[o,l,c,r,s,n,d,v]}class zn extends ue{constructor(e){super(),ce(this,e,xn,Bn,oe,{session:4})}}class qn{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 Wn{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 qn(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 Un(i){let e,t=i[2]=="self"?"self":"time",n,s,r,o=i[3](i[0].time)+"";return{c(){e=h("div"),n=L(t),s=y(),r=h("div"),a(e,"class","label svelte-ci3g2p"),a(r,"class","time-val svelte-ci3g2p")},m(l,c){S(l,e,c),u(e,n),S(l,s,c),S(l,r,c),r.innerHTML=o},p(l,c){c&4&&t!==(t=l[2]=="self"?"self":"time")&&we(n,t),c&1&&o!==(o=l[3](l[0].time)+"")&&(r.innerHTML=o)},d(l){l&&(I(e),I(s),I(r))}}}function jn(i){let e,t,n,s,r=i[3](i[0].time)+"",o,l=i[0].selfTime/i[0].time>.001&&li(i);return{c(){e=h("div"),e.textContent="time",t=y(),n=h("div"),s=h("div"),o=y(),l&&l.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=r,u(n,o),l&&l.m(n,null)},p(c,d){d&1&&r!==(r=c[3](c[0].time)+"")&&(s.innerHTML=r),c[0].selfTime/c[0].time>.001?l?l.p(c,d):(l=li(c),l.c(),l.m(n,null)):l&&(l.d(1),l=null)},d(c){c&&(I(e),I(t),I(n)),l&&l.d()}}}function li(i){let e,t,n,s=i[3](i[0].selfTime)+"";return{c(){e=h("div"),e.textContent="self",t=y(),n=h("div"),a(e,"class","label svelte-ci3g2p"),a(n,"class","time-val svelte-ci3g2p")},m(r,o){S(r,e,o),S(r,t,o),S(r,n,o),n.innerHTML=s},p(r,o){o&1&&s!==(s=r[3](r[0].selfTime)+"")&&(n.innerHTML=s)},d(r){r&&(I(e),I(t),I(n))}}}function Yn(i){let e,t,n=i[0].name+"",s,r,o,l,c,d,v,m,f,p;function g(T,A){return T[2]=="both"?jn:Un}let w=g(i),b=w(i);return{c(){e=h("div"),t=h("div"),s=L(n),r=y(),b.c(),o=y(),l=h("div"),l.textContent="loc",c=y(),d=h("div"),v=h("div"),f=y(),p=new Bi(!1),a(t,"class","name svelte-ci3g2p"),a(l,"class","label svelte-ci3g2p"),a(v,"class","location-color svelte-ci3g2p"),a(v,"style",m=`background: ${i[0].locationColor}`),p.a=null,a(d,"class","location-row"),a(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),a(e,"style",`font: ${Fi}; max-width: ${Gn}px;`)},m(T,A){S(T,e,A),u(e,t),u(t,s),u(e,r),b.m(e,null),u(e,o),u(e,l),u(e,c),u(e,d),u(d,v),u(d,f),p.m(i[1],d)},p(T,[A]){A&1&&n!==(n=T[0].name+"")&&we(s,n),w===(w=g(T))&&b?b.p(T,A):(b.d(1),b=w(T),b&&(b.c(),b.m(e,o))),A&1&&m!==(m=`background: ${T[0].locationColor}`)&&a(v,"style",m),A&2&&p.p(T[1])},i:R,o:R,d(T){T&&I(e),b.d()}}}function Mi(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Xn(i,e){i.font=Fi;const t=Mi(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 Gn=310,Fi="400 13px Source Sans Pro, sans-serif";function Kn(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=Et(n.location)),i.$$.dirty&1&&t(2,r=Mi(n))},[n,s,r,o]}class Zn extends ue{constructor(e){super(),ce(this,e,Kn,Yn,oe,{f:0})}}const Qn="#212325",ai=18,Jn=17,Pe=28,at=17,ci=29,es=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"],ts=es.map(an);class is extends Wn{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 r={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:r}):this.tooltipComponent=new Zn({target:this.tooltipContainer,props:{f:r}}),this.tooltipLocation){const o={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},l=Xn(t,r),c=this.width-10-l;o.x>c&&(o.x=c);const v=this.height-10-60;o.y>v&&(o.y=v),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=Qn,t.fillRect(0,0,s,r),this.drawAxes(t);for(const d of this.frames)this.drawFrame(t,d);t.globalAlpha=1;const o=this.maxYOffset>0||this.isZoomedIn,l=!!this.mouseDownLocation;this.canvas.style.cursor=l&&o?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let c=null;!l&&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 r=Math.ceil(s)+2;r<0&&(r=0);const o=Math.ceil(s)-3,l=c=>Be(c,{from:[s,s-3],to:[.71,0],clamp:!0});for(let c=o;c.01){t.globalAlpha=p,t.font='13px "Source Sans Pro", sans-serif';let g=d.toFixed(c);g=="0"&&(g="0s");let w=f+10;t.fillText(g,v+3,w);let b=this.height+at+10-this.yOffset;bthis.width)return;if(t.fillStyle=this.colorForFrame(n),t.globalAlpha=n.isApplicationCode?1:.5,o<2){t.fillRect(s,r,o,l);return}let d=this.frameName(n);const v=Math.floor(o/3.3);if(d.length>v&&(d=d.substring(0,v)),d.length==0){t.fillRect(s,r,o,l);return}t.save(),t.beginPath(),t.rect(s,r,o,l),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let m=s;m<0&&(m=0),t.fillText(d,m+2,r+13),t.restore()}_assignLibraryOrder(){const t={};for(const s of this.frames){const o=s.frame.library??"";t[o]=(t[o]||0)+s.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=on(ts,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(){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=Jn;let r=this.xForT(t.frame.startTime),l=this.xForT(t.frame.startTime+t.frame.time)-r;return l<1&&(l=1),l>1&&(l-=Be(l,{from:[1,3],to:[0,1],clamp:!0})),{x:r,y:n,w:l,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(r=>!r.isSynthetic);for(const r of s)n-=r.time;return n}hitTest(t){for(const n of this.frames){const{x:s,y:r,w:o,h:l}=this.frameDims(n);if(t.x>=s&&t.x<=s+o&&t.y>=r&&t.y<=r+l)return n}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-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 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-Pe)/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-Pe)/r;this.startT=o,this.zoom=r}this.clampViewport()}}}function ns(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:R,i:R,o:R,d(t){t&&I(e),i[6](null)}}}function ss(i,e,t){let n,{session:s}=e;const r=vi([Ge],([v])=>({processors:[v.removeImportlib?Rt:null,v.removeTracebackHide?It:null,v.removePyinstrument?ki:null].filter(p=>p!==null),options:{}}));_e(i,r,v=>t(5,n=v));let o,l=null,c=null;xi(()=>{c==null||c.destroy()});function d(v){Me[v?"unshift":"push"](()=>{l=v,t(0,l)})}return i.$$set=v=>{"session"in v&&t(2,s=v.session)},i.$$.update=()=>{i.$$.dirty&36&&t(3,o=bi(s.rootFrame.cloneDeep(),n.processors,n.options)),i.$$.dirty&1&&l&&t(4,c=new is(l)),i.$$.dirty&24&&o&&c&&c.setRootFrame(o)},[l,r,s,o,c,n,d]}class os extends ue{constructor(e){super(),ce(this,e,ss,ns,oe,{session:2})}}function rs(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=L("Unknown view mode: "),s=L(n),a(e,"class","error")},m(r,o){S(r,e,o),u(e,t),u(e,s)},p(r,o){o&2&&n!==(n=r[1].viewMode+"")&&we(s,n)},i:R,o:R,d(r){r&&I(e)}}}function ls(i){let e,t;return e=new os({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){me(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(O(e.$$.fragment,n),t=!0)},o(n){z(e.$$.fragment,n),t=!1},d(n){pe(e,n)}}}function as(i){let e,t;return e=new zn({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){me(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(O(e.$$.fragment,n),t=!0)},o(n){z(e.$$.fragment,n),t=!1},d(n){pe(e,n)}}}function cs(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:R,i:R,o:R,d(t){t&&I(e)}}}function us(i){let e,t,n,s,r,o,l,c;n=new Cn({props:{session:i[0]}});const d=[cs,as,ls,rs],v=[];function m(f,p){return f[0].rootFrame?f[1].viewMode==="call-stack"?1:f[1].viewMode==="timeline"?2:3:0}return o=m(i),l=v[o]=d[o](i),{c(){e=h("div"),t=h("div"),be(n.$$.fragment),s=y(),r=h("div"),l.c(),a(t,"class","header"),a(r,"class","body svelte-1vwroj7"),a(e,"class","app svelte-1vwroj7")},m(f,p){S(f,e,p),u(e,t),me(n,t,null),u(e,s),u(e,r),v[o].m(r,null),c=!0},p(f,[p]){const g={};p&1&&(g.session=f[0]),n.$set(g);let w=o;o=m(f),o===w?v[o].p(f,p):(ze(),z(v[w],1,1,()=>{v[w]=null}),qe(),l=v[o],l?l.p(f,p):(l=v[o]=d[o](f),l.c()),O(l,1),l.m(r,null))},i(f){c||(O(n.$$.fragment,f),O(l),c=!0)},o(f){z(n.$$.fragment,f),z(l),c=!1},d(f){f&&I(e),pe(n),v[o].d()}}}function ds(i,e,t){let n;_e(i,Ze,m=>t(1,n=m));let{session:s}=e;const r=document.createElement("link");r.rel="shortcut icon",r.href=kn,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.rootFrame,c=l==null?void 0:l.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=m=>{"session"in m&&t(0,s=m.session)},[s,n]}class fs extends ue{constructor(e){super(),ce(this,e,ds,us,oe,{session:0})}}class hs{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(xe(e).length>1)for(const s of this.sysPath){const r=ms(e,s);xe(r).length0&&e[0].endsWith(":")?e[0]:null}function ms(i,e){if(ui(i)!=ui(e))return i;const t=xe(i),n=xe(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}const ps={render(i,e){const t=new hs(e);return new fs({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,r){S(s,e,r),u(e,n)},p:R,d(s){s&&I(e)}}}function vs(i){let e,t,n=i[3].message+"",s;return{c(){e=h("div"),t=L("Error loading file: "),s=L(n)},m(r,o){S(r,e,o),u(e,t),u(e,s)},p(r,o){o&8&&n!==(n=r[3].message+"")&&we(s,n)},d(r){r&&I(e)}}}function gs(i){let e;return{c(){e=h("div"),e.textContent="Loading..."},m(t,n){S(t,e,n)},p:R,d(t){t&&I(e)}}}function _s(i){let e,t,n,s,r,o,l,c,d,v,m,f,p,g,w=dt(i[5]),b=[];for(let M=0;M{q=null}),qe())},i(V){K||(O(r.$$.fragment,V),O(ye.$$.fragment,V),O(q),K=!0)},o(V){z(r.$$.fragment,V),z(ye.$$.fragment,V),z(q),K=!1},d(V){V&&I(e),pe(r),pe(ye),q&&q.d(),Re.r(),Ee=!1,ae(Xe)}}}function En(i,e,t){let n;_e(i,Ze,p=>t(2,n=p));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 c(p){t(1,l=!l)}const d=[[]];function v(){n.viewMode=this.__value,Ze.set(n)}function m(){n.viewMode=this.__value,Ze.set(n)}const f=()=>t(1,l=!1);return i.$$set=p=>{"session"in p&&t(0,s=p.session)},[s,l,n,r,o,c,v,d,m,f]}class Cn extends ue{constructor(e){super(),ce(this,e,En,An,oe,{session:0})}}const kn="data:image/png;base64,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",Qt=ft({}),Jt=ft({});function gi(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.2?"#D8CB2A":"#7ED321"}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,c,d,v,m,f,p,g,w,b;return{c(){e=h("div"),t=h("div"),n=x("svg"),s=x("path"),r=y(),o=h("div"),l=L(i[5]),c=y(),d=h("div"),v=L(i[4]),m=y(),f=h("div"),f.textContent=`${i[11]}`,p=y(),g=h("div"),a(s,"d","M.937-.016L5.793 4.84.937 9.696z"),a(s,"fill",i[7]),a(s,"fill-rule","evenodd"),a(s,"fill-opacity",".582"),a(n,"width","6"),a(n,"height","10"),a(t,"class","frame-triangle svelte-14yvyii"),ke(t,"rotate",!i[8]),Q(t,"visibility",i[0].children.length>0?"visible":"hidden"),a(o,"class","time svelte-14yvyii"),Q(o,"color",i[7]),Q(o,"font-weight",i[10]<.2?500:600),a(d,"class","name svelte-14yvyii"),a(f,"class","code-position svelte-14yvyii"),a(e,"class","frame-description svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),ke(e,"application-code",i[0].isApplicationCode),ke(e,"children-visible",!i[8]),Q(e,"padding-left",`${i[2]*35}px`),a(g,"class","visual-guide svelte-14yvyii"),Q(g,"left",`${i[2]*35+21}px`),Q(g,"backgroundColor",i[7])},m(T,A){S(T,e,A),u(e,t),u(t,n),u(n,s),u(e,r),u(e,o),u(o,l),u(e,c),u(e,d),u(d,v),u(e,m),u(e,f),S(T,p,A),S(T,g,A),w||(b=[$(e,"keydown",i[14]),$(e,"click",Mt(kt(i[12])))],w=!0)},p(T,A){A&128&&a(s,"fill",T[7]),A&256&&ke(t,"rotate",!T[8]),A&1&&Q(t,"visibility",T[0].children.length>0?"visible":"hidden"),A&32&&we(l,T[5]),A&128&&Q(o,"color",T[7]),A&16&&we(v,T[4]),A&1&&ke(e,"application-code",T[0].isApplicationCode),A&256&&ke(e,"children-visible",!T[8]),A&4&&Q(e,"padding-left",`${T[2]*35}px`),A&4&&Q(g,"left",`${T[2]*35+21}px`),A&128&&Q(g,"backgroundColor",T[7])},d(T){T&&(I(e),I(p),I(g)),w=!1,ae(b)}}}function ii(i){let e,t,n,s,r=i[0].group.frames.length+"",o,l,c,d,v,m;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=y(),o=L(r),l=L(" frames hidden ("),c=L(i[6]),d=L(")"),a(n,"class","group-triangle svelte-14yvyii"),ke(n,"rotate",i[9]),a(t,"class","group-header-button svelte-14yvyii"),a(e,"class","group-header svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Q(e,"padding-left",`${i[2]*35}px`)},m(f,p){S(f,e,p),u(e,t),u(t,n),u(t,s),u(t,o),u(t,l),u(t,c),u(t,d),v||(m=[$(e,"keydown",i[15]),$(e,"click",Mt(kt(i[13])))],v=!0)},p(f,p){p&512&&ke(n,"rotate",f[9]),p&1&&r!==(r=f[0].group.frames.length+"")&&we(o,r),p&64&&we(c,f[6]),p&4&&Q(e,"padding-left",`${f[2]*35}px`)},d(f){f&&I(e),v=!1,ae(m)}}}function ni(i){let e,t=[],n=new Map,s,r=dt(i[0].children);const o=l=>l[21].uuid;for(let l=0;l0&&ni(i);return{c(){e=h("div"),r&&r.c(),t=y(),o&&o.c(),n=y(),l&&l.c(),a(e,"class","frame svelte-14yvyii")},m(c,d){S(c,e,d),r&&r.m(e,null),u(e,t),o&&o.m(e,null),u(e,n),l&&l.m(e,null),s=!0},p(c,[d]){c[3]?r?r.p(c,d):(r=ti(c),r.c(),r.m(e,t)):r&&(r.d(1),r=null),c[0].group&&c[0].group.rootFrame==c[0]&&!c[8]?o?o.p(c,d):(o=ii(c),o.c(),o.m(e,n)):o&&(o.d(1),o=null),!c[8]&&c[0].children.length>0?l?(l.p(c,d),d&257&&O(l,1)):(l=ni(c),l.c(),O(l,1),l.m(e,null)):l&&(ze(),z(l,1,1,()=>{l=null}),qe())},i(c){s||(O(l),s=!0)},o(c){z(l),s=!1},d(c){c&&I(e),r&&r.d(),o&&o.d(),l&&l.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 Fn(i,e,t){var D;let n,s,r,o,l;_e(i,Jt,_=>t(16,r=_)),_e(i,Qt,_=>t(17,o=_)),_e(i,Z,_=>t(18,l=_));let{frame:c}=e,{rootFrame:d}=e,{indent:v=0}=e,m;const f=c.time/d.time;let p;const g=`${c.filePathShort}:${(D=c.lineNo)==null?void 0:D.toString().padEnd(4," ")}`;let w,b=null;if(c.group){const _=c.group.libraries;_.length<4?b=_.join(", "):b=`${_[0]}, ${_[1]}, ${_[2]}...`}let T;T=gi(f);function A(_){k(c,!s,_.altKey)}function k(_,P,N=!0){if(Jt.update(j=>({...j,[_.uuid]:P})),N)for(const j of _.children)k(j,P,!0),_.group&&_.group.rootFrame==_&&M(_.group.id,!P)}function M(_,P){Qt.update(N=>({...N,[_]:P}))}function H(){c.group&&M(c.group.id,!n)}function E(_){let P=!0;_.key==="Enter"||_.key===" "?A(_):_.key==="ArrowLeft"&&!s?k(c,!0,_.altKey):_.key==="ArrowRight"&&s?k(c,!1,_.altKey):_.key==="ArrowUp"?ri():_.key==="ArrowDown"?oi():P=!1,P&&(_.preventDefault(),_.stopPropagation())}function F(_){let P=!0;_.key==="Enter"||_.key===" "?H():_.key==="ArrowLeft"&&c.group?M(c.group.id,!1):_.key==="ArrowRight"&&c.group?M(c.group.id,!0):_.key==="ArrowUp"?ri():_.key==="ArrowDown"?oi():P=!1,P&&(_.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 _,P;if(i.$$.dirty&131073&&(c.group?o[c.group.id??""]||((_=c.group)==null?void 0:_.rootFrame)===c||c.children.filter(N=>!N.group).length>1?t(3,m=!0):t(3,m=!1):t(3,m=!0)),i.$$.dirty&1&&(c.className?t(4,p=`${c.className}.${c.function}`):t(4,p=c.function)),i.$$.dirty&262145)if(l.timeFormat==="absolute")t(5,w=c.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(l.timeFormat==="proportion")t(5,w=`${(f*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(9,n=o[((P=c.group)==null?void 0:P.id)??""]===!0),i.$$.dirty&65537&&t(8,s=r[c.uuid]===!0)},[c,d,v,m,p,w,b,T,s,n,f,g,A,H,E,F,r,o,l]}let wi=class extends ue{constructor(e){super(),ce(this,e,Fn,Mn,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 Pn="\0",Ln="[await]",et="[self]",Rn="[out-of-context]",In="[root]",Sn=[Ln,et,Rn,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 r;this.identifier=e.identifier,this._identifierParts=this.identifier.split(Pn),this.startTime=e.startTime??0,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 Je(o,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 Sn.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 On{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 sn(t);i.removeFromParent(),Lt(i,!0)}function Vn(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(o){const l=o.filePath||"",c=n&&new RegExp(n).test(l),d=t&&new RegExp(t).test(l);return c?!1:d?!0:!o.isApplicationCode}function r(o,l){l.addFrame(o),o.children.forEach(c=>{s(c)&&r(c,l)})}return i.children.forEach(o=>{if(!o.group&&s(o)&&o.children.some(s)){const l=new On(o);r(o,l)}Ti(o,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 Ci(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/tCi(s,e,t)),i}function ki(i,e){if(!i)return null;const t=l=>dn(l,c=>c.time),n=l=>{var c;return((c=l.filePath)==null?void 0:c.includes("pyinstrument/__main__.py"))&&l.children.length>0},s=l=>{var c;return l.proportionOfParent>.8&&((c=l.filePath)==null?void 0:c.includes(""))&&l.children.length>0},r=l=>{var c;return l.proportionOfParent>.8&&(new RegExp(".*runpy.py").test(l.filePath??"")||((c=l.filePath)==null?void 0:c.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 Nn(i){let e,t,n;return t=new wi({props:{frame:i[2],rootFrame:i[2]}}),{c(){e=h("div"),be(t.$$.fragment),a(e,"class","call-stack-margins svelte-16921do")},m(s,r){S(s,e,r),me(t,e,null),n=!0},p(s,r){const o={};r&4&&(o.frame=s[2]),r&4&&(o.rootFrame=s[2]),t.$set(o)},i(s){n||(O(t.$$.fragment,s),n=!0)},o(s){z(t.$$.fragment,s),n=!1},d(s){s&&I(e),pe(t)}}}function $n(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:R,i:R,o:R,d(t){t&&I(e)}}}function Bn(i){let e,t,n,s,r;const o=[$n,Nn],l=[];function c(d,v){return d[2]?1:0}return n=c(i),s=l[n]=o[n](i),{c(){e=h("div"),t=h("div"),s.c(),a(t,"class","scroll-inner svelte-16921do"),a(e,"class","call-stack-view svelte-16921do")},m(d,v){S(d,e,v),u(e,t),l[n].m(t,null),i[6](t),i[7](e),r=!0},p(d,[v]){let m=n;n=c(d),n===m?l[n].p(d,v):(ze(),z(l[m],1,1,()=>{l[m]=null}),qe(),s=l[n],s?s.p(d,v):(s=l[n]=o[n](d),s.c()),O(s,1),s.m(t,null))},i(d){r||(O(s),r=!0)},o(d){z(s),r=!1},d(d){d&&I(e),l[n].d(),i[6](null),i[7](null)}}}function xn(i,e,t){let n,{session:s}=e;const r=vi([Z],([m])=>{const f=[m.removeImportlib?Rt:null,m.removeTracebackHide?It:null,Ai,yi,Ei,m.removeIrrelevant?Ci:null,m.removePyinstrument?ki:null,m.collapseMode!=="disabled"?Ti:null].filter(g=>g!==null),p={filterThreshold:m.removeIrrelevantThreshold,hideRegex:m.collapseMode=="custom"?m.collapseCustomHide:void 0,showRegex:m.collapseMode=="custom"?m.collapseCustomShow:void 0};return{processors:f,options:p}});_e(i,r,m=>t(5,n=m));let o,l;Tt(()=>{const m=o;if(!m)throw new Error("element not set");let f;return m.addEventListener("scroll",f=()=>{t(1,l.style.minHeight=`${Math.floor(m.scrollTop+m.clientHeight)}px`,l)}),f(),()=>{m.removeEventListener("scroll",f)}});let c;function d(m){Me[m?"unshift":"push"](()=>{l=m,t(1,l)})}function v(m){Me[m?"unshift":"push"](()=>{o=m,t(0,o)})}return i.$$set=m=>{"session"in m&&t(4,s=m.session)},i.$$.update=()=>{i.$$.dirty&48&&t(2,c=bi(s.rootFrame.cloneDeep(),n.processors,n.options))},[o,l,c,r,s,n,d,v]}class zn extends ue{constructor(e){super(),ce(this,e,xn,Bn,oe,{session:4})}}class qn{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 Wn{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 qn(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 Un(i){let e,t=i[2]=="self"?"self":"time",n,s,r,o=i[3](i[0].time)+"";return{c(){e=h("div"),n=L(t),s=y(),r=h("div"),a(e,"class","label svelte-ci3g2p"),a(r,"class","time-val svelte-ci3g2p")},m(l,c){S(l,e,c),u(e,n),S(l,s,c),S(l,r,c),r.innerHTML=o},p(l,c){c&4&&t!==(t=l[2]=="self"?"self":"time")&&we(n,t),c&1&&o!==(o=l[3](l[0].time)+"")&&(r.innerHTML=o)},d(l){l&&(I(e),I(s),I(r))}}}function jn(i){let e,t,n,s,r=i[3](i[0].time)+"",o,l=i[0].selfTime/i[0].time>.001&&li(i);return{c(){e=h("div"),e.textContent="time",t=y(),n=h("div"),s=h("div"),o=y(),l&&l.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=r,u(n,o),l&&l.m(n,null)},p(c,d){d&1&&r!==(r=c[3](c[0].time)+"")&&(s.innerHTML=r),c[0].selfTime/c[0].time>.001?l?l.p(c,d):(l=li(c),l.c(),l.m(n,null)):l&&(l.d(1),l=null)},d(c){c&&(I(e),I(t),I(n)),l&&l.d()}}}function li(i){let e,t,n,s=i[3](i[0].selfTime)+"";return{c(){e=h("div"),e.textContent="self",t=y(),n=h("div"),a(e,"class","label svelte-ci3g2p"),a(n,"class","time-val svelte-ci3g2p")},m(r,o){S(r,e,o),S(r,t,o),S(r,n,o),n.innerHTML=s},p(r,o){o&1&&s!==(s=r[3](r[0].selfTime)+"")&&(n.innerHTML=s)},d(r){r&&(I(e),I(t),I(n))}}}function Yn(i){let e,t,n=i[0].name+"",s,r,o,l,c,d,v,m,f,p;function g(T,A){return T[2]=="both"?jn:Un}let w=g(i),b=w(i);return{c(){e=h("div"),t=h("div"),s=L(n),r=y(),b.c(),o=y(),l=h("div"),l.textContent="loc",c=y(),d=h("div"),v=h("div"),f=y(),p=new Bi(!1),a(t,"class","name svelte-ci3g2p"),a(l,"class","label svelte-ci3g2p"),a(v,"class","location-color svelte-ci3g2p"),a(v,"style",m=`background: ${i[0].locationColor}`),p.a=null,a(d,"class","location-row"),a(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),a(e,"style",`font: ${Fi}; max-width: ${Gn}px;`)},m(T,A){S(T,e,A),u(e,t),u(t,s),u(e,r),b.m(e,null),u(e,o),u(e,l),u(e,c),u(e,d),u(d,v),u(d,f),p.m(i[1],d)},p(T,[A]){A&1&&n!==(n=T[0].name+"")&&we(s,n),w===(w=g(T))&&b?b.p(T,A):(b.d(1),b=w(T),b&&(b.c(),b.m(e,o))),A&1&&m!==(m=`background: ${T[0].locationColor}`)&&a(v,"style",m),A&2&&p.p(T[1])},i:R,o:R,d(T){T&&I(e),b.d()}}}function Mi(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Xn(i,e){i.font=Fi;const t=Mi(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 Gn=310,Fi="400 13px Source Sans Pro, sans-serif";function Kn(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=Et(n.location)),i.$$.dirty&1&&t(2,r=Mi(n))},[n,s,r,o]}class Zn extends ue{constructor(e){super(),ce(this,e,Kn,Yn,oe,{f:0})}}const Qn="#212325",ai=18,Jn=17,Pe=28,at=17,ci=29,es=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"],ts=es.map(an);class is extends Wn{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 r={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:r}):this.tooltipComponent=new Zn({target:this.tooltipContainer,props:{f:r}}),this.tooltipLocation){const o={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},l=Xn(t,r),c=this.width-10-l;o.x>c&&(o.x=c);const v=this.height-10-60;o.y>v&&(o.y=v),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=Qn,t.fillRect(0,0,s,r),this.drawAxes(t);for(const d of this.frames)this.drawFrame(t,d);t.globalAlpha=1;const o=this.maxYOffset>0||this.isZoomedIn,l=!!this.mouseDownLocation;this.canvas.style.cursor=l&&o?"grabbing":"initial",t.fillStyle="red",t.font='23px "Source Sans Pro", sans-serif';let c=null;!l&&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 r=Math.ceil(s)+2;r<0&&(r=0);const o=Math.ceil(s)-3,l=c=>Be(c,{from:[s,s-3],to:[.71,0],clamp:!0});for(let c=o;c.01){t.globalAlpha=p,t.font='13px "Source Sans Pro", sans-serif';let g=d.toFixed(c);g=="0"&&(g="0s");let w=f+10;t.fillText(g,v+3,w);let b=this.height+at+10-this.yOffset;bthis.width)return;if(t.fillStyle=this.colorForFrame(n),t.globalAlpha=n.isApplicationCode?1:.5,o<2){t.fillRect(s,r,o,l);return}let d=this.frameName(n);const v=Math.floor(o/3.3);if(d.length>v&&(d=d.substring(0,v)),d.length==0){t.fillRect(s,r,o,l);return}t.save(),t.beginPath(),t.rect(s,r,o,l),t.fill(),t.clip(),t.font='13px "Source Sans Pro", sans-serif',t.fillStyle="white";let m=s;m<0&&(m=0),t.fillText(d,m+2,r+13),t.restore()}_assignLibraryOrder(){const t={};for(const s of this.frames){const o=s.frame.library??"";t[o]=(t[o]||0)+s.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=on(ts,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(){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=Jn;let r=this.xForT(t.frame.startTime),l=this.xForT(t.frame.startTime+t.frame.time)-r;return l<1&&(l=1),l>1&&(l-=Be(l,{from:[1,3],to:[0,1],clamp:!0})),{x:r,y:n,w:l,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(r=>!r.isSynthetic);for(const r of s)n-=r.time;return n}hitTest(t){for(const n of this.frames){const{x:s,y:r,w:o,h:l}=this.frameDims(n);if(t.x>=s&&t.x<=s+o&&t.y>=r&&t.y<=r+l)return n}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-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 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-Pe)/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-Pe)/r;this.startT=o,this.zoom=r}this.clampViewport()}}}function ns(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:R,i:R,o:R,d(t){t&&I(e),i[6](null)}}}function ss(i,e,t){let n,{session:s}=e;const r=vi([Ge],([v])=>({processors:[v.removeImportlib?Rt:null,v.removeTracebackHide?It:null,v.removePyinstrument?ki:null].filter(p=>p!==null),options:{}}));_e(i,r,v=>t(5,n=v));let o,l=null,c=null;xi(()=>{c==null||c.destroy()});function d(v){Me[v?"unshift":"push"](()=>{l=v,t(0,l)})}return i.$$set=v=>{"session"in v&&t(2,s=v.session)},i.$$.update=()=>{i.$$.dirty&36&&t(3,o=bi(s.rootFrame.cloneDeep(),n.processors,n.options)),i.$$.dirty&1&&l&&t(4,c=new is(l)),i.$$.dirty&24&&o&&c&&c.setRootFrame(o)},[l,r,s,o,c,n,d]}class os extends ue{constructor(e){super(),ce(this,e,ss,ns,oe,{session:2})}}function rs(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=L("Unknown view mode: "),s=L(n),a(e,"class","error")},m(r,o){S(r,e,o),u(e,t),u(e,s)},p(r,o){o&2&&n!==(n=r[1].viewMode+"")&&we(s,n)},i:R,o:R,d(r){r&&I(e)}}}function ls(i){let e,t;return e=new os({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){me(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(O(e.$$.fragment,n),t=!0)},o(n){z(e.$$.fragment,n),t=!1},d(n){pe(e,n)}}}function as(i){let e,t;return e=new zn({props:{session:i[0]}}),{c(){be(e.$$.fragment)},m(n,s){me(e,n,s),t=!0},p(n,s){const r={};s&1&&(r.session=n[0]),e.$set(r)},i(n){t||(O(e.$$.fragment,n),t=!0)},o(n){z(e.$$.fragment,n),t=!1},d(n){pe(e,n)}}}function cs(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:R,i:R,o:R,d(t){t&&I(e)}}}function us(i){let e,t,n,s,r,o,l,c;n=new Cn({props:{session:i[0]}});const d=[cs,as,ls,rs],v=[];function m(f,p){return f[0].rootFrame?f[1].viewMode==="call-stack"?1:f[1].viewMode==="timeline"?2:3:0}return o=m(i),l=v[o]=d[o](i),{c(){e=h("div"),t=h("div"),be(n.$$.fragment),s=y(),r=h("div"),l.c(),a(t,"class","header"),a(r,"class","body svelte-1vwroj7"),a(e,"class","app svelte-1vwroj7")},m(f,p){S(f,e,p),u(e,t),me(n,t,null),u(e,s),u(e,r),v[o].m(r,null),c=!0},p(f,[p]){const g={};p&1&&(g.session=f[0]),n.$set(g);let w=o;o=m(f),o===w?v[o].p(f,p):(ze(),z(v[w],1,1,()=>{v[w]=null}),qe(),l=v[o],l?l.p(f,p):(l=v[o]=d[o](f),l.c()),O(l,1),l.m(r,null))},i(f){c||(O(n.$$.fragment,f),O(l),c=!0)},o(f){z(n.$$.fragment,f),z(l),c=!1},d(f){f&&I(e),pe(n),v[o].d()}}}function ds(i,e,t){let n;_e(i,Ze,m=>t(1,n=m));let{session:s}=e;const r=document.createElement("link");r.rel="shortcut icon",r.href=kn,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.rootFrame,c=l==null?void 0:l.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=m=>{"session"in m&&t(0,s=m.session)},[s,n]}class fs extends ue{constructor(e){super(),ce(this,e,ds,us,oe,{session:0})}}class hs{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(xe(e).length>1)for(const s of this.sysPath){const r=ms(e,s);xe(r).length0&&e[0].endsWith(":")?e[0]:null}function ms(i,e){if(ui(i)!=ui(e))return i;const t=xe(i),n=xe(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}const ps={render(i,e){const t=new hs(e);return new fs({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,r){S(s,e,r),u(e,n)},p:R,d(s){s&&I(e)}}}function vs(i){let e,t,n=i[3].message+"",s;return{c(){e=h("div"),t=L("Error loading file: "),s=L(n)},m(r,o){S(r,e,o),u(e,t),u(e,s)},p(r,o){o&8&&n!==(n=r[3].message+"")&&we(s,n)},d(r){r&&I(e)}}}function gs(i){let e;return{c(){e=h("div"),e.textContent="Loading..."},m(t,n){S(t,e,n)},p:R,d(t){t&&I(e)}}}function _s(i){let e,t,n,s,r,o,l,c,d,v,m,f,p,g,w=dt(i[5]),b=[];for(let M=0;Mi[7].call(l)),a(r,"class","right"),a(t,"class","header svelte-1980ffz"),a(m,"class","result-element"),a(m,"style",f=i[1]?"":"display: none"),a(d,"class","body svelte-1980ffz"),a(e,"class","demo-app svelte-1980ffz")},m(M,H){S(M,e,H),u(e,t),u(t,n),u(t,s),u(t,r),u(r,o),u(r,l);for(let E=0;E_t(()=>import("./django_template_render-CIkNzFIy.js"),[],import.meta.url).then(p=>p.default),"../demo-data/sympy_calculation.json":()=>_t(()=>import("./sympy_calculation-B9Pn_4RL.js"),[],import.meta.url).then(p=>p.default),"../demo-data/wikipedia_article_word_count.json":()=>_t(()=>import("./wikipedia_article_word_count-CGt_pvsZ.js"),[],import.meta.url).then(p=>p.default)})).map(([p,g])=>({name:p.split("/").pop().split(".").slice(0,-1).join("."),promiseFn:g}));let r=s[0],o=null,l=null,c=!1,d=null,v;function m(){r=Ni(this),t(0,r),t(5,s)}function f(p){Me[p?"unshift":"push"](()=>{v=p,t(2,v)})}return i.$$.update=()=>{i.$$.dirty&1&&(t(4,c=!0),t(3,l=null),t(1,o=null),r.promiseFn().then(p=>{t(1,o=p),t(3,l=null)}).catch(p=>{t(3,l=p)}).finally(()=>{t(4,c=!1)})),i.$$.dirty&70&&v&&o&&(d&&d.$destroy(),t(6,d=ps.render(v,o)))},[r,o,v,l,c,s,d,m,f]}class bs extends ue{constructor(e){super(),ce(this,e,ws,_s,oe,{})}}new bs({target:document.body}); diff --git a/docs/_static/preview/index.html b/docs/_static/preview/index.html index f4664142..e7e1417f 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/components/CallStackView.svelte b/html_renderer/src/components/CallStackView.svelte index 548cb422..0f17ac0e 100644 --- a/html_renderer/src/components/CallStackView.svelte +++ b/html_renderer/src/components/CallStackView.svelte @@ -37,7 +37,7 @@ if (!el) { throw new Error('element not set'); } let listener el.addEventListener('scroll', listener = () => { - scrollInnerElement!.style.minHeight = `${el.scrollTop + el.clientHeight}px`; + scrollInnerElement!.style.minHeight = `${Math.floor(el.scrollTop + el.clientHeight)}px`; }); listener(); return () => { diff --git a/pyinstrument/renderers/html_resources/app.js b/pyinstrument/renderers/html_resources/app.js index 7d19cd5c..c0e42b22 100644 --- a/pyinstrument/renderers/html_resources/app.js +++ b/pyinstrument/renderers/html_resources/app.js @@ -11,4 +11,4 @@ var pyinstrumentHTMLRenderer=function(){"use strict";var ts=Object.definePropert `),Ee=h("label"),q=h("input"),Qe=R(` Call stack`),Je=b(),le=h("label"),U=h("input"),et=R(` Timeline`),te=b(),he=h("div"),me=b(),we=h("div"),pe=h("button"),_e(Te.$$.fragment),tt=R(` - View options`),Ae=b(),z&&z.c(),a(s,"class","logo svelte-qdxst2"),a(c,"class","target-description svelte-qdxst2"),a(v,"class","metric-label svelte-qdxst2"),a(w,"class","metric-value svelte-qdxst2"),a(f,"class","metric date svelte-qdxst2"),a(y,"class","svelte-qdxst2"),a(H,"class","metric-label svelte-qdxst2"),a(F,"class","metric-value svelte-qdxst2"),a(P,"class","metric svelte-qdxst2"),a(V,"class","metric-label svelte-qdxst2"),a(B,"class","metric-value svelte-qdxst2"),a(M,"class","metric svelte-qdxst2"),a(m,"class","metrics svelte-qdxst2"),a(q,"type","radio"),q.__value="call-stack",ae(q,q.__value),a(q,"class","svelte-qdxst2"),a(Ee,"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(J,"class","toggle"),a(he,"class","spacer"),Z(he,"flex","1"),a(pe,"class","js-view-options-button svelte-qdxst2"),a(we,"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,G){L(O,e,G),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,p),u(o,m),u(m,f),u(f,v),u(f,_),u(f,w),u(m,C),u(m,y),u(m,A),u(m,P),u(P,H),u(P,W),u(P,F),u(F,S),u(m,g),u(m,M),u(M,V),u(M,Y),u(M,B),u(o,Le),u(o,ee),u(ee,J),u(J,X),u(J,Ee),u(Ee,q),q.checked=q.__value===i[2].viewMode,u(Ee,Qe),u(J,Je),u(J,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,we),u(we,pe),ce(Te,pe,null),u(pe,tt),u(we,Ae),z&&z.m(we,null),Q=!0,Me||(it=[N(q,"change",i[6]),N(U,"change",i[8]),N(pe,"click",gt(vt(i[5])))],Me=!0)},p(O,[G]){(!Q||G&1)&&d!==(d=Mt(O[0].target_description)+"")&&(c.innerHTML=d),(!Q||G&1)&&E!==(E=O[0].sampleCount+"")&&ye(S,E),G&4&&(q.checked=q.__value===O[2].viewMode),G&4&&(U.checked=U.__value===O[2].viewMode),O[1]?z?(z.p(O,G),G&2&&D(z,1)):(z=Nt(O),z.c(),D(z,1),z.m(we,null)):z&&(Oe(),x(z,1,1,()=>{z=null}),Ve())},i(O){Q||(D(l.$$.fragment,O),D(Te.$$.fragment,O),D(z),Q=!0)},o(O){x(l.$$.fragment,O),x(Te.$$.fragment,O),x(z),Q=!1},d(O){O&&I(e),ue(l),ue(Te),z&&z.d(),Be.r(),Me=!1,oe(it)}}}function hn(i,e,t){let n;ge(i,Ge,v=>t(2,n=v));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(v){t(1,o=!o)}const d=[[]];function p(){n.viewMode=this.__value,Ge.set(n)}function m(){n.viewMode=this.__value,Ge.set(n)}const f=()=>t(1,o=!1);return i.$$set=v=>{"session"in v&&t(0,s=v.session)},[s,o,n,l,r,c,p,d,m,f]}class mn extends fe{constructor(e){super(),de(this,e,hn,fn,re,{session:0})}}const pn="data:image/png;base64,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",xt=st({}),Bt=st({});function zt(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.2?"#D8CB2A":"#7ED321"}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,p,m,f,v,_,w,C;return{c(){e=h("div"),t=h("div"),n=$("svg"),s=$("path"),l=b(),r=h("div"),o=R(i[5]),c=b(),d=h("div"),p=R(i[4]),m=b(),f=h("div"),f.textContent=`${i[11]}`,v=b(),_=h("div"),a(s,"d","M.937-.016L5.793 4.84.937 9.696z"),a(s,"fill",i[7]),a(s,"fill-rule","evenodd"),a(s,"fill-opacity",".582"),a(n,"width","6"),a(n,"height","10"),a(t,"class","frame-triangle svelte-14yvyii"),Ce(t,"rotate",!i[8]),Z(t,"visibility",i[0].children.length>0?"visible":"hidden"),a(r,"class","time svelte-14yvyii"),Z(r,"color",i[7]),Z(r,"font-weight",i[10]<.2?500:600),a(d,"class","name svelte-14yvyii"),a(f,"class","code-position svelte-14yvyii"),a(e,"class","frame-description svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Ce(e,"application-code",i[0].isApplicationCode),Ce(e,"children-visible",!i[8]),Z(e,"padding-left",`${i[2]*35}px`),a(_,"class","visual-guide svelte-14yvyii"),Z(_,"left",`${i[2]*35+21}px`),Z(_,"backgroundColor",i[7])},m(y,A){L(y,e,A),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,p),u(e,m),u(e,f),L(y,v,A),L(y,_,A),w||(C=[N(e,"keydown",i[14]),N(e,"click",gt(vt(i[12])))],w=!0)},p(y,A){A&128&&a(s,"fill",y[7]),A&256&&Ce(t,"rotate",!y[8]),A&1&&Z(t,"visibility",y[0].children.length>0?"visible":"hidden"),A&32&&ye(o,y[5]),A&128&&Z(r,"color",y[7]),A&16&&ye(p,y[4]),A&1&&Ce(e,"application-code",y[0].isApplicationCode),A&256&&Ce(e,"children-visible",!y[8]),A&4&&Z(e,"padding-left",`${y[2]*35}px`),A&4&&Z(_,"left",`${y[2]*35+21}px`),A&128&&Z(_,"backgroundColor",y[7])},d(y){y&&(I(e),I(v),I(_)),w=!1,oe(C)}}}function Ut(i){let e,t,n,s,l=i[0].group.frames.length+"",r,o,c,d,p,m;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=b(),r=R(l),o=R(" frames hidden ("),c=R(i[6]),d=R(")"),a(n,"class","group-triangle svelte-14yvyii"),Ce(n,"rotate",i[9]),a(t,"class","group-header-button svelte-14yvyii"),a(e,"class","group-header svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Z(e,"padding-left",`${i[2]*35}px`)},m(f,v){L(f,e,v),u(e,t),u(t,n),u(t,s),u(t,r),u(t,o),u(t,c),u(t,d),p||(m=[N(e,"keydown",i[15]),N(e,"click",gt(vt(i[13])))],p=!0)},p(f,v){v&512&&Ce(n,"rotate",f[9]),v&1&&l!==(l=f[0].group.frames.length+"")&&ye(r,l),v&64&&ye(c,f[6]),v&4&&Z(e,"padding-left",`${f[2]*35}px`)},d(f){f&&I(e),p=!1,oe(m)}}}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-14yvyii")},m(c,d){L(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[8]?r?r.p(c,d):(r=Ut(c),r.c(),r.m(e,n)):r&&(r.d(1),r=null),!c[8]&&c[0].children.length>0?o?(o.p(c,d),d&257&&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&&I(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 gn(i,e,t){var S;let n,s,l,r,o;ge(i,Bt,g=>t(16,l=g)),ge(i,xt,g=>t(17,r=g)),ge(i,K,g=>t(18,o=g));let{frame:c}=e,{rootFrame:d}=e,{indent:p=0}=e,m;const f=c.time/d.time;let v;const _=`${c.filePathShort}:${(S=c.lineNo)==null?void 0:S.toString().padEnd(4," ")}`;let w,C=null;if(c.group){const g=c.group.libraries;g.length<4?C=g.join(", "):C=`${g[0]}, ${g[1]}, ${g[2]}...`}let y;y=zt(f);function A(g){P(c,!s,g.altKey)}function P(g,M,V=!0){if(Bt.update(Y=>({...Y,[g.uuid]:M})),V)for(const Y of g.children)P(Y,M,!0),g.group&&g.group.rootFrame==g&&H(g.group.id,!M)}function H(g,M){xt.update(V=>({...V,[g]:M}))}function W(){c.group&&H(c.group.id,!n)}function F(g){let M=!0;g.key==="Enter"||g.key===" "?A(g):g.key==="ArrowLeft"&&!s?P(c,!0,g.altKey):g.key==="ArrowRight"&&s?P(c,!1,g.altKey):g.key==="ArrowUp"?Zt():g.key==="ArrowDown"?jt():M=!1,M&&(g.preventDefault(),g.stopPropagation())}function E(g){let M=!0;g.key==="Enter"||g.key===" "?W():g.key==="ArrowLeft"&&c.group?H(c.group.id,!1):g.key==="ArrowRight"&&c.group?H(c.group.id,!0):g.key==="ArrowUp"?Zt():g.key==="ArrowDown"?jt():M=!1,M&&(g.preventDefault(),g.stopPropagation())}return i.$$set=g=>{"frame"in g&&t(0,c=g.frame),"rootFrame"in g&&t(1,d=g.rootFrame),"indent"in g&&t(2,p=g.indent)},i.$$.update=()=>{var g,M;if(i.$$.dirty&131073&&(c.group?r[c.group.id??""]||((g=c.group)==null?void 0:g.rootFrame)===c||c.children.filter(V=>!V.group).length>1?t(3,m=!0):t(3,m=!1):t(3,m=!0)),i.$$.dirty&1&&(c.className?t(4,v=`${c.className}.${c.function}`):t(4,v=c.function)),i.$$.dirty&262145)if(o.timeFormat==="absolute")t(5,w=c.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(o.timeFormat==="proportion")t(5,w=`${(f*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(9,n=r[((M=c.group)==null?void 0:M.id)??""]===!0),i.$$.dirty&65537&&t(8,s=l[c.uuid]===!0)},[c,d,p,m,v,w,C,y,s,n,f,_,A,W,F,E,l,r,o]}let Kt=class extends fe{constructor(e){super(),de(this,e,gn,vn,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 _n="\0",wn="[await]",Ze="[self]",bn=[wn,Ze,"[out-of-context]","[root]"],yn="c",Tn="h";class Ke{constructor(e,t){T(this,"uuid",ot());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 l;this.identifier=e.identifier,this._identifierParts=this.identifier.split(_n),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(Tn)=="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 bn.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(yn)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class An{constructor(e){T(this,"id");T(this,"rootFrame");T(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 Yi(t);i.removeFromParent(),kt(i,!0)}function Cn(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(),kt(i,!1)}function kt(i,e){if(e&&i.children&&i.children.forEach(t=>{kt(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 An(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=>Ji(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 En(i){let e,t,n;return t=new Kt({props:{frame:i[2],rootFrame:i[2]}}),{c(){e=h("div"),_e(t.$$.fragment),a(e,"class","call-stack-margins svelte-16921do")},m(s,l){L(s,e,l),ce(t,e,null),n=!0},p(s,l){const r={};l&4&&(r.frame=s[2]),l&4&&(r.rootFrame=s[2]),t.$set(r)},i(s){n||(D(t.$$.fragment,s),n=!0)},o(s){x(t.$$.fragment,s),n=!1},d(s){s&&I(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){L(t,e,n)},p:k,i:k,o:k,d(t){t&&I(e)}}}function kn(i){let e,t,n,s,l;const r=[Mn,En],o=[];function c(d,p){return d[2]?1:0}return n=c(i),s=o[n]=r[n](i),{c(){e=h("div"),t=h("div"),s.c(),a(t,"class","scroll-inner svelte-16921do"),a(e,"class","call-stack-view svelte-16921do")},m(d,p){L(d,e,p),u(e,t),o[n].m(t,null),i[6](t),i[7](e),l=!0},p(d,[p]){let m=n;n=c(d),n===m?o[n].p(d,p):(Oe(),x(o[m],1,1,()=>{o[m]=null}),Ve(),s=o[n],s?s.p(d,p):(s=o[n]=r[n](d),s.c()),D(s,1),s.m(t,null))},i(d){l||(D(s),l=!0)},o(d){x(s),l=!1},d(d){d&&I(e),o[n].d(),i[6](null),i[7](null)}}}function Fn(i,e,t){let n,{session:s}=e;const l=Vt([K],([m])=>{const f=[m.removeImportlib?Ft:null,m.removeTracebackHide?Pt:null,ti,Jt,ii,m.removeIrrelevant?ni:null,m.removePyinstrument?si:null,m.collapseMode!=="disabled"?ei:null].filter(_=>_!==null),v={filterThreshold:m.removeIrrelevantThreshold,hideRegex:m.collapseMode=="custom"?m.collapseCustomHide:void 0,showRegex:m.collapseMode=="custom"?m.collapseCustomShow:void 0};return{processors:f,options:v}});ge(i,l,m=>t(5,n=m));let r,o;bt(()=>{const m=r;if(!m)throw new Error("element not set");let f;return m.addEventListener("scroll",f=()=>{t(1,o.style.minHeight=`${m.scrollTop+m.clientHeight}px`,o)}),f(),()=>{m.removeEventListener("scroll",f)}});let c;function d(m){Pe[m?"unshift":"push"](()=>{o=m,t(1,o)})}function p(m){Pe[m?"unshift":"push"](()=>{r=m,t(0,r)})}return i.$$set=m=>{"session"in m&&t(4,s=m.session)},i.$$.update=()=>{i.$$.dirty&48&&t(2,c=Qt(s.rootFrame.cloneDeep(),n.processors,n.options))},[r,o,c,l,s,n,d,p]}class Pn extends fe{constructor(e){super(),de(this,e,Fn,kn,re,{session:4})}}class Rn{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 In{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 Rn(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 Ln(i){let e,t=i[2]=="self"?"self":"time",n,s,l,r=i[3](i[0].time)+"";return{c(){e=h("div"),n=R(t),s=b(),l=h("div"),a(e,"class","label svelte-ci3g2p"),a(l,"class","time-val svelte-ci3g2p")},m(o,c){L(o,e,c),u(e,n),L(o,s,c),L(o,l,c),l.innerHTML=r},p(o,c){c&4&&t!==(t=o[2]=="self"?"self":"time")&&ye(n,t),c&1&&r!==(r=o[3](o[0].time)+"")&&(l.innerHTML=r)},d(o){o&&(I(e),I(s),I(l))}}}function Sn(i){let e,t,n,s,l=i[3](i[0].time)+"",r,o=i[0].selfTime/i[0].time>.001&&oi(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){L(c,e,d),L(c,t,d),L(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=oi(c),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(c){c&&(I(e),I(t),I(n)),o&&o.d()}}}function oi(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){L(l,e,r),L(l,t,r),L(l,n,r),n.innerHTML=s},p(l,r){r&1&&s!==(s=l[3](l[0].selfTime)+"")&&(n.innerHTML=s)},d(l){l&&(I(e),I(t),I(n))}}}function Dn(i){let e,t,n=i[0].name+"",s,l,r,o,c,d,p,m,f,v;function _(y,A){return y[2]=="both"?Sn:Ln}let w=_(i),C=w(i);return{c(){e=h("div"),t=h("div"),s=R(n),l=b(),C.c(),r=b(),o=h("div"),o.textContent="loc",c=b(),d=h("div"),p=h("div"),f=b(),v=new Pi(!1),a(t,"class","name svelte-ci3g2p"),a(o,"class","label svelte-ci3g2p"),a(p,"class","location-color svelte-ci3g2p"),a(p,"style",m=`background: ${i[0].locationColor}`),v.a=null,a(d,"class","location-row"),a(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),a(e,"style",`font: ${li}; max-width: ${On}px;`)},m(y,A){L(y,e,A),u(e,t),u(t,s),u(e,l),C.m(e,null),u(e,r),u(e,o),u(e,c),u(e,d),u(d,p),u(d,f),v.m(i[1],d)},p(y,[A]){A&1&&n!==(n=y[0].name+"")&&ye(s,n),w===(w=_(y))&&C?C.p(y,A):(C.d(1),C=w(y),C&&(C.c(),C.m(e,r))),A&1&&m!==(m=`background: ${y[0].locationColor}`)&&a(p,"style",m),A&2&&v.p(y[1])},i:k,o:k,d(y){y&&I(e),C.d()}}}function ri(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Hn(i,e){i.font=li;const t=ri(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 On=310,li="400 13px Source Sans Pro, sans-serif";function Vn(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=Mt(n.location)),i.$$.dirty&1&&t(2,l=ri(n))},[n,s,l,r]}class $n extends fe{constructor(e){super(),de(this,e,Vn,Dn,re,{f:0})}}const Nn="#212325",ai=18,xn=17,Ie=28,lt=17,ci=29,Bn=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"].map(Zi);class zn extends In{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,"_rootFrame",null);T(this,"maxDepth",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()}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 $n({target:this.tooltipContainer,props:{f:l}}),this.tooltipLocation){const r={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},o=Hn(t,l),c=this.width-10-o;r.x>c&&(r.x=c);const p=this.height-10-60;r.y>p&&(r.y=p),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=Nn,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=>Ne(c,{from:[s,s-3],to:[.71,0],clamp:!0});for(let c=r;c.01){t.globalAlpha=v,t.font='13px "Source Sans Pro", sans-serif';let _=d.toFixed(c);_=="0"&&(_="0s");let w=f+10;t.fillText(_,p+3,w);let C=this.height+lt+10-this.yOffset;Cthis.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 p=Math.floor(r/3.3);if(d.length>p&&(d=d.substring(0,p)),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 m=s;m<0&&(m=0),t.fillText(d,m+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=Xi(Bn,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)*ai+lt*2+ci-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*ai+lt+ci-this.yOffset,s=xn;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-=Ne(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 Wn(i){let e;return{c(){e=h("div"),e.innerHTML="",a(e,"class","timeline svelte-p2tt1k")},m(t,n){L(t,e,n),i[6](e)},p:k,i:k,o:k,d(t){t&&I(e),i[6](null)}}}function qn(i,e,t){let n,{session:s}=e;const l=Vt([je],([p])=>({processors:[p.removeImportlib?Ft:null,p.removeTracebackHide?Pt:null,p.removePyinstrument?si:null].filter(v=>v!==null),options:{}}));ge(i,l,p=>t(5,n=p));let r,o=null,c=null;Ri(()=>{c==null||c.destroy()});function d(p){Pe[p?"unshift":"push"](()=>{o=p,t(0,o)})}return i.$$set=p=>{"session"in p&&t(2,s=p.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 zn(o)),i.$$.dirty&24&&r&&c&&c.setRootFrame(r)},[o,l,s,r,c,n,d]}class Un extends fe{constructor(e){super(),de(this,e,qn,Wn,re,{session:2})}}function Yn(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=R("Unknown view mode: "),s=R(n),a(e,"class","error")},m(l,r){L(l,e,r),u(e,t),u(e,s)},p(l,r){r&2&&n!==(n=l[1].viewMode+"")&&ye(s,n)},i:k,o:k,d(l){l&&I(e)}}}function Xn(i){let e,t;return e=new Un({props:{session:i[0]}}),{c(){_e(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 Gn(i){let e,t;return e=new Pn({props:{session:i[0]}}),{c(){_e(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;return{c(){e=h("div"),e.innerHTML='
No samples recorded.
',a(e,"class","margins")},m(t,n){L(t,e,n)},p:k,i:k,o:k,d(t){t&&I(e)}}}function Zn(i){let e,t,n,s,l,r,o,c;n=new mn({props:{session:i[0]}});const d=[jn,Gn,Xn,Yn],p=[];function m(f,v){return f[0].rootFrame?f[1].viewMode==="call-stack"?1:f[1].viewMode==="timeline"?2:3:0}return r=m(i),o=p[r]=d[r](i),{c(){e=h("div"),t=h("div"),_e(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(f,v){L(f,e,v),u(e,t),ce(n,t,null),u(e,s),u(e,l),p[r].m(l,null),c=!0},p(f,[v]){const _={};v&1&&(_.session=f[0]),n.$set(_);let w=r;r=m(f),r===w?p[r].p(f,v):(Oe(),x(p[w],1,1,()=>{p[w]=null}),Ve(),o=p[r],o?o.p(f,v):(o=p[r]=d[r](f),o.c()),D(o,1),o.m(l,null))},i(f){c||(D(n.$$.fragment,f),D(o),c=!0)},o(f){x(n.$$.fragment,f),x(o),c=!1},d(f){f&&I(e),ue(n),p[r].d()}}}function Kn(i,e,t){let n;ge(i,Ge,m=>t(1,n=m));let{session:s}=e;const l=document.createElement("link");l.rel="shortcut icon",l.href=pn,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,p;return(p=/[^\s/]+(:\d+)?$/.exec(s.target_description))?d=p[0]:d=s.target_description,document.title=`${c}s - ${d} - pyinstrument`,i.$$set=m=>{"session"in m&&t(0,s=m.session)},[s,n]}class Qn extends fe{constructor(e){super(),de(this,e,Kn,Zn,re,{session:0})}}class Jn{constructor(e){T(this,"startTime");T(this,"duration");T(this,"minInterval");T(this,"maxInterval");T(this,"sampleCount");T(this,"target_description");T(this,"cpuTime");T(this,"rootFrame");T(this,"sysPath");T(this,"sysPrefixes");T(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(xe(e).length>1)for(const s of this.sysPath){const l=es(e,s);xe(l).length0&&e[0].endsWith(":")?e[0]:null}function es(i,e){if(ui(i)!=ui(e))return i;const t=xe(i),n=xe(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}return{render(i,e){const t=new Jn(e);return new Qn({target:i,props:{session:t}})}}}(); + View options`),Ae=b(),z&&z.c(),a(s,"class","logo svelte-qdxst2"),a(c,"class","target-description svelte-qdxst2"),a(v,"class","metric-label svelte-qdxst2"),a(w,"class","metric-value svelte-qdxst2"),a(f,"class","metric date svelte-qdxst2"),a(y,"class","svelte-qdxst2"),a(H,"class","metric-label svelte-qdxst2"),a(F,"class","metric-value svelte-qdxst2"),a(P,"class","metric svelte-qdxst2"),a(V,"class","metric-label svelte-qdxst2"),a(B,"class","metric-value svelte-qdxst2"),a(M,"class","metric svelte-qdxst2"),a(m,"class","metrics svelte-qdxst2"),a(q,"type","radio"),q.__value="call-stack",ae(q,q.__value),a(q,"class","svelte-qdxst2"),a(Ee,"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(J,"class","toggle"),a(he,"class","spacer"),Z(he,"flex","1"),a(pe,"class","js-view-options-button svelte-qdxst2"),a(we,"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,G){L(O,e,G),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,p),u(o,m),u(m,f),u(f,v),u(f,_),u(f,w),u(m,C),u(m,y),u(m,A),u(m,P),u(P,H),u(P,W),u(P,F),u(F,S),u(m,g),u(m,M),u(M,V),u(M,Y),u(M,B),u(o,Le),u(o,ee),u(ee,J),u(J,X),u(J,Ee),u(Ee,q),q.checked=q.__value===i[2].viewMode,u(Ee,Qe),u(J,Je),u(J,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,we),u(we,pe),ce(Te,pe,null),u(pe,tt),u(we,Ae),z&&z.m(we,null),Q=!0,Me||(it=[N(q,"change",i[6]),N(U,"change",i[8]),N(pe,"click",gt(vt(i[5])))],Me=!0)},p(O,[G]){(!Q||G&1)&&d!==(d=Mt(O[0].target_description)+"")&&(c.innerHTML=d),(!Q||G&1)&&E!==(E=O[0].sampleCount+"")&&ye(S,E),G&4&&(q.checked=q.__value===O[2].viewMode),G&4&&(U.checked=U.__value===O[2].viewMode),O[1]?z?(z.p(O,G),G&2&&D(z,1)):(z=Nt(O),z.c(),D(z,1),z.m(we,null)):z&&(Oe(),x(z,1,1,()=>{z=null}),Ve())},i(O){Q||(D(l.$$.fragment,O),D(Te.$$.fragment,O),D(z),Q=!0)},o(O){x(l.$$.fragment,O),x(Te.$$.fragment,O),x(z),Q=!1},d(O){O&&I(e),ue(l),ue(Te),z&&z.d(),Be.r(),Me=!1,oe(it)}}}function hn(i,e,t){let n;ge(i,Ge,v=>t(2,n=v));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(v){t(1,o=!o)}const d=[[]];function p(){n.viewMode=this.__value,Ge.set(n)}function m(){n.viewMode=this.__value,Ge.set(n)}const f=()=>t(1,o=!1);return i.$$set=v=>{"session"in v&&t(0,s=v.session)},[s,o,n,l,r,c,p,d,m,f]}class mn extends fe{constructor(e){super(),de(this,e,hn,fn,re,{session:0})}}const pn="data:image/png;base64,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",xt=st({}),Bt=st({});function zt(i){return i>.6?"#FF4159":i>.3?"#F5A623":i>.2?"#D8CB2A":"#7ED321"}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,p,m,f,v,_,w,C;return{c(){e=h("div"),t=h("div"),n=$("svg"),s=$("path"),l=b(),r=h("div"),o=R(i[5]),c=b(),d=h("div"),p=R(i[4]),m=b(),f=h("div"),f.textContent=`${i[11]}`,v=b(),_=h("div"),a(s,"d","M.937-.016L5.793 4.84.937 9.696z"),a(s,"fill",i[7]),a(s,"fill-rule","evenodd"),a(s,"fill-opacity",".582"),a(n,"width","6"),a(n,"height","10"),a(t,"class","frame-triangle svelte-14yvyii"),Ce(t,"rotate",!i[8]),Z(t,"visibility",i[0].children.length>0?"visible":"hidden"),a(r,"class","time svelte-14yvyii"),Z(r,"color",i[7]),Z(r,"font-weight",i[10]<.2?500:600),a(d,"class","name svelte-14yvyii"),a(f,"class","code-position svelte-14yvyii"),a(e,"class","frame-description svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Ce(e,"application-code",i[0].isApplicationCode),Ce(e,"children-visible",!i[8]),Z(e,"padding-left",`${i[2]*35}px`),a(_,"class","visual-guide svelte-14yvyii"),Z(_,"left",`${i[2]*35+21}px`),Z(_,"backgroundColor",i[7])},m(y,A){L(y,e,A),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,p),u(e,m),u(e,f),L(y,v,A),L(y,_,A),w||(C=[N(e,"keydown",i[14]),N(e,"click",gt(vt(i[12])))],w=!0)},p(y,A){A&128&&a(s,"fill",y[7]),A&256&&Ce(t,"rotate",!y[8]),A&1&&Z(t,"visibility",y[0].children.length>0?"visible":"hidden"),A&32&&ye(o,y[5]),A&128&&Z(r,"color",y[7]),A&16&&ye(p,y[4]),A&1&&Ce(e,"application-code",y[0].isApplicationCode),A&256&&Ce(e,"children-visible",!y[8]),A&4&&Z(e,"padding-left",`${y[2]*35}px`),A&4&&Z(_,"left",`${y[2]*35+21}px`),A&128&&Z(_,"backgroundColor",y[7])},d(y){y&&(I(e),I(v),I(_)),w=!1,oe(C)}}}function Ut(i){let e,t,n,s,l=i[0].group.frames.length+"",r,o,c,d,p,m;return{c(){e=h("div"),t=h("div"),n=h("div"),n.innerHTML='',s=b(),r=R(l),o=R(" frames hidden ("),c=R(i[6]),d=R(")"),a(n,"class","group-triangle svelte-14yvyii"),Ce(n,"rotate",i[9]),a(t,"class","group-header-button svelte-14yvyii"),a(e,"class","group-header svelte-14yvyii"),a(e,"role","button"),a(e,"tabindex","0"),Z(e,"padding-left",`${i[2]*35}px`)},m(f,v){L(f,e,v),u(e,t),u(t,n),u(t,s),u(t,r),u(t,o),u(t,c),u(t,d),p||(m=[N(e,"keydown",i[15]),N(e,"click",gt(vt(i[13])))],p=!0)},p(f,v){v&512&&Ce(n,"rotate",f[9]),v&1&&l!==(l=f[0].group.frames.length+"")&&ye(r,l),v&64&&ye(c,f[6]),v&4&&Z(e,"padding-left",`${f[2]*35}px`)},d(f){f&&I(e),p=!1,oe(m)}}}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-14yvyii")},m(c,d){L(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[8]?r?r.p(c,d):(r=Ut(c),r.c(),r.m(e,n)):r&&(r.d(1),r=null),!c[8]&&c[0].children.length>0?o?(o.p(c,d),d&257&&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&&I(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 gn(i,e,t){var S;let n,s,l,r,o;ge(i,Bt,g=>t(16,l=g)),ge(i,xt,g=>t(17,r=g)),ge(i,K,g=>t(18,o=g));let{frame:c}=e,{rootFrame:d}=e,{indent:p=0}=e,m;const f=c.time/d.time;let v;const _=`${c.filePathShort}:${(S=c.lineNo)==null?void 0:S.toString().padEnd(4," ")}`;let w,C=null;if(c.group){const g=c.group.libraries;g.length<4?C=g.join(", "):C=`${g[0]}, ${g[1]}, ${g[2]}...`}let y;y=zt(f);function A(g){P(c,!s,g.altKey)}function P(g,M,V=!0){if(Bt.update(Y=>({...Y,[g.uuid]:M})),V)for(const Y of g.children)P(Y,M,!0),g.group&&g.group.rootFrame==g&&H(g.group.id,!M)}function H(g,M){xt.update(V=>({...V,[g]:M}))}function W(){c.group&&H(c.group.id,!n)}function F(g){let M=!0;g.key==="Enter"||g.key===" "?A(g):g.key==="ArrowLeft"&&!s?P(c,!0,g.altKey):g.key==="ArrowRight"&&s?P(c,!1,g.altKey):g.key==="ArrowUp"?Zt():g.key==="ArrowDown"?jt():M=!1,M&&(g.preventDefault(),g.stopPropagation())}function E(g){let M=!0;g.key==="Enter"||g.key===" "?W():g.key==="ArrowLeft"&&c.group?H(c.group.id,!1):g.key==="ArrowRight"&&c.group?H(c.group.id,!0):g.key==="ArrowUp"?Zt():g.key==="ArrowDown"?jt():M=!1,M&&(g.preventDefault(),g.stopPropagation())}return i.$$set=g=>{"frame"in g&&t(0,c=g.frame),"rootFrame"in g&&t(1,d=g.rootFrame),"indent"in g&&t(2,p=g.indent)},i.$$.update=()=>{var g,M;if(i.$$.dirty&131073&&(c.group?r[c.group.id??""]||((g=c.group)==null?void 0:g.rootFrame)===c||c.children.filter(V=>!V.group).length>1?t(3,m=!0):t(3,m=!1):t(3,m=!0)),i.$$.dirty&1&&(c.className?t(4,v=`${c.className}.${c.function}`):t(4,v=c.function)),i.$$.dirty&262145)if(o.timeFormat==="absolute")t(5,w=c.time.toLocaleString(void 0,{minimumFractionDigits:3,maximumFractionDigits:3}));else if(o.timeFormat==="proportion")t(5,w=`${(f*100).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1})}%`);else throw new Error("unknown timeFormat");i.$$.dirty&131073&&t(9,n=r[((M=c.group)==null?void 0:M.id)??""]===!0),i.$$.dirty&65537&&t(8,s=l[c.uuid]===!0)},[c,d,p,m,v,w,C,y,s,n,f,_,A,W,F,E,l,r,o]}let Kt=class extends fe{constructor(e){super(),de(this,e,gn,vn,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 _n="\0",wn="[await]",Ze="[self]",bn=[wn,Ze,"[out-of-context]","[root]"],yn="c",Tn="h";class Ke{constructor(e,t){T(this,"uuid",ot());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 l;this.identifier=e.identifier,this._identifierParts=this.identifier.split(_n),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(Tn)=="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 bn.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(yn)??""}get library(){const e=this.filePathShort;return e?/^[\\/.]*[^\\/.]*/.exec(e)[0]??"":null}}class An{constructor(e){T(this,"id");T(this,"rootFrame");T(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 Yi(t);i.removeFromParent(),kt(i,!0)}function Cn(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(),kt(i,!1)}function kt(i,e){if(e&&i.children&&i.children.forEach(t=>{kt(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 An(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=>Ji(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 En(i){let e,t,n;return t=new Kt({props:{frame:i[2],rootFrame:i[2]}}),{c(){e=h("div"),_e(t.$$.fragment),a(e,"class","call-stack-margins svelte-16921do")},m(s,l){L(s,e,l),ce(t,e,null),n=!0},p(s,l){const r={};l&4&&(r.frame=s[2]),l&4&&(r.rootFrame=s[2]),t.$set(r)},i(s){n||(D(t.$$.fragment,s),n=!0)},o(s){x(t.$$.fragment,s),n=!1},d(s){s&&I(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){L(t,e,n)},p:k,i:k,o:k,d(t){t&&I(e)}}}function kn(i){let e,t,n,s,l;const r=[Mn,En],o=[];function c(d,p){return d[2]?1:0}return n=c(i),s=o[n]=r[n](i),{c(){e=h("div"),t=h("div"),s.c(),a(t,"class","scroll-inner svelte-16921do"),a(e,"class","call-stack-view svelte-16921do")},m(d,p){L(d,e,p),u(e,t),o[n].m(t,null),i[6](t),i[7](e),l=!0},p(d,[p]){let m=n;n=c(d),n===m?o[n].p(d,p):(Oe(),x(o[m],1,1,()=>{o[m]=null}),Ve(),s=o[n],s?s.p(d,p):(s=o[n]=r[n](d),s.c()),D(s,1),s.m(t,null))},i(d){l||(D(s),l=!0)},o(d){x(s),l=!1},d(d){d&&I(e),o[n].d(),i[6](null),i[7](null)}}}function Fn(i,e,t){let n,{session:s}=e;const l=Vt([K],([m])=>{const f=[m.removeImportlib?Ft:null,m.removeTracebackHide?Pt:null,ti,Jt,ii,m.removeIrrelevant?ni:null,m.removePyinstrument?si:null,m.collapseMode!=="disabled"?ei:null].filter(_=>_!==null),v={filterThreshold:m.removeIrrelevantThreshold,hideRegex:m.collapseMode=="custom"?m.collapseCustomHide:void 0,showRegex:m.collapseMode=="custom"?m.collapseCustomShow:void 0};return{processors:f,options:v}});ge(i,l,m=>t(5,n=m));let r,o;bt(()=>{const m=r;if(!m)throw new Error("element not set");let f;return m.addEventListener("scroll",f=()=>{t(1,o.style.minHeight=`${Math.floor(m.scrollTop+m.clientHeight)}px`,o)}),f(),()=>{m.removeEventListener("scroll",f)}});let c;function d(m){Pe[m?"unshift":"push"](()=>{o=m,t(1,o)})}function p(m){Pe[m?"unshift":"push"](()=>{r=m,t(0,r)})}return i.$$set=m=>{"session"in m&&t(4,s=m.session)},i.$$.update=()=>{i.$$.dirty&48&&t(2,c=Qt(s.rootFrame.cloneDeep(),n.processors,n.options))},[r,o,c,l,s,n,d,p]}class Pn extends fe{constructor(e){super(),de(this,e,Fn,kn,re,{session:4})}}class Rn{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 In{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 Rn(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 Ln(i){let e,t=i[2]=="self"?"self":"time",n,s,l,r=i[3](i[0].time)+"";return{c(){e=h("div"),n=R(t),s=b(),l=h("div"),a(e,"class","label svelte-ci3g2p"),a(l,"class","time-val svelte-ci3g2p")},m(o,c){L(o,e,c),u(e,n),L(o,s,c),L(o,l,c),l.innerHTML=r},p(o,c){c&4&&t!==(t=o[2]=="self"?"self":"time")&&ye(n,t),c&1&&r!==(r=o[3](o[0].time)+"")&&(l.innerHTML=r)},d(o){o&&(I(e),I(s),I(l))}}}function Sn(i){let e,t,n,s,l=i[3](i[0].time)+"",r,o=i[0].selfTime/i[0].time>.001&&oi(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){L(c,e,d),L(c,t,d),L(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=oi(c),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(c){c&&(I(e),I(t),I(n)),o&&o.d()}}}function oi(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){L(l,e,r),L(l,t,r),L(l,n,r),n.innerHTML=s},p(l,r){r&1&&s!==(s=l[3](l[0].selfTime)+"")&&(n.innerHTML=s)},d(l){l&&(I(e),I(t),I(n))}}}function Dn(i){let e,t,n=i[0].name+"",s,l,r,o,c,d,p,m,f,v;function _(y,A){return y[2]=="both"?Sn:Ln}let w=_(i),C=w(i);return{c(){e=h("div"),t=h("div"),s=R(n),l=b(),C.c(),r=b(),o=h("div"),o.textContent="loc",c=b(),d=h("div"),p=h("div"),f=b(),v=new Pi(!1),a(t,"class","name svelte-ci3g2p"),a(o,"class","label svelte-ci3g2p"),a(p,"class","location-color svelte-ci3g2p"),a(p,"style",m=`background: ${i[0].locationColor}`),v.a=null,a(d,"class","location-row"),a(e,"class","timeline-canvas-view-tooltip svelte-ci3g2p"),a(e,"style",`font: ${li}; max-width: ${On}px;`)},m(y,A){L(y,e,A),u(e,t),u(t,s),u(e,l),C.m(e,null),u(e,r),u(e,o),u(e,c),u(e,d),u(d,p),u(d,f),v.m(i[1],d)},p(y,[A]){A&1&&n!==(n=y[0].name+"")&&ye(s,n),w===(w=_(y))&&C?C.p(y,A):(C.d(1),C=w(y),C&&(C.c(),C.m(e,r))),A&1&&m!==(m=`background: ${y[0].locationColor}`)&&a(p,"style",m),A&2&&v.p(y[1])},i:k,o:k,d(y){y&&I(e),C.d()}}}function ri(i){return i.selfTime==i.time?"self":i.selfTime/i.time>.001?"both":"time"}function Hn(i,e){i.font=li;const t=ri(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 On=310,li="400 13px Source Sans Pro, sans-serif";function Vn(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=Mt(n.location)),i.$$.dirty&1&&t(2,l=ri(n))},[n,s,l,r]}class $n extends fe{constructor(e){super(),de(this,e,Vn,Dn,re,{f:0})}}const Nn="#212325",ai=18,xn=17,Ie=28,lt=17,ci=29,Bn=["#3475BA","#318DBC","#47A298","#8AAE5D","#C1A731","#C07210","#B84210","#B53134","#9A3586","#4958B5","#3475BA"].map(Zi);class zn extends In{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,"_rootFrame",null);T(this,"maxDepth",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()}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 $n({target:this.tooltipContainer,props:{f:l}}),this.tooltipLocation){const r={x:this.tooltipLocation.x+12,y:this.tooltipLocation.y+12},o=Hn(t,l),c=this.width-10-o;r.x>c&&(r.x=c);const p=this.height-10-60;r.y>p&&(r.y=p),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=Nn,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=>Ne(c,{from:[s,s-3],to:[.71,0],clamp:!0});for(let c=r;c.01){t.globalAlpha=v,t.font='13px "Source Sans Pro", sans-serif';let _=d.toFixed(c);_=="0"&&(_="0s");let w=f+10;t.fillText(_,p+3,w);let C=this.height+lt+10-this.yOffset;Cthis.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 p=Math.floor(r/3.3);if(d.length>p&&(d=d.substring(0,p)),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 m=s;m<0&&(m=0),t.fillText(d,m+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=Xi(Bn,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)*ai+lt*2+ci-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*ai+lt+ci-this.yOffset,s=xn;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-=Ne(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 Wn(i){let e;return{c(){e=h("div"),e.innerHTML="",a(e,"class","timeline svelte-p2tt1k")},m(t,n){L(t,e,n),i[6](e)},p:k,i:k,o:k,d(t){t&&I(e),i[6](null)}}}function qn(i,e,t){let n,{session:s}=e;const l=Vt([je],([p])=>({processors:[p.removeImportlib?Ft:null,p.removeTracebackHide?Pt:null,p.removePyinstrument?si:null].filter(v=>v!==null),options:{}}));ge(i,l,p=>t(5,n=p));let r,o=null,c=null;Ri(()=>{c==null||c.destroy()});function d(p){Pe[p?"unshift":"push"](()=>{o=p,t(0,o)})}return i.$$set=p=>{"session"in p&&t(2,s=p.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 zn(o)),i.$$.dirty&24&&r&&c&&c.setRootFrame(r)},[o,l,s,r,c,n,d]}class Un extends fe{constructor(e){super(),de(this,e,qn,Wn,re,{session:2})}}function Yn(i){let e,t,n=i[1].viewMode+"",s;return{c(){e=h("div"),t=R("Unknown view mode: "),s=R(n),a(e,"class","error")},m(l,r){L(l,e,r),u(e,t),u(e,s)},p(l,r){r&2&&n!==(n=l[1].viewMode+"")&&ye(s,n)},i:k,o:k,d(l){l&&I(e)}}}function Xn(i){let e,t;return e=new Un({props:{session:i[0]}}),{c(){_e(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 Gn(i){let e,t;return e=new Pn({props:{session:i[0]}}),{c(){_e(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;return{c(){e=h("div"),e.innerHTML='
No samples recorded.
',a(e,"class","margins")},m(t,n){L(t,e,n)},p:k,i:k,o:k,d(t){t&&I(e)}}}function Zn(i){let e,t,n,s,l,r,o,c;n=new mn({props:{session:i[0]}});const d=[jn,Gn,Xn,Yn],p=[];function m(f,v){return f[0].rootFrame?f[1].viewMode==="call-stack"?1:f[1].viewMode==="timeline"?2:3:0}return r=m(i),o=p[r]=d[r](i),{c(){e=h("div"),t=h("div"),_e(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(f,v){L(f,e,v),u(e,t),ce(n,t,null),u(e,s),u(e,l),p[r].m(l,null),c=!0},p(f,[v]){const _={};v&1&&(_.session=f[0]),n.$set(_);let w=r;r=m(f),r===w?p[r].p(f,v):(Oe(),x(p[w],1,1,()=>{p[w]=null}),Ve(),o=p[r],o?o.p(f,v):(o=p[r]=d[r](f),o.c()),D(o,1),o.m(l,null))},i(f){c||(D(n.$$.fragment,f),D(o),c=!0)},o(f){x(n.$$.fragment,f),x(o),c=!1},d(f){f&&I(e),ue(n),p[r].d()}}}function Kn(i,e,t){let n;ge(i,Ge,m=>t(1,n=m));let{session:s}=e;const l=document.createElement("link");l.rel="shortcut icon",l.href=pn,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,p;return(p=/[^\s/]+(:\d+)?$/.exec(s.target_description))?d=p[0]:d=s.target_description,document.title=`${c}s - ${d} - pyinstrument`,i.$$set=m=>{"session"in m&&t(0,s=m.session)},[s,n]}class Qn extends fe{constructor(e){super(),de(this,e,Kn,Zn,re,{session:0})}}class Jn{constructor(e){T(this,"startTime");T(this,"duration");T(this,"minInterval");T(this,"maxInterval");T(this,"sampleCount");T(this,"target_description");T(this,"cpuTime");T(this,"rootFrame");T(this,"sysPath");T(this,"sysPrefixes");T(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(xe(e).length>1)for(const s of this.sysPath){const l=es(e,s);xe(l).length0&&e[0].endsWith(":")?e[0]:null}function es(i,e){if(ui(i)!=ui(e))return i;const t=xe(i),n=xe(e);let s=0;for(;s"..").concat(t.slice(s)).join("/")}return{render(i,e){const t=new Jn(e);return new Qn({target:i,props:{session:t}})}}}();