-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path0ZriSCq6.js
More file actions
5 lines (5 loc) · 114 KB
/
Copy path0ZriSCq6.js
File metadata and controls
5 lines (5 loc) · 114 KB
1
2
3
4
5
import{u as Ut,_ as Gt}from"./Cuqdu9nB.js";import{_ as Bt,S as z,I as Vt}from"./BefdN0MI.js";import{_ as q,d as J,l as _,m as _e,A as Kt,o as H,a as I,b as E,q as le,B as qt,t as ee,g as j,s as ne,F as ut,c as B,C as Qt,f as X,w as $,e as N,u as x,r as jt,h as ae,D as Zt,E as gt,G as fe,H as be,I as Jt,p as ft,i as pt,j as ei,k as ti,n as ii}from"./BqbMuE7y.js";import{u as ni}from"./DU45Wy3H.js";import{i as si}from"./BBk2F9bR.js";import{u as ri,P as oi}from"./k1uqWTyJ.js";import{S as vt,u as ai}from"./DdKTkMGq.js";import{q as li,W as Ge}from"./BIL_AGmQ.js";import{u as hi}from"./CF6J2D0o.js";const He=q(Bt,[["__scopeId","data-v-77d01412"]]);var F=(t=>(t.CPU="cpu",t.MEMORY_CHANGE="pmu",t.MEMORY="mu",t.CALLS="calls",t))(F||{});const{formatDuration:ye,formatFileSize:Ee}=hi(),ci=t=>t<=1?"#fff":t<=10?"#7BC8F6":t<=25?"#4DA6FF":t<=50?"#1A8FFF":t<=75?"#007FFF":t<=100?"#0059B3":t<=250?"#FFD700":t<=500?"#FFA500":t<=750?"#FF8C00":t<=1e3?"#FF4500":t<=2500?"#FF0000":"#8B0000",di=t=>t<=10?"#FFFFFF":t<=20?"#f19797":t<=30?"#d93939":t<=40?"#ad1e1e":t<=50?"#982525":t<=60?"#862323":t<=70?"#671d1d":t<=80?"#540d0d":t<=90?"#340707":"#2d0606",ui=t=>{const e=t.replace("#",""),i=parseInt(e.substr(0,2),16),n=parseInt(e.substr(2,2),16),s=parseInt(e.substr(4,2),16);return(i*299+n*587+s*114)/1e3>=128?"#000":"#fff"},gi=(t,e)=>{var n;const i={p_mu:s=>`${s}%`,p_pmu:s=>`${s}%`,p_cpu:s=>`${s}%`,p_wt:s=>`${s}%`,mu:Ee,d_mu:Ee,pmu:Ee,d_pmu:Ee,cpu:ye,d_cpu:ye,wt:ye,d_wt:ye};return((n=i[e])==null?void 0:n.call(i,t))||t},fi=(t,e,i=1,n=10)=>Object.values(t).reduce((s,r,o)=>{let a="#fff",l="#000",h="#fff",c=r.cost.ct>1?`${r.cost.ct}x`:"";if(e===F.CALLS){const u="ct";if(!(r.cost[u]>=n))return s;a=ci(r.cost[u])}else{const u=`p_${e}`,b=r.cost[u]>=n;if(!b&&r.cost[u]<=i)return s;a=b?di(r.cost[u]):"#fff",l=b?ui(a):"#000",h=a;const y=r.cost.ct>1?` [ ${r.cost.ct}x ]`:"";c=`${gi(r.cost[u],u)}${y}`}const d=`p_${e}`;if(!(r.cost.p_pmu>10)&&r.cost[d]<=i)return s;s.nodes.push({data:{id:r.callee,name:r.callee,cost:r.cost,color:a,textColor:l}});const g=s.nodes.find(u=>u.data.id===r.caller);return o>0&&g&&s.edges.push({data:{source:r.caller||"",target:r.callee,color:h,label:c,weight:r.cost.ct}}),s},{nodes:[],edges:[]}),pi=()=>({initialize:si,buildData:fi}),{buildData:vi,initialize:mi}=pi(),mt=()=>({prepare:vi,initialize:mi}),bi={key:0},yi={class:"render-graph__tooltip-title"},Ei=J({__name:"render-graph",props:{elements:{},height:{}},setup(t){const e=t,i=_(),n=_(),s=_(),r=_(),o=_(),a=_(),l=(c,d)=>{if(!c||!d){i.value=void 0,n.value=void 0;return}i.value=c.data();const p=d.offsetX,g=d.offsetY,{clientHeight:u=0,clientWidth:b=0}=a.value,{offsetHeight:y=0,offsetWidth:v=0}=o.value;let f=g,w=p;if(b+p>v-80){const P=b+p-v+100;w-=P}u+g>y&&(f=g-u),n.value={top:`${f+20}px`,left:`${w}px`}},{initialize:h}=mt();return _e(()=>{s.value=h({container:r.value,elements:e.elements,onNodeHover:l})}),Kt(()=>{s.value()}),(c,d)=>(H(),I(ut,null,[E("div",{ref_key:"parent",ref:o,class:"render-graph",style:le({height:`${c.height}px`})},[E("div",{ref_key:"renderer",ref:r,class:"render-graph__in"},null,512)],4),E("div",{ref_key:"tooltip",ref:a,class:ne(["render-graph__tooltip",{"render-graph__tooltip--active":i.value}]),style:le(n.value)},[i.value?(H(),I("div",bi,[qt(c.$slots,"default",{data:i.value},()=>[E("h4",yi,ee(i.value),1)],!0)])):j("",!0)],6)],64))}}),xi=q(Ei,[["__scopeId","data-v-5ef20918"]]),wi={class:"call-stack-row__usage"},Ci={class:"call-stack-row__usage-title"},Ri={class:"call-stack-row__calls"},ki=J({__name:"call-stack-row",props:{edge:{}},emits:["hover","hide"],setup(t,{emit:e}){const i=t,n=e,s=(l,h)=>{n("hover",{callee:h.callee,cost:h.cost,caller:h.caller,position:{x:l.pageX,y:l.pageY}})},r=l=>Math.min(100,Math.max(0,l)),o=B(()=>({width:`${r(i.edge.cost.p_cpu)}%`})),a=B(()=>({width:`${r(i.edge.cost.p_mu)}%`}));return(l,h)=>(H(),I("div",{class:"call-stack-row",onMouseover:h[0]||(h[0]=c=>s(c,l.edge)),onMouseout:h[1]||(h[1]=c=>l.$emit("hide"))},[E("div",wi,[E("div",{class:"call-stack-row__usage-cpu",style:le(o.value)},null,4),E("div",{class:"call-stack-row__usage-memory",style:le(a.value)},null,4),E("div",Ci,ee(l.edge.cost.p_cpu)+"% / "+ee(l.edge.cost.p_mu)+"% ",1)]),E("div",Ri,ee(l.edge.cost.ct),1)],32))}}),Mi=q(ki,[["__scopeId","data-v-15b83beb"]]),Si={class:"call-stack"},Ti={class:"call-stack__header"},_i={class:"call-stack__header-cpu"},Pi={class:"call-stack__header-calls"},Hi={class:"call-stack__calls"},Fi=J({__name:"call-stack",props:{payload:{}},emits:["hover","hide"],setup(t){const e=t,i=Qt({CPU:z.ASC,memory:z.DEFAULT,calls:z.DEFAULT}),n=B(()=>Object.entries(e.payload.edges).sort(([,r],[,o])=>i.CPU===z.ASC?o.cost.p_cpu-r.cost.p_cpu:i.CPU===z.DESC?r.cost.p_cpu-o.cost.p_cpu:i.memory===z.ASC?o.cost.p_mu-r.cost.p_mu:i.memory===z.DESC?r.cost.p_mu-o.cost.p_mu:i.calls===z.ASC?o.cost.ct-r.cost.ct:i.calls===z.DESC?r.cost.ct-o.cost.ct:0).reduce((r,[o,a])=>({...r,[o]:a}),{})),s=r=>o=>{Object.keys(i).forEach(a=>{const l=a;l!==r?i[l]=z.DEFAULT:i[l]=o===z.DEFAULT?z.ASC:o})};return(r,o)=>(H(),I("div",Si,[E("header",Ti,[E("div",_i,[X(x(He),{sort:i.CPU,onChangeSort:o[0]||(o[0]=a=>s("CPU")(a))},{default:$(()=>[N(" CPU ")]),_:1},8,["sort"]),N(" / "),X(x(He),{sort:i.memory,onChangeSort:o[1]||(o[1]=a=>s("memory")(a))},{default:$(()=>[N(" memory ")]),_:1},8,["sort"])]),E("div",Pi,[X(x(He),{sort:i.calls,onChangeSort:o[2]||(o[2]=a=>s("calls")(a))},{default:$(()=>[N(" Calls ")]),_:1},8,["sort"])])]),E("div",Hi,[(H(!0),I(ut,null,jt(n.value,(a,l)=>(H(),ae(x(Mi),{key:l,edge:a,onHover:o[3]||(o[3]=h=>r.$emit("hover",h)),onHide:o[4]||(o[4]=h=>r.$emit("hide"))},null,8,["edge"]))),128))])]))}}),Li=q(Fi,[["__scopeId","data-v-57da93b2"]]),Xi={class:"call-stat-board"},Ai={class:"call-stat-board__title"},Wi=J({__name:"call-stat-board",props:{edge:{}},setup(t){return(e,i)=>(H(),I("div",Xi,[E("h4",Ai,ee(e.edge.callee),1),X(x(vt),{class:"call-stat-board__body",cost:e.edge.cost},null,8,["cost"])]))}}),bt=q(Wi,[["__scopeId","data-v-e34163d2"]]),Yi={class:"call-graph__toolbar"},Di={class:"call-graph__toolbar call-graph__toolbar--right"},zi={key:0,class:"call-graph__toolbar-input-wr"},$i=["value"],Ii={class:"call-graph__toolbar-input-wr"},Oi=["value","min","max","step"],Ni=J({__name:"call-graph",props:{payload:{}},setup(t){const{prepare:e}=mt(),i=t,n=_(!1),s=_(F.CPU),r=_(1),o=_(10),a=_(!1),l=_(),h=B(()=>e(i.payload.edges,s.value,r.value,o.value)),c=B(()=>s.value===F.CALLS?"Min calls":"Percent"),d=B(()=>`${s.value}-${r.value}-${o.value}`),p=B(()=>n.value?window.innerHeight:l.value.offsetHeight);_e(()=>{a.value=!0});const g=y=>{s.value=y},u=y=>{r.value=y},b=y=>{o.value=y};return(y,v)=>(H(),I("div",{ref_key:"container",ref:l,class:ne(["call-graph",{"call-graph--fullscreen":n.value}])},[a.value&&d.value?(H(),ae(x(xi),{key:d.value,class:"call-graph__graph",elements:h.value,height:p.value},{default:$(({data:{name:f,cost:w}})=>[X(x(bt),{edge:{callee:f,caller:"",cost:w}},null,8,["edge"])]),_:1},8,["elements","height"])):j("",!0),E("div",Yi,[E("button",{title:"Full screen",onClick:v[0]||(v[0]=f=>n.value=!n.value)},[X(x(Vt),{name:"fullscreen",class:"call-graph__toolbar-icon"})]),E("button",{class:ne(["call-graph__toolbar-action",{"call-graph__toolbar-action--active":s.value===x(F).CPU}]),onClick:v[1]||(v[1]=f=>g(x(F).CPU))}," CPU ",2),E("button",{class:ne(["call-graph__toolbar-action",{"call-graph__toolbar-action--active":s.value===x(F).MEMORY_CHANGE}]),onClick:v[2]||(v[2]=f=>g(x(F).MEMORY_CHANGE))}," Memory change ",2),E("button",{class:ne(["call-graph__toolbar-action",{"call-graph__toolbar-action--active":s.value===x(F).MEMORY}]),onClick:v[3]||(v[3]=f=>g(x(F).MEMORY))}," Memory usage ",2),E("button",{class:ne(["call-graph__toolbar-action",{"call-graph__toolbar-action--active":s.value===x(F).CALLS}]),onClick:v[4]||(v[4]=f=>g(x(F).CALLS))}," Calls ",2)]),E("div",Di,[s.value!==x(F).CALLS?(H(),I("label",zi,[N(" Threshold "),E("input",{class:"call-graph__toolbar-input",type:"number",value:r.value,min:0,max:10,step:.1,onInput:v[5]||(v[5]=f=>u(f.target.value))},null,40,$i)])):j("",!0),E("label",Ii,[N(ee(c.value)+" ",1),E("input",{class:"call-graph__toolbar-input",type:"number",value:o.value,min:s.value===x(F).CALLS?1:0,max:s.value===x(F).CALLS?1e3:100,step:s.value===x(F).CALLS?10:5,onInput:v[6]||(v[6]=f=>b(f.target.value))},null,40,Oi)])])],2))}}),Ui=q(Ni,[["__scopeId","data-v-9007d666"]]);/*!
* perfect-scrollbar v1.5.3
* Copyright 2021 Hyunje Jun, MDBootstrap and Contributors
* Licensed under MIT
*/function U(t){return getComputedStyle(t)}function W(t,e){for(var i in e){var n=e[i];typeof n=="number"&&(n=n+"px"),t.style[i]=n}return t}function xe(t){var e=document.createElement("div");return e.className=t,e}var Be=typeof Element<"u"&&(Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector);function Q(t,e){if(!Be)throw new Error("No element matching method supported");return Be.call(t,e)}function oe(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function Ve(t,e){return Array.prototype.filter.call(t.children,function(i){return Q(i,e)})}var S={main:"ps",rtl:"ps__rtl",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",clicking:"ps--clicking",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},yt={x:null,y:null};function Et(t,e){var i=t.element.classList,n=S.state.scrolling(e);i.contains(n)?clearTimeout(yt[e]):i.add(n)}function xt(t,e){yt[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(S.state.scrolling(e))},t.settings.scrollingThreshold)}function Gi(t,e){Et(t,e),xt(t,e)}var pe=function(e){this.element=e,this.handlers={}},wt={isEmpty:{configurable:!0}};pe.prototype.bind=function(e,i){typeof this.handlers[e]>"u"&&(this.handlers[e]=[]),this.handlers[e].push(i),this.element.addEventListener(e,i,!1)};pe.prototype.unbind=function(e,i){var n=this;this.handlers[e]=this.handlers[e].filter(function(s){return i&&s!==i?!0:(n.element.removeEventListener(e,s,!1),!1)})};pe.prototype.unbindAll=function(){for(var e in this.handlers)this.unbind(e)};wt.isEmpty.get=function(){var t=this;return Object.keys(this.handlers).every(function(e){return t.handlers[e].length===0})};Object.defineProperties(pe.prototype,wt);var he=function(){this.eventElements=[]};he.prototype.eventElement=function(e){var i=this.eventElements.filter(function(n){return n.element===e})[0];return i||(i=new pe(e),this.eventElements.push(i)),i};he.prototype.bind=function(e,i,n){this.eventElement(e).bind(i,n)};he.prototype.unbind=function(e,i,n){var s=this.eventElement(e);s.unbind(i,n),s.isEmpty&&this.eventElements.splice(this.eventElements.indexOf(s),1)};he.prototype.unbindAll=function(){this.eventElements.forEach(function(e){return e.unbindAll()}),this.eventElements=[]};he.prototype.once=function(e,i,n){var s=this.eventElement(e),r=function(o){s.unbind(i,r),n(o)};s.bind(i,r)};function we(t){if(typeof window.CustomEvent=="function")return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function Me(t,e,i,n,s){n===void 0&&(n=!0),s===void 0&&(s=!1);var r;if(e==="top")r=["contentHeight","containerHeight","scrollTop","y","up","down"];else if(e==="left")r=["contentWidth","containerWidth","scrollLeft","x","left","right"];else throw new Error("A proper axis should be provided");Bi(t,i,r,n,s)}function Bi(t,e,i,n,s){var r=i[0],o=i[1],a=i[2],l=i[3],h=i[4],c=i[5];n===void 0&&(n=!0),s===void 0&&(s=!1);var d=t.element;t.reach[l]=null,d[a]<1&&(t.reach[l]="start"),d[a]>t[r]-t[o]-1&&(t.reach[l]="end"),e&&(d.dispatchEvent(we("ps-scroll-"+l)),e<0?d.dispatchEvent(we("ps-scroll-"+h)):e>0&&d.dispatchEvent(we("ps-scroll-"+c)),n&&Gi(t,l)),t.reach[l]&&(e||s)&&d.dispatchEvent(we("ps-"+l+"-reach-"+t.reach[l]))}function k(t){return parseInt(t,10)||0}function Vi(t){return Q(t,"input,[contenteditable]")||Q(t,"select,[contenteditable]")||Q(t,"textarea,[contenteditable]")||Q(t,"button,[contenteditable]")}function Ki(t){var e=U(t);return k(e.width)+k(e.paddingLeft)+k(e.paddingRight)+k(e.borderLeftWidth)+k(e.borderRightWidth)}var se={isWebKit:typeof document<"u"&&"WebkitAppearance"in document.documentElement.style,supportsTouch:typeof window<"u"&&("ontouchstart"in window||"maxTouchPoints"in window.navigator&&window.navigator.maxTouchPoints>0||window.DocumentTouch&&document instanceof window.DocumentTouch),supportsIePointer:typeof navigator<"u"&&navigator.msMaxTouchPoints,isChrome:typeof navigator<"u"&&/Chrome/i.test(navigator&&navigator.userAgent)};function V(t){var e=t.element,i=Math.floor(e.scrollTop),n=e.getBoundingClientRect();t.containerWidth=Math.round(n.width),t.containerHeight=Math.round(n.height),t.contentWidth=e.scrollWidth,t.contentHeight=e.scrollHeight,e.contains(t.scrollbarXRail)||(Ve(e,S.element.rail("x")).forEach(function(s){return oe(s)}),e.appendChild(t.scrollbarXRail)),e.contains(t.scrollbarYRail)||(Ve(e,S.element.rail("y")).forEach(function(s){return oe(s)}),e.appendChild(t.scrollbarYRail)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset<t.contentWidth?(t.scrollbarXActive=!0,t.railXWidth=t.containerWidth-t.railXMarginWidth,t.railXRatio=t.containerWidth/t.railXWidth,t.scrollbarXWidth=Ke(t,k(t.railXWidth*t.containerWidth/t.contentWidth)),t.scrollbarXLeft=k((t.negativeScrollAdjustment+e.scrollLeft)*(t.railXWidth-t.scrollbarXWidth)/(t.contentWidth-t.containerWidth))):t.scrollbarXActive=!1,!t.settings.suppressScrollY&&t.containerHeight+t.settings.scrollYMarginOffset<t.contentHeight?(t.scrollbarYActive=!0,t.railYHeight=t.containerHeight-t.railYMarginHeight,t.railYRatio=t.containerHeight/t.railYHeight,t.scrollbarYHeight=Ke(t,k(t.railYHeight*t.containerHeight/t.contentHeight)),t.scrollbarYTop=k(i*(t.railYHeight-t.scrollbarYHeight)/(t.contentHeight-t.containerHeight))):t.scrollbarYActive=!1,t.scrollbarXLeft>=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),qi(e,t),t.scrollbarXActive?e.classList.add(S.state.active("x")):(e.classList.remove(S.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=t.isRtl===!0?t.contentWidth:0),t.scrollbarYActive?e.classList.add(S.state.active("y")):(e.classList.remove(S.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)}function Ke(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function qi(t,e){var i={width:e.railXWidth},n=Math.floor(t.scrollTop);e.isRtl?i.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:i.left=t.scrollLeft,e.isScrollbarXUsingBottom?i.bottom=e.scrollbarXBottom-n:i.top=e.scrollbarXTop+n,W(e.scrollbarXRail,i);var s={top:n,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?s.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth-9:s.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?s.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth*2-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:s.left=e.scrollbarYLeft+t.scrollLeft,W(e.scrollbarYRail,s),W(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),W(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}function Qi(t){t.element,t.event.bind(t.scrollbarY,"mousedown",function(e){return e.stopPropagation()}),t.event.bind(t.scrollbarYRail,"mousedown",function(e){var i=e.pageY-window.pageYOffset-t.scrollbarYRail.getBoundingClientRect().top,n=i>t.scrollbarYTop?1:-1;t.element.scrollTop+=n*t.containerHeight,V(t),e.stopPropagation()}),t.event.bind(t.scrollbarX,"mousedown",function(e){return e.stopPropagation()}),t.event.bind(t.scrollbarXRail,"mousedown",function(e){var i=e.pageX-window.pageXOffset-t.scrollbarXRail.getBoundingClientRect().left,n=i>t.scrollbarXLeft?1:-1;t.element.scrollLeft+=n*t.containerWidth,V(t),e.stopPropagation()})}function ji(t){qe(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),qe(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])}function qe(t,e){var i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],h=e[7],c=e[8],d=t.element,p=null,g=null,u=null;function b(f){f.touches&&f.touches[0]&&(f[s]=f.touches[0].pageY),d[l]=p+u*(f[s]-g),Et(t,h),V(t),f.stopPropagation(),f.type.startsWith("touch")&&f.changedTouches.length>1&&f.preventDefault()}function y(){xt(t,h),t[c].classList.remove(S.state.clicking),t.event.unbind(t.ownerDocument,"mousemove",b)}function v(f,w){p=d[l],w&&f.touches&&(f[s]=f.touches[0].pageY),g=f[s],u=(t[n]-t[i])/(t[r]-t[a]),w?t.event.bind(t.ownerDocument,"touchmove",b):(t.event.bind(t.ownerDocument,"mousemove",b),t.event.once(t.ownerDocument,"mouseup",y),f.preventDefault()),t[c].classList.add(S.state.clicking),f.stopPropagation()}t.event.bind(t[o],"mousedown",function(f){v(f)}),t.event.bind(t[o],"touchstart",function(f){v(f,!0)})}function Zi(t){var e=t.element,i=function(){return Q(e,":hover")},n=function(){return Q(t.scrollbarX,":focus")||Q(t.scrollbarY,":focus")};function s(r,o){var a=Math.floor(e.scrollTop);if(r===0){if(!t.scrollbarYActive)return!1;if(a===0&&o>0||a>=t.contentHeight-t.containerHeight&&o<0)return!t.settings.wheelPropagation}var l=e.scrollLeft;if(o===0){if(!t.scrollbarXActive)return!1;if(l===0&&r<0||l>=t.contentWidth-t.containerWidth&&r>0)return!t.settings.wheelPropagation}return!0}t.event.bind(t.ownerDocument,"keydown",function(r){if(!(r.isDefaultPrevented&&r.isDefaultPrevented()||r.defaultPrevented)&&!(!i()&&!n())){var o=document.activeElement?document.activeElement:t.ownerDocument.activeElement;if(o){if(o.tagName==="IFRAME")o=o.contentDocument.activeElement;else for(;o.shadowRoot;)o=o.shadowRoot.activeElement;if(Vi(o))return}var a=0,l=0;switch(r.which){case 37:r.metaKey?a=-t.contentWidth:r.altKey?a=-t.containerWidth:a=-30;break;case 38:r.metaKey?l=t.contentHeight:r.altKey?l=t.containerHeight:l=30;break;case 39:r.metaKey?a=t.contentWidth:r.altKey?a=t.containerWidth:a=30;break;case 40:r.metaKey?l=-t.contentHeight:r.altKey?l=-t.containerHeight:l=-30;break;case 32:r.shiftKey?l=t.containerHeight:l=-t.containerHeight;break;case 33:l=t.containerHeight;break;case 34:l=-t.containerHeight;break;case 36:l=t.contentHeight;break;case 35:l=-t.contentHeight;break;default:return}t.settings.suppressScrollX&&a!==0||t.settings.suppressScrollY&&l!==0||(e.scrollTop-=l,e.scrollLeft+=a,V(t),s(a,l)&&r.preventDefault())}})}function Ji(t){var e=t.element;function i(o,a){var l=Math.floor(e.scrollTop),h=e.scrollTop===0,c=l+e.offsetHeight===e.scrollHeight,d=e.scrollLeft===0,p=e.scrollLeft+e.offsetWidth===e.scrollWidth,g;return Math.abs(a)>Math.abs(o)?g=h||c:g=d||p,g?!t.settings.wheelPropagation:!0}function n(o){var a=o.deltaX,l=-1*o.deltaY;return(typeof a>"u"||typeof l>"u")&&(a=-1*o.wheelDeltaX/6,l=o.wheelDeltaY/6),o.deltaMode&&o.deltaMode===1&&(a*=10,l*=10),a!==a&&l!==l&&(a=0,l=o.wheelDelta),o.shiftKey?[-l,-a]:[a,l]}function s(o,a,l){if(!se.isWebKit&&e.querySelector("select:focus"))return!0;if(!e.contains(o))return!1;for(var h=o;h&&h!==e;){if(h.classList.contains(S.element.consuming))return!0;var c=U(h);if(l&&c.overflowY.match(/(scroll|auto)/)){var d=h.scrollHeight-h.clientHeight;if(d>0&&(h.scrollTop>0&&l<0||h.scrollTop<d&&l>0))return!0}if(a&&c.overflowX.match(/(scroll|auto)/)){var p=h.scrollWidth-h.clientWidth;if(p>0&&(h.scrollLeft>0&&a<0||h.scrollLeft<p&&a>0))return!0}h=h.parentNode}return!1}function r(o){var a=n(o),l=a[0],h=a[1];if(!s(o.target,l,h)){var c=!1;t.settings.useBothWheelAxes?t.scrollbarYActive&&!t.scrollbarXActive?(h?e.scrollTop-=h*t.settings.wheelSpeed:e.scrollTop+=l*t.settings.wheelSpeed,c=!0):t.scrollbarXActive&&!t.scrollbarYActive&&(l?e.scrollLeft+=l*t.settings.wheelSpeed:e.scrollLeft-=h*t.settings.wheelSpeed,c=!0):(e.scrollTop-=h*t.settings.wheelSpeed,e.scrollLeft+=l*t.settings.wheelSpeed),V(t),c=c||i(l,h),c&&!o.ctrlKey&&(o.stopPropagation(),o.preventDefault())}}typeof window.onwheel<"u"?t.event.bind(e,"wheel",r):typeof window.onmousewheel<"u"&&t.event.bind(e,"mousewheel",r)}function en(t){if(!se.supportsTouch&&!se.supportsIePointer)return;var e=t.element;function i(u,b){var y=Math.floor(e.scrollTop),v=e.scrollLeft,f=Math.abs(u),w=Math.abs(b);if(w>f){if(b<0&&y===t.contentHeight-t.containerHeight||b>0&&y===0)return window.scrollY===0&&b>0&&se.isChrome}else if(f>w&&(u<0&&v===t.contentWidth-t.containerWidth||u>0&&v===0))return!0;return!0}function n(u,b){e.scrollTop-=b,e.scrollLeft-=u,V(t)}var s={},r=0,o={},a=null;function l(u){return u.targetTouches?u.targetTouches[0]:u}function h(u){return u.pointerType&&u.pointerType==="pen"&&u.buttons===0?!1:!!(u.targetTouches&&u.targetTouches.length===1||u.pointerType&&u.pointerType!=="mouse"&&u.pointerType!==u.MSPOINTER_TYPE_MOUSE)}function c(u){if(h(u)){var b=l(u);s.pageX=b.pageX,s.pageY=b.pageY,r=new Date().getTime(),a!==null&&clearInterval(a)}}function d(u,b,y){if(!e.contains(u))return!1;for(var v=u;v&&v!==e;){if(v.classList.contains(S.element.consuming))return!0;var f=U(v);if(y&&f.overflowY.match(/(scroll|auto)/)){var w=v.scrollHeight-v.clientHeight;if(w>0&&(v.scrollTop>0&&y<0||v.scrollTop<w&&y>0))return!0}if(b&&f.overflowX.match(/(scroll|auto)/)){var P=v.scrollWidth-v.clientWidth;if(P>0&&(v.scrollLeft>0&&b<0||v.scrollLeft<P&&b>0))return!0}v=v.parentNode}return!1}function p(u){if(h(u)){var b=l(u),y={pageX:b.pageX,pageY:b.pageY},v=y.pageX-s.pageX,f=y.pageY-s.pageY;if(d(u.target,v,f))return;n(v,f),s=y;var w=new Date().getTime(),P=w-r;P>0&&(o.x=v/P,o.y=f/P,r=w),i(v,f)&&u.preventDefault()}}function g(){t.settings.swipeEasing&&(clearInterval(a),a=setInterval(function(){if(t.isInitialized){clearInterval(a);return}if(!o.x&&!o.y){clearInterval(a);return}if(Math.abs(o.x)<.01&&Math.abs(o.y)<.01){clearInterval(a);return}if(!t.element){clearInterval(a);return}n(o.x*30,o.y*30),o.x*=.8,o.y*=.8},10))}se.supportsTouch?(t.event.bind(e,"touchstart",c),t.event.bind(e,"touchmove",p),t.event.bind(e,"touchend",g)):se.supportsIePointer&&(window.PointerEvent?(t.event.bind(e,"pointerdown",c),t.event.bind(e,"pointermove",p),t.event.bind(e,"pointerup",g)):window.MSPointerEvent&&(t.event.bind(e,"MSPointerDown",c),t.event.bind(e,"MSPointerMove",p),t.event.bind(e,"MSPointerUp",g)))}var tn=function(){return{handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxScrollbarLength:null,minScrollbarLength:null,scrollingThreshold:1e3,scrollXMarginOffset:0,scrollYMarginOffset:0,suppressScrollX:!1,suppressScrollY:!1,swipeEasing:!0,useBothWheelAxes:!1,wheelPropagation:!0,wheelSpeed:1}},nn={"click-rail":Qi,"drag-thumb":ji,keyboard:Zi,wheel:Ji,touch:en},ve=function(e,i){var n=this;if(i===void 0&&(i={}),typeof e=="string"&&(e=document.querySelector(e)),!e||!e.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");this.element=e,e.classList.add(S.main),this.settings=tn();for(var s in i)this.settings[s]=i[s];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var r=function(){return e.classList.add(S.state.focus)},o=function(){return e.classList.remove(S.state.focus)};this.isRtl=U(e).direction==="rtl",this.isRtl===!0&&e.classList.add(S.rtl),this.isNegativeScroll=function(){var h=e.scrollLeft,c=null;return e.scrollLeft=-1,c=e.scrollLeft<0,e.scrollLeft=h,c}(),this.negativeScrollAdjustment=this.isNegativeScroll?e.scrollWidth-e.clientWidth:0,this.event=new he,this.ownerDocument=e.ownerDocument||document,this.scrollbarXRail=xe(S.element.rail("x")),e.appendChild(this.scrollbarXRail),this.scrollbarX=xe(S.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",r),this.event.bind(this.scrollbarX,"blur",o),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var a=U(this.scrollbarXRail);this.scrollbarXBottom=parseInt(a.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=k(a.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=k(a.borderLeftWidth)+k(a.borderRightWidth),W(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=k(a.marginLeft)+k(a.marginRight),W(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=xe(S.element.rail("y")),e.appendChild(this.scrollbarYRail),this.scrollbarY=xe(S.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",r),this.event.bind(this.scrollbarY,"blur",o),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var l=U(this.scrollbarYRail);this.scrollbarYRight=parseInt(l.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=k(l.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?Ki(this.scrollbarY):null,this.railBorderYWidth=k(l.borderTopWidth)+k(l.borderBottomWidth),W(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=k(l.marginTop)+k(l.marginBottom),W(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:e.scrollLeft<=0?"start":e.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:e.scrollTop<=0?"start":e.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(h){return nn[h](n)}),this.lastScrollTop=Math.floor(e.scrollTop),this.lastScrollLeft=e.scrollLeft,this.event.bind(this.element,"scroll",function(h){return n.onScroll(h)}),V(this)};ve.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,W(this.scrollbarXRail,{display:"block"}),W(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=k(U(this.scrollbarXRail).marginLeft)+k(U(this.scrollbarXRail).marginRight),this.railYMarginHeight=k(U(this.scrollbarYRail).marginTop)+k(U(this.scrollbarYRail).marginBottom),W(this.scrollbarXRail,{display:"none"}),W(this.scrollbarYRail,{display:"none"}),V(this),Me(this,"top",0,!1,!0),Me(this,"left",0,!1,!0),W(this.scrollbarXRail,{display:""}),W(this.scrollbarYRail,{display:""}))};ve.prototype.onScroll=function(e){this.isAlive&&(V(this),Me(this,"top",this.element.scrollTop-this.lastScrollTop),Me(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)};ve.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),oe(this.scrollbarX),oe(this.scrollbarY),oe(this.scrollbarXRail),oe(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)};ve.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(e){return!e.match(/^ps([-_].+|)$/)}).join(" ")};const Qe=["scroll","ps-scroll-y","ps-scroll-x","ps-scroll-up","ps-scroll-down","ps-scroll-left","ps-scroll-right","ps-y-reach-start","ps-y-reach-end","ps-x-reach-start","ps-x-reach-end"];var sn={name:"PerfectScrollbar",props:{options:{type:Object,required:!1,default:()=>{}},tag:{type:String,required:!1,default:"div"},watchOptions:{type:Boolean,required:!1,default:!1}},emits:Qe,data(){return{ps:null}},watch:{watchOptions(t){!t&&this.watcher?this.watcher():this.createWatcher()}},mounted(){this.create(),this.watchOptions&&this.createWatcher()},updated(){this.$nextTick(()=>{this.update()})},beforeUnmount(){this.destroy()},methods:{create(){this.ps&&this.$isServer||(this.ps=new ve(this.$el,this.options),Qe.forEach(t=>{this.ps.element.addEventListener(t,e=>this.$emit(t,e))}))},createWatcher(){this.watcher=this.$watch("options",()=>{this.destroy(),this.create()},{deep:!0})},update(){this.ps&&this.ps.update()},destroy(){this.ps&&(this.ps.destroy(),this.ps=null)}},render(){return Zt(this.tag,{class:"ps"},this.$slots.default&&this.$slots.default())}},Ct={exports:{}},rn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Rt={exports:{}},on=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")},an=on,ln=Array.prototype.concat,hn=Array.prototype.slice,je=Rt.exports=function(e){for(var i=[],n=0,s=e.length;n<s;n++){var r=e[n];an(r)?i=ln.call(i,hn.call(r)):i.push(r)}return i};je.wrap=function(t){return function(){return t(je(arguments))}};var cn=Rt.exports,ue=rn,me=cn,kt=Object.hasOwnProperty,Mt=Object.create(null);for(var Fe in ue)kt.call(ue,Fe)&&(Mt[ue[Fe]]=Fe);var D=Ct.exports={to:{},get:{}};D.get=function(t){var e=t.substring(0,3).toLowerCase(),i,n;switch(e){case"hsl":i=D.get.hsl(t),n="hsl";break;case"hwb":i=D.get.hwb(t),n="hwb";break;default:i=D.get.rgb(t),n="rgb";break}return i?{model:n,value:i}:null};D.get.rgb=function(t){if(!t)return null;var e=/^#([a-f0-9]{3,4})$/i,i=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,n=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,s=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,r=/^(\w+)$/,o=[0,0,0,1],a,l,h;if(a=t.match(i)){for(h=a[2],a=a[1],l=0;l<3;l++){var c=l*2;o[l]=parseInt(a.slice(c,c+2),16)}h&&(o[3]=parseInt(h,16)/255)}else if(a=t.match(e)){for(a=a[1],h=a[3],l=0;l<3;l++)o[l]=parseInt(a[l]+a[l],16);h&&(o[3]=parseInt(h+h,16)/255)}else if(a=t.match(n)){for(l=0;l<3;l++)o[l]=parseInt(a[l+1],0);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else if(a=t.match(s)){for(l=0;l<3;l++)o[l]=Math.round(parseFloat(a[l+1])*2.55);a[4]&&(a[5]?o[3]=parseFloat(a[4])*.01:o[3]=parseFloat(a[4]))}else return(a=t.match(r))?a[1]==="transparent"?[0,0,0,0]:kt.call(ue,a[1])?(o=ue[a[1]],o[3]=1,o):null:null;for(l=0;l<3;l++)o[l]=Z(o[l],0,255);return o[3]=Z(o[3],0,1),o};D.get.hsl=function(t){if(!t)return null;var e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,i=t.match(e);if(i){var n=parseFloat(i[4]),s=(parseFloat(i[1])%360+360)%360,r=Z(parseFloat(i[2]),0,100),o=Z(parseFloat(i[3]),0,100),a=Z(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};D.get.hwb=function(t){if(!t)return null;var e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,i=t.match(e);if(i){var n=parseFloat(i[4]),s=(parseFloat(i[1])%360+360)%360,r=Z(parseFloat(i[2]),0,100),o=Z(parseFloat(i[3]),0,100),a=Z(isNaN(n)?1:n,0,1);return[s,r,o,a]}return null};D.to.hex=function(){var t=me(arguments);return"#"+Ce(t[0])+Ce(t[1])+Ce(t[2])+(t[3]<1?Ce(Math.round(t[3]*255)):"")};D.to.rgb=function(){var t=me(arguments);return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};D.to.rgb.percent=function(){var t=me(arguments),e=Math.round(t[0]/255*100),i=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+i+"%, "+n+"%)":"rgba("+e+"%, "+i+"%, "+n+"%, "+t[3]+")"};D.to.hsl=function(){var t=me(arguments);return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};D.to.hwb=function(){var t=me(arguments),e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};D.to.keyword=function(t){return Mt[t.slice(0,3)]};function Z(t,e,i){return Math.min(Math.max(e,t),i)}function Ce(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}var dn=Ct.exports,St={exports:{}},un={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},te=un,Tt={};for(var Le in te)te.hasOwnProperty(Le)&&(Tt[te[Le]]=Le);var m=St.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var A in m)if(m.hasOwnProperty(A)){if(!("channels"in m[A]))throw new Error("missing channels property: "+A);if(!("labels"in m[A]))throw new Error("missing channel labels property: "+A);if(m[A].labels.length!==m[A].channels)throw new Error("channel and label counts mismatch: "+A);var gn=m[A].channels,fn=m[A].labels;delete m[A].channels,delete m[A].labels,Object.defineProperty(m[A],"channels",{value:gn}),Object.defineProperty(m[A],"labels",{value:fn})}m.rgb.hsl=function(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255,s=Math.min(e,i,n),r=Math.max(e,i,n),o=r-s,a,l,h;return r===s?a=0:e===r?a=(i-n)/o:i===r?a=2+(n-e)/o:n===r&&(a=4+(e-i)/o),a=Math.min(a*60,360),a<0&&(a+=360),h=(s+r)/2,r===s?l=0:h<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,h*100]};m.rgb.hsv=function(t){var e,i,n,s,r,o=t[0]/255,a=t[1]/255,l=t[2]/255,h=Math.max(o,a,l),c=h-Math.min(o,a,l),d=function(p){return(h-p)/6/c+1/2};return c===0?s=r=0:(r=c/h,e=d(o),i=d(a),n=d(l),o===h?s=n-i:a===h?s=1/3+e-n:l===h&&(s=2/3+i-e),s<0?s+=1:s>1&&(s-=1)),[s*360,r*100,h*100]};m.rgb.hwb=function(t){var e=t[0],i=t[1],n=t[2],s=m.rgb.hsl(t)[0],r=1/255*Math.min(e,Math.min(i,n));return n=1-1/255*Math.max(e,Math.max(i,n)),[s,r*100,n*100]};m.rgb.cmyk=function(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255,s,r,o,a;return a=Math.min(1-e,1-i,1-n),s=(1-e-a)/(1-a)||0,r=(1-i-a)/(1-a)||0,o=(1-n-a)/(1-a)||0,[s*100,r*100,o*100,a*100]};function pn(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}m.rgb.keyword=function(t){var e=Tt[t];if(e)return e;var i=1/0,n;for(var s in te)if(te.hasOwnProperty(s)){var r=te[s],o=pn(t,r);o<i&&(i=o,n=s)}return n};m.keyword.rgb=function(t){return te[t]};m.rgb.xyz=function(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var s=e*.4124+i*.3576+n*.1805,r=e*.2126+i*.7152+n*.0722,o=e*.0193+i*.1192+n*.9505;return[s*100,r*100,o*100]};m.rgb.lab=function(t){var e=m.rgb.xyz(t),i=e[0],n=e[1],s=e[2],r,o,a;return i/=95.047,n/=100,s/=108.883,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,r=116*n-16,o=500*(i-n),a=200*(n-s),[r,o,a]};m.hsl.rgb=function(t){var e=t[0]/360,i=t[1]/100,n=t[2]/100,s,r,o,a,l;if(i===0)return l=n*255,[l,l,l];n<.5?r=n*(1+i):r=n+i-n*i,s=2*n-r,a=[0,0,0];for(var h=0;h<3;h++)o=e+1/3*-(h-1),o<0&&o++,o>1&&o--,6*o<1?l=s+(r-s)*6*o:2*o<1?l=r:3*o<2?l=s+(r-s)*(2/3-o)*6:l=s,a[h]=l*255;return a};m.hsl.hsv=function(t){var e=t[0],i=t[1]/100,n=t[2]/100,s=i,r=Math.max(n,.01),o,a;return n*=2,i*=n<=1?n:2-n,s*=r<=1?r:2-r,a=(n+i)/2,o=n===0?2*s/(r+s):2*i/(n+i),[e,o*100,a*100]};m.hsv.rgb=function(t){var e=t[0]/60,i=t[1]/100,n=t[2]/100,s=Math.floor(e)%6,r=e-Math.floor(e),o=255*n*(1-i),a=255*n*(1-i*r),l=255*n*(1-i*(1-r));switch(n*=255,s){case 0:return[n,l,o];case 1:return[a,n,o];case 2:return[o,n,l];case 3:return[o,a,n];case 4:return[l,o,n];case 5:return[n,o,a]}};m.hsv.hsl=function(t){var e=t[0],i=t[1]/100,n=t[2]/100,s=Math.max(n,.01),r,o,a;return a=(2-i)*n,r=(2-i)*s,o=i*s,o/=r<=1?r:2-r,o=o||0,a/=2,[e,o*100,a*100]};m.hwb.rgb=function(t){var e=t[0]/360,i=t[1]/100,n=t[2]/100,s=i+n,r,o,a,l;s>1&&(i/=s,n/=s),r=Math.floor(6*e),o=1-n,a=6*e-r,r&1&&(a=1-a),l=i+a*(o-i);var h,c,d;switch(r){default:case 6:case 0:h=o,c=l,d=i;break;case 1:h=l,c=o,d=i;break;case 2:h=i,c=o,d=l;break;case 3:h=i,c=l,d=o;break;case 4:h=l,c=i,d=o;break;case 5:h=o,c=i,d=l;break}return[h*255,c*255,d*255]};m.cmyk.rgb=function(t){var e=t[0]/100,i=t[1]/100,n=t[2]/100,s=t[3]/100,r,o,a;return r=1-Math.min(1,e*(1-s)+s),o=1-Math.min(1,i*(1-s)+s),a=1-Math.min(1,n*(1-s)+s),[r*255,o*255,a*255]};m.xyz.rgb=function(t){var e=t[0]/100,i=t[1]/100,n=t[2]/100,s,r,o;return s=e*3.2406+i*-1.5372+n*-.4986,r=e*-.9689+i*1.8758+n*.0415,o=e*.0557+i*-.204+n*1.057,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92,s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),[s*255,r*255,o*255]};m.xyz.lab=function(t){var e=t[0],i=t[1],n=t[2],s,r,o;return e/=95.047,i/=100,n/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,s=116*i-16,r=500*(e-i),o=200*(i-n),[s,r,o]};m.lab.xyz=function(t){var e=t[0],i=t[1],n=t[2],s,r,o;r=(e+16)/116,s=i/500+r,o=r-n/200;var a=Math.pow(r,3),l=Math.pow(s,3),h=Math.pow(o,3);return r=a>.008856?a:(r-16/116)/7.787,s=l>.008856?l:(s-16/116)/7.787,o=h>.008856?h:(o-16/116)/7.787,s*=95.047,r*=100,o*=108.883,[s,r,o]};m.lab.lch=function(t){var e=t[0],i=t[1],n=t[2],s,r,o;return s=Math.atan2(n,i),r=s*360/2/Math.PI,r<0&&(r+=360),o=Math.sqrt(i*i+n*n),[e,o,r]};m.lch.lab=function(t){var e=t[0],i=t[1],n=t[2],s,r,o;return o=n/360*2*Math.PI,s=i*Math.cos(o),r=i*Math.sin(o),[e,s,r]};m.rgb.ansi16=function(t){var e=t[0],i=t[1],n=t[2],s=1 in arguments?arguments[1]:m.rgb.hsv(t)[2];if(s=Math.round(s/50),s===0)return 30;var r=30+(Math.round(n/255)<<2|Math.round(i/255)<<1|Math.round(e/255));return s===2&&(r+=60),r};m.hsv.ansi16=function(t){return m.rgb.ansi16(m.hsv.rgb(t),t[2])};m.rgb.ansi256=function(t){var e=t[0],i=t[1],n=t[2];if(e===i&&i===n)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var s=16+36*Math.round(e/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5);return s};m.ansi16.rgb=function(t){var e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var i=(~~(t>50)+1)*.5,n=(e&1)*i*255,s=(e>>1&1)*i*255,r=(e>>2&1)*i*255;return[n,s,r]};m.ansi256.rgb=function(t){if(t>=232){var e=(t-232)*10+8;return[e,e,e]}t-=16;var i,n=Math.floor(t/36)/5*255,s=Math.floor((i=t%36)/6)/5*255,r=i%6/5*255;return[n,s,r]};m.rgb.hex=function(t){var e=((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255),i=e.toString(16).toUpperCase();return"000000".substring(i.length)+i};m.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var i=e[0];e[0].length===3&&(i=i.split("").map(function(a){return a+a}).join(""));var n=parseInt(i,16),s=n>>16&255,r=n>>8&255,o=n&255;return[s,r,o]};m.rgb.hcg=function(t){var e=t[0]/255,i=t[1]/255,n=t[2]/255,s=Math.max(Math.max(e,i),n),r=Math.min(Math.min(e,i),n),o=s-r,a,l;return o<1?a=r/(1-o):a=0,o<=0?l=0:s===e?l=(i-n)/o%6:s===i?l=2+(n-e)/o:l=4+(e-i)/o+4,l/=6,l%=1,[l*360,o*100,a*100]};m.hsl.hcg=function(t){var e=t[1]/100,i=t[2]/100,n=1,s=0;return i<.5?n=2*e*i:n=2*e*(1-i),n<1&&(s=(i-.5*n)/(1-n)),[t[0],n*100,s*100]};m.hsv.hcg=function(t){var e=t[1]/100,i=t[2]/100,n=e*i,s=0;return n<1&&(s=(i-n)/(1-n)),[t[0],n*100,s*100]};m.hcg.rgb=function(t){var e=t[0]/360,i=t[1]/100,n=t[2]/100;if(i===0)return[n*255,n*255,n*255];var s=[0,0,0],r=e%1*6,o=r%1,a=1-o,l=0;switch(Math.floor(r)){case 0:s[0]=1,s[1]=o,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=o;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=o,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-i)*n,[(i*s[0]+l)*255,(i*s[1]+l)*255,(i*s[2]+l)*255]};m.hcg.hsv=function(t){var e=t[1]/100,i=t[2]/100,n=e+i*(1-e),s=0;return n>0&&(s=e/n),[t[0],s*100,n*100]};m.hcg.hsl=function(t){var e=t[1]/100,i=t[2]/100,n=i*(1-e)+.5*e,s=0;return n>0&&n<.5?s=e/(2*n):n>=.5&&n<1&&(s=e/(2*(1-n))),[t[0],s*100,n*100]};m.hcg.hwb=function(t){var e=t[1]/100,i=t[2]/100,n=e+i*(1-e);return[t[0],(n-e)*100,(1-n)*100]};m.hwb.hcg=function(t){var e=t[1]/100,i=t[2]/100,n=1-i,s=n-e,r=0;return s<1&&(r=(n-s)/(1-s)),[t[0],s*100,r*100]};m.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};m.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};m.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};m.gray.hsl=m.gray.hsv=function(t){return[0,0,t[0]]};m.gray.hwb=function(t){return[0,100,t[0]]};m.gray.cmyk=function(t){return[0,0,0,t[0]]};m.gray.lab=function(t){return[t[0],0,0]};m.gray.hex=function(t){var e=Math.round(t[0]/100*255)&255,i=(e<<16)+(e<<8)+e,n=i.toString(16).toUpperCase();return"000000".substring(n.length)+n};m.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]};var _t=St.exports,Se=_t;function vn(){for(var t={},e=Object.keys(Se),i=e.length,n=0;n<i;n++)t[e[n]]={distance:-1,parent:null};return t}function mn(t){var e=vn(),i=[t];for(e[t].distance=0;i.length;)for(var n=i.pop(),s=Object.keys(Se[n]),r=s.length,o=0;o<r;o++){var a=s[o],l=e[a];l.distance===-1&&(l.distance=e[n].distance+1,l.parent=n,i.unshift(a))}return e}function bn(t,e){return function(i){return e(t(i))}}function yn(t,e){for(var i=[e[t].parent,t],n=Se[e[t].parent][t],s=e[t].parent;e[s].parent;)i.unshift(e[s].parent),n=bn(Se[e[s].parent][s],n),s=e[s].parent;return n.conversion=i,n}var En=function(t){for(var e=mn(t),i={},n=Object.keys(e),s=n.length,r=0;r<s;r++){var o=n[r],a=e[o];a.parent!==null&&(i[o]=yn(o,e))}return i},We=_t,xn=En,re={},wn=Object.keys(We);function Cn(t){var e=function(i){return i==null?i:(arguments.length>1&&(i=Array.prototype.slice.call(arguments)),t(i))};return"conversion"in t&&(e.conversion=t.conversion),e}function Rn(t){var e=function(i){if(i==null)return i;arguments.length>1&&(i=Array.prototype.slice.call(arguments));var n=t(i);if(typeof n=="object")for(var s=n.length,r=0;r<s;r++)n[r]=Math.round(n[r]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}wn.forEach(function(t){re[t]={},Object.defineProperty(re[t],"channels",{value:We[t].channels}),Object.defineProperty(re[t],"labels",{value:We[t].labels});var e=xn(t),i=Object.keys(e);i.forEach(function(n){var s=e[n];re[t][n]=Rn(s),re[t][n].raw=Cn(s)})});var kn=re,de=dn,Y=kn,$e=[].slice,Pt=["keyword","gray","hex"],Ye={};Object.keys(Y).forEach(function(t){Ye[$e.call(Y[t].labels).sort().join("")]=t});var Te={};function L(t,e){if(!(this instanceof L))return new L(t,e);if(e&&e in Pt&&(e=null),e&&!(e in Y))throw new Error("Unknown model: "+e);var i,n;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof L)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if(typeof t=="string"){var s=de.get(t);if(s===null)throw new Error("Unable to parse color from string: "+t);this.model=s.model,n=Y[this.model].channels,this.color=s.value.slice(0,n),this.valpha=typeof s.value[n]=="number"?s.value[n]:1}else if(t.length){this.model=e||"rgb",n=Y[this.model].channels;var r=$e.call(t,0,n);this.color=De(r,n),this.valpha=typeof t[n]=="number"?t[n]:1}else if(typeof t=="number")t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);var a=o.sort().join("");if(!(a in Ye))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Ye[a];var l=Y[this.model].labels,h=[];for(i=0;i<l.length;i++)h.push(t[l[i]]);this.color=De(h)}if(Te[this.model])for(n=Y[this.model].channels,i=0;i<n;i++){var c=Te[this.model][i];c&&(this.color[i]=c(this.color[i]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}L.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in de.to?this:this.rgb();e=e.round(typeof t=="number"?t:1);var i=e.valpha===1?e.color:e.color.concat(this.valpha);return de.to[e.model](i)},percentString:function(t){var e=this.rgb().round(typeof t=="number"?t:1),i=e.valpha===1?e.color:e.color.concat(this.valpha);return de.to.rgb.percent(i)},array:function(){return this.valpha===1?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=Y[this.model].channels,i=Y[this.model].labels,n=0;n<e;n++)t[i[n]]=this.color[n];return this.valpha!==1&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,this.valpha!==1&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,this.valpha!==1&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new L(this.color.map(Sn(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new L(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:M("rgb",0,T(255)),green:M("rgb",1,T(255)),blue:M("rgb",2,T(255)),hue:M(["hsl","hsv","hsl","hwb","hcg"],0,function(t){return(t%360+360)%360}),saturationl:M("hsl",1,T(100)),lightness:M("hsl",2,T(100)),saturationv:M("hsv",1,T(100)),value:M("hsv",2,T(100)),chroma:M("hcg",1,T(100)),gray:M("hcg",2,T(100)),white:M("hwb",1,T(100)),wblack:M("hwb",2,T(100)),cyan:M("cmyk",0,T(100)),magenta:M("cmyk",1,T(100)),yellow:M("cmyk",2,T(100)),black:M("cmyk",3,T(100)),x:M("xyz",0,T(100)),y:M("xyz",1,T(100)),z:M("xyz",2,T(100)),l:M("lab",0,T(100)),a:M("lab",1),b:M("lab",2),keyword:function(t){return arguments.length?new L(t):Y[this.model].keyword(this.color)},hex:function(t){return arguments.length?new L(t):de.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255},luminosity:function(){for(var t=this.rgb().color,e=[],i=0;i<t.length;i++){var n=t[i]/255;e[i]=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}return .2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return L.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),i=e.color[0];return i=(i+t)%360,i=i<0?360+i:i,e.color[0]=i,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var i=t.rgb(),n=this.rgb(),s=e===void 0?.5:e,r=2*s-1,o=i.alpha()-n.alpha(),a=((r*o===-1?r:(r+o)/(1+r*o))+1)/2,l=1-a;return L.rgb(a*i.red()+l*n.red(),a*i.green()+l*n.green(),a*i.blue()+l*n.blue(),i.alpha()*s+n.alpha()*(1-s))}};Object.keys(Y).forEach(function(t){if(Pt.indexOf(t)===-1){var e=Y[t].channels;L.prototype[t]=function(){if(this.model===t)return new L(this);if(arguments.length)return new L(arguments,t);var i=typeof arguments[e]=="number"?e:this.valpha;return new L(Tn(Y[this.model][t].raw(this.color)).concat(i),t)},L[t]=function(i){return typeof i=="number"&&(i=De($e.call(arguments),e)),new L(i,t)}}});function Mn(t,e){return Number(t.toFixed(e))}function Sn(t){return function(e){return Mn(e,t)}}function M(t,e,i){return t=Array.isArray(t)?t:[t],t.forEach(function(n){(Te[n]||(Te[n]=[]))[e]=i}),t=t[0],function(n){var s;return arguments.length?(i&&(n=i(n)),s=this[t](),s.color[e]=n,s):(s=this[t]().color[e],i&&(s=i(s)),s)}}function T(t){return function(e){return Math.max(0,Math.min(t,e))}}function Tn(t){return Array.isArray(t)?t:[t]}function De(t,e){for(var i=0;i<e;i++)typeof t[i]!="number"&&(t[i]=0);return t}var _n=L;const Pe=gt(_n);class ie extends fe.EventEmitter{constructor(e){super(),this.name=e}init(e,i){this.renderEngine=e,this.interactionsEngine=i}}const G=(t,e={})=>Object.keys(t).reduce((i,n)=>(e[n]?i[n]=e[n]:i[n]=t[n],i),{}),Ze=t=>typeof t=="number",K=t=>t[t.length-1],Ht=1,Ft=.25,Pn=Ht*2+Ft,Lt=(t,e,i=null,n=0)=>{t.forEach(s=>{const r=e(s,i,n);s.children&&Lt(s.children,e,r||s,n+1)})},Xt=t=>{const e=[];let i=0;return Lt(t,(n,s,r)=>{const o={source:n,end:n.start+n.duration,parent:s,level:r,index:i++};return e.push(o),o}),e.sort((n,s)=>n.level-s.level||n.source.start-s.source.start)},At=t=>{let e=!0,i=0,n=0;return t.forEach(({source:{start:s},end:r})=>{e?(i=s,n=r,e=!1):(i=i<s?i:s,n=n>r?n:r)}),{min:i,max:n}},Hn=t=>{const e=t[0],i=K(t);return i.source.start+i.source.duration-e.source.start},Fn=(t,e,i)=>t.source.start<i&&t.end>e||t.source.start>e&&t.end<i,Ln=(t,e,i)=>t.start<i&&t.end>e||t.start>e&&t.end<i,Xn=(t,e)=>t.source.color===e.source.color&&t.source.type===e.source.type;function Wt(t,e=Xn){return t.reduce((i,n)=>{const s=K(i),r=s&&K(s);return r&&r.level===n.level&&e(r,n)?s.push(n):i.push([n]),i},[]).filter(i=>i.length).map(i=>({nodes:i}))}const Ie=(t,e,i=0,n=0,s=Ft,r=Ht)=>{let o=null,a=null,l=0;return t.reduce((h,{nodes:c})=>{o=null,a=null,l=0;for(const d of c)Fn(d,i,n)&&(o&&!a||o&&a&&(d.source.start-(a.source.start+a.source.duration))*e<s&&d.source.duration*e<r&&a.source.duration*e<r?(o[l]=d,l++):(o=[d],l=1,h.push(o)),a=d);return h},[]).map(h=>{const c=h[0],d=Hn(h);return{start:c.source.start,end:c.source.start+d,duration:d,type:c.source.type,color:c.source.color,level:c.level,nodes:h}})},Yt=(t,e,i,n,s,r)=>t.reduce((o,a)=>(Ln(a,i,n)&&(a.duration*e<=Pn?o.push(a):o.push(...Ie([a],e,i,n,s,r))),o),[]),Je=Pe.hsl(180,30,70);class An extends ie{constructor({data:e,colors:i={},name:n="flameChartPlugin"}){super(n),this.height=0,this.flatTree=[],this.positionY=0,this.colors={},this.selectedRegion=null,this.hoveredRegion=null,this.lastRandomColor=Je,this.metaClusterizedFlatTree=[],this.actualClusterizedFlatTree=[],this.initialClusterizedFlatTree=[],this.lastUsedColor=null,this.renderChartTimeout=-1,this.data=e,this.userColors=i,this.parseData(),this.reset()}init(e,i){super.init(e,i),this.interactionsEngine.on("change-position",this.handlePositionChange.bind(this)),this.interactionsEngine.on("select",this.handleSelect.bind(this)),this.interactionsEngine.on("hover",this.handleHover.bind(this)),this.interactionsEngine.on("up",this.handleMouseUp.bind(this)),this.initData()}handlePositionChange({deltaX:e,deltaY:i}){const n=this.positionY,s=this.renderEngine.parent.positionX;this.interactionsEngine.setCursor("grabbing"),this.positionY+i>=0?this.setPositionY(this.positionY+i):this.setPositionY(0),this.renderEngine.tryToChangePosition(e),(s!==this.renderEngine.parent.positionX||n!==this.positionY)&&this.renderEngine.parent.render()}handleMouseUp(){this.interactionsEngine.clearCursor()}setPositionY(e){this.positionY=e}reset(){this.colors={},this.lastRandomColor=Je,this.positionY=0,this.selectedRegion=null}calcMinMax(){const{flatTree:e}=this,{min:i,max:n}=At(e);this.min=i,this.max=n}handleSelect(e){var i,n;const s=this.findNodeInCluster(e);this.selectedRegion!==s&&(this.selectedRegion=s,this.renderEngine.render(),this.emit("select",{node:(n=(i=this.selectedRegion)===null||i===void 0?void 0:i.data)!==null&&n!==void 0?n:null,type:"flame-chart-node"}))}handleHover(e){this.hoveredRegion=this.findNodeInCluster(e)}findNodeInCluster(e){const i=this.interactionsEngine.getMouse();if(e&&e.type==="cluster"){const n=e.data.nodes.find(({level:s,source:{start:r,duration:o}})=>{const{x:a,y:l,w:h}=this.calcRect(r,o,s);return i.x>=a&&i.x<=a+h&&i.y>=l&&i.y<=l+this.renderEngine.blockHeight});if(n)return{data:n,type:"node"}}return null}getColor(e="_default",i){if(i)return i;if(this.colors[e])return this.colors[e];if(this.userColors[e]){const n=new Pe(this.userColors[e]);return this.colors[e]=n.rgb().toString(),this.colors[e]}return this.lastRandomColor=this.lastRandomColor.rotate(27),this.colors[e]=this.lastRandomColor.rgb().toString(),this.colors[e]}setData(e){this.data=e,this.parseData(),this.initData(),this.reset(),this.renderEngine.recalcMinMax(),this.renderEngine.resetParentView()}parseData(){this.flatTree=Xt(this.data),this.calcMinMax()}initData(){this.metaClusterizedFlatTree=Wt(this.flatTree),this.initialClusterizedFlatTree=Ie(this.metaClusterizedFlatTree,this.renderEngine.zoom,this.min,this.max),this.reclusterizeClusteredFlatTree()}reclusterizeClusteredFlatTree(){this.actualClusterizedFlatTree=Yt(this.initialClusterizedFlatTree,this.renderEngine.zoom,this.renderEngine.positionX,this.renderEngine.positionX+this.renderEngine.getRealView())}calcRect(e,i,n){const s=i*this.renderEngine.zoom;return{x:this.renderEngine.timeToPosition(e),y:n*(this.renderEngine.blockHeight+1)-this.positionY,w:s<=.1?.1:s>=3?s-1:s-s/3}}renderTooltip(){if(this.hoveredRegion){if(this.renderEngine.options.tooltip===!1)return!0;if(typeof this.renderEngine.options.tooltip=="function")this.renderEngine.options.tooltip(this.hoveredRegion,this.renderEngine,this.interactionsEngine.getGlobalMouse());else{const{data:{source:{start:e,duration:i,name:n,children:s}}}=this.hoveredRegion,r=this.renderEngine.getTimeUnits(),o=i-(s?s.reduce((d,{duration:p})=>d+p,0):0),a=this.renderEngine.getAccuracy()+2,l=`${n}`,h=`duration: ${i.toFixed(a)} ${r} ${s!=null&&s.length?`(self ${o.toFixed(a)} ${r})`:""}`,c=`start: ${e.toFixed(a)}`;this.renderEngine.renderTooltipFromData([{text:l},{text:h},{text:c}],this.interactionsEngine.getGlobalMouse())}return!0}return!1}render(){const{width:e,blockHeight:i,height:n,minTextWidth:s}=this.renderEngine;this.lastUsedColor=null,this.reclusterizeClusteredFlatTree();const r=l=>h=>{const{start:c,duration:d,level:p}=h,{x:g,y:u,w:b}=this.calcRect(c,d,p);g+b>0&&g<e&&u+i>0&&u<n&&l(h,g,u,b)},o=(l,h,c,d)=>{const{type:p,nodes:g,color:u}=l,b=this.interactionsEngine.getMouse();b.y>=c&&b.y<=c+i&&a(l,h,c,d),d>=.25&&this.renderEngine.addRectToRenderQueue(this.getColor(p,u),h,c,d),d>=s&&g.length===1&&this.renderEngine.addTextToRenderQueue(g[0].source.name,h,c,d)},a=(l,h,c,d)=>{this.interactionsEngine.addHitRegion("cluster",l,h,c,d,i)};if(this.actualClusterizedFlatTree.forEach(r(o)),this.selectedRegion&&this.selectedRegion.type==="node"){const{source:{start:l,duration:h},level:c}=this.selectedRegion.data,{x:d,y:p,w:g}=this.calcRect(l,h,c);this.renderEngine.addStrokeToRenderQueue("green",d,p,g,this.renderEngine.blockHeight)}clearTimeout(this.renderChartTimeout),this.renderChartTimeout=window.setTimeout(()=>{this.interactionsEngine.clearHitRegions(),this.actualClusterizedFlatTree.forEach(r(a))},16)}}const et={font:"10px sans-serif",fontColor:"black"};class Wn extends ie{constructor(e={}){super("timeGridPlugin"),this.styles=et,this.height=0,this.setSettings(e)}setSettings({styles:e}){this.styles=G(et,e),this.renderEngine&&this.overrideEngineSettings()}overrideEngineSettings(){this.renderEngine.setSettingsOverrides({styles:this.styles}),this.height=Math.round(this.renderEngine.charHeight+10)}init(e,i){super.init(e,i),this.overrideEngineSettings()}render(){return this.renderEngine.parent.timeGrid.renderTimes(this.renderEngine),this.renderEngine.parent.timeGrid.renderLines(0,this.renderEngine.height,this.renderEngine),!0}}class Yn extends ie{constructor({data:e,name:i="marksPlugin"}){super(i),this.hoveredRegion=null,this.selectedRegion=null,this.marks=this.prepareMarks(e),this.calcMinMax()}calcMinMax(){const{marks:e}=this;e.length&&(this.min=e.reduce((i,{timestamp:n})=>n<i?n:i,e[0].timestamp),this.max=e.reduce((i,{timestamp:n})=>n>i?n:i,e[0].timestamp))}init(e,i){super.init(e,i),this.interactionsEngine.on("hover",this.handleHover.bind(this)),this.interactionsEngine.on("select",this.handleSelect.bind(this))}handleHover(e){this.hoveredRegion=e}handleSelect(e){var i;this.selectedRegion!==e&&(this.selectedRegion=e,this.emit("select",{node:(i=e==null?void 0:e.data)!==null&&i!==void 0?i:null,type:"mark"}),this.renderEngine.render())}get height(){return this.renderEngine.blockHeight+2}prepareMarks(e){return e.map(({color:i,...n})=>({...n,color:new Pe(i).alpha(.7).rgb().toString()})).sort((i,n)=>i.timestamp-n.timestamp)}setMarks(e){this.marks=this.prepareMarks(e),this.calcMinMax(),this.renderEngine.recalcMinMax(),this.renderEngine.resetParentView()}calcMarksBlockPosition(e,i){return e>0&&i>e?i:e}render(){this.marks.reduce((e,i)=>{const{timestamp:n,color:s,shortName:r}=i,{width:o}=this.renderEngine.ctx.measureText(r),a=o+this.renderEngine.blockPaddingLeftRight*2,l=this.renderEngine.timeToPosition(n),h=this.calcMarksBlockPosition(l,e);return this.renderEngine.addRectToRenderQueue(s,h,1,a),this.renderEngine.addTextToRenderQueue(r,h,1,a),this.interactionsEngine.addHitRegion("timestamp",i,h,1,a,this.renderEngine.blockHeight),h+a},0)}postRender(){this.marks.forEach(e=>{const{timestamp:i,color:n}=e,s=this.renderEngine.timeToPosition(i);this.renderEngine.parent.setCtxValue("strokeStyle",n),this.renderEngine.parent.setCtxValue("lineWidth",1),this.renderEngine.parent.callCtx("setLineDash",[8,7]),this.renderEngine.parent.ctx.beginPath(),this.renderEngine.parent.ctx.moveTo(s,this.renderEngine.position),this.renderEngine.parent.ctx.lineTo(s,this.renderEngine.parent.height),this.renderEngine.parent.ctx.stroke()})}renderTooltip(){if(this.hoveredRegion&&this.hoveredRegion.type==="timestamp"){if(this.renderEngine.options.tooltip===!1)return!0;if(typeof this.renderEngine.options.tooltip=="function")this.renderEngine.options.tooltip(this.hoveredRegion,this.renderEngine,this.interactionsEngine.getGlobalMouse());else{const{data:{fullName:e,timestamp:i}}=this.hoveredRegion,n=this.renderEngine.getAccuracy()+2,s=`${e}`,r=`${i.toFixed(n)} ${this.renderEngine.timeUnits}`;this.renderEngine.renderTooltipFromData([{text:s},{text:r}],this.interactionsEngine.getGlobalMouse())}return!0}return!1}}const Dn=85,tt={color:"rgba(90,90,90,0.20)"};class Dt{constructor(e){this.styles=tt,this.timeUnits="ms",this.start=0,this.end=0,this.accuracy=0,this.delta=0,this.setSettings(e)}setDefaultRenderEngine(e){this.renderEngine=e,this.timeUnits=this.renderEngine.getTimeUnits()}setSettings({styles:e}){this.styles=G(tt,e),this.renderEngine&&(this.timeUnits=this.renderEngine.getTimeUnits())}recalc(){const e=this.renderEngine.max-this.renderEngine.min,i=this.renderEngine.width/Dn,n=e/i,s=this.renderEngine.getRealView(),r=s/(e||1);this.delta=n/Math.pow(2,Math.floor(Math.log2(1/r))),this.start=Math.floor((this.renderEngine.positionX-this.renderEngine.min)/this.delta),this.end=Math.ceil(s/this.delta)+this.start,this.accuracy=this.calcNumberFix()}calcNumberFix(){var e;const i=(this.delta/2).toString();if(i.includes("e"))return Number((e=i.match(/\d+$/))===null||e===void 0?void 0:e[0]);const n=i.match(/(0\.0*)/);return n?n[0].length-1:0}getTimelineAccuracy(){return this.accuracy}forEachTime(e){for(let i=this.start;i<=this.end;i++){const n=i*this.delta+this.renderEngine.min,s=this.renderEngine.timeToPosition(Number(n.toFixed(this.accuracy)));e(s,n)}}renderLines(e,i,n=this.renderEngine){n.setCtxValue("fillStyle",this.styles.color),this.forEachTime(s=>{n.fillRect(s,e,1,i)})}renderTimes(e=this.renderEngine){e.setCtxValue("fillStyle",e.styles.fontColor),e.setCtxFont(e.styles.font),this.forEachTime((i,n)=>{e.fillText(n.toFixed(this.accuracy)+this.timeUnits,i+e.blockPaddingLeftRight,e.charHeight)})}}function Re(t,e,i,n){return t.length?t.reduce((s,{[e]:r})=>i(s,r),t[0][e]):n}const zt=t=>t.items.map(({name:e,intervals:i,timing:n,meta:s},r)=>{const a=(typeof i=="string"?t.intervals[i]:i).map(({start:g,end:u,color:b,type:y,name:v})=>({start:typeof g=="string"?n[g]:g,end:typeof u=="string"?n[u]:u,color:b,name:v,type:y})).filter(({start:g,end:u})=>typeof g=="number"&&typeof u=="number"),l=a.filter(({type:g})=>g==="block"),h=Re(l,"start",Math.min,0),c=Re(l,"end",Math.max,0),d=Re(a,"start",Math.min,0),p=Re(a,"end",Math.max,0);return{intervals:a,textBlock:{start:h,end:c},name:e,timing:n,min:d,max:p,index:r,meta:s}}).filter(({intervals:e})=>e.length).sort((e,i)=>e.min-i.min||i.max-e.max),zn=(t,e,i,n)=>n-(t-e)*i,$n={fillColor:"rgba(0, 0, 0, 0.1)",lineWidth:1,lineDash:[],lineColor:"rgba(0, 0, 0, 0.5)",type:"smooth"},$t=t=>{const e=[],i=t.map(o=>{var a;return{group:o.units&&!o.group?o.units:"default",...o,style:{lineWidth:1,fillColor:"rgba(0, 0, 0, 0.15)",lineColor:"rgba(0, 0, 0, 0.20)",lineDash:[],type:"smooth",...(a=o.style)!==null&&a!==void 0?a:{}}}}),n=i.reduce((o,{points:a,group:l,min:h,max:c},d)=>(o[l]||(o[l]={min:h??a[0][1],max:c??a[0][1]}),e[d]={start:a[0][0],end:K(a)[0]},a.forEach(([p,g])=>{h===void 0&&(o[l].min=Math.min(o[l].min,g)),c===void 0&&(o[l].max=Math.max(o[l].max,g)),e[d].start=Math.min(e[d].start,p),e[d].end=Math.max(e[d].end,p)}),o),{}),s=Math.min(...e.map(({start:o})=>o)),r=Math.max(...e.map(({end:o})=>o));return{summary:n,total:{min:s,max:r},timeseries:i,timeboxes:e}},It=(t,e,i)=>{var n,s;return e.dynamicMinMax?t.reduce((r,[,o])=>(r.min=Math.min(r.min,o),r.max=Math.max(r.max,o),r),{min:(n=e.min)!==null&&n!==void 0?n:1/0,max:(s=e.max)!==null&&s!==void 0?s:-1/0}):e.group?i[e.group]:{min:-1/0,max:1/0}},Ot=(t,{timeseries:e})=>{const i=e.reduce((n,{points:s,units:r,name:o,group:a})=>{const l=In(s,t),c=a!==r&&a!=="default"?a:"default";let d="";return l&&(o&&(d+=o+": "),d+=l[1].toFixed(2),r&&(d+=r)),n[c]||(n[c]=[]),n[c].push(d),n},{});return Object.entries(i).reduce((n,[s,r])=>(s!=="default"&&n.push({text:s,color:"black"}),r.forEach(o=>{n.push({text:o})}),n),[])},ke=({engine:t,points:e,style:i,min:n,max:s})=>{const r={...$n,...i??{}};t.setCtxValue("strokeStyle",r.lineColor),t.setCtxValue("fillStyle",r.fillColor),t.setCtxValue("lineWidth",r.lineWidth),t.callCtx("setLineDash",r.lineDash),t.ctx.beginPath();const o=(t.height-t.charHeight-4)/(s-n);if(e.length>1){const a=e.map(([l,h])=>[t.timeToPosition(l),zn(h,n,o,t.height)]);if(t.ctx.moveTo(a[0][0],t.height),t.ctx.lineTo(a[0][0],a[0][1]),r.type==="smooth"||!r.type){for(let c=1;c<a.length-2;c++){const d=(a[c][0]+a[c+1][0])/2,p=(a[c][1]+a[c+1][1])/2;t.ctx.quadraticCurveTo(a[c][0],a[c][1],d,p)}const l=a[a.length-2],h=K(a);t.ctx.quadraticCurveTo(l[0],l[1],h[0],h[1]),t.ctx.quadraticCurveTo(h[0],h[1],h[0],t.height)}else if(r.type==="line")for(let l=1;l<a.length;l++)t.ctx.lineTo(a[l][0],a[l][1]);else if(r.type==="bar"){for(let l=0;l<a.length;l++){const h=a[l],c=a[l-1]||h,d=a[l+1],p=(h[0]-c[0])/2,g=d?(d[0]-h[0])/2:p;t.ctx.lineTo(c[0]+p,h[1]),t.ctx.lineTo(h[0]+g,h[1]),d?t.ctx.lineTo(h[0]+g,d[1]):t.ctx.lineTo(h[0]+g,t.height)}t.ctx.lineTo(K(a)[0],t.height)}}t.ctx.closePath(),t.ctx.stroke(),t.ctx.fill()},In=(t,e,i=!0)=>{if(t[0][0]>=e)return i?t[0]:null;if(K(t)[0]<=e)return i?K(t):null;if(t.length<=1)return t[0];let n=0,s=t.length-1;for(;n<=s;){const r=Math.ceil((s+n)/2);if(e>=t[r-1][0]&&e<=t[r][0]){const o=Math.abs(e-t[r-1][0])<Math.abs(e-t[r][0])?r-1:r;return t[o]}t[r][0]<e?n=r+1:s=r-1}return null},it=2,nt={font:"9px sans-serif",fontColor:"black",overlayColor:"rgba(112, 112, 112, 0.5)",graphStrokeColor:"rgba(0, 0, 0, 0.10)",graphFillColor:"rgba(0, 0, 0, 0.15)",flameChartGraphType:"smooth",waterfallStrokeOpacity:.4,waterfallFillOpacity:.35,waterfallGraphType:"smooth",bottomLineColor:"rgba(0, 0, 0, 0.25)",knobColor:"rgb(131, 131, 131)",knobStrokeColor:"white",knobSize:6,height:60,backgroundColor:"white"};class On extends ie{constructor({waterfall:e,flameChartNodes:i,timeseries:n,settings:s,name:r="timeframeSelectorPlugin"}){super(r),this.styles=nt,this.height=0,this.leftKnobMoving=!1,this.rightKnobMoving=!1,this.selectingActive=!1,this.startSelectingPosition=0,this.actualClusters=[],this.clusters=[],this.flameChartMaxLevel=0,this.flameChartDots=[],this.waterfallDots=[],this.waterfallMaxLevel=0,this.actualClusterizedFlatTree=[],this.hoveredRegion=null,this.flameChartNodes=i,this.waterfall=e,this.timeseries=n,this.shouldRender=!0,this.setSettings(s)}init(e,i){super.init(e,i),this.interactionsEngine.on("down",this.handleMouseDown.bind(this)),this.interactionsEngine.on("up",this.handleMouseUp.bind(this)),this.interactionsEngine.on("move",this.handleMouseMove.bind(this)),this.interactionsEngine.on("hover",this.handleHover.bind(this)),this.setSettings()}handleHover(e){this.hoveredRegion=e}handleMouseDown(e,i){e&&(e.type==="timeframeKnob"?(e.data==="left"?this.leftKnobMoving=!0:this.rightKnobMoving=!0,this.interactionsEngine.setCursor("ew-resize")):e.type==="timeframeArea"&&(this.selectingActive=!0,this.startSelectingPosition=i.x))}handleMouseUp(e,i,n){let s=!1;if(this.timeout&&(s=!0),clearTimeout(this.timeout),this.timeout=window.setTimeout(()=>this.timeout=void 0,300),this.leftKnobMoving=!1,this.rightKnobMoving=!1,this.interactionsEngine.clearCursor(),this.selectingActive&&!n&&this.applyChanges(),this.selectingActive=!1,n&&!s){const r=this.getRightKnobPosition(),o=this.getLeftKnobPosition();i.x>r?this.setRightKnobPosition(i.x):i.x>o&&i.x<r?i.x-o>r-i.x?this.setRightKnobPosition(i.x):this.setLeftKnobPosition(i.x):this.setLeftKnobPosition(i.x),this.applyChanges()}s&&(this.renderEngine.parent.setZoom(this.renderEngine.getInitialZoom()),this.renderEngine.parent.setPositionX(this.renderEngine.min),this.renderEngine.parent.render())}handleMouseMove(e,i){this.leftKnobMoving&&(this.setLeftKnobPosition(i.x),this.applyChanges()),this.rightKnobMoving&&(this.setRightKnobPosition(i.x),this.applyChanges()),this.selectingActive&&(this.startSelectingPosition>=i.x?(this.setLeftKnobPosition(i.x),this.setRightKnobPosition(this.startSelectingPosition)):(this.setRightKnobPosition(i.x),this.setLeftKnobPosition(this.startSelectingPosition)),this.renderEngine.render())}postInit(){this.offscreenRenderEngine=this.renderEngine.makeChild(),this.offscreenRenderEngine.setSettingsOverrides({styles:this.styles}),this.timeGrid=new Dt({styles:this.renderEngine.parent.timeGrid.styles}),this.timeGrid.setDefaultRenderEngine(this.offscreenRenderEngine),this.offscreenRenderEngine.on("resize",()=>{this.offscreenRenderEngine.setZoom(this.renderEngine.getInitialZoom()),this.offscreenRender()}),this.offscreenRenderEngine.on("min-max-change",()=>this.shouldRender=!0),this.setData({flameChartNodes:this.flameChartNodes,waterfall:this.waterfall,timeseries:this.timeseries})}setLeftKnobPosition(e){const i=this.getRightKnobPosition();if(e<i-1){const n=this.renderEngine.getRealView(),s=this.renderEngine.setPositionX(this.offscreenRenderEngine.pixelToTime(e)+this.renderEngine.min),r=this.renderEngine.width/(n-s);this.renderEngine.setZoom(r)}}setRightKnobPosition(e){const i=this.getLeftKnobPosition();if(e>i+1){const n=this.renderEngine.getRealView(),s=this.renderEngine.positionX+n-(this.offscreenRenderEngine.pixelToTime(e)+this.renderEngine.min),r=this.renderEngine.width/(n-s);this.renderEngine.setZoom(r)}}getLeftKnobPosition(){return(this.renderEngine.positionX-this.renderEngine.min)*this.renderEngine.getInitialZoom()}getRightKnobPosition(){return(this.renderEngine.positionX-this.renderEngine.min+this.renderEngine.getRealView())*this.renderEngine.getInitialZoom()}applyChanges(){this.renderEngine.parent.setPositionX(this.renderEngine.positionX),this.renderEngine.parent.setZoom(this.renderEngine.zoom),this.renderEngine.parent.render()}setSettings({styles:e}={styles:this.styles}){this.styles=G(nt,e),this.height=this.styles.height,this.offscreenRenderEngine&&(this.offscreenRenderEngine.setSettingsOverrides({styles:this.styles}),this.timeGrid.setSettings({styles:this.renderEngine.parent.timeGrid.styles})),this.shouldRender=!0}makeFlameChartDots(){if(this.flameChartNodes){const e=[],i=Xt(this.flameChartNodes),{min:n,max:s}=At(i);this.min=n,this.max=s,this.clusters=Wt(i,()=>!0),this.actualClusters=Ie(this.clusters,this.renderEngine.zoom,this.min,this.max,it,1/0),this.actualClusterizedFlatTree=Yt(this.actualClusters,this.renderEngine.zoom,this.min,this.max,it,1/0).sort((a,l)=>a.start-l.start),this.actualClusterizedFlatTree.forEach(({start:a,end:l})=>{e.push({time:a,type:"start"},{time:l,type:"end"})}),e.sort((a,l)=>a.time-l.time);const{dots:r,maxLevel:o}=this.makeRenderDots(e);this.flameChartDots=r,this.flameChartMaxLevel=o}}makeRenderDots(e){const i=[];let n=0,s=0;return e.forEach(({type:r,time:o})=>{(r==="start"||r==="end")&&i.push([o,n]),r==="start"?n++:n--,s=Math.max(s,n),i.push([o,n])}),{dots:i,maxLevel:s}}makeWaterfallDots(){if(this.waterfall){const e=zt(this.waterfall),n=Object.entries(e.reduce((r,{intervals:o})=>(o.forEach(a=>{r[a.color]||(r[a.color]=[]),r[a.color].push(a)}),r),{})).map(([r,o])=>{const a=[];return o.forEach(({start:l,end:h})=>{a.push({type:"start",time:l}),a.push({type:"end",time:h})}),a.sort((l,h)=>l.time-h.time),{color:r,points:a}});let s=0;this.waterfallDots=n.map(({color:r,points:o})=>{const{dots:a,maxLevel:l}=this.makeRenderDots(o);return s=Math.max(s,l),{color:r,dots:a}}),this.waterfallMaxLevel=s}}prepareTimeseries(){var e;!((e=this.timeseries)===null||e===void 0)&&e.length?this.preparedTimeseries=$t(this.timeseries):this.preparedTimeseries=void 0}setData({flameChartNodes:e,waterfall:i,timeseries:n}){this.flameChartNodes=e,this.waterfall=i,this.timeseries=n,this.makeFlameChartDots(),this.makeWaterfallDots(),this.prepareTimeseries(),this.offscreenRender()}setTimeseries(e){this.timeseries=e,this.prepareTimeseries(),this.offscreenRender()}setFlameChartNodes(e){this.flameChartNodes=e,this.makeFlameChartDots(),this.offscreenRender()}setWaterfall(e){this.waterfall=e,this.makeWaterfallDots(),this.offscreenRender()}offscreenRender(){const e=this.offscreenRenderEngine.getInitialZoom();if(this.offscreenRenderEngine.setZoom(e),this.offscreenRenderEngine.setPositionX(this.offscreenRenderEngine.min),this.offscreenRenderEngine.clear(),this.timeGrid.recalc(),this.timeGrid.renderLines(0,this.offscreenRenderEngine.height),this.timeGrid.renderTimes(),ke({engine:this.offscreenRenderEngine,points:this.flameChartDots,min:0,max:this.flameChartMaxLevel,style:{lineColor:this.styles.graphStrokeColor,fillColor:this.styles.graphFillColor,type:this.styles.flameChartGraphType}}),this.waterfallDots.forEach(({color:i,dots:n})=>{const s=new Pe(i);ke({engine:this.offscreenRenderEngine,points:n,min:0,max:this.waterfallMaxLevel,style:{lineColor:s.alpha(this.styles.waterfallStrokeOpacity).rgb().toString(),fillColor:s.alpha(this.styles.waterfallFillOpacity).rgb().toString(),type:this.styles.waterfallGraphType}})}),this.preparedTimeseries){const{summary:i,timeseries:n}=this.preparedTimeseries;n.forEach(s=>{const r=It(s.points,s,i);ke({engine:this.offscreenRenderEngine,points:s.points,min:r.min,max:r.max,style:s.style})})}this.offscreenRenderEngine.setCtxValue("fillStyle",this.styles.bottomLineColor),this.offscreenRenderEngine.ctx.fillRect(0,this.height-1,this.offscreenRenderEngine.width,1)}renderTimeframe(){const e=this.renderEngine.positionX-this.renderEngine.min,i=e*this.renderEngine.getInitialZoom(),n=(e+this.renderEngine.getRealView())*this.renderEngine.getInitialZoom(),s=i-this.styles.knobSize/2,r=n-this.styles.knobSize/2,o=this.renderEngine.height/3;this.renderEngine.setCtxValue("fillStyle",this.styles.overlayColor),this.renderEngine.fillRect(0,0,i,this.renderEngine.height),this.renderEngine.fillRect(n,0,this.renderEngine.width-n,this.renderEngine.height),this.renderEngine.setCtxValue("fillStyle",this.styles.overlayColor),this.renderEngine.fillRect(i-1,0,1,this.renderEngine.height),this.renderEngine.fillRect(n+1,0,1,this.renderEngine.height),this.renderEngine.setCtxValue("fillStyle",this.styles.knobColor),this.renderEngine.fillRect(s,0,this.styles.knobSize,o),this.renderEngine.fillRect(r,0,this.styles.knobSize,o),this.renderEngine.renderStroke(this.styles.knobStrokeColor,s,0,this.styles.knobSize,o),this.renderEngine.renderStroke(this.styles.knobStrokeColor,r,0,this.styles.knobSize,o),this.interactionsEngine.addHitRegion("timeframeKnob","left",s,0,this.styles.knobSize,o,"ew-resize"),this.interactionsEngine.addHitRegion("timeframeKnob","right",r,0,this.styles.knobSize,o,"ew-resize"),this.interactionsEngine.addHitRegion("timeframeArea",null,0,0,this.renderEngine.width,this.renderEngine.height,"text")}renderTooltip(){if(this.hoveredRegion){const i=this.interactionsEngine.getMouse().x/this.renderEngine.getInitialZoom()+this.renderEngine.min,n=`${i.toFixed(this.renderEngine.getAccuracy()+2)} ${this.renderEngine.timeUnits}`,s=this.preparedTimeseries?Ot(i,this.preparedTimeseries):[];return this.renderEngine.renderTooltipFromData([{text:n},...s],this.interactionsEngine.getGlobalMouse()),!0}return!1}render(){return this.shouldRender&&(this.shouldRender=!1,this.offscreenRender()),this.renderEngine.copy(this.offscreenRenderEngine),this.renderTimeframe(),this.interactionsEngine.addHitRegion("timeframe",null,0,0,this.renderEngine.width,this.height),!0}}const Nn={height:56},st=2;class Un extends ie{constructor({name:e="timeseriesPlugin",data:i,settings:n}){super(e),this.height=56,this.hoveredRegion=null,this.setSettings(n),this.setData(i)}init(e,i){super.init(e,i),this.interactionsEngine.on("change-position",this.handlePositionChange.bind(this)),this.interactionsEngine.on("hover",this.handleHover.bind(this)),this.interactionsEngine.on("up",this.handleMouseUp.bind(this))}handlePositionChange(e){const i=this.renderEngine.parent.positionX;this.interactionsEngine.setCursor("grabbing"),this.renderEngine.tryToChangePosition(e.deltaX),i!==this.renderEngine.parent.positionX&&this.renderEngine.parent.render()}handleMouseUp(){this.interactionsEngine.clearCursor()}setSettings({styles:e}={styles:this.styles}){this.styles=G(Nn,e),this.height=this.styles.height}setData(e){const i=$t(e);this.data=i,this.min=i.total.min,this.max=i.total.max,this.renderEngine&&(this.renderEngine.recalcMinMax(),this.renderEngine.resetParentView())}handleHover(e){this.hoveredRegion=e}renderTooltip(){if(this.hoveredRegion){const e=this.interactionsEngine.getMouse().x,i=this.renderEngine.pixelToTime(e)+this.renderEngine.positionX,n=`${i.toFixed(this.renderEngine.getAccuracy()+2)} ${this.renderEngine.timeUnits}`,s=Ot(i,this.data);return this.renderEngine.renderTooltipFromData([{text:n},...s],this.interactionsEngine.getGlobalMouse()),!0}return!1}render(){if(this.data.timeseries.length===0)return;const e=this.renderEngine.positionX,i=this.renderEngine.positionX+this.renderEngine.getRealView();this.data.timeseries.forEach((n,s)=>{if(this.data.timeboxes[s].end<e||this.data.timeboxes[s].start>i)return;const r=e<=this.data.timeboxes[s].start?0:Math.max(n.points.findIndex(([h])=>h>=e)-st,0),o=i>=this.data.timeboxes[s].end?n.points.length:n.points.findIndex(([h])=>h>=i)+st,a=n.points.slice(r,o),l=It(a,n,this.data.summary);ke({engine:this.renderEngine,points:a,min:l.min,max:l.max,style:n.style})}),this.interactionsEngine.addHitRegion("timeseries",null,0,0,this.renderEngine.width,this.height)}}const Xe={defaultHeight:68};class Gn extends ie{constructor({data:e,name:i="waterfallPlugin",settings:n}){super(i),this.styles=Xe,this.height=Xe.defaultHeight,this.data=[],this.positionY=0,this.hoveredRegion=null,this.selectedRegion=null,this.initialData=[],this.setData(e),this.setSettings(n)}init(e,i){super.init(e,i),this.interactionsEngine.on("change-position",this.handlePositionChange.bind(this)),this.interactionsEngine.on("hover",this.handleHover.bind(this)),this.interactionsEngine.on("select",this.handleSelect.bind(this)),this.interactionsEngine.on("up",this.handleMouseUp.bind(this))}handlePositionChange({deltaX:e,deltaY:i}){const n=this.positionY,s=this.renderEngine.parent.positionX;this.interactionsEngine.setCursor("grabbing"),this.positionY+i>=0?this.setPositionY(this.positionY+i):this.setPositionY(0),this.renderEngine.tryToChangePosition(e),(s!==this.renderEngine.parent.positionX||n!==this.positionY)&&this.renderEngine.parent.render()}handleMouseUp(){this.interactionsEngine.clearCursor()}handleHover(e){this.hoveredRegion=e}handleSelect(e){this.selectedRegion!==e&&(this.selectedRegion=e,this.emit("select",{node:e!=null&&e.data?this.initialData[e.data]:null,type:"waterfall-node"}),this.renderEngine.render())}setPositionY(e){this.positionY=e}setSettings({styles:e}){this.styles=G(Xe,e),this.height=this.styles.defaultHeight,this.positionY=0}setData(e){this.positionY=0,this.initialData=e.items,this.data=zt(e),e.items.length&&(this.min=this.data.reduce((i,{min:n})=>Math.min(i,n),this.data[0].min),this.max=this.data.reduce((i,{max:n})=>Math.max(i,n),this.data[0].max)),this.renderEngine&&(this.renderEngine.recalcMinMax(),this.renderEngine.resetParentView())}calcRect(e,i,n){const s=i*this.renderEngine.zoom;return{x:this.renderEngine.timeToPosition(e),w:n?s<=.1?.1:s>=3?s-1:s-s/3:s}}renderTooltip(){if(this.hoveredRegion){if(this.renderEngine.options.tooltip===!1)return!0;if(typeof this.renderEngine.options.tooltip=="function"){const{data:e}=this.hoveredRegion,i={...this.hoveredRegion};i.data=this.data.find(({index:n})=>e===n),this.renderEngine.options.tooltip(i,this.renderEngine,this.interactionsEngine.getGlobalMouse())}else{const{data:e}=this.hoveredRegion,i=this.data.find(({index:n})=>e===n);if(i){const{name:n,intervals:s,timing:r,meta:o=[]}=i,a=this.renderEngine.getTimeUnits(),l=this.renderEngine.getAccuracy()+2,h={text:`${n}`},c={text:"intervals",color:this.renderEngine.styles.tooltipHeaderFontColor},d=s.map(({name:y,start:v,end:f})=>({text:`${y}: ${(f-v).toFixed(l)} ${a}`})),p={text:"timing",color:this.renderEngine.styles.tooltipHeaderFontColor},g=Object.entries(r).filter(([,y])=>typeof y=="number").map(([y,v])=>({text:`${y}: ${v.toFixed(l)} ${a}`})),u={text:"meta",color:this.renderEngine.styles.tooltipHeaderFontColor},b=o?o.map(({name:y,value:v,color:f})=>({text:`${y}: ${v}`,color:f})):[];this.renderEngine.renderTooltipFromData([h,c,...d,p,...g,...b.length?[u,...b]:[]],this.interactionsEngine.getGlobalMouse())}}return!0}return!1}render(){const e=this.renderEngine.positionX+this.renderEngine.getRealView(),i=this.renderEngine.positionX,n=this.renderEngine.blockHeight+1,s=[];this.data.filter(({min:o,max:a})=>!(e<o&&e<a||i>a&&e>o)).map(o=>{for(;s.length&&o.min-K(s).max>0;)s.pop();const a=s.length,l={...o,level:a};return s.push(o),l}).forEach(({name:o,intervals:a,textBlock:l,level:h,index:c})=>{const d=h*n-this.positionY;if(d+n>=0&&d-n<=this.renderEngine.height){const p=this.renderEngine.timeToPosition(l.start),g=this.renderEngine.timeToPosition(l.end);this.renderEngine.addTextToRenderQueue(o,p,d,g-p);const{x:u,w:b}=a.reduce((y,{color:v,start:f,end:w,type:P},C)=>{const{x:R,w:O}=this.calcRect(f,w-f,C===a.length-1);return P==="block"&&this.renderEngine.addRectToRenderQueue(v,R,d,O),{x:y.x===null?R:y.x,w:O+y.w}},{x:null,w:0});this.selectedRegion&&this.selectedRegion.type==="waterfall-node"&&this.selectedRegion.data===c&&this.renderEngine.addStrokeToRenderQueue("green",u??0,d,b,this.renderEngine.blockHeight),this.interactionsEngine.addHitRegion("waterfall-node",c,u??0,d,b,this.renderEngine.blockHeight)}},0)}}const rt={height:16,color:"rgb(202,202,202, 0.25)",strokeColor:"rgb(138,138,138, 0.50)",dotsColor:"rgb(97,97,97)",fontColor:"black",font:"10px sans-serif",triangleWidth:10,triangleHeight:7,triangleColor:"black",leftPadding:10};class ot extends ie{constructor(e,i){super("togglePlugin"),this.styles=rt,this.height=0,this.resizeActive=!1,this.resizeStartHeight=0,this.resizeStartPosition=0,this.setSettings(i),this.title=e}setSettings({styles:e}={}){this.styles=G(rt,e),this.height=this.styles.height+1}init(e,i){super.init(e,i),this.getNextEngine().setFlexible(),this.interactionsEngine.on("click",s=>{if(s&&s.type==="toggle"&&s.data===this.renderEngine.id){const r=this.getNextEngine();r.collapsed?r.expand():r.collapse(),this.renderEngine.parent.recalcChildrenSizes(),this.renderEngine.parent.render()}}),this.interactionsEngine.on("down",s=>{if(s&&s.type==="knob-resize"&&s.data===this.renderEngine.id){const r=this.getPrevEngine();this.interactionsEngine.setCursor("row-resize"),this.resizeActive=!0,this.resizeStartHeight=r.height,this.resizeStartPosition=this.interactionsEngine.getGlobalMouse().y}}),this.interactionsEngine.parent.on("move",()=>{if(this.resizeActive){const s=this.getPrevEngine(),r=this.interactionsEngine.getGlobalMouse();if(s.flexible){const o=this.resizeStartHeight-(this.resizeStartPosition-r.y);o<=0?(s.collapse(),s.resize({height:0})):(s.collapsed&&s.expand(),s.resize({height:o})),this.renderEngine.parent.render()}}}),this.interactionsEngine.parent.on("up",()=>{this.interactionsEngine.clearCursor(),this.resizeActive=!1})}getPrevEngine(){var e;const i=((e=this.renderEngine.id)!==null&&e!==void 0?e:0)-1;return this.renderEngine.parent.children[i]}getNextEngine(){var e;const i=((e=this.renderEngine.id)!==null&&e!==void 0?e:0)+1;return this.renderEngine.parent.children[i]}render(){const e=this.getNextEngine(),i=this.getPrevEngine(),n=this.styles.leftPadding+this.styles.triangleWidth,s=this.renderEngine.width/2,r=this.styles.height/2;this.renderEngine.setCtxFont(this.styles.font),this.renderEngine.setCtxValue("fillStyle",this.styles.color),this.renderEngine.setCtxValue("strokeStyle",this.styles.strokeColor),this.renderEngine.fillRect(0,0,this.renderEngine.width,this.styles.height),this.renderEngine.setCtxValue("fillStyle",this.styles.fontColor),this.renderEngine.addTextToRenderQueue(this.title,n,0,this.renderEngine.width),this.renderEngine.renderTriangle(this.styles.triangleColor,this.styles.leftPadding,this.styles.height/2,this.styles.triangleWidth,this.styles.triangleHeight,e.collapsed?"right":"bottom");const{width:o}=this.renderEngine.ctx.measureText(this.title),a=o+n;this.interactionsEngine.addHitRegion("toggle",this.renderEngine.id,0,0,a,this.styles.height,"pointer"),i.flexible&&(this.renderEngine.renderCircle(this.styles.dotsColor,s,r,1.5),this.renderEngine.renderCircle(this.styles.dotsColor,s-10,r,1.5),this.renderEngine.renderCircle(this.styles.dotsColor,s+10,r,1.5),this.interactionsEngine.addHitRegion("knob-resize",this.renderEngine.id,a,0,this.renderEngine.width-a,this.styles.height,"row-resize"))}}const at=`QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890_-+()[]{}\\/|'";:.,?~`,Bn=()=>{const t=navigator.userAgent.toLowerCase();return t.includes("safari")?!t.includes("chrome"):!1};function Vn(t){const e=t,i=window.devicePixelRatio||1,n=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return i/n}const lt={tooltip:void 0,timeUnits:"ms"},ht={blockHeight:16,blockPaddingLeftRight:4,backgroundColor:"white",font:"10px sans-serif",fontColor:"black",tooltipHeaderFontColor:"black",tooltipBodyFontColor:"#688f45",tooltipBackgroundColor:"white",tooltipShadowColor:"black",tooltipShadowBlur:6,tooltipShadowOffsetX:0,tooltipShadowOffsetY:0,headerHeight:14,headerColor:"rgba(112, 112, 112, 0.25)",headerStrokeColor:"rgba(112, 112, 112, 0.5)",headerTitleLeftPadding:16};class Nt extends fe.EventEmitter{constructor(e,i){super(),this.options=lt,this.timeUnits="ms",this.styles=ht,this.blockPaddingLeftRight=0,this.blockHeight=0,this.blockPaddingTopBottom=0,this.charHeight=0,this.placeholderWidth=0,this.avgCharWidth=0,this.minTextWidth=0,this.textRenderQueue=[],this.strokeRenderQueue=[],this.rectRenderQueue={},this.zoom=0,this.positionX=0,this.min=0,this.max=0,this.ctxCachedSettings={},this.ctxCachedCalls={},this.setCtxValue=(n,s)=>{this.ctxCachedSettings[n]!==s&&(this.ctx[n]=s,this.ctxCachedSettings[n]=s)},this.callCtx=(n,s)=>{(!this.ctxCachedCalls[n]||this.ctxCachedCalls[n]!==s)&&(this.ctx[n](s),this.ctxCachedCalls[n]=s)},this.width=e.width,this.height=e.height,this.isSafari=Bn(),this.canvas=e,this.ctx=e.getContext("2d",{alpha:!1}),this.pixelRatio=Vn(this.ctx),this.setSettings(i),this.applyCanvasSize(),this.reset()}setSettings({options:e,styles:i}){this.options=G(lt,e),this.styles=G(ht,i),this.timeUnits=this.options.timeUnits,this.blockHeight=this.styles.blockHeight,this.ctx.font=this.styles.font;const{actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,width:r}=this.ctx.measureText(at),{width:o}=this.ctx.measureText("…"),a=n+s;this.blockPaddingLeftRight=this.styles.blockPaddingLeftRight,this.blockPaddingTopBottom=Math.ceil((this.blockHeight-a)/2),this.charHeight=a+1,this.placeholderWidth=o,this.avgCharWidth=r/at.length,this.minTextWidth=this.avgCharWidth+this.placeholderWidth}reset(){this.textRenderQueue=[],this.strokeRenderQueue=[],this.rectRenderQueue={},this.ctxCachedCalls={},this.ctxCachedSettings={}}setCtxShadow(e){var i,n;this.setCtxValue("shadowBlur",e.blur),this.setCtxValue("shadowColor",e.color),this.setCtxValue("shadowOffsetY",(i=e.offsetY)!==null&&i!==void 0?i:0),this.setCtxValue("shadowOffsetX",(n=e.offsetX)!==null&&n!==void 0?n:0)}setCtxFont(e){e&&this.ctx.font!==e&&(this.ctx.font=e)}fillRect(e,i,n,s){this.ctx.fillRect(e,i,n,s)}fillText(e,i,n){this.ctx.fillText(e,i,n)}renderBlock(e,i,n,s){this.setCtxValue("fillStyle",e),this.ctx.fillRect(i,n,s,this.blockHeight)}renderStroke(e,i,n,s,r){this.setCtxValue("strokeStyle",e),this.ctx.setLineDash([]),this.ctx.strokeRect(i,n,s,r)}clear(e=this.width,i=this.height,n=0,s=0){this.setCtxValue("fillStyle",this.styles.backgroundColor),this.ctx.clearRect(n,s,e,i-1),this.ctx.fillRect(n,s,e,i),this.ctxCachedCalls={},this.ctxCachedSettings={},this.emit("clear")}timeToPosition(e){return e*this.zoom-this.positionX*this.zoom}pixelToTime(e){return e/this.zoom}setZoom(e){this.zoom=e}setPositionX(e){const i=this.positionX;return this.positionX=e,e-i}addRectToRenderQueue(e,i,n,s){this.rectRenderQueue[e]||(this.rectRenderQueue[e]=[]),this.rectRenderQueue[e].push({x:i,y:n,w:s})}addTextToRenderQueue(e,i,n,s){if(e){const r=s-(this.blockPaddingLeftRight*2-(i<0?i:0));r>0&&this.textRenderQueue.push({text:e,x:i,y:n,w:s,textMaxWidth:r})}}addStrokeToRenderQueue(e,i,n,s,r){this.strokeRenderQueue.push({color:e,x:i,y:n,w:s,h:r})}resolveRectRenderQueue(){Object.entries(this.rectRenderQueue).forEach(([e,i])=>{this.setCtxValue("fillStyle",e),i.forEach(({x:n,y:s,w:r})=>this.renderBlock(e,n,s,r))}),this.rectRenderQueue={}}resolveTextRenderQueue(){this.setCtxValue("fillStyle",this.styles.fontColor),this.textRenderQueue.forEach(({text:e,x:i,y:n,textMaxWidth:s})=>{const{width:r}=this.ctx.measureText(e);if(r>s){const o=r/e.length,l=(Math.floor((s-this.placeholderWidth)/o)-1)/2;l>0?e=e.slice(0,Math.ceil(l))+"…"+e.slice(e.length-Math.floor(l),e.length):e=""}e&&this.ctx.fillText(e,(i<0?0:i)+this.blockPaddingLeftRight,n+this.blockHeight-this.blockPaddingTopBottom)}),this.textRenderQueue=[]}resolveStrokeRenderQueue(){this.strokeRenderQueue.forEach(({color:e,x:i,y:n,w:s,h:r})=>{this.renderStroke(e,i,n,s,r)}),this.strokeRenderQueue=[]}setMinMax(e,i){const n=e!==this.min||i!==this.max;this.min=e,this.max=i,n&&this.emit("min-max-change",e,i)}getTimeUnits(){return this.timeUnits}tryToChangePosition(e){const i=this.getRealView();this.positionX+e+i<=this.max&&this.positionX+e>=this.min?this.setPositionX(this.positionX+e):this.positionX+e<=this.min?this.setPositionX(this.min):this.positionX+e+i>=this.max&&this.setPositionX(this.max-i)}getInitialZoom(){return this.max-this.min>0?this.width/(this.max-this.min):1}getRealView(){return this.width/this.zoom}resetView(){this.setZoom(this.getInitialZoom()),this.setPositionX(this.min)}resize(e,i){const n=typeof e=="number"&&this.width!==e,s=typeof i=="number"&&this.height!==i;return n||s?(this.width=n?e:this.width,this.height=s?i:this.height,this.applyCanvasSize(),this.emit("resize",{width:this.width,height:this.height}),s):!1}applyCanvasSize(){this.canvas.style.backgroundColor="white",this.canvas.style.overflow="hidden",this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px",this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),this.ctx.font=this.styles.font}copy(e){const i=this.isSafari?1:e.pixelRatio;e.canvas.height&&this.ctx.drawImage(e.canvas,0,0,e.canvas.width*i,e.canvas.height*i,0,e.position||0,e.width*i,e.height*i)}renderTooltipFromData(e,i){const n=i.x+10,s=i.y+10,o=e.map(({text:a})=>a).map(a=>this.ctx.measureText(a)).reduce((a,{width:l})=>Math.max(a,l),0)+this.blockPaddingLeftRight*2;this.setCtxShadow({color:this.styles.tooltipShadowColor,blur:this.styles.tooltipShadowBlur,offsetX:this.styles.tooltipShadowOffsetX,offsetY:this.styles.tooltipShadowOffsetY}),this.setCtxValue("fillStyle",this.styles.tooltipBackgroundColor),this.ctx.fillRect(n,s,o+this.blockPaddingLeftRight*2,(this.charHeight+2)*e.length+this.blockPaddingLeftRight*2),this.setCtxShadow({color:"transparent",blur:0}),e.forEach(({text:a,color:l},h)=>{l?this.setCtxValue("fillStyle",l):h?this.setCtxValue("fillStyle",this.styles.tooltipBodyFontColor):this.setCtxValue("fillStyle",this.styles.tooltipHeaderFontColor),this.ctx.fillText(a,n+this.blockPaddingLeftRight,s+this.blockHeight-this.blockPaddingTopBottom+(this.charHeight+2)*h)})}renderShape(e,i,n,s){this.setCtxValue("fillStyle",e),this.ctx.beginPath(),this.ctx.moveTo(i[0].x+n,i[0].y+s),i.slice(1).forEach(({x:r,y:o})=>this.ctx.lineTo(r+n,o+s)),this.ctx.closePath(),this.ctx.fill()}renderTriangle(e,i,n,s,r,o){const a=r/2,l=s/2;let h;switch(o){case"top":h=[{x:0-l,y:a},{x:0,y:0-a},{x:l,y:a}];break;case"right":h=[{x:0-a,y:0-l},{x:0-a,y:l},{x:a,y:0}];break;case"bottom":h=[{x:0-l,y:0-a},{x:l,y:0-a},{x:0,y:a}];break;case"left":h=[{x:a,y:0-l},{x:a,y:l},{x:0-a,y:0}];break}this.renderShape(e,h,i,n)}renderCircle(e,i,n,s){this.ctx.beginPath(),this.ctx.arc(i,n,s,0,2*Math.PI,!1),this.setCtxValue("fillStyle",e),this.ctx.fill()}}class Oe extends Nt{constructor({width:e,height:i,parent:n,id:s}){const r=document.createElement("canvas");r.width=e,r.height=i,super(r,{options:n.options,styles:n.styles}),this.flexible=!1,this.collapsed=!1,this.position=0,this.width=e,this.height=i,this.parent=n,this.id=s,this.children=[],this.applyCanvasSize()}makeChild(){const e=new Oe({width:this.width,height:this.height,parent:this.parent,id:void 0});return this.children.push(e),e.setMinMax(this.min,this.max),e.resetView(),e}setFlexible(){this.flexible=!0}collapse(){this.collapsed=!0,this.clear()}expand(){this.collapsed=!1}setSettingsOverrides(e){this.setSettings({styles:G(this.styles,e.styles),options:G(this.options,e.options)}),this.children.forEach(i=>i.setSettingsOverrides(e))}resize({width:e,height:i,position:n},s){const r=super.resize(e,i);!s&&r&&this.parent.recalcChildrenSizes(),typeof n=="number"&&(this.position=n),this.children.forEach(o=>o.resize({width:e,height:i,position:n}))}setMinMax(e,i){super.setMinMax(e,i),this.children.forEach(n=>n.setMinMax(e,i))}setSettings(e){super.setSettings(e),this.children&&this.children.forEach(i=>i.setSettings(e))}tryToChangePosition(e){this.parent.tryToChangePosition(e)}recalcMinMax(){this.parent.calcMinMax()}getTimeUnits(){return this.parent.getTimeUnits()}getAccuracy(){return this.parent.timeGrid.accuracy}renderTimeGrid(){this.parent.timeGrid.renderLines(0,this.height,this)}renderTimeGridTimes(){this.parent.timeGrid.renderTimes(this)}standardRender(){this.resolveRectRenderQueue(),this.resolveTextRenderQueue(),this.resolveStrokeRenderQueue(),this.renderTimeGrid()}renderTooltipFromData(e,i){this.parent.renderTooltipFromData(e,i)}resetParentView(){this.parent.resetView(),this.parent.render()}render(){this.parent.partialRender(this.id)}}const Kn=6;class qn extends Nt{constructor({canvas:e,settings:i,timeGrid:n,plugins:s}){super(e,i),this.freeSpace=0,this.lastPartialAnimationFrame=null,this.lastGlobalAnimationFrame=null,this.plugins=s,this.children=[],this.requestedRenders=[],this.timeGrid=n,this.timeGrid.setDefaultRenderEngine(this)}makeInstance(){const e=new Oe({width:this.width,height:0,id:this.children.length,parent:this});return e.setMinMax(this.min,this.max),e.resetView(),this.children.push(e),e}calcMinMax(){const e=this.plugins.map(({min:n})=>n).filter(Ze).reduce((n,s)=>Math.min(n,s)),i=this.plugins.map(({max:n})=>n).filter(Ze).reduce((n,s)=>Math.max(n,s));this.setMinMax(e,i)}calcTimeGrid(){this.timeGrid.recalc()}setMinMax(e,i){super.setMinMax(e,i),this.children.forEach(n=>n.setMinMax(e,i))}setSettings(e){super.setSettings(e),this.children&&(this.children.forEach(i=>i.setSettings(e)),this.recalcChildrenSizes())}resize(e,i){const n=this.width;return super.resize(e,i),this.recalcChildrenSizes(),this.getInitialZoom()>this.zoom?this.resetView():this.positionX>this.min&&this.tryToChangePosition(-this.pixelToTime((e-n)/2)),!0}recalcChildrenSizes(){const e=this.getChildrenSizes();this.freeSpace=e.reduce((i,{height:n})=>i-n,this.height),this.children.forEach((i,n)=>{i.resize(e[n],!0)})}getChildrenSizes(){const i=this.children.map((o,a)=>a).map(o=>{const a=this.plugins[o];return this.children[o].flexible&&a.height?"flexibleStatic":a.height?"static":"flexibleGrowing"}),n=i.reduce((o,a,l)=>{var h,c;const d=this.plugins[l],p=this.children[l];return p.collapsed?o:a==="flexibleGrowing"?o-(p.height||0):a==="flexibleStatic"?o-((p==null?void 0:p.height)||(d==null?void 0:d.height)||0):a==="static"?o-((c=(h=this.plugins[l])===null||h===void 0?void 0:h.height)!==null&&c!==void 0?c:0):o},this.height),s=i.filter(o=>o==="flexibleGrowing").length,r=Math.floor(n/s);return i.reduce((o,a,l)=>{var h,c;const d=this.children[l],p=this.plugins[l];let g=0;if(d.collapsed)g=0;else switch(a){case"static":g=(h=p.height)!==null&&h!==void 0?h:0;break;case"flexibleGrowing":g=(d.height||0)+r;break;case"flexibleStatic":g=(c=d.height||this.plugins[l].height)!==null&&c!==void 0?c:0;break}return o.result.push({width:this.width,position:o.position,height:g}),o.position+=g,o},{position:0,result:[]}).result}getAccuracy(){return this.timeGrid.accuracy}setZoom(e){return this.getAccuracy()<Kn||e<=this.zoom?(super.setZoom(e),this.children.forEach(i=>i.setZoom(e)),!0):!1}setPositionX(e){const i=super.setPositionX(e);return this.children.forEach(n=>n.setPositionX(e)),i}renderPlugin(e){var i;const n=this.plugins[e],s=this.children[e];s==null||s.clear(),s.collapsed||!((i=n==null?void 0:n.render)===null||i===void 0)&&i.call(n)||s.standardRender()}partialRender(e){typeof e=="number"&&this.requestedRenders.push(e),this.lastPartialAnimationFrame||(this.lastPartialAnimationFrame=requestAnimationFrame(()=>{this.requestedRenders.forEach(i=>this.renderPlugin(i)),this.shallowRender(),this.requestedRenders=[],this.lastPartialAnimationFrame=null}))}shallowRender(){this.clear(),this.timeGrid.renderLines(this.height-this.freeSpace,this.freeSpace),this.children.forEach(i=>{i.collapsed||this.copy(i)});let e=!1;this.plugins.forEach(i=>{i.postRender&&i.postRender()}),this.plugins.forEach(i=>{i.renderTooltip&&(e=e||!!i.renderTooltip())}),!e&&typeof this.options.tooltip=="function"&&this.options.tooltip(null,this,null)}render(e){typeof this.lastPartialAnimationFrame=="number"&&cancelAnimationFrame(this.lastPartialAnimationFrame),this.requestedRenders=[],this.lastPartialAnimationFrame=null,this.lastGlobalAnimationFrame||(this.lastGlobalAnimationFrame=requestAnimationFrame(()=>{e==null||e(),this.timeGrid.recalc(),this.children.forEach((i,n)=>this.renderPlugin(n)),this.shallowRender(),this.lastGlobalAnimationFrame=null}))}}const Qn=["down","up","move","click","select"];class ge extends fe.EventEmitter{static getId(){return ge.count++}constructor(e,i){super(),this.id=ge.getId(),this.parent=e,this.renderEngine=i,i.on("clear",()=>this.clearHitRegions()),Qn.forEach(n=>e.on(n,(s,r,o)=>{(!s||s.id===this.id)&&this.resend(n,s,r,o)})),["hover"].forEach(n=>e.on(n,(s,r)=>{(!s||s.id===this.id)&&this.emit(n,s,r)})),e.on("change-position",(n,s,r,o)=>{o===this&&this.emit("change-position",n,s,r)}),this.hitRegions=[]}resend(e,...i){this.renderEngine.position<=this.parent.mouse.y&&this.renderEngine.height+this.renderEngine.position>=this.parent.mouse.y&&this.emit(e,...i)}getMouse(){const{x:e,y:i}=this.parent.mouse;return{x:e,y:i-this.renderEngine.position}}getGlobalMouse(){return this.parent.mouse}clearHitRegions(){this.hitRegions=[]}addHitRegion(e,i,n,s,r,o,a){this.hitRegions.push({type:e,data:i,x:n,y:s,w:r,h:o,cursor:a,id:this.id})}setCursor(e){this.parent.setCursor(e)}clearCursor(){this.parent.clearCursor()}}ge.count=0;class jn extends fe.EventEmitter{constructor(e,i){super(),this.selectedRegion=null,this.hoveredRegion=null,this.moveActive=!1,this.currentCursor=null,this.renderEngine=i,this.canvas=e,this.hitRegions=[],this.instances=[],this.mouse={x:0,y:0},this.handleMouseWheel=this.handleMouseWheel.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.initListeners(),this.reset()}makeInstance(e){const i=new ge(this,e);return this.instances.push(i),i}reset(){this.selectedRegion=null,this.hoveredRegion=null,this.hitRegions=[]}destroy(){this.removeListeners()}initListeners(){this.canvas&&(this.canvas.addEventListener("wheel",this.handleMouseWheel),this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.canvas.addEventListener("mouseleave",this.handleMouseUp),this.canvas.addEventListener("mousemove",this.handleMouseMove))}removeListeners(){this.canvas&&(this.canvas.removeEventListener("wheel",this.handleMouseWheel),this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.removeEventListener("mouseleave",this.handleMouseUp),this.canvas.removeEventListener("mousemove",this.handleMouseMove))}handleMouseWheel(e){const{deltaY:i,deltaX:n}=e;e.preventDefault();const s=this.renderEngine.getRealView(),r=this.renderEngine.getInitialZoom(),o=this.renderEngine.positionX,a=this.renderEngine.zoom,l=n/this.renderEngine.zoom;let h=i/1e3*this.renderEngine.zoom;if(this.renderEngine.tryToChangePosition(l),h=this.renderEngine.zoom-h>=r?h:this.renderEngine.zoom-r,h!==0&&this.renderEngine.setZoom(this.renderEngine.zoom-h)){const d=this.mouse.x/this.renderEngine.width,g=(s-this.renderEngine.width/this.renderEngine.zoom)*d;this.renderEngine.tryToChangePosition(g)}this.checkRegionHover(),(o!==this.renderEngine.positionX||a!==this.renderEngine.zoom)&&this.renderEngine.render()}handleMouseDown(){this.moveActive=!0,this.mouseDownPosition={x:this.mouse.x,y:this.mouse.y},this.mouseDownHoveredInstance=this.hoveredInstance,this.emit("down",this.hoveredRegion,this.mouse)}handleMouseUp(){this.moveActive=!1;const e=this.mouseDownPosition&&this.mouseDownPosition.x===this.mouse.x&&this.mouseDownPosition.y===this.mouse.y;e&&this.handleRegionHit(),this.emit("up",this.hoveredRegion,this.mouse,e),e&&this.emit("click",this.hoveredRegion,this.mouse)}handleMouseMove(e){if(this.moveActive){const i=this.mouse.y-e.offsetY,n=(this.mouse.x-e.offsetX)/this.renderEngine.zoom;(i||n)&&this.emit("change-position",{deltaX:n,deltaY:i},this.mouseDownPosition,this.mouse,this.mouseDownHoveredInstance)}this.mouse.x=e.offsetX,this.mouse.y=e.offsetY,this.checkRegionHover(),this.emit("move",this.hoveredRegion,this.mouse)}handleRegionHit(){const e=this.getHoveredRegion();this.emit("select",e,this.mouse)}checkRegionHover(){const e=this.getHoveredRegion();e&&this.hoveredRegion&&e.id!==this.hoveredRegion.id&&this.emit("hover",null,this.mouse),e?(!this.currentCursor&&e.cursor?this.renderEngine.canvas.style.cursor=e.cursor:this.currentCursor||this.clearCursor(),this.hoveredRegion=e,this.emit("hover",e,this.mouse),this.renderEngine.partialRender()):this.hoveredRegion&&!e&&(this.currentCursor||this.clearCursor(),this.hoveredRegion=null,this.emit("hover",null,this.mouse),this.renderEngine.partialRender())}getHoveredRegion(){const e=this.hitRegions.find(({x:n,y:s,w:r,h:o})=>this.mouse.x>=n&&this.mouse.x<=n+r&&this.mouse.y>=s&&this.mouse.y<=s+o);if(e)return e;const i=this.instances.find(({renderEngine:n})=>n.position<=this.mouse.y&&n.height+n.position>=this.mouse.y);if(this.hoveredInstance=i,i){const n=i.renderEngine.position;return i.hitRegions.find(({x:s,y:r,w:o,h:a})=>this.mouse.x>=s&&this.mouse.x<=s+o&&this.mouse.y>=r+n&&this.mouse.y<=r+a+n)}return null}clearHitRegions(){this.hitRegions=[]}addHitRegion(e,i,n,s,r,o,a){this.hitRegions.push({type:e,data:i,x:n,y:s,w:r,h:o,cursor:a})}setCursor(e){this.renderEngine.canvas.style.cursor=e,this.currentCursor=e}clearCursor(){const e=this.getHoveredRegion();this.currentCursor=null,e!=null&&e.cursor?this.renderEngine.canvas.style.cursor=e.cursor:this.renderEngine.canvas.style.cursor=""}}class Zn extends fe.EventEmitter{constructor({canvas:e,plugins:i,settings:n}){var s;super();const r=(s=n==null?void 0:n.styles)!==null&&s!==void 0?s:{};this.timeGrid=new Dt({styles:r==null?void 0:r.timeGrid}),this.renderEngine=new qn({canvas:e,settings:{styles:r==null?void 0:r.main,options:n==null?void 0:n.options},plugins:i,timeGrid:this.timeGrid}),this.interactionsEngine=new jn(e,this.renderEngine),this.plugins=i;const o=Array(this.plugins.length).fill(null).map(()=>{const a=this.renderEngine.makeInstance(),l=this.interactionsEngine.makeInstance(a);return{renderEngine:a,interactionsEngine:l}});this.plugins.forEach((a,l)=>{a.init(o[l].renderEngine,o[l].interactionsEngine)}),this.renderEngine.calcMinMax(),this.renderEngine.resetView(),this.renderEngine.recalcChildrenSizes(),this.renderEngine.calcTimeGrid(),this.plugins.forEach(a=>{var l;return(l=a.postInit)===null||l===void 0?void 0:l.call(a)}),this.renderEngine.render()}render(){this.renderEngine.render()}resize(e,i){this.renderEngine.render(()=>this.renderEngine.resize(e,i))}execOnPlugins(e,...i){let n=0;for(;n<this.plugins.length;)this.plugins[n][e]&&this.plugins[n][e](...i),n++}setSettings(e){var i,n;this.timeGrid.setSettings({styles:(i=e.styles)===null||i===void 0?void 0:i.timeGrid}),this.renderEngine.setSettings({options:e.options,styles:(n=e.styles)===null||n===void 0?void 0:n.main}),this.plugins.forEach(s=>{var r,o;return(r=s.setSettings)===null||r===void 0?void 0:r.call(s,{styles:(o=e.styles)===null||o===void 0?void 0:o[s.name]})}),this.renderEngine.render()}setZoom(e,i){const n=this.renderEngine.width/(i-e);this.renderEngine.setPositionX(e),this.renderEngine.setZoom(n),this.renderEngine.render()}}const Jn={};class es extends Zn{constructor({canvas:e,data:i,marks:n,waterfall:s,timeframeTimeseries:r,timeseries:o,colors:a,settings:l=Jn,plugins:h=[]}){var c;const d=[],{headers:{waterfall:p="waterfall",flameChart:g="flame chart"}={}}=l,u=(c=l==null?void 0:l.styles)!==null&&c!==void 0?c:{},b=new Wn({styles:u==null?void 0:u.timeGridPlugin});d.push(b);let y,v,f,w,P;o&&(P=new Un({data:o,settings:{styles:u==null?void 0:u.timeseriesPlugin}}),d.push(P)),n&&(y=new Yn({data:n}),y.on("select",C=>this.emit("select",C)),d.push(y)),s&&(v=new Gn({data:s,settings:{styles:u==null?void 0:u.waterfallPlugin}}),v.on("select",C=>this.emit("select",C)),i&&d.push(new ot(p,{styles:u==null?void 0:u.togglePlugin})),d.push(v)),i&&(w=new An({data:i,colors:a}),w.on("select",C=>this.emit("select",C)),s&&d.push(new ot(g,{styles:u==null?void 0:u.togglePlugin})),d.push(w)),(i||s||r)&&(f=new On({flameChartNodes:i,waterfall:s,timeseries:r,settings:{styles:u==null?void 0:u.timeframeSelectorPlugin}}),d.unshift(f)),super({canvas:e,settings:l,plugins:[...d,...h]}),w&&f&&(this.setNodes=C=>{w&&w.setData(C),f&&f.setFlameChartNodes(C)},this.setFlameChartPosition=({x:C,y:R})=>{typeof C=="number"&&this.renderEngine.setPositionX(C),typeof R=="number"&&w&&w.setPositionY(R),this.renderEngine.render()}),y&&(this.setMarks=C=>{y&&y.setMarks(C)}),v&&(this.setWaterfall=C=>{v&&v.setData(C),f&&f.setWaterfall(C)}),P&&(this.setTimeseries=C=>{P&&P.setData(C)}),f&&(this.setTimeframeTimeseries=C=>{f==null||f.setTimeseries(C)})}}var ts="Expected a function",ct=NaN,is="[object Symbol]",ns=/^\s+|\s+$/g,ss=/^[-+]0x[0-9a-f]+$/i,rs=/^0b[01]+$/i,os=/^0o[0-7]+$/i,as=parseInt,ls=typeof be=="object"&&be&&be.Object===Object&&be,hs=typeof self=="object"&&self&&self.Object===Object&&self,cs=ls||hs||Function("return this")(),ds=Object.prototype,us=ds.toString,gs=Math.max,fs=Math.min,Ae=function(){return cs.Date.now()};function ps(t,e,i){var n,s,r,o,a,l,h=0,c=!1,d=!1,p=!0;if(typeof t!="function")throw new TypeError(ts);e=dt(e)||0,ze(i)&&(c=!!i.leading,d="maxWait"in i,r=d?gs(dt(i.maxWait)||0,e):r,p="trailing"in i?!!i.trailing:p);function g(R){var O=n,ce=s;return n=s=void 0,h=R,o=t.apply(ce,O),o}function u(R){return h=R,a=setTimeout(v,e),c?g(R):o}function b(R){var O=R-l,ce=R-h,Ue=e-O;return d?fs(Ue,r-ce):Ue}function y(R){var O=R-l,ce=R-h;return l===void 0||O>=e||O<0||d&&ce>=r}function v(){var R=Ae();if(y(R))return f(R);a=setTimeout(v,b(R))}function f(R){return a=void 0,p&&n?g(R):(n=s=void 0,o)}function w(){a!==void 0&&clearTimeout(a),h=0,n=l=s=a=void 0}function P(){return a===void 0?o:f(Ae())}function C(){var R=Ae(),O=y(R);if(n=arguments,s=this,l=R,O){if(a===void 0)return u(l);if(d)return a=setTimeout(v,e),g(l)}return a===void 0&&(a=setTimeout(v,e)),o}return C.cancel=w,C.flush=P,C}function ze(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function vs(t){return!!t&&typeof t=="object"}function ms(t){return typeof t=="symbol"||vs(t)&&us.call(t)==is}function dt(t){if(typeof t=="number")return t;if(ms(t))return ct;if(ze(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=ze(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=t.replace(ns,"");var i=rs.test(t);return i||os.test(t)?as(t.slice(2),i?2:8):ss.test(t)?ct:+t}var bs=ps;const ys=gt(bs),Es=(t,e)=>{let i=[];const n={};return Object.values(t).forEach(s=>{var h;const r=s.caller,o=s.callee,a=(s.cost[String(e)]||0)>0?s.cost[String(e)]/1e3:0,l=0;if(o&&!n[o]&&(n[o]={name:o,start:l,duration:a,cost:s.cost,children:[]}),r&&!n[r]&&(n[r]={name:r,start:l,duration:a,cost:s.cost,children:[]}),!(!r||i.includes(o))){if(n[r]&&n[r].children){const c=n[r].children||[],d=c?c[c.length-1]:null;n[o].start=d?d.start+d.duration:n[o].start}else n[o].start+=n[r].start;(h=n[r].children)==null||h.push(n[o]),i.push(o)}}),i=[],n["main()"]},xs=()=>({build:Es}),ws=J({__name:"flame-graph",props:{edges:{}},emits:["hover","hide"],setup(t,{emit:e}){const i=t,n=e,s=_(),r=_(),{build:o}=xs(),a=()=>{if(!r.value||!s.value)return;const{width:l,height:h}=r.value.getBoundingClientRect();s.value.width=l||1,s.value.height=h||1;const c=new es({canvas:s.value,data:[o(i.edges,F.CPU)],settings:{styles:{main:{blockHeight:20}},options:{tooltip:(d,p,g)=>{d===null?n("hide"):n("hover",{callee:d.data.source.name,caller:"",cost:d.data.source.cost,position:{x:(g==null?void 0:g.x)||0,y:(g==null?void 0:g.y)||0}})}}}});c.render(),window.addEventListener("resize",ys(()=>{if(!r.value)return;const{width:d,height:p}=r.value.getBoundingClientRect();c.resize(d,p)},30))};return _e(()=>{Jt(()=>{a()})}),(l,h)=>(H(),I("div",{ref_key:"graph",ref:r,class:"flame-graph"},[E("canvas",{ref_key:"canvas",ref:s,class:"flame-graph__canvas"},null,512)],512))}}),Cs=q(ws,[["__scopeId","data-v-3fdcffce"]]),Rs=t=>(ft("data-v-01765fde"),t=t(),pt(),t),ks={class:"profiler-page"},Ms=Rs(()=>E("div",{class:"profiler-page__head"},null,-1)),Ss={class:"profiler-page__main"},Ts={ref:"calls",class:"profiler-page__callstack"},_s={ref:"info",class:"profiler-page__stat"},Ps={class:"profiler-page__stat-board"},Hs={class:"profiler-page__stat-tabs"},Fs=J({__name:"profiler-page",props:{event:{}},setup(t){const e={x:0,y:0},i=_(),n=_(""),s=_(e),r=B(()=>{let c=s.value.y,d=s.value.x;if(750+s.value.x>window.innerWidth-80){const p=750+s.value.x-window.innerWidth+100;d-=p}return 150+s.value.y>window.innerHeight&&(c=s.value.y-150),{top:`${c+10}px`,left:`${d}px`,width:"750px"}}),o=l=>{if(l){const{position:h,...c}=l||{};i.value=c,s.value=h}else i.value=null,s.value=e},a=l=>{n.value=l.tab.name};return(l,h)=>(H(),I("div",ks,[Ms,E("main",Ss,[E("section",Ts,[X(x(sn),{style:le({height:"calc(100vh - 48px)"})},{default:$(()=>[X(x(Li),{payload:l.event.payload,onHover:o,onHide:o},null,8,["payload"])]),_:1},8,["style"])],512),E("div",_s,[E("section",Ps,[X(x(vt),{cost:l.event.payload.peaks},null,8,["cost"])]),E("section",Hs,[X(x(li),{options:{useUrlFragment:!1},onChanged:a},{default:$(()=>[X(x(Ge),{name:"Call graph"},{default:$(()=>[n.value==="Call graph"?(H(),ae(x(Ui),{key:0,payload:l.event.payload},null,8,["payload"])):j("",!0)]),_:1}),X(x(Ge),{name:"Flamechart"},{default:$(()=>[n.value==="Flamechart"?(H(),ae(x(Cs),{key:n.value,"data-key":n.value,edges:l.event.payload.edges,onHover:o,onHide:o},null,8,["data-key","edges"])):j("",!0)]),_:1})]),_:1})])],512),i.value?(H(),ae(x(bt),{key:0,class:"profiler-page__hover-edge",edge:i.value,style:le(r.value)},null,8,["edge","style"])):j("",!0)])]))}}),Ls=q(Fs,[["__scopeId","data-v-01765fde"]]),Ne=t=>(ft("data-v-df2b77b9"),t=t(),pt(),t),Xs={class:"profiler-event"},As={key:0,class:"profiler-event__loading"},Ws=Ne(()=>E("div",null,null,-1)),Ys=Ne(()=>E("div",null,null,-1)),Ds=Ne(()=>E("div",null,null,-1)),zs=[Ws,Ys,Ds],$s={class:"profiler-event__body"},Is=J({__name:"[id]",setup(t){const{normalizeProfilerEvent:e}=ai(),{params:i}=ei(),{$authToken:n}=ii(),s=ti(),r=i.id;ri({title:`Profiler > ${r} | Buggregator`});const{events:o}=Ut(),a=_(!1),l=_(null),h=B(()=>l.value?e(l.value):null),c=()=>{o.removeById(r),s.push("/")};return _e(async()=>{a.value=!0,await ni(o.getUrl(r),{headers:{"X-Auth-Token":n.token||""},onResponse({response:{_data:p}}){l.value=p,a.value=!1},onResponseError(){s.push("/404")},onRequestError(){s.push("/404")}},"$tWhgOcWFS1")}),(p,g)=>{const u=Gt;return H(),I("main",Xs,[X(x(oi),{class:"profiler-event__head","button-title":"Delete event",onDelete:c},{default:$(()=>[X(u,{to:"/"},{default:$(()=>[N("Home")]),_:1}),N(" / "),X(u,{to:"/profiler"},{default:$(()=>[N("Profiler")]),_:1}),N(" / "),X(u,{disabled:!0},{default:$(()=>[N(ee(x(r)),1)]),_:1})]),_:1}),a.value&&!h.value?(H(),I("div",As,zs)):j("",!0),E("div",$s,[h.value?(H(),ae(x(Ls),{key:0,event:h.value},null,8,["event"])):j("",!0)])])}}}),js=q(Is,[["__scopeId","data-v-df2b77b9"]]);export{js as default};