@wick-charts/react 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.js +2218 -2157
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react"),I=require("react/jsx-runtime");var Xa=Object.defineProperty,Pr=i=>{throw TypeError(i)},Na=(i,t,e)=>t in i?Xa(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,P=(i,t,e)=>Na(i,typeof t!="symbol"?t+"":t,e),Rn=(i,t,e)=>t.has(i)||Pr("Cannot "+e),r=(i,t,e)=>(Rn(i,t,"read from private field"),e?e.call(i):t.get(i)),w=(i,t,e)=>t.has(i)?Pr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),u=(i,t,e,s)=>(Rn(i,t,"write to private field"),t.set(i,e),e),C=(i,t,e)=>(Rn(i,t,"access private method"),e),fn=(i,t,e,s)=>({set _(n){u(i,t,n)},get _(){return r(i,t,s)}});const Ua=22.999999999999996;var ze,Je,Qe,ot,Wt,qt,Xt,di,mn,gn;class _a{constructor(t){w(this,di),w(this,ze),w(this,Je,0),w(this,Qe,0),w(this,ot),w(this,Wt,Ua),w(this,qt,-1),w(this,Xt),u(this,ze,{from:t.initial.from,to:t.initial.to}),u(this,ot,{from:t.initial.from,to:t.initial.to}),u(this,Xt,{from:t.initial.from,to:t.initial.to})}get current(){return r(this,Xt)}get target(){return r(this,ot)}get animating(){const t=C(this,di,gn).call(this);return Math.abs(r(this,Xt).from-r(this,ot).from)>t||Math.abs(r(this,Xt).to-r(this,ot).to)>t||Math.abs(r(this,Je))>t*r(this,Wt)||Math.abs(r(this,Qe))>t*r(this,Wt)}retarget(t,e={}){const s=e.expandMs??200;if(s<=0){this.snap(t,e);return}const n=e.now??performance.now(),a=4.6/(s/1e3);if(r(this,qt)<0){u(this,ot,{from:t.from,to:t.to}),u(this,Wt,a),u(this,qt,n);return}const{x:o,vFrom:l,vTo:h}=C(this,di,mn).call(this,n);u(this,ze,o),u(this,Je,l),u(this,Qe,h),u(this,Wt,a),u(this,ot,{from:t.from,to:t.to}),u(this,qt,n),u(this,Xt,o)}snap(t,e={}){const s=e.now??performance.now();u(this,ze,{from:t.from,to:t.to}),u(this,ot,{from:t.from,to:t.to}),u(this,Je,0),u(this,Qe,0),u(this,qt,s),u(this,Xt,{from:t.from,to:t.to})}tick(t){if(r(this,qt)<0)return u(this,qt,t),!1;const{x:e,vFrom:s,vTo:n}=C(this,di,mn).call(this,t);u(this,Xt,e);const a=C(this,di,gn).call(this);return Math.abs(e.from-r(this,ot).from)<a&&Math.abs(e.to-r(this,ot).to)<a&&Math.abs(s)<a*r(this,Wt)&&Math.abs(n)<a*r(this,Wt)?(u(this,Xt,{from:r(this,ot).from,to:r(this,ot).to}),u(this,ze,{from:r(this,ot).from,to:r(this,ot).to}),u(this,Je,0),u(this,Qe,0),u(this,qt,t),!1):!0}}ze=new WeakMap,Je=new WeakMap,Qe=new WeakMap,ot=new WeakMap,Wt=new WeakMap,qt=new WeakMap,Xt=new WeakMap,di=new WeakSet,mn=function(i){const t=Math.max(0,(i-r(this,qt))/1e3),e=Math.exp(-r(this,Wt)*t),s=r(this,ze).from-r(this,ot).from,n=r(this,Je)+r(this,Wt)*s,a=r(this,ot).from+(s+n*t)*e,o=(n-r(this,Wt)*(s+n*t))*e,l=r(this,ze).to-r(this,ot).to,h=r(this,Qe)+r(this,Wt)*l,c=r(this,ot).to+(l+h*t)*e,d=(h-r(this,Wt)*(l+h*t))*e;return{x:{from:a,to:c},vFrom:o,vTo:d}},gn=function(){return Math.max(r(this,ot).to-r(this,ot).from,1)*1e-4};const pn=250,qn=4.6/(pn/1e3);var Ee,ti,ei,lt,ve,ye,Jt,Nt,fi,bn,vn;class Ga{constructor(t){w(this,fi),w(this,Ee),w(this,ti,0),w(this,ei,0),w(this,lt),w(this,ve,qn),w(this,ye,qn),w(this,Jt,-1),w(this,Nt),u(this,Ee,{min:t.initial.min,max:t.initial.max}),u(this,lt,{min:t.initial.min,max:t.initial.max}),u(this,Nt,{min:t.initial.min,max:t.initial.max})}get current(){return r(this,Nt)}get target(){return r(this,lt)}get animating(){const t=C(this,fi,vn).call(this),e=Math.min(r(this,ve),r(this,ye));return Math.abs(r(this,Nt).min-r(this,lt).min)>t||Math.abs(r(this,Nt).max-r(this,lt).max)>t||Math.abs(r(this,ti))>t*e||Math.abs(r(this,ei))>t*e}retarget(t,e={}){const s=e.now??performance.now(),n=e.expandMs??pn,a=e.contractMs??pn,o=4.6/(n/1e3),l=4.6/(a/1e3);if(r(this,Jt)<0){u(this,lt,{min:t.min,max:t.max}),u(this,ve,o),u(this,ye,o),u(this,Jt,s);return}const{x:h,vMin:c,vMax:d}=C(this,fi,bn).call(this,s);u(this,Ee,h),u(this,ti,c),u(this,ei,d),u(this,ve,t.min<h.min?o:l),u(this,ye,t.max>h.max?o:l),u(this,lt,{min:t.min,max:t.max}),u(this,Jt,s),u(this,Nt,h)}snap(t,e={}){const s=e.now??performance.now();u(this,Ee,{min:t.min,max:t.max}),u(this,lt,{min:t.min,max:t.max}),u(this,ti,0),u(this,ei,0),u(this,Jt,s),u(this,Nt,{min:t.min,max:t.max})}tick(t){if(r(this,Jt)<0)return u(this,Jt,t),!1;const{x:e,vMin:s,vMax:n}=C(this,fi,bn).call(this,t);u(this,Nt,e);const a=C(this,fi,vn).call(this),o=Math.min(r(this,ve),r(this,ye));return Math.abs(e.min-r(this,lt).min)<a&&Math.abs(e.max-r(this,lt).max)<a&&Math.abs(s)<a*o&&Math.abs(n)<a*o?(u(this,Nt,{min:r(this,lt).min,max:r(this,lt).max}),u(this,Ee,{min:r(this,lt).min,max:r(this,lt).max}),u(this,ti,0),u(this,ei,0),u(this,Jt,t),!1):!0}}Ee=new WeakMap,ti=new WeakMap,ei=new WeakMap,lt=new WeakMap,ve=new WeakMap,ye=new WeakMap,Jt=new WeakMap,Nt=new WeakMap,fi=new WeakSet,bn=function(i){const t=Math.max(0,(i-r(this,Jt))/1e3),e=Math.exp(-r(this,ve)*t),s=Math.exp(-r(this,ye)*t),n=r(this,Ee).min-r(this,lt).min,a=r(this,ti)+r(this,ve)*n,o=r(this,lt).min+(n+a*t)*e,l=(a-r(this,ve)*(n+a*t))*e,h=r(this,Ee).max-r(this,lt).max,c=r(this,ei)+r(this,ye)*h,d=r(this,lt).max+(h+c*t)*s,f=(c-r(this,ye)*(h+c*t))*s;return{x:{min:o,max:d},vMin:l,vMax:f}},vn=function(){return Math.max(r(this,lt).max-r(this,lt).min,1)*1e-4};function Fr(){return({initial:i})=>Ka(i)?new Ga({initial:i}):new _a({initial:i})}function Ka(i){return"min"in i&&"max"in i}const Za=/^(\d+(?:\.\d+)?)(ms|s)$/;function Br(i){if(i===!1)return 0;if(typeof i=="number")return i;if(typeof i=="string"){const t=Za.exec(i);if(!t)throw new Error(`Invalid AnimationTime: ${JSON.stringify(i)}`);const e=Number.parseFloat(t[1]);return t[2]==="s"?e*1e3:e}throw new Error(`Invalid AnimationTime: ${String(i)}`)}function vt(i,t){return i===void 0?t:Br(i)}const qa=100;var N,Z,Vi,ae,Hs,Ut,pt,Rs,Ws,oe,As;class Ja{constructor(t){w(this,pt),w(this,N),w(this,Z),w(this,Vi),w(this,ae),w(this,Hs),w(this,Ut,!1),u(this,N,{transition:t.y.curve({initial:t.initial.yRange}),settleMs:t.y.settleMs,stickyMs:t.y.stickyMs,stickyFloorMs:t.y.stickyFloorMs,gestureMs:t.y.gestureMs,toggleMs:t.y.toggleMs,toggleUntil:0}),u(this,Z,{transition:t.x.curve({initial:t.initial.xRange}),settleMs:t.x.settleMs,gestureMs:t.x.gestureMs,threshold:null,lastTarget:null,gestureUntil:0}),u(this,Vi,t.computeXTarget),u(this,ae,t.computeYTarget),u(this,Hs,t.onWake)}onPointAppended(t){const e=t??performance.now();if(e<r(this,Z).gestureUntil)return;const s=r(this,Vi).call(this),n=s??r(this,Z).transition.target,a=r(this,ae).call(this,{xTarget:n});if(s===null&&a===null)return;const o=!r(this,Ut),l=e<r(this,N).toggleUntil;s!==null&&C(this,pt,Rs).call(this,s,e,r(this,Z).settleMs),a!==null&&!l&&r(this,N).transition.retarget(a,{now:e,expandMs:r(this,N).settleMs,contractMs:C(this,pt,As).call(this,r(this,N).transition.current,a)}),C(this,pt,oe).call(this,o)}onSeriesVisibilityChanged(t){const e=r(this,ae).call(this,{xTarget:r(this,Z).transition.target});if(e===null)return;const s=t??performance.now(),n=!r(this,Ut);r(this,N).toggleMs>0?(r(this,N).transition.snap(r(this,N).transition.current,{now:s}),r(this,N).transition.retarget(e,{now:s,expandMs:r(this,N).toggleMs,contractMs:r(this,N).toggleMs}),r(this,N).toggleUntil=s+r(this,N).toggleMs):(r(this,N).transition.snap(e,{now:s}),r(this,N).toggleUntil=0),C(this,pt,oe).call(this,n)}onPanZoom(t,e){const s=e??performance.now(),n=!r(this,Ut);if(C(this,pt,Rs).call(this,t.xTarget,s,r(this,Z).gestureMs),r(this,Z).gestureUntil=s+qa,t.yAuto){const a=r(this,ae).call(this,{xTarget:t.xTarget});a!==null&&r(this,N).transition.retarget(a,{now:s,expandMs:r(this,N).gestureMs,contractMs:r(this,N).gestureMs})}C(this,pt,oe).call(this,n)}onAxisReconfig(t){const e=r(this,ae).call(this,{xTarget:r(this,Z).transition.target});if(e===null)return;const s=t??performance.now(),n=!r(this,Ut);r(this,N).transition.snap(e,{now:s}),C(this,pt,oe).call(this,n)}onProgrammaticZoom(t,e){r(this,Z).gestureUntil=0;const s=r(this,ae).call(this,{xTarget:t.xTarget}),n=e??performance.now(),a=!r(this,Ut);if(t.xEase===!0){C(this,pt,Rs).call(this,t.xTarget,n,r(this,Z).gestureMs),s!==null&&r(this,N).transition.retarget(s,{now:n,expandMs:r(this,N).settleMs,contractMs:C(this,pt,As).call(this,r(this,N).transition.current,s)}),C(this,pt,oe).call(this,a);return}C(this,pt,Ws).call(this,t.xTarget,n),s!==null&&r(this,N).transition.retarget(s,{now:n,expandMs:r(this,N).settleMs,contractMs:C(this,pt,As).call(this,r(this,N).transition.current,s)}),C(this,pt,oe).call(this,a)}onDataReplaced(t){const e=r(this,Vi).call(this),s=r(this,ae).call(this,{xTarget:e??r(this,Z).transition.target});if(e===null&&s===null)return;const n=t??performance.now(),a=!r(this,Ut);e!==null&&C(this,pt,Ws).call(this,e,n),s!==null&&r(this,N).transition.snap(s,{now:n}),C(this,pt,oe).call(this,a)}snap(t,e){r(this,Z).gestureUntil=0;const s=e??performance.now(),n=!r(this,Ut);t.x!==void 0&&C(this,pt,Ws).call(this,t.x,s),t.y!==void 0&&r(this,N).transition.snap(t.y,{now:s}),C(this,pt,oe).call(this,n)}tick(t){r(this,Z).transition.tick(t),r(this,N).transition.tick(t);const e=r(this,Z).transition.animating||r(this,N).transition.animating;return u(this,Ut,e),{xRange:r(this,Z).transition.current,yRange:r(this,N).transition.current,animating:e}}getAnimationState(){return{xRange:r(this,Z).transition.current,yRange:r(this,N).transition.current,animating:r(this,Z).transition.animating||r(this,N).transition.animating}}getTarget(){return{x:r(this,Z).transition.target,y:r(this,N).transition.target}}get animating(){return r(this,Z).transition.animating||r(this,N).transition.animating}get lastXTarget(){return r(this,Z).lastTarget}setXThreshold(t){r(this,Z).threshold=t}setXSettleMs(t){r(this,Z).settleMs=t}}N=new WeakMap,Z=new WeakMap,Vi=new WeakMap,ae=new WeakMap,Hs=new WeakMap,Ut=new WeakMap,pt=new WeakSet,Rs=function(i,t,e){r(this,Z).threshold!==null&&r(this,Z).threshold>0&&r(this,Z).lastTarget!==null&&Math.abs(i.to-r(this,Z).lastTarget.to)<r(this,Z).threshold||(r(this,Z).transition.retarget(i,{now:t,expandMs:e}),r(this,Z).lastTarget={from:i.from,to:i.to})},Ws=function(i,t){r(this,Z).transition.snap({from:i.from,to:i.to},{now:t}),r(this,Z).lastTarget={from:i.from,to:i.to}},oe=function(i){var t;i&&((t=r(this,Hs))==null||t.call(this))},As=function(i,t){const e=r(this,N).stickyMs;if(e<=0)return e;const s=Math.max(i.max-i.min,Number.EPSILON),n=Math.max(0,t.min-i.min),a=Math.max(0,i.max-t.max),o=Math.min(1,Math.max(n,a)/s),l=Math.min(r(this,N).stickyFloorMs,e);return Math.max(l,e*o)};function Qa(i){return new Ja(i)}const Ss=250;var Bt,Ve,Ye,ht,Ht,xe,we,Pt,Me,yn,tn,en,Dr;class to{constructor(t){w(this,Me),w(this,Bt),w(this,Ve,0),w(this,Ye,0),w(this,ht),w(this,Ht,-1),w(this,xe,Ss/1e3),w(this,we,Ss/1e3),w(this,Pt),u(this,Bt,{min:t.initial.min,max:t.initial.max}),u(this,ht,{min:t.initial.min,max:t.initial.max}),u(this,Pt,{min:t.initial.min,max:t.initial.max})}get current(){return r(this,Pt)}get target(){return r(this,ht)}get animating(){if(r(this,Ht)<0)return!1;const t=C(this,Me,Dr).call(this);return Math.abs(r(this,Pt).min-r(this,ht).min)>t||Math.abs(r(this,Pt).max-r(this,ht).max)>t}retarget(t,e={}){const s=e.now??performance.now(),n=e.expandMs??Ss,a=e.contractMs??Ss;if(r(this,Ht)<0){u(this,ht,{min:t.min,max:t.max}),u(this,xe,(t.min<r(this,Pt).min?n:a)/1e3),u(this,we,(t.max>r(this,Pt).max?n:a)/1e3),u(this,Ht,s);return}const{x:o,vMin:l,vMax:h}=C(this,Me,yn).call(this,s);u(this,Bt,o),u(this,Ve,Math.sign(l)===Math.sign(t.min-o.min)?l:0),u(this,Ye,Math.sign(h)===Math.sign(t.max-o.max)?h:0),u(this,xe,(t.min<o.min?n:a)/1e3),u(this,we,(t.max>o.max?n:a)/1e3),u(this,ht,{min:t.min,max:t.max}),u(this,Ht,s),u(this,Pt,o)}snap(t,e={}){const s=e.now??performance.now();u(this,Bt,{min:t.min,max:t.max}),u(this,ht,{min:t.min,max:t.max}),u(this,Ve,0),u(this,Ye,0),u(this,Ht,s),u(this,Pt,{min:t.min,max:t.max})}tick(t){if(r(this,Ht)<0)return u(this,Ht,t),!1;if(r(this,Bt).min===r(this,ht).min&&r(this,Bt).max===r(this,ht).max&&r(this,Ve)===0&&r(this,Ye)===0)return!1;const{x:e}=C(this,Me,yn).call(this,t);u(this,Pt,e);const s=(t-r(this,Ht))/1e3;return s>=r(this,xe)&&s>=r(this,we)?(u(this,Pt,{min:r(this,ht).min,max:r(this,ht).max}),u(this,Bt,{min:r(this,ht).min,max:r(this,ht).max}),u(this,Ve,0),u(this,Ye,0),!1):!0}}Bt=new WeakMap,Ve=new WeakMap,Ye=new WeakMap,ht=new WeakMap,Ht=new WeakMap,xe=new WeakMap,we=new WeakMap,Pt=new WeakMap,Me=new WeakSet,yn=function(i){const t=Math.max(0,(i-r(this,Ht))/1e3),e=r(this,xe)>0?Math.min(1,t/r(this,xe)):1,s=r(this,we)>0?Math.min(1,t/r(this,we)):1,n=C(this,Me,tn).call(this,r(this,Bt).min,r(this,Ve),r(this,ht).min,e,r(this,xe)),a=e>=1?0:C(this,Me,en).call(this,r(this,Bt).min,r(this,Ve),r(this,ht).min,e,r(this,xe)),o=C(this,Me,tn).call(this,r(this,Bt).max,r(this,Ye),r(this,ht).max,s,r(this,we)),l=s>=1?0:C(this,Me,en).call(this,r(this,Bt).max,r(this,Ye),r(this,ht).max,s,r(this,we));return{x:{min:n,max:o},vMin:a,vMax:l}},tn=function(i,t,e,s,n){if(s>=1)return e;const a=s*s,o=a*s,l=2*o-3*a+1,h=o-2*a+s,c=-2*o+3*a;return l*i+h*n*t+c*e},en=function(i,t,e,s,n){if(n<=0)return 0;const a=s*s,o=6*a-6*s,l=3*a-4*s+1,h=-6*a+6*s;return(o*i+l*n*t+h*e)/n},Dr=function(){return Math.max(r(this,ht).max-r(this,ht).min,1)*1e-4};function zr(){return({initial:i})=>new to({initial:i})}var Ue;class eo{constructor(t){w(this,Ue),u(this,Ue,{...t.initial})}get current(){return r(this,Ue)}get target(){return r(this,Ue)}get animating(){return!1}retarget(t){u(this,Ue,{...t})}snap(t){u(this,Ue,{...t})}tick(){return!1}}Ue=new WeakMap;function Yi(){return({initial:i})=>new eo({initial:i})}function Er(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.fontSize)!==void 0?i.axis.x.fontSize:t==="y"&&((s=i.axis.y)==null?void 0:s.fontSize)!==void 0?i.axis.y.fontSize:i.axis.fontSize}function Vr(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.textColor)!==void 0?i.axis.x.textColor:t==="y"&&((s=i.axis.y)==null?void 0:s.textColor)!==void 0?i.axis.y.textColor:i.axis.textColor}function Dt(i){return Array.isArray(i)?i.source??i[0]:i}const ci=6e4,_e=36e5,je=864e5,le=365*je;function zt(i){return i instanceof Date?i.getTime():i}function io(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:zt(t.time)}))}function so(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:zt(t.time)}))}function Yr(i){if(i.length<2)return je;const t=[];for(let e=1;e<Math.min(i.length,20);e++)t.push(i[e]-i[e-1]);return t.sort((e,s)=>e-s),t[Math.floor(t.length/2)]}function gs(i,t){const e=new Date(i);return t>=le?e.toLocaleDateString("en-US",{year:"numeric"}):t>=je?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=_e?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function jr(i){return new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function no(i){const t=[1e3,5e3,1e4,15e3,3e4],e=[ci,5*ci,10*ci,15*ci,30*ci],s=[_e,2*_e,4*_e,6*_e,12*_e],n=[je,7*je,30*je,90*je],a=[le,2*le,5*le,10*le,25*le,50*le,100*le];return i<ci?[...t,...e,...s,...n,...a]:i<_e?[...e,...s,...n,...a]:i<je?[...s,...n,...a]:i<le?[...n,...a]:a}const ro=.01;function Hr(i){const{chart:t,container:e,axis:s}=i,n=new Map;let a=null;const o=s==="x"?t.timeScale.tickTracker:t.yScale.tickTracker;function l(){return s==="x"?t.timeScale.niceTickValues(t.getDataInterval()):{ticks:t.yScale.niceTickValues(),tickInterval:0}}function h(g,p){return s==="x"?gs(g,p):t.yScale.formatY(g)}function c(g,p){if(s==="x"){g.style.left=`${t.timeScale.timeToX(p)}px`;return}g.style.top=`${t.yScale.valueToY(p)}px`}function d(g,p){g.style.color=Vr(p,s),g.style.fontSize=`${Er(p,s)}px`,g.style.fontFamily=p.typography.fontFamily}function f(g,p,b){const v=document.createElement("span");return v.textContent=h(g,p),v.style.position="absolute",v.style.userSelect="none",d(v,b),v.style.willChange="opacity",s==="x"?(v.style.transform="translateX(-50%)",v.style.whiteSpace="nowrap"):(v.style.right="8px",v.style.transform="translateY(-50%)",v.style.fontVariantNumeric="tabular-nums"),e.appendChild(v),v}function m(){const g=t.getTheme(),p=g!==a;a=g;const{ticks:b,tickInterval:v}=l();o.setCurrentTicks(b);const{entries:S}=o.snapshot(),L=new Set;for(const{value:y,opacity:M}of S){if(M<=ro)continue;L.add(y);let k=n.get(y);if(k===void 0)k=f(y,v,g),n.set(y,k);else{const F=h(y,v);k.textContent!==F&&(k.textContent=F),p&&d(k,g)}c(k,y),k.style.opacity=String(M)}for(const[y,M]of n)L.has(y)||(M.remove(),n.delete(y))}return m(),t.on("tickFrame",m),t.on("viewportChange",m),t.on("overlayChange",m),()=>{t.off("tickFrame",m),t.off("viewportChange",m),t.off("overlayChange",m);for(const g of n.values())g.remove();n.clear()}}const Wn=250,An=250,Gs=Wn,Pn=An,Fn=600,Bn=Wn,Dn=An,zn=Wn,En=An,ao=250,oo=250,lo=200,ho=150,co=250,sn=2500,Jn=500,uo=100,fo=250,$r=250,Or={line:{entryMs:0,smoothMs:0,pulseMs:0},candlestick:{entryMs:0,smoothMs:0},bar:{entryMs:0,smoothMs:0},pie:{entryMs:0,updateMs:0}};function mo(i){if(i!==null&&typeof i=="object")return{stickyMs:vt(i.max,sn),stickyFloorMs:vt(i.min,Jn)};if(i===void 0)return{stickyMs:sn,stickyFloorMs:Jn};const t=vt(i,sn);return{stickyMs:t,stickyFloorMs:t}}class $s{constructor(t,e,s){P(this,"axis"),P(this,"toggleMs"),P(this,"series"),this.axis=t,this.toggleMs=e,this.series=s}static resolve(t){if(t===!1)return new $s({y:{curve:Yi(),settleMs:0,stickyMs:0,stickyFloorMs:0,gestureMs:0},x:{curve:Yi(),settleMs:0,gestureMs:0},ticksMs:0},0,Or);const e=t===!0||t===void 0?void 0:t,s=e==null?void 0:e.axis,n=s===!1?!1:s==null?void 0:s.y,a=s===!1?!1:s==null?void 0:s.x,o=s===!1?!1:s==null?void 0:s.ticks,l=e==null?void 0:e.toggle,h=e==null?void 0:e.series,c=n===!1?{curve:Yi(),settleMs:0,stickyMs:0,stickyFloorMs:0,gestureMs:0}:{curve:(n==null?void 0:n.curve)??zr(),settleMs:vt(n==null?void 0:n.settle,co),...mo(n==null?void 0:n.sticky),gestureMs:vt(n==null?void 0:n.gesture,uo)},d=a===!1?{curve:Yi(),settleMs:0,gestureMs:0}:{curve:(a==null?void 0:a.curve)??Fr(),settleMs:vt(a==null?void 0:a.settle,lo),gestureMs:vt(a==null?void 0:a.gesture,ho)},f=o===!1?0:vt(o,$r),m=vt(l,fo),g=go(h);return new $s({y:c,x:d,ticksMs:f},m,g)}defaults(t){if(t==="line"){const{entryMs:n,smoothMs:a,pulseMs:o}=this.series.line;return{entryMs:n,smoothMs:a,pulseMs:o}}if(t==="candlestick"){const{entryMs:n,smoothMs:a}=this.series.candlestick;return{entryMs:n,smoothMs:a}}if(t==="pie"){const{entryMs:n,updateMs:a}=this.series.pie;return{entryMs:n,updateMs:a}}const{entryMs:e,smoothMs:s}=this.series.bar;return{entryMs:e,smoothMs:s}}overrides(t){const e={};if(t==="line"){const{entryMs:a,smoothMs:o,pulseMs:l}=this.series.line;return a===0&&(e.entryMs=0),o===0&&(e.smoothMs=0),l===0&&(e.pulseMs=0),e}if(t==="pie")return e;const{entryMs:s,smoothMs:n}=t==="candlestick"?this.series.candlestick:this.series.bar;return s===0&&(e.entryMs=0),n===0&&(e.smoothMs=0),e}}function go(i){if(i===!1)return Or;const t=i==null?void 0:i.line,e=i==null?void 0:i.candlestick,s=i==null?void 0:i.bar,n=i==null?void 0:i.pie,a=t===!1?{entryMs:0,smoothMs:0,pulseMs:0}:{entryMs:vt(t==null?void 0:t.entry,Gs),smoothMs:vt(t==null?void 0:t.smooth,Pn),pulseMs:vt(t==null?void 0:t.pulse,Fn)},o=e===!1?{entryMs:0,smoothMs:0}:{entryMs:vt(e==null?void 0:e.entry,Bn),smoothMs:vt(e==null?void 0:e.smooth,Dn)},l=s===!1?{entryMs:0,smoothMs:0}:{entryMs:vt(s==null?void 0:s.entry,zn),smoothMs:vt(s==null?void 0:s.smooth,En)},h=n===!1?{entryMs:0,updateMs:0}:{entryMs:vt(n==null?void 0:n.entry,ao),updateMs:vt(n==null?void 0:n.update,oo)};return{line:a,candlestick:o,bar:l,pie:h}}class Ks{constructor(){P(this,"listeners",new Map)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){var s;(s=this.listeners.get(t))==null||s.delete(e)}emit(t,...e){var s;(s=this.listeners.get(t))==null||s.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function Qn(i,t){const e=new Map;return new Proxy(i,{get(s,n){const a=Reflect.get(s,n,s);if(typeof a!="function")return a;const o=e.get(n);if(o)return o;const l=typeof n=="string"?n:String(n),h=a,c=(...d)=>(t.set(l,(t.get(l)??0)+1),h.apply(s,d));return e.set(n,c),c},set(s,n,a){return Reflect.set(s,n,a,s)}})}function tr(i,t,e){const s=document.createElement("canvas");return s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.display="block",s.style.zIndex=String(t),i.appendChild(s),s}class po extends Ks{constructor(t,e){super(),P(this,"mainCanvas"),P(this,"mainCtx"),P(this,"overlayCanvas"),P(this,"overlayCtx"),P(this,"resizeObserver"),P(this,"_size"),P(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=tr(t,0),this.overlayCanvas=tr(t,1);const s=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!s||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?Qn(s,e.drawCallsMain):s,this.overlayCtx=e?Qn(n,e.drawCallsOverlay):n;const a=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:a,verticalPixelRatio:a},this.resizeObserver=new ResizeObserver(l=>{this.handleResize(l[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const o=t.getBoundingClientRect();if(o.width>0&&o.height>0){const l=window.devicePixelRatio||1,h=l,c=Math.round(o.width*l),d=Math.round(o.height*h);this.mainCanvas.width=c,this.mainCanvas.height=d,this.overlayCanvas.width=c,this.overlayCanvas.height=d,this._size={media:{width:o.width,height:o.height},bitmap:{width:c,height:d},horizontalPixelRatio:c/o.width,verticalPixelRatio:d/o.height}}}handleResize(t){var e,s;let n,a,o,l;if(this.supportsDevicePixelContentBox&&(e=t.devicePixelContentBoxSize)!=null&&e[0]){const d=t.devicePixelContentBoxSize[0];n=d.inlineSize,a=d.blockSize;const f=t.contentBoxSize[0];o=f.inlineSize,l=f.blockSize}else{const d=(s=t.contentBoxSize)==null?void 0:s[0];if(d)o=d.inlineSize,l=d.blockSize;else{const m=t.contentRect;o=m.width,l=m.height}const f=window.devicePixelRatio||1;n=Math.round(o*f),a=Math.round(l*f)}if(n===0||a===0)return;this.mainCanvas.width=n,this.mainCanvas.height=a,this.overlayCanvas.width=n,this.overlayCanvas.height=a;const h=n/o,c=a/l;this._size={media:{width:o,height:l},bitmap:{width:n,height:a},horizontalPixelRatio:h,verticalPixelRatio:c},this.emit("resize",this._size)}get size(){return this._size}useMainLayer(t){this.mainCtx.save(),t({context:this.mainCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.mainCtx.restore()}useOverlayLayer(t){const{width:e,height:s}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,s),this.overlayCtx.save(),t({context:this.overlayCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.overlayCtx.restore()}get canvas(){return this.overlayCanvas}destroy(){this.resizeObserver.disconnect(),this.mainCanvas.remove(),this.overlayCanvas.remove(),this.removeAllListeners()}}const bo=3,vo=8,er=900,yo=24,xo=11,wo=10,Mo=18;function ko(i){const{state:t}=i;if(t==="idle"||t==="has-more")return;const e=i.timeScale.timeToX(i.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){So(i,e);return}t==="no-data"&&Co(i,e)}}function So({scope:i,theme:t,chartMediaHeight:e,side:s,now:n},a){const{context:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i,c=bo*l,d=vo*l,f=yo*l,m=a*l,g=s==="right"?m+f:m-f,p=e/2*h,b=n%er/er,v=Math.floor(b*3),S=Xr(t.axis.textColor??"#787b86",.3),L=t.axis.textColor??"#787b86";o.save();for(let y=0;y<3;y++){const M=(y-1)*d,k=g+M;o.beginPath(),o.arc(k,p,c,0,Math.PI*2),o.fillStyle=y===v?L:S,o.fill()}o.restore()}function Co({scope:i,theme:t,chartMediaHeight:e,side:s},n){const{context:a,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.round(n*o)+.5;a.save(),a.strokeStyle=Xr(t.axis.textColor??"#787b86",.6),a.lineWidth=1,a.setLineDash([4*o,4*o]),a.beginPath(),a.moveTo(h,0),a.lineTo(h,e*l),a.stroke(),a.setLineDash([]);const c=wo*o,d=s==="right"?h-c:h+c,f=Mo*l;a.fillStyle=t.axis.textColor??"#787b86",a.font=`${xo*o}px ${t.typography.fontFamily}`,a.textAlign=s==="right"?"right":"left",a.textBaseline="top",a.fillText("No more data",d,f),a.restore()}function Xr(i,t){const e=/^#([0-9a-f]{6})$/i.exec(i.trim());if(!e)return i;const s=parseInt(e[1].slice(0,2),16),n=parseInt(e[1].slice(2,4),16),a=parseInt(e[1].slice(4,6),16);return`rgba(${s}, ${n}, ${a}, ${t})`}function To(i){const t=performance.now();for(const e of["left","right"]){const s=i.edgeStates[e];if(s==="idle"||s==="has-more")continue;const n=i.resolveBoundary(e);n!==null&&ko({scope:i.scope,timeScale:i.timeScale,theme:i.theme,chartMediaHeight:i.chartMediaHeight,boundaryTime:n,side:e,state:s,now:t})}}function Lo(i,t,e){return t!==null?t:i==="left"?e.first??null:e.last??null}function Oe(i,t,e,s){return typeof i=="object"?i.intervals*e:s<=0?0:i/s*t}function Io(i){const{firstTime:t,lastTime:e,dataInterval:s,maxVisibleBars:n,chartWidth:a,padding:o}=i,l=n*s,h=e-t,c=h>0?h:s*10,d=Oe(o.right,c,s,a),f=Oe(o.left,c,s,a);let m=e+d,g=t-f;return m-g>l&&(m=e+d,g=m-l),{from:g,to:m}}const ir=i=>"close"in i?i.close:i.value;function Nr(i,t,e){const s=t.find(c=>c.id===i);if(!s)return null;const n=s.renderer;if(n.kind==="pie")return null;const a=n.getLastDataPoint();if(!a)return null;const{from:o,to:l}=e;if(a.time>=o&&a.time<=l)return{value:ir(a),isLive:!0};const h=n.getVisibleDataPoints(o,l);return h.length===0?null:{value:ir(h[h.length-1]),isLive:!1}}function Ro(i,t,e){var s,n;const a=t.find(l=>l.id===i);return a?((n=(s=a.renderer).getStackedLastValue)==null?void 0:n.call(s))||Nr(i,t,e):null}function Wo(i,t){const e=t.find(a=>a.id===i);if(!e)return null;const s=e.renderer;if(s.kind==="pie")return null;const n=s.getSecondLastDataPoint();return n?"close"in n?n.close:n.value:null}const Ao=5e3,Po=2e3,Fo=30;function nn(i,t,e){let s=0;for(;s<t.length&&t[s]<e;)s++;s>0&&(i.splice(0,s),t.splice(0,s))}function rn(i,t,e){const s=i.length-e;s>0&&(i.splice(0,s),t.splice(0,s))}function an(i){if(i.length===0)return{last:0,p50:0,p95:0};const t=[...i].sort((e,s)=>e-s);return{last:i[i.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function sr(i){if(i.length<2)return 0;const t=i[i.length-1]-i[0];return t<=0?0:(i.length-1)*1e3/t}function nr(i){const t={};for(const[e,s]of i)t[e]=s;return t}class on{constructor(t={}){P(this,"drawCallsMain",new Map),P(this,"drawCallsOverlay",new Map),P(this,"mainMs",[]),P(this,"overlayMs",[]),P(this,"mainStamps",[]),P(this,"overlayStamps",[]),P(this,"perSeriesMs",new Map),P(this,"perSeriesStamps",new Map),P(this,"listeners",new Set),P(this,"windowMs"),P(this,"maxSamples"),P(this,"heapInterval"),P(this,"heapCounter",0),P(this,"heapMb",null),P(this,"mainFrameCount",0),P(this,"overlayFrameCount",0),P(this,"lastStamp",0),this.windowMs=t.windowMs??Ao,this.maxSamples=t.maxSamples??Po,this.heapInterval=t.heapSampleEveryNFrames??Fo}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,s){if(this.lastStamp=s,t==="main"?(this.mainMs.push(e),this.mainStamps.push(s),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(s),this.overlayFrameCount++),this.trimAll(s),this.listeners.size>0){const n=this.getStats();for(const a of this.listeners)a(n)}}recordSeries(t,e,s=this.lastStamp){let n=this.perSeriesMs.get(t),a=this.perSeriesStamps.get(t);(!n||!a)&&(n=[],a=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,a)),n.push(e),a.push(s)}trimAll(t){const e=t-this.windowMs;nn(this.mainMs,this.mainStamps,e),nn(this.overlayMs,this.overlayStamps,e),rn(this.mainMs,this.mainStamps,this.maxSamples),rn(this.overlayMs,this.overlayStamps,this.maxSamples);for(const s of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(s),a=this.perSeriesStamps.get(s);!n||!a||(nn(n,a,e),rn(n,a,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[e,s]of this.perSeriesMs)t[e]=an(s);return{mainRendersPerSec:sr(this.mainStamps),overlayRendersPerSec:sr(this.overlayStamps),mainFrameMs:an(this.mainMs),overlayFrameMs:an(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:nr(this.drawCallsMain),overlay:nr(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}const Bo=200,Do=2;function zo(i){const{range:t,chartWidth:e,dataInterval:s,padding:n,dataStart:a,dataEnd:o}=i,l=d=>typeof d=="object"||d===0||e>0,h=a!==null&&l(n.left)?a-Oe(n.left,t,s,e):null,c=o!==null&&l(n.right)?o+Oe(n.right,t,s,e):null;return{left:h,right:c}}function Eo(i){return 10*i}function Vo(i){const{dataInterval:t,padding:e,dataStart:s,dataEnd:n}=i;if(s===null||n===null)return null;const a=n-s;if(a<=0)return null;const o=typeof e.left=="object"?e.left.intervals*t:null,l=typeof e.right=="object"?e.right.intervals*t:null;return o!==null||l!==null?a+(o??0)+(l??0):a+t*5}function Yo(i){return i*.5}function jo(i){const{currentLogical:t,timeDelta:e,chartWidth:s,dataInterval:n,padding:a,dataStart:o,dataEnd:l}=i,{from:h,to:c}=t;if(c-h<=0)return{newLogical:null,autoScrollOff:!1,edgeReached:null};let d=h+e,f=c+e,m=null;if(l!==null&&d>l){const v=d-l;d-=v,f-=v,m={side:"right",overshoot:v,boundaryTime:l}}if(o!==null&&f<o){const v=o-f;d+=v,f+=v,m={side:"left",overshoot:v,boundaryTime:o}}const g=l!==null&&(typeof a.right=="object"||a.right===0||s>0)?Oe(a.right,f-d,n,s):0,p=Yo(n),b=l!==null&&Math.abs(f-(l+g))<p;return{newLogical:{from:d,to:f},autoScrollOff:!b,edgeReached:m}}function Ho(i){const{currentLogical:t,centerTime:e,factor:s,chartWidth:n,dataInterval:a,padding:o,dataStart:l,dataEnd:h}=i,{from:c,to:d}=t,f=d-c;if(f<=0)return{newLogical:null};const m=Eo(a),{left:g,right:p}=zo({range:f,chartWidth:n,dataInterval:a,padding:o,dataStart:l,dataEnd:h}),b=g!==null&&p!==null?p-g:Vo({dataInterval:a,padding:o,dataStart:l,dataEnd:h});let v=f*s;v<m&&(v=m),s>1&&b!==null&&v>b&&(v=b);const S=(e-c)/f,L=e-S*v,y=L+v;return{newLogical:{from:L,to:y}}}function $o(i){if(!i)return{monitor:null,ownsMonitor:!1,showHud:!1};if(i===!0)return{monitor:new on,ownsMonitor:!0,showHud:!0};if(i instanceof on)return{monitor:i,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...s}=i,n=e!==void 0;return{monitor:e??new on(s),ownsMonitor:!n,showHud:t??!n}}const Cs={top:20,bottom:20,right:{intervals:3},left:{intervals:0}};function rr(i){return{top:(i==null?void 0:i.top)??Cs.top,bottom:(i==null?void 0:i.bottom)??Cs.bottom,right:(i==null?void 0:i.right)??Cs.right,left:(i==null?void 0:i.left)??Cs.left}}function ar(i,t){return typeof i=="number"&&typeof t=="number"?i===t:typeof i=="object"&&typeof t=="object"?i.intervals===t.intervals:!1}function Oo(i){return i===void 0||!Number.isFinite(i)?Bo:Math.max(Do,Math.floor(i))}const Xo=5e3,No=5,or=.3,Uo=5e3;var mi,Re;class _o{constructor(){w(this,mi,0),w(this,Re,0)}observe(t){if(r(this,mi)>0){const e=t-r(this,mi);e>=No&&e<Xo&&u(this,Re,r(this,Re)===0?e:or*e+(1-or)*r(this,Re))}u(this,mi,t)}pause(){u(this,mi,0)}pickSettleMs(t,e=3){return r(this,Re)===0?t:Math.min(Uo,Math.max(t,r(this,Re)*e))}get emaMs(){return r(this,Re)}}mi=new WeakMap,Re=new WeakMap;const Go=.5,Ko=4;function Zo(i){const{currentLogical:t,lastTime:e,prevDataEnd:s,dataInterval:n,paddingRight:a,chartWidth:o,holdUntilFilled:l}=i,{from:h,to:c}=t,d=c-h;if(d<=0)return{newLogical:null,releaseHold:!1,reengageAutoScroll:!1};const f=Oe(a,d,n,o);if(l){const y=n*.01;if(e+f<=c+y)return{newLogical:null,releaseHold:!1,reengageAutoScroll:!0}}const m=s!==null?c-s:f,g=Math.max(0,Math.min(f,m)),p=e+g,b=p-d,v=Go*n,S=o>0?Ko/o*d:v,L=Math.min(v,S);return Math.abs(p-c)<L?{newLogical:null,releaseHold:l,reengageAutoScroll:!0}:{newLogical:{from:b,to:p},releaseHold:l,reengageAutoScroll:!0}}function qo(i,t,e){let s=1/0,n=-1/0;for(const a of t){if(!a.visible||a.renderer.kind==="pie")continue;const o=a.renderer.getValueRange(i.from,i.to);o&&(o.max>n&&(n=o.max),o.min<s&&(s=o.min),e==null||e.push(o.min,o.max))}return s===1/0||n===-1/0?null:{min:s,max:n}}function lr(i,t,e,s,n){if(i===void 0||i==="auto")return t;if(typeof i=="number")return i;if(typeof i=="function")return i(s);const a=String(i).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const o=a[1]==="-"?-1:1,l=parseFloat(a[2])/100,h=Math.abs(e-t)||Math.abs(t)||1;return t+o*l*h*(n==="max"?1:-1)}return t}function Jo(i,t,e,s){const{context:n,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.max(1,Math.round(l)),c=Math.max(1,Math.round(o));n.strokeStyle=s.crosshair.color,n.lineWidth=Math.max(h,c),n.setLineDash([4*o,4*o]);const d=Math.round(t)+(c%2===1?.5:0),f=Math.round(e)+(h%2===1?.5:0);n.beginPath(),n.moveTo(d,0),n.lineTo(d,a.height),n.moveTo(0,f),n.lineTo(a.width,f),n.stroke(),n.setLineDash([])}function Qo({scope:i,timeScale:t,yScale:e,theme:s,yTicks:n,timeTicks:a}){const{context:o,bitmapSize:l,horizontalPixelRatio:h,verticalPixelRatio:c}=i;o.save(),o.strokeStyle=s.grid.color,s.grid.style==="dashed"?o.setLineDash([4*h,4*h]):s.grid.style==="dotted"&&o.setLineDash([1*h,3*h]);const d=Math.max(1,Math.round(c)),f=d%2===1?.5:0;o.lineWidth=d;for(const{value:p,opacity:b}of n.entries){if(b<=.01)continue;const v=Math.round(e.valueToBitmapY(p))+f;o.globalAlpha=b,o.beginPath(),o.moveTo(0,v),o.lineTo(l.width,v),o.stroke()}const m=Math.max(1,Math.round(h)),g=m%2===1?.5:0;o.lineWidth=m;for(const{value:p,opacity:b}of a.entries){if(b<=.01)continue;const v=Math.round(t.timeToBitmapX(p))+g;o.globalAlpha=b,o.beginPath(),o.moveTo(v,0),o.lineTo(v,l.height),o.stroke()}o.restore()}function hs(i,t,e){return Math.max(t,Math.min(e,i))}function ee(i,t,e){return i+(t-i)*e}function hr(i,t,e,s){const n=Math.exp(-e*s);return t+(i-t)*n}function ji(i){return 1-(1-i)**3}function ln(i,t,e){let s=0,n=i.length-1;for(;s<=n;){const a=s+n>>>1,o=e(i[a]);if(o<t)s=a+1;else if(o>t)n=a-1;else return a}return s}class Ur extends Ks{constructor(){super(...arguments),P(this,"data",[]),P(this,"_visible",!0),P(this,"cachedRange",null),P(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let s=1;s<t.length;s++)if(t[s].time<t[s-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((s,n)=>s.time-n.time),this.cachedRange=null,this.emit("update")}append(t){if(this.data.length>0&&t.time<=this.data[this.data.length-1].time){this.updateLast(t);return}this.data.push(t),this.cachedRange=null,this.emit("update")}updateLast(t){this.data.length!==0&&(this.data[this.data.length-1]=t,this.cachedRange=null,this.emit("update"))}trimStart(t){if(!(t<=0||this.data.length===0)){if(t>=this.data.length){this.data=[],this.cachedRange=null,this.emit("update");return}this.data=this.data.slice(t),this.cachedRange=null,this.emit("update")}}getAll(){return this.data}getVisibleData(t,e){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===e)return this.cachedResult;const s=Math.max(0,ln(this.data,t,a=>a.time)-1),n=Math.min(this.data.length,ln(this.data,e,a=>a.time)+1);return this.cachedResult=this.data.slice(s,n),this.cachedRange={from:t,to:e},this.cachedResult}first(){return this.data[0]}last(){return this.data[this.data.length-1]}get length(){return this.data.length}isEmpty(){return this.data.length===0}findNearest(t,e){if(this.data.length===0)return null;const s=ln(this.data,t,o=>o.time);let n=null,a=e;for(let o=Math.max(0,s-1);o<=Math.min(this.data.length-1,s+1);o++){const l=Math.abs(this.data[o].time-t);l<=a&&(a=l,n=this.data[o])}return n}}class tl{constructor(t,e,s){P(this,"dragging",!1),P(this,"lastX",0),this.target=t,this.timeScale=e,this.canvas=s}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const e=t.clientX-this.lastX;this.lastX=t.clientX;const s=this.timeScale.pixelDeltaToTimeDelta(-e);this.target.pan(s,this.timeScale.getMediaWidth())}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair")}isDragging(){return this.dragging}}class el{constructor(t,e){this.target=t,this.timeScale=e}handleWheel(t){t.preventDefault();const e=il(t.deltaY,t.deltaMode),s=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),a=Math.min(t.offsetX,n),o=this.timeScale.xToTime(a);this.target.zoomAt(o,s,n)}cancelPendingRebound(){}}function il(i,t){return t===WheelEvent.DOM_DELTA_LINE?i*8:t===WheelEvent.DOM_DELTA_PAGE?i*24:i}function cr(i,t){const e=i.clientX-t.clientX,s=i.clientY-t.clientY;return Math.hypot(e,s)}class sl extends Ks{constructor(t,e,s,n){super(),P(this,"zoom"),P(this,"pan"),P(this,"canvas"),P(this,"timeScale"),P(this,"yScale"),P(this,"target"),P(this,"onWheel",a=>{this.zoom.handleWheel(a)}),P(this,"onMouseDown",a=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(a)}),P(this,"onMouseMove",a=>{this.pan.isDragging()&&this.pan.handleMouseMove(a),this.emitCrosshair(a.offsetX,a.offsetY)}),P(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),P(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),P(this,"onDblClick",()=>{}),P(this,"lastTouchDist",0),P(this,"touchCount",0),P(this,"onTouchStart",a=>{a.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=a.touches.length,a.touches.length===1?this.pan.handleMouseDown({button:0,clientX:a.touches[0].clientX}):a.touches.length===2&&(this.lastTouchDist=cr(a.touches[0],a.touches[1]))}),P(this,"onTouchMove",a=>{if(a.preventDefault(),a.touches.length===1&&this.touchCount===1)this.pan.handleMouseMove({clientX:a.touches[0].clientX});else if(a.touches.length===2){const o=cr(a.touches[0],a.touches[1]),l=(a.touches[0].clientX+a.touches[1].clientX)/2,h=this.canvas.getBoundingClientRect();if(o>0&&this.lastTouchDist>0){const c=hs(this.lastTouchDist/o,.1,10),d=this.timeScale.xToTime(l-h.left);this.target.zoomAt(d,c,this.timeScale.getMediaWidth())}this.lastTouchDist=o}}),P(this,"onTouchEnd",a=>{if(a.touches.length===0){this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null);return}a.touches.length===1&&(this.touchCount=1,this.lastTouchDist=0,this.pan.handleMouseDown({button:0,clientX:a.touches[0].clientX}))}),P(this,"onTouchCancel",()=>{this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null)}),this.canvas=t,this.target=e,this.timeScale=s,this.yScale=n,this.zoom=new el(e,s),this.pan=new tl(e,s,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd),t.addEventListener("touchcancel",this.onTouchCancel)}emitCrosshair(t,e){const s=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:s,y:n})}destroy(){this.zoom.cancelPendingRebound(),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.canvas.removeEventListener("touchcancel",this.onTouchCancel),this.removeAllListeners()}}const nl=100,rl={position:"absolute",top:"4px",right:"4px",padding:"4px 6px",background:"rgba(0, 0, 0, 0.6)",color:"#e0e0e0",font:"11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace",borderRadius:"3px",pointerEvents:"none",zIndex:"20",whiteSpace:"pre",letterSpacing:"0.01em"};function ur(i){let t=0;for(const e of Object.values(i))t+=e;return t}const ms=9,Vn=7,ne=6,Yn=9;function al(i,t){return Math.round(i*t).toLocaleString("en-US")}function dr(i,t,e,s,n){return[i.padEnd(ms),t.toFixed(1).padStart(Vn),e.toFixed(2).padStart(ne),s.toFixed(2).padStart(ne),al(n,t).padStart(Yn)].join(" ")}function fr(i){return[i.padEnd(ms),"—".padStart(Vn),"—".padStart(ne),"—".padStart(ne),"idle".padStart(Yn)].join(" ")}function ol(){return["".padEnd(ms),"FPS".padStart(Vn),"ms".padStart(ne),"worst".padStart(ne),"calls/s".padStart(Yn)].join(" ")}function ll(i){const t=ur(i.drawCalls.main),e=ur(i.drawCalls.overlay),s=i.frameCount.main===0?fr("Main"):dr("Main",i.mainRendersPerSec,i.mainFrameMs.last,i.mainFrameMs.p95,t),n=i.frameCount.overlay===0?fr("Overlay"):dr("Overlay",i.overlayRendersPerSec,i.overlayFrameMs.last,i.overlayFrameMs.p95,e),a=[ol(),s,n],o=Object.keys(i.perSeries);if(o.length>1){a.push(""),a.push("Per series (main pass)"),a.push(["".padEnd(ms),"ms".padStart(ne),"worst".padStart(ne)].join(" "));for(const l of o){const h=i.perSeries[l];a.push([` ${l}`.padEnd(ms),h.last.toFixed(2).padStart(ne),h.p95.toFixed(2).padStart(ne)].join(" "))}}return a.join(`
2
- `)}class hl{constructor(t,e,s=nl){P(this,"element"),P(this,"unsubscribe"),P(this,"updateIntervalMs"),P(this,"lastUpdate",0),this.updateIntervalMs=s;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,rl),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=ll(t))}}class Ts{constructor(t){P(this,"dirty",!1),P(this,"rafId",null),P(this,"callback"),P(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const _r=i=>1-(1-i)**3;var he,gi,ce,Ps,pi,Hi,Fs,$i,Bs,Oi,We;class Pi{constructor(t){w(this,he),w(this,gi),w(this,ce),w(this,Ps,0),w(this,pi),w(this,Hi),w(this,Fs),w(this,$i),w(this,Bs),w(this,Oi),w(this,We,!1),u(this,he,t.initial),u(this,gi,t.initial),u(this,ce,t.initial),u(this,Fs,t.duration),u(this,pi,t.duration),u(this,$i,t.easing??_r),u(this,Hi,r(this,$i)),u(this,Bs,t.lerp),u(this,Oi,t.equals??Object.is)}get current(){return r(this,he)}get target(){return r(this,ce)}get animating(){return r(this,We)}snap(t){u(this,he,t),u(this,gi,t),u(this,ce,t),u(this,We,!1)}setTarget(t,e={}){const s=e.now??performance.now();if(r(this,We)){if(r(this,Oi).call(this,t,r(this,ce)))return;this.tick(s)}else if(r(this,Oi).call(this,t,r(this,he)))return;const n=e.duration??r(this,Fs);if(n<=0){this.snap(t);return}u(this,gi,r(this,he)),u(this,ce,t),u(this,pi,n),u(this,Hi,e.easing??r(this,$i)),u(this,Ps,s),u(this,We,!0)}tick(t){if(!r(this,We))return!1;const e=t-r(this,Ps);if(e>=r(this,pi))return u(this,he,r(this,ce)),u(this,We,!1),!1;const s=e<=0?0:e/r(this,pi);return u(this,he,r(this,Bs).call(this,r(this,gi),r(this,ce),r(this,Hi).call(this,s))),!0}}he=new WeakMap,gi=new WeakMap,ce=new WeakMap,Ps=new WeakMap,pi=new WeakMap,Hi=new WeakMap,Fs=new WeakMap,$i=new WeakMap,Bs=new WeakMap,Oi=new WeakMap,We=new WeakMap;const cl={entries:[],isAnimating:!1},ul=(i,t,e)=>i+(t-i)*e;function dl(i,t){if(i===t)return!0;if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return!1;return!0}var ue,Xi,_t,bi,vi;class Gr{constructor(t={}){w(this,ue,[]),w(this,Xi,[]),w(this,_t,new Map),w(this,bi),w(this,vi,!1),u(this,bi,t.fadeMs??$r)}setCurrentTicks(t){if(dl(t,r(this,ue)))return;const e=r(this,vi)?r(this,bi):0,s=new Set(t),n=new Set(r(this,ue));for(const a of t){if(n.has(a))continue;let o=r(this,_t).get(a);o===void 0&&(o=new Pi({initial:0,duration:r(this,bi),lerp:ul}),r(this,_t).set(a,o)),o.setTarget(1,{duration:e})}for(const a of r(this,ue)){if(s.has(a))continue;const o=r(this,_t).get(a);o!==void 0&&o.setTarget(0,{duration:e})}u(this,Xi,r(this,ue)),u(this,ue,t.slice())}tick(t){let e=!1;for(const[s,n]of r(this,_t)){if(n.tick(t)){e=!0;continue}n.current===0&&r(this,_t).delete(s)}return e}snapshot(){if(r(this,_t).size===0)return cl;const t=[];let e=!1;for(const[s,n]of r(this,_t)){const a=n.current;a<=0||(t.push({value:s,opacity:a}),n.animating&&(e=!0))}return{entries:t,isAnimating:e}}getCurrentTicks(){return r(this,ue)}getPreviousTicks(){return r(this,Xi)}setFadeMs(t){u(this,bi,t)}markArmed(){u(this,vi,!0)}get isArmed(){return r(this,vi)}reset(){u(this,ue,[]),u(this,Xi,[]),r(this,_t).clear(),u(this,vi,!1)}}ue=new WeakMap,Xi=new WeakMap,_t=new WeakMap,bi=new WeakMap,vi=new WeakMap;const fl=50,ml=80;class Kr{constructor(){P(this,"tickTracker",new Gr),P(this,"from",0),P(this,"to",0),P(this,"width",1),P(this,"pixelRatio",1),P(this,"dataInterval",null),P(this,"labelCountHintValue",null),P(this,"minSpacingValue",null),P(this,"resolvedInterval",null),P(this,"lastInterval",null),P(this,"lastWant",null),P(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??ml}update(t,e,s,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=s,n!==void 0&&n>0){const a=mr(n);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=gl(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=pl(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const o=mr(t);this.lastBucketKey!==null&&this.lastBucketKey!==o&&this.resetHysteresis(),this.lastBucketKey=o,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,s=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(fl,Math.floor((this.to-s)/e)+1)),a=[];for(let o=0;o<n;o++)a.push(s+o*e);return{ticks:a,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=no(this.dataInterval),e=this.to-this.from,s=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,s)}else n=s;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=s;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let a=t[t.length-1],o=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){a=t[l],o=l;break}if(this.labelCountHint!=null&&o>0&&this.countTicks(a)<this.labelCountHint){const l=t[o-1];l>=s&&(a=l)}this.resolvedInterval=a,this.lastInterval=a,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function mr(i){return i<6e4?0:i<36e5?1:i<864e5?2:3}function gl(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function pl(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function Zr(i){const t=Math.abs(i);if(t===0)return"0";if(t<1e-12)return i.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),s=Math.min(12,e+4),n=i.toFixed(s);return n.includes(".")?n.replace(/\.?0+$/,""):n}function qr(i){return Number.isNaN(i)?"—":i===1/0?"∞":i===-1/0?"−∞":null}function Xe(i,t){const e=qr(i);if(e!==null)return e;const s=Math.abs(i),n=(t==null?void 0:t.decimals)??2,a=(o,l,h)=>{const c=o/l,d=Number.parseFloat(c.toFixed(n));return Math.abs(d)>=1e3?null:`${c.toFixed(n)}${h}`};return s>=1e15?i.toExponential(2):s>=1e12?a(i,1e12,"T")??i.toExponential(2):s>=1e9?a(i,1e9,"B")??`${(i/1e12).toFixed(n)}T`:s>=1e6?a(i,1e6,"M")??`${(i/1e9).toFixed(n)}B`:s>=1e3?a(i,1e3,"K")??`${(i/1e6).toFixed(n)}M`:s<1?Zr(i):s<100?i.toFixed(2):i.toFixed(0)}function jn(i){const t=qr(i);if(t!==null)return t;const e=Math.abs(i);return e===0?"0":e<1?Zr(i):e<100?i.toFixed(4):e>=1e7?Xe(i):e<1e4?i.toFixed(2):i.toFixed(0)}function bl(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function vl(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e>=5?5:e>=2?2:1)*t}const yl=50,xl=50;class Jr{constructor(){P(this,"tickTracker",new Gr),P(this,"min",0),P(this,"max",0),P(this,"height",1),P(this,"pixelRatio",1),P(this,"labelCountHintValue",null),P(this,"minSpacingValue",null),P(this,"resolvedInterval",null),P(this,"lastInterval",null),P(this,"lastRawInterval",null),P(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??xl}update(t,e,s){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=s,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=wl(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Ml(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,s=Math.max(0,Math.min(yl,Math.floor((this.max-e)/t)+1)),n=[];for(let a=0;a<s;a++)n.push(e+a*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return Xe(t);const e=this.resolvedInterval,s=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(s)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,s=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/s;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const o=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let a=bl(n);if(this.labelCountHint!=null&&this.countTicks(a)<this.labelCountHint){const o=vl(n);o>=e&&o>0&&(a=o)}this.resolvedInterval=a,this.lastInterval=a,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function wl(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Ml(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function kl(i){let t=0,e=0;for(const s of i)s>0?t+=s:s<0&&(e+=s);return{positive:t,negative:e}}function Sl(i){return i.positive>0?i.positive:i.negative<0?i.negative:0}function Cl(i){return i.positive>0?100:i.negative<0?-100:0}const gr=(i,t,e)=>i+(t-i)*e;var Vt,de;class Qr{constructor(t){P(this,"stores"),P(this,"entries"),P(this,"displayedLastValues"),w(this,Vt),w(this,de),this.stores=Array.from({length:t},()=>new Ur),this.entries=Array.from({length:t},()=>new Map),this.displayedLastValues=new Array(t).fill(null),u(this,Vt,new Array(t).fill(null)),u(this,de,Array.from({length:t},()=>new Pi({initial:1,duration:0,lerp:gr})))}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}setData(t,e=0){const s=this.stores[e];if(!s)return;const n=so(t??[]);s.setData(n);const a=s.last();this.displayedLastValues[e]=a?a.value:null,r(this,Vt)[e]=null,this.entries[e].clear()}appendPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t,a=zt(n.time);s.append({...n,time:a}),this.displayedLastValues[e]=n.value,r(this,Vt)[e]=null;const o=this.options.entryMs;this.isEntryEnabled()&&o>0&&this.entries[e].set(a,{startTime:performance.now()})}updateLastPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t;s.updateLast({...n,time:zt(n.time)});const a=n.value,o=this.options.smoothMs;if(o<=0){this.displayedLastValues[e]=a,r(this,Vt)[e]=null;return}let l=r(this,Vt)[e];if(l===null){const h=this.displayedLastValues[e]??a;l=new Pi({initial:h,duration:o,lerp:gr}),r(this,Vt)[e]=l}l.setTarget(a)}keepLast(t,e=0){const s=this.stores[e];if(!s||t<0)return;const n=s.length-t;n<=0||s.trimStart(n)}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var s;(s=this.stores[t])==null||s.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners()}entranceProgress(t,e,s){var n;const a=(n=this.entries[e])==null?void 0:n.get(s);if(a===void 0)return 1;const o=this.options.entryMs;if(o<=0)return 1;const l=performance.now()-a.startTime;return l<=0?0:l>=o?1:l/o}effectiveValue(t,e,s,n){var a,o;const l=(o=(a=this.stores[e])==null?void 0:a.last())==null?void 0:o.time;return l===void 0||s!==l?n:this.displayedLastValues[e]??n}tickAnimations(t){for(const e of r(this,de))e.tick(t);for(let e=0;e<this.stores.length;e++){const s=r(this,Vt)[e];if(s!==null){const o=s.tick(t);this.displayedLastValues[e]=s.current,o||(r(this,Vt)[e]=null)}const n=this.options.entryMs;if(n<=0){this.entries[e].clear();continue}const a=this.entries[e];for(const[o,l]of a)t-l.startTime>=n&&a.delete(o)}}get needsAnimation(){for(const t of r(this,de))if(t.animating)return!0;for(const t of r(this,Vt))if(t!==null)return!0;for(const t of this.entries)if(t.size>0)return!0;return!1}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}setAlpha(t,e){for(const s of r(this,de))s.setTarget(t,{duration:e})}getAlpha(){for(const t of r(this,de))if(t.current>0||t.animating)return 1;return 0}setLayerAlpha(t,e,s){var n;(n=r(this,de)[t])==null||n.setTarget(e,{duration:s})}getLayerAlpha(t){var e;return((e=r(this,de)[t])==null?void 0:e.current)??1}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var s;return((s=this.stores[0])==null?void 0:s.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const s=this.getColors(),n=[];for(let a=0;a<this.stores.length;a++){if(!this.stores[a].isVisible())continue;const o=this.stores[a].getVisibleData(t-e,t+e);if(o.length===0)continue;let l=o[0],h=Math.abs(o[0].time-t);for(let c=1;c<o.length;c++){const d=Math.abs(o[c].time-t);d<=h&&(h=d,l=o[c])}n.push({layerIndex:a,time:l.time,value:l.value,color:s[a%s.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const o=(t=this.stores[0])==null?void 0:t.last();return o?{value:o.value,isLive:!0}:null}let e=-1/0;for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const s=this.options.stacking;if(s==="off"){for(let o=this.stores.length-1;o>=0;o--){if(!this.stores[o].isVisible())continue;const l=this.stores[o].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();n.push(l&&l.time===e?l.value:0)}const a=kl(n);return{value:s==="percent"?Cl(a):Sl(a),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].last();n&&e.push({layerIndex:s,time:n.time,value:n.value,color:t[s%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getTimeBounds(){let t=1/0,e=-1/0;for(const s of this.stores){const n=s.first();if(!n)continue;const a=s.last()??n;n.time<t&&(t=n.time),a.time>e&&(e=a.time)}return t===1/0?null:{first:t,last:e}}getLastDataPoint(){var t;return((t=this.stores[0])==null?void 0:t.last())??null}getSecondLastDataPoint(){var t;const e=(t=this.stores[0])==null?void 0:t.getAll();return!e||e.length<2?null:e[e.length-2]}sampleTimes(t){for(const e of this.stores){const s=e.getAll();if(s.length!==0)return s.slice(0,t).map(n=>n.time)}return[]}getVisibleDataPoints(t,e){var s;return((s=this.stores[0])==null?void 0:s.getVisibleData(t,e))??[]}getValueRange(t,e){const s=this.options.stacking;if(s==="percent")return{min:0,max:100};const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(s==="off"){let h=1/0,c=-1/0;for(const d of n)for(const f of d)Number.isFinite(f.value)&&(f.value<h&&(h=f.value),f.value>c&&(c=f.value));return h<1/0?{min:h,max:c}:null}const a=new Map;for(let h=0;h<n.length;h++)for(const c of n[h]){let d=a.get(c.time);d||(d=new Array(n.length).fill(0),a.set(c.time,d)),d[h]=Number.isFinite(c.value)?c.value:0}let o=0,l=0;for(const h of a.values()){let c=0,d=0;for(const f of h)f>0?c+=f:d+=f;c>l&&(l=c),d<o&&(o=d)}return l>o?{min:o,max:l}:null}}Vt=new WeakMap,de=new WeakMap;const Tl={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off",anchor:"center",entryMs:zn,smoothMs:En};function pr(i){return{...i,entryMs:i.entryMs===!1?0:i.entryMs??zn,smoothMs:i.smoothMs===!1?0:i.smoothMs??En}}class Ll extends Qr{constructor(t,e){super(t),P(this,"kind","bar"),this.options=pr({...Tl,...e})}updateOptions(t){this.options=pr({...this.options,...t})}isEntryEnabled(){return(this.options.entryAnimation??"fade-grow")!=="none"}applyTheme(t,e){const s=e.seriesColors,n=this.options.colors.map((a,o)=>a===s[o]?t.seriesColors[o]??a:a);this.updateOptions({colors:n})}applyBarTransform(t,e,s,n,a,o){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:s,barHeight:n,x:a,barWidth:o,alpha:1};let h=s,c=n,d=a,f=1;if((l==="fade"||l==="fade-grow")&&(f=t),l==="grow"||l==="fade-grow"){const m=n*t;s<e?h=e-m:h=e,c=Math.max(1,m)}return l==="slide"&&(d=a+(1-t)*o,f=t),{topY:h,barHeight:c,x:d,barWidth:o,alpha:f}}render(t){switch(this.tickAnimations(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:s,yScale:n,dataInterval:a}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange();let c=0;for(const L of this.stores){if(!L.isVisible())continue;const y=L.getVisibleData(h.from,h.to).length;if(y>c&&(c=y),c>2)break}const d=s.barWidthBitmap(a),f=Math.round(30*l),m=c<=2?Math.min(f,d):d,g=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),p=Math.floor(g/2),b=this.options.anchor==="right"?g:p,v=n.getRange().min<0,S=v?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const L=this.options.colors[0],y=this.options.colors.length>1?this.options.colors[1]:L,M=this.stores[0].getVisibleData(h.from,h.to);for(const k of M){if(!Number.isFinite(k.value))continue;const F=this.effectiveValue(t,0,k.time,k.value),T=this.entranceProgress(t,0,k.time),D=s.timeToBitmapX(k.time);if(F>=0){const B=n.valueToBitmapY(F),x=Math.max(1,S-B);this.drawAnimatedBar({context:o,progress:T,baselineY:S,topY:B,barHeight:x,x:D-b,barWidth:g,color:L})}else{const B=n.valueToBitmapY(F),x=Math.max(1,B-S);this.drawAnimatedBar({context:o,progress:T,baselineY:S,topY:S,barHeight:x,x:D-b,barWidth:g,color:y})}}}else{const L=this.stores.map((M,k)=>this.getLayerAlpha(k)>0?M.getVisibleData(h.from,h.to):[]),y=new Map;for(let M=0;M<L.length;M++){const k=this.getLayerAlpha(M);for(const F of L[M]){if(!Number.isFinite(F.value))continue;let T=y.get(F.time);T||(T=[],y.set(F.time,T)),T.push({layer:M,value:this.effectiveValue(t,M,F.time,F.value)*k})}}for(const[M,k]of y){k.sort((T,D)=>Math.abs(D.value)-Math.abs(T.value));const F=s.timeToBitmapX(M);for(const{layer:T,value:D}of k){const B=this.options.colors[T%this.options.colors.length],x=this.entranceProgress(t,T,M);if(D>=0){const R=n.valueToBitmapY(D),A=Math.max(1,S-R);this.drawAnimatedBar({context:o,progress:x,baselineY:S,topY:R,barHeight:A,x:F-b,barWidth:g,color:B})}else{const R=n.valueToBitmapY(D),A=Math.max(1,R-S);this.drawAnimatedBar({context:o,progress:x,baselineY:S,topY:S,barHeight:A,x:F-b,barWidth:g,color:B})}}}}if(v){o.strokeStyle=t.theme.grid.color,o.lineWidth=1;const L=Math.round(S)+.5;o.beginPath(),o.moveTo(0,L),o.lineTo(e.bitmapSize.width,L),o.stroke()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:a,dataInterval:o}=t,{context:l,horizontalPixelRatio:h}=s,c=n.getRange();let d=0;for(const y of this.stores){if(!y.isVisible())continue;const M=y.getVisibleData(c.from,c.to).length;if(M>d&&(d=M),d>2)break}const f=n.barWidthBitmap(o),m=Math.round(30*h),g=d<=2?Math.min(m,f):f,p=Math.max(1,Math.round(g*this.options.barWidthRatio)-2),b=Math.floor(p/2),v=this.options.anchor==="right"?p:b,S=this.stores.map((y,M)=>this.getLayerAlpha(M)>0?y.getVisibleData(c.from,c.to):[]);if(S.every(y=>y.length===0))return;const L=new Map;for(let y=0;y<S.length;y++){const M=this.getLayerAlpha(y);for(const k of S[y]){let F=L.get(k.time);F||(F=new Array(S.length).fill(0),L.set(k.time,F));const T=Number.isFinite(k.value)?k.value:0;F[y]=this.effectiveValue(t,y,k.time,T)*M}}for(let y=0;y<S.length;y++){const M=this.options.colors[y%this.options.colors.length];for(const[k,F]of L){const T=F[y];if(T===0)continue;const D=n.timeToBitmapX(k);let B=0,x=0;for(let A=0;A<y;A++){const z=F[A];z>0?B+=z:x+=z}const R=this.entranceProgress(t,y,k);if(e){let A=0,z=0;for(const E of F)E>0?A+=E:z+=E;if(T>0&&A>0){const E=B/A*100,V=(B+T)/A*100,X=a.valueToBitmapY(V),$=a.valueToBitmapY(E),G=Math.max(1,$-X);this.drawAnimatedBar({context:l,progress:R,baselineY:$,topY:X,barHeight:G,x:D-v,barWidth:p,color:M})}else if(T<0&&z<0){const E=x/z*-100,V=(x+T)/z*-100,X=a.valueToBitmapY(E),$=a.valueToBitmapY(V),G=Math.max(1,$-X);this.drawAnimatedBar({context:l,progress:R,baselineY:X,topY:X,barHeight:G,x:D-v,barWidth:p,color:M})}}else if(T>0){const A=a.valueToBitmapY(B+T),z=a.valueToBitmapY(B),E=Math.max(1,z-A);this.drawAnimatedBar({context:l,progress:R,baselineY:z,topY:A,barHeight:E,x:D-v,barWidth:p,color:M})}else{const A=a.valueToBitmapY(x),z=a.valueToBitmapY(x+T),E=Math.max(1,z-A);this.drawAnimatedBar({context:l,progress:R,baselineY:A,topY:A,barHeight:E,x:D-v,barWidth:p,color:M})}}}}fillBar(t,e,s,n,a,o){t.fillStyle=o,t.fillRect(e,s,n,a)}drawAnimatedBar(t){const{context:e,progress:s,baselineY:n,topY:a,barHeight:o,x:l,barWidth:h,color:c}=t,d=this.options.entryAnimation??"fade-grow";if(s>=1||d==="none"){this.fillBar(e,l,a,h,o,c);return}const f=this.applyBarTransform(s,n,a,o,l,h);e.save(),e.globalAlpha=f.alpha,e.fillStyle=c,e.fillRect(f.x,f.topY,f.barWidth,f.barHeight),e.restore()}}function br(i,t){return i.length<=t?i:Rl(i,t,e=>e.time,e=>e.value)}function Il(i,t){if(i.length<=t)return i;const e=Math.ceil(i.length/t),s=[];for(let n=0;n<i.length;n+=e){const a=Math.min(n+e,i.length);let o=-1/0,l=1/0,h=0;for(let c=n;c<a;c++)i[c].high>o&&(o=i[c].high),i[c].low<l&&(l=i[c].low),h+=i[c].volume??0;s.push({time:i[n].time,open:i[n].open,high:o,low:l,close:i[a-1].close,volume:h})}return s}function Rl(i,t,e,s){if(t>=i.length||t<3)return i;const n=[i[0]],a=(i.length-2)/(t-2);let o=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*a)+1,c=Math.min(Math.floor((l+2)*a)+1,i.length-1);let d=0,f=0;const m=c,g=Math.min(Math.floor((l+3)*a)+1,i.length),p=g-m;if(p>0){for(let y=m;y<g;y++)d+=e(i[y]),f+=s(i[y]);d/=p,f/=p}let b=-1,v=h;const S=e(i[o]),L=s(i[o]);for(let y=h;y<c;y++){const M=Math.abs((S-d)*(s(i[y])-L)-(S-e(i[y]))*(f-L));M>b&&(b=M,v=y)}n.push(i[v]),o=v}return n.push(i[i.length-1]),n}const vr=new Map;function Wl(i){return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)]}function De(i,t){if(i.startsWith("rgba"))return i.replace(/[\d.]+\)\s*$/,`${t})`);if(i.startsWith("rgb("))return i.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=i+t;let s=vr.get(e);if(s)return s;const[n,a,o]=Wl(i);return s=`rgba(${n}, ${a}, ${o}, ${t})`,vr.set(e,s),s}function Ls(i){return typeof i=="number"&&!Number.isFinite(i)}const Al=(()=>{const i=new WeakSet;return(t,e,s,n)=>{s.length===0||i.has(t)||(i.add(t),console.warn(`[wick-charts] ${e}: skipping ${s.length} row${s.length===1?"":"s"} with NaN / Infinity values (indices ${s.join(", ")}; first offending row: ${n}). Filter upstream data; the renderer drops poisoned rows to keep the rest of the chart alive.`))}})(),Pl=.15,Fl=.005;function Bl(i,t,e){const s={time:t.time,open:i.open+(t.open-i.open)*e,high:i.high+(t.high-i.high)*e,low:i.low+(t.low-i.low)*e,close:i.close+(t.close-i.close)*e};if(i.volume!==void 0||t.volume!==void 0){const n=i.volume??0,a=t.volume??0;s.volume=n+(a-n)*e}return s}function Dl(i,t){return i.time===t.time&&i.open===t.open&&i.high===t.high&&i.low===t.low&&i.close===t.close&&(i.volume??0)===(t.volume??0)}const zl={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6,entryMs:Bn,smoothMs:Dn};function yr(i){return{...i,entryMs:i.entryMs===!1?0:i.entryMs??Bn,smoothMs:i.smoothMs===!1?0:i.smoothMs??Dn}}var Gt,Yt,Ni,Ds,yi;class El{constructor(t,e){P(this,"kind","candlestick"),P(this,"store"),P(this,"options"),P(this,"displayedLast",null),P(this,"entries",new Map),w(this,Gt,null),w(this,Yt,null),w(this,Ni,!0),w(this,Ds,!1),w(this,yi,new Pi({initial:1,duration:0,lerp:(s,n,a)=>s+(n-s)*a})),this.store=t,this.options=yr({...zl,...e}),this.displayedLast=t.last()??null}isEntryEnabled(){return(this.options.entryAnimation??"unfold")!=="none"}updateOptions(t){this.options=yr({...this.options,...t})}getColor(){return Dt(this.options.up.body)}setData(t){this.store.setData(io(t??[]));const e=this.store.last();this.displayedLast=e??null,u(this,Gt,null),this.entries.clear(),u(this,Yt,null)}appendPoint(t){const e=t,s=zt(e.time),n={...e,time:s};this.store.append(n),this.displayedLast=n,u(this,Gt,null);const a=this.options.entryMs;this.isEntryEnabled()&&a>0&&this.entries.set(s,{startTime:performance.now()})}updateLastPoint(t){const e=t,s=zt(e.time),n={...e,time:s};this.store.updateLast(n);const a=this.options.smoothMs;if(a<=0){this.displayedLast=n,u(this,Gt,null);return}let o=r(this,Gt);if(o===null){const l=this.displayedLast??n;o=new Pi({initial:l,duration:a,lerp:Bl,equals:Dl}),u(this,Gt,o)}o.setTarget(n)}keepLast(t){if(t<0)return;const e=this.store.length-t;e<=0||this.store.trimStart(e)}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[Dt(this.options.up.body)]}applyTheme(t,e){this.updateOptions({up:{...t.candlestick.up},down:{...t.candlestick.down}})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners()}tickAnimations(t){r(this,yi).tick(t);const e=r(this,Gt);if(e!==null){const n=e.tick(t);this.displayedLast=e.current,n||u(this,Gt,null)}const s=this.options.entryMs;if(s<=0){this.entries.clear();return}for(const[n,a]of this.entries)t-a.startTime>=s&&this.entries.delete(n)}get needsAnimation(){return r(this,yi).animating||r(this,Gt)!==null||this.entries.size>0||!r(this,Ni)}cancelEntranceAnimations(){this.entries.clear()}setAlpha(t,e){r(this,yi).setTarget(t,{duration:e})}getAlpha(){return r(this,yi).current}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}getTimeBounds(){const t=this.store.first(),e=this.store.last();return!t||!e?null:{first:t.time,last:e.time}}getLastDataPoint(){return this.store.last()??null}getSecondLastDataPoint(){const t=this.store.getAll();return t.length>=2?t[t.length-2]:null}sampleTimes(t){return this.store.getAll().slice(0,t).map(e=>e.time)}getVisibleDataPoints(t,e){return this.store.getVisibleData(t,e)}getValueRange(t,e){const s=this.store.getVisibleData(t,e);let n=1/0,a=-1/0;for(const o of s)Number.isFinite(o.low)&&o.low<n&&(n=o.low),Number.isFinite(o.high)&&o.high>a&&(a=o.high);return n===1/0||a===-1/0?null:{min:n,max:a}}render(t){this.tickAnimations(performance.now());const{scope:e,timeScale:s,yScale:n,dataInterval:a}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange();let c=this.store.getVisibleData(h.from,h.to);const d=e.mediaSize.width,f=c.length>d*2;if(f&&(c=Il(c,Math.round(d*1.5))),c.length===0)return;const m=this.displayedLast;if(!f&&m!==null){const R=c.length-1;c[R].time===m.time&&(c=[...c.slice(0,R),m])}let g=null;if(this.entries.size>0){const R=this.options.entryMs,A=performance.now();for(const z of c){const E=this.entries.get(z.time);if(E===void 0)continue;const V=A-E.startTime,X=R<=0?1:Math.min(1,Math.max(0,V/R));if(X>=1)continue;const $=ji(X);g===null&&(g=new Map),g.set(z.time,$)}}const p=s.barWidthBitmap(a),b=Math.round(30*l),v=c.length<=2?Math.min(b,p):p,S=Math.max(1,Math.round(l));let L=Math.max(1,Math.round(v*this.options.bodyWidthRatio)-2);(L&1)!==(S&1)&&(L=L>1?L-1:2);const y=Math.floor(L/2),M=f!==r(this,Ds);u(this,Ds,f);const k=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:o,data:c,timeScale:s,chartHeight:k,barWidth:v,wickWidth:S,entranceByTime:g,snapVolScale:M});const F=[],T=[],D=[];let B=null;for(let R=0;R<c.length;R++){const A=c[R];if(Ls(A.open)||Ls(A.close)||Ls(A.high)||Ls(A.low)){D.push(R),B===null&&(B=A);continue}A.close>=A.open?F.push(A):T.push(A)}B!==null&&Al(this,"candlestick",D,`time ${B.time}`);const x={ctx:o,timeScale:s,yScale:n,halfBody:y,bodyWidth:L,wickWidth:S,entranceByTime:g};this.drawCandles({...x,candles:F,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...x,candles:T,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:s,chartHeight:n,barWidth:a,wickWidth:o,entranceByTime:l,snapVolScale:h}){let c=0;for(const S of e)Number.isFinite(S.volume)&&S.volume>c&&(c=S.volume);if(c===0){u(this,Yt,null),u(this,Ni,!0);return}r(this,Yt)===null||h?u(this,Yt,c):u(this,Yt,r(this,Yt)+(c-r(this,Yt))*Pl),u(this,Ni,Math.abs(c-r(this,Yt))<=c*Fl);const d=r(this,Yt),f=n*.2;let m=Math.max(1,a-2);(m&1)!==(o&1)&&(m=m>1?m-1:2);const g=Math.floor(m/2),p=De(Dt(this.options.up.body),.2),b=De(Dt(this.options.down.body),.2),v=this.options.entryAnimation??"unfold";for(const S of e){if(!Number.isFinite(S.volume)||S.volume<=0)continue;const L=S.volume,y=s.timeToBitmapX(S.time),M=Math.min(f,Math.max(1,L/d*f)),k=S.close>=S.open;t.fillStyle=k?p:b;const F=(l==null?void 0:l.get(S.time))??1;if(F>=1||v==="none"){t.fillRect(y-g,n-M,m,M);continue}const T=hn(F,v,{x:y-g,barWidth:m,anchorY:n,topY:n-M,bottomY:n});t.save(),t.globalAlpha=T.alpha,t.fillRect(T.x,T.topY,m,Math.max(1,T.bottomY-T.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:s,yScale:n,halfBody:a,bodyWidth:o,wickWidth:l,body:h,wickColor:c,entranceByTime:d}){if(e.length===0)return;const f=this.options.entryAnimation??"unfold",m=o+2;t.fillStyle=c;for(const p of e){const b=(d==null?void 0:d.get(p.time))??1,v=s.timeToBitmapX(p.time),S=n.valueToBitmapY(p.open),L=n.valueToBitmapY(p.high),y=n.valueToBitmapY(p.low),M=v-Math.floor(l/2);if(b>=1||f==="none"){t.fillRect(M,L,l,y-L);continue}const k=hn(b,f,{x:M,barWidth:m,anchorY:S,topY:L,bottomY:y});t.save(),t.globalAlpha=k.alpha,t.fillRect(k.x,k.topY,l,Math.max(1,k.bottomY-k.topY)),t.restore()}const g=Array.isArray(h);for(const p of e){const b=(d==null?void 0:d.get(p.time))??1,v=s.timeToBitmapX(p.time),S=n.valueToBitmapY(p.open),L=n.valueToBitmapY(p.close),y=Math.min(S,L),M=Math.max(S,L),k=Math.max(1,M-y),F=b<1&&f!=="none";let T=v-a,D=y,B=k,x=1;if(F){const R=hn(b,f,{x:v-a,barWidth:m,anchorY:S,topY:y,bottomY:M});T=R.x,D=R.topY,B=Math.max(1,R.bottomY-R.topY),x=R.alpha}if(F&&t.save(),g&&B>2){const R=t.createLinearGradient(0,D,0,D+B);R.addColorStop(0,h[0]),R.addColorStop(1,h[1]),t.fillStyle=R}else t.fillStyle=g?h[0]:h;F&&(t.globalAlpha=x),t.fillRect(T,D,o,B),F&&t.restore()}}}Gt=new WeakMap,Yt=new WeakMap,Ni=new WeakMap,Ds=new WeakMap,yi=new WeakMap;function hn(i,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:i};case"unfold":return{x:e.x,topY:ee(e.anchorY,e.topY,i),bottomY:ee(e.anchorY,e.bottomY,i),alpha:1};case"slide":return{x:e.x+(1-i)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:i};case"fade-unfold":return{x:e.x,topY:ee(e.anchorY,e.topY,i),bottomY:ee(e.anchorY,e.bottomY,i),alpha:i}}}const Vl={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off",entryMs:Gs,smoothMs:Pn,pulseMs:Fn};function xr(i){const t=i.areaFill,e=t!==void 0&&i.area===void 0?{visible:!!t}:i.area;return{...i,area:e,entryMs:i.entryMs===!1?0:i.entryMs??Gs,smoothMs:i.smoothMs===!1?0:i.smoothMs??Pn,pulseMs:i.pulseMs===!1?0:i.pulseMs??Fn}}class Yl extends Qr{constructor(t,e){super(t),P(this,"kind","line"),P(this,"areaGradientCache",new Map),this.options=xr({...Vl,...e})}updateOptions(t){this.options=xr({...this.options,...t})}getStacking(){return this.options.stacking}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)}),this.options.strokeWidth===e.line.width&&this.updateOptions({strokeWidth:t.line.width})}isEntryEnabled(){return(this.options.entryAnimation??"grow")!=="none"}get hasPulse(){return this.options.pulse&&this.options.pulseMs>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let s=0;s<this.stores.length;s++){if(this.getLayerAlpha(s)<=0)continue;const n=this.stores[s].last();if(n&&n.time>=t)return!0}return!1}render(t){this.tickAnimations(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e){const s=this.stores[e],n=s.last();if(!n)return null;const{timeScale:a,yScale:o}=t,l=a.timeToBitmapX(n.time),h=o.valueToBitmapY(this.effectiveValue(t,e,n.time,n.value));if((this.options.entryAnimation??"grow")!=="grow")return{x:l,y:h};const c=this.entranceProgress(t,e,n.time);if(c>=1)return{x:l,y:h};const d=s.getAll();if(d.length<2)return{x:l,y:h};const f=d[d.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=a.timeToBitmapX(f.time),g=o.valueToBitmapY(f.value),p=ji(c);return{x:ee(m,l,p),y:ee(g,h,p)}}renderOff(t){var e;const{scope:s,timeScale:n,yScale:a}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,c=this.options.strokeWidth>0,d=Math.max(1,Math.round(this.options.strokeWidth*h)),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){const g=this.getLayerAlpha(m);if(g<=0)continue;let p=this.stores[m].getVisibleData(l.from,l.to);const b=s.mediaSize.width;if(p.length>b*2&&(p=br(p,Math.round(b*1.5))),p.length<2)continue;const v=this.options.colors[m%this.options.colors.length],S=p[p.length-1],L=this.entranceProgress(t,m,S.time),y=f==="fade"&&L<1,M=this.trailingEndpoint(t,m)??{x:n.timeToBitmapX(S.time),y:a.valueToBitmapY(this.effectiveValue(t,m,S.time,S.value))},k=M.x,F=M.y,T=g<1;(T||y)&&(o.save(),T&&(o.globalAlpha*=g),y&&(o.globalAlpha*=L));const D=p.length-1,B=[];let x=null;for(let A=0;A<D;A++){const z=p[A].value;if(!Number.isFinite(z)){x=null;continue}x||(x=[],B.push(x)),x.push({x:n.timeToBitmapX(p[A].time),y:a.valueToBitmapY(z)})}const R=(e=p[D])==null?void 0:e.value;if(Number.isFinite(k)&&Number.isFinite(F)&&Number.isFinite(R)&&(x?x.push({x:k,y:F}):B.push([{x:k,y:F}])),c&&B.some(A=>A.length>=2)){o.beginPath();for(const A of B)if(!(A.length<2)){o.moveTo(A[0].x,A[0].y);for(let z=1;z<A.length;z++)o.lineTo(A[z].x,A[z].y)}o.strokeStyle=v,o.lineWidth=d,o.lineJoin="round",o.lineCap="round",o.stroke()}if(c){const A=Math.max(1,d/2);let z=!1;for(const E of B)E.length===1&&(z||(o.beginPath(),z=!0),o.moveTo(E[0].x+A,E[0].y),o.arc(E[0].x,E[0].y,A,0,Math.PI*2));z&&(o.fillStyle=v,o.fill())}if(this.options.area.visible){const A=s.bitmapSize.height,z=String(m),E=this.areaGradientCache.get(z);let V;E&&E.bottomY===A&&E.color===v?V=E.gradient:(V=o.createLinearGradient(0,0,0,A),V.addColorStop(0,De(v,.12)),V.addColorStop(1,De(v,.01)),this.areaGradientCache.set(z,{gradient:V,bottomY:A,color:v})),o.fillStyle=V;for(const X of B)if(!(X.length<2)){o.beginPath(),o.moveTo(X[0].x,X[0].y);for(let $=1;$<X.length;$++)o.lineTo(X[$].x,X[$].y);o.lineTo(X[X.length-1].x,A),o.lineTo(X[0].x,A),o.closePath(),o.fill()}}(y||T)&&o.restore()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:a}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,c=this.options.strokeWidth>0,d=Math.max(1,Math.round(this.options.strokeWidth*h)),f=s.mediaSize.width,m=this.stores.map((x,R)=>{if(this.getLayerAlpha(R)<=0)return[];let A=x.getVisibleData(l.from,l.to);return A.length>f*2&&(A=br(A,Math.round(f*1.5))),A}),g=new Set;for(const x of m)for(const R of x)g.add(R.time);const p=Array.from(g).sort((x,R)=>x-R);if(p.length<2)return;const b=m.map((x,R)=>{const A=new Map,z=this.getLayerAlpha(R);for(const E of x)A.set(E.time,this.effectiveValue(t,R,E.time,E.value)*z);return A}),v=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let x=0;x<p.length;x++){const R=p[x];let A=0;if(e)for(let E=0;E<this.stores.length;E++){const V=b[E].get(R);Number.isFinite(V)&&(A+=V)}let z=0;for(let E=0;E<this.stores.length;E++){const V=b[E].get(R),X=Number.isFinite(V)?V:0;z+=e&&A>0?X/A*100:X,v[E][x]=z}}const S=this.options.entryAnimation??"grow",L=new Map;for(let x=0;x<p.length;x++)L.set(p[x],x);const y=p.length-1,M=new Array(this.stores.length).fill(1);for(let x=0;x<this.stores.length;x++){if(this.getLayerAlpha(x)<=0)continue;const R=this.stores[x].last();if(!R)continue;const A=this.entranceProgress(t,x,R.time);if(A>=1)continue;const z=L.get(R.time);if(z!==y)continue;const E=this.stores[x].getAll();if(E.length<2)continue;const V=E[E.length-2].time;L.get(V)===z-1&&(M[x]=A)}const k=(x,R)=>{if(R>=1||x.length<2)return;const A=x.length-1,z=x[A-1],E=x[A];x[A]=[ee(z[0],E[0],R),ee(z[1],E[1],R)]},F=s.bitmapSize.height;let T=-1,D=-1;for(let x=0;x<this.stores.length;x++)if(!(this.getLayerAlpha(x)<=0))if(T<0)T=x;else{D=x;break}const B=T>=0?this.getLayerAlpha(T):1;for(let x=this.stores.length-1;x>=0;x--){const R=this.getLayerAlpha(x);if(R<=0)continue;const A=this.options.colors[x%this.options.colors.length],z=M[x],E=x>0&&this.getLayerAlpha(x-1)>0?M[x-1]:1,V=x===T,X=D>=0&&x===D&&B<1,$=[];for(let _=0;_<p.length;_++){const q=x>0?a.valueToBitmapY(v[x-1][_]):F;let J=q;V?J=F:X&&(J=q+(F-q)*(1-B)),$.push([n.timeToBitmapX(p[_]),J])}S==="grow"&&k($,ji(E));const G=[];for(let _=0;_<p.length;_++){let q=a.valueToBitmapY(v[x][_]);V&&R<1&&(q=F+(q-F)*R),G.push([n.timeToBitmapX(p[_]),q])}S==="grow"&&k(G,ji(z));const xt=S==="fade"&&z<1;if(xt&&(o.save(),o.globalAlpha=z),this.options.area.visible){let _=G[0][1],q=$[0][1];for(let K=1;K<G.length;K++)G[K][1]<_&&(_=G[K][1]);for(let K=1;K<$.length;K++)$[K][1]>q&&(q=$[K][1]);let J=De(A,.25);if(q>_+.5){const K=o.createLinearGradient(0,_,0,q);K.addColorStop(0,De(A,.25)),K.addColorStop(1,De(A,.05)),J=K}o.beginPath(),o.moveTo(G[0][0],G[0][1]);for(let K=1;K<G.length;K++)o.lineTo(G[K][0],G[K][1]);for(let K=$.length-1;K>=0;K--)o.lineTo($[K][0],$[K][1]);o.closePath(),o.fillStyle=J,o.fill()}const Tt=c&&R<1;if(Tt&&(o.save(),o.globalAlpha*=R),c){o.beginPath(),o.moveTo(G[0][0],G[0][1]);for(let _=1;_<G.length;_++)o.lineTo(G[_][0],G[_][1]);o.strokeStyle=A,o.lineWidth=d,o.lineJoin="round",o.lineCap="round",o.stroke()}Tt&&o.restore(),xt&&o.restore()}}drawOverlay(t){this.tickAnimations(performance.now());const{scope:e,timeScale:s,yScale:n,crosshair:a,dataInterval:o}=t,l=e,h=this.options.pulseMs,c=h>0?performance.now()/(h*2*Math.PI)%1:0;if(a){const d=this.options.colors,f=this.options.stacking,m=4*l.horizontalPixelRatio,g=[],p=[];for(let v=0;v<this.stores.length;v++){const S=this.stores[v].findNearest(a.time,o);S?(g.push(S.value),p.push(S.time)):(g.push(0),p.push(null))}const b=[];if(f==="off")for(const v of g)b.push(v);else{let v=0;if(f==="percent")for(let L=0;L<g.length;L++)v+=g[L]*this.getLayerAlpha(L);let S=0;for(let L=0;L<g.length;L++){const y=g[L]*this.getLayerAlpha(L);S+=f==="percent"&&v>0?y/v*100:y,b.push(S)}}for(let v=0;v<this.stores.length;v++){const S=p[v];if(S===null)continue;const L=this.getLayerAlpha(v);if(L<=0)continue;const y=d[v%d.length],M=s.timeToBitmapX(S),k=n.valueToBitmapY(b[v]),F=L<1;F&&(e.context.save(),e.context.globalAlpha*=L),e.context.save(),e.context.globalAlpha*=.25,e.context.beginPath(),e.context.arc(M,k,m+3*l.horizontalPixelRatio,0,Math.PI*2),e.context.fillStyle=y,e.context.fill(),e.context.restore(),e.context.beginPath(),e.context.arc(M,k,m,0,Math.PI*2),e.context.fillStyle=y,e.context.fill(),F&&e.context.restore()}}if(this.hasPulse&&h>0){const d=this.options.stacking;for(let f=0;f<this.stores.length;f++){const m=this.getLayerAlpha(f);if(m<=0)continue;const g=this.options.colors[f%this.options.colors.length];if(d==="off"){const M=this.trailingEndpoint(t,f);if(!M)continue;this.drawPulse({ctx:e.context,x:M.x,y:M.y,color:g,pixelRatio:l.horizontalPixelRatio,phase:c,alpha:m});continue}const p=this.stores[f].last();if(!p)continue;const b=p.time,v=d==="percent",S=M=>{const k=D=>{const B=this.getLayerAlpha(D);if(B<=0)return 0;const x=D===f&&M===b?p:this.stores[D].findNearest(M,0);return!x||x.time!==M?0:this.effectiveValue(t,D,M,x.value)*B};let F=0;if(v)for(let D=0;D<this.stores.length;D++)F+=k(D);let T=0;for(let D=0;D<=f;D++){const B=k(D);T+=v&&F>0?B/F*100:B}return T};let L=s.timeToBitmapX(b),y=n.valueToBitmapY(S(b));if((this.options.entryAnimation??"grow")==="grow"){const M=this.entranceProgress(t,f,b);if(M<1){const k=this.stores[f].getAll(),F=k.length>=2?k[k.length-2]:null;if(F!==null&&F.time!==b){const T=ji(M),D=s.timeToBitmapX(F.time),B=n.valueToBitmapY(S(F.time));L=ee(D,L,T),y=ee(B,y,T)}}}this.drawPulse({ctx:e.context,x:L,y,color:g,pixelRatio:l.horizontalPixelRatio,phase:c,alpha:m})}}}drawPulse({ctx:t,x:e,y:s,color:n,pixelRatio:a,phase:o,alpha:l=1}){const h=3*a,c=.4+.6*Math.abs(Math.sin(o*2*Math.PI)),d=h+4*a*c,f=l<1;f&&(t.save(),t.globalAlpha*=l),t.beginPath(),t.arc(e,s,d,0,Math.PI*2),t.fillStyle=De(n,c*.3),t.fill(),t.beginPath(),t.arc(e,s,h,0,Math.PI*2),t.fillStyle=n,t.fill(),f&&t.restore()}}const ta={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8},jl={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...ta},animate:!1},xn=Math.PI/180;function Hl(i,t){return{...i??{},...t}}function $l(i){return{...ta,...i??{}}}function Ol(i){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return i===!0||i===!1?t:{...t,...i}}function Xl(i){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return i===!0||i===!1?t:{...t,...i}}const Ti=Math.PI*2,ea=.85;function wr(i){const{bitmapWidth:t,bitmapHeight:e,padTop:s,padBottom:n}=i,a=Math.max(0,i.labelReserve??0),o=Math.min(Math.max(0,s),e),l=Math.min(Math.max(0,n),e-o),h=e-o-l,c=Math.max(0,t-2*a),d=t/2,f=o+h/2,m=Math.max(0,Math.min(c,h)/2*ea);return{cx:d,cy:f,maxR:m}}function Nl(i){if(!i.startsWith("#"))return!1;const t=parseInt(i.slice(1,3),16),e=parseInt(i.slice(3,5),16),s=parseInt(i.slice(5,7),16);return t*.299+e*.587+s*.114>150}function Ul(i,t){if(!i.startsWith("#"))return i;const e=Math.min(255,parseInt(i.slice(1,3),16)+Math.round(255*t)),s=Math.min(255,parseInt(i.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(i.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Mr(i){if(i.startsWith("#"))return{r:parseInt(i.slice(1,3),16)||0,g:parseInt(i.slice(3,5),16)||0,b:parseInt(i.slice(5,7),16)||0,a:1};const t=i.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(s=>s.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function _l(i,t){const e=Mr(i),s=Mr(t),n=s.a,a=Math.round(s.r*n+e.r*(1-n)),o=Math.round(s.g*n+e.g*(1-n)),l=Math.round(s.b*n+e.b*(1-n));return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var tt,it,Kt,Mt,xi,Ae,$t,Ge,rt,wn,ke,Ui,zs,ia,sa,na;class Gl{constructor(t){w(this,rt),P(this,"kind","pie"),w(this,tt,[]),w(this,it),w(this,Kt,-1),w(this,Mt,[]),w(this,xi,0),w(this,Ae,1),w(this,$t,null),w(this,Ge,[]),u(this,it,C(this,rt,wn).call(this,jl,t??{}))}getData(){return r(this,tt)}setData(t){const e=t??[];u(this,tt,e),u(this,Mt,new Array(e.length).fill(0)),u(this,Ae,r(this,it).animate?0:1),u(this,$t,null);for(const s of r(this,Ge))s()}onDataChanged(t){return r(this,Ge).push(t),()=>{const e=r(this,Ge).indexOf(t);e>=0&&r(this,Ge).splice(e,1)}}updateOptions(t){var e,s;const n=(e=r(this,it).sliceLabels)==null?void 0:e.mode;u(this,it,C(this,rt,wn).call(this,r(this,it),t??{})),((s=r(this,it).sliceLabels)==null?void 0:s.mode)==="outside"&&n!=="outside"&&u(this,Ae,r(this,it).animate?0:1),u(this,$t,null)}getColor(){var t,e;return((t=r(this,tt)[0])==null?void 0:t.color)??((e=r(this,it).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&u(this,$t,null)}hitTest(t,e,s,n,a){var o;if(r(this,tt).length===0)return-1;const l=C(this,rt,Ui).call(this);if(l<=0)return-1;const h=((o=r(this,$t))==null?void 0:o.reserve)??0,{cx:c,cy:d,maxR:f}=wr({bitmapWidth:s,bitmapHeight:n,padTop:(a==null?void 0:a.top)??0,padBottom:(a==null?void 0:a.bottom)??0,labelReserve:h}),m=f,g=m*r(this,it).innerRadiusRatio,p=t-c,b=e-d,v=Math.sqrt(p*p+b*b);if(v>m||v<g)return-1;let S=Math.atan2(b,p)+Math.PI/2;S<0&&(S+=Ti);let L=0;for(let y=0;y<r(this,tt).length;y++){const M=C(this,rt,ke).call(this,r(this,tt)[y].value)/l*Ti;if(S>=L&&S<L+M)return y;L+=M}return-1}setHoverIndex(t){return r(this,Kt)===t?!1:(u(this,Kt,t),!0)}getHoverIndex(){return r(this,Kt)}getHoverInfo(t){if(r(this,Kt)<0)return null;const e=r(this,tt)[r(this,Kt)];if(!e)return null;const s=C(this,rt,Ui).call(this),n=r(this,it).colors??t.seriesColors;return{label:e.label,value:e.value,percent:s>0?C(this,rt,ke).call(this,e.value)/s*100:0,color:e.color??n[r(this,Kt)%n.length]}}getSliceInfo(t){if(r(this,tt).length===0)return null;const e=C(this,rt,Ui).call(this),s=r(this,it).colors??t.seriesColors;return r(this,tt).map((n,a)=>({label:n.label,value:n.value,percent:e>0?C(this,rt,ke).call(this,n.value)/e*100:0,color:n.color??s[a%s.length]}))}get needsAnimation(){var t;if(!r(this,it).animate)return!1;for(let e=0;e<r(this,Mt).length;e++){const s=e===r(this,Kt)?1:0;if(Math.abs(r(this,Mt)[e]-s)>.01)return!0}return((t=r(this,it).sliceLabels)==null?void 0:t.mode)==="outside"&&r(this,Ae)<.99}dispose(){u(this,Ge,[]),u(this,tt,[]),u(this,Mt,[]),u(this,xi,0)}_inspectSliceOffsets(){return r(this,Mt)}render(t){if(r(this,tt).length===0)return;const{scope:e,theme:s,padding:n}=t,{context:a,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=e,c=performance.now(),d=r(this,xi)?Math.min(.05,(c-r(this,xi))/1e3):0;u(this,xi,c);const f=C(this,rt,Ui).call(this);if(f<=0)return;const m=12;for(;r(this,Mt).length<r(this,tt).length;)r(this,Mt).push(0);if(r(this,it).animate)for(let V=0;V<r(this,tt).length;V++){const X=V===r(this,Kt)?1:0;r(this,Mt)[V]=hr(r(this,Mt)[V],X,m,d)}const g=$l(r(this,it).sliceLabels);a.font=`${g.fontSize*l}px ${s.typography.fontFamily}`,g.mode==="outside"&&r(this,it).animate&&u(this,Ae,hr(r(this,Ae),1,6,d));const p=r(this,it).colors??s.seriesColors,b=g.mode==="outside"?C(this,rt,ia).call(this,a,g,f,l):0,{cx:v,cy:S,maxR:L}=wr({bitmapWidth:o.width,bitmapHeight:o.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:b}),y=L,M=y*r(this,it).innerRadiusRatio,k=r(this,it).padAngle*xn,F=8*l,T=r(this,it).shadow??!1,D=Ol(T),B=r(this,it).innerShadow??!1,x=Xl(B);let R=-Math.PI/2;for(let V=0;V<r(this,tt).length;V++){const X=r(this,tt)[V],$=C(this,rt,ke).call(this,X.value)/f*Ti,G=R+k/2,xt=R+$-k/2,Tt=R+$/2,_=X.color??p[V%p.length];if(xt<=G){R+=$;continue}const q=r(this,Mt)[V]*F,J=Math.cos(Tt)*q,K=Math.sin(Tt)*q,Et=v+J,kt=S+K;a.beginPath(),a.arc(Et,kt,y,G,xt),M>0?a.arc(Et,kt,M,xt,G,!0):a.lineTo(Et,kt),a.closePath();const Lt=a.createRadialGradient(Et,kt,M||0,Et,kt,y);if(Lt.addColorStop(0,Ul(_,.15)),B){const re=Math.max(0,Math.min(.999,1-x.depth));Lt.addColorStop(re,_),Lt.addColorStop(1,_l(_,x.color))}else Lt.addColorStop(1,_);a.fillStyle=Lt;const Ie=r(this,Mt)[V];if(T||Ie>.01){const re=T?1:0,Ne=Ie;a.shadowColor=T?D.color:"rgba(0,0,0,0.25)",a.shadowBlur=(D.blur*re+12*Ne)*l,a.shadowOffsetX=D.offsetX*re*l+J*.3*Ne,a.shadowOffsetY=D.offsetY*re*h+K*.3*Ne}a.fill(),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0,R+=$}if(g.mode==="none")return;R=-Math.PI/2;const A=s.tooltip.textColor;if(g.mode==="outside"){const V=C(this,rt,na).call(this,{cx:v,cy:S,outerR:y,total:f,palette:p,labels:g,hpr:l,bitmapHeight:o.height}),X=V.length>1?Math.min(.06,.9/(V.length-1)):0;for(let $=0;$<V.length;$++){const G=V[$];if(G===null)continue;const xt=$*X,Tt=hs((r(this,Ae)-xt)/(1-xt),0,1);C(this,rt,sa).call(this,{context:a,entry:G,textColor:A,labels:g,hpr:l,progress:Tt})}return}const z=M>0?(y+M)/2:y*.65;a.textAlign="center",a.textBaseline="middle";const E=g.minSliceAngle*xn;for(let V=0;V<r(this,tt).length;V++){const X=r(this,tt)[V],$=C(this,rt,ke).call(this,X.value)/f*Ti;if($>=E){const G=R+$/2,xt=r(this,Mt)[V]*F,Tt=X.color??p[V%p.length],_=C(this,rt,zs).call(this,X,f,g.content),q=a.measureText(_).width,J=g.fontSize*1.2*l,K=$<Math.PI?2*z*Math.sin($/2):2*z,Et=q>K-4*l,kt=M>0&&z-M<J;if(!Et&&!kt){const Lt=v+Math.cos(G)*(z+xt),Ie=S+Math.sin(G)*(z+xt);a.fillStyle=Nl(Tt)?"#000000":"#ffffff",a.fillText(_,Lt,Ie)}}R+=$}}}tt=new WeakMap,it=new WeakMap,Kt=new WeakMap,Mt=new WeakMap,xi=new WeakMap,Ae=new WeakMap,$t=new WeakMap,Ge=new WeakMap,rt=new WeakSet,wn=function(i,t){const e={...i,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=Hl(i.sliceLabels,t.sliceLabels)),e},ke=function(i){return Number.isFinite(i)&&i>0?i:0},Ui=function(){let i=0;for(const t of r(this,tt))i+=C(this,rt,ke).call(this,t.value);return i},zs=function(i,t,e){const s=t>0?C(this,rt,ke).call(this,i.value)/t*100:0,n=`${s.toFixed(s>=10?0:1)}%`;return e==="percent"?n:e==="label"?i.label:`${i.label} ${n}`},ia=function(i,t,e,s){const n=i.font;if(r(this,$t)&&r(this,$t).fontScale===s&&r(this,$t).font===n)return r(this,$t).reserve;let a=0;for(const h of r(this,tt)){const c=C(this,rt,zs).call(this,h,e,t.content),d=i.measureText(c).width;d>a&&(a=d)}const o=Math.max(t.distance,t.elbowLen),l=(a+(o+Math.max(0,t.railWidth)+t.legPad+4)*s)/ea;return u(this,$t,{fontScale:s,font:n,reserve:l}),l},sa=function(i){const{context:t,entry:e,textColor:s,labels:n,hpr:a,progress:o}=i;if(o<=0)return;const{anchorX:l,anchorY:h,elbowX:c,elbowY:d,side:f,text:m,color:g,labelX:p,labelY:b}=e,v=p+f*n.legPad*a,S=hs(o/.15,0,1),L=hs((o-.15)/.45,0,1),y=hs((o-.6)/.4,0,1);if(t.save(),t.globalAlpha=S,t.fillStyle=g,t.beginPath(),t.arc(l,h,2.5*a,0,Ti),t.fill(),t.restore(),L>0){t.save(),t.globalAlpha=L,t.strokeStyle=g,t.lineWidth=1*a,t.lineCap="round",t.beginPath(),t.moveTo(l,h);const M=l+(c-l)*L,k=h+(d-h)*L;if(t.lineTo(M,k),y>0){const F=c+(p-c)*y,T=d+(b-d)*y;t.lineTo(F,T)}t.stroke(),t.restore()}y>0&&(t.save(),t.globalAlpha=y,t.fillStyle=s,t.textAlign=f>=0?"left":"right",t.textBaseline="middle",t.fillText(m,v,b),t.restore())},na=function(i){const{cx:t,cy:e,outerR:s,total:n,palette:a,labels:o,hpr:l,bitmapHeight:h}=i,c=new Array(r(this,tt).length).fill(null),d=o.elbowLen*l,f=Math.max(o.distance,o.elbowLen)*l,m=Math.max(0,o.railWidth)*l,g=[];let p=-Math.PI/2;const b=o.minSliceAngle*xn;for(let y=0;y<r(this,tt).length;y++){const M=r(this,tt)[y],k=C(this,rt,ke).call(this,M.value)/n*Ti;if(k>=b){const F=p+k/2,T=r(this,Mt)[y]*(8*l),D=Math.cos(F),B=Math.sin(F),x=D>=0?1:-1,R=t+D*(s+T),A=e+B*(s+T),z=t+D*(s+T+d),E=e+B*(s+T+d),V=t+D*(s+T+f)+x*m,X=e+B*(s+T+f),$={anchorX:R,anchorY:A,elbowX:z,elbowY:E,side:x,labelX:V,labelY:X,text:C(this,rt,zs).call(this,M,n,o.content),color:M.color??a[y%a.length]};c[y]=$,g.push({entry:$})}p+=k}const v=Math.max(1,o.fontSize*o.labelGap)*l,S=o.fontSize*l,L=h-o.fontSize*l;for(const y of[1,-1]){const M=[];for(const T of g)T.entry.side===y&&M.push(T.entry);if(M.length===0)continue;M.sort((T,D)=>T.labelY-D.labelY);const k=[];for(let T=0;T<M.length;T++)for(k.push({count:1,sumIdeal:M[T].labelY,startIdx:T});k.length>=2;){const D=k[k.length-2],B=k[k.length-1],x=D.sumIdeal/D.count,R=B.sumIdeal/B.count,A=x+(D.count-1)*v/2;if(R-(B.count-1)*v/2>=A+v)break;D.count+=B.count,D.sumIdeal+=B.sumIdeal,k.pop()}if(k.length>0){const T=k[0],D=T.sumIdeal/T.count-(T.count-1)*v/2;if(D<S)for(T.sumIdeal+=(S-D)*T.count;k.length>=2;){const B=k[0],x=k[1],R=B.sumIdeal/B.count,A=x.sumIdeal/x.count,z=R+(B.count-1)*v/2;if(A-(x.count-1)*v/2>=z+v)break;B.count+=x.count,B.sumIdeal+=x.sumIdeal,k.splice(1,1)}}if(k.length>0){const T=k[k.length-1],D=T.sumIdeal/T.count+(T.count-1)*v/2;if(D>L)for(T.sumIdeal-=(D-L)*T.count;k.length>=2;){const B=k[k.length-2],x=k[k.length-1],R=B.sumIdeal/B.count,A=x.sumIdeal/x.count,z=R+(B.count-1)*v/2;if(A-(x.count-1)*v/2>=z+v)break;B.count+=x.count,B.sumIdeal+=x.sumIdeal,k.pop()}}const F=(S+L)/2;for(const T of k){const D=(T.count-1)*v,B=T.sumIdeal/T.count;D>L-S&&B-D/2<S&&(T.sumIdeal=F*T.count)}for(const T of k){const D=T.sumIdeal/T.count;for(let B=0;B<T.count;B++)M[T.startIdx+B].labelY=D+(B-(T.count-1)/2)*v}}for(const y of g){const M=y.entry,k=M.labelY-M.anchorY;let F;if(Math.abs(k)<=d){const B=M.side*Math.sqrt(Math.max(0,d*d-k*k));F=M.anchorX+B}else F=(M.anchorX+M.labelX)/2;const T=Math.min(M.anchorX,M.labelX),D=Math.max(M.anchorX,M.labelX);M.elbowX=Math.max(T,Math.min(D,F)),M.elbowY=M.labelY}return c};function ps(i){if(!i.startsWith("#")||i.length!==4)return i;const t=i[1],e=i[2],s=i[3];return`#${t}${t}${e}${e}${s}${s}`}function ra(i){const t=ps(i);return!t.startsWith("#")||t.length<7?!1:parseInt(t.slice(1,3),16)*.299+parseInt(t.slice(3,5),16)*.587+parseInt(t.slice(5,7),16)*.114<128}function at(i){var t,e,s,n,a,o,l,h,c,d,f,m,g,p,b,v,S,L,y,M,k,F,T,D,B,x,R,A,z,E,V,X,$,G;const{name:xt="Custom",description:Tt,fontUrl:_=null}=i,q=ps(i.background),J=ra(q),K=J?"#d1d4dc":"#24292f",Et=J?"#787b86":"#8b949e",kt=J?"#26a69a":"#2da44e",Lt=J?"#ef5350":"#cf222e",Ie=J?"#2962ff":"#0969da",re=J?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",Ne=J?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",xs=J?_i(q,.1):Mn(q,.05),ws=J?wi(q,.92):wi(q,.95),Ms=J?wi(_i(q,.15),.6):"rgba(200,200,200,0.5)",ks=Js,oi=((e=(t=i.candlestick)==null?void 0:t.up)==null?void 0:e.body)??kt,li=((n=(s=i.candlestick)==null?void 0:s.down)==null?void 0:n.body)??Lt,hi=Dt(oi),st=Dt(li),yt=((a=i.line)==null?void 0:a.color)??Ie,It=((o=i.tooltip)==null?void 0:o.textColor)??K,Kn=((l=i.axis)==null?void 0:l.textColor)??Et,Ha=((h=i.typography)==null?void 0:h.fontFamily)??ks,Zn=((c=i.typography)==null?void 0:c.fontSize)??12,$a=i.chartGradient??(J?[_i(q,.04),Mn(q,.06)]:[_i(q,.06),q]),Oa={background:q,chartGradient:$a,typography:{fontFamily:Ha,fontSize:Zn},grid:{color:((d=i.grid)==null?void 0:d.color)??re,style:((f=i.grid)==null?void 0:f.style)??"solid"},candlestick:{up:{body:oi,wick:((g=(m=i.candlestick)==null?void 0:m.up)==null?void 0:g.wick)??hi},down:{body:li,wick:((b=(p=i.candlestick)==null?void 0:p.down)==null?void 0:b.wick)??st}},line:{color:yt,width:((v=i.line)==null?void 0:v.width)??1,areaTopColor:((S=i.line)==null?void 0:S.areaTopColor)??wi(yt,.08),areaBottomColor:((L=i.line)==null?void 0:L.areaBottomColor)??wi(yt,.01)},seriesColors:i.seriesColors??[yt,kt,Lt],bands:{upper:((y=i.bands)==null?void 0:y.upper)??yt,lower:((M=i.bands)==null?void 0:M.lower)??st},crosshair:{color:((k=i.crosshair)==null?void 0:k.color)??Ne,labelBackground:((F=i.crosshair)==null?void 0:F.labelBackground)??xs,labelTextColor:((T=i.crosshair)==null?void 0:T.labelTextColor)??It},axis:{fontSize:((D=i.axis)==null?void 0:D.fontSize)??10,textColor:Kn,...(B=i.axis)!=null&&B.x?{x:{...i.axis.x}}:{},...(x=i.axis)!=null&&x.y?{y:{...i.axis.y}}:{}},yLabel:{fontSize:((R=i.yLabel)==null?void 0:R.fontSize)??11,upBackground:((A=i.yLabel)==null?void 0:A.upBackground)??hi,downBackground:((z=i.yLabel)==null?void 0:z.downBackground)??st,neutralBackground:((E=i.yLabel)==null?void 0:E.neutralBackground)??xs,textColor:((V=i.yLabel)==null?void 0:V.textColor)??"#ffffff"},tooltip:{fontSize:((X=i.tooltip)==null?void 0:X.fontSize)??Zn,background:(($=i.tooltip)==null?void 0:$.background)??ws,textColor:It,borderColor:((G=i.tooltip)==null?void 0:G.borderColor)??Ms},navigator:Kl({dark:J,bg:q,neutralFg:Kn,upBody:oi,downBody:li,upBase:hi,downBase:st,config:i.navigator})};return{name:xt,description:Tt,fontUrl:_,dark:J,theme:Oa}}function Kl(i){var t,e,s,n,a,o,l,h,c,d,f,m,g,p,b,v,S,L;const{dark:y,bg:M,neutralFg:k,upBody:F,downBody:T,upBase:D,downBase:B,config:x}=i,R=(x==null?void 0:x.background)??"transparent",A=y?"rgba(255,255,255,1)":"rgba(0,0,0,1)",z=((t=x==null?void 0:x.handle)==null?void 0:t.color)??Bi(A,.3),E=((e=x==null?void 0:x.mask)==null?void 0:e.fill)??Bi(M,y?.78:.82);return{height:(x==null?void 0:x.height)??48,background:R,borderColor:(x==null?void 0:x.borderColor)??Bi(k,y?.18:.22),line:{color:((s=x==null?void 0:x.line)==null?void 0:s.color)??k,width:((n=x==null?void 0:x.line)==null?void 0:n.width)??1,areaTopColor:((a=x==null?void 0:x.line)==null?void 0:a.areaTopColor)??Bi(k,y?.22:.18),areaBottomColor:((o=x==null?void 0:x.line)==null?void 0:o.areaBottomColor)??Bi(k,0)},candlestick:{up:{body:((h=(l=x==null?void 0:x.candlestick)==null?void 0:l.up)==null?void 0:h.body)??F,wick:((d=(c=x==null?void 0:x.candlestick)==null?void 0:c.up)==null?void 0:d.wick)??D},down:{body:((m=(f=x==null?void 0:x.candlestick)==null?void 0:f.down)==null?void 0:m.body)??T,wick:((p=(g=x==null?void 0:x.candlestick)==null?void 0:g.down)==null?void 0:p.wick)??B}},window:{fill:((b=x==null?void 0:x.window)==null?void 0:b.fill)??"transparent",border:((v=x==null?void 0:x.window)==null?void 0:v.border)??"transparent",borderWidth:((S=x==null?void 0:x.window)==null?void 0:S.borderWidth)??0},handle:{color:z,width:((L=x==null?void 0:x.handle)==null?void 0:L.width)??6},mask:{fill:E}}}function Bi(i,t){if(i.startsWith("#")&&i.length===7)return wi(i,t);const e=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:i}function wi(i,t){const e=ps(i),s=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${s}, ${n}, ${a}, ${t})`}function _i(i,t){if(!i.startsWith("#"))return i;const e=ps(i),s=Math.min(255,Math.round(parseInt(e.slice(1,3),16)+255*t)),n=Math.min(255,Math.round(parseInt(e.slice(3,5),16)+255*t)),a=Math.min(255,Math.round(parseInt(e.slice(5,7),16)+255*t));return`#${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function Mn(i,t){if(!i.startsWith("#"))return i;const e=ps(i),s=Math.max(0,Math.round(parseInt(e.slice(1,3),16)*(1-t))),n=Math.max(0,Math.round(parseInt(e.slice(3,5),16)*(1-t))),a=Math.max(0,Math.round(parseInt(e.slice(5,7),16)*(1-t)));return`#${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function j(i){const t=i.startsWith("#")&&i.length===7?[_i(i,.2),Mn(i,.15)]:[i,i];return Object.defineProperty(t,"source",{value:i,enumerable:!1}),t}const Zs="'JetBrains Mono', 'Fira Code', monospace",qs="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Js="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Hn="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",aa="'Roboto Mono', monospace",oa="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Zl="'IBM Plex Mono', monospace",ql="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",$n="'Fira Code', monospace",On="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",la="'Source Code Pro', monospace",ha="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",Jl="'Space Mono', monospace",Ql="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",Xn="'Plus Jakarta Sans', sans-serif",Nn="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",th="'Caveat', 'Comic Sans MS', cursive",eh="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",ca=at({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(90,92,116,0.2)"},candlestick:{up:{body:j("#a6e3a1"),wick:"#a6e3a1"},down:{body:j("#f38ba8"),wick:"#f38ba8"}},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.7)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:Js},fontUrl:Hn});let ih=0;var ct,nt,jt,Gi,O,dt,Ki,ut,St,ft,Pe,Mi,Zt,Es,Vs,ge,Zi,Ke,cs,Os,Rt,Q,ni,Xs,ie,et,Wi,Se,Ns,mt,Li,Ft,bt,ki,fe,qi,Ji,Y,Fe,ua,da,fa,ma,Qi,Ct,ii,Ii,us,ds,kn,ga,Ai,ts,pa,cn,ri,Sn,Cn,Ot;class ba extends Ks{constructor(t,e){var s,n,a,o,l,h;super(),w(this,Y),w(this,ct),w(this,nt),w(this,jt),P(this,"timeScale"),P(this,"yScale"),w(this,Gi),w(this,O,[]),w(this,dt),w(this,Ki),w(this,ut,6e4),w(this,St,null),w(this,ft,{}),w(this,Pe,null),w(this,Mi,{}),w(this,Zt,{left:"idle",right:"idle"}),w(this,Es,{left:null,right:null}),w(this,Vs),w(this,ge,0),w(this,Zi,!1),w(this,Ke,!1),w(this,cs,!1),w(this,Os,0),w(this,Rt),w(this,Q),w(this,ni),w(this,Xs,!1),w(this,ie,null),w(this,et,null),w(this,Wi,null),w(this,Se,!1),w(this,Ns),w(this,mt,{from:0,to:0}),w(this,Li,{min:0,max:0}),w(this,Ft,!0),w(this,bt),w(this,ki,0),w(this,fe),w(this,qi,!1),w(this,Ji,null),w(this,Qi,!1),w(this,Ct,!1),w(this,ii,!1),w(this,Ii),w(this,us,Number.NaN),w(this,ds,Number.NaN),e!=null&&e.axis&&(u(this,Mi,e.axis),u(this,ft,{min:(s=e.axis.y)==null?void 0:s.min,max:(n=e.axis.y)==null?void 0:n.max})),u(this,dt,(e==null?void 0:e.theme)??ca.theme),u(this,Ki,((a=e==null?void 0:e.grid)==null?void 0:a.visible)!==!1),u(this,Rt,$s.resolve(e==null?void 0:e.animations)),u(this,Ns,Oo((o=e==null?void 0:e.viewport)==null?void 0:o.maxVisibleBars)),u(this,bt,rr(e==null?void 0:e.padding)),u(this,ni,new _o);const c=r(this,Rt).axis.y,d=r(this,Rt).axis.x;u(this,Q,Qa({initial:{yRange:{min:0,max:0},xRange:{from:0,to:0}},y:{curve:c.curve,settleMs:c.settleMs,stickyMs:c.stickyMs,stickyFloorMs:c.stickyFloorMs,gestureMs:c.gestureMs,toggleMs:r(this,Rt).toggleMs},x:{curve:d.curve,settleMs:d.settleMs,gestureMs:d.gestureMs},computeXTarget:()=>C(this,Y,ga).call(this),computeYTarget:({xTarget:b})=>C(this,Y,kn).call(this,b),onWake:()=>{var b;return(b=r(this,nt))==null?void 0:b.markDirty()}})),u(this,Vs,e==null?void 0:e.onEdgeReached),u(this,Ii,(l=e==null?void 0:e.viewport)==null?void 0:l.initialRange);const f=$o(e==null?void 0:e.perf);u(this,fe,f.monitor),u(this,qi,f.ownsMonitor),u(this,ct,new po(t,r(this,fe)??void 0)),this.timeScale=new Kr,this.yScale=new Jr;const m=r(this,Rt).axis.ticksMs;this.timeScale.tickTracker.setFadeMs(m),this.yScale.tickTracker.setFadeMs(m);const g=r(this,fe);g?(u(this,nt,new Ts(b=>{g.resetDrawCalls("main");const v=performance.now();this.renderMain(b),g.recordFrame("main",performance.now()-v,b)})),u(this,jt,new Ts(b=>{g.resetDrawCalls("overlay");const v=performance.now();this.renderOverlay(b),g.recordFrame("overlay",performance.now()-v,b)})),f.showHud&&u(this,Ji,new hl(t,g))):(u(this,nt,new Ts(b=>this.renderMain(b))),u(this,jt,new Ts(b=>this.renderOverlay(b))));const p=(e==null?void 0:e.interactive)!==!1;u(this,Gi,p?new sl(r(this,ct).canvas,this,this.timeScale,this.yScale):null),r(this,ct).on("resize",()=>{this.syncScales(),this.renderMain(),this.emit("viewportChange")}),this.syncScales(),(h=r(this,Gi))==null||h.on("crosshairMove",b=>{u(this,St,b),r(this,jt).markDirty(),this.emit("crosshairMove",b),C(this,Y,ma).call(this,b)})}get yAxisWidth(){const t=r(this,Mi).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=r(this,Mi).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return r(this,Os)}addSeries(t,e={}){var s;const{layers:n,id:a,...o}=e,l=n??1,h={...r(this,Rt).defaults(t),...o,...r(this,Rt).overrides(t)},c=C(this,Y,da).call(this,t,l,h),d=C(this,Y,ua).call(this,a);return(s=c.onDataChanged)==null||s.call(c,()=>this.onDataChanged()),r(this,O).push({id:d,label:o.label,renderer:c,visible:!0}),u(this,Pe,null),this.emit("seriesChange"),C(this,Y,Fe).call(this),d}removeSeries(t){const e=r(this,O).findIndex(s=>s.id===t);e>=0&&(r(this,O)[e].renderer.dispose(),r(this,O).splice(e,1),u(this,Pe,null),r(this,nt).markDirty(),this.emit("seriesChange"),C(this,Y,Fe).call(this))}getAnimationState(){return r(this,Q).getAnimationState()}setSeriesData(t,e,s){const n=r(this,O).find(a=>a.id===t);n&&(u(this,Qi,!0),n.renderer.setData(e,s))}appendData(t,e,s){const n=r(this,O).find(a=>a.id===t);n===void 0||n.renderer.appendPoint===void 0||n.renderer.appendPoint(e,s)}updateData(t,e,s){var n,a;const o=r(this,O).find(l=>l.id===t);(a=o==null?void 0:(n=o.renderer).updateLastPoint)==null||a.call(n,e,s)}keepLast(t,e,s){var n,a;const o=r(this,O).find(l=>l.id===t);(a=o==null?void 0:(n=o.renderer).keepLast)==null||a.call(n,e,s)}updateSeriesOptions(t,e){const s=r(this,O).find(d=>d.id===t);if(!s)return;const n=s.label,a=s.renderer.getLayerColors().slice(),o=r(this,Rt).overrides(s.renderer.kind);s.renderer.updateOptions({...e,...o}),"label"in e&&typeof e.label=="string"&&(s.label=e.label),r(this,nt).markDirty();const l=s.renderer.getLayerColors(),h=a.length!==l.length||a.some((d,f)=>d!==l[f]),c=n!==s.label;(h||c)&&C(this,Y,Fe).call(this)}batch(t){fn(this,ge)._++;try{t()}finally{if(--fn(this,ge)._<=0){if(u(this,ge,0),r(this,Zi))u(this,Zi,!1),u(this,Ke,!1),this.onDataChanged();else if(r(this,Ke)){u(this,Ke,!1),u(this,Ct,!0);const e=performance.now();r(this,Q).onAxisReconfig(e),C(this,Y,Ot).call(this,e),r(this,nt).markDirty()}r(this,cs)&&(u(this,cs,!1),this.emit("overlayChange"))}}}setSeriesVisible(t,e){var s,n;const a=r(this,O).find(h=>h.id===t);if(!a||a.visible===e)return;a.visible=e,C(this,Y,Fe).call(this);const o=r(this,Rt).toggleMs;if((n=(s=a.renderer).setAlpha)==null||n.call(s,e?1:0,o),r(this,nt).markDirty(),r(this,ge)>0){u(this,Ke,!0);return}u(this,Ct,!0);const l=performance.now();r(this,Q).onSeriesVisibilityChanged(l),C(this,Y,Ot).call(this,l)}getAutoScroll(){return r(this,Ft)}isSeriesVisible(t){var e;return((e=r(this,O).find(s=>s.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,s){var n,a;const o=r(this,O).find(c=>c.id===t);if(!o||o.renderer.getLayerCount()<=1||o.renderer.isLayerVisible(e)===s)return;o.renderer.setLayerVisible(e,s),C(this,Y,Fe).call(this);const l=r(this,Rt).toggleMs;if((a=(n=o.renderer).setLayerAlpha)==null||a.call(n,e,s?1:0,l),r(this,nt).markDirty(),r(this,ge)>0){u(this,Ke,!0);return}u(this,Ct,!0);const h=performance.now();r(this,Q).onSeriesVisibilityChanged(h),C(this,Y,Ot).call(this,h)}isLayerVisible(t,e){const s=r(this,O).find(n=>n.id===t);return(s==null?void 0:s.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const s=r(this,ct).size.media.width-this.yAxisWidth;C(this,Y,Ai).call(this,t,e,s),C(this,Y,ts).call(this,{xEase:!0})}getVisibleRange(){return r(this,mt).from===0&&r(this,mt).to===0?r(this,Q).getAnimationState().xRange:r(this,mt)}getDataRange(){return r(this,ie)===null||r(this,et)===null?null:{from:r(this,ie),to:r(this,et)}}setVisibleRange(t,e){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:o,last:l}=this.getDataBounds();if(o===void 0||l===void 0)return;const h=Math.max(o,l-(t-1)*r(this,ut)),c=r(this,ct).size.media.width-this.yAxisWidth;C(this,Y,Ai).call(this,h,l,c),C(this,Y,ts).call(this);return}if("bars"in t){if(!Number.isInteger(t.bars)||t.bars<2)return;const o=zt(t.from),l=o+t.bars*r(this,ut);u(this,Ft,r(this,et)!==null&&r(this,et)>=o&&r(this,et)<=l),C(this,Y,ri).call(this,{from:o,to:l},{emitChange:!0}),u(this,Se,!0),C(this,Y,ts).call(this);return}const s=zt(t.from),n=zt(t.to);u(this,Ft,r(this,et)!==null&&r(this,et)>=s&&r(this,et)<=n),u(this,Se,!1);const a=C(this,Y,ri).call(this,{from:s,to:n},{emitChange:!0});if(e!=null&&e.gesture){a&&C(this,Y,pa).call(this);return}C(this,Y,ts).call(this)}getYRange(){return r(this,Li)}getCrosshairPosition(){return r(this,St)}setCrosshair(t){if(t===null){if(r(this,St)===null)return;u(this,St,null),r(this,jt).markDirty(),this.emit("crosshairMove",null);return}const{time:e}=t;if(!Number.isFinite(e))return;const s=r(this,St);let n;if(t.y!==void 0)n=t.y;else if(s!==null)n=s.y;else{const l=r(this,Li);n=(l.min+l.max)/2}if(!Number.isFinite(n)||s!==null&&s.time===e&&s.y===n)return;const a=this.timeScale.timeToX(e),o=this.yScale.valueToY(n);u(this,St,{mediaX:a,mediaY:o,time:e,y:n}),r(this,jt).markDirty(),this.emit("crosshairMove",r(this,St))}getLastValue(t){return Nr(t,r(this,O),r(this,Q).getAnimationState().xRange)}getPreviousClose(t){return Wo(t,r(this,O))}getLastData(t){const e=r(this,O).find(s=>s.id===t);return!e||e.renderer.kind==="pie"?null:e.renderer.getLastDataPoint()}getDataAtTime(t,e){var s,n;const a=r(this,O).find(o=>o.id===t);return a?((n=(s=a.renderer).getDataAtTime)==null?void 0:n.call(s,e,r(this,ut)))??null:null}getLayerSnapshots(t,e){var s,n;const a=r(this,O).find(o=>o.id===t);return a!=null&&a.visible?((n=(s=a.renderer).getLayerSnapshots)==null?void 0:n.call(s,e,r(this,ut)))??null:null}getSeriesIds(){return r(this,Pe)||u(this,Pe,r(this,O).map(t=>t.id)),r(this,Pe).slice()}getSeriesIdsByType(t,e){const s=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,a=[];for(const o of r(this,O)){const l=o.renderer.kind==="pie";if(t==="pie"&&!l||t==="time"&&l)continue;const h=o.renderer.getLayerCount();if(!(n&&h>1)){if(s){if(!o.visible)continue;if(h>1){let c=!1;for(let d=0;d<h;d++)if(o.renderer.isLayerVisible(d)){c=!0;break}if(!c)continue}}a.push(o.id)}}return a}getStackedLastValue(t){return Ro(t,r(this,O),r(this,Q).getAnimationState().xRange)}getLayerLastSnapshots(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:s.call(e))??null}listSeriesForTest(){return r(this,O).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=r(this,O).find(s=>s.id===t);return e?e.renderer.getLayerColors()[0]??r(this,dt).line.color:null}getSeriesLabel(t){var e;return(e=r(this,O).find(s=>s.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=r(this,O).find(a=>a.id===t);if(!e)return null;const s=e.renderer.getLayerCount();if(s<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:s},(a,o)=>({color:n[o%n.length]}))}getSliceInfo(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:s.call(e,r(this,dt)))??null}getHoverInfo(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:s.call(e,r(this,dt)))??null}setTheme(t){const e=r(this,dt);u(this,dt,t);for(const s of r(this,O))s.renderer.applyTheme(t,e);r(this,nt).markDirty(),C(this,Y,Fe).call(this)}getTheme(){return r(this,dt)}setAxis(t){var e,s;const n=this.yAxisWidth,a=this.xAxisHeight;u(this,Mi,t),u(this,ft,{min:(e=t.y)==null?void 0:e.min,max:(s=t.y)==null?void 0:s.max}),u(this,Ct,!0);const o=performance.now();r(this,Q).onAxisReconfig(o),C(this,Y,Ot).call(this,o),(this.yAxisWidth!==n||this.xAxisHeight!==a)&&this.syncScales(),r(this,nt).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),r(this,nt).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),r(this,nt).markDirty())}getMediaSize(){return r(this,ct).size.media}getLayout(){const t=r(this,ct).size.media,e=this.yAxisWidth,s=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-s},yAxisWidth:e,xAxisHeight:s}}getDataInterval(){return r(this,ut)}setPadding(t){const e=r(this,bt);u(this,bt,rr(t));const s=r(this,bt),n=!ar(e.left,s.left)||!ar(e.right,s.right),a=e.top!==s.top||e.bottom!==s.bottom;if(n){const{first:o,last:l}=this.getDataBounds();if(o!==void 0&&l!==void 0){const h=r(this,ct).size.media.width-this.yAxisWidth;C(this,Y,Ai).call(this,o,l,h)}}if(n||a){u(this,Ct,!0);const o=performance.now();r(this,Q).onAxisReconfig(o),C(this,Y,Ot).call(this,o)}this.syncScales(),r(this,nt).markDirty(),a&&this.emit("viewportChange")}setGrid(t){u(this,Ki,t.visible),r(this,nt).markDirty()}setEdgeState(t,e){r(this,Zt)[t]!==e&&(r(this,Zt)[t]=e,r(this,jt).markDirty())}getEdgeState(t){return r(this,Zt)[t]}setYLabel(t){}destroy(){var t,e,s;for(const n of r(this,O))n.renderer.dispose();u(this,O,[]),u(this,Pe,null),r(this,nt).destroy(),r(this,jt).destroy(),(t=r(this,Gi))==null||t.destroy(),r(this,ct).destroy(),(e=r(this,Ji))==null||e.destroy(),u(this,Ji,null),r(this,qi)&&((s=r(this,fe))==null||s.destroy()),u(this,fe,null),u(this,qi,!1),this.removeAllListeners()}getPerfMonitor(){return r(this,fe)}getDataBounds(){let t,e;for(const s of r(this,O)){if(!s.visible||s.renderer.kind==="pie")continue;const n=s.renderer.getTimeBounds();n!==null&&((t===void 0||n.first<t)&&(t=n.first),(e===void 0||n.last>e)&&(e=n.last))}return{first:t,last:e}}onDataChanged(){if(r(this,ge)>0){u(this,Zi,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&u(this,ie,t),e!==void 0&&(u(this,Wi,r(this,et)),u(this,et,e));const s=r(this,Qi);u(this,Qi,!1);const n=!r(this,Ct)&&t!==void 0;s&&(this.yScale.tickTracker.reset(),this.timeScale.tickTracker.reset()),u(this,Xs,s);const a=performance.now();s||n?r(this,Q).onDataReplaced(a):r(this,Q).onPointAppended(a),r(this,Q).lastXTarget!==null&&u(this,ii,!0),t!==void 0&&u(this,Ct,!0),C(this,Y,Ot).call(this,a),this.syncScales(),n?this.renderMain():r(this,nt).markDirty(),this.emit("dataUpdate"),C(this,Y,Fe).call(this)}updateDataInterval(){for(const t of r(this,O)){if(t.renderer.kind==="pie")continue;const e=t.renderer.sampleTimes(20);if(e.length>=2){u(this,ut,Yr(e));break}}}pan(t,e=r(this,ki)){var s;e>0&&u(this,ki,e),u(this,Se,!1);const n=jo({currentLogical:r(this,mt),timeDelta:t,chartWidth:e,dataInterval:r(this,ut),padding:{left:r(this,bt).left,right:r(this,bt).right},dataStart:r(this,ie),dataEnd:r(this,et)});n.newLogical!==null&&(u(this,Ft,!n.autoScrollOff),C(this,Y,ri).call(this,n.newLogical,{emitChange:!0}),n.edgeReached!==null&&(r(this,Es)[n.edgeReached.side]=n.edgeReached.boundaryTime,(s=r(this,Vs))==null||s.call(this,n.edgeReached)),r(this,ni).pause(),C(this,Y,Cn).call(this))}zoomAt(t,e,s=r(this,ki)){s>0&&u(this,ki,s),u(this,Se,!1);const n=Ho({currentLogical:r(this,mt),centerTime:t,factor:e,chartWidth:s,dataInterval:r(this,ut),padding:{left:r(this,bt).left,right:r(this,bt).right},dataStart:r(this,ie),dataEnd:r(this,et)});if(n.newLogical===null)return;let a=n.newLogical;if(r(this,Ft)&&r(this,et)!==null){const o=a.to-a.from,l=Oe(r(this,bt).right,o,r(this,ut),s),h=r(this,et)+l;a={from:h-o,to:h},u(this,Wi,r(this,et))}C(this,Y,ri).call(this,a,{emitChange:!0}),r(this,ni).pause(),C(this,Y,Cn).call(this)}syncScales(){const t=r(this,ct).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,s=t.media.height-this.xAxisHeight;this.timeScale.update(r(this,Q).getAnimationState().xRange,e,t.horizontalPixelRatio,r(this,ut)),this.yScale.update(r(this,Li),s,t.verticalPixelRatio)}renderMain(t){const e=r(this,ct).size;if(e.media.width===0||e.media.height===0)return;const s=typeof t=="number"?t:performance.now(),n=r(this,Q).tick(s);n.animating&&r(this,nt).markDirty();const a=n.yRange.min,o=n.yRange.max,l=a!==r(this,us)||o!==r(this,ds);if(l){const m=r(this,ft).min!==void 0&&r(this,ft).min!=="auto",g=r(this,ft).max!==void 0&&r(this,ft).max!=="auto",p=e.media.height-this.xAxisHeight;C(this,Y,Sn).call(this,a,o,p,m,g),u(this,us,a),u(this,ds,o)}if(this.syncScales(),r(this,et)!==null&&!r(this,Ft)){const m=r(this,Q).lastXTarget??r(this,mt),g=m.to-m.from;if(g>0){const p=r(this,ct).size.media.width-this.yAxisWidth,b=Oe(r(this,bt).right,g,r(this,ut),p),v=r(this,ut)*.5;Math.abs(m.to-(r(this,et)+b))<v&&u(this,Ft,!0)}}l&&this.emit("viewportChange");let h=!1,c=!1;r(this,ct).useMainLayer(m=>{var g,p;const{context:b,bitmapSize:v}=m,S=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,L=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;b.clearRect(0,0,v.width,v.height),b.save(),b.beginPath(),b.rect(0,0,S,L),b.clip(),this.yScale.tickTracker.setCurrentTicks(this.yScale.niceTickValues()),this.timeScale.tickTracker.setCurrentTicks(this.timeScale.niceTickValues(r(this,ut)).ticks),this.yScale.tickTracker.tick(s),this.timeScale.tickTracker.tick(s);const y=this.yScale.tickTracker.snapshot(),M=this.timeScale.tickTracker.snapshot();h=y.isAnimating,c=M.isAnimating,(y.isAnimating||M.isAnimating||n.animating)&&this.emit("tickFrame"),r(this,Ki)&&Qo({scope:m,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,dt),yTicks:y,timeTicks:M});const k=r(this,bt),F={top:k.top,bottom:k.bottom},T=r(this,fe);for(const D of r(this,O)){const B=((p=(g=D.renderer).getAlpha)==null?void 0:p.call(g))??(D.visible?1:0);if(B<=0)continue;const x={scope:m,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,dt),dataInterval:r(this,ut),padding:F,state:n,seriesId:D.id},R=b.globalAlpha;if(B<1&&(b.globalAlpha=R*B),T){const A=performance.now();D.renderer.render(x),T.recordSeries(D.id,performance.now()-A,s)}else D.renderer.render(x);B<1&&(b.globalAlpha=R)}b.restore()});let d=!1;for(const m of r(this,O))if(m.renderer.needsAnimation){d=!0,r(this,nt).markDirty();break}const f=h||c;!n.animating&&!d&&!f&&(this.yScale.tickTracker.markArmed(),this.timeScale.tickTracker.markArmed()),this.renderOverlay()}renderOverlay(t){var e,s;const n=r(this,ct).size;if(n.media.width===0||n.media.height===0)return;let a=!1;for(const h of r(this,O))if(h.visible&&h.renderer.overlayNeedsAnimation){a=!0;break}const o=r(this,Zt).left==="loading"||r(this,Zt).right==="loading",l=r(this,Zt).left!=="idle"||r(this,Zt).right!=="idle";if(r(this,ct).useOverlayLayer(h=>{var c,d;if(!r(this,St)&&!a&&!l)return;const f=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,m=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,f,m),h.context.clip(),r(this,St)&&C(this,Y,fa).call(this)){const v=r(this,St).mediaX*n.horizontalPixelRatio,S=r(this,St).mediaY*n.verticalPixelRatio;Jo(h,v,S,r(this,dt))}const g=r(this,bt),p={top:g.top,bottom:g.bottom},b=r(this,Q).getAnimationState();for(const v of r(this,O))v.visible&&((d=(c=v.renderer).drawOverlay)==null||d.call(c,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,dt),dataInterval:r(this,ut),padding:p,crosshair:r(this,St),state:b,seriesId:v.id}));l&&To({scope:h,chartMediaHeight:n.media.height-this.xAxisHeight,timeScale:this.timeScale,theme:r(this,dt),edgeStates:r(this,Zt),resolveBoundary:v=>Lo(v,r(this,Es)[v],this.getDataBounds())}),h.context.restore()}),a){const{from:h,to:c}=this.timeScale.getRange();let d=!1;for(const f of r(this,O))if(!(!f.visible||!f.renderer.overlayNeedsAnimation)&&(((s=(e=f.renderer).hasOverlayContentInRange)==null?void 0:s.call(e,h,c))??!0)){d=!0;break}d&&r(this,jt).markDirty()}o&&r(this,jt).markDirty()}}ct=new WeakMap,nt=new WeakMap,jt=new WeakMap,Gi=new WeakMap,O=new WeakMap,dt=new WeakMap,Ki=new WeakMap,ut=new WeakMap,St=new WeakMap,ft=new WeakMap,Pe=new WeakMap,Mi=new WeakMap,Zt=new WeakMap,Es=new WeakMap,Vs=new WeakMap,ge=new WeakMap,Zi=new WeakMap,Ke=new WeakMap,cs=new WeakMap,Os=new WeakMap,Rt=new WeakMap,Q=new WeakMap,ni=new WeakMap,Xs=new WeakMap,ie=new WeakMap,et=new WeakMap,Wi=new WeakMap,Se=new WeakMap,Ns=new WeakMap,mt=new WeakMap,Li=new WeakMap,Ft=new WeakMap,bt=new WeakMap,ki=new WeakMap,fe=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Y=new WeakSet,Fe=function(){if(fn(this,Os)._++,r(this,ge)>0){u(this,cs,!0);return}this.emit("overlayChange")},ua=function(i){if(i&&!r(this,O).some(e=>e.id===i))return i;let t;do t=`series_${++ih}`;while(r(this,O).some(e=>e.id===t));return t},da=function(i,t,e){switch(i){case"candlestick":return new El(new Ur,{up:{...r(this,dt).candlestick.up},down:{...r(this,dt).candlestick.down},...e});case"line":return new Yl(t,{colors:t===1?[r(this,dt).line.color]:r(this,dt).seriesColors.slice(0,t),strokeWidth:r(this,dt).line.width,...e});case"bar":return new Ll(t,{colors:r(this,dt).seriesColors.slice(0,t),...e});case"pie":return new Gl({...e})}},fa=function(){for(const i of r(this,O))if(i.visible&&i.renderer.kind!=="pie")return!0;return!1},ma=function(i){const t=r(this,ct).size,e=r(this,bt),s={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const a of r(this,O)){if(!a.renderer.hitTest||!a.renderer.setHoverIndex)continue;let o=-1;if(i){const l=i.mediaX*t.horizontalPixelRatio,h=i.mediaY*t.verticalPixelRatio;o=a.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,s)}a.renderer.setHoverIndex(o)&&(n=!0)}n&&r(this,nt).markDirty()},Qi=new WeakMap,Ct=new WeakMap,ii=new WeakMap,Ii=new WeakMap,us=new WeakMap,ds=new WeakMap,kn=function(i){const t=i??r(this,mt),e=r(this,ft).min!==void 0&&r(this,ft).min!=="auto"&&typeof r(this,ft).min!="number"||r(this,ft).max!==void 0&&r(this,ft).max!=="auto"&&typeof r(this,ft).max!="number"?[]:null,s=qo(t,r(this,O),e);if(s===null)return u(this,Ct,!1),null;const n=lr(r(this,ft).min,s.min,s.max,e??[],"min"),a=lr(r(this,ft).max,s.max,s.min,e??[],"max");return{min:n,max:a}},ga=function(){if(r(this,ie)===null||r(this,et)===null)return null;const{from:i,to:t}=r(this,mt),e=i===0&&t===0,s=r(this,ct).size.media.width-this.yAxisWidth;if(e)return C(this,Y,Ai).call(this,r(this,ie),r(this,et),s),r(this,Ii)!==void 0&&(this.setVisibleRange(r(this,Ii)),u(this,Ii,void 0)),r(this,mt);if(!r(this,Ft))return null;if(r(this,Xs))return C(this,Y,Ai).call(this,r(this,ie),r(this,et),s),r(this,mt);const n=Zo({currentLogical:r(this,mt),lastTime:r(this,et),prevDataEnd:r(this,Wi),dataInterval:r(this,ut),paddingRight:r(this,bt).right,chartWidth:s,holdUntilFilled:r(this,Se)});return n.releaseHold&&u(this,Se,!1),n.reengageAutoScroll&&u(this,Ft,!0),n.newLogical===null?null:(r(this,ni).observe(performance.now()),r(this,Q).setXSettleMs(r(this,ni).pickSettleMs(r(this,Rt).axis.x.settleMs)),C(this,Y,ri).call(this,n.newLogical,{emitChange:!1,skipValidation:!0}),u(this,Wi,r(this,et)),n.newLogical)},Ai=function(i,t,e){const s=r(this,bt),n=Io({firstTime:i,lastTime:t,dataInterval:r(this,ut),maxVisibleBars:r(this,Ns),chartWidth:e,padding:{left:s.left,right:s.right}});u(this,Se,!1),u(this,Ft,!0),C(this,Y,ri).call(this,n,{emitChange:!0})},ts=function(i){const t=r(this,mt);if(t.to<=t.from)return;const e=performance.now();if(!r(this,ii)||!r(this,Ct)){C(this,Y,cn).call(this,e);return}r(this,Q).onProgrammaticZoom({xTarget:t,xEase:i==null?void 0:i.xEase},e),C(this,Y,Ot).call(this,e)},pa=function(){const i=r(this,mt);if(i.to<=i.from)return;const t=performance.now();if(!r(this,ii)||!r(this,Ct)){C(this,Y,cn).call(this,t);return}r(this,Q).onPanZoom({xTarget:i,yAuto:!0},t),C(this,Y,Ot).call(this,t)},cn=function(i){const t=r(this,mt),e=C(this,Y,kn).call(this,t);u(this,ii,!0),e!==null&&u(this,Ct,!0),r(this,Q).snap({x:t,y:e??void 0},i),C(this,Y,Ot).call(this,i)},ri=function(i,t){var e;const{from:s,to:n}=i;return!Number.isFinite(s)||!Number.isFinite(n)||n<=s||!t.skipValidation&&(n-s)/r(this,ut)<2||r(this,mt).from===s&&r(this,mt).to===n?!1:(u(this,mt,{from:s,to:n}),t.emitChange&&(this.syncScales(),(e=r(this,nt))==null||e.markDirty(),this.emit("viewportChange")),!0)},Sn=function(i,t,e,s,n){const a=t-i,o=e>0?r(this,bt).top/e*a:0,l=e>0?r(this,bt).bottom/e*a:0;u(this,Li,{min:s?i:i-l,max:n?t:t+o})},Cn=function(){const i=r(this,mt);if(i.to<=i.from)return;u(this,ii,!0),u(this,Ct,!0);const t=performance.now();r(this,Q).onPanZoom({xTarget:i,yAuto:!0},t),C(this,Y,Ot).call(this,t)},Ot=function(i){const t=r(this,Q).tick(i),e=r(this,ct).size;if(e.media.width===0||e.media.height===0)return;const s=r(this,ft).min!==void 0&&r(this,ft).min!=="auto",n=r(this,ft).max!==void 0&&r(this,ft).max!=="auto",a=e.media.height-this.xAxisHeight;C(this,Y,Sn).call(this,t.yRange.min,t.yRange.max,a,s,n),u(this,us,t.yRange.min),u(this,ds,t.yRange.max),this.syncScales()};const Fi={len:0,firstTime:null,lastTime:null},sh=20;function Un(i){const{chart:t,id:e,data:s,prev:n,layerIndex:a}=i;if(s.length===0)return t.setSeriesData(e,[],a),{len:0,firstTime:null,lastTime:null};const o=zt(s[0].time),l=zt(s[s.length-1].time),h=n.firstTime!==null&&n.firstTime!==o,c=s.length-n.len,d=n.lastTime!==null&&n.lastTime!==l;if(h&&c===0&&d)t.appendData(e,s[s.length-1],a),t.keepLast(e,s.length,a);else if(n.len===0||s.length<n.len||c>sh||h)t.setSeriesData(e,s,a);else if(s.length===n.len)t.updateData(e,s[s.length-1],a);else for(let f=n.len;f<s.length;f++)t.appendData(e,s[f],a);return{len:s.length,firstTime:o,lastTime:l}}function nh(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const a=n/t,o=[];let l=0;for(let h=0;h<t;h++){const c=h===t-1?s+1:e+(h+1)*a;let d=null,f=null;for(;l<i.length&&i[l].time<c;){const m=i[l];(d===null||m.value<d.value)&&(d=m),(f===null||m.value>f.value)&&(f=m),l++}if(!(d===null||f===null)){if(d===f){o.push(d);continue}d.time<f.time?o.push(d,f):o.push(f,d)}}return o}function rh(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const a=n/t,o=[];let l=0;for(let h=0;h<t;h++){const c=h===t-1?s+1:e+(h+1)*a;let d=null;for(;l<i.length&&i[l].time<c;){const f=i[l];d===null?d={time:f.time,open:f.open,high:f.high,low:f.low,close:f.close}:(f.high>d.high&&(d.high=f.high),f.low<d.low&&(d.low=f.low),d.close=f.close),l++}d!==null&&o.push(d)}return o}const kr=8;function va(i,t){return Math.abs(i-t.left)<=kr?{gesture:"resize-left",snapToCenter:!1}:Math.abs(i-t.right)<=kr?{gesture:"resize-right",snapToCenter:!1}:i>t.left&&i<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function ah(i){const{startVisible:t,deltaPx:e,pixelsPerTime:s,dataRange:n}=i,a=t.to-t.from,o=e/s;let l=t.from+o,h=t.to+o;return l<n.from&&(l=n.from,h=l+a),h>n.to&&(h=n.to,l=h-a),l<n.from&&(l=n.from),{from:l,to:h}}function oh(i){const{edge:t,startVisible:e,deltaPx:s,pixelsPerTime:n,dataRange:a,minSpan:o}=i,l=s/n;if(t==="left"){let d=e.from+l,f=e.to;return d<a.from&&(d=a.from),f-d<o&&(d=f-o),d<a.from&&(d=a.from,f=Math.min(a.to,d+o)),{from:d,to:f}}let h=e.from,c=e.to+l;return c>a.to&&(c=a.to),c-h<o&&(c=h+o),c>a.to&&(c=a.to,h=Math.max(a.from,c-o)),{from:h,to:c}}function lh(i){const{time:t,startVisible:e,xRange:s}=i,n=e.to-e.from;let a=t-n/2,o=a+n;return a<s.from&&(a=s.from,o=a+n),o>s.to&&(o=s.to,a=o-n),a<s.from&&(a=s.from),{from:a,to:o}}function hh(i){const{ctx:t,theme:e,mediaWidth:s,mediaHeight:n}=i;t.fillStyle=e.background,t.fillRect(0,0,s,n)}function ch(i,t,e=!0,s=1){if(t.length<2)return;const{ctx:n,timeScale:a,yScale:o,mediaHeight:l,theme:h}=i,c=s<1&&t.length>=2,d=c?t.length-2:t.length-1;if(e){const f=n.createLinearGradient(0,0,0,l);f.addColorStop(0,h.line.areaTopColor),f.addColorStop(1,h.line.areaBottomColor),n.beginPath();for(let m=0;m<=d;m++){const g=t[m],p=a.timeToX(g.time),b=o.valueToY(g.value);m===0?n.moveTo(p,b):n.lineTo(p,b)}if(n.lineTo(a.timeToX(t[d].time),l),n.lineTo(a.timeToX(t[0].time),l),n.closePath(),n.fillStyle=f,n.fill(),c){n.save(),n.globalAlpha=s,n.beginPath();const m=t[d],g=t[t.length-1],p=a.timeToX(m.time),b=a.timeToX(g.time);n.moveTo(p,o.valueToY(m.value)),n.lineTo(b,o.valueToY(g.value)),n.lineTo(b,l),n.lineTo(p,l),n.closePath(),n.fillStyle=f,n.fill(),n.restore()}}n.beginPath();for(let f=0;f<=d;f++){const m=t[f],g=a.timeToX(m.time),p=o.valueToY(m.value);f===0?n.moveTo(g,p):n.lineTo(g,p)}if(n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),c){n.save(),n.globalAlpha=s,n.beginPath();const f=t[d],m=t[t.length-1];n.moveTo(a.timeToX(f.time),o.valueToY(f.value)),n.lineTo(a.timeToX(m.time),o.valueToY(m.value)),n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),n.restore()}}function uh(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:a,mediaHeight:o,theme:l}=i,h=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.8:2),c=e<1,d=t.length-1;s.fillStyle=l.line.color;for(let f=0;f<t.length;f++){const m=t[f],g=n.timeToX(m.time),p=a.valueToY(m.value),b=Math.max(1,o-p);c&&f===d?(s.save(),s.globalAlpha=e,s.fillRect(g-h/2,p,h,b),s.restore()):s.fillRect(g-h/2,p,h,b)}}function dh(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:a,theme:o}=i,l=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.75:2),h=e<1,c=t.length-1;for(let d=0;d<t.length;d++){const f=t[d],m=f.close>=f.open?o.candlestick.up:o.candlestick.down,g=Dt(m.body),p=n.timeToX(f.time),b=a.valueToY(f.open),v=a.valueToY(f.close),S=a.valueToY(f.high),L=a.valueToY(f.low),y=h&&d===c;y&&(s.save(),s.globalAlpha=e),s.strokeStyle=m.wick,s.lineWidth=1,s.beginPath(),s.moveTo(p,S),s.lineTo(p,L),s.stroke();const M=Math.min(b,v),k=Math.max(1,Math.abs(v-b));s.fillStyle=g,s.fillRect(p-l/2,M,l,k),y&&s.restore()}}function fh(i,t,e){const s=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),a=i.timeToX(s),o=i.timeToX(n),l=Math.min(a,o),h=Math.max(a,o);return{left:l,right:h,width:Math.max(1,h-l)}}var Qt,U,Us,gt,te,$e,Ce,Te,pe,be,ai,Ri,Be,Ys,js,Ze,me,Le,es,se,is,fs,ss,si,ns,rs,as,os,qe,ls,H,Tn,At,ya,Ln,He,Di,un,Is,Sr,xa,wa,Ma,Cr,Tr,ui,Lr;class ka{constructor(t){w(this,H),w(this,Qt),w(this,U),w(this,Us),w(this,gt),w(this,te),w(this,$e),w(this,Ce),w(this,Te),w(this,pe),w(this,be),w(this,ai),w(this,Ri),w(this,Be,new Kr),w(this,Ys,new Jr),w(this,js,0),w(this,Ze,0),w(this,me,1),w(this,Le,null),w(this,es,!0),w(this,se,null),w(this,is,null),w(this,fs,-1),w(this,ss),w(this,si,null),w(this,ns),w(this,rs),w(this,as),w(this,os),w(this,qe),w(this,ls),u(this,Qt,t.container),u(this,gt,t.chart),u(this,ai,t.data),u(this,Ri,t.options??{}),window.getComputedStyle(r(this,Qt)).position==="static"&&(r(this,Qt).style.position="relative"),u(this,U,document.createElement("canvas")),r(this,U).style.position="absolute",r(this,U).style.left="0",r(this,U).style.top="0",r(this,U).style.height="100%",r(this,U).style.touchAction="none",r(this,Qt).appendChild(r(this,U));const e=r(this,U).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");u(this,Us,e),u(this,te,document.createElement("div")),r(this,te).dataset.chartNavigatorOverlay="",r(this,te).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",u(this,$e,document.createElement("div")),r(this,$e).style.cssText="position:absolute;left:0;top:0;bottom:0;",u(this,Ce,document.createElement("div")),r(this,Ce).style.cssText="position:absolute;top:0;bottom:0;",u(this,Te,document.createElement("div")),r(this,Te).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",u(this,pe,Rr()),u(this,be,Rr()),r(this,te).append(r(this,$e),r(this,Ce),r(this,Te),r(this,pe),r(this,be)),r(this,Qt).appendChild(r(this,te)),u(this,ns,()=>C(this,H,He).call(this)),u(this,rs,()=>C(this,H,He).call(this)),r(this,gt).on("viewportChange",r(this,ns)),r(this,gt).on("overlayChange",r(this,rs)),u(this,as,n=>C(this,H,xa).call(this,n)),u(this,os,n=>C(this,H,wa).call(this,n)),u(this,qe,n=>C(this,H,Ma).call(this,n)),u(this,ls,()=>{r(this,si)===null&&(r(this,U).style.cursor="default")}),r(this,U).addEventListener("pointerdown",r(this,as)),r(this,U).addEventListener("pointermove",r(this,os)),r(this,U).addEventListener("pointerup",r(this,qe)),r(this,U).addEventListener("pointercancel",r(this,qe)),r(this,U).addEventListener("pointerleave",r(this,ls)),u(this,ss,new ResizeObserver(n=>C(this,H,ya).call(this,n[0]))),r(this,ss).observe(r(this,Qt)),C(this,H,Tn).call(this);const s=r(this,Qt).getBoundingClientRect();s.width>0&&s.height>0&&C(this,H,Ln).call(this,s.width,s.height),C(this,H,He).call(this)}setData(t){var e;const s=mh(t),n=(s==null?void 0:s.time)??null;if(n!==null&&r(this,is)!==null&&n!==r(this,is)){const a=((e=r(this,se))==null?void 0:e.current)??0;u(this,se,new Pi({initial:a,duration:Gs,easing:_r,lerp:(o,l,h)=>o+(l-o)*h})),r(this,se).setTarget(1)}u(this,is,n),u(this,fs,(s==null?void 0:s.seriesIndex)??-1),u(this,ai,t),C(this,H,He).call(this)}setOptions(t){u(this,Ri,t),C(this,H,Tn).call(this),C(this,H,He).call(this)}destroy(){r(this,gt).off("viewportChange",r(this,ns)),r(this,gt).off("overlayChange",r(this,rs)),r(this,U).removeEventListener("pointerdown",r(this,as)),r(this,U).removeEventListener("pointermove",r(this,os)),r(this,U).removeEventListener("pointerup",r(this,qe)),r(this,U).removeEventListener("pointercancel",r(this,qe)),r(this,U).removeEventListener("pointerleave",r(this,ls)),r(this,ss).disconnect(),r(this,Le)!==null&&(cancelAnimationFrame(r(this,Le)),u(this,Le,null)),r(this,U).remove(),r(this,te).remove()}get height(){return r(this,Ri).height??r(this,gt).getTheme().navigator.height}}Qt=new WeakMap,U=new WeakMap,Us=new WeakMap,gt=new WeakMap,te=new WeakMap,$e=new WeakMap,Ce=new WeakMap,Te=new WeakMap,pe=new WeakMap,be=new WeakMap,ai=new WeakMap,Ri=new WeakMap,Be=new WeakMap,Ys=new WeakMap,js=new WeakMap,Ze=new WeakMap,me=new WeakMap,Le=new WeakMap,es=new WeakMap,se=new WeakMap,is=new WeakMap,fs=new WeakMap,ss=new WeakMap,si=new WeakMap,ns=new WeakMap,rs=new WeakMap,as=new WeakMap,os=new WeakMap,qe=new WeakMap,ls=new WeakMap,H=new WeakSet,Tn=function(){const i=r(this,Ri).height;i!==void 0&&(r(this,Qt).style.height=`${i}px`)},At=function(){return Math.max(0,r(this,js)-r(this,gt).yAxisWidth)},ya=function(i){var t;if(!i)return;const e=(t=i.contentBoxSize)==null?void 0:t[0],s=(e==null?void 0:e.inlineSize)??i.contentRect.width,n=(e==null?void 0:e.blockSize)??i.contentRect.height;s<=0||n<=0||(C(this,H,Ln).call(this,s,n),C(this,H,He).call(this))},Ln=function(i,t){const e=window.devicePixelRatio||1;u(this,js,i),u(this,Ze,t),u(this,me,e);const s=r(this,H,At);r(this,U).width=Math.round(s*e),r(this,U).height=Math.round(t*e),r(this,U).style.width=`${s}px`,r(this,te).style.width=`${s}px`},He=function(){r(this,es)&&r(this,Le)!==null||(u(this,es,!0),r(this,Le)===null&&u(this,Le,requestAnimationFrame(()=>{u(this,Le,null),u(this,es,!1),C(this,H,Cr).call(this)})))},Di=function(i){const t=r(this,U).getBoundingClientRect();return i.clientX-t.left},un=function(){const i=C(this,H,ui).call(this),t=C(this,H,Lr).call(this);return r(this,Be).update(i,r(this,H,At),r(this,me)),r(this,Ys).update(t,r(this,Ze),r(this,me)),{xRange:i,yRange:t}},Is=function(){return C(this,H,un).call(this),fh(r(this,Be),r(this,gt).getVisibleRange(),C(this,H,ui).call(this))},Sr=function(){const i=C(this,H,ui).call(this),t=i.to-i.from;return t<=0||r(this,H,At)<=0?0:r(this,H,At)/t},xa=function(i){if(i.button!==void 0&&i.button!==0)return;const t=C(this,H,Di).call(this,i),e=C(this,H,ui).call(this);if(e.to<=e.from)return;const s=C(this,H,Is).call(this),n=va(t,s),a=C(this,H,Sr).call(this);if(a===0)return;let o=r(this,gt).getVisibleRange();if(n.snapToCenter){const l=r(this,Be).xToTime(t),h=lh({time:l,startVisible:o,xRange:e});r(this,gt).setVisibleRange(h),o=h}u(this,si,{pointerId:i.pointerId,gesture:n.gesture,startX:t,startVisible:o,pixelsPerTime:a}),r(this,U).setPointerCapture(i.pointerId),r(this,U).style.cursor=Sa(n.gesture,!0),i.preventDefault()},wa=function(i){const t=r(this,si);if(t===null){r(this,U).style.cursor=Ir(C(this,H,Di).call(this,i),C(this,H,Is).call(this));return}if(i.pointerId!==t.pointerId)return;const e=C(this,H,Di).call(this,i)-t.startX,s=C(this,H,ui).call(this);let n;if(t.gesture==="pan")n=ah({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s});else{const a=t.gesture==="resize-left"?"left":"right";n=oh({edge:a,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s,minSpan:2*r(this,gt).getDataInterval()})}r(this,gt).setVisibleRange(n)},Ma=function(i){const t=r(this,si);t===null||i.pointerId!==t.pointerId||(u(this,si,null),r(this,U).hasPointerCapture(i.pointerId)&&r(this,U).releasePointerCapture(i.pointerId),r(this,U).style.cursor=Ir(C(this,H,Di).call(this,i),C(this,H,Is).call(this)))},Cr=function(){if(r(this,H,At)<=0||r(this,Ze)<=0)return;const i=r(this,gt).getTheme().navigator,{xRange:t}=C(this,H,un).call(this);r(this,U).width=Math.round(r(this,H,At)*r(this,me)),r(this,U).height=Math.round(r(this,Ze)*r(this,me)),r(this,U).style.width=`${r(this,H,At)}px`,r(this,te).style.width=`${r(this,H,At)}px`;const e=r(this,Us),s=r(this,U).width,n=r(this,U).height;e.save(),e.clearRect(0,0,s,n),e.scale(r(this,me),r(this,me));const a={ctx:e,timeScale:r(this,Be),yScale:r(this,Ys),mediaWidth:r(this,H,At),mediaHeight:r(this,Ze),theme:i};r(this,U).style.boxShadow=`inset 0 1px 0 ${i.borderColor}, inset 0 -1px 0 ${i.borderColor}`,hh(a);let o=1;r(this,se)!==null&&(r(this,se).tick(performance.now()),o=r(this,se).current,r(this,se).animating?C(this,H,He).call(this):u(this,se,null));const l=Math.max(1,Math.round(r(this,H,At))),h=r(this,ai);if(h.type==="candlestick")dh(a,rh(h.points,l),o);else{const c=dn(h),d=c.length===1,f=r(this,fs)>=0?r(this,fs):c.length-1;for(let m=0;m<c.length;m++){const g=nh(c[m],l),p=m===f?o:1;h.type==="bar"?uh(a,g,p):ch(a,g,d,p)}}e.restore(),C(this,H,Tr).call(this,i,t)},Tr=function(i,t){if(t.to<=t.from)return;const e=r(this,gt).getVisibleRange(),s=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),a=r(this,Be).timeToX(s),o=r(this,Be).timeToX(n),l=Math.min(a,o),h=Math.max(a,o),c=Math.max(1,h-l);r(this,$e).style.width=`${l}px`,r(this,$e).style.background=i.mask.fill,r(this,$e).style.display=l>0?"block":"none";const d=Math.max(0,r(this,H,At)-(l+c));r(this,Ce).style.left=`${l+c}px`,r(this,Ce).style.width=`${d}px`,r(this,Ce).style.background=i.mask.fill,r(this,Ce).style.display=d>0?"block":"none",r(this,Te).style.left=`${l}px`,r(this,Te).style.width=`${c}px`,r(this,Te).style.background=i.window.fill,r(this,Te).style.border=i.window.borderWidth>0?`${i.window.borderWidth}px solid ${i.window.border}`:"none";const f=i.handle.width,m=Math.max(1,f/2),g=r(this,gt).getTheme().background;r(this,pe).style.left=`${l-f/2}px`,r(this,pe).style.width=`${f}px`,r(this,pe).style.background=i.handle.color,r(this,pe).style.borderRadius=`${m}px`,r(this,be).style.left=`${l+c-f/2}px`,r(this,be).style.width=`${f}px`,r(this,be).style.background=i.handle.color,r(this,be).style.borderRadius=`${m}px`;for(const p of r(this,pe).children)p.style.background=g;for(const p of r(this,be).children)p.style.background=g},ui=function(){const i=r(this,ai);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,s=0;if(i.type==="candlestick")s=i.points.length,s>0&&(t=i.points[0].time,e=i.points[s-1].time);else for(const a of dn(i))a.length!==0&&(s+=a.length,a[0].time<t&&(t=a[0].time),a[a.length-1].time>e&&(e=a[a.length-1].time));if(s>=2&&e>t)return{from:t,to:e};if(s===1)return{...r(this,gt).getVisibleRange()};const n=r(this,gt).getDataRange();return n&&n.to>n.from?n:{...r(this,gt).getVisibleRange()}},Lr=function(){const i=r(this,ai);let t=1/0,e=-1/0;if(i.type==="candlestick")for(const n of i.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of dn(i))for(const a of n)a.value<t&&(t=a.value),a.value>e&&(e=a.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const s=(e-t)*.2;return{min:t-s,max:e+s}};function dn(i){return"series"in i?i.series:[i.points]}function mh(i){if(i.type==="candlestick"){const n=i.points.length;return n===0?null:{time:i.points[n-1].time,seriesIndex:-1}}const t="series"in i?i.series:[i.points];let e=null,s=-1;for(let n=0;n<t.length;n++){const a=t[n];if(a.length===0)continue;const o=a[a.length-1].time;(e===null||o>e)&&(e=o,s=n)}return e===null?null:{time:e,seriesIndex:s}}function Sa(i,t){return i==="resize-left"||i==="resize-right"?"ew-resize":t?"grabbing":"grab"}function Ir(i,t){return Sa(gh(i,t),!1)}function gh(i,t){return va(i,t).gesture}function Rr(){const i=document.createElement("div");i.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",i.appendChild(e)}return i}const In=new WeakMap;function Ca(i,t){var e;return(e=In.get(i))==null?void 0:e.get(t)}function Ta(i,t,e){let s=In.get(i);s||(s=new Map,In.set(i,s)),s.set(t,e)}function Wr(i){return"close"in i?i.close:i.value}function La(i,t){if(t==="none"||i.length<=1)return i;const e=[...i];return e.sort((s,n)=>{const a=Wr(s.data),o=Wr(n.data);return t==="asc"?a-o:o-a}),e}function _s(i){const t=Object.freeze({...i.data}),e={id:i.id,seriesId:i.seriesId,layerIndex:i.layerIndex,label:i.label,data:t,color:i.color};return Object.freeze(e)}function _n(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Ca(i,t.cacheKey);if(n&&n.version===s&&n.time===t.time&&n.sort===e)return n.data;const a=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l);if(i.getSeriesLayers(l)!==null){const d=i.getLayerSnapshots(l,t.time);if(!d)continue;for(const f of d)a.push(_s({id:`${l}_layer${f.layerIndex}`,seriesId:l,layerIndex:f.layerIndex,label:h,data:{time:f.time,value:f.value},color:f.color}));continue}const c=i.getDataAtTime(l,t.time);c&&a.push(_s({id:l,seriesId:l,label:h,data:c,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(La(a,e));return Ta(i,t.cacheKey,{version:s,time:t.time,sort:e,data:o}),o}function Ia(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Ca(i,t.cacheKey);if(n&&n.version===s&&n.time===null&&n.sort===e)return n.data;const a=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l),c=i.getLayerLastSnapshots(l);if(c){for(const f of c)a.push(_s({id:`${l}_layer${f.layerIndex}`,seriesId:l,layerIndex:f.layerIndex,label:h,data:{time:f.time,value:f.value},color:f.color}));continue}const d=i.getLastData(l);d&&a.push(_s({id:l,seriesId:l,label:h,data:d,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(La(a,e));return Ta(i,t.cacheKey,{version:s,time:null,sort:e,data:o}),o}const ph=at({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(90,88,100,0.2)"},candlestick:{up:{body:j("#96e072"),wick:"#96e072"},down:{body:j("#ee5d43"),wick:"#ee5d43"}},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.7)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:aa},fontUrl:oa}),bh=at({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(82,90,108,0.2)"},candlestick:{up:{body:j("#bae67e"),wick:"#bae67e"},down:{body:j("#f27983"),wick:"#f27983"}},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.7)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:Js},fontUrl:Hn}),vh=at({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(108,113,140,0.2)"},candlestick:{up:{body:j("#50fa7b"),wick:"#50fa7b"},down:{body:j("#ff5555"),wick:"#ff5555"}},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.7)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:$n},fontUrl:On}),yh=at({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{up:{body:j("#2da44e"),wick:"#2da44e"},down:{body:j("#cf222e"),wick:"#cf222e"}},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(80,90,100,0.5)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:Xn},fontUrl:Nn}),xh=at({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(100,94,90,0.2)"},candlestick:{up:{body:j("#b8bb26"),wick:"#b8bb26"},down:{body:j("#fb4934"),wick:"#fb4934"}},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.7)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:Zs},fontUrl:qs}),wh={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:eh,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:th,fontSize:15},grid:{color:"rgba(180,170,150,0.2)",style:"solid"},candlestick:{up:{body:j("#7a9a5e"),wick:"#7a9a5e"},down:{body:j("#b07060"),wick:"#b07060"}},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{fontSize:13,textColor:"#a09880"},yLabel:{fontSize:15,upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{fontSize:14,background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.3)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:j("#7a9a5e"),wick:"#7a9a5e"},down:{body:j("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},Mh="'Silkscreen', cursive",kh="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Sh=at({name:"Matrix",background:"#000000",candlestick:{up:{body:j("#00ff41"),wick:"#00ff41"},down:{body:j("#00802a"),wick:"#00802a"}},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.08)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Mh},fontUrl:kh,chartGradient:["#010a01","#000000"]}),Ch=at({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:j("#6b8e5e"),wick:"#6b8e5e"},down:{body:j("#b85468"),wick:"#b85468"}},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.3)",style:"dashed"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(80,60,90,0.45)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:Xn},fontUrl:Nn,chartGradient:["#f8f4f7","#f5f0f4"]}),Th=at({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)",style:"dotted"},candlestick:{up:{body:j("#6a9a6e"),wick:"#6a9a6e"},down:{body:j("#c45070"),wick:"#c45070"}},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(120,70,90,0.5)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.25)"},typography:{fontFamily:Js},fontUrl:Hn}),Lh=at({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(95,99,120,0.2)"},candlestick:{up:{body:j("#c3e88d"),wick:"#c3e88d"},down:{body:j("#f07178"),wick:"#f07178"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.7)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:aa},fontUrl:oa}),Ih="'Silkscreen', cursive",Rh="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Wh=at({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.04)",style:"solid"},candlestick:{up:{body:j("#111111"),wick:"#111111"},down:{body:j("#bbbbbb"),wick:"#bbbbbb"}},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.35)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{fontSize:9,background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.04)"},typography:{fontFamily:Ih},fontUrl:Rh}),Ah=at({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:j("#2e9070"),wick:"#2e9070"},down:{body:j("#d04848"),wick:"#d04848"}},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(55,80,70,0.45)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:Jl},fontUrl:Ql,chartGradient:["#f8f7f0","#f6f5ee"]}),Ph=at({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(104,100,102,0.2)"},candlestick:{up:{body:j("#8ab862"),wick:"#8ab862"},down:{body:j("#d05470"),wick:"#d05470"}},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.7)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:$n},fontUrl:On}),Fh=at({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(71,92,118,0.2)"},candlestick:{up:{body:j("#7ec699"),wick:"#7ec699"},down:{body:j("#e06c75"),wick:"#e06c75"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.7)",labelBackground:"#1d3b53"},axis:{textColor:"#4d5a6c"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Zs},fontUrl:qs}),Bh=at({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(99,104,116,0.2)"},candlestick:{up:{body:j("#98c379"),wick:"#98c379"},down:{body:j("#e06c75"),wick:"#e06c75"}},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.7)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:Zs},fontUrl:qs}),Dh=at({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(98,98,100,0.2)"},candlestick:{up:{body:j("#19f9d8"),wick:"#19f9d8"},down:{body:j("#ff75b5"),wick:"#ff75b5"}},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.7)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:$n},fontUrl:On}),zh=at({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:j("#5a9a68"),wick:"#5a9a68"},down:{body:j("#d06848"),wick:"#d06848"}},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(100,70,55,0.45)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:Xn},fontUrl:Nn,chartGradient:["#fff8f2","#fef6f0"]}),Eh=at({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",chartGradient:["#fdfdfd","#f5f5f5"],grid:{color:"rgba(200,200,200,0.4)"},candlestick:{up:{body:j("#448c27"),wick:"#448c27"},down:{body:j("#aa3731"),wick:"#aa3731"}},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(80,80,80,0.5)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Zl},fontUrl:ql}),Vh=at({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:j("#56949f"),wick:"#56949f"},down:{body:j("#b4637a"),wick:"#b4637a"}},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(80,72,98,0.5)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.2)"},typography:{fontFamily:la},fontUrl:ha}),Yh=at({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:j("#5a8a50"),wick:"#5a8a50"},down:{body:j("#b85040"),wick:"#b85040"}},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(85,65,45,0.45)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:la},fontUrl:ha,chartGradient:["#f8f4ec","#f4f0e8"]}),jh=at({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(200,193,170,0.4)"},candlestick:{up:{body:j("#859900"),wick:"#859900"},down:{body:j("#dc322f"),wick:"#dc322f"}},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(80,100,100,0.55)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:Zs},fontUrl:qs});function bs(i){const{x:t,y:e,chartWidth:s,chartHeight:n,tooltipWidth:a,tooltipHeight:o,offsetX:l=16,offsetY:h=16}=i,c=t+l+a>s?t-l-a:t+l,d=e+h+o>n?e-h-o:e+h,f=Math.max(0,s-a),m=Math.max(0,n-o);return{left:Math.max(0,Math.min(f,c)),top:Math.max(0,Math.min(m,d))}}const Si=W.createContext(null);function wt(){const i=W.useContext(Si);if(!i)throw new Error("useChartInstance must be used within <ChartContainer>");return i}function Ra({data:i,options:t,id:e}){var o;const s=wt(),n=W.useRef(null),a=W.useRef([]);return W.useLayoutEffect(()=>{const l=s.addSeries("bar",{...t,layers:i.length,id:e});return n.current=l,a.current=new Array(i.length).fill(Fi),()=>{s.removeSeries(l),n.current=null,a.current=[]}},[s,i.length,e]),W.useLayoutEffect(()=>{const l=n.current;l&&s.batch(()=>{for(let h=0;h<i.length;h++)a.current[h]=Un({chart:s,id:l,data:i[h],prev:a.current[h]??Fi,layerIndex:h})})},[s,i]),W.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(o=t==null?void 0:t.colors)==null?void 0:o.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}function Hh({data:i,options:t,id:e}){var o,l,h,c,d,f;const s=wt(),n=W.useRef(null),a=W.useRef(Fi);return W.useLayoutEffect(()=>{const m=s.addSeries("candlestick",{...t,id:e});return n.current=m,()=>{s.removeSeries(m),n.current=null,a.current=Fi}},[s,e]),W.useLayoutEffect(()=>{const m=n.current;m&&(a.current=Un({chart:s,id:m,data:i,prev:a.current}))},[s,i]),W.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,Array.isArray((o=t==null?void 0:t.up)==null?void 0:o.body)?t.up.body.join(","):(l=t==null?void 0:t.up)==null?void 0:l.body,Array.isArray((h=t==null?void 0:t.down)==null?void 0:h.body)?t.down.body.join(","):(c=t==null?void 0:t.down)==null?void 0:c.body,(d=t==null?void 0:t.up)==null?void 0:d.wick,(f=t==null?void 0:t.down)==null?void 0:f.wick,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}const Gn=W.createContext(null),Ci=Gn.Provider;function vs(){const i=W.useContext(Gn);if(!i)throw new Error("useTheme must be used within <ThemeProvider>");return i}function $h(){return W.useContext(Gn)}function Qs(i,t,e){const s=Array.isArray(t)?t:[t];return{subscribe:n=>{const a=n;for(const o of s)i.on(o,a);return()=>{for(const o of s)i.off(o,a)}},getSnapshot:e}}function Wa(i){const t=W.useMemo(()=>Qs(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getVisibleRange()),[i]);return W.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Aa(i){const t=W.useMemo(()=>Qs(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getYRange()),[i]);return W.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Oh(i,t){const e=W.useMemo(()=>{let s=i.getLastValue(t),n=s?i.yScale.valueToY(s.value):null;const a=()=>s,o=()=>{const l=i.getLastValue(t),h=l?i.yScale.valueToY(l.value):null;return(s==null?void 0:s.value)===(l==null?void 0:l.value)&&(s==null?void 0:s.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(s=l,n=h,!0)};return{subscribe:l=>{o();const h=()=>{o()&&l()};return i.on("dataUpdate",h),i.on("viewportChange",h),()=>{i.off("dataUpdate",h),i.off("viewportChange",h)}},getSnapshot:a}},[i,t]);return W.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Xh(i,t){const e=W.useMemo(()=>Qs(i,"dataUpdate",()=>i.getPreviousClose(t)),[i,t]);return W.useSyncExternalStore(e.subscribe,e.getSnapshot)}function ys(i){const t=W.useMemo(()=>Qs(i,"crosshairMove",()=>i.getCrosshairPosition()),[i]);return W.useSyncExternalStore(t.subscribe,t.getSnapshot)}const Nh=(i,t)=>t==="volume"?Xe(i):jn(i);function Pa({sort:i="none",format:t=Nh,children:e}){const s=wt(),n=vs(),a=ys(s),[,o]=W.useState(0);W.useLayoutEffect(()=>{const m=()=>o(g=>g+1);return s.on("overlayChange",m),s.getSeriesIds().length>0&&o(g=>g+1),()=>{s.off("overlayChange",m)}},[s]);const l=Ia(s,{sort:i,cacheKey:"infobar-last"});let h=l,c=l.length===0?0:Math.max(...l.map(m=>m.data.time)),d=!1;if(a!==null){const m=_n(s,{time:a.time,sort:i,cacheKey:"infobar-hover"});m.length>0&&(h=m,c=a.time,d=!0)}if(h.length===0)return e?null:I.jsx("div",{"data-tooltip-legend":"","aria-hidden":"true",style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",visibility:"hidden",pointerEvents:"none"},children:I.jsx("span",{children:" "})});if(e)return I.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:d?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:h,time:c,isHover:d})});const f=s.getDataInterval();return I.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:d?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[I.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:gs(c,f)}),h.map(m=>{if("open"in m.data){const b=m.data,v=b.close>=b.open,S=Dt(v?n.candlestick.up.body:n.candlestick.down.body);return I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[I.jsx(zi,{label:"O",display:t(b.open,"open"),color:S,dim:n.axis.textColor}),I.jsx(zi,{label:"H",display:t(b.high,"high"),color:S,dim:n.axis.textColor}),I.jsx(zi,{label:"L",display:t(b.low,"low"),color:S,dim:n.axis.textColor}),I.jsx(zi,{label:"C",display:t(b.close,"close"),color:S,dim:n.axis.textColor}),b.volume!=null&&I.jsx(zi,{label:"V",display:t(b.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},m.id)}const p=m.data;return I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[I.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.color,flexShrink:0}}),I.jsx("span",{style:{color:m.color,fontWeight:500},children:t(p.value,"value")})]},m.id)})]})}function zi({label:i,display:t,color:e,dim:s}){return I.jsxs(I.Fragment,{children:[I.jsx("span",{style:{color:s,opacity:.5,marginLeft:5},children:i}),I.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function Uh({chart:i,isolatedIdRef:t,setIsolatedId:e}){const s=[],n=i.getSeriesIds();for(const a of n){const o=i.getSeriesLayers(a);if(o){const l=i.getSeriesLabel(a);for(let h=0;h<o.length;h++){const c=`${a}_layer${h}`,d=i.isSeriesVisible(a)&&i.isLayerVisible(a,h);s.push(Ar({id:c,seriesId:a,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:o[h].color,isDisabled:!d,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=i.getSeriesColor(a);if(!l)continue;const h=i.getSeriesLabel(a),c=i.isSeriesVisible(a);s.push(Ar({id:a,seriesId:a,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!c,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}return s}function Ar(i){const{id:t,seriesId:e,layerIndex:s,label:n,color:a,isDisabled:o,chart:l,isolatedIdRef:h,setIsolatedId:c}=i;return{id:t,seriesId:e,layerIndex:s,label:n,color:a,isDisabled:o,toggle:()=>{s!==void 0?l.setLayerVisible(e,s,!l.isLayerVisible(e,s)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const m of l.getSeriesIds()){l.setSeriesVisible(m,!0);const g=l.getSeriesLayers(m);if(g)for(let p=0;p<g.length;p++)l.setLayerVisible(m,p,!0)}}),h.current=null,c(null);return}l.batch(()=>{for(const m of l.getSeriesIds()){const g=l.getSeriesLayers(m);if(g){l.setSeriesVisible(m,m===e);for(let p=0;p<g.length;p++)l.setLayerVisible(m,p,m===e&&p===s)}else l.setSeriesVisible(m,m===t)}}),h.current=t,c(t)}}}function Fa({items:i,position:t="bottom",mode:e="toggle",children:s}){const n=wt(),a=vs(),[o,l]=W.useState(null),[h,c]=W.useState(0),d=W.useRef(o);d.current=o,W.useLayoutEffect(()=>{const b=()=>c(S=>S+1),v=()=>l(null);return n.on("overlayChange",b),n.on("seriesChange",v),n.getSeriesIds().length>0&&c(S=>S+1),()=>{n.off("overlayChange",b),n.off("seriesChange",v)}},[n]);const f=W.useMemo(()=>Uh({chart:n,isolatedIdRef:d,setIsolatedId:l}),[n,o,h]),m=t==="right",g={display:"flex",flexDirection:m?"column":"row",flexWrap:"wrap",gap:m?6:14,padding:m?"8px 6px":"6px 8px",alignItems:m?"flex-start":"center",justifyContent:m?"flex-start":"center",fontFamily:a.typography.fontFamily,fontSize:a.axis.fontSize,color:a.axis.textColor,pointerEvents:"auto",flexShrink:0};if(s)return f.length===0?null:I.jsx("div",{"data-legend":t,style:g,children:s({items:f})});if(i)return i.length===0?null:I.jsx("div",{"data-legend":t,style:g,children:i.map((b,v)=>I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:2,background:b.color,flexShrink:0}}),I.jsx("span",{style:{whiteSpace:"nowrap"},children:b.label})]},v))});if(f.length===0)return null;const p=b=>{e==="isolate"||e==="solo"?b.isolate():b.toggle()};return I.jsx("div",{"data-legend":t,style:g,children:f.map(b=>I.jsxs("div",{onClick:()=>p(b),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:b.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:2,background:b.color,flexShrink:0}}),I.jsx("span",{style:{whiteSpace:"nowrap"},children:b.label})]},b.id))})}function Ba({data:i,height:t,style:e,className:s}){const n=wt(),a=vs(),o=W.useRef(null),l=W.useRef(null);W.useLayoutEffect(()=>{if(!o.current)return;const c=new ka({container:o.current,chart:n,data:i,options:t!==void 0?{height:t}:void 0});return l.current=c,()=>{c.destroy(),l.current=null}},[n]),W.useEffect(()=>{var c;(c=l.current)==null||c.setData(i)},[i]),W.useEffect(()=>{var c;(c=l.current)==null||c.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??a.navigator.height;return I.jsx("div",{ref:o,className:s,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function _h(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function Da({seriesId:i,mode:t,format:e,position:s,children:n}){const a=t??"both",o=s??"bottom",l=e??Xe,h=wt(),c=h.getTheme(),[,d]=W.useState(0);W.useLayoutEffect(()=>{const p=()=>d(b=>b+1);return h.on("overlayChange",p),h.getSeriesIds().length>0&&p(),()=>{h.off("overlayChange",p)}},[h]);const f=_h(h,i),m=f!==null?h.getSliceInfo(f):null;if(!m||m.length===0)return null;if(n)return I.jsx(I.Fragment,{children:n({slices:m,mode:a,format:l})});const g=o==="overlay";return I.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":o,style:{display:"flex",flexDirection:"column",gap:6,padding:g?"8px 12px":"6px 10px",fontFamily:c.typography.fontFamily,fontSize:c.typography.fontSize,color:c.tooltip.textColor,pointerEvents:"auto"},children:m.map((p,b)=>I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[I.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:p.color,flexShrink:0}}),I.jsx("span",{style:{flex:1,opacity:.8},children:p.label}),(a==="value"||a==="both")&&I.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:a==="value"?40:void 0,textAlign:"right"},children:l(p.value)}),(a==="percent"||a==="both")&&I.jsxs("span",{style:{opacity:a==="percent"?1:.5,fontWeight:a==="percent"?600:400,fontSize:a==="percent"?c.typography.fontSize:c.axis.fontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[p.percent.toFixed(1),"%"]})]},b))})}const za=W.memo(function({children:t,sub:e,style:s}){const n=vs();return I.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 0",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontWeight:600,color:n.tooltip.textColor,pointerEvents:"none",...s},children:[t!=null&&t!==!1&&I.jsx("span",{children:t}),e!=null&&e!==!1&&I.jsx("span",{style:{fontWeight:400,color:n.axis.textColor,fontSize:n.axis.fontSize},children:e})]})},(i,t)=>i.children===t.children&&i.sub===t.sub&&i.style===t.style);function Gh(i){let t=null,e=null,s=null,n=null,a=null;const o=[],l=h=>{if(W.isValidElement(h)&&h.type===W.Fragment){W.Children.forEach(h.props.children,l);return}if(W.isValidElement(h)){if(h.type===za){t=h;return}if(h.type===Fa){e=h;return}if(h.type===Da){const c=h;c.props.position==="overlay"?o.push(h):s=c;return}if(h.type===Pa){n=h;return}if(h.type===Ba){a=h;return}}o.push(h)};return W.Children.forEach(i,l),{titleEl:t,legendEl:e,pieLegendEl:s,tooltipLegendEl:n,navigatorEl:a,overlay:o}}function Ea({children:i,theme:t,axis:e,padding:s,viewport:n,gradient:a=!0,interactive:o,grid:l,headerLayout:h="overlay",perf:c,animations:d,onEdgeReached:f,style:m,className:g}){var ws,Ms,ks,oi,li,hi;const p=W.useRef(c),b=W.useRef(f),v=$h(),S=t??v??void 0,L=W.useRef(null),y=W.useRef(null),[M,k]=W.useState(0),F=W.useRef([]);W.useLayoutEffect(()=>{if(!L.current)return;const st={};if(e&&(st.axis=e),S&&(st.theme=S),s&&(st.padding=s),n&&(st.viewport=n),o!==void 0&&(st.interactive=o),l!==void 0&&(st.grid=l),p.current!==void 0&&(st.perf=p.current),d!==void 0&&(st.animations=d),b.current&&(st.onEdgeReached=b.current),y.current=new ba(L.current,st),process.env.NODE_ENV!=="production"){const yt=performance.now(),It=F.current;for(It.push(yt);It.length>0&&yt-It[0]>1e3;)It.shift();It.length>3&&console.warn("[wick-charts] <ChartContainer> recreated the chart >3 times in the last second. The `animations` prop is init-only — wrap it in useMemo(() => ({...}), [deps]) so a stable reference identity prevents tear-down on every render.")}return k(yt=>yt+1),()=>{var yt;(yt=y.current)==null||yt.destroy(),y.current=null}},[d]),W.useEffect(()=>{y.current&&S&&y.current.setTheme(S)},[S]),W.useEffect(()=>{y.current&&e&&y.current.setAxis(e)},[(ws=e==null?void 0:e.y)==null?void 0:ws.width,(Ms=e==null?void 0:e.y)==null?void 0:Ms.min,(ks=e==null?void 0:e.y)==null?void 0:ks.max,(oi=e==null?void 0:e.y)==null?void 0:oi.visible,(li=e==null?void 0:e.x)==null?void 0:li.height,(hi=e==null?void 0:e.x)==null?void 0:hi.visible]);const T=W.useRef(null),[D,B]=W.useState(0),x=h==="overlay"?D:0;W.useLayoutEffect(()=>{const st=y.current;if(!st)return;const It={top:((s==null?void 0:s.top)??20)+x,...(s==null?void 0:s.bottom)!==void 0?{bottom:s.bottom}:{},...(s==null?void 0:s.right)!==void 0?{right:s.right}:{},...(s==null?void 0:s.left)!==void 0?{left:s.left}:{}};st.setPadding(It)},[s==null?void 0:s.top,s==null?void 0:s.bottom,typeof(s==null?void 0:s.right)=="object"?s.right.intervals:s==null?void 0:s.right,typeof(s==null?void 0:s.left)=="object"?s.left.intervals:s==null?void 0:s.left,x]),W.useEffect(()=>{y.current&&l!==void 0&&y.current.setGrid(l)},[l==null?void 0:l.visible]);const R=y.current,{titleEl:A,legendEl:z,pieLegendEl:E,tooltipLegendEl:V,navigatorEl:X,overlay:$}=Gh(i),G=(z==null?void 0:z.props.position)??"bottom",xt=(E==null?void 0:E.props.position)??"bottom",Tt=G==="right"||xt==="right",_=S??(R==null?void 0:R.getTheme()),[q,J]=(_==null?void 0:_.chartGradient)??["transparent","transparent"],K=(_==null?void 0:_.background)??"transparent",Et=a?`linear-gradient(to bottom, ${q} 0%, ${K} 70%, ${J} 100%)`:K;W.useLayoutEffect(()=>{if(h!=="overlay"){B(0);return}const st=T.current;if(!st){B(0);return}const yt=()=>B(st.getBoundingClientRect().height);yt();const It=new ResizeObserver(yt);return It.observe(st),()=>It.disconnect()},[A!==null,V!==null,h,R!==null]);const kt=(A||V)&&I.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":h==="overlay"?"":void 0,ref:T,style:h==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[A,V]}),Lt=I.jsx("div",{ref:L,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:R&&I.jsx(Si.Provider,{value:R,children:I.jsxs(Ci,{value:S??R.getTheme(),children:[h==="overlay"&&kt,I.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:$})]})})}),Ie=h==="inline"?I.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[R&&kt&&I.jsx(Si.Provider,{value:R,children:I.jsx(Ci,{value:S??R.getTheme(),children:kt})}),Lt]}):Lt,re=R&&z&&I.jsx(Si.Provider,{value:R,children:I.jsx(Ci,{value:S??R.getTheme(),children:z})}),Ne=R&&E&&I.jsx(Si.Provider,{value:R,children:I.jsx(Ci,{value:S??R.getTheme(),children:E})}),xs=R&&X&&I.jsx(Si.Provider,{value:R,children:I.jsx(Ci,{value:S??R.getTheme(),children:X})});return I.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:Et,...m},children:[I.jsxs("div",{style:{display:"flex",flexDirection:Tt?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Ie,re,Ne]}),xs]})}function Kh({side:i,threshold:t=5,onTrigger:e,indicator:s="canvas",children:n}){const a=wt(),[o,l]=W.useState(!1),[h,c]=W.useState(!0),[,d]=W.useState(0),f=W.useRef(e);f.current=e;const m=W.useRef(n!==void 0);m.current=n!==void 0;const g=W.useRef(!1),p=W.useRef(!1);if(W.useEffect(()=>{if(!h)return;const L=()=>{const k=a.getVisibleRange(),F=a.getDataRange();return F?i==="left"?k.from-F.from:F.to-k.to:null},y=()=>{if(g.current||!h)return;g.current=!0,l(!0),s==="canvas"&&a.setEdgeState(i,"loading");let k;try{k=f.current()}catch(T){throw g.current=!1,l(!1),s==="canvas"&&a.setEdgeState(i,"idle"),T}const F=T=>{g.current=!1,l(!1),T===!1?(c(!1),s==="canvas"&&a.setEdgeState(i,"no-data")):s==="canvas"&&a.setEdgeState(i,"idle")};k&&typeof k.then=="function"?k.then(F,()=>F(void 0)):F(void 0)},M=()=>{const k=a.getDataInterval(),F=L();if(F!==null){if(!p.current){F>t*k&&(p.current=!0);return}F<=t*k&&y(),m.current&&d(T=>T+1)}};return a.on("viewportChange",M),a.on("overlayChange",M),M(),()=>{a.off("viewportChange",M),a.off("overlayChange",M)}},[a,i,t,s,h]),W.useEffect(()=>()=>{s==="canvas"&&a.setEdgeState(i,"idle")},[a,i,s]),!n)return null;const b=a.getDataRange();if(!b)return null;const v=i==="left"?b.from:b.to,S=a.timeScale.timeToX(v);return I.jsx(I.Fragment,{children:n({x:S,side:i,isLoading:o,boundaryTime:v,hasMore:h})})}function Va({data:i,options:t,id:e}){var o,l;const s=wt(),n=W.useRef(null),a=W.useRef([]);return W.useLayoutEffect(()=>{const h=s.addSeries("line",{...t,layers:i.length,id:e});return n.current=h,a.current=new Array(i.length).fill(Fi),()=>{s.removeSeries(h),n.current=null,a.current=[]}},[s,i.length,e]),W.useLayoutEffect(()=>{const h=n.current;h&&s.batch(()=>{for(let c=0;c<i.length;c++)a.current[c]=Un({chart:s,id:h,data:i[c],prev:a.current[c]??Fi,layerIndex:c})})},[s,i]),W.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(o=t==null?void 0:t.colors)==null?void 0:o.join(","),t==null?void 0:t.strokeWidth,(l=t==null?void 0:t.area)==null?void 0:l.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}function Zh({data:i,options:t,id:e}){var a,o,l,h,c,d,f,m,g;const s=wt(),n=W.useRef(null);return W.useLayoutEffect(()=>{const p=s.addSeries("pie",{...t,id:e});return n.current=p,()=>{s.removeSeries(p),n.current=null}},[s,e]),W.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.mode,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.minSliceAngle,(c=t==null?void 0:t.sliceLabels)==null?void 0:c.elbowLen,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.legPad,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.labelGap,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.distance,(g=t==null?void 0:t.sliceLabels)==null?void 0:g.railWidth]),W.useLayoutEffect(()=>{n.current&&s.setSeriesData(n.current,i)},[s,i]),null}function qh(){const i=wt(),t=ys(i);if(!t)return null;const e=i.getTheme(),s=i.getDataInterval(),n=i.timeScale.niceTickValues(s).tickInterval||s,a={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.axis.fontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return I.jsxs(I.Fragment,{children:[I.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...a},children:i.yScale.formatY(t.y)}),I.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...a},children:gs(t.time,n)})]})}const Jh=["0","1","2","3","4","5","6","7","8","9"];function Qh(i){const t=[];for(const e of i)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function Ya({value:i,format:t,locale:e="en-US",spinDuration:s=350,className:n,style:a}){const l=W.useMemo(()=>{if(typeof t=="function")return t;const c=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return d=>c.format(d)},[t,e])(i),h=Qh(l);return I.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...a},children:h.map((c,d)=>c.type==="digit"?I.jsx(tc,{digit:parseInt(c.value,10),duration:s},`d${d}`):I.jsx("span",{style:{display:"inline-block"},children:c.value},`s${d}`))})}function tc({digit:i,duration:t}){const e=W.useRef(!1);return W.useEffect(()=>{e.current=!0},[]),I.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:I.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-i*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Jh.map(s=>I.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:s},s))})})}function ec(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const ic=160,sc=70;function nc({seriesId:i,format:t=Xe,children:e}){const s=wt(),n=ys(s),[,a]=W.useState(0);W.useLayoutEffect(()=>{const m=()=>a(g=>g+1);return s.on("overlayChange",m),()=>{s.off("overlayChange",m)}},[s]);const o=ec(s,i),l=o!==null?s.getHoverInfo(o):null;if(!l||!n)return null;const h=s.getTheme(),c=s.getMediaSize();if(e)return I.jsx(rc,{x:n.mediaX,y:n.mediaY,chartWidth:c.width,chartHeight:c.height,children:e({info:l,format:t})});const{left:d,top:f}=bs({x:n.mediaX,y:n.mediaY,chartWidth:c.width,chartHeight:c.height,tooltipWidth:ic,tooltipHeight:sc,offsetX:16,offsetY:16});return I.jsxs("div",{style:{position:"absolute",left:d,top:f,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[I.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:l.color,flexShrink:0}}),I.jsx("span",{style:{fontWeight:600},children:l.label})]}),I.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[I.jsx("span",{style:{opacity:.6},children:t(l.value)}),I.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function rc({x:i,y:t,chartWidth:e,chartHeight:s,children:n}){const a=W.useRef(null),[o,l]=W.useState(null);W.useEffect(()=>{const c=a.current;if(!c||typeof ResizeObserver>"u")return;const d=new ResizeObserver(f=>{var g;const m=(g=f[0])==null?void 0:g.contentRect;m&&l(p=>p&&p.width===m.width&&p.height===m.height?p:{width:m.width,height:m.height})});return d.observe(c),()=>d.disconnect()},[]);const h=o?bs({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:o.width,tooltipHeight:o.height,offsetX:16,offsetY:16}):{left:0,top:0};return I.jsx("div",{ref:a,"data-measured":o?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:o?"visible":"hidden"},children:n})}function ac(i,t){if(i.startsWith("rgba")||!i.startsWith("#"))return i;const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function oc(i){if(i.length<2)return{value:0,pct:0,positive:!0};const t=i[0].value,s=i[i.length-1].value-t,n=t!==0?s/t*100:0;return{value:s,pct:n,positive:s>=0}}function lc({data:i,theme:t,variant:e="line",valuePosition:s="right",formatValue:n=Xe,label:a,sublabel:o,color:l,negativeColor:h,area:c,areaFill:d,yRange:f,flow:m,width:g=140,height:p=48,strokeWidth:b=1.5,gradient:v=!0,style:S}){const L=(c==null?void 0:c.visible)??d??!0,y=i.length>0?i[i.length-1].value:0,M=W.useMemo(()=>oc(i),[i]),k=l??t.seriesColors[0],F=h??Dt(t.candlestick.down.body),T=Dt(M.positive?t.candlestick.up.body:t.candlestick.down.body),D=W.useMemo(()=>{if(!m||i.length<2)return;const R=i[1].time-i[0].time;if(R<=0)return;const A=m.align??"right";if(A==="left")return{maxVisibleBars:m.capacity,initialRange:{from:i[0].time,bars:m.capacity}};const z=i[i.length-1].time,E=A==="offscreen"?z-R:z,V=E-m.capacity*R;return{maxVisibleBars:m.capacity,initialRange:{from:V,to:E}}},[]),B=s!=="none"&&I.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[a&&I.jsx("div",{style:{fontSize:t.axis.fontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a}),I.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(y)}),o!==void 0?I.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:o}):I.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:T,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[M.positive?"+":"",M.pct.toFixed(1),"%"]})]}),x=I.jsx("div",{style:{width:g,height:p,flexShrink:0,borderRadius:4,overflow:"hidden"},children:I.jsx(Ea,{theme:t,axis:{y:{visible:!1,width:0,min:f==null?void 0:f.min,max:f==null?void 0:f.max},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:v,interactive:!1,grid:{visible:!1},viewport:D,children:e==="line"?I.jsx(Va,{data:[i],options:{colors:[k],strokeWidth:b,area:{visible:L},pulse:!1,stacking:"off"}}):I.jsx(Ra,{data:[i],options:{colors:[k,F],barWidthRatio:.7,stacking:"off",anchor:"right"}})})});return I.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:ac(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...S},children:[s==="left"&&B,x,s==="right"&&B]})}function ja({labelCount:i,minLabelSpacing:t}={}){const e=wt();Wa(e);const s=W.useRef(null);return W.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:i??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,i,t]),W.useLayoutEffect(()=>{const n=s.current;if(n!==null)return Hr({chart:e,container:n,axis:"x"})},[e]),I.jsx("div",{ref:s,style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"}})}const hc=(i,t)=>t==="volume"?Xe(i):jn(i);function cc({sort:i="none",format:t=hc,children:e}){const s=wt(),n=ys(s),[,a]=W.useState(0);if(W.useLayoutEffect(()=>{const m=()=>a(g=>g+1);return s.on("overlayChange",m),s.getSeriesIds().length>0&&a(g=>g+1),()=>{s.off("overlayChange",m)}},[s]),!n)return null;const o=_n(s,{time:n.time,sort:i,cacheKey:"tooltip"});if(o.length===0)return null;const l=s.getTheme(),h=s.getDataInterval(),c=s.getMediaSize(),d=c.width-s.yAxisWidth,f=c.height-s.xAxisHeight;return e?I.jsx(uc,{x:n.mediaX,y:n.mediaY,chartWidth:d,chartHeight:f,theme:l,children:e({snapshots:o,time:n.time})}):I.jsx(dc,{snapshots:o,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:d,chartHeight:f,theme:l,dataInterval:h,format:t})}function uc({x:i,y:t,chartWidth:e,chartHeight:s,theme:n,children:a}){const o=W.useRef(null),[l,h]=W.useState(null);W.useEffect(()=>{const d=o.current;if(!d||typeof ResizeObserver>"u")return;const f=new ResizeObserver(m=>{var p;const g=(p=m[0])==null?void 0:p.contentRect;g&&h(b=>b&&b.width===g.width&&b.height===g.height?b:{width:g.width,height:g.height})});return f.observe(d),()=>f.disconnect()},[]);const c=l?bs({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return I.jsx("div",{ref:o,"data-measured":l?"true":"false",style:{position:"absolute",left:c.left,top:c.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.tooltip.fontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:l?"visible":"hidden"},children:a})}function dc({snapshots:i,displayTime:t,x:e,y:s,chartWidth:n,chartHeight:a,theme:o,dataInterval:l,format:h}){const c=i.some(L=>"open"in L.data),d=i.filter(L=>!("open"in L.data)).length,f=160,m=c?140:40+d*22,{left:g,top:p}=bs({x:e,y:s,chartWidth:n,chartHeight:a,tooltipWidth:f,tooltipHeight:m}),b=o.tooltip.background,v=o.tooltip.borderColor;return I.jsxs("div",{style:{position:"absolute",left:g,top:p,pointerEvents:"none",background:b,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${v}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:o.tooltip.fontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,width:f,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[I.jsxs("div",{style:{fontSize:o.axis.fontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${v}`,letterSpacing:"0.02em"},children:[jr(t)," ",gs(t,l)]}),i.map(L=>{if("open"in L.data){const k=L.data,F=k.close>=k.open,T=Dt(F?o.candlestick.up.body:o.candlestick.down.body);return I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[I.jsx(Ei,{label:"Open",color:T,display:h(k.open,"open")}),I.jsx(Ei,{label:"High",color:T,display:h(k.high,"high")}),I.jsx(Ei,{label:"Low",color:T,display:h(k.low,"low")}),I.jsx(Ei,{label:"Close",color:T,display:h(k.close,"close")}),k.volume!=null&&I.jsx(Ei,{label:"Volume",color:o.tooltip.textColor,display:h(k.volume,"volume")})]},L.id)}const M=L.data;return I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:L.color,flexShrink:0}}),I.jsx("span",{style:{opacity:.6,flex:1},children:L.label??"Value"}),I.jsx("span",{style:{fontWeight:600,color:L.color},children:h(M.value,"value")})]},L.id)})]})}function Ei({label:i,color:t,display:e}){return I.jsxs(I.Fragment,{children:[I.jsx("span",{style:{opacity:.5},children:i}),I.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function fc({format:i,labelCount:t,minLabelSpacing:e}={}){const s=wt();Aa(s);const n=W.useRef(null);return W.useLayoutEffect(()=>(s.yScale.setFormat(i??null),()=>s.yScale.setFormat(null)),[s,i]),W.useLayoutEffect(()=>(s.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{s.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[s,t,e]),W.useLayoutEffect(()=>{const a=n.current;if(a!==null)return Hr({chart:s,container:a,axis:"y"})},[s]),I.jsx("div",{ref:n,style:{position:"absolute",right:0,top:0,bottom:s.xAxisHeight,width:s.yAxisWidth,pointerEvents:"none"}})}function mc(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const s=i.getSeriesIdsByType("time",{visibleOnly:!0});return s.length>0?s[0]:null}function gc({seriesId:i,color:t,format:e,children:s}){const n=wt();W.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,a]=W.useState(0);W.useLayoutEffect(()=>{const y=()=>a(M=>M+1);return n.on("overlayChange",y),n.on("viewportChange",y),n.getSeriesIds().length>0&&a(M=>M+1),()=>{n.off("overlayChange",y),n.off("viewportChange",y)}},[n]);const o=mc(n,i),l=o!==null?n.getStackedLastValue(o):null,h=o!==null?n.getPreviousClose(o):null,c=n.yScale.getRange(),d=c.max-c.min,f=d<.1?6:d<10?4:d<1e3?2:0,m=W.useMemo(()=>{if(e)return e;const y=new Intl.NumberFormat("en-US",{minimumFractionDigits:f,maximumFractionDigits:f,useGrouping:!1});return M=>y.format(M)},[e,f]);if(!l||o===null)return null;const{value:g,isLive:p}=l,b=n.getTheme(),v=n.yScale.valueToY(g),S=h===null?"neutral":g>h?"up":g<h?"down":"neutral";let L;return p?t?L=t:L=S==="up"?b.yLabel.upBackground:S==="down"?b.yLabel.downBackground:b.yLabel.neutralBackground:L=b.axis.textColor,s?I.jsx(I.Fragment,{children:s({value:g,y:v,bgColor:L,isLive:p,direction:S,format:m})}):I.jsxs(I.Fragment,{children:[I.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:v,height:0,borderTop:`1px dashed ${L}`,opacity:.5,pointerEvents:"none",zIndex:2}}),I.jsx("div",{style:{position:"absolute",right:4,top:v,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:L,color:b.yLabel.textColor,fontSize:b.yLabel.fontSize,fontFamily:b.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:I.jsx(Ya,{value:g,format:m,spinDuration:350})})]})}exports.BarSeries=Ra;exports.CandlestickSeries=Hh;exports.ChartContainer=Ea;exports.ChartInstance=ba;exports.Crosshair=qh;exports.EdgeLoader=Kh;exports.InfoBar=Pa;exports.Legend=Fa;exports.LineSeries=Va;exports.Navigator=Ba;exports.NavigatorController=ka;exports.NumberFlow=Ya;exports.PieLegend=Da;exports.PieSeries=Zh;exports.PieTooltip=nc;exports.Sparkline=lc;exports.ThemeProvider=Ci;exports.TimeAxis=ja;exports.Title=za;exports.Tooltip=cc;exports.XAxis=ja;exports.YAxis=fc;exports.YLabel=gc;exports.andromeda=ph;exports.autoGradient=j;exports.ayuMirage=bh;exports.buildHoverSnapshots=_n;exports.buildLastSnapshots=Ia;exports.catppuccin=ca;exports.computeTooltipPosition=bs;exports.createTheme=at;exports.detectInterval=Yr;exports.dracula=vh;exports.formatCompact=Xe;exports.formatDate=jr;exports.formatPriceAdaptive=jn;exports.formatTime=gs;exports.githubLight=yh;exports.gruvbox=xh;exports.handwritten=wh;exports.hermite=zr;exports.highContrast=Sh;exports.isDarkBg=ra;exports.lavenderMist=Ch;exports.lightPink=Th;exports.materialPalenight=Lh;exports.minimalLight=Wh;exports.mintBreeze=Ah;exports.monokaiPro=Ph;exports.nightOwl=Fh;exports.normalizeTime=zt;exports.oneDarkPro=Bh;exports.panda=Dh;exports.parseAnimationTime=Br;exports.peachCream=zh;exports.quietLight=Eh;exports.resolveAxisFontSize=Er;exports.resolveAxisTextColor=Vr;exports.resolveCandlestickBodyColor=Dt;exports.rosePineDawn=Vh;exports.sandDune=Yh;exports.snap=Yi;exports.solarizedLight=jh;exports.spring=Fr;exports.useChartInstance=wt;exports.useCrosshairPosition=ys;exports.useLastYValue=Oh;exports.usePreviousClose=Xh;exports.useTheme=vs;exports.useVisibleRange=Wa;exports.useYRange=Aa;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),I=require("react/jsx-runtime");var fo=Object.defineProperty,Zr=i=>{throw TypeError(i)},mo=(i,t,e)=>t in i?fo(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,F=(i,t,e)=>mo(i,typeof t!="symbol"?t+"":t,e),_n=(i,t,e)=>t.has(i)||Zr("Cannot "+e),r=(i,t,e)=>(_n(i,t,"read from private field"),e?e.call(i):t.get(i)),v=(i,t,e)=>t.has(i)?Zr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),c=(i,t,e,s)=>(_n(i,t,"write to private field"),t.set(i,e),e),S=(i,t,e)=>(_n(i,t,"access private method"),e),Rn=(i,t,e,s)=>({set _(n){c(i,t,n)},get _(){return r(i,t,s)}});const go=22.999999999999996;var He,si,ni,lt,At,Jt,Nt,vi,An,Pn;class po{constructor(t){v(this,vi),v(this,He),v(this,si,0),v(this,ni,0),v(this,lt),v(this,At,go),v(this,Jt,-1),v(this,Nt),c(this,He,{from:t.initial.from,to:t.initial.to}),c(this,lt,{from:t.initial.from,to:t.initial.to}),c(this,Nt,{from:t.initial.from,to:t.initial.to})}get current(){return r(this,Nt)}get target(){return r(this,lt)}get animating(){const t=S(this,vi,Pn).call(this);return Math.abs(r(this,Nt).from-r(this,lt).from)>t||Math.abs(r(this,Nt).to-r(this,lt).to)>t||Math.abs(r(this,si))>t*r(this,At)||Math.abs(r(this,ni))>t*r(this,At)}retarget(t,e={}){const s=e.expandMs??200;if(s<=0){this.snap(t,e);return}const n=e.now??performance.now(),a=4.6/(s/1e3);if(r(this,Jt)<0){c(this,lt,{from:t.from,to:t.to}),c(this,At,a),c(this,Jt,n);return}const{x:o,vFrom:l,vTo:h}=S(this,vi,An).call(this,n);c(this,He,o),c(this,si,l),c(this,ni,h),c(this,At,a),c(this,lt,{from:t.from,to:t.to}),c(this,Jt,n),c(this,Nt,o)}snap(t,e={}){const s=e.now??performance.now();c(this,He,{from:t.from,to:t.to}),c(this,lt,{from:t.from,to:t.to}),c(this,si,0),c(this,ni,0),c(this,Jt,s),c(this,Nt,{from:t.from,to:t.to})}tick(t){if(r(this,Jt)<0)return c(this,Jt,t),!1;const{x:e,vFrom:s,vTo:n}=S(this,vi,An).call(this,t);c(this,Nt,e);const a=S(this,vi,Pn).call(this);return Math.abs(e.from-r(this,lt).from)<a&&Math.abs(e.to-r(this,lt).to)<a&&Math.abs(s)<a*r(this,At)&&Math.abs(n)<a*r(this,At)?(c(this,Nt,{from:r(this,lt).from,to:r(this,lt).to}),c(this,He,{from:r(this,lt).from,to:r(this,lt).to}),c(this,si,0),c(this,ni,0),c(this,Jt,t),!1):!0}}He=new WeakMap,si=new WeakMap,ni=new WeakMap,lt=new WeakMap,At=new WeakMap,Jt=new WeakMap,Nt=new WeakMap,vi=new WeakSet,An=function(i){const t=Math.max(0,(i-r(this,Jt))/1e3),e=Math.exp(-r(this,At)*t),s=r(this,He).from-r(this,lt).from,n=r(this,si)+r(this,At)*s,a=r(this,lt).from+(s+n*t)*e,o=(n-r(this,At)*(s+n*t))*e,l=r(this,He).to-r(this,lt).to,h=r(this,ni)+r(this,At)*l,u=r(this,lt).to+(l+h*t)*e,d=(h-r(this,At)*(l+h*t))*e;return{x:{from:a,to:u},vFrom:o,vTo:d}},Pn=function(){return Math.max(r(this,lt).to-r(this,lt).from,1)*1e-4};const Fn=250,gr=4.6/(Fn/1e3);var $e,ri,ai,ht,we,Me,Qt,Ut,yi,Bn,Dn;class bo{constructor(t){v(this,yi),v(this,$e),v(this,ri,0),v(this,ai,0),v(this,ht),v(this,we,gr),v(this,Me,gr),v(this,Qt,-1),v(this,Ut),c(this,$e,{min:t.initial.min,max:t.initial.max}),c(this,ht,{min:t.initial.min,max:t.initial.max}),c(this,Ut,{min:t.initial.min,max:t.initial.max})}get current(){return r(this,Ut)}get target(){return r(this,ht)}get animating(){const t=S(this,yi,Dn).call(this),e=Math.min(r(this,we),r(this,Me));return Math.abs(r(this,Ut).min-r(this,ht).min)>t||Math.abs(r(this,Ut).max-r(this,ht).max)>t||Math.abs(r(this,ri))>t*e||Math.abs(r(this,ai))>t*e}retarget(t,e={}){const s=e.now??performance.now(),n=e.expandMs??Fn,a=e.contractMs??Fn,o=4.6/(n/1e3),l=4.6/(a/1e3);if(r(this,Qt)<0){c(this,ht,{min:t.min,max:t.max}),c(this,we,o),c(this,Me,o),c(this,Qt,s);return}const{x:h,vMin:u,vMax:d}=S(this,yi,Bn).call(this,s);c(this,$e,h),c(this,ri,u),c(this,ai,d),c(this,we,t.min<h.min?o:l),c(this,Me,t.max>h.max?o:l),c(this,ht,{min:t.min,max:t.max}),c(this,Qt,s),c(this,Ut,h)}snap(t,e={}){const s=e.now??performance.now();c(this,$e,{min:t.min,max:t.max}),c(this,ht,{min:t.min,max:t.max}),c(this,ri,0),c(this,ai,0),c(this,Qt,s),c(this,Ut,{min:t.min,max:t.max})}tick(t){if(r(this,Qt)<0)return c(this,Qt,t),!1;const{x:e,vMin:s,vMax:n}=S(this,yi,Bn).call(this,t);c(this,Ut,e);const a=S(this,yi,Dn).call(this),o=Math.min(r(this,we),r(this,Me));return Math.abs(e.min-r(this,ht).min)<a&&Math.abs(e.max-r(this,ht).max)<a&&Math.abs(s)<a*o&&Math.abs(n)<a*o?(c(this,Ut,{min:r(this,ht).min,max:r(this,ht).max}),c(this,$e,{min:r(this,ht).min,max:r(this,ht).max}),c(this,ri,0),c(this,ai,0),c(this,Qt,t),!1):!0}}$e=new WeakMap,ri=new WeakMap,ai=new WeakMap,ht=new WeakMap,we=new WeakMap,Me=new WeakMap,Qt=new WeakMap,Ut=new WeakMap,yi=new WeakSet,Bn=function(i){const t=Math.max(0,(i-r(this,Qt))/1e3),e=Math.exp(-r(this,we)*t),s=Math.exp(-r(this,Me)*t),n=r(this,$e).min-r(this,ht).min,a=r(this,ri)+r(this,we)*n,o=r(this,ht).min+(n+a*t)*e,l=(a-r(this,we)*(n+a*t))*e,h=r(this,$e).max-r(this,ht).max,u=r(this,ai)+r(this,Me)*h,d=r(this,ht).max+(h+u*t)*s,f=(u-r(this,Me)*(h+u*t))*s;return{x:{min:o,max:d},vMin:l,vMax:f}},Dn=function(){return Math.max(r(this,ht).max-r(this,ht).min,1)*1e-4};function Jr(){return({initial:i})=>vo(i)?new bo({initial:i}):new po({initial:i})}function vo(i){return"min"in i&&"max"in i}const yo=/^(\d+(?:\.\d+)?)(ms|s)$/;function Qr(i){if(i===!1)return 0;if(typeof i=="number")return i;if(typeof i=="string"){const t=yo.exec(i);if(!t)throw new Error(`Invalid AnimationTime: ${JSON.stringify(i)}`);const e=Number.parseFloat(t[1]);return t[2]==="s"?e*1e3:e}throw new Error(`Invalid AnimationTime: ${String(i)}`)}function vt(i,t){return i===void 0?t:Qr(i)}const xo=100;var N,J,qi,le,sn,_t,pt,Xs,Ns,he,Us;class wo{constructor(t){v(this,pt),v(this,N),v(this,J),v(this,qi),v(this,le),v(this,sn),v(this,_t,!1),c(this,N,{transition:t.y.curve({initial:t.initial.yRange}),settleMs:t.y.settleMs,stickyMs:t.y.stickyMs,stickyFloorMs:t.y.stickyFloorMs,gestureMs:t.y.gestureMs,toggleMs:t.y.toggleMs,toggleUntil:0}),c(this,J,{transition:t.x.curve({initial:t.initial.xRange}),settleMs:t.x.settleMs,gestureMs:t.x.gestureMs,lastTarget:null,gestureUntil:0}),c(this,qi,t.computeXTarget),c(this,le,t.computeYTarget),c(this,sn,t.onWake)}onPointAppended(t){const e=t??performance.now();if(e<r(this,J).gestureUntil)return;const s=r(this,qi).call(this),n=s??r(this,J).transition.target,a=r(this,le).call(this,{xTarget:n});if(s===null&&a===null)return;const o=!r(this,_t),l=e<r(this,N).toggleUntil;s!==null&&S(this,pt,Xs).call(this,s,e,r(this,J).settleMs),a!==null&&!l&&r(this,N).transition.retarget(a,{now:e,expandMs:r(this,N).settleMs,contractMs:S(this,pt,Us).call(this,r(this,N).transition.current,a)}),S(this,pt,he).call(this,o)}onSeriesVisibilityChanged(t){const e=r(this,le).call(this,{xTarget:r(this,J).transition.target});if(e===null)return;const s=t??performance.now(),n=!r(this,_t);r(this,N).toggleMs>0?(r(this,N).transition.snap(r(this,N).transition.current,{now:s}),r(this,N).transition.retarget(e,{now:s,expandMs:r(this,N).toggleMs,contractMs:r(this,N).toggleMs}),r(this,N).toggleUntil=s+r(this,N).toggleMs):(r(this,N).transition.snap(e,{now:s}),r(this,N).toggleUntil=0),S(this,pt,he).call(this,n)}onPanZoom(t,e){const s=e??performance.now(),n=!r(this,_t);if(S(this,pt,Xs).call(this,t.xTarget,s,r(this,J).gestureMs),r(this,J).gestureUntil=s+xo,t.yAuto){const a=r(this,le).call(this,{xTarget:t.xTarget});a!==null&&r(this,N).transition.retarget(a,{now:s,expandMs:r(this,N).gestureMs,contractMs:r(this,N).gestureMs})}S(this,pt,he).call(this,n)}onAxisReconfig(t){const e=r(this,le).call(this,{xTarget:r(this,J).transition.target});if(e===null)return;const s=t??performance.now(),n=!r(this,_t);r(this,N).transition.snap(e,{now:s}),S(this,pt,he).call(this,n)}onProgrammaticZoom(t,e){r(this,J).gestureUntil=0;const s=r(this,le).call(this,{xTarget:t.xTarget}),n=e??performance.now(),a=!r(this,_t);if(t.xEase===!0){S(this,pt,Xs).call(this,t.xTarget,n,r(this,J).gestureMs),s!==null&&r(this,N).transition.retarget(s,{now:n,expandMs:r(this,N).settleMs,contractMs:S(this,pt,Us).call(this,r(this,N).transition.current,s)}),S(this,pt,he).call(this,a);return}S(this,pt,Ns).call(this,t.xTarget,n),s!==null&&r(this,N).transition.retarget(s,{now:n,expandMs:r(this,N).settleMs,contractMs:S(this,pt,Us).call(this,r(this,N).transition.current,s)}),S(this,pt,he).call(this,a)}onDataReplaced(t){const e=r(this,qi).call(this),s=r(this,le).call(this,{xTarget:e??r(this,J).transition.target});if(e===null&&s===null)return;const n=t??performance.now(),a=!r(this,_t);e!==null&&S(this,pt,Ns).call(this,e,n),s!==null&&r(this,N).transition.snap(s,{now:n}),S(this,pt,he).call(this,a)}snap(t,e){r(this,J).gestureUntil=0;const s=e??performance.now(),n=!r(this,_t);t.x!==void 0&&S(this,pt,Ns).call(this,t.x,s),t.y!==void 0&&r(this,N).transition.snap(t.y,{now:s}),S(this,pt,he).call(this,n)}tick(t){r(this,J).transition.tick(t),r(this,N).transition.tick(t);const e=r(this,J).transition.animating||r(this,N).transition.animating;return c(this,_t,e),{xRange:r(this,J).transition.current,yRange:r(this,N).transition.current,animating:e}}getAnimationState(){return{xRange:r(this,J).transition.current,yRange:r(this,N).transition.current,animating:r(this,J).transition.animating||r(this,N).transition.animating}}getTarget(){return{x:r(this,J).transition.target,y:r(this,N).transition.target}}get animating(){return r(this,J).transition.animating||r(this,N).transition.animating}get lastXTarget(){return r(this,J).lastTarget}setXSettleMs(t){r(this,J).settleMs=t}}N=new WeakMap,J=new WeakMap,qi=new WeakMap,le=new WeakMap,sn=new WeakMap,_t=new WeakMap,pt=new WeakSet,Xs=function(i,t,e){r(this,J).transition.retarget(i,{now:t,expandMs:e}),r(this,J).lastTarget={from:i.from,to:i.to}},Ns=function(i,t){r(this,J).transition.snap({from:i.from,to:i.to},{now:t}),r(this,J).lastTarget={from:i.from,to:i.to}},he=function(i){var t;i&&((t=r(this,sn))==null||t.call(this))},Us=function(i,t){const e=r(this,N).stickyMs;if(e<=0)return e;const s=Math.max(i.max-i.min,Number.EPSILON),n=Math.max(0,t.min-i.min),a=Math.max(0,i.max-t.max),o=Math.min(1,Math.max(n,a)/s),l=Math.min(r(this,N).stickyFloorMs,e);return Math.max(l,e*o)};function Mo(i){return new wo(i)}const Ys=250;var Dt,Oe,Xe,ct,$t,ke,Se,Ft,Ce,zn,bn,vn,ta;class ko{constructor(t){v(this,Ce),v(this,Dt),v(this,Oe,0),v(this,Xe,0),v(this,ct),v(this,$t,-1),v(this,ke,Ys/1e3),v(this,Se,Ys/1e3),v(this,Ft),c(this,Dt,{min:t.initial.min,max:t.initial.max}),c(this,ct,{min:t.initial.min,max:t.initial.max}),c(this,Ft,{min:t.initial.min,max:t.initial.max})}get current(){return r(this,Ft)}get target(){return r(this,ct)}get animating(){if(r(this,$t)<0)return!1;const t=S(this,Ce,ta).call(this);return Math.abs(r(this,Ft).min-r(this,ct).min)>t||Math.abs(r(this,Ft).max-r(this,ct).max)>t}retarget(t,e={}){const s=e.now??performance.now(),n=e.expandMs??Ys,a=e.contractMs??Ys;if(r(this,$t)<0){c(this,ct,{min:t.min,max:t.max}),c(this,ke,(t.min<r(this,Ft).min?n:a)/1e3),c(this,Se,(t.max>r(this,Ft).max?n:a)/1e3),c(this,$t,s);return}const{x:o,vMin:l,vMax:h}=S(this,Ce,zn).call(this,s);c(this,Dt,o),c(this,Oe,Math.sign(l)===Math.sign(t.min-o.min)?l:0),c(this,Xe,Math.sign(h)===Math.sign(t.max-o.max)?h:0),c(this,ke,(t.min<o.min?n:a)/1e3),c(this,Se,(t.max>o.max?n:a)/1e3),c(this,ct,{min:t.min,max:t.max}),c(this,$t,s),c(this,Ft,o)}snap(t,e={}){const s=e.now??performance.now();c(this,Dt,{min:t.min,max:t.max}),c(this,ct,{min:t.min,max:t.max}),c(this,Oe,0),c(this,Xe,0),c(this,$t,s),c(this,Ft,{min:t.min,max:t.max})}tick(t){if(r(this,$t)<0)return c(this,$t,t),!1;if(r(this,Dt).min===r(this,ct).min&&r(this,Dt).max===r(this,ct).max&&r(this,Oe)===0&&r(this,Xe)===0)return!1;const{x:e}=S(this,Ce,zn).call(this,t);c(this,Ft,e);const s=(t-r(this,$t))/1e3;return s>=r(this,ke)&&s>=r(this,Se)?(c(this,Ft,{min:r(this,ct).min,max:r(this,ct).max}),c(this,Dt,{min:r(this,ct).min,max:r(this,ct).max}),c(this,Oe,0),c(this,Xe,0),!1):!0}}Dt=new WeakMap,Oe=new WeakMap,Xe=new WeakMap,ct=new WeakMap,$t=new WeakMap,ke=new WeakMap,Se=new WeakMap,Ft=new WeakMap,Ce=new WeakSet,zn=function(i){const t=Math.max(0,(i-r(this,$t))/1e3),e=r(this,ke)>0?Math.min(1,t/r(this,ke)):1,s=r(this,Se)>0?Math.min(1,t/r(this,Se)):1,n=S(this,Ce,bn).call(this,r(this,Dt).min,r(this,Oe),r(this,ct).min,e,r(this,ke)),a=e>=1?0:S(this,Ce,vn).call(this,r(this,Dt).min,r(this,Oe),r(this,ct).min,e,r(this,ke)),o=S(this,Ce,bn).call(this,r(this,Dt).max,r(this,Xe),r(this,ct).max,s,r(this,Se)),l=s>=1?0:S(this,Ce,vn).call(this,r(this,Dt).max,r(this,Xe),r(this,ct).max,s,r(this,Se));return{x:{min:n,max:o},vMin:a,vMax:l}},bn=function(i,t,e,s,n){if(s>=1)return e;const a=s*s,o=a*s,l=2*o-3*a+1,h=o-2*a+s,u=-2*o+3*a;return l*i+h*n*t+u*e},vn=function(i,t,e,s,n){if(n<=0)return 0;const a=s*s,o=6*a-6*s,l=3*a-4*s+1,h=-6*a+6*s;return(o*i+l*n*t+h*e)/n},ta=function(){return Math.max(r(this,ct).max-r(this,ct).min,1)*1e-4};function ea(){return({initial:i})=>new ko({initial:i})}var Ze;class So{constructor(t){v(this,Ze),c(this,Ze,{...t.initial})}get current(){return r(this,Ze)}get target(){return r(this,Ze)}get animating(){return!1}retarget(t){c(this,Ze,{...t})}snap(t){c(this,Ze,{...t})}tick(){return!1}}Ze=new WeakMap;function Zi(){return({initial:i})=>new So({initial:i})}function ia(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.fontSize)!==void 0?i.axis.x.fontSize:t==="y"&&((s=i.axis.y)==null?void 0:s.fontSize)!==void 0?i.axis.y.fontSize:i.axis.fontSize}function sa(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.textColor)!==void 0?i.axis.x.textColor:t==="y"&&((s=i.axis.y)==null?void 0:s.textColor)!==void 0?i.axis.y.textColor:i.axis.textColor}function zt(i){return Array.isArray(i)?i.source??i[0]:i}const pi=6e4,Je=36e5,Ne=864e5,ce=365*Ne;function Et(i){return i instanceof Date?i.getTime():i}function Co(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:Et(t.time)}))}function To(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:Et(t.time)}))}function na(i){if(i.length<2)return Ne;const t=[];for(let e=1;e<Math.min(i.length,20);e++)t.push(i[e]-i[e-1]);return t.sort((e,s)=>e-s),t[Math.floor(t.length/2)]}function Rs(i,t){const e=new Date(i);return t>=ce?e.toLocaleDateString("en-US",{year:"numeric"}):t>=Ne?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=Je?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ra(i){return new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Lo(i){const t=[1e3,5e3,1e4,15e3,3e4],e=[pi,5*pi,10*pi,15*pi,30*pi],s=[Je,2*Je,4*Je,6*Je,12*Je],n=[Ne,7*Ne,30*Ne,90*Ne],a=[ce,2*ce,5*ce,10*ce,25*ce,50*ce,100*ce];return i<pi?[...t,...e,...s,...n,...a]:i<Je?[...e,...s,...n,...a]:i<Ne?[...s,...n,...a]:i<ce?[...n,...a]:a}const Io=.01;function aa(i){const{chart:t,container:e,axis:s}=i,n=new Map;let a=null;const o=s==="x"?t.timeScale.tickTracker:t.yScale.tickTracker;function l(){return s==="x"?t.timeScale.niceTickValues(t.getDataInterval()):{ticks:t.yScale.niceTickValues(),tickInterval:0}}function h(g,b){return s==="x"?Rs(g,b):t.yScale.formatY(g)}function u(g,b){if(s==="x"){g.style.left=`${t.timeScale.timeToX(b)}px`;return}g.style.top=`${t.yScale.valueToY(b)}px`}function d(g,b){g.style.color=sa(b,s),g.style.fontSize=`${ia(b,s)}px`,g.style.fontFamily=b.typography.fontFamily}function f(g,b,y){const M=document.createElement("span");return M.textContent=h(g,b),M.style.position="absolute",M.style.userSelect="none",d(M,y),M.style.willChange="opacity",s==="x"?(M.style.transform="translateX(-50%)",M.style.whiteSpace="nowrap"):(M.style.right="8px",M.style.transform="translateY(-50%)",M.style.fontVariantNumeric="tabular-nums"),e.appendChild(M),M}function m(){const g=t.getTheme(),b=g!==a;a=g;const{ticks:y,tickInterval:M}=l();o.setCurrentTicks(y);const{entries:L}=o.snapshot(),x=new Set;for(const{value:k,opacity:C}of L){if(C<=Io)continue;x.add(k);let A=n.get(k);if(A===void 0)A=f(k,M,g),n.set(k,A);else{const T=h(k,M);A.textContent!==T&&(A.textContent=T),b&&d(A,g)}u(A,k),A.style.opacity=String(C)}for(const[k,C]of n)x.has(k)||(C.remove(),n.delete(k))}function p(){t.getAnimationState().animating||m()}return m(),t.on("tickFrame",m),t.on("viewportChange",p),t.on("overlayChange",m),()=>{t.off("tickFrame",m),t.off("viewportChange",p),t.off("overlayChange",m);for(const g of n.values())g.remove();n.clear()}}const Gn=250,Kn=250,cn=Gn,qn=Kn,Zn=600,Jn=Gn,Qn=Kn,tr=Gn,er=Kn,Wo=250,Ro=250,Ao=200,Po=150,Fo=250,yn=2500,pr=500,Bo=100,Do=250,oa=250,la={line:{entryMs:0,smoothMs:0,pulseMs:0},candlestick:{entryMs:0,smoothMs:0},bar:{entryMs:0,smoothMs:0},pie:{entryMs:0,updateMs:0}};function zo(i){if(i!==null&&typeof i=="object")return{stickyMs:vt(i.max,yn),stickyFloorMs:vt(i.min,pr)};if(i===void 0)return{stickyMs:yn,stickyFloorMs:pr};const t=vt(i,yn);return{stickyMs:t,stickyFloorMs:t}}class nn{constructor(t,e,s){F(this,"axis"),F(this,"toggleMs"),F(this,"series"),this.axis=t,this.toggleMs=e,this.series=s}static resolve(t){if(t===!1)return new nn({y:{curve:Zi(),settleMs:0,stickyMs:0,stickyFloorMs:0,gestureMs:0},x:{curve:Zi(),settleMs:0,gestureMs:0},ticksMs:0},0,la);const e=t===!0||t===void 0?void 0:t,s=e==null?void 0:e.axis,n=s===!1?!1:s==null?void 0:s.y,a=s===!1?!1:s==null?void 0:s.x,o=s===!1?!1:s==null?void 0:s.ticks,l=e==null?void 0:e.toggle,h=e==null?void 0:e.series,u=n===!1?{curve:Zi(),settleMs:0,stickyMs:0,stickyFloorMs:0,gestureMs:0}:{curve:(n==null?void 0:n.curve)??ea(),settleMs:vt(n==null?void 0:n.settle,Fo),...zo(n==null?void 0:n.sticky),gestureMs:vt(n==null?void 0:n.gesture,Bo)},d=a===!1?{curve:Zi(),settleMs:0,gestureMs:0}:{curve:(a==null?void 0:a.curve)??Jr(),settleMs:vt(a==null?void 0:a.settle,Ao),gestureMs:vt(a==null?void 0:a.gesture,Po)},f=o===!1?0:vt(o,oa),m=vt(l,Do),p=Eo(h);return new nn({y:u,x:d,ticksMs:f},m,p)}defaults(t){if(t==="line"){const{entryMs:n,smoothMs:a,pulseMs:o}=this.series.line;return{entryMs:n,smoothMs:a,pulseMs:o}}if(t==="candlestick"){const{entryMs:n,smoothMs:a}=this.series.candlestick;return{entryMs:n,smoothMs:a}}if(t==="pie"){const{entryMs:n,updateMs:a}=this.series.pie;return{entryMs:n,updateMs:a}}const{entryMs:e,smoothMs:s}=this.series.bar;return{entryMs:e,smoothMs:s}}overrides(t){const e={};if(t==="line"){const{entryMs:a,smoothMs:o,pulseMs:l}=this.series.line;return a===0&&(e.entryMs=0),o===0&&(e.smoothMs=0),l===0&&(e.pulseMs=0),e}if(t==="pie")return e;const{entryMs:s,smoothMs:n}=t==="candlestick"?this.series.candlestick:this.series.bar;return s===0&&(e.entryMs=0),n===0&&(e.smoothMs=0),e}}function Eo(i){if(i===!1)return la;const t=i==null?void 0:i.line,e=i==null?void 0:i.candlestick,s=i==null?void 0:i.bar,n=i==null?void 0:i.pie,a=t===!1?{entryMs:0,smoothMs:0,pulseMs:0}:{entryMs:vt(t==null?void 0:t.entry,cn),smoothMs:vt(t==null?void 0:t.smooth,qn),pulseMs:vt(t==null?void 0:t.pulse,Zn)},o=e===!1?{entryMs:0,smoothMs:0}:{entryMs:vt(e==null?void 0:e.entry,Jn),smoothMs:vt(e==null?void 0:e.smooth,Qn)},l=s===!1?{entryMs:0,smoothMs:0}:{entryMs:vt(s==null?void 0:s.entry,tr),smoothMs:vt(s==null?void 0:s.smooth,er)},h=n===!1?{entryMs:0,updateMs:0}:{entryMs:vt(n==null?void 0:n.entry,Wo),updateMs:vt(n==null?void 0:n.update,Ro)};return{line:a,candlestick:o,bar:l,pie:h}}class un{constructor(){F(this,"listeners",new Map)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){var s;(s=this.listeners.get(t))==null||s.delete(e)}emit(t,...e){var s;(s=this.listeners.get(t))==null||s.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function br(i,t){const e=new Map;return new Proxy(i,{get(s,n){const a=Reflect.get(s,n,s);if(typeof a!="function")return a;const o=e.get(n);if(o)return o;const l=typeof n=="string"?n:String(n),h=a,u=(...d)=>(t.set(l,(t.get(l)??0)+1),h.apply(s,d));return e.set(n,u),u},set(s,n,a){return Reflect.set(s,n,a,s)}})}function vr(i,t,e){const s=document.createElement("canvas");return s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.display="block",s.style.zIndex=String(t),i.appendChild(s),s}class Vo extends un{constructor(t,e){super(),F(this,"mainCanvas"),F(this,"mainCtx"),F(this,"overlayCanvas"),F(this,"overlayCtx"),F(this,"resizeObserver"),F(this,"_size"),F(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=vr(t,0),this.overlayCanvas=vr(t,1);const s=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!s||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?br(s,e.drawCallsMain):s,this.overlayCtx=e?br(n,e.drawCallsOverlay):n;const a=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:a,verticalPixelRatio:a},this.resizeObserver=new ResizeObserver(l=>{this.handleResize(l[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const o=t.getBoundingClientRect();if(o.width>0&&o.height>0){const l=window.devicePixelRatio||1,h=l,u=Math.round(o.width*l),d=Math.round(o.height*h);this.mainCanvas.width=u,this.mainCanvas.height=d,this.overlayCanvas.width=u,this.overlayCanvas.height=d,this._size={media:{width:o.width,height:o.height},bitmap:{width:u,height:d},horizontalPixelRatio:u/o.width,verticalPixelRatio:d/o.height}}}handleResize(t){var e,s;let n,a,o,l;if(this.supportsDevicePixelContentBox&&(e=t.devicePixelContentBoxSize)!=null&&e[0]){const d=t.devicePixelContentBoxSize[0];n=d.inlineSize,a=d.blockSize;const f=t.contentBoxSize[0];o=f.inlineSize,l=f.blockSize}else{const d=(s=t.contentBoxSize)==null?void 0:s[0];if(d)o=d.inlineSize,l=d.blockSize;else{const m=t.contentRect;o=m.width,l=m.height}const f=window.devicePixelRatio||1;n=Math.round(o*f),a=Math.round(l*f)}if(n===0||a===0)return;this.mainCanvas.width=n,this.mainCanvas.height=a,this.overlayCanvas.width=n,this.overlayCanvas.height=a;const h=n/o,u=a/l;this._size={media:{width:o,height:l},bitmap:{width:n,height:a},horizontalPixelRatio:h,verticalPixelRatio:u},this.emit("resize",this._size)}get size(){return this._size}useMainLayer(t){this.mainCtx.save(),t({context:this.mainCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.mainCtx.restore()}useOverlayLayer(t){const{width:e,height:s}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,s),this.overlayCtx.save(),t({context:this.overlayCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.overlayCtx.restore()}get canvas(){return this.overlayCanvas}destroy(){this.resizeObserver.disconnect(),this.mainCanvas.remove(),this.overlayCanvas.remove(),this.removeAllListeners()}}const Yo=3,jo=8,yr=900,Ho=24,$o=11,Oo=10,Xo=18;function No(i){const{state:t}=i;if(t==="idle"||t==="has-more")return;const e=i.timeScale.timeToX(i.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){Uo(i,e);return}t==="no-data"&&_o(i,e)}}function Uo({scope:i,theme:t,chartMediaHeight:e,side:s,now:n},a){const{context:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i,u=Yo*l,d=jo*l,f=Ho*l,m=a*l,p=s==="right"?m+f:m-f,g=e/2*h,b=n%yr/yr,y=Math.floor(b*3),M=ha(t.axis.textColor??"#787b86",.3),L=t.axis.textColor??"#787b86";o.save();for(let x=0;x<3;x++){const k=(x-1)*d,C=p+k;o.beginPath(),o.arc(C,g,u,0,Math.PI*2),o.fillStyle=x===y?L:M,o.fill()}o.restore()}function _o({scope:i,theme:t,chartMediaHeight:e,side:s},n){const{context:a,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.round(n*o)+.5;a.save(),a.strokeStyle=ha(t.axis.textColor??"#787b86",.6),a.lineWidth=1,a.setLineDash([4*o,4*o]),a.beginPath(),a.moveTo(h,0),a.lineTo(h,e*l),a.stroke(),a.setLineDash([]);const u=Oo*o,d=s==="right"?h-u:h+u,f=Xo*l;a.fillStyle=t.axis.textColor??"#787b86",a.font=`${$o*o}px ${t.typography.fontFamily}`,a.textAlign=s==="right"?"right":"left",a.textBaseline="top",a.fillText("No more data",d,f),a.restore()}function ha(i,t){const e=/^#([0-9a-f]{6})$/i.exec(i.trim());if(!e)return i;const s=parseInt(e[1].slice(0,2),16),n=parseInt(e[1].slice(2,4),16),a=parseInt(e[1].slice(4,6),16);return`rgba(${s}, ${n}, ${a}, ${t})`}function Go(i){const t=performance.now();for(const e of["left","right"]){const s=i.edgeStates[e];if(s==="idle"||s==="has-more")continue;const n=i.resolveBoundary(e);n!==null&&No({scope:i.scope,timeScale:i.timeScale,theme:i.theme,chartMediaHeight:i.chartMediaHeight,boundaryTime:n,side:e,state:s,now:t})}}function Ko(i,t,e){return t!==null?t:i==="left"?e.first??null:e.last??null}function Ge(i,t,e,s){return typeof i=="object"?i.intervals*e:s<=0?0:i/s*t}function qo(i){const{firstTime:t,lastTime:e,dataInterval:s,maxVisibleBars:n,chartWidth:a,padding:o}=i,l=n*s,h=e-t,u=h>0?h:s*10,d=Ge(o.right,u,s,a),f=Ge(o.left,u,s,a);let m=e+d,p=t-f;return m-p>l&&(m=e+d,p=m-l),{from:p,to:m}}const xr=i=>"close"in i?i.close:i.value;function ca(i,t,e){const s=t.find(u=>u.id===i);if(!s)return null;const n=s.renderer;if(n.kind==="pie")return null;const a=n.getLastDataPoint();if(!a)return null;const{from:o,to:l}=e;if(a.time>=o&&a.time<=l)return{value:xr(a),isLive:!0};const h=n.getVisibleDataPoints(o,l);return h.length===0?null:{value:xr(h[h.length-1]),isLive:!1}}function Zo(i,t,e){var s,n;const a=t.find(l=>l.id===i);return a?((n=(s=a.renderer).getStackedLastValue)==null?void 0:n.call(s))||ca(i,t,e):null}function Jo(i,t){const e=t.find(a=>a.id===i);if(!e)return null;const s=e.renderer;if(s.kind==="pie")return null;const n=s.getSecondLastDataPoint();return n?"close"in n?n.close:n.value:null}const Qo=5e3,tl=2e3,el=30;function xn(i,t,e){let s=0;for(;s<t.length&&t[s]<e;)s++;s>0&&(i.splice(0,s),t.splice(0,s))}function wn(i,t,e){const s=i.length-e;s>0&&(i.splice(0,s),t.splice(0,s))}function Mn(i){if(i.length===0)return{last:0,p50:0,p95:0};const t=[...i].sort((e,s)=>e-s);return{last:i[i.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function wr(i){if(i.length<2)return 0;const t=i[i.length-1]-i[0];return t<=0?0:(i.length-1)*1e3/t}function Mr(i){const t={};for(const[e,s]of i)t[e]=s;return t}class kn{constructor(t={}){F(this,"drawCallsMain",new Map),F(this,"drawCallsOverlay",new Map),F(this,"mainMs",[]),F(this,"overlayMs",[]),F(this,"mainStamps",[]),F(this,"overlayStamps",[]),F(this,"perSeriesMs",new Map),F(this,"perSeriesStamps",new Map),F(this,"listeners",new Set),F(this,"windowMs"),F(this,"maxSamples"),F(this,"heapInterval"),F(this,"heapCounter",0),F(this,"heapMb",null),F(this,"mainFrameCount",0),F(this,"overlayFrameCount",0),F(this,"lastStamp",0),this.windowMs=t.windowMs??Qo,this.maxSamples=t.maxSamples??tl,this.heapInterval=t.heapSampleEveryNFrames??el}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,s){if(this.lastStamp=s,t==="main"?(this.mainMs.push(e),this.mainStamps.push(s),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(s),this.overlayFrameCount++),this.trimAll(s),this.listeners.size>0){const n=this.getStats();for(const a of this.listeners)a(n)}}recordSeries(t,e,s=this.lastStamp){let n=this.perSeriesMs.get(t),a=this.perSeriesStamps.get(t);(!n||!a)&&(n=[],a=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,a)),n.push(e),a.push(s)}trimAll(t){const e=t-this.windowMs;xn(this.mainMs,this.mainStamps,e),xn(this.overlayMs,this.overlayStamps,e),wn(this.mainMs,this.mainStamps,this.maxSamples),wn(this.overlayMs,this.overlayStamps,this.maxSamples);for(const s of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(s),a=this.perSeriesStamps.get(s);!n||!a||(xn(n,a,e),wn(n,a,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[e,s]of this.perSeriesMs)t[e]=Mn(s);return{mainRendersPerSec:wr(this.mainStamps),overlayRendersPerSec:wr(this.overlayStamps),mainFrameMs:Mn(this.mainMs),overlayFrameMs:Mn(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:Mr(this.drawCallsMain),overlay:Mr(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}const il=200,sl=2;function nl(i){const{range:t,chartWidth:e,dataInterval:s,padding:n,dataStart:a,dataEnd:o}=i,l=d=>typeof d=="object"||d===0||e>0,h=a!==null&&l(n.left)?a-Ge(n.left,t,s,e):null,u=o!==null&&l(n.right)?o+Ge(n.right,t,s,e):null;return{left:h,right:u}}function rl(i){return 10*i}function al(i){const{dataInterval:t,padding:e,dataStart:s,dataEnd:n}=i;if(s===null||n===null)return null;const a=n-s;if(a<=0)return null;const o=typeof e.left=="object"?e.left.intervals*t:null,l=typeof e.right=="object"?e.right.intervals*t:null;return o!==null||l!==null?a+(o??0)+(l??0):a+t*5}function ol(i){return i*.5}function ll(i){const{currentLogical:t,timeDelta:e,chartWidth:s,dataInterval:n,padding:a,dataStart:o,dataEnd:l}=i,{from:h,to:u}=t;if(u-h<=0)return{newLogical:null,autoScrollOff:!1,edgeReached:null};let d=h+e,f=u+e,m=null;if(l!==null&&d>l){const y=d-l;d-=y,f-=y,m={side:"right",overshoot:y,boundaryTime:l}}if(o!==null&&f<o){const y=o-f;d+=y,f+=y,m={side:"left",overshoot:y,boundaryTime:o}}const p=l!==null&&(typeof a.right=="object"||a.right===0||s>0)?Ge(a.right,f-d,n,s):0,g=ol(n),b=l!==null&&Math.abs(f-(l+p))<g;return{newLogical:{from:d,to:f},autoScrollOff:!b,edgeReached:m}}function hl(i){const{currentLogical:t,centerTime:e,factor:s,chartWidth:n,dataInterval:a,padding:o,dataStart:l,dataEnd:h}=i,{from:u,to:d}=t,f=d-u;if(f<=0)return{newLogical:null};const m=rl(a),{left:p,right:g}=nl({range:f,chartWidth:n,dataInterval:a,padding:o,dataStart:l,dataEnd:h}),b=p!==null&&g!==null?g-p:al({dataInterval:a,padding:o,dataStart:l,dataEnd:h});let y=f*s;y<m&&(y=m),s>1&&b!==null&&y>b&&(y=b);const M=(e-u)/f,L=e-M*y,x=L+y;return{newLogical:{from:L,to:x}}}function cl(i){if(!i)return{monitor:null,ownsMonitor:!1,showHud:!1};if(i===!0)return{monitor:new kn,ownsMonitor:!0,showHud:!0};if(i instanceof kn)return{monitor:i,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...s}=i,n=e!==void 0;return{monitor:e??new kn(s),ownsMonitor:!n,showHud:t??!n}}const js={top:20,bottom:20,right:{intervals:3},left:{intervals:0}};function kr(i){return{top:(i==null?void 0:i.top)??js.top,bottom:(i==null?void 0:i.bottom)??js.bottom,right:(i==null?void 0:i.right)??js.right,left:(i==null?void 0:i.left)??js.left}}function Sr(i,t){return typeof i=="number"&&typeof t=="number"?i===t:typeof i=="object"&&typeof t=="object"?i.intervals===t.intervals:!1}function ul(i){return i===void 0||!Number.isFinite(i)?il:Math.max(sl,Math.floor(i))}const dl=5e3,fl=5,Cr=.3,ml=5e3;var xi,Pe;class gl{constructor(){v(this,xi,0),v(this,Pe,0)}observe(t){if(r(this,xi)>0){const e=t-r(this,xi);e>=fl&&e<dl&&c(this,Pe,r(this,Pe)===0?e:Cr*e+(1-Cr)*r(this,Pe))}c(this,xi,t)}pause(){c(this,xi,0)}pickSettleMs(t,e=3){return r(this,Pe)===0?t:Math.min(ml,Math.max(t,r(this,Pe)*e))}get emaMs(){return r(this,Pe)}}xi=new WeakMap,Pe=new WeakMap;const pl=.5,bl=4;function vl(i){const{currentLogical:t,lastTime:e,prevDataEnd:s,dataInterval:n,paddingRight:a,chartWidth:o,holdUntilFilled:l}=i,{from:h,to:u}=t,d=u-h;if(d<=0)return{newLogical:null,releaseHold:!1,reengageAutoScroll:!1};const f=Ge(a,d,n,o);if(l){const x=n*.01;if(e+f<=u+x)return{newLogical:null,releaseHold:!1,reengageAutoScroll:!0}}const m=s!==null?u-s:f,p=Math.max(0,Math.min(f,m)),g=e+p,b=g-d,y=pl*n,M=o>0?bl/o*d:y,L=Math.min(y,M);return Math.abs(g-u)<L?{newLogical:null,releaseHold:l,reengageAutoScroll:!0}:{newLogical:{from:b,to:g},releaseHold:l,reengageAutoScroll:!0}}function yl(i,t,e){let s=1/0,n=-1/0;for(const a of t){if(!a.visible||a.renderer.kind==="pie")continue;const o=a.renderer.getValueRange(i.from,i.to);o&&(o.max>n&&(n=o.max),o.min<s&&(s=o.min),e==null||e.push(o.min,o.max))}return s===1/0||n===-1/0?null:{min:s,max:n}}function Tr(i,t,e,s,n){if(i===void 0||i==="auto")return t;if(typeof i=="number")return i;if(typeof i=="function")return i(s);const a=String(i).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const o=a[1]==="-"?-1:1,l=parseFloat(a[2])/100,h=Math.abs(e-t)||Math.abs(t)||1;return t+o*l*h*(n==="max"?1:-1)}return t}function xl(i,t,e,s){const{context:n,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.max(1,Math.round(l)),u=Math.max(1,Math.round(o));n.strokeStyle=s.crosshair.color,n.lineWidth=Math.max(h,u),n.setLineDash([4*o,4*o]);const d=Math.round(t)+(u%2===1?.5:0),f=Math.round(e)+(h%2===1?.5:0);n.beginPath(),n.moveTo(d,0),n.lineTo(d,a.height),n.moveTo(0,f),n.lineTo(a.width,f),n.stroke(),n.setLineDash([])}function wl({scope:i,timeScale:t,yScale:e,theme:s,yTicks:n,timeTicks:a}){const{context:o,bitmapSize:l,horizontalPixelRatio:h,verticalPixelRatio:u}=i;o.save(),o.strokeStyle=s.grid.color,s.grid.style==="dashed"?o.setLineDash([4*h,4*h]):s.grid.style==="dotted"&&o.setLineDash([1*h,3*h]);const d=Math.max(1,Math.round(u)),f=d%2===1?.5:0;o.lineWidth=d;for(const{value:g,opacity:b}of n.entries){if(b<=.01)continue;const y=Math.round(e.valueToBitmapY(g))+f;o.globalAlpha=b,o.beginPath(),o.moveTo(0,y),o.lineTo(l.width,y),o.stroke()}const m=Math.max(1,Math.round(h)),p=m%2===1?.5:0;o.lineWidth=m;for(const{value:g,opacity:b}of a.entries){if(b<=.01)continue;const y=Math.round(t.timeToBitmapX(g))+p;o.globalAlpha=b,o.beginPath(),o.moveTo(y,0),o.lineTo(y,l.height),o.stroke()}o.restore()}function Ss(i,t,e){return Math.max(t,Math.min(e,i))}function se(i,t,e){return i+(t-i)*e}function Lr(i,t,e,s){const n=Math.exp(-e*s);return t+(i-t)*n}function Sn(i,t,e){let s=0,n=i.length-1;for(;s<=n;){const a=s+n>>>1,o=e(i[a]);if(o<t)s=a+1;else if(o>t)n=a-1;else return a}return s}class ua extends un{constructor(){super(...arguments),F(this,"data",[]),F(this,"_visible",!0),F(this,"cachedRange",null),F(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let s=1;s<t.length;s++)if(t[s].time<t[s-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((s,n)=>s.time-n.time),this.cachedRange=null,this.emit("update")}append(t){if(this.data.length>0&&t.time<=this.data[this.data.length-1].time){this.updateLast(t);return}this.data.push(t),this.cachedRange=null,this.emit("update")}updateLast(t){this.data.length!==0&&(this.data[this.data.length-1]=t,this.cachedRange=null,this.emit("update"))}trimStart(t){if(!(t<=0||this.data.length===0)){if(t>=this.data.length){this.data=[],this.cachedRange=null,this.emit("update");return}this.data=this.data.slice(t),this.cachedRange=null,this.emit("update")}}getAll(){return this.data}getVisibleData(t,e){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===e)return this.cachedResult;const s=Math.max(0,Sn(this.data,t,a=>a.time)-1),n=Math.min(this.data.length,Sn(this.data,e,a=>a.time)+1);return this.cachedResult=this.data.slice(s,n),this.cachedRange={from:t,to:e},this.cachedResult}first(){return this.data[0]}last(){return this.data[this.data.length-1]}get length(){return this.data.length}isEmpty(){return this.data.length===0}findNearest(t,e){if(this.data.length===0)return null;const s=Sn(this.data,t,o=>o.time);let n=null,a=e;for(let o=Math.max(0,s-1);o<=Math.min(this.data.length-1,s+1);o++){const l=Math.abs(this.data[o].time-t);l<=a&&(a=l,n=this.data[o])}return n}}class Ml{constructor(t,e,s){F(this,"dragging",!1),F(this,"lastX",0),this.target=t,this.timeScale=e,this.canvas=s}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const e=t.clientX-this.lastX;this.lastX=t.clientX;const s=this.timeScale.pixelDeltaToTimeDelta(-e);this.target.pan(s,this.timeScale.getMediaWidth())}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair")}isDragging(){return this.dragging}}class kl{constructor(t,e){this.target=t,this.timeScale=e}handleWheel(t){t.preventDefault();const e=Sl(t.deltaY,t.deltaMode),s=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),a=Math.min(t.offsetX,n),o=this.timeScale.xToTime(a);this.target.zoomAt(o,s,n)}cancelPendingRebound(){}}function Sl(i,t){return t===WheelEvent.DOM_DELTA_LINE?i*8:t===WheelEvent.DOM_DELTA_PAGE?i*24:i}function Ir(i,t){const e=i.clientX-t.clientX,s=i.clientY-t.clientY;return Math.hypot(e,s)}class Cl extends un{constructor(t,e,s,n){super(),F(this,"zoom"),F(this,"pan"),F(this,"canvas"),F(this,"timeScale"),F(this,"yScale"),F(this,"target"),F(this,"onWheel",a=>{this.zoom.handleWheel(a)}),F(this,"onMouseDown",a=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(a)}),F(this,"onMouseMove",a=>{this.pan.isDragging()&&this.pan.handleMouseMove(a),this.emitCrosshair(a.offsetX,a.offsetY)}),F(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),F(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),F(this,"onDblClick",()=>{}),F(this,"lastTouchDist",0),F(this,"touchCount",0),F(this,"onTouchStart",a=>{a.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=a.touches.length,a.touches.length===1?this.pan.handleMouseDown({button:0,clientX:a.touches[0].clientX}):a.touches.length===2&&(this.lastTouchDist=Ir(a.touches[0],a.touches[1]))}),F(this,"onTouchMove",a=>{if(a.preventDefault(),a.touches.length===1&&this.touchCount===1)this.pan.handleMouseMove({clientX:a.touches[0].clientX});else if(a.touches.length===2){const o=Ir(a.touches[0],a.touches[1]),l=(a.touches[0].clientX+a.touches[1].clientX)/2,h=this.canvas.getBoundingClientRect();if(o>0&&this.lastTouchDist>0){const u=Ss(this.lastTouchDist/o,.1,10),d=this.timeScale.xToTime(l-h.left);this.target.zoomAt(d,u,this.timeScale.getMediaWidth())}this.lastTouchDist=o}}),F(this,"onTouchEnd",a=>{if(a.touches.length===0){this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null);return}a.touches.length===1&&(this.touchCount=1,this.lastTouchDist=0,this.pan.handleMouseDown({button:0,clientX:a.touches[0].clientX}))}),F(this,"onTouchCancel",()=>{this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null)}),this.canvas=t,this.target=e,this.timeScale=s,this.yScale=n,this.zoom=new kl(e,s),this.pan=new Ml(e,s,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd),t.addEventListener("touchcancel",this.onTouchCancel)}emitCrosshair(t,e){const s=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:s,y:n})}destroy(){this.zoom.cancelPendingRebound(),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.canvas.removeEventListener("touchcancel",this.onTouchCancel),this.removeAllListeners()}}const Tl=100,Ll={position:"absolute",top:"4px",right:"4px",padding:"4px 6px",background:"rgba(0, 0, 0, 0.6)",color:"#e0e0e0",font:"11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace",borderRadius:"3px",pointerEvents:"none",zIndex:"20",whiteSpace:"pre",letterSpacing:"0.01em"};function Wr(i){let t=0;for(const e of Object.values(i))t+=e;return t}const Ws=9,ir=7,ae=6,sr=9;function Il(i,t){return Math.round(i*t).toLocaleString("en-US")}function Rr(i,t,e,s,n){return[i.padEnd(Ws),t.toFixed(1).padStart(ir),e.toFixed(2).padStart(ae),s.toFixed(2).padStart(ae),Il(n,t).padStart(sr)].join(" ")}function Ar(i){return[i.padEnd(Ws),"—".padStart(ir),"—".padStart(ae),"—".padStart(ae),"idle".padStart(sr)].join(" ")}function Wl(){return["".padEnd(Ws),"FPS".padStart(ir),"ms".padStart(ae),"worst".padStart(ae),"calls/s".padStart(sr)].join(" ")}function Rl(i){const t=Wr(i.drawCalls.main),e=Wr(i.drawCalls.overlay),s=i.frameCount.main===0?Ar("Main"):Rr("Main",i.mainRendersPerSec,i.mainFrameMs.last,i.mainFrameMs.p95,t),n=i.frameCount.overlay===0?Ar("Overlay"):Rr("Overlay",i.overlayRendersPerSec,i.overlayFrameMs.last,i.overlayFrameMs.p95,e),a=[Wl(),s,n],o=Object.keys(i.perSeries);if(o.length>1){a.push(""),a.push("Per series (main pass)"),a.push(["".padEnd(Ws),"ms".padStart(ae),"worst".padStart(ae)].join(" "));for(const l of o){const h=i.perSeries[l];a.push([` ${l}`.padEnd(Ws),h.last.toFixed(2).padStart(ae),h.p95.toFixed(2).padStart(ae)].join(" "))}}return a.join(`
2
+ `)}class Al{constructor(t,e,s=Tl){F(this,"element"),F(this,"unsubscribe"),F(this,"updateIntervalMs"),F(this,"lastUpdate",0),this.updateIntervalMs=s;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,Ll),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=Rl(t))}}class Hs{constructor(t){F(this,"dirty",!1),F(this,"rafId",null),F(this,"callback"),F(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const hi=i=>1-(1-i)**3;var ue,wi,de,_s,Mi,Ji,Gs,Qi,Ks,ts,Fe;class dn{constructor(t){v(this,ue),v(this,wi),v(this,de),v(this,_s,0),v(this,Mi),v(this,Ji),v(this,Gs),v(this,Qi),v(this,Ks),v(this,ts),v(this,Fe,!1),c(this,ue,t.initial),c(this,wi,t.initial),c(this,de,t.initial),c(this,Gs,t.duration),c(this,Mi,t.duration),c(this,Qi,t.easing??hi),c(this,Ji,r(this,Qi)),c(this,Ks,t.lerp),c(this,ts,t.equals??Object.is)}get current(){return r(this,ue)}get target(){return r(this,de)}get animating(){return r(this,Fe)}snap(t){c(this,ue,t),c(this,wi,t),c(this,de,t),c(this,Fe,!1)}setTarget(t,e={}){const s=e.now??performance.now();if(r(this,Fe)){if(r(this,ts).call(this,t,r(this,de)))return;this.tick(s)}else if(r(this,ts).call(this,t,r(this,ue)))return;const n=e.duration??r(this,Gs);if(n<=0){this.snap(t);return}c(this,wi,r(this,ue)),c(this,de,t),c(this,Mi,n),c(this,Ji,e.easing??r(this,Qi)),c(this,_s,s),c(this,Fe,!0)}tick(t){if(!r(this,Fe))return!1;const e=t-r(this,_s);if(e>=r(this,Mi))return c(this,ue,r(this,de)),c(this,Fe,!1),!1;const s=e<=0?0:e/r(this,Mi);return c(this,ue,r(this,Ks).call(this,r(this,wi),r(this,de),r(this,Ji).call(this,s))),!0}}ue=new WeakMap,wi=new WeakMap,de=new WeakMap,_s=new WeakMap,Mi=new WeakMap,Ji=new WeakMap,Gs=new WeakMap,Qi=new WeakMap,Ks=new WeakMap,ts=new WeakMap,Fe=new WeakMap;const da=250,Pr=4.6/(da/1e3);var oi,Vi,Rt,Ue,te,Be,es,En,fa;class ki{constructor(t){v(this,es),v(this,oi),v(this,Vi,0),v(this,Rt),v(this,Ue,Pr),v(this,te,-1),v(this,Be),c(this,oi,t),c(this,Rt,t),c(this,Be,t)}get current(){return r(this,Be)}get target(){return r(this,Rt)}retarget(t,e={}){const s=e.now??performance.now(),n=e.settleMs??da,a=n>0?4.6/(n/1e3):Pr;if(r(this,te)<0){c(this,Rt,t),c(this,Ue,a),c(this,te,s);return}const{x:o,v:l}=S(this,es,En).call(this,s);c(this,oi,o),c(this,Vi,l),c(this,Ue,a),c(this,Rt,t),c(this,te,s),c(this,Be,o)}snap(t,e={}){const s=e.now??performance.now();c(this,oi,t),c(this,Rt,t),c(this,Vi,0),c(this,te,s),c(this,Be,t)}tick(t){if(r(this,te)<0)return c(this,te,t),!1;const{x:e,v:s}=S(this,es,En).call(this,t);c(this,Be,e);const n=S(this,es,fa).call(this);return Math.abs(e-r(this,Rt))<n&&Math.abs(s)<n*r(this,Ue)?(c(this,Be,r(this,Rt)),c(this,oi,r(this,Rt)),c(this,Vi,0),c(this,te,t),!1):!0}}oi=new WeakMap,Vi=new WeakMap,Rt=new WeakMap,Ue=new WeakMap,te=new WeakMap,Be=new WeakMap,es=new WeakSet,En=function(i){const t=Math.max(0,(i-r(this,te))/1e3),e=Math.exp(-r(this,Ue)*t),s=r(this,oi)-r(this,Rt),n=r(this,Vi)+r(this,Ue)*s,a=r(this,Rt)+(s+n*t)*e,o=(n-r(this,Ue)*(s+n*t))*e;return{x:a,v:o}},fa=function(){return Math.max(Math.abs(r(this,Rt)),1)*1e-4};const Pl={entries:[],isAnimating:!1},Fl=(i,t,e)=>i+(t-i)*e;function Bl(i,t){if(i===t)return!0;if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return!1;return!0}var fe,is,Gt,Si,Ci;class ma{constructor(t={}){v(this,fe,[]),v(this,is,[]),v(this,Gt,new Map),v(this,Si),v(this,Ci,!1),c(this,Si,t.fadeMs??oa)}setCurrentTicks(t){if(Bl(t,r(this,fe)))return;const e=r(this,Ci)?r(this,Si):0,s=new Set(t),n=new Set(r(this,fe));for(const a of t){if(n.has(a))continue;let o=r(this,Gt).get(a);o===void 0&&(o=new dn({initial:0,duration:r(this,Si),lerp:Fl}),r(this,Gt).set(a,o)),o.setTarget(1,{duration:e})}for(const a of r(this,fe)){if(s.has(a))continue;const o=r(this,Gt).get(a);o!==void 0&&o.setTarget(0,{duration:e})}c(this,is,r(this,fe)),c(this,fe,t.slice())}tick(t){let e=!1;for(const[s,n]of r(this,Gt)){if(n.tick(t)){e=!0;continue}n.current===0&&r(this,Gt).delete(s)}return e}snapshot(){if(r(this,Gt).size===0)return Pl;const t=[];let e=!1;for(const[s,n]of r(this,Gt)){const a=n.current;a<=0||(t.push({value:s,opacity:a}),n.animating&&(e=!0))}return{entries:t,isAnimating:e}}getCurrentTicks(){return r(this,fe)}getPreviousTicks(){return r(this,is)}setFadeMs(t){c(this,Si,t)}markArmed(){c(this,Ci,!0)}get isArmed(){return r(this,Ci)}reset(){c(this,fe,[]),c(this,is,[]),r(this,Gt).clear(),c(this,Ci,!1)}}fe=new WeakMap,is=new WeakMap,Gt=new WeakMap,Si=new WeakMap,Ci=new WeakMap;const Dl=50,zl=80;class ga{constructor(){F(this,"tickTracker",new ma),F(this,"from",0),F(this,"to",0),F(this,"width",1),F(this,"pixelRatio",1),F(this,"dataInterval",null),F(this,"labelCountHintValue",null),F(this,"minSpacingValue",null),F(this,"resolvedInterval",null),F(this,"lastInterval",null),F(this,"lastWant",null),F(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??zl}update(t,e,s,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=s,n!==void 0&&n>0){const a=Fr(n);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=El(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Vl(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const o=Fr(t);this.lastBucketKey!==null&&this.lastBucketKey!==o&&this.resetHysteresis(),this.lastBucketKey=o,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,s=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(Dl,Math.floor((this.to-s)/e)+1)),a=[];for(let o=0;o<n;o++)a.push(s+o*e);return{ticks:a,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=Lo(this.dataInterval),e=this.to-this.from,s=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,s)}else n=s;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=s;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let a=t[t.length-1],o=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){a=t[l],o=l;break}if(this.labelCountHint!=null&&o>0&&this.countTicks(a)<this.labelCountHint){const l=t[o-1];l>=s&&(a=l)}this.resolvedInterval=a,this.lastInterval=a,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function Fr(i){return i<6e4?0:i<36e5?1:i<864e5?2:3}function El(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Vl(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function pa(i){const t=Math.abs(i);if(t===0)return"0";if(t<1e-12)return i.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),s=Math.min(12,e+4),n=i.toFixed(s);return n.includes(".")?n.replace(/\.?0+$/,""):n}function ba(i){return Number.isNaN(i)?"—":i===1/0?"∞":i===-1/0?"−∞":null}function Ke(i,t){const e=ba(i);if(e!==null)return e;const s=Math.abs(i),n=(t==null?void 0:t.decimals)??2,a=(o,l,h)=>{const u=o/l,d=Number.parseFloat(u.toFixed(n));return Math.abs(d)>=1e3?null:`${u.toFixed(n)}${h}`};return s>=1e15?i.toExponential(2):s>=1e12?a(i,1e12,"T")??i.toExponential(2):s>=1e9?a(i,1e9,"B")??`${(i/1e12).toFixed(n)}T`:s>=1e6?a(i,1e6,"M")??`${(i/1e9).toFixed(n)}B`:s>=1e3?a(i,1e3,"K")??`${(i/1e6).toFixed(n)}M`:s<1?pa(i):s<100?i.toFixed(2):i.toFixed(0)}function nr(i){const t=ba(i);if(t!==null)return t;const e=Math.abs(i);return e===0?"0":e<1?pa(i):e<100?i.toFixed(4):e>=1e7?Ke(i):e<1e4?i.toFixed(2):i.toFixed(0)}function Yl(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function jl(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e>=5?5:e>=2?2:1)*t}const Hl=50,$l=50;class va{constructor(){F(this,"tickTracker",new ma),F(this,"min",0),F(this,"max",0),F(this,"height",1),F(this,"pixelRatio",1),F(this,"labelCountHintValue",null),F(this,"minSpacingValue",null),F(this,"resolvedInterval",null),F(this,"lastInterval",null),F(this,"lastRawInterval",null),F(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??$l}update(t,e,s){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=s,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Ol(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Xl(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,s=Math.max(0,Math.min(Hl,Math.floor((this.max-e)/t)+1)),n=[];for(let a=0;a<s;a++)n.push(e+a*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return Ke(t);const e=this.resolvedInterval,s=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(s)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,s=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/s;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const o=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let a=Yl(n);if(this.labelCountHint!=null&&this.countTicks(a)<this.labelCountHint){const o=jl(n);o>=e&&o>0&&(a=o)}this.resolvedInterval=a,this.lastInterval=a,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function Ol(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Xl(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function Nl(i){let t=0,e=0;for(const s of i)s>0?t+=s:s<0&&(e+=s);return{positive:t,negative:e}}function Ul(i){return i.positive>0?i.positive:i.negative<0?i.negative:0}function _l(i){return i.positive>0?100:i.negative<0?-100:0}const Gl=(i,t,e)=>i+(t-i)*e;var Yt,me;class ya{constructor(t){F(this,"stores"),F(this,"entries"),F(this,"displayedLastValues"),v(this,Yt),v(this,me),this.stores=Array.from({length:t},()=>new ua),this.entries=Array.from({length:t},()=>new Map),this.displayedLastValues=new Array(t).fill(null),c(this,Yt,new Array(t).fill(null)),c(this,me,Array.from({length:t},()=>new dn({initial:1,duration:0,lerp:Gl})))}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}setData(t,e=0){const s=this.stores[e];if(!s)return;const n=To(t??[]);s.setData(n);const a=s.last();this.displayedLastValues[e]=a?a.value:null,r(this,Yt)[e]=null,this.entries[e].clear()}appendPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t,a=Et(n.time);s.append({...n,time:a}),this.displayedLastValues[e]=n.value,r(this,Yt)[e]=null;const o=this.options.entryMs;this.isEntryEnabled()&&o>0&&this.entries[e].set(a,{startTime:performance.now()})}updateLastPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t;s.updateLast({...n,time:Et(n.time)});const a=n.value,o=this.options.smoothMs;if(o<=0){this.displayedLastValues[e]=a,r(this,Yt)[e]=null;return}let l=r(this,Yt)[e];if(l===null){const h=this.displayedLastValues[e]??a;l=new ki(h),r(this,Yt)[e]=l}l.retarget(a,{settleMs:o})}keepLast(t,e=0){const s=this.stores[e];if(!s||t<0)return;const n=s.length-t;n<=0||s.trimStart(n)}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var s;(s=this.stores[t])==null||s.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners()}entranceProgress(t,e,s){var n;const a=(n=this.entries[e])==null?void 0:n.get(s);if(a===void 0)return 1;const o=this.options.entryMs;if(o<=0)return 1;const l=performance.now()-a.startTime;return l<=0?0:l>=o?1:l/o}effectiveValue(t,e,s,n){var a,o;const l=(o=(a=this.stores[e])==null?void 0:a.last())==null?void 0:o.time;return l===void 0||s!==l?n:this.displayedLastValues[e]??n}tickAnimations(t){for(const e of r(this,me))e.tick(t);for(let e=0;e<this.stores.length;e++){const s=r(this,Yt)[e];if(s!==null){const o=s.tick(t);this.displayedLastValues[e]=s.current,o||(r(this,Yt)[e]=null)}const n=this.options.entryMs;if(n<=0){this.entries[e].clear();continue}const a=this.entries[e];for(const[o,l]of a)t-l.startTime>=n&&a.delete(o)}}get needsAnimation(){for(const t of r(this,me))if(t.animating)return!0;for(const t of r(this,Yt))if(t!==null)return!0;for(const t of this.entries)if(t.size>0)return!0;return!1}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}setAlpha(t,e){for(const s of r(this,me))s.setTarget(t,{duration:e})}getAlpha(){for(const t of r(this,me))if(t.current>0||t.animating)return 1;return 0}setLayerAlpha(t,e,s){var n;(n=r(this,me)[t])==null||n.setTarget(e,{duration:s})}getLayerAlpha(t){var e;return((e=r(this,me)[t])==null?void 0:e.current)??1}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var s;return((s=this.stores[0])==null?void 0:s.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const s=this.getColors(),n=[];for(let a=0;a<this.stores.length;a++){if(!this.stores[a].isVisible())continue;const o=this.stores[a].getVisibleData(t-e,t+e);if(o.length===0)continue;let l=o[0],h=Math.abs(o[0].time-t);for(let u=1;u<o.length;u++){const d=Math.abs(o[u].time-t);d<=h&&(h=d,l=o[u])}n.push({layerIndex:a,time:l.time,value:l.value,color:s[a%s.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const o=(t=this.stores[0])==null?void 0:t.last();return o?{value:o.value,isLive:!0}:null}let e=-1/0;for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const s=this.options.stacking;if(s==="off"){for(let o=this.stores.length-1;o>=0;o--){if(!this.stores[o].isVisible())continue;const l=this.stores[o].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();n.push(l&&l.time===e?l.value:0)}const a=Nl(n);return{value:s==="percent"?_l(a):Ul(a),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].last();n&&e.push({layerIndex:s,time:n.time,value:n.value,color:t[s%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getTimeBounds(){let t=1/0,e=-1/0;for(const s of this.stores){const n=s.first();if(!n)continue;const a=s.last()??n;n.time<t&&(t=n.time),a.time>e&&(e=a.time)}return t===1/0?null:{first:t,last:e}}getLastDataPoint(){var t;return((t=this.stores[0])==null?void 0:t.last())??null}getSecondLastDataPoint(){var t;const e=(t=this.stores[0])==null?void 0:t.getAll();return!e||e.length<2?null:e[e.length-2]}sampleTimes(t){for(const e of this.stores){const s=e.getAll();if(s.length!==0)return s.slice(0,t).map(n=>n.time)}return[]}getVisibleDataPoints(t,e){var s;return((s=this.stores[0])==null?void 0:s.getVisibleData(t,e))??[]}getValueRange(t,e){const s=this.options.stacking;if(s==="percent")return{min:0,max:100};const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(s==="off"){let h=1/0,u=-1/0;for(const d of n)for(const f of d)Number.isFinite(f.value)&&(f.value<h&&(h=f.value),f.value>u&&(u=f.value));return h<1/0?{min:h,max:u}:null}const a=new Map;for(let h=0;h<n.length;h++)for(const u of n[h]){let d=a.get(u.time);d||(d=new Array(n.length).fill(0),a.set(u.time,d)),d[h]=Number.isFinite(u.value)?u.value:0}let o=0,l=0;for(const h of a.values()){let u=0,d=0;for(const f of h)f>0?u+=f:d+=f;u>l&&(l=u),d<o&&(o=d)}return l>o?{min:o,max:l}:null}}Yt=new WeakMap,me=new WeakMap;const Kl={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off",anchor:"center",entryMs:tr,smoothMs:er};function Br(i){return{...i,entryMs:i.entryMs===!1?0:i.entryMs??tr,smoothMs:i.smoothMs===!1?0:i.smoothMs??er}}class ql extends ya{constructor(t,e){super(t),F(this,"kind","bar"),this.options=Br({...Kl,...e})}updateOptions(t){this.options=Br({...this.options,...t})}isEntryEnabled(){return(this.options.entryAnimation??"fade-grow")!=="none"}applyTheme(t,e){const s=e.seriesColors,n=this.options.colors.map((a,o)=>a===s[o]?t.seriesColors[o]??a:a);this.updateOptions({colors:n})}applyBarTransform(t,e,s,n,a,o){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:s,barHeight:n,x:a,barWidth:o,alpha:1};let h=s,u=n,d=a,f=1;if((l==="fade"||l==="fade-grow")&&(f=t),l==="grow"||l==="fade-grow"){const m=n*t;s<e?h=e-m:h=e,u=Math.max(1,m)}return l==="slide"&&(d=a+(1-t)*o,f=t),{topY:h,barHeight:u,x:d,barWidth:o,alpha:f}}render(t){switch(this.tickAnimations(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:s,yScale:n,dataInterval:a}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange();let u=0;for(const L of this.stores){if(!L.isVisible())continue;const x=L.getVisibleData(h.from,h.to).length;if(x>u&&(u=x),u>2)break}const d=s.barWidthBitmap(a),f=Math.round(30*l),m=u<=2?Math.min(f,d):d,p=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),g=Math.floor(p/2),b=this.options.anchor==="right"?p:g,y=n.getRange().min<0,M=y?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const L=this.options.colors[0],x=this.options.colors.length>1?this.options.colors[1]:L,k=this.stores[0].getVisibleData(h.from,h.to);for(const C of k){if(!Number.isFinite(C.value))continue;const A=this.effectiveValue(t,0,C.time,C.value),T=this.entranceProgress(t,0,C.time),D=s.timeToBitmapX(C.time);if(A>=0){const B=n.valueToBitmapY(A),w=Math.max(1,M-B);this.drawAnimatedBar({context:o,progress:T,baselineY:M,topY:B,barHeight:w,x:D-b,barWidth:p,color:L})}else{const B=n.valueToBitmapY(A),w=Math.max(1,B-M);this.drawAnimatedBar({context:o,progress:T,baselineY:M,topY:M,barHeight:w,x:D-b,barWidth:p,color:x})}}}else{const L=this.stores.map((k,C)=>this.getLayerAlpha(C)>0?k.getVisibleData(h.from,h.to):[]),x=new Map;for(let k=0;k<L.length;k++){const C=this.getLayerAlpha(k);for(const A of L[k]){if(!Number.isFinite(A.value))continue;let T=x.get(A.time);T||(T=[],x.set(A.time,T)),T.push({layer:k,value:this.effectiveValue(t,k,A.time,A.value)*C})}}for(const[k,C]of x){C.sort((T,D)=>Math.abs(D.value)-Math.abs(T.value));const A=s.timeToBitmapX(k);for(const{layer:T,value:D}of C){const B=this.options.colors[T%this.options.colors.length],w=this.entranceProgress(t,T,k);if(D>=0){const W=n.valueToBitmapY(D),P=Math.max(1,M-W);this.drawAnimatedBar({context:o,progress:w,baselineY:M,topY:W,barHeight:P,x:A-b,barWidth:p,color:B})}else{const W=n.valueToBitmapY(D),P=Math.max(1,W-M);this.drawAnimatedBar({context:o,progress:w,baselineY:M,topY:M,barHeight:P,x:A-b,barWidth:p,color:B})}}}}if(y){o.strokeStyle=t.theme.grid.color,o.lineWidth=1;const L=Math.round(M)+.5;o.beginPath(),o.moveTo(0,L),o.lineTo(e.bitmapSize.width,L),o.stroke()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:a,dataInterval:o}=t,{context:l,horizontalPixelRatio:h}=s,u=n.getRange();let d=0;for(const x of this.stores){if(!x.isVisible())continue;const k=x.getVisibleData(u.from,u.to).length;if(k>d&&(d=k),d>2)break}const f=n.barWidthBitmap(o),m=Math.round(30*h),p=d<=2?Math.min(m,f):f,g=Math.max(1,Math.round(p*this.options.barWidthRatio)-2),b=Math.floor(g/2),y=this.options.anchor==="right"?g:b,M=this.stores.map((x,k)=>this.getLayerAlpha(k)>0?x.getVisibleData(u.from,u.to):[]);if(M.every(x=>x.length===0))return;const L=new Map;for(let x=0;x<M.length;x++){const k=this.getLayerAlpha(x);for(const C of M[x]){let A=L.get(C.time);A||(A=new Array(M.length).fill(0),L.set(C.time,A));const T=Number.isFinite(C.value)?C.value:0;A[x]=this.effectiveValue(t,x,C.time,T)*k}}for(let x=0;x<M.length;x++){const k=this.options.colors[x%this.options.colors.length];for(const[C,A]of L){const T=A[x];if(T===0)continue;const D=n.timeToBitmapX(C);let B=0,w=0;for(let P=0;P<x;P++){const z=A[P];z>0?B+=z:w+=z}const W=this.entranceProgress(t,x,C);if(e){let P=0,z=0;for(const E of A)E>0?P+=E:z+=E;if(T>0&&P>0){const E=B/P*100,V=(B+T)/P*100,X=a.valueToBitmapY(V),$=a.valueToBitmapY(E),G=Math.max(1,$-X);this.drawAnimatedBar({context:l,progress:W,baselineY:$,topY:X,barHeight:G,x:D-y,barWidth:g,color:k})}else if(T<0&&z<0){const E=w/z*-100,V=(w+T)/z*-100,X=a.valueToBitmapY(E),$=a.valueToBitmapY(V),G=Math.max(1,$-X);this.drawAnimatedBar({context:l,progress:W,baselineY:X,topY:X,barHeight:G,x:D-y,barWidth:g,color:k})}}else if(T>0){const P=a.valueToBitmapY(B+T),z=a.valueToBitmapY(B),E=Math.max(1,z-P);this.drawAnimatedBar({context:l,progress:W,baselineY:z,topY:P,barHeight:E,x:D-y,barWidth:g,color:k})}else{const P=a.valueToBitmapY(w),z=a.valueToBitmapY(w+T),E=Math.max(1,z-P);this.drawAnimatedBar({context:l,progress:W,baselineY:P,topY:P,barHeight:E,x:D-y,barWidth:g,color:k})}}}}fillBar(t,e,s,n,a,o){t.fillStyle=o,t.fillRect(e,s,n,a)}drawAnimatedBar(t){const{context:e,progress:s,baselineY:n,topY:a,barHeight:o,x:l,barWidth:h,color:u}=t,d=this.options.entryAnimation??"fade-grow";if(s>=1||d==="none"){this.fillBar(e,l,a,h,o,u);return}const f=this.applyBarTransform(s,n,a,o,l,h);e.save(),e.globalAlpha=f.alpha,e.fillStyle=u,e.fillRect(f.x,f.topY,f.barWidth,f.barHeight),e.restore()}}function Dr(i,t){return i.length<=t?i:Jl(i,t,e=>e.time,e=>e.value)}function Zl(i,t){if(i.length<=t)return i;const e=Math.ceil(i.length/t),s=[];for(let n=0;n<i.length;n+=e){const a=Math.min(n+e,i.length);let o=-1/0,l=1/0,h=0;for(let u=n;u<a;u++)i[u].high>o&&(o=i[u].high),i[u].low<l&&(l=i[u].low),h+=i[u].volume??0;s.push({time:i[n].time,open:i[n].open,high:o,low:l,close:i[a-1].close,volume:h})}return s}function Jl(i,t,e,s){if(t>=i.length||t<3)return i;const n=[i[0]],a=(i.length-2)/(t-2);let o=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*a)+1,u=Math.min(Math.floor((l+2)*a)+1,i.length-1);let d=0,f=0;const m=u,p=Math.min(Math.floor((l+3)*a)+1,i.length),g=p-m;if(g>0){for(let x=m;x<p;x++)d+=e(i[x]),f+=s(i[x]);d/=g,f/=g}let b=-1,y=h;const M=e(i[o]),L=s(i[o]);for(let x=h;x<u;x++){const k=Math.abs((M-d)*(s(i[x])-L)-(M-e(i[x]))*(f-L));k>b&&(b=k,y=x)}n.push(i[y]),o=y}return n.push(i[i.length-1]),n}const zr=new Map,Er=new Map;function xa(i){return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)]}function Ql(i,t,e){return`#${i.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}`}function Ye(i,t){if(i.startsWith("rgba"))return i.replace(/[\d.]+\)\s*$/,`${t})`);if(i.startsWith("rgb("))return i.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=i+t;let s=zr.get(e);if(s)return s;const[n,a,o]=xa(i);return s=`rgba(${n}, ${a}, ${o}, ${t})`,zr.set(e,s),s}function wa(i,t){const e=i+t;let s=Er.get(e);if(s)return s;const[n,a,o]=xa(i);return s=Ql(Math.min(255,Math.round(n+(255-n)*t)),Math.min(255,Math.round(a+(255-a)*t)),Math.min(255,Math.round(o+(255-o)*t))),Er.set(e,s),s}function $s(i){return typeof i=="number"&&!Number.isFinite(i)}const th=(()=>{const i=new WeakSet;return(t,e,s,n)=>{s.length===0||i.has(t)||(i.add(t),console.warn(`[wick-charts] ${e}: skipping ${s.length} row${s.length===1?"":"s"} with NaN / Infinity values (indices ${s.join(", ")}; first offending row: ${n}). Filter upstream data; the renderer drops poisoned rows to keep the rest of the chart alive.`))}})(),eh=.15,ih=.005;var Ti,Li,Ii,Wi,Ri,ss,ns;class sh{constructor(t){v(this,Ti),v(this,Li),v(this,Ii),v(this,Wi),v(this,Ri),v(this,ss),v(this,ns),c(this,Ti,new ki(t.open)),c(this,Li,new ki(t.high)),c(this,Ii,new ki(t.low)),c(this,Wi,new ki(t.close)),c(this,Ri,new ki(t.volume??0)),c(this,ss,t.time),c(this,ns,t.volume!==void 0)}retarget(t,e={}){c(this,ss,t.time),t.volume!==void 0&&c(this,ns,!0),r(this,Ti).retarget(t.open,e),r(this,Li).retarget(t.high,e),r(this,Ii).retarget(t.low,e),r(this,Wi).retarget(t.close,e),r(this,Ri).retarget(t.volume??0,e)}tick(t){const e=r(this,Ti).tick(t),s=r(this,Li).tick(t),n=r(this,Ii).tick(t),a=r(this,Wi).tick(t),o=r(this,Ri).tick(t);return e||s||n||a||o}get current(){const t={time:r(this,ss),open:r(this,Ti).current,high:r(this,Li).current,low:r(this,Ii).current,close:r(this,Wi).current};return r(this,ns)&&(t.volume=r(this,Ri).current),t}}Ti=new WeakMap,Li=new WeakMap,Ii=new WeakMap,Wi=new WeakMap,Ri=new WeakMap,ss=new WeakMap,ns=new WeakMap;const nh={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6,entryMs:Jn,smoothMs:Qn};function Vr(i){return{...i,entryMs:i.entryMs===!1?0:i.entryMs??Jn,smoothMs:i.smoothMs===!1?0:i.smoothMs??Qn}}var Kt,jt,rs,qs,Ai;class rh{constructor(t,e){F(this,"kind","candlestick"),F(this,"store"),F(this,"options"),F(this,"displayedLast",null),F(this,"entries",new Map),v(this,Kt,null),v(this,jt,null),v(this,rs,!0),v(this,qs,!1),v(this,Ai,new dn({initial:1,duration:0,lerp:(s,n,a)=>s+(n-s)*a})),this.store=t,this.options=Vr({...nh,...e}),this.displayedLast=t.last()??null}isEntryEnabled(){return(this.options.entryAnimation??"unfold")!=="none"}updateOptions(t){this.options=Vr({...this.options,...t})}getColor(){return zt(this.options.up.body)}setData(t){this.store.setData(Co(t??[]));const e=this.store.last();this.displayedLast=e??null,c(this,Kt,null),this.entries.clear(),c(this,jt,null)}appendPoint(t){const e=t,s=Et(e.time),n={...e,time:s};this.store.append(n),this.displayedLast=n,c(this,Kt,null);const a=this.options.entryMs;this.isEntryEnabled()&&a>0&&this.entries.set(s,{startTime:performance.now()})}updateLastPoint(t){const e=t,s=Et(e.time),n={...e,time:s};this.store.updateLast(n);const a=this.options.smoothMs;if(a<=0){this.displayedLast=n,c(this,Kt,null);return}let o=r(this,Kt);if(o===null){const l=this.displayedLast??n;o=new sh(l),c(this,Kt,o)}o.retarget(n,{settleMs:a})}keepLast(t){if(t<0)return;const e=this.store.length-t;e<=0||this.store.trimStart(e)}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[zt(this.options.up.body)]}applyTheme(t,e){this.updateOptions({up:{...t.candlestick.up},down:{...t.candlestick.down}})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners()}tickAnimations(t){r(this,Ai).tick(t);const e=r(this,Kt);if(e!==null){const n=e.tick(t);this.displayedLast=e.current,n||c(this,Kt,null)}const s=this.options.entryMs;if(s<=0){this.entries.clear();return}for(const[n,a]of this.entries)t-a.startTime>=s&&this.entries.delete(n)}get needsAnimation(){return r(this,Ai).animating||r(this,Kt)!==null||this.entries.size>0||!r(this,rs)}cancelEntranceAnimations(){this.entries.clear()}setAlpha(t,e){r(this,Ai).setTarget(t,{duration:e})}getAlpha(){return r(this,Ai).current}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}getTimeBounds(){const t=this.store.first(),e=this.store.last();return!t||!e?null:{first:t.time,last:e.time}}getLastDataPoint(){return this.store.last()??null}getSecondLastDataPoint(){const t=this.store.getAll();return t.length>=2?t[t.length-2]:null}sampleTimes(t){return this.store.getAll().slice(0,t).map(e=>e.time)}getVisibleDataPoints(t,e){return this.store.getVisibleData(t,e)}getValueRange(t,e){const s=this.store.getVisibleData(t,e);let n=1/0,a=-1/0;for(const o of s)Number.isFinite(o.low)&&o.low<n&&(n=o.low),Number.isFinite(o.high)&&o.high>a&&(a=o.high);return n===1/0||a===-1/0?null:{min:n,max:a}}render(t){this.tickAnimations(performance.now());const{scope:e,timeScale:s,yScale:n,dataInterval:a}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange();let u=this.store.getVisibleData(h.from,h.to);const d=e.mediaSize.width,f=u.length>d*2;if(f&&(u=Zl(u,Math.round(d*1.5))),u.length===0)return;const m=this.displayedLast;if(!f&&m!==null){const W=u.length-1;u[W].time===m.time&&(u=[...u.slice(0,W),m])}let p=null;if(this.entries.size>0){const W=this.options.entryMs,P=performance.now();for(const z of u){const E=this.entries.get(z.time);if(E===void 0)continue;const V=P-E.startTime,X=W<=0?1:Math.min(1,Math.max(0,V/W));if(X>=1)continue;const $=hi(X);p===null&&(p=new Map),p.set(z.time,$)}}const g=s.barWidthBitmap(a),b=Math.round(30*l),y=u.length<=2?Math.min(b,g):g,M=Math.max(1,Math.round(l));let L=Math.max(1,Math.round(y*this.options.bodyWidthRatio)-2);(L&1)!==(M&1)&&(L=L>1?L-1:2);const x=Math.floor(L/2),k=f!==r(this,qs);c(this,qs,f);const C=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:o,data:u,timeScale:s,chartHeight:C,barWidth:y,wickWidth:M,entranceByTime:p,snapVolScale:k});const A=[],T=[],D=[];let B=null;for(let W=0;W<u.length;W++){const P=u[W];if($s(P.open)||$s(P.close)||$s(P.high)||$s(P.low)){D.push(W),B===null&&(B=P);continue}P.close>=P.open?A.push(P):T.push(P)}B!==null&&th(this,"candlestick",D,`time ${B.time}`);const w={ctx:o,timeScale:s,yScale:n,halfBody:x,bodyWidth:L,wickWidth:M,entranceByTime:p};this.drawCandles({...w,candles:A,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...w,candles:T,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:s,chartHeight:n,barWidth:a,wickWidth:o,entranceByTime:l,snapVolScale:h}){let u=0;for(const M of e)Number.isFinite(M.volume)&&M.volume>u&&(u=M.volume);if(u===0){c(this,jt,null),c(this,rs,!0);return}r(this,jt)===null||h?c(this,jt,u):c(this,jt,r(this,jt)+(u-r(this,jt))*eh),c(this,rs,Math.abs(u-r(this,jt))<=u*ih);const d=r(this,jt),f=n*.2;let m=Math.max(1,a-2);(m&1)!==(o&1)&&(m=m>1?m-1:2);const p=Math.floor(m/2),g=Ye(zt(this.options.up.body),.2),b=Ye(zt(this.options.down.body),.2),y=this.options.entryAnimation??"unfold";for(const M of e){if(!Number.isFinite(M.volume)||M.volume<=0)continue;const L=M.volume,x=s.timeToBitmapX(M.time),k=Math.min(f,Math.max(1,L/d*f)),C=M.close>=M.open;t.fillStyle=C?g:b;const A=(l==null?void 0:l.get(M.time))??1;if(A>=1||y==="none"){t.fillRect(x-p,n-k,m,k);continue}const T=Cn(A,y,{x:x-p,barWidth:m,anchorY:n,topY:n-k,bottomY:n});t.save(),t.globalAlpha=T.alpha,t.fillRect(T.x,T.topY,m,Math.max(1,T.bottomY-T.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:s,yScale:n,halfBody:a,bodyWidth:o,wickWidth:l,body:h,wickColor:u,entranceByTime:d}){if(e.length===0)return;const f=this.options.entryAnimation??"unfold",m=o+2;t.fillStyle=u;for(const g of e){const b=(d==null?void 0:d.get(g.time))??1,y=s.timeToBitmapX(g.time),M=n.valueToBitmapY(g.open),L=n.valueToBitmapY(g.high),x=n.valueToBitmapY(g.low),k=y-Math.floor(l/2);if(b>=1||f==="none"){t.fillRect(k,L,l,x-L);continue}const C=Cn(b,f,{x:k,barWidth:m,anchorY:M,topY:L,bottomY:x});t.save(),t.globalAlpha=C.alpha,t.fillRect(C.x,C.topY,l,Math.max(1,C.bottomY-C.topY)),t.restore()}const p=Array.isArray(h);for(const g of e){const b=(d==null?void 0:d.get(g.time))??1,y=s.timeToBitmapX(g.time),M=n.valueToBitmapY(g.open),L=n.valueToBitmapY(g.close),x=Math.min(M,L),k=Math.max(M,L),C=Math.max(1,k-x),A=b<1&&f!=="none";let T=y-a,D=x,B=C,w=1;if(A){const W=Cn(b,f,{x:y-a,barWidth:m,anchorY:M,topY:x,bottomY:k});T=W.x,D=W.topY,B=Math.max(1,W.bottomY-W.topY),w=W.alpha}if(A&&t.save(),p&&B>2){const W=t.createLinearGradient(0,D,0,D+B);W.addColorStop(0,h[0]),W.addColorStop(1,h[1]),t.fillStyle=W}else t.fillStyle=p?h[0]:h;A&&(t.globalAlpha=w),t.fillRect(T,D,o,B),A&&t.restore()}}}Kt=new WeakMap,jt=new WeakMap,rs=new WeakMap,qs=new WeakMap,Ai=new WeakMap;function Cn(i,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:i};case"unfold":return{x:e.x,topY:se(e.anchorY,e.topY,i),bottomY:se(e.anchorY,e.bottomY,i),alpha:1};case"slide":return{x:e.x+(1-i)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:i};case"fade-unfold":return{x:e.x,topY:se(e.anchorY,e.topY,i),bottomY:se(e.anchorY,e.bottomY,i),alpha:i}}}const ah={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off",entryMs:cn,smoothMs:qn,pulseMs:Zn};function Yr(i){const t=i.areaFill,e=t!==void 0&&i.area===void 0?{visible:!!t}:i.area;return{...i,area:e,entryMs:i.entryMs===!1?0:i.entryMs??cn,smoothMs:i.smoothMs===!1?0:i.smoothMs??qn,pulseMs:i.pulseMs===!1?0:i.pulseMs??Zn}}class oh extends ya{constructor(t,e){super(t),F(this,"kind","line"),F(this,"areaGradientCache",new Map),this.options=Yr({...ah,...e})}updateOptions(t){this.options=Yr({...this.options,...t})}getStacking(){return this.options.stacking}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)}),this.options.strokeWidth===e.line.width&&this.updateOptions({strokeWidth:t.line.width})}isEntryEnabled(){return(this.options.entryAnimation??"grow")!=="none"}get hasPulse(){return this.options.pulse&&this.options.pulseMs>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let s=0;s<this.stores.length;s++){if(this.getLayerAlpha(s)<=0)continue;const n=this.stores[s].last();if(n&&n.time>=t)return!0}return!1}render(t){this.tickAnimations(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e){const s=this.stores[e],n=s.last();if(!n)return null;const{timeScale:a,yScale:o}=t,l=a.timeToBitmapX(n.time),h=o.valueToBitmapY(this.effectiveValue(t,e,n.time,n.value));if((this.options.entryAnimation??"grow")!=="grow")return{x:l,y:h};const u=this.entranceProgress(t,e,n.time);if(u>=1)return{x:l,y:h};const d=s.getAll();if(d.length<2)return{x:l,y:h};const f=d[d.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=a.timeToBitmapX(f.time),p=o.valueToBitmapY(f.value),g=hi(u);return{x:se(m,l,g),y:se(p,h,g)}}renderOff(t){var e;const{scope:s,timeScale:n,yScale:a}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,u=this.options.strokeWidth>0,d=Math.max(1,Math.round(this.options.strokeWidth*h)),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){const p=this.getLayerAlpha(m);if(p<=0)continue;let g=this.stores[m].getVisibleData(l.from,l.to);const b=s.mediaSize.width;if(g.length>b*2&&(g=Dr(g,Math.round(b*1.5))),g.length<2)continue;const y=this.options.colors[m%this.options.colors.length],M=g[g.length-1],L=this.entranceProgress(t,m,M.time),x=f==="fade"&&L<1,k=this.trailingEndpoint(t,m)??{x:n.timeToBitmapX(M.time),y:a.valueToBitmapY(this.effectiveValue(t,m,M.time,M.value))},C=k.x,A=k.y,T=p<1;(T||x)&&(o.save(),T&&(o.globalAlpha*=p),x&&(o.globalAlpha*=L));const D=g.length-1,B=[];let w=null;for(let P=0;P<D;P++){const z=g[P].value;if(!Number.isFinite(z)){w=null;continue}w||(w=[],B.push(w)),w.push({x:n.timeToBitmapX(g[P].time),y:a.valueToBitmapY(z)})}const W=(e=g[D])==null?void 0:e.value;if(Number.isFinite(C)&&Number.isFinite(A)&&Number.isFinite(W)&&(w?w.push({x:C,y:A}):B.push([{x:C,y:A}])),u&&B.some(P=>P.length>=2)){o.beginPath();for(const P of B)if(!(P.length<2)){o.moveTo(P[0].x,P[0].y);for(let z=1;z<P.length;z++)o.lineTo(P[z].x,P[z].y)}o.strokeStyle=y,o.lineWidth=d,o.lineJoin="round",o.lineCap="round",o.stroke()}if(u){const P=Math.max(1,d/2);let z=!1;for(const E of B)E.length===1&&(z||(o.beginPath(),z=!0),o.moveTo(E[0].x+P,E[0].y),o.arc(E[0].x,E[0].y,P,0,Math.PI*2));z&&(o.fillStyle=y,o.fill())}if(this.options.area.visible){const P=s.bitmapSize.height,z=String(m),E=this.areaGradientCache.get(z);let V;E&&E.bottomY===P&&E.color===y?V=E.gradient:(V=o.createLinearGradient(0,0,0,P),V.addColorStop(0,Ye(y,.12)),V.addColorStop(1,Ye(y,.01)),this.areaGradientCache.set(z,{gradient:V,bottomY:P,color:y})),o.fillStyle=V;for(const X of B)if(!(X.length<2)){o.beginPath(),o.moveTo(X[0].x,X[0].y);for(let $=1;$<X.length;$++)o.lineTo(X[$].x,X[$].y);o.lineTo(X[X.length-1].x,P),o.lineTo(X[0].x,P),o.closePath(),o.fill()}}(x||T)&&o.restore()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:a}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,u=this.options.strokeWidth>0,d=Math.max(1,Math.round(this.options.strokeWidth*h)),f=s.mediaSize.width,m=this.stores.map((w,W)=>{if(this.getLayerAlpha(W)<=0)return[];let P=w.getVisibleData(l.from,l.to);return P.length>f*2&&(P=Dr(P,Math.round(f*1.5))),P}),p=new Set;for(const w of m)for(const W of w)p.add(W.time);const g=Array.from(p).sort((w,W)=>w-W);if(g.length<2)return;const b=m.map((w,W)=>{const P=new Map,z=this.getLayerAlpha(W);for(const E of w)P.set(E.time,this.effectiveValue(t,W,E.time,E.value)*z);return P}),y=Array.from({length:this.stores.length},()=>new Array(g.length).fill(0));for(let w=0;w<g.length;w++){const W=g[w];let P=0;if(e)for(let E=0;E<this.stores.length;E++){const V=b[E].get(W);Number.isFinite(V)&&(P+=V)}let z=0;for(let E=0;E<this.stores.length;E++){const V=b[E].get(W),X=Number.isFinite(V)?V:0;z+=e&&P>0?X/P*100:X,y[E][w]=z}}const M=this.options.entryAnimation??"grow",L=new Map;for(let w=0;w<g.length;w++)L.set(g[w],w);const x=g.length-1,k=new Array(this.stores.length).fill(1);for(let w=0;w<this.stores.length;w++){if(this.getLayerAlpha(w)<=0)continue;const W=this.stores[w].last();if(!W)continue;const P=this.entranceProgress(t,w,W.time);if(P>=1)continue;const z=L.get(W.time);if(z!==x)continue;const E=this.stores[w].getAll();if(E.length<2)continue;const V=E[E.length-2].time;L.get(V)===z-1&&(k[w]=P)}const C=(w,W)=>{if(W>=1||w.length<2)return;const P=w.length-1,z=w[P-1],E=w[P];w[P]=[se(z[0],E[0],W),se(z[1],E[1],W)]},A=s.bitmapSize.height;let T=-1,D=-1;for(let w=0;w<this.stores.length;w++)if(!(this.getLayerAlpha(w)<=0))if(T<0)T=w;else{D=w;break}const B=T>=0?this.getLayerAlpha(T):1;for(let w=this.stores.length-1;w>=0;w--){const W=this.getLayerAlpha(w);if(W<=0)continue;const P=this.options.colors[w%this.options.colors.length],z=k[w],E=w>0&&this.getLayerAlpha(w-1)>0?k[w-1]:1,V=w===T,X=D>=0&&w===D&&B<1,$=[];for(let _=0;_<g.length;_++){const q=w>0?a.valueToBitmapY(y[w-1][_]):A;let Z=q;V?Z=A:X&&(Z=q+(A-q)*(1-B)),$.push([n.timeToBitmapX(g[_]),Z])}M==="grow"&&C($,hi(E));const G=[];for(let _=0;_<g.length;_++){let q=a.valueToBitmapY(y[w][_]);V&&W<1&&(q=A+(q-A)*W),G.push([n.timeToBitmapX(g[_]),q])}M==="grow"&&C(G,hi(z));const xt=M==="fade"&&z<1;if(xt&&(o.save(),o.globalAlpha=z),this.options.area.visible){let _=G[0][1],q=$[0][1];for(let K=1;K<G.length;K++)G[K][1]<_&&(_=G[K][1]);for(let K=1;K<$.length;K++)$[K][1]>q&&(q=$[K][1]);let Z=Ye(P,.25);if(q>_+.5){const K=o.createLinearGradient(0,_,0,q);K.addColorStop(0,Ye(P,.25)),K.addColorStop(1,Ye(P,.05)),Z=K}o.beginPath(),o.moveTo(G[0][0],G[0][1]);for(let K=1;K<G.length;K++)o.lineTo(G[K][0],G[K][1]);for(let K=$.length-1;K>=0;K--)o.lineTo($[K][0],$[K][1]);o.closePath(),o.fillStyle=Z,o.fill()}const Tt=u&&W<1;if(Tt&&(o.save(),o.globalAlpha*=W),u){o.beginPath(),o.moveTo(G[0][0],G[0][1]);for(let _=1;_<G.length;_++)o.lineTo(G[_][0],G[_][1]);o.strokeStyle=P,o.lineWidth=d,o.lineJoin="round",o.lineCap="round",o.stroke()}Tt&&o.restore(),xt&&o.restore()}}drawOverlay(t){this.tickAnimations(performance.now());const{scope:e,timeScale:s,yScale:n,crosshair:a,dataInterval:o}=t,l=e,h=this.options.pulseMs,u=h>0?performance.now()/(h*2*Math.PI)%1:0;if(a){const d=this.options.colors,f=this.options.stacking,m=4*l.horizontalPixelRatio,p=[],g=[];for(let y=0;y<this.stores.length;y++){const M=this.stores[y].findNearest(a.time,o);M?(p.push(M.value),g.push(M.time)):(p.push(0),g.push(null))}const b=[];if(f==="off")for(const y of p)b.push(y);else{let y=0;if(f==="percent")for(let L=0;L<p.length;L++)y+=p[L]*this.getLayerAlpha(L);let M=0;for(let L=0;L<p.length;L++){const x=p[L]*this.getLayerAlpha(L);M+=f==="percent"&&y>0?x/y*100:x,b.push(M)}}for(let y=0;y<this.stores.length;y++){const M=g[y];if(M===null)continue;const L=this.getLayerAlpha(y);if(L<=0)continue;const x=d[y%d.length],k=s.timeToBitmapX(M),C=n.valueToBitmapY(b[y]),A=L<1;A&&(e.context.save(),e.context.globalAlpha*=L),e.context.save(),e.context.globalAlpha*=.25,e.context.beginPath(),e.context.arc(k,C,m+3*l.horizontalPixelRatio,0,Math.PI*2),e.context.fillStyle=x,e.context.fill(),e.context.restore(),e.context.beginPath(),e.context.arc(k,C,m,0,Math.PI*2),e.context.fillStyle=x,e.context.fill(),A&&e.context.restore()}}if(this.hasPulse&&h>0){const d=this.options.stacking;for(let f=0;f<this.stores.length;f++){const m=this.getLayerAlpha(f);if(m<=0)continue;const p=this.options.colors[f%this.options.colors.length];if(d==="off"){const k=this.trailingEndpoint(t,f);if(!k)continue;this.drawPulse({ctx:e.context,x:k.x,y:k.y,color:p,pixelRatio:l.horizontalPixelRatio,phase:u,alpha:m});continue}const g=this.stores[f].last();if(!g)continue;const b=g.time,y=d==="percent",M=k=>{const C=D=>{const B=this.getLayerAlpha(D);if(B<=0)return 0;const w=D===f&&k===b?g:this.stores[D].findNearest(k,0);return!w||w.time!==k?0:this.effectiveValue(t,D,k,w.value)*B};let A=0;if(y)for(let D=0;D<this.stores.length;D++)A+=C(D);let T=0;for(let D=0;D<=f;D++){const B=C(D);T+=y&&A>0?B/A*100:B}return T};let L=s.timeToBitmapX(b),x=n.valueToBitmapY(M(b));if((this.options.entryAnimation??"grow")==="grow"){const k=this.entranceProgress(t,f,b);if(k<1){const C=this.stores[f].getAll(),A=C.length>=2?C[C.length-2]:null;if(A!==null&&A.time!==b){const T=hi(k),D=s.timeToBitmapX(A.time),B=n.valueToBitmapY(M(A.time));L=se(D,L,T),x=se(B,x,T)}}}this.drawPulse({ctx:e.context,x:L,y:x,color:p,pixelRatio:l.horizontalPixelRatio,phase:u,alpha:m})}}}drawPulse({ctx:t,x:e,y:s,color:n,pixelRatio:a,phase:o,alpha:l=1}){const h=3*a,u=.4+.6*Math.abs(Math.sin(o*2*Math.PI)),d=h+4*a*u,f=l<1;f&&(t.save(),t.globalAlpha*=l),t.beginPath(),t.arc(e,s,d,0,Math.PI*2),t.fillStyle=Ye(n,u*.3),t.fill(),t.beginPath(),t.arc(e,s,h,0,Math.PI*2),t.fillStyle=n,t.fill(),f&&t.restore()}}const Ma={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8},lh={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...Ma},animate:!1},Vn=Math.PI/180;function hh(i,t){return{...i??{},...t}}function ch(i){return{...Ma,...i??{}}}function uh(i){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return i===!0||i===!1?t:{...t,...i}}function dh(i){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return i===!0||i===!1?t:{...t,...i}}const Yi=Math.PI*2,ka=.85;function jr(i){const{bitmapWidth:t,bitmapHeight:e,padTop:s,padBottom:n}=i,a=Math.max(0,i.labelReserve??0),o=Math.min(Math.max(0,s),e),l=Math.min(Math.max(0,n),e-o),h=e-o-l,u=Math.max(0,t-2*a),d=t/2,f=o+h/2,m=Math.max(0,Math.min(u,h)/2*ka);return{cx:d,cy:f,maxR:m}}function fh(i){if(!i.startsWith("#"))return!1;const t=parseInt(i.slice(1,3),16),e=parseInt(i.slice(3,5),16),s=parseInt(i.slice(5,7),16);return t*.299+e*.587+s*.114>150}function mh(i,t){if(!i.startsWith("#"))return i;const e=i.length===4?`#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`:i;return wa(e,t)}function Hr(i){if(i.startsWith("#"))return{r:parseInt(i.slice(1,3),16)||0,g:parseInt(i.slice(3,5),16)||0,b:parseInt(i.slice(5,7),16)||0,a:1};const t=i.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(s=>s.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function gh(i,t){const e=Hr(i),s=Hr(t),n=s.a,a=Math.round(s.r*n+e.r*(1-n)),o=Math.round(s.g*n+e.g*(1-n)),l=Math.round(s.b*n+e.b*(1-n));return`#${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var tt,it,qt,Mt,Pi,De,Ot,Qe,rt,Yn,Te,as,Zs,Sa,Ca,Ta;class ph{constructor(t){v(this,rt),F(this,"kind","pie"),v(this,tt,[]),v(this,it),v(this,qt,-1),v(this,Mt,[]),v(this,Pi,0),v(this,De,1),v(this,Ot,null),v(this,Qe,[]),c(this,it,S(this,rt,Yn).call(this,lh,t??{}))}getData(){return r(this,tt)}setData(t){const e=t??[];c(this,tt,e),c(this,Mt,new Array(e.length).fill(0)),c(this,De,r(this,it).animate?0:1),c(this,Ot,null);for(const s of r(this,Qe))s()}onDataChanged(t){return r(this,Qe).push(t),()=>{const e=r(this,Qe).indexOf(t);e>=0&&r(this,Qe).splice(e,1)}}updateOptions(t){var e,s;const n=(e=r(this,it).sliceLabels)==null?void 0:e.mode;c(this,it,S(this,rt,Yn).call(this,r(this,it),t??{})),((s=r(this,it).sliceLabels)==null?void 0:s.mode)==="outside"&&n!=="outside"&&c(this,De,r(this,it).animate?0:1),c(this,Ot,null)}getColor(){var t,e;return((t=r(this,tt)[0])==null?void 0:t.color)??((e=r(this,it).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&c(this,Ot,null)}hitTest(t,e,s,n,a){var o;if(r(this,tt).length===0)return-1;const l=S(this,rt,as).call(this);if(l<=0)return-1;const h=((o=r(this,Ot))==null?void 0:o.reserve)??0,{cx:u,cy:d,maxR:f}=jr({bitmapWidth:s,bitmapHeight:n,padTop:(a==null?void 0:a.top)??0,padBottom:(a==null?void 0:a.bottom)??0,labelReserve:h}),m=f,p=m*r(this,it).innerRadiusRatio,g=t-u,b=e-d,y=Math.sqrt(g*g+b*b);if(y>m||y<p)return-1;let M=Math.atan2(b,g)+Math.PI/2;M<0&&(M+=Yi);let L=0;for(let x=0;x<r(this,tt).length;x++){const k=S(this,rt,Te).call(this,r(this,tt)[x].value)/l*Yi;if(M>=L&&M<L+k)return x;L+=k}return-1}setHoverIndex(t){return r(this,qt)===t?!1:(c(this,qt,t),!0)}getHoverIndex(){return r(this,qt)}getHoverInfo(t){if(r(this,qt)<0)return null;const e=r(this,tt)[r(this,qt)];if(!e)return null;const s=S(this,rt,as).call(this),n=r(this,it).colors??t.seriesColors;return{label:e.label,value:e.value,percent:s>0?S(this,rt,Te).call(this,e.value)/s*100:0,color:e.color??n[r(this,qt)%n.length]}}getSliceInfo(t){if(r(this,tt).length===0)return null;const e=S(this,rt,as).call(this),s=r(this,it).colors??t.seriesColors;return r(this,tt).map((n,a)=>({label:n.label,value:n.value,percent:e>0?S(this,rt,Te).call(this,n.value)/e*100:0,color:n.color??s[a%s.length]}))}get needsAnimation(){var t;if(!r(this,it).animate)return!1;for(let e=0;e<r(this,Mt).length;e++){const s=e===r(this,qt)?1:0;if(Math.abs(r(this,Mt)[e]-s)>.01)return!0}return((t=r(this,it).sliceLabels)==null?void 0:t.mode)==="outside"&&r(this,De)<.99}dispose(){c(this,Qe,[]),c(this,tt,[]),c(this,Mt,[]),c(this,Pi,0)}_inspectSliceOffsets(){return r(this,Mt)}render(t){if(r(this,tt).length===0)return;const{scope:e,theme:s,padding:n}=t,{context:a,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=e,u=performance.now(),d=r(this,Pi)?Math.min(.05,(u-r(this,Pi))/1e3):0;c(this,Pi,u);const f=S(this,rt,as).call(this);if(f<=0)return;const m=12;for(;r(this,Mt).length<r(this,tt).length;)r(this,Mt).push(0);if(r(this,it).animate)for(let V=0;V<r(this,tt).length;V++){const X=V===r(this,qt)?1:0;r(this,Mt)[V]=Lr(r(this,Mt)[V],X,m,d)}const p=ch(r(this,it).sliceLabels);a.font=`${p.fontSize*l}px ${s.typography.fontFamily}`,p.mode==="outside"&&r(this,it).animate&&c(this,De,Lr(r(this,De),1,6,d));const g=r(this,it).colors??s.seriesColors,b=p.mode==="outside"?S(this,rt,Sa).call(this,a,p,f,l):0,{cx:y,cy:M,maxR:L}=jr({bitmapWidth:o.width,bitmapHeight:o.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:b}),x=L,k=x*r(this,it).innerRadiusRatio,C=r(this,it).padAngle*Vn,A=8*l,T=r(this,it).shadow??!1,D=uh(T),B=r(this,it).innerShadow??!1,w=dh(B);let W=-Math.PI/2;for(let V=0;V<r(this,tt).length;V++){const X=r(this,tt)[V],$=S(this,rt,Te).call(this,X.value)/f*Yi,G=W+C/2,xt=W+$-C/2,Tt=W+$/2,_=X.color??g[V%g.length];if(xt<=G){W+=$;continue}const q=r(this,Mt)[V]*A,Z=Math.cos(Tt)*q,K=Math.sin(Tt)*q,Vt=y+Z,kt=M+K;a.beginPath(),a.arc(Vt,kt,x,G,xt),k>0?a.arc(Vt,kt,k,xt,G,!0):a.lineTo(Vt,kt),a.closePath();const Lt=a.createRadialGradient(Vt,kt,k||0,Vt,kt,x);if(Lt.addColorStop(0,mh(_,.15)),B){const oe=Math.max(0,Math.min(.999,1-w.depth));Lt.addColorStop(oe,_),Lt.addColorStop(1,gh(_,w.color))}else Lt.addColorStop(1,_);a.fillStyle=Lt;const Ae=r(this,Mt)[V];if(T||Ae>.01){const oe=T?1:0,qe=Ae;a.shadowColor=T?D.color:"rgba(0,0,0,0.25)",a.shadowBlur=(D.blur*oe+12*qe)*l,a.shadowOffsetX=D.offsetX*oe*l+Z*.3*qe,a.shadowOffsetY=D.offsetY*oe*h+K*.3*qe}a.fill(),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0,W+=$}if(p.mode==="none")return;W=-Math.PI/2;const P=s.tooltip.textColor;if(p.mode==="outside"){const V=S(this,rt,Ta).call(this,{cx:y,cy:M,outerR:x,total:f,palette:g,labels:p,hpr:l,bitmapHeight:o.height}),X=V.length>1?Math.min(.06,.9/(V.length-1)):0;for(let $=0;$<V.length;$++){const G=V[$];if(G===null)continue;const xt=$*X,Tt=Ss((r(this,De)-xt)/(1-xt),0,1);S(this,rt,Ca).call(this,{context:a,entry:G,textColor:P,labels:p,hpr:l,progress:Tt})}return}const z=k>0?(x+k)/2:x*.65;a.textAlign="center",a.textBaseline="middle";const E=p.minSliceAngle*Vn;for(let V=0;V<r(this,tt).length;V++){const X=r(this,tt)[V],$=S(this,rt,Te).call(this,X.value)/f*Yi;if($>=E){const G=W+$/2,xt=r(this,Mt)[V]*A,Tt=X.color??g[V%g.length],_=S(this,rt,Zs).call(this,X,f,p.content),q=a.measureText(_).width,Z=p.fontSize*1.2*l,K=$<Math.PI?2*z*Math.sin($/2):2*z,Vt=q>K-4*l,kt=k>0&&z-k<Z;if(!Vt&&!kt){const Lt=y+Math.cos(G)*(z+xt),Ae=M+Math.sin(G)*(z+xt);a.fillStyle=fh(Tt)?"#000000":"#ffffff",a.fillText(_,Lt,Ae)}}W+=$}}}tt=new WeakMap,it=new WeakMap,qt=new WeakMap,Mt=new WeakMap,Pi=new WeakMap,De=new WeakMap,Ot=new WeakMap,Qe=new WeakMap,rt=new WeakSet,Yn=function(i,t){const e={...i,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=hh(i.sliceLabels,t.sliceLabels)),e},Te=function(i){return Number.isFinite(i)&&i>0?i:0},as=function(){let i=0;for(const t of r(this,tt))i+=S(this,rt,Te).call(this,t.value);return i},Zs=function(i,t,e){const s=t>0?S(this,rt,Te).call(this,i.value)/t*100:0,n=`${s.toFixed(s>=10?0:1)}%`;return e==="percent"?n:e==="label"?i.label:`${i.label} ${n}`},Sa=function(i,t,e,s){const n=i.font;if(r(this,Ot)&&r(this,Ot).fontScale===s&&r(this,Ot).font===n)return r(this,Ot).reserve;let a=0;for(const h of r(this,tt)){const u=S(this,rt,Zs).call(this,h,e,t.content),d=i.measureText(u).width;d>a&&(a=d)}const o=Math.max(t.distance,t.elbowLen),l=(a+(o+Math.max(0,t.railWidth)+t.legPad+4)*s)/ka;return c(this,Ot,{fontScale:s,font:n,reserve:l}),l},Ca=function(i){const{context:t,entry:e,textColor:s,labels:n,hpr:a,progress:o}=i;if(o<=0)return;const{anchorX:l,anchorY:h,elbowX:u,elbowY:d,side:f,text:m,color:p,labelX:g,labelY:b}=e,y=g+f*n.legPad*a,M=Ss(o/.15,0,1),L=Ss((o-.15)/.45,0,1),x=Ss((o-.6)/.4,0,1);if(t.save(),t.globalAlpha=M,t.fillStyle=p,t.beginPath(),t.arc(l,h,2.5*a,0,Yi),t.fill(),t.restore(),L>0){t.save(),t.globalAlpha=L,t.strokeStyle=p,t.lineWidth=1*a,t.lineCap="round",t.beginPath(),t.moveTo(l,h);const k=l+(u-l)*L,C=h+(d-h)*L;if(t.lineTo(k,C),x>0){const A=u+(g-u)*x,T=d+(b-d)*x;t.lineTo(A,T)}t.stroke(),t.restore()}x>0&&(t.save(),t.globalAlpha=x,t.fillStyle=s,t.textAlign=f>=0?"left":"right",t.textBaseline="middle",t.fillText(m,y,b),t.restore())},Ta=function(i){const{cx:t,cy:e,outerR:s,total:n,palette:a,labels:o,hpr:l,bitmapHeight:h}=i,u=new Array(r(this,tt).length).fill(null),d=o.elbowLen*l,f=Math.max(o.distance,o.elbowLen)*l,m=Math.max(0,o.railWidth)*l,p=[];let g=-Math.PI/2;const b=o.minSliceAngle*Vn;for(let x=0;x<r(this,tt).length;x++){const k=r(this,tt)[x],C=S(this,rt,Te).call(this,k.value)/n*Yi;if(C>=b){const A=g+C/2,T=r(this,Mt)[x]*(8*l),D=Math.cos(A),B=Math.sin(A),w=D>=0?1:-1,W=t+D*(s+T),P=e+B*(s+T),z=t+D*(s+T+d),E=e+B*(s+T+d),V=t+D*(s+T+f)+w*m,X=e+B*(s+T+f),$={anchorX:W,anchorY:P,elbowX:z,elbowY:E,side:w,labelX:V,labelY:X,text:S(this,rt,Zs).call(this,k,n,o.content),color:k.color??a[x%a.length]};u[x]=$,p.push({entry:$})}g+=C}const y=Math.max(1,o.fontSize*o.labelGap)*l,M=o.fontSize*l,L=h-o.fontSize*l;for(const x of[1,-1]){const k=[];for(const T of p)T.entry.side===x&&k.push(T.entry);if(k.length===0)continue;k.sort((T,D)=>T.labelY-D.labelY);const C=[];for(let T=0;T<k.length;T++)for(C.push({count:1,sumIdeal:k[T].labelY,startIdx:T});C.length>=2;){const D=C[C.length-2],B=C[C.length-1],w=D.sumIdeal/D.count,W=B.sumIdeal/B.count,P=w+(D.count-1)*y/2;if(W-(B.count-1)*y/2>=P+y)break;D.count+=B.count,D.sumIdeal+=B.sumIdeal,C.pop()}if(C.length>0){const T=C[0],D=T.sumIdeal/T.count-(T.count-1)*y/2;if(D<M)for(T.sumIdeal+=(M-D)*T.count;C.length>=2;){const B=C[0],w=C[1],W=B.sumIdeal/B.count,P=w.sumIdeal/w.count,z=W+(B.count-1)*y/2;if(P-(w.count-1)*y/2>=z+y)break;B.count+=w.count,B.sumIdeal+=w.sumIdeal,C.splice(1,1)}}if(C.length>0){const T=C[C.length-1],D=T.sumIdeal/T.count+(T.count-1)*y/2;if(D>L)for(T.sumIdeal-=(D-L)*T.count;C.length>=2;){const B=C[C.length-2],w=C[C.length-1],W=B.sumIdeal/B.count,P=w.sumIdeal/w.count,z=W+(B.count-1)*y/2;if(P-(w.count-1)*y/2>=z+y)break;B.count+=w.count,B.sumIdeal+=w.sumIdeal,C.pop()}}const A=(M+L)/2;for(const T of C){const D=(T.count-1)*y,B=T.sumIdeal/T.count;D>L-M&&B-D/2<M&&(T.sumIdeal=A*T.count)}for(const T of C){const D=T.sumIdeal/T.count;for(let B=0;B<T.count;B++)k[T.startIdx+B].labelY=D+(B-(T.count-1)/2)*y}}for(const x of p){const k=x.entry,C=k.labelY-k.anchorY;let A;if(Math.abs(C)<=d){const B=k.side*Math.sqrt(Math.max(0,d*d-C*C));A=k.anchorX+B}else A=(k.anchorX+k.labelX)/2;const T=Math.min(k.anchorX,k.labelX),D=Math.max(k.anchorX,k.labelX);k.elbowX=Math.max(T,Math.min(D,A)),k.elbowY=k.labelY}return u};function As(i){if(!i.startsWith("#")||i.length!==4)return i;const t=i[1],e=i[2],s=i[3];return`#${t}${t}${e}${e}${s}${s}`}function La(i){const t=As(i);return!t.startsWith("#")||t.length<7?!1:parseInt(t.slice(1,3),16)*.299+parseInt(t.slice(3,5),16)*.587+parseInt(t.slice(5,7),16)*.114<128}function ot(i){var t,e,s,n,a,o,l,h,u,d,f,m,p,g,b,y,M,L,x,k,C,A,T,D,B,w,W,P,z,E,V,X,$,G;const{name:xt="Custom",description:Tt,fontUrl:_=null}=i,q=As(i.background),Z=La(q),K=Z?"#d1d4dc":"#24292f",Vt=Z?"#787b86":"#8b949e",kt=Z?"#26a69a":"#2da44e",Lt=Z?"#ef5350":"#cf222e",Ae=Z?"#2962ff":"#0969da",oe=Z?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",qe=Z?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Ds=Z?os(q,.1):jn(q,.05),zs=Z?Fi(q,.92):Fi(q,.95),Es=Z?Fi(os(q,.15),.6):"rgba(200,200,200,0.5)",Vs=gn,fi=((e=(t=i.candlestick)==null?void 0:t.up)==null?void 0:e.body)??kt,mi=((n=(s=i.candlestick)==null?void 0:s.down)==null?void 0:n.body)??Lt,gi=zt(fi),st=zt(mi),yt=((a=i.line)==null?void 0:a.color)??Ae,It=((o=i.tooltip)==null?void 0:o.textColor)??K,fr=((l=i.axis)==null?void 0:l.textColor)??Vt,ho=((h=i.typography)==null?void 0:h.fontFamily)??Vs,mr=((u=i.typography)==null?void 0:u.fontSize)??12,co=i.chartGradient??(Z?[os(q,.04),jn(q,.06)]:[os(q,.06),q]),uo={background:q,chartGradient:co,typography:{fontFamily:ho,fontSize:mr},grid:{color:((d=i.grid)==null?void 0:d.color)??oe,style:((f=i.grid)==null?void 0:f.style)??"solid"},candlestick:{up:{body:fi,wick:((p=(m=i.candlestick)==null?void 0:m.up)==null?void 0:p.wick)??gi},down:{body:mi,wick:((b=(g=i.candlestick)==null?void 0:g.down)==null?void 0:b.wick)??st}},line:{color:yt,width:((y=i.line)==null?void 0:y.width)??1,areaTopColor:((M=i.line)==null?void 0:M.areaTopColor)??Fi(yt,.08),areaBottomColor:((L=i.line)==null?void 0:L.areaBottomColor)??Fi(yt,.01)},seriesColors:i.seriesColors??[yt,kt,Lt],bands:{upper:((x=i.bands)==null?void 0:x.upper)??yt,lower:((k=i.bands)==null?void 0:k.lower)??st},crosshair:{color:((C=i.crosshair)==null?void 0:C.color)??qe,labelBackground:((A=i.crosshair)==null?void 0:A.labelBackground)??Ds,labelTextColor:((T=i.crosshair)==null?void 0:T.labelTextColor)??It},axis:{fontSize:((D=i.axis)==null?void 0:D.fontSize)??10,textColor:fr,...(B=i.axis)!=null&&B.x?{x:{...i.axis.x}}:{},...(w=i.axis)!=null&&w.y?{y:{...i.axis.y}}:{}},yLabel:{fontSize:((W=i.yLabel)==null?void 0:W.fontSize)??11,upBackground:((P=i.yLabel)==null?void 0:P.upBackground)??gi,downBackground:((z=i.yLabel)==null?void 0:z.downBackground)??st,neutralBackground:((E=i.yLabel)==null?void 0:E.neutralBackground)??Ds,textColor:((V=i.yLabel)==null?void 0:V.textColor)??"#ffffff"},tooltip:{fontSize:((X=i.tooltip)==null?void 0:X.fontSize)??mr,background:(($=i.tooltip)==null?void 0:$.background)??zs,textColor:It,borderColor:((G=i.tooltip)==null?void 0:G.borderColor)??Es},navigator:bh({dark:Z,bg:q,neutralFg:fr,upBody:fi,downBody:mi,upBase:gi,downBase:st,config:i.navigator})};return{name:xt,description:Tt,fontUrl:_,dark:Z,theme:uo}}function bh(i){var t,e,s,n,a,o,l,h,u,d,f,m,p,g,b,y,M,L;const{dark:x,bg:k,neutralFg:C,upBody:A,downBody:T,upBase:D,downBase:B,config:w}=i,W=(w==null?void 0:w.background)??"transparent",P=x?"rgba(255,255,255,1)":"rgba(0,0,0,1)",z=((t=w==null?void 0:w.handle)==null?void 0:t.color)??Ui(P,.3),E=((e=w==null?void 0:w.mask)==null?void 0:e.fill)??Ui(k,x?.78:.82);return{height:(w==null?void 0:w.height)??48,background:W,borderColor:(w==null?void 0:w.borderColor)??Ui(C,x?.18:.22),line:{color:((s=w==null?void 0:w.line)==null?void 0:s.color)??C,width:((n=w==null?void 0:w.line)==null?void 0:n.width)??1,areaTopColor:((a=w==null?void 0:w.line)==null?void 0:a.areaTopColor)??Ui(C,x?.22:.18),areaBottomColor:((o=w==null?void 0:w.line)==null?void 0:o.areaBottomColor)??Ui(C,0)},candlestick:{up:{body:((h=(l=w==null?void 0:w.candlestick)==null?void 0:l.up)==null?void 0:h.body)??A,wick:((d=(u=w==null?void 0:w.candlestick)==null?void 0:u.up)==null?void 0:d.wick)??D},down:{body:((m=(f=w==null?void 0:w.candlestick)==null?void 0:f.down)==null?void 0:m.body)??T,wick:((g=(p=w==null?void 0:w.candlestick)==null?void 0:p.down)==null?void 0:g.wick)??B}},window:{fill:((b=w==null?void 0:w.window)==null?void 0:b.fill)??"transparent",border:((y=w==null?void 0:w.window)==null?void 0:y.border)??"transparent",borderWidth:((M=w==null?void 0:w.window)==null?void 0:M.borderWidth)??0},handle:{color:z,width:((L=w==null?void 0:w.handle)==null?void 0:L.width)??6},mask:{fill:E}}}function Ui(i,t){if(i.startsWith("#")&&i.length===7)return Fi(i,t);const e=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:i}function Fi(i,t){const e=As(i),s=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${s}, ${n}, ${a}, ${t})`}function os(i,t){return i.startsWith("#")?wa(As(i),t):i}function jn(i,t){if(!i.startsWith("#"))return i;const e=As(i),s=Math.max(0,Math.round(parseInt(e.slice(1,3),16)*(1-t))),n=Math.max(0,Math.round(parseInt(e.slice(3,5),16)*(1-t))),a=Math.max(0,Math.round(parseInt(e.slice(5,7),16)*(1-t)));return`#${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function H(i){const t=i.startsWith("#")&&i.length===7?[os(i,.2),jn(i,.15)]:[i,i];return Object.defineProperty(t,"source",{value:i,enumerable:!1}),t}const fn="'JetBrains Mono', 'Fira Code', monospace",mn="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",gn="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",rr="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",Ia="'Roboto Mono', monospace",Wa="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",vh="'IBM Plex Mono', monospace",yh="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",ar="'Fira Code', monospace",or="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",Ra="'Source Code Pro', monospace",Aa="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",xh="'Space Mono', monospace",wh="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",lr="'Plus Jakarta Sans', sans-serif",hr="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",Mh="'Caveat', 'Comic Sans MS', cursive",kh="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Pa=ot({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(90,92,116,0.2)"},candlestick:{up:{body:H("#a6e3a1"),wick:"#a6e3a1"},down:{body:H("#f38ba8"),wick:"#f38ba8"}},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.7)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:gn},fontUrl:rr});let Sh=0;var ut,nt,Ht,ls,O,ft,hs,dt,St,mt,ze,Bi,Zt,Js,Qs,be,cs,ti,Cs,rn,Wt,Q,ci,an,ne,et,Oi,Le,on,gt,ji,Bt,bt,Di,ge,us,ds,j,Ee,Fa,Ba,Da,za,fs,Ct,li,Hi,Ts,Ls,Hn,Ea,Xi,ms,Va,Tn,ui,$n,On,Xt;class Ya extends un{constructor(t,e){var s,n,a,o,l,h;super(),v(this,j),v(this,ut),v(this,nt),v(this,Ht),F(this,"timeScale"),F(this,"yScale"),v(this,ls),v(this,O,[]),v(this,ft),v(this,hs),v(this,dt,6e4),v(this,St,null),v(this,mt,{}),v(this,ze,null),v(this,Bi,{}),v(this,Zt,{left:"idle",right:"idle"}),v(this,Js,{left:null,right:null}),v(this,Qs),v(this,be,0),v(this,cs,!1),v(this,ti,!1),v(this,Cs,!1),v(this,rn,0),v(this,Wt),v(this,Q),v(this,ci),v(this,an,!1),v(this,ne,null),v(this,et,null),v(this,Oi,null),v(this,Le,!1),v(this,on),v(this,gt,{from:0,to:0}),v(this,ji,{min:0,max:0}),v(this,Bt,!0),v(this,bt),v(this,Di,0),v(this,ge),v(this,us,!1),v(this,ds,null),v(this,fs,!1),v(this,Ct,!1),v(this,li,!1),v(this,Hi),v(this,Ts,Number.NaN),v(this,Ls,Number.NaN),e!=null&&e.axis&&(c(this,Bi,e.axis),c(this,mt,{min:(s=e.axis.y)==null?void 0:s.min,max:(n=e.axis.y)==null?void 0:n.max})),c(this,ft,(e==null?void 0:e.theme)??Pa.theme),c(this,hs,((a=e==null?void 0:e.grid)==null?void 0:a.visible)!==!1),c(this,Wt,nn.resolve(e==null?void 0:e.animations)),c(this,on,ul((o=e==null?void 0:e.viewport)==null?void 0:o.maxVisibleBars)),c(this,bt,kr(e==null?void 0:e.padding)),c(this,ci,new gl);const u=r(this,Wt).axis.y,d=r(this,Wt).axis.x;c(this,Q,Mo({initial:{yRange:{min:0,max:0},xRange:{from:0,to:0}},y:{curve:u.curve,settleMs:u.settleMs,stickyMs:u.stickyMs,stickyFloorMs:u.stickyFloorMs,gestureMs:u.gestureMs,toggleMs:r(this,Wt).toggleMs},x:{curve:d.curve,settleMs:d.settleMs,gestureMs:d.gestureMs},computeXTarget:()=>S(this,j,Ea).call(this),computeYTarget:({xTarget:b})=>S(this,j,Hn).call(this,b),onWake:()=>{var b;return(b=r(this,nt))==null?void 0:b.markDirty()}})),c(this,Qs,e==null?void 0:e.onEdgeReached),c(this,Hi,(l=e==null?void 0:e.viewport)==null?void 0:l.initialRange);const f=cl(e==null?void 0:e.perf);c(this,ge,f.monitor),c(this,us,f.ownsMonitor),c(this,ut,new Vo(t,r(this,ge)??void 0)),this.timeScale=new ga,this.yScale=new va;const m=r(this,Wt).axis.ticksMs;this.timeScale.tickTracker.setFadeMs(m),this.yScale.tickTracker.setFadeMs(m);const p=r(this,ge);p?(c(this,nt,new Hs(b=>{p.resetDrawCalls("main");const y=performance.now();this.renderMain(b),p.recordFrame("main",performance.now()-y,b)})),c(this,Ht,new Hs(b=>{p.resetDrawCalls("overlay");const y=performance.now();this.renderOverlay(b),p.recordFrame("overlay",performance.now()-y,b)})),f.showHud&&c(this,ds,new Al(t,p))):(c(this,nt,new Hs(b=>this.renderMain(b))),c(this,Ht,new Hs(b=>this.renderOverlay(b))));const g=(e==null?void 0:e.interactive)!==!1;c(this,ls,g?new Cl(r(this,ut).canvas,this,this.timeScale,this.yScale):null),r(this,ut).on("resize",()=>{this.syncScales(),this.renderMain(),this.emit("viewportChange")}),this.syncScales(),(h=r(this,ls))==null||h.on("crosshairMove",b=>{c(this,St,b),r(this,Ht).markDirty(),this.emit("crosshairMove",b),S(this,j,za).call(this,b)})}get yAxisWidth(){const t=r(this,Bi).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=r(this,Bi).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return r(this,rn)}addSeries(t,e={}){var s;const{layers:n,id:a,...o}=e,l=n??1,h={...r(this,Wt).defaults(t),...o,...r(this,Wt).overrides(t)},u=S(this,j,Ba).call(this,t,l,h),d=S(this,j,Fa).call(this,a);return(s=u.onDataChanged)==null||s.call(u,()=>this.onDataChanged()),r(this,O).push({id:d,label:o.label,renderer:u,visible:!0}),c(this,ze,null),this.emit("seriesChange"),S(this,j,Ee).call(this),d}removeSeries(t){const e=r(this,O).findIndex(s=>s.id===t);e>=0&&(r(this,O)[e].renderer.dispose(),r(this,O).splice(e,1),c(this,ze,null),r(this,nt).markDirty(),this.emit("seriesChange"),S(this,j,Ee).call(this))}getAnimationState(){return r(this,Q).getAnimationState()}setSeriesData(t,e,s){const n=r(this,O).find(a=>a.id===t);n&&(c(this,fs,!0),n.renderer.setData(e,s))}appendData(t,e,s){const n=r(this,O).find(a=>a.id===t);n===void 0||n.renderer.appendPoint===void 0||n.renderer.appendPoint(e,s)}updateData(t,e,s){var n,a;const o=r(this,O).find(l=>l.id===t);(a=o==null?void 0:(n=o.renderer).updateLastPoint)==null||a.call(n,e,s)}keepLast(t,e,s){var n,a;const o=r(this,O).find(l=>l.id===t);(a=o==null?void 0:(n=o.renderer).keepLast)==null||a.call(n,e,s)}updateSeriesOptions(t,e){const s=r(this,O).find(d=>d.id===t);if(!s)return;const n=s.label,a=s.renderer.getLayerColors().slice(),o=r(this,Wt).overrides(s.renderer.kind);s.renderer.updateOptions({...e,...o}),"label"in e&&typeof e.label=="string"&&(s.label=e.label),r(this,nt).markDirty();const l=s.renderer.getLayerColors(),h=a.length!==l.length||a.some((d,f)=>d!==l[f]),u=n!==s.label;(h||u)&&S(this,j,Ee).call(this)}batch(t){Rn(this,be)._++;try{t()}finally{if(--Rn(this,be)._<=0){if(c(this,be,0),r(this,cs))c(this,cs,!1),c(this,ti,!1),this.onDataChanged();else if(r(this,ti)){c(this,ti,!1),c(this,Ct,!0);const e=performance.now();r(this,Q).onAxisReconfig(e),S(this,j,Xt).call(this,e),r(this,nt).markDirty()}r(this,Cs)&&(c(this,Cs,!1),this.emit("overlayChange"))}}}setSeriesVisible(t,e){var s,n;const a=r(this,O).find(h=>h.id===t);if(!a||a.visible===e)return;a.visible=e,S(this,j,Ee).call(this);const o=r(this,Wt).toggleMs;if((n=(s=a.renderer).setAlpha)==null||n.call(s,e?1:0,o),r(this,nt).markDirty(),r(this,be)>0){c(this,ti,!0);return}c(this,Ct,!0);const l=performance.now();r(this,Q).onSeriesVisibilityChanged(l),S(this,j,Xt).call(this,l)}getAutoScroll(){return r(this,Bt)}isSeriesVisible(t){var e;return((e=r(this,O).find(s=>s.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,s){var n,a;const o=r(this,O).find(u=>u.id===t);if(!o||o.renderer.getLayerCount()<=1||o.renderer.isLayerVisible(e)===s)return;o.renderer.setLayerVisible(e,s),S(this,j,Ee).call(this);const l=r(this,Wt).toggleMs;if((a=(n=o.renderer).setLayerAlpha)==null||a.call(n,e,s?1:0,l),r(this,nt).markDirty(),r(this,be)>0){c(this,ti,!0);return}c(this,Ct,!0);const h=performance.now();r(this,Q).onSeriesVisibilityChanged(h),S(this,j,Xt).call(this,h)}isLayerVisible(t,e){const s=r(this,O).find(n=>n.id===t);return(s==null?void 0:s.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const s=r(this,ut).size.media.width-this.yAxisWidth;S(this,j,Xi).call(this,t,e,s),S(this,j,ms).call(this,{xEase:!0})}getVisibleRange(){return r(this,gt).from===0&&r(this,gt).to===0?r(this,Q).getAnimationState().xRange:r(this,gt)}getDataRange(){return r(this,ne)===null||r(this,et)===null?null:{from:r(this,ne),to:r(this,et)}}setVisibleRange(t,e){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:o,last:l}=this.getDataBounds();if(o===void 0||l===void 0)return;const h=Math.max(o,l-(t-1)*r(this,dt)),u=r(this,ut).size.media.width-this.yAxisWidth;S(this,j,Xi).call(this,h,l,u),S(this,j,ms).call(this);return}if("bars"in t){if(!Number.isInteger(t.bars)||t.bars<2)return;const o=Et(t.from),l=o+t.bars*r(this,dt);c(this,Bt,r(this,et)!==null&&r(this,et)>=o&&r(this,et)<=l),S(this,j,ui).call(this,{from:o,to:l},{emitChange:!0}),c(this,Le,!0),S(this,j,ms).call(this);return}const s=Et(t.from),n=Et(t.to);c(this,Bt,r(this,et)!==null&&r(this,et)>=s&&r(this,et)<=n),c(this,Le,!1);const a=S(this,j,ui).call(this,{from:s,to:n},{emitChange:!0});if(e!=null&&e.gesture){a&&S(this,j,Va).call(this);return}S(this,j,ms).call(this)}getYRange(){return r(this,ji)}getCrosshairPosition(){return r(this,St)}setCrosshair(t){if(t===null){if(r(this,St)===null)return;c(this,St,null),r(this,Ht).markDirty(),this.emit("crosshairMove",null);return}const{time:e}=t;if(!Number.isFinite(e))return;const s=r(this,St);let n;if(t.y!==void 0)n=t.y;else if(s!==null)n=s.y;else{const l=r(this,ji);n=(l.min+l.max)/2}if(!Number.isFinite(n)||s!==null&&s.time===e&&s.y===n)return;const a=this.timeScale.timeToX(e),o=this.yScale.valueToY(n);c(this,St,{mediaX:a,mediaY:o,time:e,y:n}),r(this,Ht).markDirty(),this.emit("crosshairMove",r(this,St))}getLastValue(t){return ca(t,r(this,O),r(this,Q).getAnimationState().xRange)}getPreviousClose(t){return Jo(t,r(this,O))}getLastData(t){const e=r(this,O).find(s=>s.id===t);return!e||e.renderer.kind==="pie"?null:e.renderer.getLastDataPoint()}getDataAtTime(t,e){var s,n;const a=r(this,O).find(o=>o.id===t);return a?((n=(s=a.renderer).getDataAtTime)==null?void 0:n.call(s,e,r(this,dt)))??null:null}getLayerSnapshots(t,e){var s,n;const a=r(this,O).find(o=>o.id===t);return a!=null&&a.visible?((n=(s=a.renderer).getLayerSnapshots)==null?void 0:n.call(s,e,r(this,dt)))??null:null}getSeriesIds(){return r(this,ze)||c(this,ze,r(this,O).map(t=>t.id)),r(this,ze).slice()}getSeriesIdsByType(t,e){const s=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,a=[];for(const o of r(this,O)){const l=o.renderer.kind==="pie";if(t==="pie"&&!l||t==="time"&&l)continue;const h=o.renderer.getLayerCount();if(!(n&&h>1)){if(s){if(!o.visible)continue;if(h>1){let u=!1;for(let d=0;d<h;d++)if(o.renderer.isLayerVisible(d)){u=!0;break}if(!u)continue}}a.push(o.id)}}return a}getStackedLastValue(t){return Zo(t,r(this,O),r(this,Q).getAnimationState().xRange)}getLayerLastSnapshots(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:s.call(e))??null}listSeriesForTest(){return r(this,O).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=r(this,O).find(s=>s.id===t);return e?e.renderer.getLayerColors()[0]??r(this,ft).line.color:null}getSeriesLabel(t){var e;return(e=r(this,O).find(s=>s.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=r(this,O).find(a=>a.id===t);if(!e)return null;const s=e.renderer.getLayerCount();if(s<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:s},(a,o)=>({color:n[o%n.length]}))}getSliceInfo(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:s.call(e,r(this,ft)))??null}getHoverInfo(t){var e,s;const n=r(this,O).find(a=>a.id===t);return((s=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:s.call(e,r(this,ft)))??null}setTheme(t){const e=r(this,ft);c(this,ft,t);for(const s of r(this,O))s.renderer.applyTheme(t,e);r(this,nt).markDirty(),S(this,j,Ee).call(this)}getTheme(){return r(this,ft)}setAxis(t){var e,s;const n=this.yAxisWidth,a=this.xAxisHeight;c(this,Bi,t),c(this,mt,{min:(e=t.y)==null?void 0:e.min,max:(s=t.y)==null?void 0:s.max}),c(this,Ct,!0);const o=performance.now();r(this,Q).onAxisReconfig(o),S(this,j,Xt).call(this,o),(this.yAxisWidth!==n||this.xAxisHeight!==a)&&this.syncScales(),r(this,nt).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),r(this,nt).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),r(this,nt).markDirty())}getMediaSize(){return r(this,ut).size.media}getLayout(){const t=r(this,ut).size.media,e=this.yAxisWidth,s=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-s},yAxisWidth:e,xAxisHeight:s}}getDataInterval(){return r(this,dt)}setPadding(t){const e=r(this,bt);c(this,bt,kr(t));const s=r(this,bt),n=!Sr(e.left,s.left)||!Sr(e.right,s.right),a=e.top!==s.top||e.bottom!==s.bottom;if(n){const{first:o,last:l}=this.getDataBounds();if(o!==void 0&&l!==void 0){const h=r(this,ut).size.media.width-this.yAxisWidth;S(this,j,Xi).call(this,o,l,h)}}if(n||a){c(this,Ct,!0);const o=performance.now();r(this,Q).onAxisReconfig(o),S(this,j,Xt).call(this,o)}this.syncScales(),r(this,nt).markDirty(),a&&this.emit("viewportChange")}setGrid(t){c(this,hs,t.visible),r(this,nt).markDirty()}setEdgeState(t,e){r(this,Zt)[t]!==e&&(r(this,Zt)[t]=e,r(this,Ht).markDirty())}getEdgeState(t){return r(this,Zt)[t]}setYLabel(t){}destroy(){var t,e,s;for(const n of r(this,O))n.renderer.dispose();c(this,O,[]),c(this,ze,null),r(this,nt).destroy(),r(this,Ht).destroy(),(t=r(this,ls))==null||t.destroy(),r(this,ut).destroy(),(e=r(this,ds))==null||e.destroy(),c(this,ds,null),r(this,us)&&((s=r(this,ge))==null||s.destroy()),c(this,ge,null),c(this,us,!1),this.removeAllListeners()}getPerfMonitor(){return r(this,ge)}getDataBounds(){let t,e;for(const s of r(this,O)){if(!s.visible||s.renderer.kind==="pie")continue;const n=s.renderer.getTimeBounds();n!==null&&((t===void 0||n.first<t)&&(t=n.first),(e===void 0||n.last>e)&&(e=n.last))}return{first:t,last:e}}onDataChanged(){if(r(this,be)>0){c(this,cs,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&c(this,ne,t),e!==void 0&&(c(this,Oi,r(this,et)),c(this,et,e));const s=r(this,fs);c(this,fs,!1);const n=!r(this,Ct)&&t!==void 0;s&&(this.yScale.tickTracker.reset(),this.timeScale.tickTracker.reset()),c(this,an,s);const a=performance.now();s||n?r(this,Q).onDataReplaced(a):r(this,Q).onPointAppended(a),r(this,Q).lastXTarget!==null&&c(this,li,!0),t!==void 0&&c(this,Ct,!0),S(this,j,Xt).call(this,a),this.syncScales(),n?this.renderMain():r(this,nt).markDirty(),this.emit("dataUpdate"),S(this,j,Ee).call(this)}updateDataInterval(){for(const t of r(this,O)){if(t.renderer.kind==="pie")continue;const e=t.renderer.sampleTimes(20);if(e.length>=2){c(this,dt,na(e));break}}}pan(t,e=r(this,Di)){var s;e>0&&c(this,Di,e),c(this,Le,!1);const n=ll({currentLogical:r(this,gt),timeDelta:t,chartWidth:e,dataInterval:r(this,dt),padding:{left:r(this,bt).left,right:r(this,bt).right},dataStart:r(this,ne),dataEnd:r(this,et)});n.newLogical!==null&&(c(this,Bt,!n.autoScrollOff),S(this,j,ui).call(this,n.newLogical,{emitChange:!0}),n.edgeReached!==null&&(r(this,Js)[n.edgeReached.side]=n.edgeReached.boundaryTime,(s=r(this,Qs))==null||s.call(this,n.edgeReached)),r(this,ci).pause(),S(this,j,On).call(this))}zoomAt(t,e,s=r(this,Di)){s>0&&c(this,Di,s),c(this,Le,!1);const n=hl({currentLogical:r(this,gt),centerTime:t,factor:e,chartWidth:s,dataInterval:r(this,dt),padding:{left:r(this,bt).left,right:r(this,bt).right},dataStart:r(this,ne),dataEnd:r(this,et)});if(n.newLogical===null)return;let a=n.newLogical;if(r(this,Bt)&&r(this,et)!==null){const o=a.to-a.from,l=Ge(r(this,bt).right,o,r(this,dt),s),h=r(this,et)+l;a={from:h-o,to:h},c(this,Oi,r(this,et))}S(this,j,ui).call(this,a,{emitChange:!0}),r(this,ci).pause(),S(this,j,On).call(this)}syncScales(){const t=r(this,ut).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,s=t.media.height-this.xAxisHeight;this.timeScale.update(r(this,Q).getAnimationState().xRange,e,t.horizontalPixelRatio,r(this,dt)),this.yScale.update(r(this,ji),s,t.verticalPixelRatio)}renderMain(t){const e=r(this,ut).size;if(e.media.width===0||e.media.height===0)return;const s=typeof t=="number"?t:performance.now(),n=r(this,Q).tick(s);n.animating&&r(this,nt).markDirty();const a=n.yRange.min,o=n.yRange.max,l=a!==r(this,Ts)||o!==r(this,Ls);if(l){const m=r(this,mt).min!==void 0&&r(this,mt).min!=="auto",p=r(this,mt).max!==void 0&&r(this,mt).max!=="auto",g=e.media.height-this.xAxisHeight;S(this,j,$n).call(this,a,o,g,m,p),c(this,Ts,a),c(this,Ls,o)}if(this.syncScales(),r(this,et)!==null&&!r(this,Bt)){const m=r(this,Q).lastXTarget??r(this,gt),p=m.to-m.from;if(p>0){const g=r(this,ut).size.media.width-this.yAxisWidth,b=Ge(r(this,bt).right,p,r(this,dt),g),y=r(this,dt)*.5;Math.abs(m.to-(r(this,et)+b))<y&&c(this,Bt,!0)}}l&&this.emit("viewportChange");let h=!1,u=!1;r(this,ut).useMainLayer(m=>{var p,g;const{context:b,bitmapSize:y}=m,M=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,L=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;b.clearRect(0,0,y.width,y.height),b.save(),b.beginPath(),b.rect(0,0,M,L),b.clip(),this.yScale.tickTracker.setCurrentTicks(this.yScale.niceTickValues()),this.timeScale.tickTracker.setCurrentTicks(this.timeScale.niceTickValues(r(this,dt)).ticks),this.yScale.tickTracker.tick(s),this.timeScale.tickTracker.tick(s);const x=this.yScale.tickTracker.snapshot(),k=this.timeScale.tickTracker.snapshot();h=x.isAnimating,u=k.isAnimating,(x.isAnimating||k.isAnimating||n.animating)&&this.emit("tickFrame"),r(this,hs)&&wl({scope:m,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,ft),yTicks:x,timeTicks:k});const C=r(this,bt),A={top:C.top,bottom:C.bottom},T=r(this,ge);for(const D of r(this,O)){const B=((g=(p=D.renderer).getAlpha)==null?void 0:g.call(p))??(D.visible?1:0);if(B<=0)continue;const w={scope:m,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,ft),dataInterval:r(this,dt),padding:A,state:n,seriesId:D.id},W=b.globalAlpha;if(B<1&&(b.globalAlpha=W*B),T){const P=performance.now();D.renderer.render(w),T.recordSeries(D.id,performance.now()-P,s)}else D.renderer.render(w);B<1&&(b.globalAlpha=W)}b.restore()});let d=!1;for(const m of r(this,O))if(m.renderer.needsAnimation){d=!0,r(this,nt).markDirty();break}const f=h||u;!n.animating&&!d&&!f&&(this.yScale.tickTracker.markArmed(),this.timeScale.tickTracker.markArmed()),this.renderOverlay()}renderOverlay(t){var e,s;const n=r(this,ut).size;if(n.media.width===0||n.media.height===0)return;let a=!1;for(const h of r(this,O))if(h.visible&&h.renderer.overlayNeedsAnimation){a=!0;break}const o=r(this,Zt).left==="loading"||r(this,Zt).right==="loading",l=r(this,Zt).left!=="idle"||r(this,Zt).right!=="idle";if(r(this,ut).useOverlayLayer(h=>{var u,d;if(!r(this,St)&&!a&&!l)return;const f=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,m=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,f,m),h.context.clip(),r(this,St)&&S(this,j,Da).call(this)){const y=r(this,St).mediaX*n.horizontalPixelRatio,M=r(this,St).mediaY*n.verticalPixelRatio;xl(h,y,M,r(this,ft))}const p=r(this,bt),g={top:p.top,bottom:p.bottom},b=r(this,Q).getAnimationState();for(const y of r(this,O))y.visible&&((d=(u=y.renderer).drawOverlay)==null||d.call(u,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:r(this,ft),dataInterval:r(this,dt),padding:g,crosshair:r(this,St),state:b,seriesId:y.id}));l&&Go({scope:h,chartMediaHeight:n.media.height-this.xAxisHeight,timeScale:this.timeScale,theme:r(this,ft),edgeStates:r(this,Zt),resolveBoundary:y=>Ko(y,r(this,Js)[y],this.getDataBounds())}),h.context.restore()}),a){const{from:h,to:u}=this.timeScale.getRange();let d=!1;for(const f of r(this,O))if(!(!f.visible||!f.renderer.overlayNeedsAnimation)&&(((s=(e=f.renderer).hasOverlayContentInRange)==null?void 0:s.call(e,h,u))??!0)){d=!0;break}d&&r(this,Ht).markDirty()}o&&r(this,Ht).markDirty()}}ut=new WeakMap,nt=new WeakMap,Ht=new WeakMap,ls=new WeakMap,O=new WeakMap,ft=new WeakMap,hs=new WeakMap,dt=new WeakMap,St=new WeakMap,mt=new WeakMap,ze=new WeakMap,Bi=new WeakMap,Zt=new WeakMap,Js=new WeakMap,Qs=new WeakMap,be=new WeakMap,cs=new WeakMap,ti=new WeakMap,Cs=new WeakMap,rn=new WeakMap,Wt=new WeakMap,Q=new WeakMap,ci=new WeakMap,an=new WeakMap,ne=new WeakMap,et=new WeakMap,Oi=new WeakMap,Le=new WeakMap,on=new WeakMap,gt=new WeakMap,ji=new WeakMap,Bt=new WeakMap,bt=new WeakMap,Di=new WeakMap,ge=new WeakMap,us=new WeakMap,ds=new WeakMap,j=new WeakSet,Ee=function(){if(Rn(this,rn)._++,r(this,be)>0){c(this,Cs,!0);return}this.emit("overlayChange")},Fa=function(i){if(i&&!r(this,O).some(e=>e.id===i))return i;let t;do t=`series_${++Sh}`;while(r(this,O).some(e=>e.id===t));return t},Ba=function(i,t,e){switch(i){case"candlestick":return new rh(new ua,{up:{...r(this,ft).candlestick.up},down:{...r(this,ft).candlestick.down},...e});case"line":return new oh(t,{colors:t===1?[r(this,ft).line.color]:r(this,ft).seriesColors.slice(0,t),strokeWidth:r(this,ft).line.width,...e});case"bar":return new ql(t,{colors:r(this,ft).seriesColors.slice(0,t),...e});case"pie":return new ph({...e})}},Da=function(){for(const i of r(this,O))if(i.visible&&i.renderer.kind!=="pie")return!0;return!1},za=function(i){const t=r(this,ut).size,e=r(this,bt),s={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const a of r(this,O)){if(!a.renderer.hitTest||!a.renderer.setHoverIndex)continue;let o=-1;if(i){const l=i.mediaX*t.horizontalPixelRatio,h=i.mediaY*t.verticalPixelRatio;o=a.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,s)}a.renderer.setHoverIndex(o)&&(n=!0)}n&&r(this,nt).markDirty()},fs=new WeakMap,Ct=new WeakMap,li=new WeakMap,Hi=new WeakMap,Ts=new WeakMap,Ls=new WeakMap,Hn=function(i){const t=i??r(this,gt),e=r(this,mt).min!==void 0&&r(this,mt).min!=="auto"&&typeof r(this,mt).min!="number"||r(this,mt).max!==void 0&&r(this,mt).max!=="auto"&&typeof r(this,mt).max!="number"?[]:null,s=yl(t,r(this,O),e);if(s===null)return c(this,Ct,!1),null;const n=Tr(r(this,mt).min,s.min,s.max,e??[],"min"),a=Tr(r(this,mt).max,s.max,s.min,e??[],"max");return{min:n,max:a}},Ea=function(){if(r(this,ne)===null||r(this,et)===null)return null;const{from:i,to:t}=r(this,gt),e=i===0&&t===0,s=r(this,ut).size.media.width-this.yAxisWidth;if(e)return S(this,j,Xi).call(this,r(this,ne),r(this,et),s),r(this,Hi)!==void 0&&(this.setVisibleRange(r(this,Hi)),c(this,Hi,void 0)),r(this,gt);if(!r(this,Bt))return null;if(r(this,an))return S(this,j,Xi).call(this,r(this,ne),r(this,et),s),r(this,gt);const n=vl({currentLogical:r(this,gt),lastTime:r(this,et),prevDataEnd:r(this,Oi),dataInterval:r(this,dt),paddingRight:r(this,bt).right,chartWidth:s,holdUntilFilled:r(this,Le)});return n.releaseHold&&c(this,Le,!1),n.reengageAutoScroll&&c(this,Bt,!0),n.newLogical===null?null:(r(this,ci).observe(performance.now()),r(this,Q).setXSettleMs(r(this,ci).pickSettleMs(r(this,Wt).axis.x.settleMs)),S(this,j,ui).call(this,n.newLogical,{emitChange:!1,skipValidation:!0}),c(this,Oi,r(this,et)),n.newLogical)},Xi=function(i,t,e){const s=r(this,bt),n=qo({firstTime:i,lastTime:t,dataInterval:r(this,dt),maxVisibleBars:r(this,on),chartWidth:e,padding:{left:s.left,right:s.right}});c(this,Le,!1),c(this,Bt,!0),S(this,j,ui).call(this,n,{emitChange:!0})},ms=function(i){const t=r(this,gt);if(t.to<=t.from)return;const e=performance.now();if(!r(this,li)||!r(this,Ct)){S(this,j,Tn).call(this,e);return}r(this,Q).onProgrammaticZoom({xTarget:t,xEase:i==null?void 0:i.xEase},e),S(this,j,Xt).call(this,e)},Va=function(){const i=r(this,gt);if(i.to<=i.from)return;const t=performance.now();if(!r(this,li)||!r(this,Ct)){S(this,j,Tn).call(this,t);return}r(this,Q).onPanZoom({xTarget:i,yAuto:!0},t),S(this,j,Xt).call(this,t)},Tn=function(i){const t=r(this,gt),e=S(this,j,Hn).call(this,t);c(this,li,!0),e!==null&&c(this,Ct,!0),r(this,Q).snap({x:t,y:e??void 0},i),S(this,j,Xt).call(this,i)},ui=function(i,t){var e;const{from:s,to:n}=i;return!Number.isFinite(s)||!Number.isFinite(n)||n<=s||!t.skipValidation&&(n-s)/r(this,dt)<2||r(this,gt).from===s&&r(this,gt).to===n?!1:(c(this,gt,{from:s,to:n}),t.emitChange&&(this.syncScales(),(e=r(this,nt))==null||e.markDirty(),this.emit("viewportChange")),!0)},$n=function(i,t,e,s,n){const a=t-i,o=e>0?r(this,bt).top/e*a:0,l=e>0?r(this,bt).bottom/e*a:0;c(this,ji,{min:s?i:i-l,max:n?t:t+o})},On=function(){const i=r(this,gt);if(i.to<=i.from)return;c(this,li,!0),c(this,Ct,!0);const t=performance.now();r(this,Q).onPanZoom({xTarget:i,yAuto:!0},t),S(this,j,Xt).call(this,t)},Xt=function(i){const t=r(this,Q).tick(i),e=r(this,ut).size;if(e.media.width===0||e.media.height===0)return;const s=r(this,mt).min!==void 0&&r(this,mt).min!=="auto",n=r(this,mt).max!==void 0&&r(this,mt).max!=="auto",a=e.media.height-this.xAxisHeight;S(this,j,$n).call(this,t.yRange.min,t.yRange.max,a,s,n),c(this,Ts,t.yRange.min),c(this,Ls,t.yRange.max),this.syncScales()};const Ni={len:0,firstTime:null,lastTime:null},Ch=20;function cr(i){const{chart:t,id:e,data:s,prev:n,layerIndex:a}=i;if(s.length===0)return t.setSeriesData(e,[],a),{len:0,firstTime:null,lastTime:null};const o=Et(s[0].time),l=Et(s[s.length-1].time),h=n.firstTime!==null&&n.firstTime!==o,u=s.length-n.len,d=n.lastTime!==null&&n.lastTime!==l;if(h&&u===0&&d)t.appendData(e,s[s.length-1],a),t.keepLast(e,s.length,a);else if(n.len===0||s.length<n.len||u>Ch||h)t.setSeriesData(e,s,a);else if(s.length===n.len)t.updateData(e,s[s.length-1],a);else for(let f=n.len;f<s.length;f++)t.appendData(e,s[f],a);return{len:s.length,firstTime:o,lastTime:l}}function Th(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const a=n/t,o=[];let l=0;for(let h=0;h<t;h++){const u=h===t-1?s+1:e+(h+1)*a;let d=null,f=null;for(;l<i.length&&i[l].time<u;){const m=i[l];(d===null||m.value<d.value)&&(d=m),(f===null||m.value>f.value)&&(f=m),l++}if(!(d===null||f===null)){if(d===f){o.push(d);continue}d.time<f.time?o.push(d,f):o.push(f,d)}}return o}function Lh(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const a=n/t,o=[];let l=0;for(let h=0;h<t;h++){const u=h===t-1?s+1:e+(h+1)*a;let d=null;for(;l<i.length&&i[l].time<u;){const f=i[l];d===null?d={time:f.time,open:f.open,high:f.high,low:f.low,close:f.close}:(f.high>d.high&&(d.high=f.high),f.low<d.low&&(d.low=f.low),d.close=f.close),l++}d!==null&&o.push(d)}return o}const $r=8;function ja(i,t){return Math.abs(i-t.left)<=$r?{gesture:"resize-left",snapToCenter:!1}:Math.abs(i-t.right)<=$r?{gesture:"resize-right",snapToCenter:!1}:i>t.left&&i<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function Ih(i){const{startVisible:t,deltaPx:e,pixelsPerTime:s,dataRange:n}=i,a=t.to-t.from,o=e/s;let l=t.from+o,h=t.to+o;return l<n.from&&(l=n.from,h=l+a),h>n.to&&(h=n.to,l=h-a),l<n.from&&(l=n.from),{from:l,to:h}}function Wh(i){const{edge:t,startVisible:e,deltaPx:s,pixelsPerTime:n,dataRange:a,minSpan:o}=i,l=s/n;if(t==="left"){let d=e.from+l,f=e.to;return d<a.from&&(d=a.from),f-d<o&&(d=f-o),d<a.from&&(d=a.from,f=Math.min(a.to,d+o)),{from:d,to:f}}let h=e.from,u=e.to+l;return u>a.to&&(u=a.to),u-h<o&&(u=h+o),u>a.to&&(u=a.to,h=Math.max(a.from,u-o)),{from:h,to:u}}function Rh(i){const{time:t,startVisible:e,xRange:s}=i,n=e.to-e.from;let a=t-n/2,o=a+n;return a<s.from&&(a=s.from,o=a+n),o>s.to&&(o=s.to,a=o-n),a<s.from&&(a=s.from),{from:a,to:o}}function Ah(i){const{ctx:t,theme:e,mediaWidth:s,mediaHeight:n}=i;t.fillStyle=e.background,t.fillRect(0,0,s,n)}function Ph(i,t,e=!0,s=1){if(t.length<2)return;const{ctx:n,timeScale:a,yScale:o,mediaHeight:l,theme:h}=i,u=s<1&&t.length>=2,d=u?t.length-2:t.length-1;if(e){const f=n.createLinearGradient(0,0,0,l);f.addColorStop(0,h.line.areaTopColor),f.addColorStop(1,h.line.areaBottomColor),n.beginPath();for(let m=0;m<=d;m++){const p=t[m],g=a.timeToX(p.time),b=o.valueToY(p.value);m===0?n.moveTo(g,b):n.lineTo(g,b)}if(n.lineTo(a.timeToX(t[d].time),l),n.lineTo(a.timeToX(t[0].time),l),n.closePath(),n.fillStyle=f,n.fill(),u){n.save(),n.globalAlpha=s,n.beginPath();const m=t[d],p=t[t.length-1],g=a.timeToX(m.time),b=a.timeToX(p.time);n.moveTo(g,o.valueToY(m.value)),n.lineTo(b,o.valueToY(p.value)),n.lineTo(b,l),n.lineTo(g,l),n.closePath(),n.fillStyle=f,n.fill(),n.restore()}}n.beginPath();for(let f=0;f<=d;f++){const m=t[f],p=a.timeToX(m.time),g=o.valueToY(m.value);f===0?n.moveTo(p,g):n.lineTo(p,g)}if(n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),u){n.save(),n.globalAlpha=s,n.beginPath();const f=t[d],m=t[t.length-1];n.moveTo(a.timeToX(f.time),o.valueToY(f.value)),n.lineTo(a.timeToX(m.time),o.valueToY(m.value)),n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),n.restore()}}function Fh(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:a,mediaHeight:o,theme:l}=i,h=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.8:2),u=e<1,d=t.length-1;s.fillStyle=l.line.color;for(let f=0;f<t.length;f++){const m=t[f],p=n.timeToX(m.time),g=a.valueToY(m.value),b=Math.max(1,o-g);u&&f===d?(s.save(),s.globalAlpha=e,s.fillRect(p-h/2,g,h,b),s.restore()):s.fillRect(p-h/2,g,h,b)}}function Bh(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:a,theme:o}=i,l=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.75:2),h=e<1,u=t.length-1;for(let d=0;d<t.length;d++){const f=t[d],m=f.close>=f.open?o.candlestick.up:o.candlestick.down,p=zt(m.body),g=n.timeToX(f.time),b=a.valueToY(f.open),y=a.valueToY(f.close),M=a.valueToY(f.high),L=a.valueToY(f.low),x=h&&d===u;x&&(s.save(),s.globalAlpha=e),s.strokeStyle=m.wick,s.lineWidth=1,s.beginPath(),s.moveTo(g,M),s.lineTo(g,L),s.stroke();const k=Math.min(b,y),C=Math.max(1,Math.abs(y-b));s.fillStyle=p,s.fillRect(g-l/2,k,l,C),x&&s.restore()}}function Dh(i,t,e){const s=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),a=i.timeToX(s),o=i.timeToX(n),l=Math.min(a,o),h=Math.max(a,o);return{left:l,right:h,width:Math.max(1,h-l)}}var ee,U,ln,at,ie,_e,Ie,We,ve,ye,di,$i,Ve,tn,en,ei,pe,Re,gs,re,ps,Is,bs,je,vs,ys,xs,ws,Ms,ii,ks,Y,Xn,Pt,Ha,Nn,xe,_i,Ln,In,Os,Or,$a,Oa,Xa,Xr,Nr,bi,Ur;class Na{constructor(t){v(this,Y),v(this,ee),v(this,U),v(this,ln),v(this,at),v(this,ie),v(this,_e),v(this,Ie),v(this,We),v(this,ve),v(this,ye),v(this,di),v(this,$i),v(this,Ve,new ga),v(this,tn,new va),v(this,en,0),v(this,ei,0),v(this,pe,1),v(this,Re,null),v(this,gs,!0),v(this,re,null),v(this,ps,null),v(this,Is,-1),v(this,bs),v(this,je,null),v(this,vs),v(this,ys),v(this,xs),v(this,ws),v(this,Ms),v(this,ii),v(this,ks),c(this,ee,t.container),c(this,at,t.chart),c(this,di,t.data),c(this,$i,t.options??{}),window.getComputedStyle(r(this,ee)).position==="static"&&(r(this,ee).style.position="relative"),c(this,U,document.createElement("canvas")),r(this,U).style.position="absolute",r(this,U).style.left="0",r(this,U).style.top="0",r(this,U).style.height="100%",r(this,U).style.touchAction="none",r(this,ee).appendChild(r(this,U));const e=r(this,U).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");c(this,ln,e),c(this,ie,document.createElement("div")),r(this,ie).dataset.chartNavigatorOverlay="",r(this,ie).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",c(this,_e,document.createElement("div")),r(this,_e).style.cssText="position:absolute;left:0;top:0;bottom:0;",c(this,Ie,document.createElement("div")),r(this,Ie).style.cssText="position:absolute;top:0;bottom:0;",c(this,We,document.createElement("div")),r(this,We).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",c(this,ve,Gr()),c(this,ye,Gr()),r(this,ie).append(r(this,_e),r(this,Ie),r(this,We),r(this,ve),r(this,ye)),r(this,ee).appendChild(r(this,ie)),c(this,vs,()=>S(this,Y,xe).call(this)),c(this,ys,()=>S(this,Y,xe).call(this)),c(this,xs,()=>S(this,Y,xe).call(this)),r(this,at).on("viewportChange",r(this,vs)),r(this,at).on("overlayChange",r(this,ys)),r(this,at).on("tickFrame",r(this,xs)),c(this,ws,n=>S(this,Y,$a).call(this,n)),c(this,Ms,n=>S(this,Y,Oa).call(this,n)),c(this,ii,n=>S(this,Y,Xa).call(this,n)),c(this,ks,()=>{r(this,je)===null&&(r(this,U).style.cursor="default")}),r(this,U).addEventListener("pointerdown",r(this,ws)),r(this,U).addEventListener("pointermove",r(this,Ms)),r(this,U).addEventListener("pointerup",r(this,ii)),r(this,U).addEventListener("pointercancel",r(this,ii)),r(this,U).addEventListener("pointerleave",r(this,ks)),c(this,bs,new ResizeObserver(n=>S(this,Y,Ha).call(this,n[0]))),r(this,bs).observe(r(this,ee)),S(this,Y,Xn).call(this);const s=r(this,ee).getBoundingClientRect();s.width>0&&s.height>0&&S(this,Y,Nn).call(this,s.width,s.height),S(this,Y,xe).call(this)}setData(t){var e;const s=zh(t),n=(s==null?void 0:s.time)??null;if(n!==null&&r(this,ps)!==null&&n!==r(this,ps)){const a=((e=r(this,re))==null?void 0:e.current)??0;c(this,re,new dn({initial:a,duration:cn,easing:hi,lerp:(o,l,h)=>o+(l-o)*h})),r(this,re).setTarget(1)}c(this,ps,n),c(this,Is,(s==null?void 0:s.seriesIndex)??-1),c(this,di,t),S(this,Y,xe).call(this)}setOptions(t){c(this,$i,t),S(this,Y,Xn).call(this),S(this,Y,xe).call(this)}destroy(){r(this,at).off("viewportChange",r(this,vs)),r(this,at).off("overlayChange",r(this,ys)),r(this,at).off("tickFrame",r(this,xs)),r(this,U).removeEventListener("pointerdown",r(this,ws)),r(this,U).removeEventListener("pointermove",r(this,Ms)),r(this,U).removeEventListener("pointerup",r(this,ii)),r(this,U).removeEventListener("pointercancel",r(this,ii)),r(this,U).removeEventListener("pointerleave",r(this,ks)),r(this,bs).disconnect(),r(this,Re)!==null&&(cancelAnimationFrame(r(this,Re)),c(this,Re,null)),r(this,U).remove(),r(this,ie).remove()}get height(){return r(this,$i).height??r(this,at).getTheme().navigator.height}}ee=new WeakMap,U=new WeakMap,ln=new WeakMap,at=new WeakMap,ie=new WeakMap,_e=new WeakMap,Ie=new WeakMap,We=new WeakMap,ve=new WeakMap,ye=new WeakMap,di=new WeakMap,$i=new WeakMap,Ve=new WeakMap,tn=new WeakMap,en=new WeakMap,ei=new WeakMap,pe=new WeakMap,Re=new WeakMap,gs=new WeakMap,re=new WeakMap,ps=new WeakMap,Is=new WeakMap,bs=new WeakMap,je=new WeakMap,vs=new WeakMap,ys=new WeakMap,xs=new WeakMap,ws=new WeakMap,Ms=new WeakMap,ii=new WeakMap,ks=new WeakMap,Y=new WeakSet,Xn=function(){const i=r(this,$i).height;i!==void 0&&(r(this,ee).style.height=`${i}px`)},Pt=function(){return Math.max(0,r(this,en)-r(this,at).yAxisWidth)},Ha=function(i){var t;if(!i)return;const e=(t=i.contentBoxSize)==null?void 0:t[0],s=(e==null?void 0:e.inlineSize)??i.contentRect.width,n=(e==null?void 0:e.blockSize)??i.contentRect.height;s<=0||n<=0||(S(this,Y,Nn).call(this,s,n),S(this,Y,xe).call(this))},Nn=function(i,t){const e=window.devicePixelRatio||1;c(this,en,i),c(this,ei,t),c(this,pe,e);const s=r(this,Y,Pt);r(this,U).width=Math.round(s*e),r(this,U).height=Math.round(t*e),r(this,U).style.width=`${s}px`,r(this,ie).style.width=`${s}px`},xe=function(){r(this,gs)&&r(this,Re)!==null||(c(this,gs,!0),r(this,Re)===null&&c(this,Re,requestAnimationFrame(()=>{c(this,Re,null),c(this,gs,!1),S(this,Y,Xr).call(this)})))},_i=function(i){const t=r(this,U).getBoundingClientRect();return i.clientX-t.left},Ln=function(){const i=S(this,Y,bi).call(this),t=S(this,Y,Ur).call(this);return r(this,Ve).update(i,r(this,Y,Pt),r(this,pe)),r(this,tn).update(t,r(this,ei),r(this,pe)),{xRange:i,yRange:t}},In=function(){return r(this,je)!==null?r(this,at).getVisibleRange():r(this,at).getAnimationState().xRange},Os=function(){return S(this,Y,Ln).call(this),Dh(r(this,Ve),S(this,Y,In).call(this),S(this,Y,bi).call(this))},Or=function(){const i=S(this,Y,bi).call(this),t=i.to-i.from;return t<=0||r(this,Y,Pt)<=0?0:r(this,Y,Pt)/t},$a=function(i){if(i.button!==void 0&&i.button!==0)return;const t=S(this,Y,_i).call(this,i),e=S(this,Y,bi).call(this);if(e.to<=e.from)return;const s=S(this,Y,Os).call(this),n=ja(t,s),a=S(this,Y,Or).call(this);if(a===0)return;let o=r(this,at).getVisibleRange();if(n.snapToCenter){const l=r(this,Ve).xToTime(t),h=Rh({time:l,startVisible:o,xRange:e});r(this,at).setVisibleRange(h),o=h}c(this,je,{pointerId:i.pointerId,gesture:n.gesture,startX:t,startVisible:o,pixelsPerTime:a}),r(this,U).setPointerCapture(i.pointerId),r(this,U).style.cursor=Ua(n.gesture,!0),i.preventDefault()},Oa=function(i){const t=r(this,je);if(t===null){r(this,U).style.cursor=_r(S(this,Y,_i).call(this,i),S(this,Y,Os).call(this));return}if(i.pointerId!==t.pointerId)return;const e=S(this,Y,_i).call(this,i)-t.startX,s=S(this,Y,bi).call(this);let n;if(t.gesture==="pan")n=Ih({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s});else{const a=t.gesture==="resize-left"?"left":"right";n=Wh({edge:a,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s,minSpan:2*r(this,at).getDataInterval()})}r(this,at).setVisibleRange(n)},Xa=function(i){const t=r(this,je);t===null||i.pointerId!==t.pointerId||(c(this,je,null),r(this,U).hasPointerCapture(i.pointerId)&&r(this,U).releasePointerCapture(i.pointerId),r(this,U).style.cursor=_r(S(this,Y,_i).call(this,i),S(this,Y,Os).call(this)))},Xr=function(){if(r(this,Y,Pt)<=0||r(this,ei)<=0)return;const i=r(this,at).getTheme().navigator,{xRange:t}=S(this,Y,Ln).call(this);r(this,U).width=Math.round(r(this,Y,Pt)*r(this,pe)),r(this,U).height=Math.round(r(this,ei)*r(this,pe)),r(this,U).style.width=`${r(this,Y,Pt)}px`,r(this,ie).style.width=`${r(this,Y,Pt)}px`;const e=r(this,ln),s=r(this,U).width,n=r(this,U).height;e.save(),e.clearRect(0,0,s,n),e.scale(r(this,pe),r(this,pe));const a={ctx:e,timeScale:r(this,Ve),yScale:r(this,tn),mediaWidth:r(this,Y,Pt),mediaHeight:r(this,ei),theme:i};r(this,U).style.boxShadow=`inset 0 1px 0 ${i.borderColor}, inset 0 -1px 0 ${i.borderColor}`,Ah(a);let o=1;r(this,re)!==null&&(r(this,re).tick(performance.now()),o=r(this,re).current,r(this,re).animating?S(this,Y,xe).call(this):c(this,re,null));const l=Math.max(1,Math.round(r(this,Y,Pt))),h=r(this,di);if(h.type==="candlestick")Bh(a,Lh(h.points,l),o);else{const u=Wn(h),d=u.length===1,f=r(this,Is)>=0?r(this,Is):u.length-1;for(let m=0;m<u.length;m++){const p=Th(u[m],l),g=m===f?o:1;h.type==="bar"?Fh(a,p,g):Ph(a,p,d,g)}}e.restore(),S(this,Y,Nr).call(this,i,t)},Nr=function(i,t){if(t.to<=t.from)return;const e=S(this,Y,In).call(this),s=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),a=r(this,Ve).timeToX(s),o=r(this,Ve).timeToX(n),l=Math.min(a,o),h=Math.max(a,o),u=Math.max(1,h-l);r(this,_e).style.width=`${l}px`,r(this,_e).style.background=i.mask.fill,r(this,_e).style.display=l>0?"block":"none";const d=Math.max(0,r(this,Y,Pt)-(l+u));r(this,Ie).style.left=`${l+u}px`,r(this,Ie).style.width=`${d}px`,r(this,Ie).style.background=i.mask.fill,r(this,Ie).style.display=d>0?"block":"none",r(this,We).style.left=`${l}px`,r(this,We).style.width=`${u}px`,r(this,We).style.background=i.window.fill,r(this,We).style.border=i.window.borderWidth>0?`${i.window.borderWidth}px solid ${i.window.border}`:"none";const f=i.handle.width,m=Math.max(1,f/2),p=r(this,at).getTheme().background;r(this,ve).style.left=`${l-f/2}px`,r(this,ve).style.width=`${f}px`,r(this,ve).style.background=i.handle.color,r(this,ve).style.borderRadius=`${m}px`,r(this,ye).style.left=`${l+u-f/2}px`,r(this,ye).style.width=`${f}px`,r(this,ye).style.background=i.handle.color,r(this,ye).style.borderRadius=`${m}px`;for(const g of r(this,ve).children)g.style.background=p;for(const g of r(this,ye).children)g.style.background=p},bi=function(){const i=r(this,di);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,s=0;if(i.type==="candlestick")s=i.points.length,s>0&&(t=i.points[0].time,e=i.points[s-1].time);else for(const a of Wn(i))a.length!==0&&(s+=a.length,a[0].time<t&&(t=a[0].time),a[a.length-1].time>e&&(e=a[a.length-1].time));if(s>=2&&e>t)return{from:t,to:e};if(s===1)return{...r(this,at).getVisibleRange()};const n=r(this,at).getDataRange();return n&&n.to>n.from?n:{...r(this,at).getVisibleRange()}},Ur=function(){const i=r(this,di);let t=1/0,e=-1/0;if(i.type==="candlestick")for(const n of i.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of Wn(i))for(const a of n)a.value<t&&(t=a.value),a.value>e&&(e=a.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const s=(e-t)*.2;return{min:t-s,max:e+s}};function Wn(i){return"series"in i?i.series:[i.points]}function zh(i){if(i.type==="candlestick"){const n=i.points.length;return n===0?null:{time:i.points[n-1].time,seriesIndex:-1}}const t="series"in i?i.series:[i.points];let e=null,s=-1;for(let n=0;n<t.length;n++){const a=t[n];if(a.length===0)continue;const o=a[a.length-1].time;(e===null||o>e)&&(e=o,s=n)}return e===null?null:{time:e,seriesIndex:s}}function Ua(i,t){return i==="resize-left"||i==="resize-right"?"ew-resize":t?"grabbing":"grab"}function _r(i,t){return Ua(Eh(i,t),!1)}function Eh(i,t){return ja(i,t).gesture}function Gr(){const i=document.createElement("div");i.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",i.appendChild(e)}return i}const Un=new WeakMap;function _a(i,t){var e;return(e=Un.get(i))==null?void 0:e.get(t)}function Ga(i,t,e){let s=Un.get(i);s||(s=new Map,Un.set(i,s)),s.set(t,e)}function Kr(i){return"close"in i?i.close:i.value}function Ka(i,t){if(t==="none"||i.length<=1)return i;const e=[...i];return e.sort((s,n)=>{const a=Kr(s.data),o=Kr(n.data);return t==="asc"?a-o:o-a}),e}function hn(i){const t=Object.freeze({...i.data}),e={id:i.id,seriesId:i.seriesId,layerIndex:i.layerIndex,label:i.label,data:t,color:i.color};return Object.freeze(e)}function ur(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=_a(i,t.cacheKey);if(n&&n.version===s&&n.time===t.time&&n.sort===e)return n.data;const a=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l);if(i.getSeriesLayers(l)!==null){const d=i.getLayerSnapshots(l,t.time);if(!d)continue;for(const f of d)a.push(hn({id:`${l}_layer${f.layerIndex}`,seriesId:l,layerIndex:f.layerIndex,label:h,data:{time:f.time,value:f.value},color:f.color}));continue}const u=i.getDataAtTime(l,t.time);u&&a.push(hn({id:l,seriesId:l,label:h,data:u,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Ka(a,e));return Ga(i,t.cacheKey,{version:s,time:t.time,sort:e,data:o}),o}function qa(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=_a(i,t.cacheKey);if(n&&n.version===s&&n.time===null&&n.sort===e)return n.data;const a=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l),u=i.getLayerLastSnapshots(l);if(u){for(const f of u)a.push(hn({id:`${l}_layer${f.layerIndex}`,seriesId:l,layerIndex:f.layerIndex,label:h,data:{time:f.time,value:f.value},color:f.color}));continue}const d=i.getLastData(l);d&&a.push(hn({id:l,seriesId:l,label:h,data:d,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Ka(a,e));return Ga(i,t.cacheKey,{version:s,time:null,sort:e,data:o}),o}const Vh=ot({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(90,88,100,0.2)"},candlestick:{up:{body:H("#96e072"),wick:"#96e072"},down:{body:H("#ee5d43"),wick:"#ee5d43"}},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.7)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:Ia},fontUrl:Wa}),Yh=ot({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(82,90,108,0.2)"},candlestick:{up:{body:H("#bae67e"),wick:"#bae67e"},down:{body:H("#f27983"),wick:"#f27983"}},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.7)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:gn},fontUrl:rr}),jh=ot({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(108,113,140,0.2)"},candlestick:{up:{body:H("#50fa7b"),wick:"#50fa7b"},down:{body:H("#ff5555"),wick:"#ff5555"}},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.7)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:ar},fontUrl:or}),Hh=ot({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{up:{body:H("#2da44e"),wick:"#2da44e"},down:{body:H("#cf222e"),wick:"#cf222e"}},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(80,90,100,0.5)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:lr},fontUrl:hr}),$h=ot({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(100,94,90,0.2)"},candlestick:{up:{body:H("#b8bb26"),wick:"#b8bb26"},down:{body:H("#fb4934"),wick:"#fb4934"}},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.7)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:fn},fontUrl:mn}),Oh={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:kh,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:Mh,fontSize:15},grid:{color:"rgba(180,170,150,0.2)",style:"solid"},candlestick:{up:{body:H("#7a9a5e"),wick:"#7a9a5e"},down:{body:H("#b07060"),wick:"#b07060"}},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{fontSize:13,textColor:"#a09880"},yLabel:{fontSize:15,upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{fontSize:14,background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.3)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:H("#7a9a5e"),wick:"#7a9a5e"},down:{body:H("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},Xh="'Silkscreen', cursive",Nh="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Uh=ot({name:"Matrix",background:"#000000",candlestick:{up:{body:H("#00ff41"),wick:"#00ff41"},down:{body:H("#00802a"),wick:"#00802a"}},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.08)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Xh},fontUrl:Nh,chartGradient:["#010a01","#000000"]}),_h=ot({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:H("#6b8e5e"),wick:"#6b8e5e"},down:{body:H("#b85468"),wick:"#b85468"}},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.3)",style:"dashed"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(80,60,90,0.45)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:lr},fontUrl:hr,chartGradient:["#f8f4f7","#f5f0f4"]}),Gh=ot({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)",style:"dotted"},candlestick:{up:{body:H("#6a9a6e"),wick:"#6a9a6e"},down:{body:H("#c45070"),wick:"#c45070"}},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(120,70,90,0.5)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.25)"},typography:{fontFamily:gn},fontUrl:rr}),Kh=ot({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(95,99,120,0.2)"},candlestick:{up:{body:H("#c3e88d"),wick:"#c3e88d"},down:{body:H("#f07178"),wick:"#f07178"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.7)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:Ia},fontUrl:Wa}),qh="'Silkscreen', cursive",Zh="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Jh=ot({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.04)",style:"solid"},candlestick:{up:{body:H("#111111"),wick:"#111111"},down:{body:H("#bbbbbb"),wick:"#bbbbbb"}},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.35)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{fontSize:9,background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.04)"},typography:{fontFamily:qh},fontUrl:Zh}),Qh=ot({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:H("#2e9070"),wick:"#2e9070"},down:{body:H("#d04848"),wick:"#d04848"}},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(55,80,70,0.45)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:xh},fontUrl:wh,chartGradient:["#f8f7f0","#f6f5ee"]}),tc=ot({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(104,100,102,0.2)"},candlestick:{up:{body:H("#8ab862"),wick:"#8ab862"},down:{body:H("#d05470"),wick:"#d05470"}},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.7)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:ar},fontUrl:or}),ec=ot({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(71,92,118,0.2)"},candlestick:{up:{body:H("#7ec699"),wick:"#7ec699"},down:{body:H("#e06c75"),wick:"#e06c75"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.7)",labelBackground:"#1d3b53"},axis:{textColor:"#4d5a6c"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:fn},fontUrl:mn}),ic=ot({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(99,104,116,0.2)"},candlestick:{up:{body:H("#98c379"),wick:"#98c379"},down:{body:H("#e06c75"),wick:"#e06c75"}},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.7)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:fn},fontUrl:mn}),sc=ot({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(98,98,100,0.2)"},candlestick:{up:{body:H("#19f9d8"),wick:"#19f9d8"},down:{body:H("#ff75b5"),wick:"#ff75b5"}},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.7)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:ar},fontUrl:or}),nc=ot({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:H("#5a9a68"),wick:"#5a9a68"},down:{body:H("#d06848"),wick:"#d06848"}},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(100,70,55,0.45)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:lr},fontUrl:hr,chartGradient:["#fff8f2","#fef6f0"]}),rc=ot({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",chartGradient:["#fdfdfd","#f5f5f5"],grid:{color:"rgba(200,200,200,0.4)"},candlestick:{up:{body:H("#448c27"),wick:"#448c27"},down:{body:H("#aa3731"),wick:"#aa3731"}},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(80,80,80,0.5)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:vh},fontUrl:yh}),ac=ot({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:H("#56949f"),wick:"#56949f"},down:{body:H("#b4637a"),wick:"#b4637a"}},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(80,72,98,0.5)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.2)"},typography:{fontFamily:Ra},fontUrl:Aa}),oc=ot({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:H("#5a8a50"),wick:"#5a8a50"},down:{body:H("#b85040"),wick:"#b85040"}},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(85,65,45,0.45)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:Ra},fontUrl:Aa,chartGradient:["#f8f4ec","#f4f0e8"]}),lc=ot({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(200,193,170,0.4)"},candlestick:{up:{body:H("#859900"),wick:"#859900"},down:{body:H("#dc322f"),wick:"#dc322f"}},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(80,100,100,0.55)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:fn},fontUrl:mn});function Ps(i){const{x:t,y:e,chartWidth:s,chartHeight:n,tooltipWidth:a,tooltipHeight:o,offsetX:l=16,offsetY:h=16}=i,u=t+l+a>s?t-l-a:t+l,d=e+h+o>n?e-h-o:e+h,f=Math.max(0,s-a),m=Math.max(0,n-o);return{left:Math.max(0,Math.min(f,u)),top:Math.max(0,Math.min(m,d))}}const zi=R.createContext(null);function wt(){const i=R.useContext(zi);if(!i)throw new Error("useChartInstance must be used within <ChartContainer>");return i}function Za({data:i,options:t,id:e}){var o;const s=wt(),n=R.useRef(null),a=R.useRef([]);return R.useLayoutEffect(()=>{const l=s.addSeries("bar",{...t,layers:i.length,id:e});return n.current=l,a.current=new Array(i.length).fill(Ni),()=>{s.removeSeries(l),n.current=null,a.current=[]}},[s,i.length,e]),R.useLayoutEffect(()=>{const l=n.current;l&&s.batch(()=>{for(let h=0;h<i.length;h++)a.current[h]=cr({chart:s,id:l,data:i[h],prev:a.current[h]??Ni,layerIndex:h})})},[s,i]),R.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(o=t==null?void 0:t.colors)==null?void 0:o.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}function hc({data:i,options:t,id:e}){var o,l,h,u,d,f;const s=wt(),n=R.useRef(null),a=R.useRef(Ni);return R.useLayoutEffect(()=>{const m=s.addSeries("candlestick",{...t,id:e});return n.current=m,()=>{s.removeSeries(m),n.current=null,a.current=Ni}},[s,e]),R.useLayoutEffect(()=>{const m=n.current;m&&(a.current=cr({chart:s,id:m,data:i,prev:a.current}))},[s,i]),R.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,Array.isArray((o=t==null?void 0:t.up)==null?void 0:o.body)?t.up.body.join(","):(l=t==null?void 0:t.up)==null?void 0:l.body,Array.isArray((h=t==null?void 0:t.down)==null?void 0:h.body)?t.down.body.join(","):(u=t==null?void 0:t.down)==null?void 0:u.body,(d=t==null?void 0:t.up)==null?void 0:d.wick,(f=t==null?void 0:t.down)==null?void 0:f.wick,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}const dr=R.createContext(null),Ei=dr.Provider;function Fs(){const i=R.useContext(dr);if(!i)throw new Error("useTheme must be used within <ThemeProvider>");return i}function cc(){return R.useContext(dr)}function pn(i,t,e){const s=Array.isArray(t)?t:[t];return{subscribe:n=>{const a=n;for(const o of s)i.on(o,a);return()=>{for(const o of s)i.off(o,a)}},getSnapshot:e}}function Ja(i){const t=R.useMemo(()=>pn(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getVisibleRange()),[i]);return R.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Qa(i){const t=R.useMemo(()=>pn(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getYRange()),[i]);return R.useSyncExternalStore(t.subscribe,t.getSnapshot)}function uc(i,t){const e=R.useMemo(()=>{let s=i.getLastValue(t),n=s?i.yScale.valueToY(s.value):null;const a=()=>s,o=()=>{const l=i.getLastValue(t),h=l?i.yScale.valueToY(l.value):null;return(s==null?void 0:s.value)===(l==null?void 0:l.value)&&(s==null?void 0:s.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(s=l,n=h,!0)};return{subscribe:l=>{o();const h=()=>{o()&&l()};return i.on("dataUpdate",h),i.on("viewportChange",h),()=>{i.off("dataUpdate",h),i.off("viewportChange",h)}},getSnapshot:a}},[i,t]);return R.useSyncExternalStore(e.subscribe,e.getSnapshot)}function dc(i,t){const e=R.useMemo(()=>pn(i,"dataUpdate",()=>i.getPreviousClose(t)),[i,t]);return R.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Bs(i){const t=R.useMemo(()=>pn(i,"crosshairMove",()=>i.getCrosshairPosition()),[i]);return R.useSyncExternalStore(t.subscribe,t.getSnapshot)}const fc=(i,t)=>t==="volume"?Ke(i):nr(i);function to({sort:i="none",format:t=fc,children:e}){const s=wt(),n=Fs(),a=Bs(s),[,o]=R.useState(0);R.useLayoutEffect(()=>{const m=()=>o(p=>p+1);return s.on("overlayChange",m),s.getSeriesIds().length>0&&o(p=>p+1),()=>{s.off("overlayChange",m)}},[s]);const l=qa(s,{sort:i,cacheKey:"infobar-last"});let h=l,u=l.length===0?0:Math.max(...l.map(m=>m.data.time)),d=!1;if(a!==null){const m=ur(s,{time:a.time,sort:i,cacheKey:"infobar-hover"});m.length>0&&(h=m,u=a.time,d=!0)}if(h.length===0)return e?null:I.jsx("div",{"data-tooltip-legend":"","aria-hidden":"true",style:{display:"flex",alignItems:"center",gap:4,padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",visibility:"hidden",pointerEvents:"none"},children:I.jsx("span",{children:" "})});if(e)return I.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:d?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:h,time:u,isHover:d})});const f=s.getDataInterval();return I.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:d?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[I.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:Rs(u,f)}),h.map(m=>{if("open"in m.data){const b=m.data,y=b.close>=b.open,M=zt(y?n.candlestick.up.body:n.candlestick.down.body);return I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[I.jsx(Gi,{label:"O",display:t(b.open,"open"),color:M,dim:n.axis.textColor}),I.jsx(Gi,{label:"H",display:t(b.high,"high"),color:M,dim:n.axis.textColor}),I.jsx(Gi,{label:"L",display:t(b.low,"low"),color:M,dim:n.axis.textColor}),I.jsx(Gi,{label:"C",display:t(b.close,"close"),color:M,dim:n.axis.textColor}),b.volume!=null&&I.jsx(Gi,{label:"V",display:t(b.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},m.id)}const g=m.data;return I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[I.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.color,flexShrink:0}}),I.jsx("span",{style:{color:m.color,fontWeight:500},children:t(g.value,"value")})]},m.id)})]})}function Gi({label:i,display:t,color:e,dim:s}){return I.jsxs(I.Fragment,{children:[I.jsx("span",{style:{color:s,opacity:.5,marginLeft:5},children:i}),I.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function mc({chart:i,isolatedIdRef:t,setIsolatedId:e}){const s=[],n=i.getSeriesIds();for(const a of n){const o=i.getSeriesLayers(a);if(o){const l=i.getSeriesLabel(a);for(let h=0;h<o.length;h++){const u=`${a}_layer${h}`,d=i.isSeriesVisible(a)&&i.isLayerVisible(a,h);s.push(qr({id:u,seriesId:a,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:o[h].color,isDisabled:!d,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=i.getSeriesColor(a);if(!l)continue;const h=i.getSeriesLabel(a),u=i.isSeriesVisible(a);s.push(qr({id:a,seriesId:a,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!u,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}return s}function qr(i){const{id:t,seriesId:e,layerIndex:s,label:n,color:a,isDisabled:o,chart:l,isolatedIdRef:h,setIsolatedId:u}=i;return{id:t,seriesId:e,layerIndex:s,label:n,color:a,isDisabled:o,toggle:()=>{s!==void 0?l.setLayerVisible(e,s,!l.isLayerVisible(e,s)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const m of l.getSeriesIds()){l.setSeriesVisible(m,!0);const p=l.getSeriesLayers(m);if(p)for(let g=0;g<p.length;g++)l.setLayerVisible(m,g,!0)}}),h.current=null,u(null);return}l.batch(()=>{for(const m of l.getSeriesIds()){const p=l.getSeriesLayers(m);if(p){l.setSeriesVisible(m,m===e);for(let g=0;g<p.length;g++)l.setLayerVisible(m,g,m===e&&g===s)}else l.setSeriesVisible(m,m===t)}}),h.current=t,u(t)}}}function eo({items:i,position:t="bottom",mode:e="toggle",children:s}){const n=wt(),a=Fs(),[o,l]=R.useState(null),[h,u]=R.useState(0),d=R.useRef(o);d.current=o,R.useLayoutEffect(()=>{const b=()=>u(M=>M+1),y=()=>l(null);return n.on("overlayChange",b),n.on("seriesChange",y),n.getSeriesIds().length>0&&u(M=>M+1),()=>{n.off("overlayChange",b),n.off("seriesChange",y)}},[n]);const f=R.useMemo(()=>mc({chart:n,isolatedIdRef:d,setIsolatedId:l}),[n,o,h]),m=t==="right",p={display:"flex",flexDirection:m?"column":"row",flexWrap:"wrap",gap:m?6:14,padding:m?"8px 6px":"6px 8px",alignItems:m?"flex-start":"center",justifyContent:m?"flex-start":"center",fontFamily:a.typography.fontFamily,fontSize:a.axis.fontSize,color:a.axis.textColor,pointerEvents:"auto",flexShrink:0};if(s)return f.length===0?null:I.jsx("div",{"data-legend":t,style:p,children:s({items:f})});if(i)return i.length===0?null:I.jsx("div",{"data-legend":t,style:p,children:i.map((b,y)=>I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:2,background:b.color,flexShrink:0}}),I.jsx("span",{style:{whiteSpace:"nowrap"},children:b.label})]},y))});if(f.length===0)return null;const g=b=>{e==="isolate"||e==="solo"?b.isolate():b.toggle()};return I.jsx("div",{"data-legend":t,style:p,children:f.map(b=>I.jsxs("div",{onClick:()=>g(b),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:b.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:2,background:b.color,flexShrink:0}}),I.jsx("span",{style:{whiteSpace:"nowrap"},children:b.label})]},b.id))})}function io({data:i,height:t,style:e,className:s}){const n=wt(),a=Fs(),o=R.useRef(null),l=R.useRef(null);R.useLayoutEffect(()=>{if(!o.current)return;const u=new Na({container:o.current,chart:n,data:i,options:t!==void 0?{height:t}:void 0});return l.current=u,()=>{u.destroy(),l.current=null}},[n]),R.useEffect(()=>{var u;(u=l.current)==null||u.setData(i)},[i]),R.useEffect(()=>{var u;(u=l.current)==null||u.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??a.navigator.height;return I.jsx("div",{ref:o,className:s,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function gc(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function so({seriesId:i,mode:t,format:e,position:s,children:n}){const a=t??"both",o=s??"bottom",l=e??Ke,h=wt(),u=h.getTheme(),[,d]=R.useState(0);R.useLayoutEffect(()=>{const g=()=>d(b=>b+1);return h.on("overlayChange",g),h.getSeriesIds().length>0&&g(),()=>{h.off("overlayChange",g)}},[h]);const f=gc(h,i),m=f!==null?h.getSliceInfo(f):null;if(!m||m.length===0)return null;if(n)return I.jsx(I.Fragment,{children:n({slices:m,mode:a,format:l})});const p=o==="overlay";return I.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":o,style:{display:"flex",flexDirection:"column",gap:6,padding:p?"8px 12px":"6px 10px",fontFamily:u.typography.fontFamily,fontSize:u.typography.fontSize,color:u.tooltip.textColor,pointerEvents:"auto"},children:m.map((g,b)=>I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[I.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:g.color,flexShrink:0}}),I.jsx("span",{style:{flex:1,opacity:.8},children:g.label}),(a==="value"||a==="both")&&I.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:a==="value"?40:void 0,textAlign:"right"},children:l(g.value)}),(a==="percent"||a==="both")&&I.jsxs("span",{style:{opacity:a==="percent"?1:.5,fontWeight:a==="percent"?600:400,fontSize:a==="percent"?u.typography.fontSize:u.axis.fontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[g.percent.toFixed(1),"%"]})]},b))})}const no=R.memo(function({children:t,sub:e,style:s}){const n=Fs();return I.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 0",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontWeight:600,color:n.tooltip.textColor,pointerEvents:"none",...s},children:[t!=null&&t!==!1&&I.jsx("span",{children:t}),e!=null&&e!==!1&&I.jsx("span",{style:{fontWeight:400,color:n.axis.textColor,fontSize:n.axis.fontSize},children:e})]})},(i,t)=>i.children===t.children&&i.sub===t.sub&&i.style===t.style);function pc(i){let t=null,e=null,s=null,n=null,a=null;const o=[],l=h=>{if(R.isValidElement(h)&&h.type===R.Fragment){R.Children.forEach(h.props.children,l);return}if(R.isValidElement(h)){if(h.type===no){t=h;return}if(h.type===eo){e=h;return}if(h.type===so){const u=h;u.props.position==="overlay"?o.push(h):s=u;return}if(h.type===to){n=h;return}if(h.type===io){a=h;return}}o.push(h)};return R.Children.forEach(i,l),{titleEl:t,legendEl:e,pieLegendEl:s,tooltipLegendEl:n,navigatorEl:a,overlay:o}}function ro({children:i,theme:t,axis:e,padding:s,viewport:n,gradient:a=!0,interactive:o,grid:l,headerLayout:h="overlay",perf:u,animations:d,onEdgeReached:f,style:m,className:p}){var zs,Es,Vs,fi,mi,gi;const g=R.useRef(u),b=R.useRef(f),y=cc(),M=t??y??void 0,L=R.useRef(null),x=R.useRef(null),[k,C]=R.useState(0),A=R.useRef([]);R.useLayoutEffect(()=>{if(!L.current)return;const st={};if(e&&(st.axis=e),M&&(st.theme=M),s&&(st.padding=s),n&&(st.viewport=n),o!==void 0&&(st.interactive=o),l!==void 0&&(st.grid=l),g.current!==void 0&&(st.perf=g.current),d!==void 0&&(st.animations=d),b.current&&(st.onEdgeReached=b.current),x.current=new Ya(L.current,st),process.env.NODE_ENV!=="production"){const yt=performance.now(),It=A.current;for(It.push(yt);It.length>0&&yt-It[0]>1e3;)It.shift();It.length>3&&console.warn("[wick-charts] <ChartContainer> recreated the chart >3 times in the last second. The `animations` prop is init-only — wrap it in useMemo(() => ({...}), [deps]) so a stable reference identity prevents tear-down on every render.")}return C(yt=>yt+1),()=>{var yt;(yt=x.current)==null||yt.destroy(),x.current=null}},[d]),R.useEffect(()=>{x.current&&M&&x.current.setTheme(M)},[M]),R.useEffect(()=>{x.current&&e&&x.current.setAxis(e)},[(zs=e==null?void 0:e.y)==null?void 0:zs.width,(Es=e==null?void 0:e.y)==null?void 0:Es.min,(Vs=e==null?void 0:e.y)==null?void 0:Vs.max,(fi=e==null?void 0:e.y)==null?void 0:fi.visible,(mi=e==null?void 0:e.x)==null?void 0:mi.height,(gi=e==null?void 0:e.x)==null?void 0:gi.visible]);const T=R.useRef(null),[D,B]=R.useState(0),w=h==="overlay"?D:0;R.useLayoutEffect(()=>{const st=x.current;if(!st)return;const It={top:((s==null?void 0:s.top)??20)+w,...(s==null?void 0:s.bottom)!==void 0?{bottom:s.bottom}:{},...(s==null?void 0:s.right)!==void 0?{right:s.right}:{},...(s==null?void 0:s.left)!==void 0?{left:s.left}:{}};st.setPadding(It)},[s==null?void 0:s.top,s==null?void 0:s.bottom,typeof(s==null?void 0:s.right)=="object"?s.right.intervals:s==null?void 0:s.right,typeof(s==null?void 0:s.left)=="object"?s.left.intervals:s==null?void 0:s.left,w]),R.useEffect(()=>{x.current&&l!==void 0&&x.current.setGrid(l)},[l==null?void 0:l.visible]);const W=x.current,{titleEl:P,legendEl:z,pieLegendEl:E,tooltipLegendEl:V,navigatorEl:X,overlay:$}=pc(i),G=(z==null?void 0:z.props.position)??"bottom",xt=(E==null?void 0:E.props.position)??"bottom",Tt=G==="right"||xt==="right",_=M??(W==null?void 0:W.getTheme()),[q,Z]=(_==null?void 0:_.chartGradient)??["transparent","transparent"],K=(_==null?void 0:_.background)??"transparent",Vt=a?`linear-gradient(to bottom, ${q} 0%, ${K} 70%, ${Z} 100%)`:K;R.useLayoutEffect(()=>{if(h!=="overlay"){B(0);return}const st=T.current;if(!st){B(0);return}const yt=()=>B(st.getBoundingClientRect().height);yt();const It=new ResizeObserver(yt);return It.observe(st),()=>It.disconnect()},[P!==null,V!==null,h,W!==null]);const kt=(P||V)&&I.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":h==="overlay"?"":void 0,ref:T,style:h==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[P,V]}),Lt=I.jsx("div",{ref:L,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:W&&I.jsx(zi.Provider,{value:W,children:I.jsxs(Ei,{value:M??W.getTheme(),children:[h==="overlay"&&kt,I.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:$})]})})}),Ae=h==="inline"?I.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[W&&kt&&I.jsx(zi.Provider,{value:W,children:I.jsx(Ei,{value:M??W.getTheme(),children:kt})}),Lt]}):Lt,oe=W&&z&&I.jsx(zi.Provider,{value:W,children:I.jsx(Ei,{value:M??W.getTheme(),children:z})}),qe=W&&E&&I.jsx(zi.Provider,{value:W,children:I.jsx(Ei,{value:M??W.getTheme(),children:E})}),Ds=W&&X&&I.jsx(zi.Provider,{value:W,children:I.jsx(Ei,{value:M??W.getTheme(),children:X})});return I.jsxs("div",{className:p,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:Vt,...m},children:[I.jsxs("div",{style:{display:"flex",flexDirection:Tt?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Ae,oe,qe]}),Ds]})}function bc({side:i,threshold:t=5,onTrigger:e,indicator:s="canvas",children:n}){const a=wt(),[o,l]=R.useState(!1),[h,u]=R.useState(!0),[,d]=R.useState(0),f=R.useRef(e);f.current=e;const m=R.useRef(n!==void 0);m.current=n!==void 0;const p=R.useRef(!1),g=R.useRef(!1);if(R.useEffect(()=>{if(!h)return;const L=()=>{const C=a.getVisibleRange(),A=a.getDataRange();return A?i==="left"?C.from-A.from:A.to-C.to:null},x=()=>{if(p.current||!h)return;p.current=!0,l(!0),s==="canvas"&&a.setEdgeState(i,"loading");let C;try{C=f.current()}catch(T){throw p.current=!1,l(!1),s==="canvas"&&a.setEdgeState(i,"idle"),T}const A=T=>{p.current=!1,l(!1),T===!1?(u(!1),s==="canvas"&&a.setEdgeState(i,"no-data")):s==="canvas"&&a.setEdgeState(i,"idle")};C&&typeof C.then=="function"?C.then(A,()=>A(void 0)):A(void 0)},k=()=>{const C=a.getDataInterval(),A=L();if(A!==null){if(!g.current){A>t*C&&(g.current=!0);return}A<=t*C&&x(),m.current&&d(T=>T+1)}};return a.on("viewportChange",k),a.on("overlayChange",k),k(),()=>{a.off("viewportChange",k),a.off("overlayChange",k)}},[a,i,t,s,h]),R.useEffect(()=>()=>{s==="canvas"&&a.setEdgeState(i,"idle")},[a,i,s]),!n)return null;const b=a.getDataRange();if(!b)return null;const y=i==="left"?b.from:b.to,M=a.timeScale.timeToX(y);return I.jsx(I.Fragment,{children:n({x:M,side:i,isLoading:o,boundaryTime:y,hasMore:h})})}function ao({data:i,options:t,id:e}){var o,l;const s=wt(),n=R.useRef(null),a=R.useRef([]);return R.useLayoutEffect(()=>{const h=s.addSeries("line",{...t,layers:i.length,id:e});return n.current=h,a.current=new Array(i.length).fill(Ni),()=>{s.removeSeries(h),n.current=null,a.current=[]}},[s,i.length,e]),R.useLayoutEffect(()=>{const h=n.current;h&&s.batch(()=>{for(let u=0;u<i.length;u++)a.current[u]=cr({chart:s,id:h,data:i[u],prev:a.current[u]??Ni,layerIndex:u})})},[s,i]),R.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(o=t==null?void 0:t.colors)==null?void 0:o.join(","),t==null?void 0:t.strokeWidth,(l=t==null?void 0:t.area)==null?void 0:l.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.smoothMs]),null}function vc({data:i,options:t,id:e}){var a,o,l,h,u,d,f,m,p;const s=wt(),n=R.useRef(null);return R.useLayoutEffect(()=>{const g=s.addSeries("pie",{...t,id:e});return n.current=g,()=>{s.removeSeries(g),n.current=null}},[s,e]),R.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.mode,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.minSliceAngle,(u=t==null?void 0:t.sliceLabels)==null?void 0:u.elbowLen,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.legPad,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.labelGap,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.distance,(p=t==null?void 0:t.sliceLabels)==null?void 0:p.railWidth]),R.useLayoutEffect(()=>{n.current&&s.setSeriesData(n.current,i)},[s,i]),null}function yc(){const i=wt(),t=Bs(i);if(!t)return null;const e=i.getTheme(),s=i.getDataInterval(),n=i.timeScale.niceTickValues(s).tickInterval||s,a={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.axis.fontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return I.jsxs(I.Fragment,{children:[I.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...a},children:i.yScale.formatY(t.y)}),I.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...a},children:Rs(t.time,n)})]})}const xc=["0","1","2","3","4","5","6","7","8","9"];function wc(i){const t=[];for(const e of i)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function oo({value:i,format:t,locale:e="en-US",spinDuration:s=350,className:n,style:a}){const l=R.useMemo(()=>{if(typeof t=="function")return t;const u=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return d=>u.format(d)},[t,e])(i),h=wc(l);return I.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...a},children:h.map((u,d)=>u.type==="digit"?I.jsx(Mc,{digit:parseInt(u.value,10),duration:s},`d${d}`):I.jsx("span",{style:{display:"inline-block"},children:u.value},`s${d}`))})}function Mc({digit:i,duration:t}){const e=R.useRef(!1);return R.useEffect(()=>{e.current=!0},[]),I.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:I.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-i*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:xc.map(s=>I.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:s},s))})})}function kc(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Sc=160,Cc=70;function Tc({seriesId:i,format:t=Ke,children:e}){const s=wt(),n=Bs(s),[,a]=R.useState(0);R.useLayoutEffect(()=>{const m=()=>a(p=>p+1);return s.on("overlayChange",m),()=>{s.off("overlayChange",m)}},[s]);const o=kc(s,i),l=o!==null?s.getHoverInfo(o):null;if(!l||!n)return null;const h=s.getTheme(),u=s.getMediaSize();if(e)return I.jsx(Lc,{x:n.mediaX,y:n.mediaY,chartWidth:u.width,chartHeight:u.height,children:e({info:l,format:t})});const{left:d,top:f}=Ps({x:n.mediaX,y:n.mediaY,chartWidth:u.width,chartHeight:u.height,tooltipWidth:Sc,tooltipHeight:Cc,offsetX:16,offsetY:16});return I.jsxs("div",{style:{position:"absolute",left:d,top:f,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[I.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:l.color,flexShrink:0}}),I.jsx("span",{style:{fontWeight:600},children:l.label})]}),I.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[I.jsx("span",{style:{opacity:.6},children:t(l.value)}),I.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function Lc({x:i,y:t,chartWidth:e,chartHeight:s,children:n}){const a=R.useRef(null),[o,l]=R.useState(null);R.useEffect(()=>{const u=a.current;if(!u||typeof ResizeObserver>"u")return;const d=new ResizeObserver(f=>{var p;const m=(p=f[0])==null?void 0:p.contentRect;m&&l(g=>g&&g.width===m.width&&g.height===m.height?g:{width:m.width,height:m.height})});return d.observe(u),()=>d.disconnect()},[]);const h=o?Ps({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:o.width,tooltipHeight:o.height,offsetX:16,offsetY:16}):{left:0,top:0};return I.jsx("div",{ref:a,"data-measured":o?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:o?"visible":"hidden"},children:n})}function Ic(i,t){if(i.startsWith("rgba")||!i.startsWith("#"))return i;const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function Wc(i){if(i.length<2)return{value:0,pct:0,positive:!0};const t=i[0].value,s=i[i.length-1].value-t,n=t!==0?s/t*100:0;return{value:s,pct:n,positive:s>=0}}function Rc({data:i,theme:t,variant:e="line",valuePosition:s="right",formatValue:n=Ke,label:a,sublabel:o,color:l,negativeColor:h,area:u,areaFill:d,yRange:f,flow:m,width:p=140,height:g=48,strokeWidth:b=1.5,gradient:y=!0,style:M}){const L=(u==null?void 0:u.visible)??d??!0,x=i.length>0?i[i.length-1].value:0,k=R.useMemo(()=>Wc(i),[i]),C=l??t.seriesColors[0],A=h??zt(t.candlestick.down.body),T=zt(k.positive?t.candlestick.up.body:t.candlestick.down.body),D=R.useMemo(()=>{if(!m||i.length<2)return;const W=i[1].time-i[0].time;if(W<=0)return;const P=m.align??"right";if(P==="left")return{maxVisibleBars:m.capacity,initialRange:{from:i[0].time,bars:m.capacity}};const z=i[i.length-1].time,E=P==="offscreen"?z-W:z,V=E-m.capacity*W;return{maxVisibleBars:m.capacity,initialRange:{from:V,to:E}}},[]),B=s!=="none"&&I.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[a&&I.jsx("div",{style:{fontSize:t.axis.fontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a}),I.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(x)}),o!==void 0?I.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:o}):I.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:T,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[k.positive?"+":"",k.pct.toFixed(1),"%"]})]}),w=I.jsx("div",{style:{width:p,height:g,flexShrink:0,borderRadius:4,overflow:"hidden"},children:I.jsx(ro,{theme:t,axis:{y:{visible:!1,width:0,min:f==null?void 0:f.min,max:f==null?void 0:f.max},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:y,interactive:!1,grid:{visible:!1},viewport:D,children:e==="line"?I.jsx(ao,{data:[i],options:{colors:[C],strokeWidth:b,area:{visible:L},pulse:!1,stacking:"off"}}):I.jsx(Za,{data:[i],options:{colors:[C,A],barWidthRatio:.7,stacking:"off",anchor:"right"}})})});return I.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Ic(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...M},children:[s==="left"&&B,w,s==="right"&&B]})}function lo({labelCount:i,minLabelSpacing:t}={}){const e=wt();Ja(e);const s=R.useRef(null);return R.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:i??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,i,t]),R.useLayoutEffect(()=>{const n=s.current;if(n!==null)return aa({chart:e,container:n,axis:"x"})},[e]),I.jsx("div",{ref:s,style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"}})}const Ac=(i,t)=>t==="volume"?Ke(i):nr(i);function Pc({sort:i="none",format:t=Ac,children:e}){const s=wt(),n=Bs(s),[,a]=R.useState(0);if(R.useLayoutEffect(()=>{const m=()=>a(p=>p+1);return s.on("overlayChange",m),s.getSeriesIds().length>0&&a(p=>p+1),()=>{s.off("overlayChange",m)}},[s]),!n)return null;const o=ur(s,{time:n.time,sort:i,cacheKey:"tooltip"});if(o.length===0)return null;const l=s.getTheme(),h=s.getDataInterval(),u=s.getMediaSize(),d=u.width-s.yAxisWidth,f=u.height-s.xAxisHeight;return e?I.jsx(Fc,{x:n.mediaX,y:n.mediaY,chartWidth:d,chartHeight:f,theme:l,children:e({snapshots:o,time:n.time})}):I.jsx(Bc,{snapshots:o,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:d,chartHeight:f,theme:l,dataInterval:h,format:t})}function Fc({x:i,y:t,chartWidth:e,chartHeight:s,theme:n,children:a}){const o=R.useRef(null),[l,h]=R.useState(null);R.useEffect(()=>{const d=o.current;if(!d||typeof ResizeObserver>"u")return;const f=new ResizeObserver(m=>{var g;const p=(g=m[0])==null?void 0:g.contentRect;p&&h(b=>b&&b.width===p.width&&b.height===p.height?b:{width:p.width,height:p.height})});return f.observe(d),()=>f.disconnect()},[]);const u=l?Ps({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return I.jsx("div",{ref:o,"data-measured":l?"true":"false",style:{position:"absolute",left:u.left,top:u.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.tooltip.fontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:l?"visible":"hidden"},children:a})}function Bc({snapshots:i,displayTime:t,x:e,y:s,chartWidth:n,chartHeight:a,theme:o,dataInterval:l,format:h}){const u=i.some(L=>"open"in L.data),d=i.filter(L=>!("open"in L.data)).length,f=160,m=u?140:40+d*22,{left:p,top:g}=Ps({x:e,y:s,chartWidth:n,chartHeight:a,tooltipWidth:f,tooltipHeight:m}),b=o.tooltip.background,y=o.tooltip.borderColor;return I.jsxs("div",{style:{position:"absolute",left:p,top:g,pointerEvents:"none",background:b,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${y}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:o.tooltip.fontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,width:f,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[I.jsxs("div",{style:{fontSize:o.axis.fontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${y}`,letterSpacing:"0.02em"},children:[ra(t)," ",Rs(t,l)]}),i.map(L=>{if("open"in L.data){const C=L.data,A=C.close>=C.open,T=zt(A?o.candlestick.up.body:o.candlestick.down.body);return I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[I.jsx(Ki,{label:"Open",color:T,display:h(C.open,"open")}),I.jsx(Ki,{label:"High",color:T,display:h(C.high,"high")}),I.jsx(Ki,{label:"Low",color:T,display:h(C.low,"low")}),I.jsx(Ki,{label:"Close",color:T,display:h(C.close,"close")}),C.volume!=null&&I.jsx(Ki,{label:"Volume",color:o.tooltip.textColor,display:h(C.volume,"volume")})]},L.id)}const k=L.data;return I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[I.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:L.color,flexShrink:0}}),I.jsx("span",{style:{opacity:.6,flex:1},children:L.label??"Value"}),I.jsx("span",{style:{fontWeight:600,color:L.color},children:h(k.value,"value")})]},L.id)})]})}function Ki({label:i,color:t,display:e}){return I.jsxs(I.Fragment,{children:[I.jsx("span",{style:{opacity:.5},children:i}),I.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function Dc({format:i,labelCount:t,minLabelSpacing:e}={}){const s=wt();Qa(s);const n=R.useRef(null);return R.useLayoutEffect(()=>(s.yScale.setFormat(i??null),()=>s.yScale.setFormat(null)),[s,i]),R.useLayoutEffect(()=>(s.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{s.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[s,t,e]),R.useLayoutEffect(()=>{const a=n.current;if(a!==null)return aa({chart:s,container:a,axis:"y"})},[s]),I.jsx("div",{ref:n,style:{position:"absolute",right:0,top:0,bottom:s.xAxisHeight,width:s.yAxisWidth,pointerEvents:"none"}})}function zc(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const s=i.getSeriesIdsByType("time",{visibleOnly:!0});return s.length>0?s[0]:null}function Ec({seriesId:i,color:t,format:e,children:s}){const n=wt();R.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,a]=R.useState(0);R.useLayoutEffect(()=>{const x=()=>a(k=>k+1);return n.on("overlayChange",x),n.on("viewportChange",x),n.getSeriesIds().length>0&&a(k=>k+1),()=>{n.off("overlayChange",x),n.off("viewportChange",x)}},[n]);const o=zc(n,i),l=o!==null?n.getStackedLastValue(o):null,h=o!==null?n.getPreviousClose(o):null,u=n.yScale.getRange(),d=u.max-u.min,f=d<.1?6:d<10?4:d<1e3?2:0,m=R.useMemo(()=>{if(e)return e;const x=new Intl.NumberFormat("en-US",{minimumFractionDigits:f,maximumFractionDigits:f,useGrouping:!1});return k=>x.format(k)},[e,f]);if(!l||o===null)return null;const{value:p,isLive:g}=l,b=n.getTheme(),y=n.yScale.valueToY(p),M=h===null?"neutral":p>h?"up":p<h?"down":"neutral";let L;return g?t?L=t:L=M==="up"?b.yLabel.upBackground:M==="down"?b.yLabel.downBackground:b.yLabel.neutralBackground:L=b.axis.textColor,s?I.jsx(I.Fragment,{children:s({value:p,y,bgColor:L,isLive:g,direction:M,format:m})}):I.jsxs(I.Fragment,{children:[I.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:y,height:0,borderTop:`1px dashed ${L}`,opacity:.5,pointerEvents:"none",zIndex:2}}),I.jsx("div",{style:{position:"absolute",right:4,top:y,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:L,color:b.yLabel.textColor,fontSize:b.yLabel.fontSize,fontFamily:b.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:I.jsx(oo,{value:p,format:m,spinDuration:350})})]})}exports.BarSeries=Za;exports.CandlestickSeries=hc;exports.ChartContainer=ro;exports.ChartInstance=Ya;exports.Crosshair=yc;exports.EdgeLoader=bc;exports.InfoBar=to;exports.Legend=eo;exports.LineSeries=ao;exports.Navigator=io;exports.NavigatorController=Na;exports.NumberFlow=oo;exports.PieLegend=so;exports.PieSeries=vc;exports.PieTooltip=Tc;exports.Sparkline=Rc;exports.ThemeProvider=Ei;exports.TimeAxis=lo;exports.Title=no;exports.Tooltip=Pc;exports.XAxis=lo;exports.YAxis=Dc;exports.YLabel=Ec;exports.andromeda=Vh;exports.autoGradient=H;exports.ayuMirage=Yh;exports.buildHoverSnapshots=ur;exports.buildLastSnapshots=qa;exports.catppuccin=Pa;exports.computeTooltipPosition=Ps;exports.createTheme=ot;exports.detectInterval=na;exports.dracula=jh;exports.formatCompact=Ke;exports.formatDate=ra;exports.formatPriceAdaptive=nr;exports.formatTime=Rs;exports.githubLight=Hh;exports.gruvbox=$h;exports.handwritten=Oh;exports.hermite=ea;exports.highContrast=Uh;exports.isDarkBg=La;exports.lavenderMist=_h;exports.lightPink=Gh;exports.materialPalenight=Kh;exports.minimalLight=Jh;exports.mintBreeze=Qh;exports.monokaiPro=tc;exports.nightOwl=ec;exports.normalizeTime=Et;exports.oneDarkPro=ic;exports.panda=sc;exports.parseAnimationTime=Qr;exports.peachCream=nc;exports.quietLight=rc;exports.resolveAxisFontSize=ia;exports.resolveAxisTextColor=sa;exports.resolveCandlestickBodyColor=zt;exports.rosePineDawn=ac;exports.sandDune=oc;exports.snap=Zi;exports.solarizedLight=lc;exports.spring=Jr;exports.useChartInstance=wt;exports.useCrosshairPosition=Bs;exports.useLastYValue=uc;exports.usePreviousClose=dc;exports.useTheme=Fs;exports.useVisibleRange=Ja;exports.useYRange=Qa;