@tony01/astroneum 0.4.1-beta.2 → 0.4.1-beta.25
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.
- package/CHANGELOG.md +281 -237
- package/LICENSE +21 -21
- package/README.md +250 -198
- package/dist/{Indicator-BBI3L_lx.d.ts → Indicator-BQQcVGGT.d.ts} +51 -227
- package/dist/astroneum.css +1 -1
- package/dist/chunk-47YGQEL5.js +399 -0
- package/dist/chunk-67XM5LOK.js +2 -0
- package/dist/{chunk-2YYGUSVX.js → chunk-DFJMDDL5.js} +1 -1
- package/dist/chunk-EFAS6F4C.js +59 -0
- package/dist/chunk-EHZN52CY.js +2 -0
- package/dist/chunk-HKLWNPMP.js +35 -0
- package/dist/chunk-ONPPQW65.js +2 -0
- package/dist/chunk-SCTHEM27.js +3 -0
- package/dist/chunk-UQXYMB6X.js +2 -0
- package/dist/chunk-WSIR5T2M.js +3 -0
- package/dist/entries/alerts.d.ts +36 -10
- package/dist/entries/alerts.js +1 -1
- package/dist/entries/datafeeds/crypto.d.ts +5 -1
- package/dist/entries/datafeeds/crypto.js +1 -1
- package/dist/entries/datafeeds/polygon.d.ts +3 -1
- package/dist/entries/datafeeds/polygon.js +1 -1
- package/dist/entries/headless.d.ts +78 -0
- package/dist/entries/headless.js +2 -0
- package/dist/entries/multichart.d.ts +12 -1
- package/dist/entries/multichart.js +1 -1
- package/dist/entries/replay.d.ts +3 -1
- package/dist/entries/script.d.ts +2 -68
- package/dist/entries/script.js +1 -1
- package/dist/entries/watchlist.d.ts +32 -2
- package/dist/entries/watchlist.js +1 -1
- package/dist/entries/workspace.d.ts +61 -0
- package/dist/entries/workspace.js +2 -0
- package/dist/index-BiXdqLA4.d.ts +45 -0
- package/dist/index-_JgHTy8X.d.ts +19 -0
- package/dist/index.d.ts +188 -27
- package/dist/index.js +1 -1
- package/dist/script-BU9StbN-.d.ts +120 -0
- package/dist/types-W6SIYQ9m.d.ts +232 -0
- package/dist/types-yETgeYsE.d.ts +28 -0
- package/dist/zh-CN-NDTUDZGZ.js +3 -0
- package/package.json +157 -147
- package/dist/chunk-4YOLQ5DC.js +0 -2
- package/dist/chunk-I4YQBP2M.js +0 -3
- package/dist/chunk-OOMZRONH.js +0 -35
- package/dist/chunk-PV2GAINM.js +0 -2
- package/dist/chunk-YW3STIPY.js +0 -653
- package/dist/zh-CN-Y2C6RSOI.js +0 -3
- package/docs/STRUCTURE.md +0 -231
- package/docs/TODO-DESIGN.md +0 -261
- package/docs/TODO.md +0 -222
- package/docs/api.md +0 -528
- package/docs/datafeed-guide.md +0 -311
- package/docs/design-astroneum.md +0 -479
- package/docs/plugin-development.md +0 -565
- package/docs/tv-functions-skill.md +0 -706
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function G(n,e){if(!(!ae(n)&&!ae(e))){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],i=e[t];ae(i)&&ae(r)?G(r,i):n[t]=Te(i);}}}function Te(n){if(!ae(n))return n;let e=null;ne(n)?e=[]:e={};for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){let r=n[t];ae(r)?e[t]=Te(r):e[t]=r;}return e}function ne(n){return Object.prototype.toString.call(n)==="[object Array]"}function q(n){return typeof n=="function"}function ae(n){return typeof n=="object"&&_(n)}function w(n){return typeof n=="number"&&Number.isFinite(n)}function _(n){return n!=null}function Se(n){return typeof n=="boolean"}function L(n){return typeof n=="string"}var ia=/\\(\\)?/g,oa=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g");function Q(n,e,t){if(_(n)){let r=[];e.replace(oa,(s,...l)=>{let c=s;return _(l[1])?c=l[2].replace(ia,"$1"):_(l[0])&&(c=l[0].trim()),r.push(c),""});let i=n,o=0,a=r.length;for(;_(i)&&o<a;)i=i?.[r[o++]];return _(i)?i:t??"--"}return t??"--"}function na(n,e){let t={};return n.formatToParts(new Date(e)).forEach(({type:r,value:i})=>{switch(r){case "year":{t.YYYY=i;break}case "month":{t.MM=i;break}case "day":{t.DD=i;break}case "hour":{t.HH=i==="24"?"00":i;break}case "minute":{t.mm=i;break}case "second":{t.ss=i;break}}}),t}function mr(n,e,t){let r=na(n,e);return t.replace(/YYYY|MM|DD|HH|mm|ss/g,i=>r[i])}function J(n,e){let t=+n;return w(t)?t.toFixed(e??2):`${n}`}function pr(n){let e=+n;if(w(e)){if(e>1e9)return `${+(e/1e9).toFixed(3)}B`;if(e>1e6)return `${+(e/1e6).toFixed(3)}M`;if(e>1e3)return `${+(e/1e3).toFixed(3)}K`}return `${n}`}function gr(n,e){let t=`${n}`;if(e.length===0)return t;if(t.includes(".")){let r=t.split(".");return `${r[0].replace(/(\d)(?=(\d{3})+$)/g,i=>`${i}${e}`)}.${r[1]}`}return t.replace(/(\d)(?=(\d{3})+$)/g,r=>`${r}${e}`)}function fr(n,e){let t=`${n}`;if(new RegExp("\\.0{"+e+",}[1-9][0-9]*$").test(t)){let i=t.split("."),o=i.length-1,a=i[o],s=/0*/.exec(a);if(_(s)){let l=s[0].length;return i[o]=a.replace(/0*/,`0{${l}}`),i.join(".")}}return t}function Nr(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>{let i=e[r];return _(i)?i:`{${r}}`})}function lt(n,e,t,r){let i=n.result,o=n.figures,a=n.styles,s=Q(a,"circles",t.circles),l=s.length,c=Q(a,"bars",t.bars),u=c.length,d=Q(a,"lines",t.lines),h=d.length,m=0,p=0,g=0,f,y=0;o.forEach(v=>{switch(v.type){case "circle":{y=m;let b=s[m%l];f={...b,color:b.noChangeColor},m++;break}case "bar":{y=p;let b=c[p%u];f={...b,color:b.noChangeColor},p++;break}case "line":{y=g,f=d[g%h],g++;break}}if(_(v.type)){let b=v.styles?.({data:{prev:i[e-1],current:i[e],next:i[e+1]},indicator:n,defaultStyles:t});r(v,{...f,...b},y);}});}var st=class n{id;paneId;name;shortName;precision=4;calcParams=[];shouldOhlc=false;shouldFormatBigNumber=false;visible=true;zLevel=0;extendData;series="normal";figures=[];minValue=null;maxValue=null;styles=null;shouldUpdate=(e,t)=>{let r=JSON.stringify(e.calcParams)!==JSON.stringify(t.calcParams)||e.figures!==t.figures||e.calc!==t.calc,i=r||e.shortName!==t.shortName||e.series!==t.series||e.minValue!==t.minValue||e.maxValue!==t.maxValue||e.precision!==t.precision||e.shouldOhlc!==t.shouldOhlc||e.shouldFormatBigNumber!==t.shouldFormatBigNumber||e.visible!==t.visible||e.zLevel!==t.zLevel||e.extendData!==t.extendData||e.regenerateFigures!==t.regenerateFigures||e.createTooltipDataSource!==t.createTooltipDataSource||e.draw!==t.draw;return {calc:r,draw:i}};calc=()=>[];regenerateFigures=null;createTooltipDataSource=null;draw=null;result=[];_prevIndicator;_lockSeriesPrecision=false;constructor(e){this.override(e),this._lockSeriesPrecision=false;}override(e){let{result:t,...r}=this;this._prevIndicator={...Te(r),result:t};let{id:i,name:o,shortName:a,precision:s,styles:l,figures:c,calcParams:u,...d}=e;!L(this.id)&&L(i)&&(this.id=i),L(this.name)||(this.name=o??""),this.shortName=a??this.shortName??this.name,w(s)&&(this.precision=s,this._lockSeriesPrecision=true),_(l)&&(this.styles??={},G(this.styles,l)),G(this,d),_(u)&&(this.calcParams=u,q(this.regenerateFigures)&&(this.figures=this.regenerateFigures(this.calcParams))),this.figures=c??this.figures;}setSeriesPrecision(e){this._lockSeriesPrecision||(this.precision=e);}shouldUpdateImp(){let e=this._prevIndicator.zLevel!==this.zLevel,t=this.shouldUpdate(this._prevIndicator,this);return Se(t)?{calc:t,draw:t,sort:e}:{...t,sort:e}}async calcImp(e,t="full"){try{let r=await this.calc(e,this);return this.result=r,!0}catch{return false}}static extend(e){class t extends n{constructor(){super(e);}}return t}};var aa={name:"A/D",shortName:"A/D",precision:2,shouldFormatBigNumber:true,figures:[{key:"ad",title:"A/D: ",type:"line"}],calc:n=>{let e=0;return n.map(t=>{let r={},i=t.high,o=t.low,a=t.close,s=t.volume??0;if(i!==o){let l=(a-o-(i-a))/(i-o);e+=l*s;}return r.ad=e,r})}},_i=aa;var sa={name:"AMA",shortName:"AMA",series:"price",calcParams:[10],precision:2,shouldOhlc:true,figures:[{key:"ama",title:"AMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=2/3,o=2/31,a=0,s=[];return n.forEach((l,c)=>{let u={};if(c>=r-1){let d=Math.abs(l.close-n[c-(r-1)].close),h=0;for(let g=c-(r-2);g<=c;g++)h+=Math.abs(n[g].close-n[g-1].close);let p=((h!==0?d/h:0)*(i-o)+o)**2;if(c===r-1){let g=0;for(let f=0;f<r;f++)g+=n[f].close;a=g/r;}else a=a+p*(l.close-a);u.ama=a;}s.push(u);}),s}},bi=sa;var la={name:"ADX",shortName:"ADX",calcParams:[14],precision:2,figures:[{key:"adx",title:"ADX: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=0,s=0,l=0,c=0,u=0,d=0;return n.map((h,m)=>{let p={},g=n[m-1]??h,f=h.high,y=h.low,v=f-y,b=Math.abs(f-g.close),S=Math.abs(g.close-y),x=f-g.high,C=g.low-y,T=Math.max(v,b,S),A=x>0&&x>C?x:0,P=C>0&&C>x?C:0;if(i+=T,o+=A,a+=P,m>=r-1){m>r-1?(s=s-s/r+T,l=l-l/r+A,c=c-c/r+P):(s=i,l=o,c=a);let I=0,R=0;s!==0&&(I=l*100/s,R=c*100/s);let D=0;R+I!==0&&(D=Math.abs(R-I)/(R+I)*100),u+=D,m>=r*2-2&&(m>r*2-2?d=(d*(r-1)+D)/r:d=u/r,p.adx=d);}return p})}},xi=la;var ca={name:"AVP",shortName:"AVP",series:"price",precision:2,figures:[{key:"avp",title:"AVP: ",type:"line"}],calc:n=>{let e=0,t=0;return n.map(r=>{let i={},o=r.turnover??0,a=r.volume??0;return e+=o,t+=a,t!==0&&(i.avp=e/t),i})}},Ci=ca;var ua={name:"ATR",shortName:"ATR",calcParams:[14],precision:2,figures:[{key:"atr",title:"ATR: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0;return n.map((o,a)=>{let s={},l=(n[a-1]??o).close,c=o.high,u=o.low,d=c-u,h=Math.abs(c-l),m=Math.abs(l-u),p=Math.max(d,h,m);return r+=p,a>=t[0]-1&&(a>t[0]-1?i=(i*(t[0]-1)+p)/t[0]:i=r/t[0],s.atr=i),s})}},Ti=ua;var da={name:"AO",shortName:"AO",calcParams:[5,34],figures:[{key:"ao",title:"AO: ",type:"bar",baseValue:0,styles:({data:n,indicator:e,defaultStyles:t})=>{let{prev:r,current:i}=n,o=r?.ao??Number.MIN_SAFE_INTEGER,a=i?.ao??Number.MIN_SAFE_INTEGER,s="";a>o?s=Q(e.styles,"bars[0].upColor",t.bars[0].upColor):s=Q(e.styles,"bars[0].downColor",t.bars[0].downColor);let l=a>o?"stroke":"fill";return {color:s,style:l,borderColor:s}}}],calc:(n,e)=>{let t=e.calcParams,r=Math.max(t[0],t[1]),i=0,o=0,a=0,s=0;return n.map((l,c)=>{let u={},d=(l.low+l.high)/2;if(i+=d,o+=d,c>=t[0]-1){a=i/t[0];let h=n[c-(t[0]-1)];i-=(h.low+h.high)/2;}if(c>=t[1]-1){s=o/t[1];let h=n[c-(t[1]-1)];o-=(h.low+h.high)/2;}return c>=r-1&&(u.ao=a-s),u})}},Si=da;var ha={name:"BIAS",shortName:"BIAS",calcParams:[6,12,24],figures:[{key:"bias1",title:"BIAS6: ",type:"line"},{key:"bias2",title:"BIAS12: ",type:"line"},{key:"bias3",title:"BIAS24: ",type:"line"}],regenerateFigures:n=>n.map((e,t)=>({key:`bias${t+1}`,title:`BIAS${e}: `,type:"line"})),calc:(n,e)=>{let{calcParams:t,figures:r}=e,i=[];return n.map((o,a)=>{let s={},l=o.close;return t.forEach((c,u)=>{if(i[u]=(i[u]??0)+l,a>=c-1){let d=i[u]/t[u];s[r[u].key]=(l-d)/d*100,i[u]-=n[a-(c-1)].close;}}),s})}},Ai=ha;function ma(n,e){let t=n.length,r=0;return n.forEach(i=>{let o=i.close-e;r+=o*o;}),r=Math.abs(r),Math.sqrt(r/t)}var pa={name:"BOLL",shortName:"BOLL",series:"price",calcParams:[20,2],precision:2,shouldOhlc:true,figures:[{key:"up",title:"UP: ",type:"line"},{key:"mid",title:"MID: ",type:"line"},{key:"dn",title:"DN: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=t[0]-1,i=0;return n.map((o,a)=>{let s=o.close,l={};if(i+=s,a>=r){l.mid=i/t[0];let c=ma(n.slice(a-r,a+1),l.mid);l.up=l.mid+t[1]*c,l.dn=l.mid-t[1]*c,i-=n[a-r].close;}return l})}},Pi=pa;var ga={name:"BRAR",shortName:"BRAR",calcParams:[26],figures:[{key:"br",title:"BR: ",type:"line"},{key:"ar",title:"AR: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=0,a=0;return n.map((s,l)=>{let c={},u=s.high,d=s.low,h=s.open,m=(n[l-1]??s).close;if(o+=u-h,a+=h-d,r+=u-m,i+=m-d,l>=t[0]-1){a!==0?c.ar=o/a*100:c.ar=0,i!==0?c.br=r/i*100:c.br=0;let p=n[l-(t[0]-1)],g=p.high,f=p.low,y=p.open,v=(n[l-t[0]]??n[l-(t[0]-1)]).close;r-=g-v,i-=v-f,o-=g-y,a-=y-f;}return c})}},wi=ga;var fa={name:"BBI",shortName:"BBI",series:"price",precision:2,calcParams:[3,6,12,24],shouldOhlc:true,figures:[{key:"bbi",title:"BBI: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=Math.max(...t),i=[],o=[];return n.map((a,s)=>{let l={},c=a.close;if(t.forEach((u,d)=>{i[d]=(i[d]??0)+c,s>=u-1&&(o[d]=i[d]/u,i[d]-=n[s-(u-1)].close);}),s>=r-1){let u=0;o.forEach(d=>{u+=d;}),l.bbi=u/4;}return l})}},Ei=fa;var va={name:"CMF",shortName:"CMF",calcParams:[20],precision:4,figures:[{key:"cmf",title:"CMF: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=[];return n.forEach((s,l)=>{let c={},u=s.high,d=s.low,h=s.close,m=s.volume??0,p=0;if(u!==d&&(p=(h-d-(u-h))/(u-d)),i+=p*m,o+=m,l>=r-1){o!==0&&(c.cmf=i/o);let g=n[l-(r-1)],f=g.volume??0,y=0;g.high!==g.low&&(y=(g.close-g.low-(g.high-g.close))/(g.high-g.low)),i-=y*f,o-=f;}a.push(c);}),a}},Ii=va;var ya={name:"CCI",shortName:"CCI",calcParams:[20],figures:[{key:"cci",title:"CCI: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=t[0]-1,i=0,o=[];return n.map((a,s)=>{let l={},c=(a.high+a.low+a.close)/3;if(i+=c,o.push(c),s>=r){let u=i/t[0],d=o.slice(s-r,s+1),h=0;d.forEach(g=>{h+=Math.abs(g-u);});let m=h/t[0];l.cci=m!==0?(c-u)/m/.015:0;let p=(n[s-r].high+n[s-r].low+n[s-r].close)/3;i-=p;}return l})}},Di=ya;var _a={name:"CORR",shortName:"CORR",calcParams:[20],precision:4,figures:[{key:"corr",title:"CORR: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0];return n.map((i,o)=>{let a={};if(o>=r-1){let s=0,l=0,c=0,u=0,d=0;for(let p=0;p<r;p++){let g=p+1,f=n[o-(r-1)+p].close;s+=g,l+=f,c+=g*f,u+=g*g,d+=f*f;}let h=r*c-s*l,m=Math.sqrt((r*u-s*s)*(r*d-l*l));a.corr=m!==0?h/m:0;}return a})}},Ri=_a;var ba={name:"CR",shortName:"CR",calcParams:[26,10,20,40,60],figures:[{key:"cr",title:"CR: ",type:"line"},{key:"ma1",title:"MA1: ",type:"line"},{key:"ma2",title:"MA2: ",type:"line"},{key:"ma3",title:"MA3: ",type:"line"},{key:"ma4",title:"MA4: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=Math.ceil(t[1]/2.5+1),i=Math.ceil(t[2]/2.5+1),o=Math.ceil(t[3]/2.5+1),a=Math.ceil(t[4]/2.5+1),s=0,l=[],c=0,u=[],d=0,h=[],m=0,p=[],g=[];return n.forEach((f,y)=>{let v={},b=n[y-1]??f,S=(b.high+b.close+b.low+b.open)/4,x=Math.max(0,f.high-S),C=Math.max(0,S-f.low);y>=t[0]-1&&(C!==0?v.cr=x/C*100:v.cr=0,s+=v.cr,c+=v.cr,d+=v.cr,m+=v.cr,y>=t[0]+t[1]-2&&(l.push(s/t[1]),y>=t[0]+t[1]+r-3&&(v.ma1=l[l.length-1-r]),s-=g[y-(t[1]-1)].cr??0),y>=t[0]+t[2]-2&&(u.push(c/t[2]),y>=t[0]+t[2]+i-3&&(v.ma2=u[u.length-1-i]),c-=g[y-(t[2]-1)].cr??0),y>=t[0]+t[3]-2&&(h.push(d/t[3]),y>=t[0]+t[3]+o-3&&(v.ma3=h[h.length-1-o]),d-=g[y-(t[3]-1)].cr??0),y>=t[0]+t[4]-2&&(p.push(m/t[4]),y>=t[0]+t[4]+a-3&&(v.ma4=p[p.length-1-a]),m-=g[y-(t[4]-1)].cr??0)),g.push(v);}),g}},Mi=ba;var xa={name:"DMA",shortName:"DMA",calcParams:[10,50,10],figures:[{key:"dma",title:"DMA: ",type:"line"},{key:"ama",title:"AMA: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=Math.max(t[0],t[1]),i=0,o=0,a=0,s=[];return n.forEach((l,c)=>{let u={},d=l.close;i+=d,o+=d;let h=0,m=0;if(c>=t[0]-1&&(h=i/t[0],i-=n[c-(t[0]-1)].close),c>=t[1]-1&&(m=o/t[1],o-=n[c-(t[1]-1)].close),c>=r-1){let p=h-m;u.dma=p,a+=p,c>=r+t[2]-2&&(u.ama=a/t[2],a-=s[c-(t[2]-1)].dma??0);}s.push(u);}),s}},ki=xa;var Ca={name:"DMI",shortName:"DMI",calcParams:[14,6],figures:[{key:"pdi",title:"PDI: ",type:"line"},{key:"mdi",title:"MDI: ",type:"line"},{key:"adx",title:"ADX: ",type:"line"},{key:"adxr",title:"ADXR: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=0,a=0,s=0,l=0,c=0,u=0,d=[];return n.forEach((h,m)=>{let p={},g=n[m-1]??h,f=g.close,y=h.high,v=h.low,b=y-v,S=Math.abs(y-f),x=Math.abs(f-v),C=y-g.high,T=g.low-v,A=Math.max(Math.max(b,S),x),P=C>0&&C>T?C:0,I=T>0&&T>C?T:0;if(r+=A,i+=P,o+=I,m>=t[0]-1){m>t[0]-1?(a=a-a/t[0]+A,s=s-s/t[0]+P,l=l-l/t[0]+I):(a=r,s=i,l=o);let R=0,D=0;a!==0&&(R=s*100/a,D=l*100/a),p.pdi=R,p.mdi=D;let E=0;D+R!==0&&(E=Math.abs(D-R)/(D+R)*100),c+=E,m>=t[0]*2-2&&(m>t[0]*2-2?u=(u*(t[0]-1)+E)/t[0]:u=c/t[0],p.adx=u,m>=t[0]*2+t[1]-3&&(p.adxr=((d[m-(t[1]-1)].adx??0)+u)/2));}d.push(p);}),d}},Fi=Ca;var Ta={name:"DC",shortName:"DC",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"up",title:"UP: ",type:"line"},{key:"mid",title:"MID: ",type:"line"},{key:"dn",title:"DN: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0];return n.map((i,o)=>{let a={};if(o>=r-1){let s=-1/0,l=1/0;for(let c=o-(r-1);c<=o;c++)s=Math.max(s,n[c].high),l=Math.min(l,n[c].low);a.up=s,a.dn=l,a.mid=(s+l)/2;}return a})}},Li=Ta;var Sa={name:"DEMA",shortName:"DEMA",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"dema",title:"DEMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=0,s=[];return n.forEach((l,c)=>{let u={},d=l.close;if(i+=d,c>=r-1){if(c>r-1){let h=o;o=(2*d+(r-1)*o)/(r+1),a=(2*h+(r-1)*a)/(r+1);}else o=i/r,a=o;u.dema=2*o-a;}s.push(u);}),s}},Bi=Sa;var Aa={name:"EMV",shortName:"EMV",calcParams:[14,9],figures:[{key:"emv",title:"EMV: ",type:"line"},{key:"maEmv",title:"MAEMV: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=[];return n.map((o,a)=>{let s={};if(a>0){let l=n[a-1],c=o.high,u=o.low,d=o.volume??0,h=(c+u)/2-(l.high+l.low)/2;if(d===0||c-u===0)s.emv=0;else {let m=d/1e8/(c-u);s.emv=h/m;}r+=s.emv,i.push(s.emv),a>=t[0]&&(s.maEmv=r/t[0],r-=i[a-t[0]]);}return s})}},Oi=Aa;var Pa={name:"EMA",shortName:"EMA",series:"price",calcParams:[6,12,20],precision:2,shouldOhlc:true,figures:[{key:"ema1",title:"EMA6: ",type:"line"},{key:"ema2",title:"EMA12: ",type:"line"},{key:"ema3",title:"EMA20: ",type:"line"}],regenerateFigures:n=>n.map((e,t)=>({key:`ema${t+1}`,title:`EMA${e}: `,type:"line"})),calc:(n,e)=>{let{calcParams:t,figures:r}=e,i=0,o=[];return n.map((a,s)=>{let l={},c=a.close;return i+=c,t.forEach((u,d)=>{s>=u-1&&(s>u-1?o[d]=(2*c+(u-1)*o[d])/(u+1):o[d]=i/u,l[r[d].key]=o[d]);}),l})}},Vi=Pa;var wa={name:"HV",shortName:"HV",calcParams:[20],precision:4,figures:[{key:"hv",title:"HV: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=[],o=[];return n.forEach((a,s)=>{let l={},c=n[s-1];if(c&&c.close!==0?o.push(Math.log(a.close/c.close)):o.push(0),s>=r){let u=o.slice(s-r+1,s+1),d=u.reduce((p,g)=>p+g,0)/r,h=0;for(let p=0;p<u.length;p++)h+=(u[p]-d)**2;let m=Math.sqrt(h/(r-1));l.hv=m*Math.sqrt(252);}i.push(l);}),i}},Ni=wa;function Wr(n,e){if(n.length<e)return NaN;let t=0,r=0,i=n.length-e;for(let o=0;o<e;o++){let a=o+1;t+=n[i+o]*a,r+=a;}return t/r}var Ea={name:"HMA",shortName:"HMA",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"hma",title:"HMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=Math.max(Math.floor(r/2),1),o=Math.max(Math.round(Math.sqrt(r)),1),a=[],s=[];for(let l=0;l<n.length;l++){let c=n.slice(0,l+1).map(u=>u.close);if(c.length>=r){let u=Wr(c,r),d=Wr(c,i);s.push(2*d-u);}else s.push(NaN);}for(let l=0;l<n.length;l++){let c={};if(l>=r+o-2){let u=s.slice(l-(o-1),l+1);c.hma=Wr(u,o);}a.push(c);}return a}},Wi=Ea;var Ia={name:"Ichimoku",shortName:"Ichimoku",series:"price",calcParams:[9,26,52],precision:2,shouldOhlc:true,figures:[{key:"tenkan",title:"Tenkan: ",type:"line"},{key:"kijun",title:"Kijun: ",type:"line"},{key:"senkouA",title:"SenkouA: ",type:"line"},{key:"senkouB",title:"SenkouB: ",type:"line"},{key:"chikou",title:"Chikou: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,[r,i,o]=t,a=[];n.forEach((s,l)=>{let c={};if(l>=r-1){let u=-1/0,d=1/0;for(let h=l-(r-1);h<=l;h++)u=Math.max(u,n[h].high),d=Math.min(d,n[h].low);c.tenkan=(u+d)/2;}if(l>=i-1){let u=-1/0,d=1/0;for(let h=l-(i-1);h<=l;h++)u=Math.max(u,n[h].high),d=Math.min(d,n[h].low);c.kijun=(u+d)/2;}if(l>=o-1){let u=-1/0,d=1/0;for(let h=l-(o-1);h<=l;h++)u=Math.max(u,n[h].high),d=Math.min(d,n[h].low);c.senkouB=(u+d)/2;}a.push(c),l>=i&&(a[l-i].chikou=s.close);});for(let s=0;s<a.length;s++)if(a[s].tenkan!==void 0&&a[s].kijun!==void 0){let l=(a[s].tenkan+a[s].kijun)/2,c=s+i;c<a.length&&(a[c].senkouA=l);}return a}},Yi=Ia;var Da={name:"KC",shortName:"KC",series:"price",calcParams:[20,1.5],precision:2,shouldOhlc:true,figures:[{key:"up",title:"UP: ",type:"line"},{key:"mid",title:"MID: ",type:"line"},{key:"dn",title:"DN: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=t[0],i=t[1],o=0,a=0,s=0,l=0;return n.map((c,u)=>{let d={},h=c.close,m=n[u-1]??c,p=Math.max(c.high-c.low,Math.abs(c.high-m.close),Math.abs(m.close-c.low));return o+=h,s+=p,u>=r-1&&(u>r-1?(a=(2*h+(r-1)*a)/(r+1),l=(l*(r-1)+p)/r):(a=o/r,l=s/r),d.mid=a,d.up=a+i*l,d.dn=a-i*l),d})}},zi=Da;var Ra={name:"LinReg",shortName:"LinReg",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"linreg",title:"LinReg: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0];return n.map((i,o)=>{let a={};if(o>=r-1){let s=0,l=0,c=0,u=0;for(let m=0;m<r;m++){let p=m+1,g=n[o-(r-1)+m].close;s+=p,l+=g,c+=p*g,u+=p*p;}let d=(r*c-s*l)/(r*u-s*s),h=(l-d*s)/r;a.linreg=d*r+h,a.slope=d;}return a})}},Hi=Ra;var Ma={name:"MTM",shortName:"MTM",calcParams:[12,6],figures:[{key:"mtm",title:"MTM: ",type:"line"},{key:"maMtm",title:"MAMTM: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=[];return n.forEach((o,a)=>{let s={};if(a>=t[0]){let l=o.close,c=n[a-t[0]].close;s.mtm=l-c,r+=s.mtm,a>=t[0]+t[1]-1&&(s.maMtm=r/t[1],r-=i[a-(t[1]-1)].mtm??0);}i.push(s);}),i}},Gi=Ma;var ka={name:"MFI",shortName:"MFI",calcParams:[14],precision:2,figures:[{key:"mfi",title:"MFI: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=[];return n.forEach((s,l)=>{let c={},u=n[l-1]??s,d=(s.high+s.low+s.close)/3,h=(u.high+u.low+u.close)/3,m=d*(s.volume??0);if(d>h?i+=m:d<h&&(o+=m),l>=r-1){if(o!==0&&i+o!==0){let b=i/o;c.mfi=100-100/(1+b);}else i===0&&o===0?c.mfi=50:i===0?c.mfi=0:c.mfi=100;let p=n[l-(r-1)],g=n[l-r]??p,f=(p.high+p.low+p.close)/3,y=(g.high+g.low+g.close)/3,v=f*(p.volume??0);f>y?i-=v:f<y&&(o-=v);}a.push(c);}),a}},Xi=ka;var Fa={name:"MA",shortName:"MA",series:"price",calcParams:[5,10,30,60],precision:2,shouldOhlc:true,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA30: ",type:"line"},{key:"ma4",title:"MA60: ",type:"line"}],regenerateFigures:n=>n.map((e,t)=>({key:`ma${t+1}`,title:`MA${e}: `,type:"line"})),calc:(n,e)=>{let{calcParams:t,figures:r}=e,i=[];return n.map((o,a)=>{let s={},l=o.close;return t.forEach((c,u)=>{i[u]=(i[u]??0)+l,a>=c-1&&(s[r[u].key]=i[u]/c,i[u]-=n[a-(c-1)].close);}),s})}},Ui=Fa;var La={name:"MACD",shortName:"MACD",calcParams:[12,26,9],figures:[{key:"dif",title:"DIF: ",type:"line"},{key:"dea",title:"DEA: ",type:"line"},{key:"macd",title:"MACD: ",type:"bar",baseValue:0,styles:({data:n,indicator:e,defaultStyles:t})=>{let{prev:r,current:i}=n,o=r?.macd??Number.MIN_SAFE_INTEGER,a=i?.macd??Number.MIN_SAFE_INTEGER,s="";return a>0?s=Q(e.styles,"bars[0].upColor",t.bars[0].upColor):a<0?s=Q(e.styles,"bars[0].downColor",t.bars[0].downColor):s=Q(e.styles,"bars[0].noChangeColor",t.bars[0].noChangeColor),{style:o<a?"stroke":"fill",color:s,borderColor:s}}}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=0,a=0,s=0,l=0,c=Math.max(t[0],t[1]);return n.map((u,d)=>{let h={},m=u.close;return r+=m,d>=t[0]-1&&(d>t[0]-1?i=(2*m+(t[0]-1)*i)/(t[0]+1):i=r/t[0]),d>=t[1]-1&&(d>t[1]-1?o=(2*m+(t[1]-1)*o)/(t[1]+1):o=r/t[1]),d>=c-1&&(a=i-o,h.dif=a,s+=a,d>=c+t[2]-2&&(d>c+t[2]-2?l=(a*2+l*(t[2]-1))/(t[2]+1):l=s/t[2],h.macd=(a-l)*2,h.dea=l)),h})}},$i=La;var Ba={name:"OBV",shortName:"OBV",calcParams:[30],figures:[{key:"obv",title:"OBV: ",type:"line"},{key:"maObv",title:"MAOBV: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=[];return n.forEach((a,s)=>{let l=n[s-1]??a;a.close<l.close?i-=a.volume??0:a.close>l.close&&(i+=a.volume??0);let c={obv:i};r+=i,s>=t[0]-1&&(c.maObv=r/t[0],r-=o[s-(t[0]-1)].obv??0),o.push(c);}),o}},qi=Ba;var Oa={name:"PP",shortName:"PP",series:"price",precision:2,shouldOhlc:true,figures:[{key:"pp",title:"PP: ",type:"line"},{key:"r1",title:"R1: ",type:"line"},{key:"r2",title:"R2: ",type:"line"},{key:"r3",title:"R3: ",type:"line"},{key:"s1",title:"S1: ",type:"line"},{key:"s2",title:"S2: ",type:"line"},{key:"s3",title:"S3: ",type:"line"}],calc:n=>n.map((e,t)=>{let r={},i=n[t-1];if(i){let o=(i.high+i.low+i.close)/3;r.pp=o,r.r1=2*o-i.low,r.r2=o+(i.high-i.low),r.r3=i.high+2*(o-i.low),r.s1=2*o-i.high,r.s2=o-(i.high-i.low),r.s3=i.low-2*(i.high-o);}return r})},ji=Oa;var Va={name:"PVT",shortName:"PVT",figures:[{key:"pvt",title:"PVT: ",type:"line"}],calc:n=>{let e=0;return n.map((t,r)=>{let i={},o=t.close,a=t.volume??1,s=(n[r-1]??t).close,l=0,c=s*a;return c!==0&&(l=(o-s)/c),e+=l,i.pvt=e,i})}},Zi=Va;var Na={name:"PSY",shortName:"PSY",calcParams:[12,6],figures:[{key:"psy",title:"PSY: ",type:"line"},{key:"maPsy",title:"MAPSY: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=[],a=[];return n.forEach((s,l)=>{let c={},u=(n[l-1]??s).close,d=s.close-u>0?1:0;o.push(d),r+=d,l>=t[0]-1&&(c.psy=r/t[0]*100,i+=c.psy,l>=t[0]+t[1]-2&&(c.maPsy=i/t[1],i-=a[l-(t[1]-1)].psy??0),r-=o[l-(t[0]-1)]),a.push(c);}),a}},Qi=Na;var Wa={name:"ROC",shortName:"ROC",calcParams:[12,6],figures:[{key:"roc",title:"ROC: ",type:"line"},{key:"maRoc",title:"MAROC: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=[],i=0;return n.forEach((o,a)=>{let s={};if(a>=t[0]-1){let l=o.close,c=(n[a-t[0]]??n[a-(t[0]-1)]).close;c!==0?s.roc=(l-c)/c*100:s.roc=0,i+=s.roc,a>=t[0]-1+t[1]-1&&(s.maRoc=i/t[1],i-=r[a-(t[1]-1)].roc??0);}r.push(s);}),r}},Ki=Wa;var Ya={name:"RSI",shortName:"RSI",calcParams:[6,12,24],figures:[{key:"rsi1",title:"RSI1: ",type:"line"},{key:"rsi2",title:"RSI2: ",type:"line"},{key:"rsi3",title:"RSI3: ",type:"line"}],regenerateFigures:n=>n.map((e,t)=>{let r=t+1;return {key:`rsi${r}`,title:`RSI${r}: `,type:"line"}}),calc:(n,e)=>{let{calcParams:t,figures:r}=e,i=[],o=[];return n.map((a,s)=>{let l={},c=(n[s-1]??a).close,u=a.close-c;return t.forEach((d,h)=>{if(u>0?i[h]=(i[h]??0)+u:o[h]=(o[h]??0)+Math.abs(u),s>=d-1){o[h]!==0?l[r[h].key]=100-100/(1+i[h]/o[h]):l[r[h].key]=0;let m=n[s-(d-1)],p=n[s-d]??m,g=m.close-p.close;g>0?i[h]-=g:o[h]-=Math.abs(g);}}),l})}},Ji=Ya;var za={name:"SAMPLE",shortName:"Sample Study",calcParams:[14],figures:[{key:"value",title:"Value: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams[0]??14,r=0,i=0;return n.map((o,a)=>{let s={};if(a===0)return s.value=50,s;let l=o.close-n[a-1].close,c=Math.max(l,0),u=Math.max(-l,0);if(a<=t?(r=(r*(a-1)+c)/a,i=(i*(a-1)+u)/a):(r=(r*(t-1)+c)/t,i=(i*(t-1)+u)/t),i===0)s.value=100;else {let d=r/i;s.value=100-100/(1+d);}return s})}},eo=za;var Ha={name:"SMA",shortName:"SMA",series:"price",calcParams:[12,2],precision:2,figures:[{key:"sma",title:"SMA: ",type:"line"}],shouldOhlc:true,calc:(n,e)=>{let t=e.calcParams,r=0,i=0;return n.map((o,a)=>{let s={},l=o.close;return r+=l,a>=t[0]-1&&(a>t[0]-1?i=(l*t[1]+i*(t[0]-t[1]+1))/(t[0]+1):i=r/t[0],s.sma=i),s})}},to=Ha;var Ga={name:"STDDEV",shortName:"STDDEV",calcParams:[20],precision:4,figures:[{key:"stddev",title:"STDDEV: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0];return n.map((i,o)=>{let a={};if(o>=r-1){let s=0;for(let u=o-(r-1);u<=o;u++)s+=n[u].close;let l=s/r,c=0;for(let u=o-(r-1);u<=o;u++)c+=(n[u].close-l)**2;a.stddev=Math.sqrt(c/r);}return a})}},ro=Ga;function xt(n,e,t){let r=0,i=0;for(i=n.length-1;r!==i;){let o=Math.floor((i+r)/2),a=i-r,s=n[o][e];if(t===n[r][e])return r;if(t===n[i][e])return i;if(t===s)return o;if(t>s?r=o:i=o,a<=2)break}return r}function io(n){let e=Math.floor(be(n)),t=Ae(e),r=n/t,i=0;return r<1.5?i=1:r<2.5?i=2:r<3.5?i=3:r<4.5?i=4:r<5.5?i=5:r<6.5?i=6:i=8,n=i*t,+n.toFixed(Math.abs(e))}function Yr(n,e){e=Math.max(0,e??0);let t=Math.pow(10,e);return Math.round(n*t)/t}function oo(n){let e=n.toString(),t=e.indexOf("e");if(t>0){let i=+e.slice(t+1);return i<0?-i:0}let r=e.indexOf(".");return r<0?0:e.length-1-r}function vr(n,e,t){let r=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],i=n.length,o=0;for(;o<i;){let a=n[o];r[0]=Math.max(a[e]??Number.MIN_SAFE_INTEGER,r[0]),r[1]=Math.min(a[t]??Number.MAX_SAFE_INTEGER,r[1]),++o;}return r}function be(n){return n===0?0:Math.log10(n)}function Ae(n){return Math.pow(10,n)}var Xa={name:"KDJ",shortName:"KDJ",calcParams:[9,3,3],figures:[{key:"k",title:"K: ",type:"line"},{key:"d",title:"D: ",type:"line"},{key:"j",title:"J: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=[];return n.forEach((i,o)=>{let a={},s=i.close;if(o>=t[0]-1){let l=vr(n.slice(o-(t[0]-1),o+1),"high","low"),c=l[0],u=l[1],d=c-u,h=(s-u)/(d===0?1:d)*100;a.k=((t[1]-1)*(r[o-1]?.k??50)+h)/t[1],a.d=((t[2]-1)*(r[o-1]?.d??50)+a.k)/t[2],a.j=3*a.k-2*a.d;}r.push(a);}),r}},no=Xa;var Ua={name:"SAR",shortName:"SAR",series:"price",calcParams:[2,2,20],precision:2,shouldOhlc:true,figures:[{key:"sar",title:"SAR: ",type:"circle",styles:({data:n,indicator:e,defaultStyles:t})=>{let{current:r}=n,i=r?.sar??Number.MIN_SAFE_INTEGER,o=((r?.high??0)+(r?.low??0))/2;return {color:i<o?Q(e.styles,"circles[0].upColor",t.circles[0].upColor):Q(e.styles,"circles[0].downColor",t.circles[0].downColor)}}}],calc:(n,e)=>{let t=e.calcParams,r=t[0]/100,i=t[1]/100,o=t[2]/100,a=r,s=-100,l=false,c=0;return n.map((u,d)=>{let h=c,m=u.high,p=u.low;if(l){(s===-100||s<m)&&(s=m,a=Math.min(a+i,o)),c=h+a*(s-h);let g=Math.min(n[Math.max(1,d)-1].low,p);c>u.low?(c=s,a=r,s=-100,l=!l):c>g&&(c=g);}else {(s===-100||s>p)&&(s=p,a=Math.min(a+i,o)),c=h+a*(s-h);let g=Math.max(n[Math.max(1,d)-1].high,m);c<u.high?(c=s,a=0,s=-100,l=!l):c<g&&(c=g);}return {high:m,low:p,sar:c}})}},ao=Ua;var $a={name:"SuperTrend",shortName:"SuperTrend",series:"price",calcParams:[10,3],precision:2,shouldOhlc:true,figures:[{key:"superTrend",title:"SuperTrend: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=t[0],i=t[1],o=0,a=0,s=1,l=0,c=0,u=[];return n.forEach((d,h)=>{let m={},p=(d.high+d.low)/2,g=n[h-1]??d,f=Math.max(d.high-d.low,Math.abs(d.high-g.close),Math.abs(g.close-d.low));if(o+=f,h>=r-1){h>r-1?a=(a*(r-1)+f)/r:a=o/r;let y=p+i*a,v=p-i*a;h===r-1?(l=y,c=v,s=1):(l=y<l||g.close>l?y:l,c=v>c||g.close<c?v:c,s===1&&d.close<c?s=-1:s===-1&&d.close>l&&(s=1)),m.superTrend=s===1?c:l,m.direction=s;}u.push(m);}),u}},so=$a;var qa={name:"TEMA",shortName:"TEMA",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"tema",title:"TEMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=0,s=0,l=[];return n.forEach((c,u)=>{let d={},h=c.close;if(i+=h,u>=r-1){if(u>r-1){let m=o,p=a;o=(2*h+(r-1)*o)/(r+1),a=(2*m+(r-1)*a)/(r+1),s=(2*p+(r-1)*s)/(r+1);}else o=i/r,a=o,s=o;d.tema=3*o-3*a+s;}l.push(d);}),l}},lo=qa;var ja={name:"TRIX",shortName:"TRIX",calcParams:[12,9],figures:[{key:"trix",title:"TRIX: ",type:"line"},{key:"maTrix",title:"MATRIX: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=0,a=0,s=0,l=0,c=0,u=[];return n.forEach((d,h)=>{let m={},p=d.close;if(r+=p,h>=t[0]-1&&(h>t[0]-1?i=(2*p+(t[0]-1)*i)/(t[0]+1):i=r/t[0],s+=i,h>=t[0]*2-2&&(h>t[0]*2-2?o=(2*i+(t[0]-1)*o)/(t[0]+1):o=s/t[0],l+=o,h>=t[0]*3-3))){let g=0,f=0;h>t[0]*3-3?(g=(2*o+(t[0]-1)*a)/(t[0]+1),f=(g-a)/a*100):g=l/t[0],a=g,m.trix=f,c+=f,h>=t[0]*3+t[1]-4&&(m.maTrix=c/t[1],c-=u[h-(t[1]-1)].trix??0);}u.push(m);}),u}},co=ja;function Za(n){let e=n.match(/^rgba\(([^)]+)\)$/i);if(e===null)return n;let t=e[1].split(",").map(r=>r.trim());return t.length<3?n:`rgba(${t[0]}, ${t[1]}, ${t[2]}, 1)`}function uo(){return {key:"volume",title:"VOLUME: ",type:"bar",baseValue:0,attrs:({coordinate:n,barSpace:e,yAxis:t})=>{let r=n.current.volume;if(!_(r))return null;let i=e.gapBar%2===0?1:0,o=t.convertToPixel(t.getRange().from),a=n.current.x-e.halfGapBar,s=e.gapBar+i,l=Math.min(r,o),c=Math.max(1,Math.abs(o-r));return {x:a,y:l,width:s,height:c}},styles:({data:n,indicator:e,defaultStyles:t})=>{let r=n.current,i=Q(e.styles,"bars[0].noChangeColor",t.bars[0].noChangeColor);return _(r)&&(r.close>r.open?i=Q(e.styles,"bars[0].upColor",t.bars[0].upColor):r.close<r.open&&(i=Q(e.styles,"bars[0].downColor",t.bars[0].downColor))),{color:Za(i)}}}}var Qa={name:"VOL",shortName:"VOL",series:"volume",calcParams:[7,25,99],shouldFormatBigNumber:true,precision:0,minValue:0,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA20: ",type:"line"},uo()],regenerateFigures:n=>{let e=n.map((t,r)=>({key:`ma${r+1}`,title:`MA${t}: `,type:"line"}));return e.push(uo()),e},calc:(n,e)=>{let{calcParams:t,figures:r}=e,i=[];return n.map((o,a)=>{let s=o.volume??0,l={volume:s,open:o.open,close:o.close};return t.forEach((c,u)=>{i[u]=(i[u]??0)+s,a>=c-1&&(l[r[u].key]=i[u]/c,i[u]-=n[a-(c-1)].volume??0);}),l})}},ho=Qa;var Ka={name:"VROC",shortName:"VROC",calcParams:[14],precision:2,figures:[{key:"vroc",title:"VROC: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0];return n.map((i,o)=>{let a={};if(o>=r){let s=n[o-r].volume??0,l=i.volume??0;s!==0&&(a.vroc=(l-s)/s*100);}return a})}},mo=Ka;var Ja={name:"VR",shortName:"VR",calcParams:[26,6],figures:[{key:"vr",title:"VR: ",type:"line"},{key:"maVr",title:"MAVR: ",type:"line"}],calc:(n,e)=>{let t=e.calcParams,r=0,i=0,o=0,a=0,s=[];return n.forEach((l,c)=>{let u={},d=l.close,h=(n[c-1]??l).close,m=l.volume??0;if(d>h?r+=m:d<h?i+=m:o+=m,c>=t[0]-1){let p=o/2;i+p===0?u.vr=0:u.vr=(r+p)/(i+p)*100,a+=u.vr,c>=t[0]+t[1]-2&&(u.maVr=a/t[1],a-=s[c-(t[1]-1)].vr??0);let g=n[c-(t[0]-1)],f=n[c-t[0]]??g,y=g.close,v=g.volume??0;y>f.close?r-=v:y<f.close?i-=v:o-=v;}s.push(u);}),s}},po=Ja;var es={name:"VWAP",shortName:"VWAP",series:"price",precision:2,shouldOhlc:true,figures:[{key:"vwap",title:"VWAP: ",type:"line"}],calc:n=>{let e=0,t=0;return n.map(r=>{let i={},o=r.volume??0,a=(r.high+r.low+r.close)/3;return e+=a*o,t+=o,t!==0&&(i.vwap=e/t),i})}},go=es;var ts={name:"VWMA",shortName:"VWMA",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"vwma",title:"VWMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=0,o=0,a=[];return n.forEach((s,l)=>{let c={},u=s.volume??0;if(i+=s.close*u,o+=u,l>=r-1){o!==0&&(c.vwma=i/o);let d=n[l-(r-1)],h=d.volume??0;i-=d.close*h,o-=h;}a.push(c);}),a}},fo=ts;var rs={name:"WMA",shortName:"WMA",series:"price",calcParams:[20],precision:2,shouldOhlc:true,figures:[{key:"wma",title:"WMA: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0],i=r*(r+1)/2;return n.map((o,a)=>{let s={};if(a>=r-1){let l=0;for(let c=0;c<r;c++){let u=c+1;l+=n[a-(r-1)+c].close*u;}s.wma=l/i;}return s})}},vo=rs;var is={name:"WR",shortName:"WR",calcParams:[6,10,14],figures:[{key:"wr1",title:"WR1: ",type:"line"},{key:"wr2",title:"WR2: ",type:"line"},{key:"wr3",title:"WR3: ",type:"line"}],regenerateFigures:n=>n.map((e,t)=>({key:`wr${t+1}`,title:`WR${t+1}: `,type:"line"})),calc:(n,e)=>{let{calcParams:t,figures:r}=e;return n.map((i,o)=>{let a={},s=i.close;return t.forEach((l,c)=>{let u=l-1;if(o>=u){let d=vr(n.slice(o-u,o+1),"high","low"),h=d[0],m=d[1],p=h-m;a[r[c].key]=p===0?0:(s-h)/p*100;}}),a})}},yo=is;var os={name:"ZZ",shortName:"ZZ",series:"price",calcParams:[5],precision:2,shouldOhlc:true,figures:[{key:"zigzag",title:"ZZ: ",type:"line"}],calc:(n,e)=>{let r=e.calcParams[0]/100,i=n.map(()=>({}));if(n.length<3)return i;let o=n[1].close>n[0].close?1:-1;o===1?n[0].low:n[0].high;let l=0,c=o===1?n[0].high:n[0].low;for(let u=1;u<n.length;u++)o===1?(n[u].high>=c&&(l=u,c=n[u].high),(c-n[u].low)/c>=r&&(i[l].zigzag=c,o=-1,l=u,c=n[u].low)):(n[u].low<=c&&(l=u,c=n[u].low),(n[u].high-c)/c>=r&&(i[l].zigzag=c,o=1,l=u,c=n[u].high));return i}},_o=os;var yr={},ns=[_i,bi,xi,Ci,Ti,Si,Ai,Pi,wi,Ei,Ii,Di,Ri,Mi,ki,Fi,Li,Bi,Oi,Vi,Ni,Wi,Yi,zi,Hi,Gi,Xi,Ui,$i,qi,ji,Zi,Qi,Ki,Ji,eo,to,ro,no,ao,so,lo,co,ho,mo,po,go,fo,vo,yo,_o],bo=false;function as(){bo||(ns.forEach(n=>{yr[n.name]=st.extend(n);}),bo=true);}function ss(n){yr[n.name]=st.extend(n);}function _r(n){return yr[n]??null}function ls(){return Object.keys(yr)}function ge(n,e){let t=e?.ignoreEvent??false;return Se(t)?!t:!t.includes(n)}var xo=1,Ct=-1,Co="overlay_",Ne="overlay_figure_",ct=class n{id;groupId="";paneId;name;totalStep=1;currentStep=xo;lock=false;visible=true;zLevel=0;needDefaultPointFigure=false;needDefaultXAxisFigure=false;needDefaultYAxisFigure=false;mode="normal";modeSensitivity=8;points=[];extendData;styles=null;createPointFigures=null;createXAxisFigures=null;createYAxisFigures=null;performEventPressedMove=null;performEventMoveForDrawing=null;onDrawStart=null;onDrawing=null;onDrawEnd=null;onClick=null;onDoubleClick=null;onRightClick=null;onPressedMoveStart=null;onPressedMoving=null;onPressedMoveEnd=null;onMouseMove=null;onMouseEnter=null;onMouseLeave=null;onRemoved=null;onSelected=null;onDeselected=null;_prevZLevel=0;_prevOverlay;_prevPressedPoint=null;_prevPressedPoints=[];constructor(e){this.override(e);}override(e){this._prevOverlay=Te({...this,_prevOverlay:null});let{id:t,name:r,currentStep:i,points:o,styles:a,...s}=e;if(G(this,s),L(this.name)||(this.name=r??""),!L(this.id)&&L(t)&&(this.id=t),_(a)&&(this.styles??={},G(this.styles,a)),ne(o)&&o.length>0){let l=0;if(this.points=[...o],o.length>=this.totalStep-1?(this.currentStep=Ct,l=this.totalStep-1):(this.currentStep=o.length+1,l=o.length),q(this.performEventMoveForDrawing))for(let c=0;c<l;c++)this.performEventMoveForDrawing({currentStep:c+2,mode:this.mode,points:this.points,performPointIndex:c,performPoint:this.points[c]});this.currentStep===Ct&&this.performEventPressedMove?.({currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:this.points.length-1,performPoint:this.points[this.points.length-1]});}}getPrevZLevel(){return this._prevZLevel}setPrevZLevel(e){this._prevZLevel=e;}shouldUpdate(){let e=this._prevOverlay.zLevel!==this.zLevel,t=e||JSON.stringify(this._prevOverlay.points)!==JSON.stringify(this.points)||this._prevOverlay.visible!==this.visible||this._prevOverlay.extendData!==this.extendData||this._prevOverlay.styles!==this.styles;return {sort:e,draw:t}}nextStep(){this.currentStep===this.totalStep-1?this.currentStep=Ct:this.currentStep++;}forceComplete(){this.currentStep=Ct;}isDrawing(){return this.currentStep!==Ct}isStart(){return this.currentStep===xo}eventMoveForDrawing(e){let t=this.currentStep-1,r={};w(e.timestamp)&&(r.timestamp=e.timestamp),w(e.dataIndex)&&(r.dataIndex=e.dataIndex),w(e.value)&&(r.value=e.value),this.points[t]=r,this.performEventMoveForDrawing?.({currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:t,performPoint:r});}eventPressedPointMove(e,t){this.points[t].timestamp=e.timestamp,w(e.value)&&(this.points[t].value=e.value),this.performEventPressedMove?.({currentStep:this.currentStep,points:this.points,mode:this.mode,performPointIndex:t,performPoint:this.points[t]});}startPressedMove(e){this._prevPressedPoint={...e},this._prevPressedPoints=Te(this.points);}eventPressedOtherMove(e,t){if(this._prevPressedPoint!==null){let r=null;w(e.dataIndex)&&w(this._prevPressedPoint.dataIndex)&&(r=e.dataIndex-this._prevPressedPoint.dataIndex);let i=null;w(e.value)&&w(this._prevPressedPoint.value)&&(i=e.value-this._prevPressedPoint.value),this.points=this._prevPressedPoints.map(o=>{w(o.timestamp)&&(o.dataIndex=t.timestampToDataIndex(o.timestamp));let a={...o};return w(r)&&w(o.dataIndex)&&(a.dataIndex=o.dataIndex+r,a.timestamp=t.dataIndexToTimestamp(a.dataIndex)??void 0),w(i)&&w(o.value)&&(a.value=o.value+i),a});}}static extend(e){class t extends n{constructor(){super(e);}}return t}};var j={PRICE:2,VOLUME:0};var cs={name:"fibonacciLine",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({chart:n,coordinates:e,bounding:t,overlay:r,yAxis:i})=>{let o=r.points;if(e.length>0){let a=0;i?.isInCandle()??true?a=n.getSymbol()?.pricePrecision??j.PRICE:n.getIndicators({paneId:r.paneId}).forEach(h=>{a=Math.max(a,h.precision);});let s=[],l=[],c=0,u=t.width;if(e.length>1&&w(o[0].value)&&w(o[1].value)){let d=[1,.786,.618,.5,.382,.236,0],h=e[0].y-e[1].y,m=o[0].value-o[1].value;d.forEach(p=>{let g=e[1].y+h*p,f=n.getDecimalFold().format(n.getThousandsSeparator().format(((o[1].value??0)+m*p).toFixed(a)));s.push({coordinates:[{x:c,y:g},{x:u,y:g}]}),l.push({x:c,y:g,text:`${f} (${(p*100).toFixed(1)}%)`,baseline:"bottom"});});}return [{type:"line",attrs:s},{type:"text",isCheckEvent:false,attrs:l}]}return []}},To=cs;var us={name:"horizontalRayLine",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>{let t={x:0,y:n[0].y};return _(n[1])&&n[0].x<n[1].x&&(t.x=e.width),[{type:"line",attrs:{coordinates:[n[0],t]}}]},performEventPressedMove:({points:n,performPoint:e})=>{n[0].value=e.value,n[1].value=e.value;},performEventMoveForDrawing:({currentStep:n,points:e,performPoint:t})=>{n===2&&(e[0].value=t.value);}},So=us;var ds={name:"horizontalSegment",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n})=>{let e=[];return n.length===2&&e.push({coordinates:n}),[{type:"line",attrs:e}]},performEventPressedMove:({points:n,performPoint:e})=>{n[0].value=e.value,n[1].value=e.value;},performEventMoveForDrawing:({currentStep:n,points:e,performPoint:t})=>{n===2&&(e[0].value=t.value);}},Ao=ds;var hs={name:"horizontalStraightLine",totalStep:2,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>[{type:"line",attrs:{coordinates:[{x:0,y:n[0].y},{x:e.width,y:n[0].y}]}}]},Po=hs;var Pe=class{_children=[];_callbacks=new Map;registerEvent(e,t){return this._callbacks.set(e,t),this}onEvent(e,t){let r=this._callbacks.get(e);return _(r)&&this.checkEventOn(t)?r(t):false}dispatchEventToChildren(e,t){let r=this._children.length-1;if(r>-1){for(let i=r;i>-1;i--)if(this._children[i].dispatchEvent(e,t))return true}return false}dispatchEvent(e,t){return this.dispatchEventToChildren(e,t)?true:this.onEvent(e,t)}addChild(e){return this._children.push(e),this}clear(){this._children=[];}};var te=2,ut=class n extends Pe{attrs;styles;constructor(e){super(),this.attrs=e.attrs,this.styles=e.styles;}checkEventOn(e){return this.checkEventOnImp(e,this.attrs,this.styles)}setAttrs(e){return this.attrs=e,this}setStyles(e){return this.styles=e,this}draw(e){this.drawImp(e,this.attrs,this.styles);}static extend(e){class t extends n{checkEventOnImp(i,o,a){return e.checkEventOn(i,o,a)}drawImp(i,o,a){e.draw(i,o,a);}}return t}};function zr(n,e){let t=[];t=t.concat(e);for(let r of t){let{coordinates:i}=r;if(i.length>1)for(let o=1;o<i.length;o++){let a=i[o-1],s=i[o];if(a.x===s.x){if(Math.abs(a.y-n.y)+Math.abs(s.y-n.y)-Math.abs(a.y-s.y)<te+te&&Math.abs(n.x-a.x)<te)return true}else {let l=dt(a,s),c=br(l,n),u=Math.abs(c-n.y);if(Math.abs(a.x-n.x)+Math.abs(s.x-n.x)-Math.abs(a.x-s.x)<te+te&&u*u/(l[0]*l[0]+1)<te*te)return true}}}return false}function br(n,e){return n!==null?e.x*n[0]+n[1]:e.y}function Fe(n,e,t){let r=dt(n,e);return br(r,t)}function dt(n,e){let t=n.x-e.x;if(t!==0){let r=(n.y-e.y)/t,i=n.y-r*n.x;return [r,i]}return null}function Hr(n,e,t){let r=e.length,i=w(t)?t>0&&t<1?t:0:t?.5:0;if(i>0&&r>2){let o=e[0].x,a=e[0].y;for(let l=1;l<r-1;l++){let c=e[l-1],u=e[l],d=e[l+1],h=u.x-c.x,m=u.y-c.y,p=d.x-u.x,g=d.y-u.y,f=d.x-c.x,y=d.y-c.y,v=Math.sqrt(h*h+m*m),b=Math.sqrt(p*p+g*g),S=b/(b+v),x=u.x+f*i*S,C=u.y+y*i*S;x=Math.min(x,Math.max(d.x,u.x)),C=Math.min(C,Math.max(d.y,u.y)),x=Math.max(x,Math.min(d.x,u.x)),C=Math.max(C,Math.min(d.y,u.y)),f=x-u.x,y=C-u.y;let T=u.x-f*v/b,A=u.y-y*v/b;T=Math.min(T,Math.max(c.x,u.x)),A=Math.min(A,Math.max(c.y,u.y)),T=Math.max(T,Math.min(c.x,u.x)),A=Math.max(A,Math.min(c.y,u.y)),f=u.x-T,y=u.y-A,x=u.x+f*b/v,C=u.y+y*b/v,n.bezierCurveTo(o,a,T,A,u.x,u.y),o=x,a=C;}let s=e[r-1];n.bezierCurveTo(o,a,s.x,s.y,s.x,s.y);}else for(let o=1;o<r;o++)n.lineTo(e[o].x,e[o].y);}function ms(n,e,t){let r=[];r=r.concat(e);let{style:i="solid",smooth:o=false,size:a=1,color:s="currentColor",dashedValue:l=[2,2]}=t;n.lineWidth=a,n.strokeStyle=s,i==="dashed"?n.setLineDash(l):n.setLineDash([]);let c=a%2===1?.5:0;r.forEach(({coordinates:u})=>{u.length>1&&(u.length===2&&(u[0].x===u[1].x||u[0].y===u[1].y)?(n.beginPath(),u[0].x===u[1].x?(n.moveTo(u[0].x+c,u[0].y),n.lineTo(u[1].x+c,u[1].y)):(n.moveTo(u[0].x,u[0].y+c),n.lineTo(u[1].x,u[1].y+c)),n.stroke(),n.closePath()):(n.save(),a%2===1&&n.translate(.5,.5),n.beginPath(),n.moveTo(u[0].x,u[0].y),Hr(n,u,o),n.stroke(),n.closePath(),n.restore()));});}var ps={name:"line",checkEventOn:zr,draw:(n,e,t)=>{ms(n,e,t);}},wo=ps;function Gr(n,e,t){let r=t??0,i=[];if(n.length>1)if(n[0].x===n[1].x){let a=e.height;if(i.push({coordinates:[{x:n[0].x,y:0},{x:n[0].x,y:a}]}),n.length>2){i.push({coordinates:[{x:n[2].x,y:0},{x:n[2].x,y:a}]});let s=n[0].x-n[2].x;for(let l=0;l<r;l++){let c=s*(l+1);i.push({coordinates:[{x:n[0].x+c,y:0},{x:n[0].x+c,y:a}]});}}}else {let a=e.width,s=dt(n[0],n[1]),l=s[0],c=s[1];if(i.push({coordinates:[{x:0,y:0*l+c},{x:a,y:a*l+c}]}),n.length>2){let u=n[2].y-l*n[2].x;i.push({coordinates:[{x:0,y:0*l+u},{x:a,y:a*l+u}]});let d=c-u;for(let h=0;h<r;h++){let m=c+d*(h+1);i.push({coordinates:[{x:0,y:0*l+m},{x:a,y:a*l+m}]});}}}return i}var gs={name:"parallelStraightLine",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>[{type:"line",attrs:Gr(n,e)}]},Eo=gs;var fs={name:"priceChannelLine",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>[{type:"line",attrs:Gr(n,e,1)}]},Io=fs;var vs={name:"priceLine",totalStep:2,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({chart:n,coordinates:e,bounding:t,overlay:r,yAxis:i})=>{let o=0;i?.isInCandle()??true?o=n.getSymbol()?.pricePrecision??j.PRICE:n.getIndicators({paneId:r.paneId}).forEach(l=>{o=Math.max(o,l.precision);});let{value:a=0}=r.points[0];return [{type:"line",attrs:{coordinates:[e[0],{x:t.width,y:e[0].y}]}},{type:"text",ignoreEvent:true,attrs:{x:e[0].x,y:e[0].y,text:n.getDecimalFold().format(n.getThousandsSeparator().format(a.toFixed(o))),baseline:"bottom"}}]}},Do=vs;function ys(n,e){if(n.length>1){let t={x:0,y:0};return n[0].x===n[1].x&&n[0].y!==n[1].y?n[0].y<n[1].y?t={x:n[0].x,y:e.height}:t={x:n[0].x,y:0}:n[0].x>n[1].x?t={x:0,y:Fe(n[0],n[1],{x:0,y:n[0].y})}:t={x:e.width,y:Fe(n[0],n[1],{x:e.width,y:n[0].y})},{coordinates:[n[0],t]}}return []}var _s={name:"rayLine",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>[{type:"line",attrs:ys(n,e)}]},Ro=_s;var bs={name:"segment",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n})=>n.length===2?[{type:"line",attrs:{coordinates:n}}]:[]},Mo=bs;var xs={name:"straightLine",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>n.length===2?n[0].x===n[1].x?[{type:"line",attrs:{coordinates:[{x:n[0].x,y:0},{x:n[0].x,y:e.height}]}}]:[{type:"line",attrs:{coordinates:[{x:0,y:Fe(n[0],n[1],{x:0,y:n[0].y})},{x:e.width,y:Fe(n[0],n[1],{x:e.width,y:n[0].y})}]}}]:[]},ko=xs;var Cs={name:"verticalRayLine",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>{if(n.length===2){let t={x:n[0].x,y:0};return n[0].y<n[1].y&&(t.y=e.height),[{type:"line",attrs:{coordinates:[n[0],t]}}]}return []},performEventPressedMove:({points:n,performPoint:e})=>{n[0].timestamp=e.timestamp,n[0].dataIndex=e.dataIndex,n[1].timestamp=e.timestamp,n[1].dataIndex=e.dataIndex;},performEventMoveForDrawing:({currentStep:n,points:e,performPoint:t})=>{n===2&&(e[0].timestamp=t.timestamp,e[0].dataIndex=t.dataIndex);}},Fo=Cs;var Ts={name:"verticalSegment",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n})=>n.length===2?[{type:"line",attrs:{coordinates:n}}]:[],performEventPressedMove:({points:n,performPoint:e})=>{n[0].timestamp=e.timestamp,n[0].dataIndex=e.dataIndex,n[1].timestamp=e.timestamp,n[1].dataIndex=e.dataIndex;},performEventMoveForDrawing:({currentStep:n,points:e,performPoint:t})=>{n===2&&(e[0].timestamp=t.timestamp,e[0].dataIndex=t.dataIndex);}},Lo=Ts;var Ss={name:"verticalStraightLine",totalStep:2,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:n,bounding:e})=>[{type:"line",attrs:{coordinates:[{x:n[0].x,y:0},{x:n[0].x,y:e.height}]}}]},Bo=Ss;var As={name:"simpleAnnotation",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:({overlay:n,coordinates:e})=>{let t="";_(n.extendData)&&(q(n.extendData)?t=n.extendData(n):t=n.extendData??"");let r=e[0].x,i=e[0].y-6,o=i-50,a=o-5;return [{type:"line",attrs:{coordinates:[{x:r,y:i},{x:r,y:o}]},ignoreEvent:true},{type:"polygon",attrs:{coordinates:[{x:r,y:o},{x:r-4,y:a},{x:r+4,y:a}]},ignoreEvent:true},{type:"text",attrs:{x:r,y:a,text:t,align:"center",baseline:"bottom"},ignoreEvent:true}]}},Oo=As;var Ps={name:"simpleTag",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:({bounding:n,coordinates:e})=>({type:"line",attrs:{coordinates:[{x:0,y:e[0].y},{x:n.width,y:e[0].y}]},ignoreEvent:true}),createYAxisFigures:({chart:n,overlay:e,coordinates:t,bounding:r,yAxis:i})=>{let o=i?.isFromZero()??false,a="left",s=0;o?(a="left",s=0):(a="right",s=r.width);let l="";return _(e.extendData)&&(q(e.extendData)?l=e.extendData(e):l=e.extendData??""),!_(l)&&w(e.points[0].value)&&(l=J(e.points[0].value,n.getSymbol()?.pricePrecision??j.PRICE)),{type:"text",attrs:{x:s,y:t[0].y,text:l,align:a,baseline:"middle"}}}},Vo=Ps;var xr={},ws=[To,So,Ao,Po,Eo,Io,Do,Ro,Mo,ko,Fo,Lo,Bo,Oo,Vo],No=false;function Es(){No||(ws.forEach(n=>{xr[n.name]=ct.extend(n);}),No=true);}function Is(n){xr[n.name]=ct.extend(n);}function Wo(n){return xr[n]??null}function Ds(){return Object.keys(xr)}var Rs={grid:{horizontal:{color:"#EDEDED"},vertical:{color:"#EDEDED"}},candle:{priceMark:{high:{color:"#76808F"},low:{color:"#76808F"}},tooltip:{rect:{color:"#FEFEFE",borderColor:"#F2F3F5"},title:{color:"#76808F"},legend:{color:"#76808F"}}},indicator:{tooltip:{title:{color:"#76808F"},legend:{color:"#76808F"}}},xAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},yAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},separator:{color:"#DDDDDD"},crosshair:{horizontal:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}},vertical:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}}}},Yo=Rs;var Ms={grid:{horizontal:{color:"#292929"},vertical:{color:"#292929"}},candle:{priceMark:{high:{color:"#C9D1D9"},low:{color:"#C9D1D9"}},tooltip:{rect:{color:"rgba(10, 10, 10, .6)",borderColor:"rgba(10, 10, 10, .6)"},title:{color:"#929AA5"},legend:{color:"#929AA5"}}},indicator:{tooltip:{title:{color:"#929AA5"},legend:{color:"#929AA5"}}},xAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},yAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},separator:{color:"#333333"},crosshair:{horizontal:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}},vertical:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}}}},zo=Ms;var Ho={light:Yo,dark:zo};function ks(n,e){Ho[n]=e;}function Go(n){return Ho[n]??null}function we(n){return n==="transparent"||n==="none"||/^[rR][gG][Bb][Aa]\(([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,){3}[\s]*0[\s]*\)$/.test(n)||/^[hH][Ss][Ll][Aa]\(([\s]*(360|3[0-5][0-9]|[012]?[0-9][0-9]?)[\s]*,)([\s]*((100|[0-9][0-9]?)%|0)[\s]*,){2}([\s]*0[\s]*)\)$/.test(n)}function Ee(n,e){let t=n.replace(/^#/,""),r=parseInt(t,16),i=r>>16&255,o=r>>8&255,a=r&255;return `rgba(${i}, ${o}, ${a}, ${e??1})`}function Xr(n,e){let t=[];t=t.concat(e);for(let r of t){let{x:i,y:o,r:a}=r,s=n.x-i,l=n.y-o;if(!(s*s+l*l>a*a))return true}return false}function Fs(n,e,t){let r=[];r=r.concat(e);let{style:i="fill",color:o="currentColor",borderSize:a=1,borderColor:s="currentColor",borderStyle:l="solid",borderDashedValue:c=[2,2]}=t,u=(i==="fill"||t.style==="stroke_fill")&&(!L(o)||!we(o));u&&(n.fillStyle=o,r.forEach(({x:d,y:h,r:m})=>{n.beginPath(),n.arc(d,h,m,0,Math.PI*2),n.closePath(),n.fill();})),(i==="stroke"||t.style==="stroke_fill")&&a>0&&!we(s)&&(n.strokeStyle=s,n.lineWidth=a,l==="dashed"?n.setLineDash(c):n.setLineDash([]),r.forEach(({x:d,y:h,r:m})=>{(!u||m>a)&&(n.beginPath(),n.arc(d,h,m,0,Math.PI*2),n.closePath(),n.stroke());}));}var Ls={name:"circle",checkEventOn:Xr,draw:(n,e,t)=>{Fs(n,e,t);}},Xo=Ls;function Ur(n,e){let t=[];t=t.concat(e);for(let r of t){let i=false,{coordinates:o}=r;for(let a=0,s=o.length-1;a<o.length;s=a++)o[a].y>n.y!=o[s].y>n.y&&n.x<(o[s].x-o[a].x)*(n.y-o[a].y)/(o[s].y-o[a].y)+o[a].x&&(i=!i);if(i)return true}return false}function Bs(n,e,t){let r=[];r=r.concat(e);let{style:i="fill",color:o="currentColor",borderSize:a=1,borderColor:s="currentColor",borderStyle:l="solid",borderDashedValue:c=[2,2]}=t;(i==="fill"||t.style==="stroke_fill")&&(!L(o)||!we(o))&&(n.fillStyle=o,r.forEach(({coordinates:u})=>{n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let d=1;d<u.length;d++)n.lineTo(u[d].x,u[d].y);n.closePath(),n.fill();})),(i==="stroke"||t.style==="stroke_fill")&&a>0&&!we(s)&&(n.strokeStyle=s,n.lineWidth=a,l==="dashed"?n.setLineDash(c):n.setLineDash([]),r.forEach(({coordinates:u})=>{n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let d=1;d<u.length;d++)n.lineTo(u[d].x,u[d].y);n.closePath(),n.stroke();}));}var Os={name:"polygon",checkEventOn:Ur,draw:(n,e,t)=>{Bs(n,e,t);}},Uo=Os;function Tt(n,e){let t=[];t=t.concat(e);for(let r of t){let i=r.x,o=r.width;o<te*2&&(i-=te,o=te*2);let a=r.y,s=r.height;if(s<te*2&&(a-=te,s=te*2),n.x>=i&&n.x<=i+o&&n.y>=a&&n.y<=a+s)return true}return false}function We(n,e,t){let r=[];r=r.concat(e);let{style:i="fill",color:o="transparent",borderSize:a=1,borderColor:s="transparent",borderStyle:l="solid",borderRadius:c=0,borderDashedValue:u=[2,2]}=t,d=n.roundRect??n.rect,h=(i==="fill"||t.style==="stroke_fill")&&(!L(o)||!we(o));if(h&&(n.fillStyle=o,r.forEach(({x:m,y:p,width:g,height:f})=>{n.beginPath(),d.call(n,m,p,g,f,c),n.closePath(),n.fill();})),(i==="stroke"||t.style==="stroke_fill")&&a>0&&!we(s)){n.strokeStyle=s,n.fillStyle=s,n.lineWidth=a,l==="dashed"?n.setLineDash(u):n.setLineDash([]);let m=a%2===1?.5:0,p=Math.round(m*2);r.forEach(({x:g,y:f,width:y,height:v})=>{y>a*2&&v>a*2?(n.beginPath(),d.call(n,g+m,f+m,y-p,v-p,c),n.closePath(),n.stroke()):h||n.fillRect(g,f,y,v);});}}var Vs={name:"rect",checkEventOn:Tt,draw:(n,e,t)=>{We(n,e,t);}},$o=Vs;var St=null;function X(n){return n.ownerDocument.defaultView?.devicePixelRatio??1}var qo=new Map;function se(n,e,t){let r=`${n??12}:${e??"normal"}:${t??"Helvetica Neue"}`,i=qo.get(r);return i===void 0&&(i=`${e??"normal"} ${n??12}px ${t??"Helvetica Neue"}`,qo.set(r,i)),i}function ie(n,e,t,r){if(!_(St)){let i=document.createElement("canvas"),o=X(i);St=i.getContext("2d"),St.scale(o,o);}return St.font=se(e,t,r),Math.round(St.measureText(n).width)}var jo=new Map;function Ie(n,e){let t=`${n.font}\0${e}`,r=jo.get(t);return r===void 0&&(r=n.measureText(e).width,jo.set(t,r)),r}function ht(n,e){let{size:t=12,paddingLeft:r=0,paddingTop:i=0,paddingRight:o=0,paddingBottom:a=0,weight:s="normal",family:l}=e,{x:c,y:u,text:d,align:h="left",baseline:m="top",width:p,height:g}=n,f=p??r+ie(d,t,s,l)+o,y=g??i+t+a,v=0;switch(h){case "left":case "start":{v=c;break}case "right":case "end":{v=c-f;break}default:{v=c-f/2;break}}let b=0;switch(m){case "top":case "hanging":{b=u;break}case "bottom":case "ideographic":case "alphabetic":{b=u-y;break}default:{b=u-y/2;break}}return {x:v,y:b,width:f,height:y}}function $r(n,e,t){let r=[];r=r.concat(e);for(let i of r){let{x:o,y:a,width:s,height:l}=ht(i,t);if(n.x>=o&&n.x<=o+s&&n.y>=a&&n.y<=a+l)return true}return false}function Ns(n,e,t){let r=[];r=r.concat(e);let{color:i="currentColor",size:o=12,family:a,weight:s,paddingLeft:l=0,paddingTop:c=0,paddingRight:u=0}=t,d=r.map(p=>ht(p,t));We(n,d,{...t,color:t.backgroundColor}),n.textAlign="left",n.textBaseline="top",n.font=se(o,s,a),n.fillStyle=i;let h=Math.max(X(n.canvas),1),m=p=>Math.round(p*h)/h;r.forEach((p,g)=>{let f=d[g],y=m(f.x+l),v=m(f.y+c),b=Math.max(0,m(f.width-l-u));n.fillText(p.text,y,v,b);});}var Ws={name:"text",checkEventOn:$r,draw:(n,e,t)=>{Ns(n,e,t);}},Zo=Ws;function Qo(n,e){let t=n.x-e.x,r=n.y-e.y;return Math.sqrt(t*t+r*r)}function qr(n,e){let t=[];t=t.concat(e);for(let r of t)if(Math.abs(Qo(n,r)-r.r)<te){let{r:i,startAngle:o,endAngle:a}=r,s=i*Math.cos(o)+r.x,l=i*Math.sin(o)+r.y,c=i*Math.cos(a)+r.x,u=i*Math.sin(a)+r.y;if(n.x<=Math.max(s,c)+te&&n.x>=Math.min(s,c)-te&&n.y<=Math.max(l,u)+te&&n.y>=Math.min(l,u)-te)return true}return false}function Ys(n,e,t){let r=[];r=r.concat(e);let{style:i="solid",size:o=1,color:a="currentColor",dashedValue:s=[2,2]}=t;n.lineWidth=o,n.strokeStyle=a,i==="dashed"?n.setLineDash(s):n.setLineDash([]),r.forEach(({x:l,y:c,r:u,startAngle:d,endAngle:h})=>{n.beginPath(),n.arc(l,c,u,d,h),n.stroke(),n.closePath();});}var zs={name:"arc",checkEventOn:qr,draw:(n,e,t)=>{Ys(n,e,t);}},Ko=zs;function Jo(n,e,t,r,i,o,a){let[s,l,c,u,d,h,m]=r,p=a?e+h:h+i,g=a?t+m:m+o;Hs(e,t,s,l,c,u,d,p,g).forEach(y=>{n.bezierCurveTo(y[0],y[1],y[2],y[3],y[4],y[5]);});}function Hs(n,e,t,r,i,o,a,s,l){let{cx:c,cy:u,startAngle:d,deltaAngle:h}=Gs(n,e,t,r,i,o,a,s,l),m=[],p=Math.ceil(Math.abs(h)/(Math.PI/2));for(let g=0;g<p;g++){let f=d+g*h/p,y=d+(g+1)*h/p,v=Xs(c,u,t,r,i,f,y);m.push(v);}return m}function Gs(n,e,t,r,i,o,a,s,l){let c=i*Math.PI/180,u=(n-s)/2,d=(e-l)/2,h=Math.cos(c)*u+Math.sin(c)*d,m=-Math.sin(c)*u+Math.cos(c)*d,p=h**2/t**2+m**2/r**2;p>1&&(t*=Math.sqrt(p),r*=Math.sqrt(p));let g=o===a?-1:1,f=t**2*r**2-t**2*m**2-r**2*h**2,y=t**2*m**2+r**2*h**2,v=g*Math.sqrt(Math.abs(f/y))*(t*m/r),b=g*Math.sqrt(Math.abs(f/y))*(-r*h/t),S=Math.cos(c)*v-Math.sin(c)*b+(n+s)/2,x=Math.sin(c)*v+Math.cos(c)*b+(e+l)/2,C=Math.atan2((m-b)/r,(h-v)/t),T=Math.atan2((-m-b)/r,(-h-v)/t)-C;return T<0&&a===1?T+=2*Math.PI:T>0&&a===0&&(T-=2*Math.PI),{cx:S,cy:x,startAngle:C,deltaAngle:T}}function Xs(n,e,t,r,i,o,a){let s=Math.sin(a-o)*(Math.sqrt(4+3*Math.tan((a-o)/2)**2)-1)/3,l=Math.cos(i),c=Math.sin(i),u=n+t*Math.cos(o)*l-r*Math.sin(o)*c,d=e+t*Math.cos(o)*c+r*Math.sin(o)*l,h=n+t*Math.cos(a)*l-r*Math.sin(a)*c,m=e+t*Math.cos(a)*c+r*Math.sin(a)*l,p=u+s*(-t*Math.sin(o)*l-r*Math.cos(o)*c),g=d+s*(-t*Math.sin(o)*c+r*Math.cos(o)*l),f=h-s*(-t*Math.sin(a)*l-r*Math.cos(a)*c),y=m-s*(-t*Math.sin(a)*c+r*Math.cos(a)*l);return [p,g,f,y,h,m]}function Us(n,e,t){let r=[];r=r.concat(e);let{lineWidth:i=1,color:o="currentColor"}=t;n.lineWidth=i,n.strokeStyle=o,n.setLineDash([]),r.forEach(({x:a,y:s,path:l})=>{let c=l.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi);if(_(c)){let u=a,d=s;n.beginPath(),c.forEach(h=>{let m=0,p=0,g=0,f=0,y=h[0],v=h.slice(1).trim().split(/[\s,]+/).map(Number);switch(y){case "M":m=v[0]+u,p=v[1]+d,n.moveTo(m,p),g=m,f=p;break;case "m":m+=v[0],p+=v[1],n.moveTo(m,p),g=m,f=p;break;case "L":m=v[0]+u,p=v[1]+d,n.lineTo(m,p);break;case "l":m+=v[0],p+=v[1],n.lineTo(m,p);break;case "H":m=v[0]+u,n.lineTo(m,p);break;case "h":m+=v[0],n.lineTo(m,p);break;case "V":p=v[0]+d,n.lineTo(m,p);break;case "v":p+=v[0],n.lineTo(m,p);break;case "C":n.bezierCurveTo(v[0]+u,v[1]+d,v[2]+u,v[3]+d,v[4]+u,v[5]+d),m=v[4]+u,p=v[5]+d;break;case "c":n.bezierCurveTo(m+v[0],p+v[1],m+v[2],p+v[3],m+v[4],p+v[5]),m+=v[4],p+=v[5];break;case "S":n.bezierCurveTo(m,p,v[0]+u,v[1]+d,v[2]+u,v[3]+d),m=v[2]+u,p=v[3]+d;break;case "s":n.bezierCurveTo(m,p,m+v[0],p+v[1],m+v[2],p+v[3]),m+=v[2],p+=v[3];break;case "Q":n.quadraticCurveTo(v[0]+u,v[1]+d,v[2]+u,v[3]+d),m=v[2]+u,p=v[3]+d;break;case "q":n.quadraticCurveTo(m+v[0],p+v[1],m+v[2],p+v[3]),m+=v[2],p+=v[3];break;case "T":n.quadraticCurveTo(m,p,v[0]+u,v[1]+d),m=v[0]+u,p=v[1]+d;break;case "t":n.quadraticCurveTo(m,p,m+v[0],p+v[1]),m+=v[0],p+=v[1];break;case "A":Jo(n,m,p,v,u,d,false),m=v[5]+u,p=v[6]+d;break;case "a":Jo(n,m,p,v,u,d,true),m+=v[5],p+=v[6];break;case "Z":case "z":n.closePath(),m=g,p=f;break;}}),t.style==="fill"?n.fill():n.stroke();}});}var $s={name:"path",checkEventOn:Tt,draw:(n,e,t)=>{Us(n,e,t);}},en=$s;var Cr={},qs=[Xo,wo,Uo,$o,Zo,Ko,en];qs.forEach(n=>{Cr[n.name]=ut.extend(n);});function js(){return Object.keys(Cr)}function Zs(n){Cr[n.name]=ut.extend(n);}function tn(n){return Cr[n]??null}var Qs={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"\u6210\u4EA4\u989D\uFF1A",change:"\u6DA8\u5E45\uFF1A",second:"\u79D2",minute:"",hour:"\u5C0F\u65F6",day:"\u5929",week:"\u5468",month:"\u6708",year:"\u5E74"},rn=Qs;var Ks={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"\u6210\u4EA4\u984D\uFF1A",change:"\u6F32\u5E45\uFF1A",second:"\u79D2",minute:"\u5206",hour:"\u5C0F\u6642",day:"\u5929",week:"\u9031",month:"\u6708",year:"\u5E74"},on=Ks;var Js={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Turnover: ",change:"Change: ",second:"S",minute:"",hour:"H",day:"D",week:"W",month:"M",year:"Y"},nn=Js;var el={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"\u58F2\u8CB7\u4EE3\u91D1\uFF1A",change:"\u5909\u52D5\uFF1A",second:"\u79D2",minute:"\u5206",hour:"\u6642",day:"\u65E5",week:"\u9031",month:"\u6708",year:"\u5E74"},an=el;var tl={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"\u0E21\u0E39\u0E25\u0E04\u0E48\u0E32: ",change:"\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07: ",second:"\u0E27\u0E34",minute:"\u0E19",hour:"\u0E0A\u0E21",day:"\u0E27",week:"\u0E2A\u0E31\u0E1B\u0E14\u0E32\u0E2B\u0E4C",month:"\u0E40\u0E14\u0E37\u0E2D\u0E19",year:"\u0E1B\u0E35"},sn=tl;var rl={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"\uAC70\uB798\uB300\uAE08: ",change:"\uBCC0\uB3D9: ",second:"\uCD08",minute:"\uBD84",hour:"\uC2DC",day:"\uC77C",week:"\uC8FC",month:"\uC6D4",year:"\uB144"},ln=rl;var il={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Chiffre d'aff. : ",change:"Variation : ",second:"s",minute:"min",hour:"h",day:"j",week:"sem",month:"m",year:"a"},cn=il;var ol={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Umsatz: ",change:"\xC4nderung: ",second:"S",minute:"Min",hour:"H",day:"T",week:"W",month:"Mo",year:"J"},un=ol;var nl={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Faturamento: ",change:"Varia\xE7\xE3o: ",second:"S",minute:"min",hour:"H",day:"D",week:"S",month:"M",year:"A"},dn=nl;var al={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Facturaci\xF3n: ",change:"Cambio: ",second:"S",minute:"min",hour:"H",day:"D",week:"S",month:"M",year:"A"},hn=al;var sl={time:"",open:"O ",high:"H ",low:"L ",close:"C ",volume:"Vol ",turnover:"Nilai: ",change:"Perubahan: ",second:"dtk",minute:"mnt",hour:"jam",day:"hr",week:"mg",month:"bln",year:"thn"},mn=sl;var Tr={"zh-CN":rn,"zh-TW":on,"en-US":nn,"ja-JP":an,"th-TH":sn,"ko-KR":ln,"fr-FR":cn,"de-DE":un,"pt-PT":dn,"es-ES":hn,"id-ID":mn};function ll(n,e){Tr[n]={...Tr[n],...e};}function cl(){return Object.keys(Tr)}function jr(n,e){return Tr[e][n]??n}var mt=-1;function xe(n){return q(window.requestAnimationFrame)?window.requestAnimationFrame(n):window.setTimeout(n,20)}function Sr(n){q(window.cancelAnimationFrame)?window.cancelAnimationFrame(n):window.clearTimeout(n);}function pn(){return {from:0,to:0,range:0,realFrom:0,realTo:0,realRange:0,displayFrom:0,displayTo:0,displayRange:0}}var Ye=class{name;scrollZoomEnabled=true;createTicks;_parent;_range=pn();_prevRange=pn();_ticks=[];_autoCalcTickFlag=true;constructor(e){this._parent=e;}getParent(){return this._parent}buildTicks(e){return this._autoCalcTickFlag&&(this._range=this.createRangeImp()),this._prevRange.from!==this._range.from||this._prevRange.to!==this._range.to||e?(this._prevRange=this._range,this._ticks=this.createTicksImp(),true):false}getTicks(){return this._ticks}setRange(e){this._autoCalcTickFlag=false,this._range=e;}getRange(){return this._range}setAutoCalcTickFlag(e){this._autoCalcTickFlag=e;}getAutoCalcTickFlag(){return this._autoCalcTickFlag}};var B={CANDLE:"candle_pane",INDICATOR:"indicator_pane_",X_AXIS:"x_axis_pane"};var Ar=8,he=class n extends Ye{reverse=false;inside=false;position="right";gap={top:.2,bottom:.1};_animRealFrom=0;_animRealTo=0;_animVelocityFrom=0;_animVelocityTo=0;_animating=false;_prevRealFrom=null;_prevRealTo=null;_lastFrameTime=0;scaleSmoothTime=.56;scaleDeadbandPx=0;scaleDeadbandLeak=.28;_lastTickBuildHeight=-1;createRange=e=>e.defaultRange;minSpan=e=>Ae(-e);valueToRealValue=e=>e;realValueToDisplayValue=e=>e;displayValueToRealValue=e=>e;realValueToValue=e=>e;displayValueToText=(e,t)=>J(e,t);constructor(e,t){super(e),this.override(t);}override(e){let{name:t,gap:r,...i}=e;L(this.name)||(this.name=t),G(this.gap,r),G(this,i);}createRangeImp(){let e=this.getParent(),t=e.getChart(),r=t.getChartStore(),i=e.getId(),o=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER,s=false,l=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,d=r.getIndicatorsByPaneId(i);d.forEach(N=>{s||=N.shouldOhlc,u=Math.min(u,N.precision),w(N.minValue)&&(l=Math.min(l,N.minValue)),w(N.maxValue)&&(c=Math.max(c,N.maxValue));});let h=4,m=this.isInCandle();if(m){let N=r.getSymbol()?.pricePrecision??j.PRICE;u!==Number.MAX_SAFE_INTEGER?h=Math.min(u,N):h=N;}else u!==Number.MAX_SAFE_INTEGER&&(h=u);let p=r.getVisibleRangeDataList(),g=t.getStyles().candle,f=g.type==="area",y=g.area.value,v=m&&!f||!m&&s;p.forEach(N=>{let O=N.dataIndex,ee=N.data.current;if(_(ee)&&(v&&(o=Math.min(o,ee.low),a=Math.max(a,ee.high)),m&&f)){let U=ee[y];w(U)&&(o=Math.min(o,U),a=Math.max(a,U));}d.forEach(({result:U,figures:$})=>{let z=U[O]??{};$.forEach(Z=>{let le=z[Z.key];w(le)&&(o=Math.min(o,le),a=Math.max(a,le));});});}),o!==Number.MAX_SAFE_INTEGER&&a!==Number.MIN_SAFE_INTEGER?(o=Math.min(l,o),a=Math.max(c,a)):(o=0,a=10);let b=a-o,S={from:o,to:a,range:b,realFrom:o,realTo:a,realRange:b,displayFrom:o,displayTo:a,displayRange:b},x=this.createRange({chart:t,paneId:i,defaultRange:S}),C=x.realFrom,T=x.realTo,A=x.realRange,P=this.minSpan(h);if(C===T||A<P){let N=l===C,O=c===T,ee=Ar/2;C=N?C:O?C-Ar*P:C-ee*P,T=O?T:N?T+Ar*P:T+ee*P;}let I=this.getBounding().height,{top:R,bottom:D}=this.gap,E=R;E>=1&&(E=E/I);let M=D;if(M>=1&&(M=M/I),A=T-C,C=C-A*M,T=T+A*E,w(this._prevRealFrom)&&w(this._prevRealTo)){let N=Math.max(I,1),ee=Math.max(Math.abs(this._prevRealTo-this._prevRealFrom),Number.EPSILON)/N,U=Math.max(this.scaleDeadbandPx,0)*ee,$=Math.max(0,Math.min(this.scaleDeadbandLeak,1)),z=C-this._prevRealFrom,Z=T-this._prevRealTo;Math.abs(z)<U&&(C=this._prevRealFrom+z*$),Math.abs(Z)<U&&(T=this._prevRealTo+Z*$),A=T-C;}let F=this.realValueToValue(C,{range:x}),W=this.realValueToValue(T,{range:x}),H=this.realValueToDisplayValue(C,{range:x}),Y=this.realValueToDisplayValue(T,{range:x});return {from:F,to:W,range:W-F,realFrom:C,realTo:T,realRange:T-C,displayFrom:H,displayTo:Y,displayRange:Y-H}}isInCandle(){return this.getParent().getId()===B.CANDLE}isFromZero(){return this.position==="left"&&this.inside||this.position==="right"&&!this.inside}tickCoord(e){let t=this.getRange(),r=this.getParent().getYAxisWidget()?.getBounding().height??0,i=this.realValueToValue(this.displayValueToRealValue(+e.value,{range:t}),{range:t}),o=this.convertToPixel(i);return Number.isFinite(o)&&o>=-r&&o<=r*2?o:this._convertToPixelByRange(i,t,r)}createTicksImp(){let e=this.getRange(),{displayFrom:t,displayTo:r,displayRange:i}=e,o=[];if(i>=0){let b=io(i/Ar),S=oo(b),x=Yr(Math.ceil(t/b)*b,S),C=Yr(Math.floor(r/b)*b,S),T=0,A=x;if(b!==0)for(;A<=C;){let P=A.toFixed(S);o[T]={text:P,coord:0,value:P},++T,A+=b;}}let a=this.getParent(),s=a.getYAxisWidget()?.getBounding().height??0,l=a.getChart().getChartStore(),c=[],u=l.getIndicatorsByPaneId(a.getId()),d=l.getStyles(),h=0,m=false;this.isInCandle()?h=l.getSymbol()?.pricePrecision??j.PRICE:u.forEach(b=>{h=Math.max(h,b.precision),m||=b.shouldFormatBigNumber;});let p=l.getInnerFormatter(),g=l.getThousandsSeparator(),f=l.getDecimalFold(),y=d.yAxis.tickText.size,v=NaN;if(o.forEach(({value:b})=>{let S=this.displayValueToText(+b,h),x=this.realValueToValue(this.displayValueToRealValue(+b,{range:e}),{range:e}),C=this._convertToPixelByRange(x,e,s);m&&(S=p.formatBigNumber(b)),S=f.format(g.format(S));let T=w(v);C>y&&C<s-y&&(T&&Math.abs(v-C)>y*2||!T)&&(c.push({text:S,coord:C,value:b}),v=C);}),c.length===0&&o.length>0){let b=NaN;o.forEach(({value:S})=>{let x=this.displayValueToText(+S,h),C=this.realValueToValue(this.displayValueToRealValue(+S,{range:e}),{range:e}),T=this._convertToPixelByRange(C,e,s);if(!Number.isFinite(T)||T<0||T>s)return;m&&(x=p.formatBigNumber(S)),x=f.format(g.format(x)),(!w(b)||Math.abs(b-T)>y)&&(c.push({text:x,coord:T,value:S}),b=T);});}return q(this.createTicks)?this.createTicks({range:this.getRange(),bounding:this.getBounding(),defaultTicks:c}):c}getAutoSize(){let e=this.getParent(),r=e.getChart().getChartStore(),i=r.getStyles(),o=i.yAxis,a=o.size;if(a!=="auto")return a;let s=0;if(o.show&&(o.axisLine.show&&(s+=o.axisLine.size),o.tickLine.show&&(s+=o.tickLine.length),o.tickText.show)){let g=0;this.getTicks().forEach(f=>{g=Math.max(g,ie(f.text,o.tickText.size,o.tickText.weight,o.tickText.family));}),s+=o.tickText.marginStart+o.tickText.marginEnd+g;}let l=i.candle.priceMark,c=l.show&&l.last.show&&l.last.text.show,u=0,d=i.crosshair,h=d.show&&d.horizontal.show&&d.horizontal.text.show,m=0;if(c||h){let g=r.getSymbol()?.pricePrecision??j.PRICE,f=this.getRange().displayTo;if(c){let y=r.getDataList(),v=y[y.length-1];if(_(v)){let{paddingLeft:b,paddingRight:S,size:x,family:C,weight:T}=l.last.text;u=b+ie(J(v.close,g),x,T,C)+S;let A=r.getInnerFormatter().formatExtendText;l.last.extendTexts.forEach((P,I)=>{let R=A({type:"last_price",data:v,index:I});R.length>0&&P.show&&(u=Math.max(u,P.paddingLeft+ie(R,P.size,P.weight,P.family)+P.paddingRight));});}}if(h){let y=r.getIndicatorsByPaneId(e.getId()),v=0,b=false;y.forEach(C=>{v=Math.max(C.precision,v),b||=C.shouldFormatBigNumber;});let S=2;if(this.isInCandle()){let C=i.indicator.lastValueMark;C.show&&C.text.show?S=Math.max(v,g):S=g;}else S=v;let x=J(f,S);b&&(x=r.getInnerFormatter().formatBigNumber(x)),x=r.getDecimalFold().format(x),m+=d.horizontal.text.paddingLeft+d.horizontal.text.paddingRight+d.horizontal.text.borderSize*2+ie(x,d.horizontal.text.size,d.horizontal.text.weight,d.horizontal.text.family);}}let p=Math.max(s,u,m);return Math.ceil(p/4)*4}getBounding(){return this.getParent().getYAxisWidget().getBounding()}convertFromPixel(e){let t=this.getBounding().height,r=this.getRange(),{realFrom:i,realRange:o}=r,s=(this.reverse?e/t:1-e/t)*o+i;return this.realValueToValue(s,{range:r})}buildTicks(e){let t=this.getParent().getYAxisWidget()?.getBounding().height??0,r=t!==this._lastTickBuildHeight,i=this.getTicks().length===0,o=this.getAutoCalcTickFlag(),a=super.buildTicks(e||r||i);if(this._lastTickBuildHeight=t,o){let{realFrom:s,realTo:l}=this.getRange();this._prevRealFrom===null?(this._animRealFrom=s,this._animRealTo=l,this._animVelocityFrom=0,this._animVelocityTo=0):this._animating||(this._animating=true,this._lastFrameTime=performance.now(),this._driveSpring()),this._prevRealFrom=s,this._prevRealTo=l;}return a}_smoothDamp(e,t,r,i){let o=Number.isFinite(this.scaleSmoothTime)?this.scaleSmoothTime:.28,s=2/Math.max(.08,Math.min(o,1.2)),l=s*i,c=1/(1+l+.48*l*l+.235*l*l*l),u=e-t,d=(r+s*u)*i,h=(r-s*d)*c;return {value:t+(u+d)*c,velocity:h}}_driveSpring(){let e=this.getParent(),t=e.getChart(),r=e.getId(),i=()=>{if(!this._animating)return;let o=performance.now(),a=Math.min((o-this._lastFrameTime)/1e3,.12);this._lastFrameTime=o;let s=this._prevRealFrom??this._animRealFrom,l=this._prevRealTo??this._animRealTo,c=1/120;for(;a>0;){let p=Math.min(c,a),g=this._smoothDamp(this._animRealFrom,s,this._animVelocityFrom,p),f=this._smoothDamp(this._animRealTo,l,this._animVelocityTo,p);this._animRealFrom=g.value,this._animRealTo=f.value,this._animVelocityFrom=g.velocity,this._animVelocityTo=f.velocity,a-=p;}let u=Math.max(Math.abs(l-s),1),d=u*1e-5,h=u*1e-4;Math.abs(this._animRealFrom-s)<d&&Math.abs(this._animRealTo-l)<d&&Math.abs(this._animVelocityFrom)<h&&Math.abs(this._animVelocityTo)<h?(this._animRealFrom=s,this._animRealTo=l,this._animVelocityFrom=0,this._animVelocityTo=0,this._animating=false,t.updatePane(0,r)):(t.updatePane(0,r),xe(i));};xe(i);}getDisplayRange(){if(this._animating||this._prevRealFrom!==null)return {realFrom:this._animRealFrom,realTo:this._animRealTo};let e=this.getRange();return {realFrom:e.realFrom,realTo:e.realTo}}convertToPixel(e){let t=this.getRange(),r=this.valueToRealValue(e,{range:t}),i=this.getParent().getYAxisWidget()?.getBounding().height??0,{realFrom:o,realTo:a}=this.getDisplayRange(),s=a-o;if(s===0)return 0;let l=(r-o)/s;return this.reverse?l*i:(1-l)*i}convertToNicePixel(e){let t=this.getParent().getYAxisWidget()?.getBounding().height??0,r=this.convertToPixel(e);return Math.max(t*.05,Math.min(r,t*.98))}_convertToPixelByRange(e,t,r){let i=this.valueToRealValue(e,{range:t}),o=t.realRange;if(o===0)return 0;let a=(i-t.realFrom)/o;return this.reverse?a*r:(1-a)*r}static extend(e){class t extends n{constructor(i){super(i,e);}}return t}};var ul={name:"normal"},gn=ul;var dl={name:"percentage",minSpan:()=>Math.pow(10,-2),displayValueToText:n=>`${J(n,2)}%`,valueToRealValue:(n,{range:e})=>(n-e.from)/e.range*e.realRange+e.realFrom,realValueToValue:(n,{range:e})=>(n-e.realFrom)/e.realRange*e.range+e.from,createRange:({chart:n,defaultRange:e})=>{let t=n.getDataList(),r=n.getVisibleRange(),i=t[r.from];if(_(i)){let{from:o,to:a,range:s}=e,l=(e.from-i.close)/i.close*100,c=(e.to-i.close)/i.close*100,u=c-l;return {from:o,to:a,range:s,realFrom:l,realTo:c,realRange:u,displayFrom:l,displayTo:c,displayRange:u}}return e}},fn=dl;var hl={name:"logarithm",minSpan:n=>.05*Ae(-n),valueToRealValue:n=>n<0?-be(Math.abs(n)):be(n),realValueToDisplayValue:n=>n<0?-Ae(Math.abs(n)):Ae(n),displayValueToRealValue:n=>n<0?-be(Math.abs(n)):be(n),realValueToValue:n=>n<0?-Ae(Math.abs(n)):Ae(n),createRange:({defaultRange:n})=>{let{from:e,to:t,range:r}=n,i=e<0?-be(Math.abs(e)):be(e),o=t<0?-be(Math.abs(t)):be(t);return {from:e,to:t,range:r,realFrom:i,realTo:o,realRange:o-i,displayFrom:e,displayTo:t,displayRange:r}}},vn=hl;var Zr={normal:he.extend(gn),percentage:he.extend(fn),logarithm:he.extend(vn)};function ml(n){Zr[n.name]=he.extend(n);}function yn(n){return Zr[n]??Zr.normal}var Qr={second:"HH:mm:ss",minute:"HH:mm",hour:"MM-DD HH:mm",day:"YYYY-MM-DD",week:"YYYY-MM-DD",month:"YYYY-MM",year:"YYYY"},Pr={second:"DD/MM/YYYY, HH:mm:ss",minute:"DD/MM/YYYY, HH:mm",hour:"DD/MM/YYYY, HH:mm",day:"DD/MM/YYYY",week:"DD/MM/YYYY",month:"MM/YYYY",year:"YYYY"};var pl=[1e3,2e3,5e3,1e4,15e3,3e4,6e4,2*6e4,5*6e4,10*6e4,15*6e4,30*6e4,36e5,2*36e5,4*36e5,6*36e5,12*36e5,864e5];function gl(n,e){switch(n){case "second":return e*1e3;case "minute":return e*6e4;case "hour":return e*36e5;default:return e*864e5}}function fl(n){for(let e of pl)if(e>=n)return e;return 864e5}var pt=class n extends Ye{constructor(e,t){super(e),this.override(t);}override(e){let{name:t,scrollZoomEnabled:r,createTicks:i}=e;L(this.name)||(this.name=t),this.scrollZoomEnabled=r??this.scrollZoomEnabled,this.createTicks=i??this.createTicks;}createRangeImp(){let t=this.getParent().getChart().getChartStore().getVisibleRange(),{realFrom:r,realTo:i}=t,o=r,a=i,s=i-r+1;return {from:o,to:a,range:s,realFrom:o,realTo:a,realRange:s,displayFrom:o,displayTo:a,displayRange:s}}createTicksImp(){let{realFrom:e,realTo:t,from:r}=this.getRange(),i=this.getParent().getChart().getChartStore(),o=i.getInnerFormatter().formatDate,a=i.getPeriod(),s=[],l=i.getBarSpace().bar,c=i.getStyles().xAxis.tickText,u=Math.max(ie("YYYY-MM-DD HH:mm:ss",c.size,c.weight,c.family),this.getBounding().width/8),d=Math.ceil(u/l);d%2!==0&&(d+=1);let h=a?.timespan??"day",m=a?.multiplier??1;if(h==="second"||h==="minute"||h==="hour"){let p=gl(h,m),g=d*p,f=fl(g),y=-1/0;for(let v=Math.max(0,Math.floor(e));v<t;v++){if(v<r)continue;let b=i.dataIndexToTimestamp(v);if(!w(b)||b%f!==0)continue;let S=this.convertToPixel(v);S-y<u||(y=S,s.push({coord:S,value:b,text:o(b,Qr[h],"xAxis")}));}}else {let p=Math.max(0,Math.floor(e/d)*d);for(let g=p;g<t;g+=d)if(g>=r){let f=i.dataIndexToTimestamp(g);w(f)&&s.push({coord:this.convertToPixel(g),value:f,text:o(f,Qr[h],"xAxis")});}}return q(this.createTicks)?this.createTicks({range:this.getRange(),bounding:this.getBounding(),defaultTicks:s}):s}getAutoSize(){let e=this.getParent().getChart().getStyles(),t=e.xAxis,r=t.size;if(r!=="auto")return r;let i=e.crosshair,o=0;t.show&&(t.axisLine.show&&(o+=t.axisLine.size),t.tickLine.show&&(o+=t.tickLine.length),t.tickText.show&&(o+=t.tickText.marginStart+t.tickText.marginEnd+t.tickText.size));let a=0;return i.show&&i.vertical.show&&i.vertical.text.show&&(a+=i.vertical.text.paddingTop+i.vertical.text.paddingBottom+i.vertical.text.borderSize*2+i.vertical.text.size),Math.max(o,a)}getBounding(){return this.getParent().getMainWidget().getBounding()}convertTimestampFromPixel(e){let t=this.getParent().getChart().getChartStore(),r=t.coordinateToDataIndex(e);return t.dataIndexToTimestamp(r)}convertTimestampToPixel(e){let t=this.getParent().getChart().getChartStore(),r=t.timestampToDataIndex(e);return t.dataIndexToCoordinate(r)}convertFromPixel(e){return this.getParent().getChart().getChartStore().coordinateToDataIndex(e)}convertToPixel(e){return this.getParent().getChart().getChartStore().dataIndexToCoordinate(e)}static extend(e){class t extends n{constructor(i){super(i,e);}}return t}};var vl={name:"normal"},_n=vl;var Kr={normal:pt.extend(_n)};function yl(n){Kr[n.name]=pt.extend(n);}function bn(n){return Kr[n]??Kr.normal}var wr="k-line-chart-id",At=class{_entries=new Map;_containerEntries=new WeakMap;_nextId=1;getOrCreate(e,t){let r=this._containerEntries.get(e);if(r!==void 0)return {chart:r.chart,created:false};let i=e.getAttribute(wr);if(i!==null){let l=this._entries.get(i);return l?.container===e?(this._containerEntries.set(e,l),{chart:l.chart,created:false}):null}let o=`k_line_chart_${this._nextId++}`,a=t(o);a.id=o;let s={chart:a,container:e,id:o};this._entries.set(o,s),this._containerEntries.set(e,s);try{e.setAttribute(wr,o);}catch(l){throw this._entries.delete(o),this._containerEntries.delete(e),a.destroy(),l}return {chart:a,created:true}}dispose(e){let t=this._resolve(e);if(t===null)return false;try{t.chart.destroy();}finally{this._entries.get(t.id)===t&&this._entries.delete(t.id),this._containerEntries.get(t.container)===t&&this._containerEntries.delete(t.container),t.container.getAttribute(wr)===t.id&&t.container.removeAttribute(wr);}return true}_resolve(e){let t=this._containerEntries.get(e);if(t!==void 0)return t;let r=e.id;if(typeof r!="string")return null;let i=this._entries.get(r);return i?.chart===e?i:null}};var _l=typeof import.meta<"u"&&import.meta.env?.DEV===true;function Jr(n,e,t,r,i,o){if(_l){let a=r!==""?`Call api \`${r}\`${i!==""||o!==""?", ":"."}`:"",s=i!==""?`invalid parameter \`${i}\`${o!==""?", ":"."}`:"";console.log(n,e,t,a,s,o!==""?o:"");}}function me(n,e,t){Jr("%c\u{1F611} astroneum warning%c %s%s%s","padding:3px 4px;border-radius:2px;color:#ffffff;background-color:#FF9600","color:#FF9600",n,e,t??"");}function ei(n,e,t){Jr("%c\u{1F61F} astroneum error%c %s%s%s","padding:3px 4px;border-radius:2px;color:#ffffff;background-color:#F92855;","color:#F92855;",n,e,t??"");}function xn(){Jr("%c\u2764\uFE0F Welcome to Astroneum. Version is __VERSION__","border-radius:4px;border:dashed 1px #1677FF;line-height:70px;padding:0 20px;margin:16px 0;font-size:14px;color:#1677FF;","","","","");}function ze(n){let e={width:0,height:0,left:0,right:0,top:0,bottom:0};return _(n)&&G(e,n),e}var Le=class{_options={duration:500,iterationCount:1};_doFrameCallback;_finishCallback;_currentIterationCount=0;_running=false;_time=0;constructor(e){G(this._options,e);}_loop(){this._running=true;let e=()=>{if(this._running){let t=performance.now()-this._time;t<this._options.duration?(this._doFrameCallback?.(t),xe(e)):(this.stop(),this._currentIterationCount++,this._currentIterationCount<this._options.iterationCount&&this.start());}};xe(e);}doFrame(e){return this._doFrameCallback=e,this}onFinish(e){return this._finishCallback=e,this}setDuration(e){return this._options.duration=e,this}setIterationCount(e){return this._options.iterationCount=e,this}start(){this._running||(this._time=performance.now(),this._loop());}stop(){this._running&&(this._doFrameCallback?.(this._options.duration),this._running=false,this._finishCallback?.());}cancel(){this._running&&(this._running=false,this._finishCallback?.());}};var ti=1,Cn=new Date().getTime();function gt(n){let e=new Date().getTime();return e===Cn?++ti:ti=1,Cn=e,`${n??""}${e}_${ti}`}function oe(n,e){let t=document.createElement(n),r=e??{};for(let i in r)t.style[i]=r[i]??"";return t}var bl=["open","high","low","close"],xl=["volume","turnover"];function ri(n,e="bar"){if(n===null||typeof n!="object")throw new TypeError(`${e} must be an object`);if(typeof n.timestamp!="number"||!Number.isFinite(n.timestamp))throw new TypeError(`${e}.timestamp must be finite`);if(!Number.isSafeInteger(n.timestamp))throw new RangeError(`${e}.timestamp must be a safe UTC-millisecond integer`);for(let t of bl)if(typeof n[t]!="number"||!Number.isFinite(n[t]))throw new TypeError(`${e}.${t} must be finite`);if(n.high<n.low||n.high<n.open||n.high<n.close||n.low>n.open||n.low>n.close)throw new RangeError(`${e} has inconsistent OHLC values`);for(let t of xl){let r=n[t];if(r!==void 0&&(typeof r!="number"||!Number.isFinite(r)))throw new TypeError(`${e}.${t} must be finite when present`);if(typeof r=="number"&&r<0)throw new RangeError(`${e}.${t} must not be negative`)}return {...n}}function Tn(n){if(!Array.isArray(n))throw new TypeError("bars must be an array");let e=null;return n.map((t,r)=>{let i=ri(t,`bars[${r}]`);if(e!==null&&i.timestamp<=e)throw new RangeError("bars must be strictly ascending by timestamp");return e=i.timestamp,i})}function ii(){return {from:0,to:0,realFrom:0,realTo:0}}var Sn={data:0,indicator:1,overlay:2},Pt=class{_holdingTasks=null;_running=false;_callback;constructor(e){this._callback=e;}add(e,t="indicator"){let r={priority:t,tasks:e};if(!this._running)this._runBatch(r);else if(_(this._holdingTasks)){let i=Sn[t],o=false;for(let a=0;a<this._holdingTasks.length;a++)if(Sn[this._holdingTasks[a].priority]>i){this._holdingTasks.splice(a,0,r),o=true;break}o||this._holdingTasks.push(r);}else this._holdingTasks=[r];}async _runBatch(e){this._running=true;try{await Promise.all(Object.values(e.tasks));}finally{if(this._running=false,this._callback?.(),_(this._holdingTasks)&&this._holdingTasks.length>0){let t=this._holdingTasks.shift();this._runBatch(t);}else this._holdingTasks=null;}}clear(){this._holdingTasks=null;}};var wt=class{_callbacks=[];subscribe(e){this._callbacks.indexOf(e)<0&&this._callbacks.push(e);}unsubscribe(e){if(q(e)){let t=this._callbacks.indexOf(e);t>-1&&this._callbacks.splice(t,1);}else this._callbacks=[];}execute(e){this._callbacks.forEach(t=>{t(e);});}isEmpty(){return this._callbacks.length===0}};var k={RED:"#F92855",GREEN:"#2DC08E",WHITE:"#FFFFFF",GREY:"#76808F",BLUE:"#1677FF"};function Cl(){return {show:true,horizontal:{show:true,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]},vertical:{show:true,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]}}}function Tl(){let n={show:true,color:k.GREY,textOffset:5,textSize:12,textFamily:"Helvetica Neue",textWeight:"500"};return {type:"candle_solid",bar:{compareRule:"current_open",upColor:k.GREEN,downColor:k.RED,noChangeColor:k.GREY,upBorderColor:k.GREEN,downBorderColor:k.RED,noChangeBorderColor:k.GREY,upWickColor:k.GREEN,downWickColor:k.RED,noChangeWickColor:k.GREY},area:{lineSize:2,lineColor:k.BLUE,smooth:false,value:"close",backgroundColor:[{offset:0,color:Ee(k.BLUE,.01)},{offset:1,color:Ee(k.BLUE,.2)}],point:{show:true,color:k.BLUE,radius:4,rippleColor:Ee(k.BLUE,.3),rippleRadius:8,animation:true,animationDuration:1e3}},priceMark:{show:true,high:{...n},low:{...n},last:{show:true,compareRule:"current_open",upColor:k.GREEN,downColor:k.RED,noChangeColor:k.GREY,line:{show:true,style:"dashed",dashedValue:[4,4],size:1},text:{show:true,style:"fill",size:12,paddingLeft:4,paddingTop:4,paddingRight:4,paddingBottom:4,borderColor:"transparent",borderStyle:"solid",borderSize:0,borderDashedValue:[2,2],color:k.WHITE,family:"Helvetica Neue",weight:"normal",borderRadius:2},extendTexts:[]}},tooltip:{offsetLeft:4,offsetTop:6,offsetRight:4,offsetBottom:6,showRule:"always",showType:"standard",rect:{position:"fixed",paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,offsetLeft:4,offsetTop:4,offsetRight:4,offsetBottom:4,borderRadius:4,borderSize:1,borderColor:"#F2F3F5",color:"#FEFEFE"},title:{show:false,size:14,family:"Helvetica Neue",weight:"normal",color:k.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,template:"{ticker} \xB7 {period}"},legend:{size:12,family:"Helvetica Neue",weight:"normal",color:k.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,defaultValue:"n/a",template:[{title:"time",value:"{time}"},{title:"open",value:"{open}"},{title:"high",value:"{high}"},{title:"low",value:"{low}"},{title:"close",value:"{close}"},{title:"volume",value:"{volume}"}]},features:[]}}}function Sl(){let n=Ee(k.GREEN,.7),e=Ee(k.RED,.7);return {ohlc:{compareRule:"current_open",upColor:n,downColor:e,noChangeColor:k.GREY},bars:[{style:"fill",borderStyle:"solid",borderSize:1,borderDashedValue:[2,2],upColor:n,downColor:e,noChangeColor:k.GREY}],lines:["#FF9600","#935EBD",k.BLUE,"#E11D74","#01C5C4"].map(t=>({style:"solid",smooth:false,size:1,dashedValue:[2,2],color:t})),circles:[{style:"fill",borderStyle:"solid",borderSize:1,borderDashedValue:[2,2],upColor:n,downColor:e,noChangeColor:k.GREY}],lastValueMark:{show:false,text:{show:false,style:"fill",color:k.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderColor:"transparent",borderSize:0,borderDashedValue:[2,2],paddingLeft:4,paddingTop:4,paddingRight:4,paddingBottom:4,borderRadius:2}},tooltip:{offsetLeft:4,offsetTop:6,offsetRight:4,offsetBottom:6,showRule:"always",showType:"standard",title:{show:true,showName:true,showParams:true,size:12,family:"Helvetica Neue",weight:"normal",color:k.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4},legend:{size:12,family:"Helvetica Neue",weight:"normal",color:k.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,defaultValue:"n/a"},features:[]}}}function An(){return {show:true,size:"auto",axisLine:{show:true,color:"#DDDDDD",size:1},tickText:{show:true,color:k.GREY,size:12,family:"Helvetica Neue",weight:"normal",marginStart:4,marginEnd:6},tickLine:{show:true,size:1,length:3,color:"#DDDDDD"}}}function Al(){return {show:true,horizontal:{show:true,line:{show:true,style:"dashed",dashedValue:[4,2],size:1,color:k.GREY},text:{show:true,style:"fill",color:k.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderColor:k.GREY,borderRadius:2,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:k.GREY},features:[]},vertical:{show:true,line:{show:true,style:"dashed",dashedValue:[4,2],size:1,color:k.GREY},text:{show:true,style:"fill",color:k.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderColor:k.GREY,borderRadius:2,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:k.GREY}}}}function Pl(){let n=Ee(k.BLUE,.35),e=Ee(k.BLUE,.25);function t(){return {style:"fill",color:k.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderRadius:2,borderColor:k.BLUE,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:k.BLUE}}return {point:{color:k.BLUE,borderColor:n,borderSize:1,radius:5,activeColor:k.BLUE,activeBorderColor:n,activeBorderSize:3,activeRadius:5},line:{style:"solid",smooth:false,color:k.BLUE,size:1,dashedValue:[2,2]},rect:{style:"fill",color:e,borderColor:k.BLUE,borderSize:1,borderRadius:0,borderStyle:"solid",borderDashedValue:[2,2]},polygon:{style:"fill",color:e,borderColor:k.BLUE,borderSize:1,borderStyle:"solid",borderDashedValue:[2,2]},circle:{style:"fill",color:e,borderColor:k.BLUE,borderSize:1,borderStyle:"solid",borderDashedValue:[2,2]},arc:{style:"solid",color:k.BLUE,size:1,dashedValue:[2,2]},text:t()}}function wl(){return {size:1,color:"#DDDDDD",fill:true,activeBackgroundColor:Ee(k.BLUE,.08)}}function Pn(){return {grid:Cl(),candle:Tl(),indicator:Sl(),xAxis:An(),yAxis:An(),separator:wl(),crosshair:Al(),overlay:Pl()}}var wn={MIN:1,MAX:50},El=10,Il=80,Dl=.2,Er=10,Et=class n{_chart;_styles=Pn();_formatter={formatDate:({dateTimeFormat:e,timestamp:t,template:r})=>mr(e,t,r),formatBigNumber:pr,formatExtendText:e=>""};_innerFormatter={formatDate:(e,t,r)=>this._formatter.formatDate({dateTimeFormat:this._dateTimeFormat,timestamp:e,template:t,type:r}),formatBigNumber:e=>this._formatter.formatBigNumber(e),formatExtendText:e=>this._formatter.formatExtendText(e)};_locale="en-US";_thousandsSeparator={sign:",",format:e=>gr(e,this._thousandsSeparator.sign)};_decimalFold={threshold:3,format:e=>fr(e,this._decimalFold.threshold)};_symbol=null;_period=null;_dataList=[];_dataLoader=null;_dataLoaderGeneration=0;_loading=false;_dataLoadMore={forward:false,backward:false};_dateTimeFormat;_zoomEnabled=true;_zoomAnchor={main:"cursor",xAxis:"cursor"};_scrollEnabled=true;_totalBarSpace=0;_barSpace=El;_gapBarSpace;_offsetRightDistance=Il;_lastBarRightSideDiffBarCount;_startLastBarRightSideDiffBarCount=0;_scrollLimitRole="bar_count";_minVisibleBarCount={left:2,right:2};_maxOffsetDistance={left:50,right:50};_visibleRange=ii();_visibleRangeDataList=[];_visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}];_crosshair={};_actions=new Map;_indicators=new Map;_taskScheduler;_pendingCalcMap=new Map;_calcMicrotaskScheduled=false;_destroyed=false;static _IDLE_CALC_THRESHOLD=2e3;_fullLayoutNeeded=false;_didInitialForcedLayout=false;_overlays=new Map;_progressOverlayInfo=null;_lastPriceMarkExtendTextUpdateTimers=[];_pressedOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null};_hoverOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null};_clickOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null};constructor(e,t){this._chart=e,this._calcOptimalBarSpace(),this._lastBarRightSideDiffBarCount=this._offsetRightDistance/this._barSpace;let{styles:r,locale:i,timezone:o,formatter:a,thousandsSeparator:s,decimalFold:l,zoomAnchor:c}=t??{};_(r)&&this.setStyles(r),L(i)&&this.setLocale(i),this.setTimezone(o??""),_(a)&&this.setFormatter(a),_(s)&&this.setThousandsSeparator(s),_(l)&&this.setDecimalFold(l),_(c)&&this.setZoomAnchor(c),this._taskScheduler=new Pt(()=>{if(this._destroyed)return;if(!this._didInitialForcedLayout&&this._dataList.length>0){this._didInitialForcedLayout=true,this._chart.layout({measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});return}let u=this._fullLayoutNeeded;this._fullLayoutNeeded=false,u?this._chart.layout({measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true}):this._chart.layout({buildYAxisTick:true,cacheYAxisWidth:true,update:true});});}setStyles(e){let t=null;if(L(e)?t=Go(e):t=e,G(this._styles,t),ne(t?.candle?.tooltip?.legend?.template)&&(this._styles.candle.tooltip.legend.template=t.candle.tooltip.legend.template),_(t?.candle?.priceMark?.last?.extendTexts)){this._clearLastPriceMarkExtendTextUpdateTimer();let r=[];this._styles.candle.priceMark.last.extendTexts.forEach(i=>{let o=i.updateInterval;if(i.show&&o>0&&!r.includes(o)){r.push(o);let a=setInterval(()=>{this._chart.updatePane(0,B.CANDLE);},o);this._lastPriceMarkExtendTextUpdateTimers.push(a);}});}}getStyles(){return this._styles}setFormatter(e){G(this._formatter,e);}getFormatter(){return this._formatter}getInnerFormatter(){return this._innerFormatter}setLocale(e){this._locale=e;}getLocale(){return this._locale}setTimezone(e){if(!_(this._dateTimeFormat)||this.getTimezone()!==e){let t={hour12:false,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"};e.length>0&&(t.timeZone=e);let r=null;try{r=new Intl.DateTimeFormat("en",t);}catch{me("","","Timezone is error!!!");}r!==null&&(this._dateTimeFormat=r);}}getTimezone(){return this._dateTimeFormat.resolvedOptions().timeZone}getDateTimeFormat(){return this._dateTimeFormat}setThousandsSeparator(e){G(this._thousandsSeparator,e);}getThousandsSeparator(){return this._thousandsSeparator}setDecimalFold(e){G(this._decimalFold,e);}getDecimalFold(){return this._decimalFold}setSymbol(e){this.resetData(()=>{this._symbol={pricePrecision:j.PRICE,volumePrecision:j.VOLUME,...this._symbol,...e},this._synchronizeIndicatorSeriesPrecision();});}getSymbol(){return this._symbol}setPeriod(e){this.resetData(()=>{this._period=e;});}getPeriod(){return this._period}getDataList(){return this._dataList}replaceBars(e){let t=Tn(e);this._useDirectData(),this._addData(t,"init");}updateBar(e){let t=ri(e),r=this._dataList[this._dataList.length-1];if(r!==void 0&&t.timestamp<r.timestamp)throw new RangeError("bar timestamp must match or follow the current last bar");this._useDirectData(),r===void 0?this._addData([t],"init"):this._addData(t,"update");}_useDirectData(){this._processDataUnsubscribe(),this._dataLoaderGeneration++,this._dataLoader=null,this._loading=false;}getVisibleRangeDataList(){return this._visibleRangeDataList}getVisibleRangeHighLowPrice(){return this._visibleRangeHighLowPrice}_addData(e,t,r){let i=false,o=false,a=0;if(ne(e)){let s={backward:false,forward:false};switch(Se(r)?(s.backward=r,s.forward=r):(s.backward=r?.backward??false,s.forward=r?.forward??false),a=e.length,t){case "init":{this._clearData(),this._dataList=e,this._dataLoadMore.backward=s.backward,this._dataLoadMore.forward=s.forward,this.setOffsetRightDistance(this._offsetRightDistance),o=true;break}case "backward":{this._dataList=this._dataList.concat(e),this._dataLoadMore.backward=s.backward,this._lastBarRightSideDiffBarCount-=a,o=a>0;break}case "forward":{this._dataList=e.concat(this._dataList),this._dataLoadMore.forward=s.forward,o=a>0;break}}i=true;}else {let s=this._dataList.length,l=()=>({...e}),c=e.timestamp,u=Q(this._dataList[s-1],"timestamp",0);if(c>u){this._dataList.push(l());let d=this.getLastBarRightSideDiffBarCount();d<0&&this.setLastBarRightSideDiffBarCount(--d),a=1,i=true,o=true;}else c===u&&(this._dataList[s-1]=l(),i=true,o=true);}if(i&&o){let s=t==="update"&&a===0;this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true});let l=this.getIndicatorsByFilter({});l.length>0?(s||(this._fullLayoutNeeded=true),this._calcIndicator(l,s?"tail":"full")):s?this._chart.layout({buildYAxisTick:true,cacheYAxisWidth:true,update:true}):this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true,cacheYAxisWidth:t!=="init"});}}setDataLoader(e){this.resetData(()=>{this._dataLoader=e;});}_calcOptimalBarSpace(){let t=1-Dl*Math.atan(Math.max(4,this._barSpace)-4)/(Math.PI*.5),r=Math.min(Math.floor(this._barSpace*t),Math.floor(this._barSpace));r%2===0&&r+2>=this._barSpace&&--r,this._gapBarSpace=Math.max(1,r);}_adjustVisibleRange(){let e=this._dataList.length,t=this._totalBarSpace/this._barSpace,r=0,i=0;this._scrollLimitRole==="distance"?(r=(this._totalBarSpace-this._maxOffsetDistance.right)/this._barSpace,i=(this._totalBarSpace-this._maxOffsetDistance.left)/this._barSpace):(r=this._minVisibleBarCount.left,i=this._minVisibleBarCount.right),r=Math.max(0,r),i=Math.max(0,i);let o=t-Math.min(r,e);this._lastBarRightSideDiffBarCount>o&&(this._lastBarRightSideDiffBarCount=o);let a=-e+Math.min(i,e);this._lastBarRightSideDiffBarCount<a&&(this._lastBarRightSideDiffBarCount=a);let s=Math.round(this._lastBarRightSideDiffBarCount+e+.5),l=s;s>e&&(s=e);let c=Math.round(s-t)-1;c<0&&(c=0);let u=this._lastBarRightSideDiffBarCount>0?Math.round(e+this._lastBarRightSideDiffBarCount-t)-1:c;this._visibleRange={from:c,to:s,realFrom:u,realTo:l},this.executeAction("onVisibleRangeChange",this._visibleRange),this._visibleRangeDataList=[],this._visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}];for(let d=u;d<l;d++){let h=this._dataList[d],m=this.dataIndexToCoordinate(d);this._visibleRangeDataList.push({dataIndex:d,x:m,data:{prev:this._dataList[d-1]??h,current:h,next:this._dataList[d+1]??h}}),_(h)&&(this._visibleRangeHighLowPrice[0].price<h.high&&(this._visibleRangeHighLowPrice[0].price=h.high,this._visibleRangeHighLowPrice[0].x=m),this._visibleRangeHighLowPrice[1].price>h.low&&(this._visibleRangeHighLowPrice[1].price=h.low,this._visibleRangeHighLowPrice[1].x=m));}c===0?this._dataLoadMore.forward&&this._processDataLoad("forward"):s===e&&this._dataLoadMore.backward&&this._processDataLoad("backward");}_processDataLoad(e){if(!this._destroyed&&!this._loading&&_(this._dataLoader)&&_(this._symbol)&&_(this._period)){this._loading=true;let t=this._dataLoader,r=this._dataLoaderGeneration,i={type:e,symbol:this._symbol,period:this._period,timestamp:null,callback:(o,a)=>{this._destroyed||this._dataLoader!==t||this._dataLoaderGeneration!==r||(this._loading=false,this._addData(o,e,a),e==="init"&&t.subscribeBar?.({symbol:this._symbol,period:this._period,callback:s=>{this._destroyed||this._dataLoader!==t||this._dataLoaderGeneration!==r||this._addData(s,"update");}}));}};switch(e){case "backward":{i.timestamp=this._dataList[this._dataList.length-1]?.timestamp??null;break}case "forward":{i.timestamp=this._dataList[0]?.timestamp??null;break}}t.getBars(i);}}_processDataUnsubscribe(){_(this._dataLoader)&&_(this._symbol)&&_(this._period)&&this._dataLoader.unsubscribeBar?.({symbol:this._symbol,period:this._period});}resetData(e){this._processDataUnsubscribe(),this._dataLoaderGeneration++,e?.(),this._loading=false,this._processDataLoad("init");}getBarSpace(){return {bar:this._barSpace,halfBar:this._barSpace/2,gapBar:this._gapBarSpace,halfGapBar:Math.floor(this._gapBarSpace/2)}}setBarSpace(e,t){e<wn.MIN||e>wn.MAX||this._barSpace===e||(this._barSpace=e,this._calcOptimalBarSpace(),t?.(),this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true}),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true,cacheYAxisWidth:true}));}setViewportState(e,t){this._barSpace!==e&&(this._barSpace=e,this._calcOptimalBarSpace()),this._lastBarRightSideDiffBarCount=t,this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true}),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true,cacheYAxisWidth:true});}setTotalBarSpace(e){this._totalBarSpace!==e&&(this._totalBarSpace=e,this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true}));}setOffsetRightDistance(e,t){return this._offsetRightDistance=this._scrollLimitRole==="distance"?Math.min(this._maxOffsetDistance.right,e):e,this._lastBarRightSideDiffBarCount=this._offsetRightDistance/this._barSpace,(t??false)&&(this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true}),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true,cacheYAxisWidth:true})),this}getInitialOffsetRightDistance(){return this._offsetRightDistance}getOffsetRightDistance(){return Math.max(0,this._lastBarRightSideDiffBarCount*this._barSpace)}getLastBarRightSideDiffBarCount(){return this._lastBarRightSideDiffBarCount}setLastBarRightSideDiffBarCount(e){this._lastBarRightSideDiffBarCount=e;}setMaxOffsetLeftDistance(e){this._scrollLimitRole="distance",this._maxOffsetDistance.left=e;}setMaxOffsetRightDistance(e){this._scrollLimitRole="distance",this._maxOffsetDistance.right=e;}setLeftMinVisibleBarCount(e){this._scrollLimitRole="bar_count",this._minVisibleBarCount.left=e;}setRightMinVisibleBarCount(e){this._scrollLimitRole="bar_count",this._minVisibleBarCount.right=e;}getVisibleRange(){return this._visibleRange}startScroll(){this._startLastBarRightSideDiffBarCount=this._lastBarRightSideDiffBarCount;}scroll(e){if(!this._scrollEnabled)return;let t=e/this._barSpace,r=this._lastBarRightSideDiffBarCount*this._barSpace;this._lastBarRightSideDiffBarCount=this._startLastBarRightSideDiffBarCount-t,this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:true}),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true,cacheYAxisWidth:true});let i=Math.round(r-this._lastBarRightSideDiffBarCount*this._barSpace);i!==0&&this.executeAction("onScroll",{distance:i});}getDataByDataIndex(e){return this._dataList[e]??null}coordinateToFloatIndex(e){let t=this._dataList.length,r=(this._totalBarSpace-e)/this._barSpace,i=t+this._lastBarRightSideDiffBarCount-r;return Math.round(i*1e6)/1e6}dataIndexToTimestamp(e){let t=this._dataList.length;if(t===0)return null;let r=this.getDataByDataIndex(e);if(_(r))return r.timestamp;if(_(this._period)){let i=t-1,o=null,a=0;if(e>i?(o=this._dataList[i].timestamp,a=e-i):e<0&&(o=this._dataList[0].timestamp,a=e),w(o)){let{timespan:s,multiplier:l}=this._period;switch(s){case "second":return o+l*1e3*a;case "minute":return o+l*60*1e3*a;case "hour":return o+l*60*60*1e3*a;case "day":return o+l*24*60*60*1e3*a;case "week":return o+l*7*24*60*60*1e3*a;case "month":{let c=new Date(o),u=c.getDate();c.setDate(1),c.setMonth(c.getMonth()+l*a);let d=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();return c.setDate(Math.min(u,d)),c.getTime()}case "year":{let c=new Date(o);return c.setFullYear(c.getFullYear()+l*a),c.getTime()}}}}return null}timestampToDataIndex(e){let t=this._dataList.length;if(t===0)return 0;if(_(this._period)){let r=null,i=0,o=t-1,a=this._dataList[o].timestamp;e>a&&(r=a,i=o);let s=this._dataList[0].timestamp;if(e<s&&(r=s,i=0),w(r)){let{timespan:l,multiplier:c}=this._period;switch(l){case "second":return i+Math.floor((e-r)/(c*1e3));case "minute":return i+Math.floor((e-r)/(c*60*1e3));case "hour":return i+Math.floor((e-r)/(c*60*60*1e3));case "day":return i+Math.floor((e-r)/(c*24*60*60*1e3));case "week":return i+Math.floor((e-r)/(c*7*24*60*60*1e3));case "month":{let u=new Date(r),d=new Date(e),h=u.getFullYear(),m=d.getFullYear(),p=u.getMonth(),g=d.getMonth();return i+Math.floor(((m-h)*12+(g-p))/c)}case "year":{let u=new Date(r).getFullYear(),d=new Date(e).getFullYear();return i+Math.floor((d-u)/c)}}}}return xt(this._dataList,"timestamp",e)}dataIndexToCoordinate(e){let r=this._dataList.length+this._lastBarRightSideDiffBarCount-e;return Math.floor(this._totalBarSpace-(r-.5)*this._barSpace+.5)}coordinateToDataIndex(e){return Math.ceil(this.coordinateToFloatIndex(e))-1}zoom(e,t,r){if(!this._zoomEnabled)return;let i=t??{x:this._crosshair.x??this._totalBarSpace/2};r==="xAxis"?this._zoomAnchor.xAxis==="last_bar"&&(i.x=this.dataIndexToCoordinate(this._dataList.length-1)):this._zoomAnchor.main==="last_bar"&&(i.x=this.dataIndexToCoordinate(this._dataList.length-1));let o=i.x,a=this.coordinateToFloatIndex(o),s=this._barSpace,l=this._barSpace+e*(this._barSpace/Er);this.setBarSpace(l,()=>{this._lastBarRightSideDiffBarCount+=a-this.coordinateToFloatIndex(o);});let c=this._barSpace/s;c!==1&&this.executeAction("onZoom",{scale:c});}setZoomEnabled(e){this._zoomEnabled=e;}isZoomEnabled(){return this._zoomEnabled}setZoomAnchor(e){L(e)?(this._zoomAnchor.main=e,this._zoomAnchor.xAxis=e):(L(e.main)&&(this._zoomAnchor.main=e.main),L(e.xAxis)&&(this._zoomAnchor.xAxis=e.xAxis));}getZoomAnchor(){return {...this._zoomAnchor}}setScrollEnabled(e){this._scrollEnabled=e;}isScrollEnabled(){return this._scrollEnabled}setCrosshair(e,t){let{notInvalidate:r,notExecuteAction:i,forceInvalidate:o}=t??{},a=e??{},s=0,l=0;w(a.x)?(s=this.coordinateToDataIndex(a.x),s<0?l=0:s>this._dataList.length-1?l=this._dataList.length-1:l=s):(s=this._dataList.length-1,l=s);let c=this._dataList[l],u=this.dataIndexToCoordinate(s),d={x:this._crosshair.x,y:this._crosshair.y,paneId:this._crosshair.paneId};this._crosshair={...a,realX:u,candleData:c,realDataIndex:s,dataIndex:l,timestamp:this.dataIndexToTimestamp(s)??void 0},(d.x!==a.x||d.y!==a.y||d.paneId!==a.paneId||(o??false))&&(_(c)&&!(i??false)&&this.hasAction("onCrosshairChange")&&L(this._crosshair.paneId)&&this.executeAction("onCrosshairChange",e),(r??false)||this._chart.updatePane(1));}getCrosshair(){return this._crosshair}executeAction(e,t){this._actions.get(e)?.execute(t);}subscribeAction(e,t){this._actions.has(e)||this._actions.set(e,new wt),this._actions.get(e)?.subscribe(t);}unsubscribeAction(e,t){let r=this._actions.get(e);_(r)&&(r.unsubscribe(t),r.isEmpty()&&this._actions.delete(e));}hasAction(e){let t=this._actions.get(e);return _(t)&&!t.isEmpty()}_sortIndicators(e){L(e)?this._indicators.get(e)?.sort((t,r)=>t.zLevel-r.zLevel):this._indicators.forEach(t=>{t.sort((r,i)=>r.zLevel-i.zLevel);});}_calcIndicator(e,t="full"){if(this._destroyed)return;let r=[].concat(e);r.length!==0&&(r.forEach(i=>{(this._pendingCalcMap.get(i.id)===void 0||t==="full")&&this._pendingCalcMap.set(i.id,{ind:i,mode:t});}),!this._calcMicrotaskScheduled&&(this._calcMicrotaskScheduled=true,queueMicrotask(()=>{if(this._calcMicrotaskScheduled=false,this._destroyed||this._pendingCalcMap.size===0)return;let i={};this._pendingCalcMap.forEach((s,l)=>{i[l]=s.ind.calcImp(this._dataList,s.mode);}),this._pendingCalcMap.clear();let o=globalThis.scheduler,a=()=>{this._destroyed||this._taskScheduler.add(i);};o!==void 0?o.postTask(a,{priority:"background"}):this._dataList.length>=n._IDLE_CALC_THRESHOLD&&typeof requestIdleCallback=="function"?requestIdleCallback(a):this._dataList.length>=n._IDLE_CALC_THRESHOLD?setTimeout(a,0):a();})));}addIndicator(e,t,r){let{name:i}=e;if(this.getIndicatorsByFilter(e).length>0)return false;let a=this.getIndicatorsByPaneId(t),s=_r(i),l=new s;return this._synchronizeIndicatorSeriesPrecision(l),l.paneId=t,l.override(e),r||(this.removeIndicator({paneId:t}),a=[]),a.push(l),this._indicators.set(t,a),this._sortIndicators(t),this._calcIndicator(l),true}getIndicatorsByPaneId(e){return this._indicators.get(e)??[]}getIndicatorsByFilter(e){let{paneId:t,name:r,id:i}=e,o=s=>_(i)?s.id===i:!_(r)||s.name===r,a=[];return _(t)?a=a.concat(this.getIndicatorsByPaneId(t).filter(o)):this._indicators.forEach(s=>{a=a.concat(s.filter(o));}),a}removeIndicator(e){let t=false;return this.getIndicatorsByFilter(e).forEach(i=>{let o=this.getIndicatorsByPaneId(i.paneId),a=o.findIndex(s=>s.id===i.id);a>-1&&(o.splice(a,1),t=true),o.length===0&&this._indicators.delete(i.paneId);}),t}hasIndicators(e){return this._indicators.has(e)}_synchronizeIndicatorSeriesPrecision(e){if(_(this._symbol)){let{pricePrecision:t=j.PRICE,volumePrecision:r=j.VOLUME}=this._symbol,i=o=>{switch(o.series){case "price":{o.setSeriesPrecision(t);break}case "volume":{o.setSeriesPrecision(r);break}}};_(e)?i(e):this._indicators.forEach(o=>{o.forEach(a=>{i(a);});});}}overrideIndicator(e){let t=false,r=false;return this.getIndicatorsByFilter(e).forEach(o=>{o.override(e);let{calc:a,draw:s,sort:l}=o.shouldUpdateImp();l&&(r=true),a?this._calcIndicator(o):s&&(t=true);}),r&&this._sortIndicators(),t?(this._chart.layout({update:true}),true):false}getOverlaysByFilter(e){let{id:t,groupId:r,paneId:i,name:o}=e,a=c=>_(t)?c.id===t:_(r)?c.groupId===r&&(!_(o)||c.name===o):!_(o)||c.name===o,s=[];_(i)?s=s.concat(this.getOverlaysByPaneId(i).filter(a)):this._overlays.forEach(c=>{s=s.concat(c.filter(a));});let l=this._progressOverlayInfo?.overlay;return _(l)&&a(l)&&s.push(l),s}getOverlaysByPaneId(e){if(!L(e)){let t=[];return this._overlays.forEach(r=>{t=t.concat(r);}),t}return this._overlays.get(e)??[]}_sortOverlays(e){L(e)?this._overlays.get(e)?.sort((t,r)=>t.zLevel-r.zLevel):this._overlays.forEach(t=>{t.sort((r,i)=>r.zLevel-i.zLevel);});}addOverlays(e,t){let r=[],i=e.map((o,a)=>{if(_(o.id)){let l=null;for(let c of this._overlays){let d=c[1].find(h=>h.id===o.id);if(_(d)){l=d;break}}if(_(l))return o.id}let s=Wo(o.name);if(_(s)){let l=o.id??gt(Co),c=new s,u=o.paneId??B.CANDLE;o.id=l,o.groupId??=l;let d=this.getOverlaysByPaneId(u).length;return o.zLevel??=d,c.override(o),r.includes(u)||r.push(u),c.isDrawing()?this._progressOverlayInfo={paneId:u,overlay:c,appointPaneFlag:t[a]}:(this._overlays.has(u)||this._overlays.set(u,[]),this._overlays.get(u)?.push(c)),c.isStart()&&c.onDrawStart?.({overlay:c,chart:this._chart}),l}return null});return r.length>0&&(this._sortOverlays(),r.forEach(o=>{this._chart.updatePane(1,o);}),this._chart.updatePane(1,B.X_AXIS)),i}getProgressOverlayInfo(){return this._progressOverlayInfo}progressOverlayComplete(){if(this._progressOverlayInfo!==null){let{overlay:e,paneId:t}=this._progressOverlayInfo;e.isDrawing()||(this._overlays.has(t)||this._overlays.set(t,[]),this._overlays.get(t)?.push(e),this._sortOverlays(t),this._progressOverlayInfo=null);}}updateProgressOverlayInfo(e,t){this._progressOverlayInfo!==null&&(Se(t)&&t&&(this._progressOverlayInfo.appointPaneFlag=t),this._progressOverlayInfo.paneId=e,this._progressOverlayInfo.overlay.override({paneId:e}));}overrideOverlay(e){let t=false,r=[];return this.getOverlaysByFilter(e).forEach(o=>{o.override(e);let{sort:a,draw:s}=o.shouldUpdate();a&&(t=true),(a||s)&&(r.includes(o.paneId)||r.push(o.paneId));}),t&&this._sortOverlays(),r.length>0?(r.forEach(o=>{this._chart.updatePane(1,o);}),this._chart.updatePane(1,B.X_AXIS),true):false}removeOverlay(e){let t=[];return this.getOverlaysByFilter(e).forEach(i=>{let o=i.paneId,a=this.getOverlaysByPaneId(i.paneId);if(i.onRemoved?.({overlay:i,chart:this._chart}),t.includes(o)||t.push(o),i.isDrawing())this._progressOverlayInfo=null;else {let s=a.findIndex(l=>l.id===i.id);s>-1&&a.splice(s,1);}a.length===0&&this._overlays.delete(o);}),t.length>0?(t.forEach(i=>{this._chart.updatePane(1,i);}),this._chart.updatePane(1,B.X_AXIS),true):false}setPressedOverlayInfo(e){this._pressedOverlayInfo=e;}getPressedOverlayInfo(){return this._pressedOverlayInfo}setHoverOverlayInfo(e,t,r){let{overlay:i,figureType:o,figureIndex:a,figure:s}=this._hoverOverlayInfo,l=e.overlay;if((i?.id!==l?.id||o!==e.figureType||a!==e.figureIndex)&&(this._hoverOverlayInfo=e,i?.id!==l?.id)){let c=false,u=false;i!==null&&(i.override({zLevel:i.getPrevZLevel()}),u=true,r(i,s)&&(c=true)),l!==null&&(l.setPrevZLevel(l.zLevel),l.override({zLevel:Number.MAX_SAFE_INTEGER}),u=true,t(l,e.figure)&&(c=true)),u&&this._sortOverlays(),c||this._chart.updatePane(1);}}getHoverOverlayInfo(){return this._hoverOverlayInfo}setClickOverlayInfo(e,t,r){let{paneId:i,overlay:o,figureType:a,figure:s,figureIndex:l}=this._clickOverlayInfo,c=e.overlay;(o?.id!==c?.id||a!==e.figureType||l!==e.figureIndex)&&(this._clickOverlayInfo=e,o?.id!==c?.id&&(_(o)&&r(o,s),_(c)&&t(c,e.figure),this._chart.updatePane(1,e.paneId),i!==e.paneId&&this._chart.updatePane(1,i),this._chart.updatePane(1,B.X_AXIS)));}getClickOverlayInfo(){return this._clickOverlayInfo}isOverlayEmpty(){return this._overlays.size===0&&this._progressOverlayInfo===null}isOverlayDrawing(){return this._progressOverlayInfo?.overlay.isDrawing()??false}_clearLastPriceMarkExtendTextUpdateTimer(){this._lastPriceMarkExtendTextUpdateTimers.forEach(e=>{clearInterval(e);}),this._lastPriceMarkExtendTextUpdateTimers=[];}_clearData(){this._dataLoadMore.backward=false,this._dataLoadMore.forward=false,this._loading=false,this._dataList=[],this._visibleRangeDataList=[],this._visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}],this._visibleRange=ii(),this._crosshair={};}getChart(){return this._chart}destroy(){this._destroyed||(this._destroyed=true,this._processDataUnsubscribe(),this._dataLoader=null,this._pendingCalcMap.clear(),this._clearData(),this._clearLastPriceMarkExtendTextUpdateTimer(),this._taskScheduler.clear(),this._overlays.clear(),this._indicators.clear(),this._actions.clear());}};var V={MAIN:"main",X_AXIS:"xAxis",Y_AXIS:"yAxis",SEPARATOR:"separator"},He=7;async function Rl(){return await new Promise(n=>{let e=new ResizeObserver(t=>{n(t.every(r=>"devicePixelContentBoxSize"in r)),e.disconnect();});e.observe(document.body,{box:"device-pixel-content-box"});}).catch(()=>false)}var ft=class{_element;_resizeObserver;_mediaQueryList;_ctx;_listener;_supportedDevicePixelContentBox=false;_width=0;_height=0;_pixelWidth=0;_pixelHeight=0;_nextPixelWidth=0;_nextPixelHeight=0;_requestAnimationId=mt;_destroyed=false;_mediaQueryListener=()=>{let e=X(this._element);this._nextPixelWidth=Math.round(this._element.clientWidth*e),this._nextPixelHeight=Math.round(this._element.clientHeight*e),this._resetPixelRatio();};constructor(e,t){this._listener=t,this._element=oe("canvas",e),this._ctx=this._element.getContext("2d"),Rl().then(r=>{this._destroyed||(this._supportedDevicePixelContentBox=r,r?(this._resizeObserver=new ResizeObserver(i=>{let a=i.find(s=>s.target===this._element)?.devicePixelContentBoxSize[0];_(a)&&(this._nextPixelWidth=a.inlineSize,this._nextPixelHeight=a.blockSize,(this._pixelWidth!==this._nextPixelWidth||this._pixelHeight!==this._nextPixelHeight)&&this._resetPixelRatio());}),this._resizeObserver.observe(this._element,{box:"device-pixel-content-box"})):(this._mediaQueryList=window.matchMedia(`(resolution: ${X(this._element)}dppx)`),this._mediaQueryList.addListener(this._mediaQueryListener)));}).catch(r=>false);}_resetPixelRatio(){this._executeListener(()=>{let e=this._element.clientWidth,t=this._element.clientHeight;this._width=e,this._height=t,this._pixelWidth=this._nextPixelWidth,this._pixelHeight=this._nextPixelHeight,this._element.width=this._nextPixelWidth,this._element.height=this._nextPixelHeight;let r=this._nextPixelWidth/e,i=this._nextPixelHeight/t;this._ctx.scale(r,i);});}_executeListener(e){this._destroyed||this._requestAnimationId===mt&&(this._requestAnimationId=xe(()=>{this._destroyed||(this._ctx.clearRect(0,0,this._width,this._height),e?.(),this._listener(),this._requestAnimationId=mt);}));}update(e,t){if(this._width!==e||this._height!==t){if(this._element.style.width=`${e}px`,this._element.style.height=`${t}px`,!this._supportedDevicePixelContentBox){let r=X(this._element);this._nextPixelWidth=Math.round(e*r),this._nextPixelHeight=Math.round(t*r),this._resetPixelRatio();}}else this._executeListener();}getElement(){return this._element}getContext(){return this._ctx}destroy(){this._destroyed||(this._destroyed=true,this._requestAnimationId!==mt&&(cancelAnimationFrame(this._requestAnimationId),this._requestAnimationId=mt),_(this._resizeObserver)&&this._resizeObserver.disconnect(),_(this._mediaQueryList)&&this._mediaQueryList.removeListener(this._mediaQueryListener));}};var ve=class{_gl;_element;constructor(e){this._element=document.createElement("canvas"),e.appendChild(this._element);let t=this._element.getContext("webgl2",{antialias:false,premultipliedAlpha:false,preserveDrawingBuffer:true,powerPreference:"high-performance"});if(t===null)throw this._element.remove(),new Error("[astroneum] WebGL2 not supported \u2014 falling back to Canvas2D");this._gl=t;}get gl(){return this._gl}get element(){return this._element}resize(e,t,r){this._element.width=Math.round(e*r),this._element.height=Math.round(t*r),this._element.style.width=`${e}px`,this._element.style.height=`${t}px`,this._gl.viewport(0,0,this._element.width,this._element.height);}destroy(){this._gl.getExtension("WEBGL_lose_context")?.loseContext(),this._element.remove();}static isSupported(){return Ml}},Ml=(()=>{try{let e=document.createElement("canvas").getContext("webgl2");return e===null?!1:(e.getExtension("WEBGL_lose_context")?.loseContext(),!0)}catch{return false}})();var kl="0123456789.,+-eEkKMBT%$ /()[]ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:\u20AC\xA5\xA3\xA2";function Fl(){return Math.max(Math.ceil(typeof window<"u"?window.devicePixelRatio??2:2),2)}var Ir=class{fontSize;fontFamily;_texture=null;_glyphs=new Map;constructor(e,t){this.fontSize=e,this.fontFamily=t;}build(e){if(this._texture!==null)return;let t=Fl(),r=Array.from(new Set(kl)),i=this.fontSize*t,o=document.createElement("canvas"),a=o.getContext("2d");a.font=`${i}px ${this.fontFamily}`;let s=Math.ceil(i*1.5),l=r.map(f=>a.measureText(f).width),c=0;for(let f=0;f<l.length;f++)l[f]>c&&(c=l[f]);let u=Math.ceil(c+i*.2),d=Math.ceil(Math.sqrt(r.length)),h=Math.ceil(r.length/d),m=d*u,p=h*s;o.width=m,o.height=p,a.font=`${i}px ${this.fontFamily}`,a.textBaseline="top",a.fillStyle="white",r.forEach((f,y)=>{let v=y%d,b=Math.floor(y/d),S=v*u,x=b*s;a.fillText(f,S,x),this._glyphs.set(f,{u0:S/m,v0:x/p,u1:(S+u)/m,v1:(x+s)/p,advance:l[y]/t,cellW:u/t,cellH:s/t});});let g=a.getImageData(0,0,m,p);this._texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,m,p,0,e.RGBA,e.UNSIGNED_BYTE,g.data),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null);}getGlyph(e){return this._glyphs.get(e)??null}get texture(){return this._texture}destroy(e){this._texture!==null&&(e.deleteTexture(this._texture),this._texture=null);}};var Ll=`#version 300 es
|
|
3
|
+
in vec2 a_corner;
|
|
4
|
+
in vec4 a_rect;
|
|
5
|
+
in vec4 a_uv;
|
|
6
|
+
in vec4 a_color;
|
|
7
|
+
uniform vec2 u_res;
|
|
8
|
+
out vec2 v_uv;
|
|
9
|
+
out vec4 v_color;
|
|
10
|
+
void main() {
|
|
11
|
+
float px = a_rect.x + a_corner.x * a_rect.z;
|
|
12
|
+
float py = a_rect.y + a_corner.y * a_rect.w;
|
|
13
|
+
v_uv = vec2(a_uv.x + a_corner.x * (a_uv.z - a_uv.x),
|
|
14
|
+
a_uv.y + a_corner.y * (a_uv.w - a_uv.y));
|
|
15
|
+
v_color = a_color;
|
|
16
|
+
gl_Position = vec4(px / u_res.x * 2.0 - 1.0,
|
|
17
|
+
1.0 - py / u_res.y * 2.0, 0.0, 1.0);
|
|
18
|
+
}`,Bl=`#version 300 es
|
|
19
|
+
precision mediump float;
|
|
20
|
+
uniform sampler2D u_atlas;
|
|
21
|
+
in vec2 v_uv;
|
|
22
|
+
in vec4 v_color;
|
|
23
|
+
out vec4 fragColor;
|
|
24
|
+
void main() {
|
|
25
|
+
float a = texture(u_atlas, v_uv).a;
|
|
26
|
+
fragColor = vec4(v_color.rgb, v_color.a * a);
|
|
27
|
+
}`;function Ol(n){let e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(n);return e!==null?[parseInt(e[1],16)/255,parseInt(e[2],16)/255,parseInt(e[3],16)/255,e[4]!==void 0?parseInt(e[4],16)/255:1]:(e=/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)/.exec(n),e!==null?[parseFloat(e[1])/255,parseFloat(e[2])/255,parseFloat(e[3])/255,e[4]!==void 0?parseFloat(e[4]):1]:[1,1,1,1])}var Dr=12,En=8192,It=class{_canvas;_gl;_program;_vao;_cornerVbo;_instanceVbo;_uRes;_uAtlas;_aCorner;_aRect;_aUv;_aColor;_mainItems=[];_overlayItems=[];_phase="main";_cssW=0;_cssH=0;_pixelRatio=1;_buf=new Float32Array(En*Dr);_atlases=new Map;constructor(e){this._canvas=document.createElement("canvas"),this._canvas.style.cssText="position:absolute;top:0;left:0;pointer-events:none;z-index:3;box-sizing:border-box;",e.appendChild(this._canvas);let t=this._canvas.getContext("webgl2",{antialias:false,premultipliedAlpha:false,preserveDrawingBuffer:true,powerPreference:"high-performance"});this._gl=t,this._program=this._compileProgram(),this._uRes=t.getUniformLocation(this._program,"u_res"),this._uAtlas=t.getUniformLocation(this._program,"u_atlas"),this._aCorner=t.getAttribLocation(this._program,"a_corner"),this._aRect=t.getAttribLocation(this._program,"a_rect"),this._aUv=t.getAttribLocation(this._program,"a_uv"),this._aColor=t.getAttribLocation(this._program,"a_color"),this._vao=t.createVertexArray(),t.bindVertexArray(this._vao),this._cornerVbo=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._cornerVbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(this._aCorner),t.vertexAttribPointer(this._aCorner,2,t.FLOAT,false,0,0),this._instanceVbo=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._instanceVbo),t.bufferData(t.ARRAY_BUFFER,this._buf,t.DYNAMIC_DRAW);let r=Dr*4;t.enableVertexAttribArray(this._aRect),t.vertexAttribPointer(this._aRect,4,t.FLOAT,false,r,0),t.vertexAttribDivisor(this._aRect,1),t.enableVertexAttribArray(this._aUv),t.vertexAttribPointer(this._aUv,4,t.FLOAT,false,r,16),t.vertexAttribDivisor(this._aUv,1),t.enableVertexAttribArray(this._aColor),t.vertexAttribPointer(this._aColor,4,t.FLOAT,false,r,32),t.vertexAttribDivisor(this._aColor,1),t.bindVertexArray(null),t.disable(t.DEPTH_TEST),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);}beginMainFrame(){this._phase="main",this._mainItems=[],this._overlayItems=[];}beginOverlayFrame(){this._phase="overlay",this._overlayItems=[];}queue(e){this._phase==="main"?this._mainItems.push(e):this._overlayItems.push(e);}flush(){this._render(this._mainItems.concat(this._overlayItems));}drawTo(e,t,r,i){this._render(i?this._mainItems.concat(this._overlayItems):this._mainItems),e.drawImage(this._canvas,0,0,t,r),i||this.flush();}_render(e){let t=this._gl;if(this._cssW===0||this._cssH===0||(t.viewport(0,0,this._canvas.width,this._canvas.height),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),e.length===0))return;t.useProgram(this._program),t.uniform2f(this._uRes,this._cssW,this._cssH),t.uniform1i(this._uAtlas,0),t.bindVertexArray(this._vao),t.activeTexture(t.TEXTURE0);let r=new Map;for(let i of e){let o=`${i.fontSize}/${i.fontFamily}`,a=r.get(o);a===void 0&&(a={atlas:this._getAtlas(i.fontSize,i.fontFamily),items:[]},r.set(o,a)),a.items.push(i);}for(let{atlas:i,items:o}of r.values()){if(i.texture===null)continue;let a=this._packInstances(i,o);a!==0&&(t.bindTexture(t.TEXTURE_2D,i.texture),t.bindBuffer(t.ARRAY_BUFFER,this._instanceVbo),t.bufferSubData(t.ARRAY_BUFFER,0,this._buf.subarray(0,a*Dr)),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,a));}t.bindVertexArray(null);}_packInstances(e,t){let r=this._buf,i=0,o=a=>Math.round(a*this._pixelRatio)/this._pixelRatio;for(let a of t){let s=a.fontSize/e.fontSize,c=(e.getGlyph("0")?.cellH??a.fontSize)*s,u=a.paddingLeft??0,d=a.paddingTop??0,[h,m,p,g]=Ol(a.color),f=0;for(let C of a.text){let T=e.getGlyph(C);f+=(T!==null?T.advance:a.fontSize*.5)*s;}let y=a.align??"left",v;y==="right"||y==="end"?v=a.x-f+u:y==="center"?v=a.x-f/2+u:v=a.x+u;let b=a.baseline??"top",S;b==="bottom"||b==="alphabetic"||b==="ideographic"?S=a.y-c+d:b==="middle"?S=a.y-c/2+d:S=a.y+d,v=o(v),S=o(S);let x=v;for(let C of a.text){if(i>=En)break;let T=e.getGlyph(C);if(T===null){x+=a.fontSize*.5*s;continue}let A=T.cellW*s,P=o(x),I=S,R=Math.max(1/this._pixelRatio,o(A)),D=Math.max(1/this._pixelRatio,o(c)),E=i*Dr;r[E]=P,r[E+1]=I,r[E+2]=R,r[E+3]=D,r[E+4]=T.u0,r[E+5]=T.v0,r[E+6]=T.u1,r[E+7]=T.v1,r[E+8]=h,r[E+9]=m,r[E+10]=p,r[E+11]=g,x+=T.advance*s,i++;}}return i}_getAtlas(e,t){let r=`${e}/${t}`,i=this._atlases.get(r);return i===void 0&&(i=new Ir(e,t),i.build(this._gl),this._atlases.set(r,i)),i}resize(e,t){if(this._cssW===e&&this._cssH===t)return;this._cssW=e,this._cssH=t;let r=Math.max(Math.ceil(X(this._canvas)),1);this._pixelRatio=r,this._canvas.width=Math.round(e*this._pixelRatio),this._canvas.height=Math.round(t*this._pixelRatio),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._gl.viewport(0,0,this._canvas.width,this._canvas.height);}getElement(){return this._canvas}destroy(){let e=this._gl;for(let r of this._atlases.values())r.destroy(e);this._atlases.clear(),e.deleteBuffer(this._cornerVbo),e.deleteBuffer(this._instanceVbo),e.deleteVertexArray(this._vao),e.deleteProgram(this._program),e.getExtension("WEBGL_lose_context")?.loseContext(),this._canvas.remove();}static isSupported(){return ve.isSupported()}_compileProgram(){let e=this._gl,t=e.createShader(e.VERTEX_SHADER);e.shaderSource(t,Ll),e.compileShader(t);let r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,Bl),e.compileShader(r);let i=e.createProgram();return e.attachShader(i,t),e.attachShader(i,r),e.linkProgram(i),e.deleteShader(t),e.deleteShader(r),i}};var Ge=class extends Pe{_rootContainer;_pane;_container;_bounding=ze();_cursor="crosshair";_forceCursor=null;constructor(e,t){super(),this._pane=t,this._rootContainer=e,this._container=this.createContainer(),e.appendChild(this._container);}setBounding(e){return G(this._bounding,e),this}getContainer(){return this._container}getBounding(){return this._bounding}getPane(){return this._pane}checkEventOn(e){return true}setCursor(e){L(this._forceCursor)||e!==this._cursor&&(this._cursor=e,this._container.style.cursor=this._cursor);}setForceCursor(e){e!==this._forceCursor&&(this._forceCursor=e,this._container.style.cursor=this._forceCursor??this._cursor);}getForceCursor(){return this._forceCursor}update(e){this.updateImp(this._container,this._bounding,e??3);}destroy(){this._rootContainer.removeChild(this._container);}};var De=class extends Ge{_mainCanvas;_overlayCanvas;_textRenderer;constructor(e,t){super(e,t);let r=this.getContainer();this._textRenderer=It.isSupported()?new It(r):null,this._mainCanvas=new ft({position:"absolute",top:"0",left:"0",zIndex:"2",boxSizing:"border-box"},()=>{this._textRenderer?.beginMainFrame(),this.updateMain(this._mainCanvas.getContext()),this._textRenderer?.flush();}),this._overlayCanvas=new ft({position:"absolute",top:"0",left:"0",zIndex:"2",boxSizing:"border-box"},()=>{this._textRenderer?.beginOverlayFrame(),this.updateOverlay(this._overlayCanvas.getContext()),this._textRenderer?.flush();}),r.appendChild(this._mainCanvas.getElement()),r.appendChild(this._overlayCanvas.getElement());}createContainer(){return oe("div",{margin:"0",padding:"0",position:"absolute",top:"0",overflow:"hidden",boxSizing:"border-box",zIndex:"1",backgroundColor:"inherit"})}getTextRenderer(){return this._textRenderer}queueText(e){this._textRenderer?.queue(e);}updateImp(e,t,r){let{width:i,height:o,left:a}=t;e.style.left=`${a}px`;let s=r,l=e.clientWidth,c=e.clientHeight;switch((i!==l||o!==c)&&(e.style.width=`${i}px`,e.style.height=`${o}px`,this._textRenderer?.resize(i,o),s=3),s){case 0:{this._mainCanvas.update(i,o);break}case 1:{this._overlayCanvas.update(i,o);break}case 3:case 4:{this._mainCanvas.update(i,o),this._overlayCanvas.update(i,o);break}}}destroy(){this._mainCanvas.destroy(),this._overlayCanvas.destroy(),this._textRenderer?.destroy();}getImage(e){let{width:t,height:r}=this.getBounding(),i=oe("canvas",{width:`${t}px`,height:`${r}px`,boxSizing:"border-box"}),o=i.getContext("2d"),a=X(i);i.width=t*a,i.height=r*a,o.scale(a,a);let s=this._overlayCanvas.getElement(),l=this._textRenderer?.getElement();return Array.from(this.getContainer().children).map((u,d)=>({element:u,index:d})).filter(u=>u.element instanceof HTMLCanvasElement).filter(u=>e||u.element!==s).filter(u=>u.element!==l).sort((u,d)=>{let h=Number(u.element.style.zIndex||0)-Number(d.element.style.zIndex||0);return h===0?u.index-d.index:h}).forEach(({element:u})=>{o.drawImage(u,0,0,t,r);}),this._textRenderer?.drawTo(o,t,r,e),i}};var K=class extends Pe{_widget;constructor(e){super(),this._widget=e;}getWidget(){return this._widget}createFigure(e,t){let r=tn(e.name);if(r!==null){let i=new r(e);if(_(t)){for(let o in t)t.hasOwnProperty(o)&&i.registerEvent(o,t[o]);this.addChild(i);}return i}return null}draw(e,...t){this.clear(),this.drawImp(e,t);}checkEventOn(e){return true}};var In=`#version 300 es
|
|
28
|
+
precision highp float;
|
|
29
|
+
|
|
30
|
+
// Per-instance attributes (divisor = 1)
|
|
31
|
+
in float a_centerX;
|
|
32
|
+
in float a_open;
|
|
33
|
+
in float a_high;
|
|
34
|
+
in float a_low;
|
|
35
|
+
in float a_close;
|
|
36
|
+
in vec4 a_wickColor;
|
|
37
|
+
in vec4 a_bodyColor;
|
|
38
|
+
in vec4 a_borderColor;
|
|
39
|
+
|
|
40
|
+
uniform float u_priceFrom; // realFrom of the visible Y range
|
|
41
|
+
uniform float u_priceRange; // realRange of the visible Y range
|
|
42
|
+
uniform vec2 u_resolution; // canvas physical pixel dimensions
|
|
43
|
+
uniform float u_pixelRatio; // CSS px \u2192 physical px
|
|
44
|
+
uniform float u_barHalfWidth; // half bar gapBar width, in CSS pixels
|
|
45
|
+
// Render mode: 0 = candle (solid/stroke), 1 = ohlc
|
|
46
|
+
uniform int u_renderMode;
|
|
47
|
+
// Half of ohlcSize in CSS pixels \u2014 only used when u_renderMode == 1
|
|
48
|
+
uniform float u_ohlcHalfSize;
|
|
49
|
+
// Pan-offset optimisation: CSS pixel delta added to every bar's a_centerX so
|
|
50
|
+
// pure-pan frames skip bufferSubData and update only this uniform (O(1)).
|
|
51
|
+
uniform float u_panOffset;
|
|
52
|
+
|
|
53
|
+
out vec4 v_color;
|
|
54
|
+
|
|
55
|
+
// Unit-quad positions shared by all three sub-quads
|
|
56
|
+
vec2 unitQuad(int id) {
|
|
57
|
+
if (id == 0) return vec2(0.0, 0.0);
|
|
58
|
+
if (id == 1) return vec2(1.0, 0.0);
|
|
59
|
+
if (id == 2) return vec2(0.0, 1.0);
|
|
60
|
+
if (id == 3) return vec2(0.0, 1.0);
|
|
61
|
+
if (id == 4) return vec2(1.0, 0.0);
|
|
62
|
+
return vec2(1.0, 1.0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// GPU price \u2192 physical screen-Y pixel
|
|
66
|
+
float priceToPhysY(float price) {
|
|
67
|
+
float rate = (price - u_priceFrom) / u_priceRange;
|
|
68
|
+
return (1.0 - rate) * u_resolution.y;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void main() {
|
|
72
|
+
bool isWick = gl_VertexID < 6;
|
|
73
|
+
bool isBodyOuter = gl_VertexID >= 6 && gl_VertexID < 12;
|
|
74
|
+
// isBodyInner = gl_VertexID >= 12
|
|
75
|
+
|
|
76
|
+
int localId = gl_VertexID < 6 ? gl_VertexID :
|
|
77
|
+
gl_VertexID < 12 ? gl_VertexID - 6 :
|
|
78
|
+
gl_VertexID - 12;
|
|
79
|
+
vec2 unit = unitQuad(localId);
|
|
80
|
+
|
|
81
|
+
float highY = priceToPhysY(a_high);
|
|
82
|
+
float lowY = priceToPhysY(a_low);
|
|
83
|
+
float openY = priceToPhysY(a_open);
|
|
84
|
+
float closeY = priceToPhysY(a_close);
|
|
85
|
+
|
|
86
|
+
float pr = u_pixelRatio;
|
|
87
|
+
float cx = (a_centerX + u_panOffset) * pr; // pan-offset + CSS px \u2192 physical px
|
|
88
|
+
float bhw = u_barHalfWidth * pr;
|
|
89
|
+
|
|
90
|
+
float screenX, screenY;
|
|
91
|
+
|
|
92
|
+
if (u_renderMode == 1) {
|
|
93
|
+
// \u2500\u2500 OHLC mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
94
|
+
// wick: center-aligned vertical bar, width = ohlcSize
|
|
95
|
+
// body-outer: open stub (left side: cx-bhw \u2192 cx-ohw)
|
|
96
|
+
// body-inner: close stub (right side: cx+ohw \u2192 cx+bhw)
|
|
97
|
+
float ohw = u_ohlcHalfSize * pr; // half ohlcSize in physical px
|
|
98
|
+
float tickH = ohw * 2.0; // tick height = ohlcSize
|
|
99
|
+
|
|
100
|
+
if (isWick) {
|
|
101
|
+
screenX = cx - ohw + unit.x * ohw * 2.0;
|
|
102
|
+
screenY = highY + (lowY - highY) * unit.y;
|
|
103
|
+
v_color = a_bodyColor;
|
|
104
|
+
} else if (isBodyOuter) {
|
|
105
|
+
float left = cx - bhw;
|
|
106
|
+
float right = cx - ohw;
|
|
107
|
+
screenX = left + unit.x * max(right - left, 0.0);
|
|
108
|
+
screenY = openY + unit.y * tickH;
|
|
109
|
+
v_color = a_bodyColor;
|
|
110
|
+
} else {
|
|
111
|
+
float left = cx + ohw;
|
|
112
|
+
float right = cx + bhw;
|
|
113
|
+
screenX = left + unit.x * max(right - left, 0.0);
|
|
114
|
+
screenY = closeY + unit.y * tickH;
|
|
115
|
+
v_color = a_bodyColor;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// \u2500\u2500 Candle mode (solid / stroke) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
119
|
+
float bodyTop = min(openY, closeY);
|
|
120
|
+
float bodyBottom = max(openY, closeY);
|
|
121
|
+
bodyBottom = max(bodyBottom, bodyTop + 1.0); // min 1px body
|
|
122
|
+
|
|
123
|
+
if (isWick) {
|
|
124
|
+
screenX = cx - 0.5 + unit.x;
|
|
125
|
+
screenY = highY + (lowY - highY) * unit.y;
|
|
126
|
+
v_color = a_wickColor;
|
|
127
|
+
} else if (isBodyOuter) {
|
|
128
|
+
screenX = cx - bhw + unit.x * bhw * 2.0;
|
|
129
|
+
screenY = bodyTop + (bodyBottom - bodyTop) * unit.y;
|
|
130
|
+
v_color = a_borderColor;
|
|
131
|
+
} else {
|
|
132
|
+
// body inner \u2014 1 physical pixel inset on each side.
|
|
133
|
+
// For stroke types, bodyColor alpha = 0 \u2192 body-inner is transparent,
|
|
134
|
+
// leaving only the body-outer border visible (hollow candle).
|
|
135
|
+
float inset = 1.0;
|
|
136
|
+
float innerHW = max(bhw - inset, 0.5);
|
|
137
|
+
screenX = cx - innerHW + unit.x * innerHW * 2.0;
|
|
138
|
+
float innerTop = bodyTop + inset;
|
|
139
|
+
float innerBottom = max(bodyBottom - inset, innerTop);
|
|
140
|
+
screenY = innerTop + (innerBottom - innerTop) * unit.y;
|
|
141
|
+
v_color = a_bodyColor;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Physical pixel \u2192 NDC (executes for both OHLC and Candle modes)
|
|
146
|
+
gl_Position = vec4(
|
|
147
|
+
screenX / u_resolution.x * 2.0 - 1.0,
|
|
148
|
+
1.0 - screenY / u_resolution.y * 2.0,
|
|
149
|
+
0.0, 1.0
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
`,Dn=`#version 300 es
|
|
153
|
+
precision mediump float;
|
|
154
|
+
in vec4 v_color;
|
|
155
|
+
out vec4 fragColor;
|
|
156
|
+
void main() { fragColor = v_color; }
|
|
157
|
+
`;function Vl(n){let e=n.replace("#","");if(e.length===6||e.length===8){let t=parseInt(e.slice(0,2),16)/255,r=parseInt(e.slice(2,4),16)/255,i=parseInt(e.slice(4,6),16)/255,o=e.length===8?parseInt(e.slice(6,8),16)/255:1;return [t,r,i,o]}if(e.length===3){let t=parseInt(e[0]+e[0],16)/255,r=parseInt(e[1]+e[1],16)/255,i=parseInt(e[2]+e[2],16)/255;return [t,r,i,1]}return [0,0,0,1]}function Nl(n){if(n.startsWith("#"))return Vl(n);let e=n.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)/);return e!==null?[parseFloat(e[1])/255,parseFloat(e[2])/255,parseFloat(e[3])/255,e[4]!==void 0?parseFloat(e[4]):1]:[0,0,0,1]}function Be(n,e){let t=e.get(n);return t===void 0&&(t=Nl(n),e.set(n,t)),t}function Rr(n,e,t){e[t]=n[0]*255+.5|0,e[t+1]=n[1]*255+.5|0,e[t+2]=n[2]*255+.5|0,e[t+3]=n[3]*255+.5|0;}var oi=class{_canvas;_gl;_sizeVersion=0;constructor(e){let t=document.createElement("canvas");t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.zIndex="1",t.style.pointerEvents="none",e.appendChild(t),this._canvas=t;let r=t.getContext("webgl2",{antialias:false,premultipliedAlpha:false,preserveDrawingBuffer:true,powerPreference:"high-performance",alpha:true});if(r===null)throw t.remove(),new Error("[SharedIndicatorGLCanvas] WebGL2 unavailable");this._gl=r,r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.disable(r.DEPTH_TEST),r.enable(r.SCISSOR_TEST);}get gl(){return this._gl}get canvas(){return this._canvas}get sizeVersion(){return this._sizeVersion}resize(e,t){let r=X(this._canvas),i=Math.round(e*r),o=Math.round(t*r);this._canvas.width===i&&this._canvas.height===o||(this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._canvas.width=i,this._canvas.height=o,this._sizeVersion++);}beginFrame(){let e=this._gl,t=this._canvas.width,r=this._canvas.height;e.viewport(0,0,t,r),e.scissor(0,0,t,r),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT);}destroy(){this._gl.getExtension("WEBGL_lose_context")?.loseContext(),this._canvas.remove();}},Dt=new WeakMap,Wl=new FinalizationRegistry(n=>{n.destroy();});function Rt(n){return Dt.get(n)??null}function ni(n,e){if(!ve.isSupported())return null;let t=Dt.get(n);if(t===void 0)try{t=new oi(e),Dt.set(n,t),Wl.register(n,t,n);}catch{return null}return t}function Rn(n){let e=Dt.get(n);e!==void 0&&(e.destroy(),Dt.delete(n));}var ye=24,Re=20,Mn=6,Yl=`#version 300 es
|
|
158
|
+
precision highp float;
|
|
159
|
+
|
|
160
|
+
// Per-segment attributes (divisor = 1)
|
|
161
|
+
in float a_x0;
|
|
162
|
+
in float a_y0;
|
|
163
|
+
in float a_x1;
|
|
164
|
+
in float a_y1;
|
|
165
|
+
in float a_halfWidth; // CSS pixels
|
|
166
|
+
in vec4 a_color; // RGBA, normalized
|
|
167
|
+
|
|
168
|
+
// Canvas dimensions in physical pixels; devicePixelRatio
|
|
169
|
+
uniform vec2 u_resolution;
|
|
170
|
+
uniform float u_pixelRatio;
|
|
171
|
+
|
|
172
|
+
out vec4 v_color;
|
|
173
|
+
out float v_normDist; // signed normalised perp distance: \xB11 at the line edges
|
|
174
|
+
|
|
175
|
+
void main() {
|
|
176
|
+
// Quad-expansion pattern for 6 vertices (two triangles):
|
|
177
|
+
// vi: 0 1 2 3 4 5
|
|
178
|
+
// t: 0 1 1 0 1 0 (0 = p0 endpoint, 1 = p1 endpoint)
|
|
179
|
+
// n: -1 -1 +1 -1 +1 +1 (\xB1normal extrusion)
|
|
180
|
+
int vi = gl_VertexID % 6;
|
|
181
|
+
float t = (vi == 1 || vi == 2 || vi == 4) ? 1.0 : 0.0;
|
|
182
|
+
float n = (vi == 2 || vi == 4 || vi == 5) ? 1.0 : -1.0;
|
|
183
|
+
|
|
184
|
+
// Convert endpoints to physical pixels
|
|
185
|
+
vec2 p0 = vec2(a_x0, a_y0) * u_pixelRatio;
|
|
186
|
+
vec2 p1 = vec2(a_x1, a_y1) * u_pixelRatio;
|
|
187
|
+
vec2 dir = p1 - p0;
|
|
188
|
+
float len = length(dir);
|
|
189
|
+
vec2 unitDir = len > 0.001 ? dir / len : vec2(1.0, 0.0);
|
|
190
|
+
vec2 normal = vec2(-unitDir.y, unitDir.x);
|
|
191
|
+
|
|
192
|
+
// Interpolate along segment then extrude perpendicular
|
|
193
|
+
vec2 pos = mix(p0, p1, t) + normal * (n * a_halfWidth * u_pixelRatio);
|
|
194
|
+
|
|
195
|
+
// Physical px \u2192 NDC (Y-flip: CSS Y=0 is top, NDC Y=+1 is top)
|
|
196
|
+
gl_Position = vec4(
|
|
197
|
+
(pos.x / u_resolution.x) * 2.0 - 1.0,
|
|
198
|
+
1.0 - (pos.y / u_resolution.y) * 2.0,
|
|
199
|
+
0.0, 1.0
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
v_color = a_color;
|
|
203
|
+
v_normDist = n; // \xB11 at the outer edges, interpolated across the quad
|
|
204
|
+
}
|
|
205
|
+
`,zl=`#version 300 es
|
|
206
|
+
precision mediump float;
|
|
207
|
+
in vec4 v_color;
|
|
208
|
+
in float v_normDist;
|
|
209
|
+
out vec4 fragColor;
|
|
210
|
+
void main() {
|
|
211
|
+
// Anti-alias the line edge over ~1 physical pixel using the built-in
|
|
212
|
+
// fwidth() derivative (GLSL ES 3.0 \u2014 no extension needed).
|
|
213
|
+
// abs(v_normDist) \u2192 0 at the centreline, 1 at the hard edge.
|
|
214
|
+
// smoothstep fades the alpha from 1 \u2192 0 over one derivative-width.
|
|
215
|
+
float fw = fwidth(v_normDist);
|
|
216
|
+
float aa = 1.0 - smoothstep(1.0 - fw, 1.0 + fw, abs(v_normDist));
|
|
217
|
+
fragColor = vec4(v_color.rgb, v_color.a * aa);
|
|
218
|
+
}
|
|
219
|
+
`;function kn(n,e,t){let r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw new Error(`[IndicatorLineWebGLRenderer] shader compile error: ${n.getShaderInfoLog(r)??"?"}`);return r}function Hl(n){let e=kn(n,n.VERTEX_SHADER,Yl),t=kn(n,n.FRAGMENT_SHADER,zl),r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.deleteShader(e),n.deleteShader(t),!n.getProgramParameter(r,n.LINK_STATUS))throw new Error(`[IndicatorLineWebGLRenderer] program link error: ${n.getProgramInfoLog(r)??"?"}`);return r}var ai=class{_sharedCanvas;_gl;_program;_vao;_vbo;_uResolution;_uPixelRatio;_capacity=0;_segCount=0;_stagingBuf=new ArrayBuffer(512*ye);_stagingF32=new Float32Array(this._stagingBuf);_stagingU8=new Uint8Array(this._stagingBuf);_colorCache=new Map;_gridVao;_gridVbo;_gridCapacity=0;_gridSegCount=0;_gridStagingBuf=new ArrayBuffer(128*ye);_gridStagingF32=new Float32Array(this._gridStagingBuf);_gridStagingU8=new Uint8Array(this._gridStagingBuf);_gridVboVersion=0;_gridDrawnVersion=-1;_gridFingerprintCount=-1;_gridFingerprintFirstX=0;_gridFingerprintFirstY=0;_gridFingerprintLastX=0;_gridFingerprintLastY=0;_fingerprintSegmentCount=-1;_fingerprintFirstX=0;_fingerprintFirstY=0;_fingerprintLastX=0;_fingerprintLastY=0;_culledBuf=[];_vboVersion=0;_drawnVersion=-1;_lastSizeVersion=-1;constructor(e){this._sharedCanvas=e;let t=e.gl;this._gl=t,this._program=Hl(t),t.useProgram(this._program),this._uResolution=t.getUniformLocation(this._program,"u_resolution"),this._uPixelRatio=t.getUniformLocation(this._program,"u_pixelRatio"),this._vao=t.createVertexArray(),t.bindVertexArray(this._vao),this._vbo=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vbo),this._setupAttribs(t),t.bindVertexArray(null),this._gridVao=t.createVertexArray(),t.bindVertexArray(this._gridVao),this._gridVbo=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._gridVbo),this._setupAttribs(t),t.bindVertexArray(null);}_setupAttribs(e){let t=this._program,r=ye,i=(a,s)=>{let l=e.getAttribLocation(t,a);l<0||(e.enableVertexAttribArray(l),e.vertexAttribPointer(l,1,e.FLOAT,false,r,s),e.vertexAttribDivisor(l,1));};i("a_x0",0),i("a_y0",4),i("a_x1",8),i("a_y1",12),i("a_halfWidth",16);let o=e.getAttribLocation(t,"a_color");o>=0&&(e.enableVertexAttribArray(o),e.vertexAttribPointer(o,4,e.UNSIGNED_BYTE,true,r,Re),e.vertexAttribDivisor(o,1));}isDirty(){return this._vboVersion!==this._drawnVersion||this._lastSizeVersion!==this._sharedCanvas.sizeVersion}resize(e,t){this._sharedCanvas.resize(e,t);}_ensureCapacity(e){if(e<=this._capacity)return;let t=Math.max(e,this._capacity*2,512);this._stagingBuf=new ArrayBuffer(t*ye),this._stagingF32=new Float32Array(this._stagingBuf),this._stagingU8=new Uint8Array(this._stagingBuf);let r=this._gl;r.bindBuffer(r.ARRAY_BUFFER,this._vbo),r.bufferData(r.ARRAY_BUFFER,t*ye,r.DYNAMIC_DRAW),this._capacity=t;}_parseColorCached(e){return Be(e,this._colorCache)}setData(e){let t=this._culledBuf,r=0;for(let u=0;u<e.length;u++){let d=e[u];Math.abs(d.x1-d.x0)<.5&&Math.abs(d.y1-d.y0)<.5||(r>=t.length?t.push(d):t[r]=d,r++);}let i=r;if(this._segCount=i,i===0){this._fingerprintSegmentCount!==0&&this._vboVersion++,this._fingerprintSegmentCount=0;return}let o=t[0],a=t[r-1];if(i===this._fingerprintSegmentCount&&o.x0===this._fingerprintFirstX&&o.y0===this._fingerprintFirstY&&a.x1===this._fingerprintLastX&&a.y1===this._fingerprintLastY)return;this._fingerprintSegmentCount=i,this._fingerprintFirstX=o.x0,this._fingerprintFirstY=o.y0,this._fingerprintLastX=a.x1,this._fingerprintLastY=a.y1,this._ensureCapacity(i);let s=this._stagingF32,l=this._stagingU8;for(let u=0;u<i;u++){let d=t[u],h=u*5,m=u*ye;s[h+0]=d.x0,s[h+1]=d.y0,s[h+2]=d.x1,s[h+3]=d.y1,s[h+4]=d.halfWidth;let p=this._parseColorCached(d.color);l[m+Re]=p[0]*255+.5|0,l[m+Re+1]=p[1]*255+.5|0,l[m+Re+2]=p[2]*255+.5|0,l[m+Re+3]=p[3]*255+.5|0;}let c=this._gl;c.bindBuffer(c.ARRAY_BUFFER,this._vbo),c.bufferSubData(c.ARRAY_BUFFER,0,this._stagingU8,0,i*ye),this._vboVersion++;}draw(){let e=this._sharedCanvas,t=e.canvas,r=this._gl,i=X(t),o=t.width,a=t.height;this._drawnVersion=this._vboVersion,this._lastSizeVersion=e.sizeVersion,this._segCount!==0&&(r.useProgram(this._program),r.uniform2f(this._uResolution,o,a),r.uniform1f(this._uPixelRatio,i),r.bindVertexArray(this._vao),r.drawArraysInstanced(r.TRIANGLES,0,Mn,this._segCount),r.bindVertexArray(null));}isGridDirty(){return this._gridVboVersion!==this._gridDrawnVersion||this._lastSizeVersion!==this._sharedCanvas.sizeVersion}_ensureGridCapacity(e){if(e<=this._gridCapacity)return;let t=Math.max(e,this._gridCapacity*2,128);this._gridStagingBuf=new ArrayBuffer(t*ye),this._gridStagingF32=new Float32Array(this._gridStagingBuf),this._gridStagingU8=new Uint8Array(this._gridStagingBuf);let r=this._gl;r.bindBuffer(r.ARRAY_BUFFER,this._gridVbo),r.bufferData(r.ARRAY_BUFFER,t*ye,r.DYNAMIC_DRAW),this._gridCapacity=t;}setGridLines(e){let t=e.length;if(this._gridSegCount=t,t===0){this._gridFingerprintCount!==0&&this._gridVboVersion++,this._gridFingerprintCount=0;return}let r=e[0],i=e[t-1];if(t===this._gridFingerprintCount&&r.x0===this._gridFingerprintFirstX&&r.y0===this._gridFingerprintFirstY&&i.x1===this._gridFingerprintLastX&&i.y1===this._gridFingerprintLastY)return;this._gridFingerprintCount=t,this._gridFingerprintFirstX=r.x0,this._gridFingerprintFirstY=r.y0,this._gridFingerprintLastX=i.x1,this._gridFingerprintLastY=i.y1,this._ensureGridCapacity(t);let o=this._gridStagingF32,a=this._gridStagingU8;for(let l=0;l<t;l++){let c=e[l],u=l*5,d=l*ye;o[u+0]=c.x0,o[u+1]=c.y0,o[u+2]=c.x1,o[u+3]=c.y1,o[u+4]=c.halfWidth;let h=this._parseColorCached(c.color);a[d+Re]=h[0]*255+.5|0,a[d+Re+1]=h[1]*255+.5|0,a[d+Re+2]=h[2]*255+.5|0,a[d+Re+3]=h[3]*255+.5|0;}let s=this._gl;s.bindBuffer(s.ARRAY_BUFFER,this._gridVbo),s.bufferSubData(s.ARRAY_BUFFER,0,this._gridStagingU8,0,t*ye),this._gridVboVersion++;}drawGrid(){if(this._gridDrawnVersion=this._gridVboVersion,this._lastSizeVersion=this._sharedCanvas.sizeVersion,this._gridSegCount===0)return;let t=this._sharedCanvas.canvas,r=this._gl,i=X(t),o=t.width,a=t.height;r.useProgram(this._program),r.uniform2f(this._uResolution,o,a),r.uniform1f(this._uPixelRatio,i),r.bindVertexArray(this._gridVao),r.drawArraysInstanced(r.TRIANGLES,0,Mn,this._gridSegCount),r.bindVertexArray(null);}destroy(){let e=this._gl;e.deleteVertexArray(this._gridVao),e.deleteBuffer(this._gridVbo),e.deleteVertexArray(this._vao),e.deleteBuffer(this._vbo),e.deleteProgram(this._program);}},Mt=new WeakMap;function Mr(n){return Mt.get(n)??null}function Fn(n,e){let t=Mt.get(n);return t===void 0&&(t=new ai(e),Mt.set(n,t)),t}function Ln(n){let e=Mt.get(n);e!==void 0&&(e.destroy(),Mt.delete(n));}var kt=class extends K{drawImp(e){let t=this.getWidget(),r=this.getWidget().getPane(),i=r.getChart(),o=t.getBounding(),a=i.getStyles().grid;if(!a.show)return;let c=Rt(t)!==null?Mr(t):null;if(c!==null){let p=[],g=a.horizontal;if(g.show!==false){let y=r.getAxisComponent(),v=(g.size??1)/2;for(let b of y.getTicks())p.push({x0:0,y0:b.coord,x1:o.width,y1:b.coord,halfWidth:v,color:g.color});}let f=a.vertical;if(f.show!==false){let y=i.getXAxisPane().getAxisComponent(),v=(f.size??1)/2;for(let b of y.getTicks())p.push({x0:b.coord,y0:0,x1:b.coord,y1:o.height,halfWidth:v,color:f.color});}c.setGridLines(p);return}let u=a.horizontal;if(u.show){let g=r.getAxisComponent().getTicks().map(f=>({coordinates:[{x:0,y:f.coord},{x:o.width,y:f.coord}]}));this.createFigure({name:"line",attrs:g,styles:u})?.draw(e);}let h=a.vertical;if(h.show){let g=i.getXAxisPane().getAxisComponent().getTicks().map(f=>({coordinates:[{x:f.coord,y:0},{x:f.coord,y:o.height}]}));this.createFigure({name:"line",attrs:g,styles:h})?.draw(e);}}};var _g="drawing_tools",Bn="__astroneumPluginRuntime";var si=class{_canvas;_gl;_vboCache=new Map;constructor(e){let t=document.createElement("canvas");t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.zIndex="1",t.style.pointerEvents="none",e.appendChild(t),this._canvas=t;let r=t.getContext("webgl2",{antialias:false,premultipliedAlpha:false,preserveDrawingBuffer:true,powerPreference:"high-performance",alpha:true});if(r===null)throw new Error("[IndicatorPluginWebGLRenderer] WebGL2 unavailable");this._gl=r,r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.disable(r.DEPTH_TEST),r.enable(r.SCISSOR_TEST);}getContext(){return this._gl}getOrCreateVbo(e){let t=this._vboCache.get(e);if(t===void 0){if(t=this._gl.createBuffer()??void 0,t===void 0)throw new Error("[IndicatorPluginWebGLRenderer] Failed to create buffer");this._vboCache.set(e,t);}return t}resize(e,t){let r=X(this._canvas),i=Math.round(e*r),o=Math.round(t*r);this._canvas.width===i&&this._canvas.height===o||(this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._canvas.width=i,this._canvas.height=o);}beginFrame(){let e=this._gl,t=this._canvas.width,r=this._canvas.height;e.viewport(0,0,t,r),e.scissor(0,0,t,r),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT);}destroy(){this._vboCache.forEach(e=>{this._gl.deleteBuffer(e);}),this._vboCache.clear(),this._gl.getExtension("WEBGL_lose_context")?.loseContext(),this._canvas.remove();}},Ft=new WeakMap;function On(n){return Ft.get(n)??null}function Vn(n,e){if(!ve.isSupported())return null;let t=Ft.get(n);if(t===void 0)try{t=new si(e),Ft.set(n,t);}catch{return null}return t}function Nn(n){let e=Ft.get(n);e!==void 0&&(e.destroy(),Ft.delete(n));}var vt=20,Lt=16,Gl=6,Wn=2166136261,Xl=16777619,Ul=1024,$l=`#version 300 es
|
|
220
|
+
precision highp float;
|
|
221
|
+
|
|
222
|
+
// Per-instance attributes (divisor = 1)
|
|
223
|
+
in float a_x;
|
|
224
|
+
in float a_y;
|
|
225
|
+
in float a_width;
|
|
226
|
+
in float a_height;
|
|
227
|
+
in vec4 a_color; // RGBA, normalized
|
|
228
|
+
|
|
229
|
+
// Canvas physical dimensions; devicePixelRatio
|
|
230
|
+
uniform vec2 u_resolution;
|
|
231
|
+
uniform float u_pixelRatio;
|
|
232
|
+
|
|
233
|
+
out vec4 v_color;
|
|
234
|
+
|
|
235
|
+
// Unit-quad positions for 6 vertices (two CCW triangles):
|
|
236
|
+
// vi: 0 1 2 3 4 5
|
|
237
|
+
// uv: (0,0) (1,0) (0,1) (0,1) (1,0) (1,1)
|
|
238
|
+
vec2 unitQuad(int id) {
|
|
239
|
+
if (id == 0) return vec2(0.0, 0.0);
|
|
240
|
+
if (id == 1) return vec2(1.0, 0.0);
|
|
241
|
+
if (id == 2) return vec2(0.0, 1.0);
|
|
242
|
+
if (id == 3) return vec2(0.0, 1.0);
|
|
243
|
+
if (id == 4) return vec2(1.0, 0.0);
|
|
244
|
+
return vec2(1.0, 1.0);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void main() {
|
|
248
|
+
vec2 uv = unitQuad(gl_VertexID % 6);
|
|
249
|
+
|
|
250
|
+
// CSS-pixel position of this vertex corner
|
|
251
|
+
vec2 cssPx = vec2(a_x + uv.x * a_width,
|
|
252
|
+
a_y + uv.y * a_height);
|
|
253
|
+
|
|
254
|
+
// CSS px \u2192 physical px \u2192 NDC (Y-flip: CSS Y=0 is top, NDC Y=+1 is top)
|
|
255
|
+
vec2 physPx = cssPx * u_pixelRatio;
|
|
256
|
+
gl_Position = vec4(
|
|
257
|
+
(physPx.x / u_resolution.x) * 2.0 - 1.0,
|
|
258
|
+
1.0 - (physPx.y / u_resolution.y) * 2.0,
|
|
259
|
+
0.0, 1.0
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
v_color = a_color;
|
|
263
|
+
}
|
|
264
|
+
`,ql=`#version 300 es
|
|
265
|
+
precision mediump float;
|
|
266
|
+
in vec4 v_color;
|
|
267
|
+
out vec4 fragColor;
|
|
268
|
+
void main() { fragColor = v_color; }
|
|
269
|
+
`;function Yn(n,e,t){let r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw new Error(`[IndicatorRectWebGLRenderer] shader compile error: ${n.getShaderInfoLog(r)??"?"}`);return r}function jl(n){let e=Yn(n,n.VERTEX_SHADER,$l),t=Yn(n,n.FRAGMENT_SHADER,ql),r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.deleteShader(e),n.deleteShader(t),!n.getProgramParameter(r,n.LINK_STATUS))throw new Error(`[IndicatorRectWebGLRenderer] program link error: ${n.getProgramInfoLog(r)??"?"}`);return r}var li=class{_sharedCanvas;_gl;_program;_vao;_vbo;_uResolution;_uPixelRatio;_capacity=0;_rectCount=0;_stagingBuf=new ArrayBuffer(512*vt);_stagingF32=new Float32Array(this._stagingBuf);_stagingU8=new Uint8Array(this._stagingBuf);_colorCache=new Map;_colorHashCache=new Map;_fingerprintRectCount=-1;_fingerprintHash=0;_culledBuf=[];_vboVersion=0;_drawnVersion=-1;_lastSizeVersion=-1;constructor(e){this._sharedCanvas=e;let t=e.gl;this._gl=t,this._program=jl(t),t.useProgram(this._program),this._uResolution=t.getUniformLocation(this._program,"u_resolution"),this._uPixelRatio=t.getUniformLocation(this._program,"u_pixelRatio"),this._vao=t.createVertexArray(),t.bindVertexArray(this._vao),this._vbo=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vbo),this._setupAttribs(t),t.bindVertexArray(null);}_setupAttribs(e){let t=this._program,r=vt,i=(a,s)=>{let l=e.getAttribLocation(t,a);l<0||(e.enableVertexAttribArray(l),e.vertexAttribPointer(l,1,e.FLOAT,false,r,s),e.vertexAttribDivisor(l,1));};i("a_x",0),i("a_y",4),i("a_width",8),i("a_height",12);let o=e.getAttribLocation(t,"a_color");o>=0&&(e.enableVertexAttribArray(o),e.vertexAttribPointer(o,4,e.UNSIGNED_BYTE,true,r,Lt),e.vertexAttribDivisor(o,1));}isDirty(){return this._vboVersion!==this._drawnVersion||this._lastSizeVersion!==this._sharedCanvas.sizeVersion}resize(e,t){this._sharedCanvas.resize(e,t);}_ensureCapacity(e){if(e<=this._capacity)return;let t=Math.max(e,this._capacity*2,512);this._stagingBuf=new ArrayBuffer(t*vt),this._stagingF32=new Float32Array(this._stagingBuf),this._stagingU8=new Uint8Array(this._stagingBuf);let r=this._gl;r.bindBuffer(r.ARRAY_BUFFER,this._vbo),r.bufferData(r.ARRAY_BUFFER,t*vt,r.DYNAMIC_DRAW),this._capacity=t;}_parseColorCached(e){return Be(e,this._colorCache)}_mixHash(e,t){return Math.imul(e^t,Xl)>>>0}_hashQuantized(e){return Math.round(e*Ul)|0}_hashColorCached(e){let t=this._colorHashCache.get(e);if(t===void 0){t=Wn;for(let r=0;r<e.length;r++)t=this._mixHash(t,e.charCodeAt(r));this._colorHashCache.set(e,t);}return t}setData(e){let t=this._culledBuf,r=0,i=Wn;for(let c=0;c<e.length;c++){let u=e[c];u.width<.5||u.height<.5||(r>=t.length?t.push(u):t[r]=u,i=this._mixHash(i,this._hashQuantized(u.x)),i=this._mixHash(i,this._hashQuantized(u.y)),i=this._mixHash(i,this._hashQuantized(u.width)),i=this._mixHash(i,this._hashQuantized(u.height)),i=this._mixHash(i,this._hashColorCached(u.color)),r++);}let o=r;if(this._rectCount=o,o===0){this._fingerprintRectCount!==0&&this._vboVersion++,this._fingerprintRectCount=0,this._fingerprintHash=0;return}if(o===this._fingerprintRectCount&&i===this._fingerprintHash)return;this._fingerprintRectCount=o,this._fingerprintHash=i,this._ensureCapacity(o);let a=this._stagingF32,s=this._stagingU8;for(let c=0;c<o;c++){let u=t[c],d=c*4,h=c*vt;a[d+0]=u.x,a[d+1]=u.y,a[d+2]=u.width,a[d+3]=u.height;let m=this._parseColorCached(u.color);s[h+Lt]=m[0]*255+.5|0,s[h+Lt+1]=m[1]*255+.5|0,s[h+Lt+2]=m[2]*255+.5|0,s[h+Lt+3]=m[3]*255+.5|0;}let l=this._gl;l.bindBuffer(l.ARRAY_BUFFER,this._vbo),l.bufferSubData(l.ARRAY_BUFFER,0,this._stagingU8,0,o*vt),this._vboVersion++;}draw(){let e=this._sharedCanvas,t=e.canvas,r=this._gl,i=X(t),o=t.width,a=t.height;this._drawnVersion=this._vboVersion,this._lastSizeVersion=e.sizeVersion,this._rectCount!==0&&(r.useProgram(this._program),r.uniform2f(this._uResolution,o,a),r.uniform1f(this._uPixelRatio,i),r.bindVertexArray(this._vao),r.drawArraysInstanced(r.TRIANGLES,0,Gl,this._rectCount),r.bindVertexArray(null));}destroy(){let e=this._gl;e.deleteVertexArray(this._vao),e.deleteBuffer(this._vbo),e.deleteProgram(this._program);}},Bt=new WeakMap;function zn(n){return Bt.get(n)??null}function Hn(n,e){let t=Bt.get(n);return t===void 0&&(t=new li(e),Bt.set(n,t)),t}function Gn(n){let e=Bt.get(n);e!==void 0&&(e.destroy(),Bt.delete(n));}function Xn(n){let{style:e,color:t,borderRadius:r,borderSize:i,borderColor:o}=n;return !(e!==void 0&&e!=="fill"||typeof t!="string"||t==="transparent"||t===""||r!==void 0&&r!==0||i!==void 0&&i>0&&typeof o=="string"&&o!=="transparent")}var Xe=class extends K{eachChildren(e){let r=this.getWidget().getPane().getChart().getChartStore(),i=r.getVisibleRangeDataList(),o=r.getBarSpace(),a=i.length,s=0;for(;s<a;)e(i[s],o,s),++s;}};function Un(n,e,t){let r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){let i=n.getShaderInfoLog(r)??"unknown";throw n.deleteShader(r),new Error(`[CandleWebGLRenderer] shader compile error: ${i}`)}return r}function Zl(n){let e=Un(n,n.VERTEX_SHADER,In),t=Un(n,n.FRAGMENT_SHADER,Dn),r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.deleteShader(e),n.deleteShader(t),!n.getProgramParameter(r,n.LINK_STATUS))throw new Error(`[CandleWebGLRenderer] program link error: ${n.getProgramInfoLog(r)??"unknown"}`);return r}var ci=class{_gl;_canvas;_program;_vao;_vbo;_uPriceFrom;_uPriceRange;_uResolution;_uPixelRatio;_uBarHalfWidth;_uRenderMode;_uOhlcHalfSize;_uPanOffset;_capacity=0;_barCount=0;_stagingBuf=new ArrayBuffer(512*32);_stagingF32=new Float32Array(this._stagingBuf);_stagingU8=new Uint8Array(this._stagingBuf);_singleBarBuf=new ArrayBuffer(32);_singleBarF32=new Float32Array(this._singleBarBuf);_singleBarU8=new Uint8Array(this._singleBarBuf);_colorCache=new Map;_fingerprintBarCount=-1;_fingerprintFirstX=0;_fingerprintLastX=0;_fingerprintLastClose=0;_fingerprintLastBodyColor="";_fingerprintFirstOpen=NaN;_fingerprintFirstClose=NaN;_fingerprintBarStep=0;_panOffsetCss=0;_vboVersion=0;_drawnVersion=-1;_lastPriceFrom=NaN;_lastPriceRange=NaN;_lastBarHalfWidth=NaN;_lastRenderMode=-1;_lastOhlcHalfSize=NaN;_vboFirstDataIdx=-1;_vboLastDataIdx=-1;_vboBar0X=0;_vboBarStep=0;_drawStartOffset=0;_visibleBarCount=0;_lastDrawStartOffset=-1;_canvasWidthCss=0;_lodActive=false;_lodBuf=[];_timerExt=null;_timerQuery=null;_timerQueryActive=false;constructor(e){let t=document.createElement("canvas");t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.zIndex="1",t.style.pointerEvents="none",e.appendChild(t),this._canvas=t;let r=t.getContext("webgl2",{antialias:false,premultipliedAlpha:false,preserveDrawingBuffer:true,powerPreference:"high-performance",alpha:true});if(r===null)throw new Error("[CandleWebGLRenderer] WebGL2 unavailable");if(this._gl=r,r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.disable(r.DEPTH_TEST),r.enable(r.SCISSOR_TEST),this._program=Zl(r),r.useProgram(this._program),this._uPriceFrom=r.getUniformLocation(this._program,"u_priceFrom"),this._uPriceRange=r.getUniformLocation(this._program,"u_priceRange"),this._uResolution=r.getUniformLocation(this._program,"u_resolution"),this._uPixelRatio=r.getUniformLocation(this._program,"u_pixelRatio"),this._uRenderMode=r.getUniformLocation(this._program,"u_renderMode"),this._uOhlcHalfSize=r.getUniformLocation(this._program,"u_ohlcHalfSize"),this._uBarHalfWidth=r.getUniformLocation(this._program,"u_barHalfWidth"),this._uPanOffset=r.getUniformLocation(this._program,"u_panOffset"),this._vao=r.createVertexArray(),r.bindVertexArray(this._vao),this._vbo=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,this._vbo),this._setupAttribs(r),r.bindVertexArray(null),import.meta.env?.DEV){let i=r.getExtension("EXT_disjoint_timer_query_webgl2");i!==null&&(this._timerExt=i,this._timerQuery=r.createQuery());}}_parseColorCached(e){return Be(e,this._colorCache)}_packColor(e,t,r){Rr(e,t,r);}_writeBarIntoViews(e,t,r,i,o){t[i+0]=e.centerX-this._panOffsetCss,t[i+1]=e.open,t[i+2]=e.high,t[i+3]=e.low,t[i+4]=e.close,this._packColor(this._parseColorCached(e.wickColor),r,o+20),this._packColor(this._parseColorCached(e.bodyColor),r,o+20+4),this._packColor(this._parseColorCached(e.borderColor),r,o+20+8);}_setupAttribs(e){this._rebindAttribsWithOffset(e,0);}_rebindAttribsWithOffset(e,t){let r=this._program,i=32,o=(s,l)=>{let c=e.getAttribLocation(r,s);c<0||(e.enableVertexAttribArray(c),e.vertexAttribPointer(c,1,e.FLOAT,false,i,t+l),e.vertexAttribDivisor(c,1));},a=(s,l)=>{let c=e.getAttribLocation(r,s);c<0||(e.enableVertexAttribArray(c),e.vertexAttribPointer(c,4,e.UNSIGNED_BYTE,true,i,t+l),e.vertexAttribDivisor(c,1));};o("a_centerX",0),o("a_open",4),o("a_high",8),o("a_low",12),o("a_close",16),a("a_wickColor",20),a("a_bodyColor",24),a("a_borderColor",28);}resize(e,t){this._canvasWidthCss=e;let r=X(this._canvas),i=Math.round(e*r),o=Math.round(t*r);this._canvas.width===i&&this._canvas.height===o||(this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._canvas.width=i,this._canvas.height=o,this._vboVersion++);}_applyLod(e,t){for(;this._lodBuf.length<t;)this._lodBuf.push({centerX:0,open:0,high:0,low:0,close:0,wickColor:"",bodyColor:"",borderColor:""});let r=e.length,i=r/t;for(let o=0;o<t;o++){let a=Math.floor(o*i),s=Math.min(Math.floor((o+1)*i)-1,r-1),l=e[a],c=e[s],u=l.high,d=l.low;for(let m=a+1;m<=s;m++){let p=e[m];p.high>u&&(u=p.high),p.low<d&&(d=p.low);}let h=this._lodBuf[o];h.centerX=l.centerX,h.open=l.open,h.high=u,h.low=d,h.close=c.close,h.wickColor=c.wickColor,h.bodyColor=c.bodyColor,h.borderColor=c.borderColor;}}_ensureCapacity(e){if(e<=this._capacity)return;let t=Math.max(e,this._capacity*2,512);this._stagingBuf=new ArrayBuffer(t*32),this._stagingF32=new Float32Array(this._stagingBuf),this._stagingU8=new Uint8Array(this._stagingBuf);let r=this._gl;r.bindBuffer(r.ARRAY_BUFFER,this._vbo),r.bufferData(r.ARRAY_BUFFER,t*32,r.DYNAMIC_DRAW),this._capacity=t;}setData(e,t=0,r=e.length){let o,a=Math.min(r,e.length-t);if(this._canvasWidthCss>0&&a>this._canvasWidthCss*1.5){let f=Math.max(1,Math.floor(this._canvasWidthCss)),y=t===0&&a===e.length?e:e.slice(t,t+a);this._applyLod(y,f),o=this._lodBuf,this._lodActive=true;}else o=e,this._lodActive=false;let s=o.length;if(this._barCount=s,s===0){this._fingerprintBarCount=0;let f=this._gl;f.clearColor(0,0,0,0),f.clear(f.COLOR_BUFFER_BIT);return}let l=this._lodActive?0:t,c=this._lodActive?s:Math.min(r,s-t);if(c===0){this._fingerprintBarCount=0;return}let u=o[l],d=o[l+c-1],h=c>=2?o[l+1].centerX-u.centerX:this._fingerprintBarStep;this._panOffsetCss=0,this._fingerprintBarCount=c,this._fingerprintFirstX=u.centerX,this._fingerprintLastX=d.centerX,this._fingerprintLastClose=d.close,this._fingerprintLastBodyColor=d.bodyColor,this._fingerprintFirstOpen=u.open,this._fingerprintFirstClose=u.close,this._fingerprintBarStep=h,this._vboFirstDataIdx=o[0].dataIndex??-1,this._vboLastDataIdx=o[s-1].dataIndex??-1,this._vboBar0X=o[0].centerX,this._vboBarStep=h,this._drawStartOffset=this._lodActive?0:t,this._visibleBarCount=this._lodActive?s:c,this._ensureCapacity(s);let m=this._stagingF32,p=this._stagingU8;for(let f=0;f<s;f++)this._writeBarIntoViews(o[f],m,p,f<<3,f*32);let g=this._gl;g.bindBuffer(g.ARRAY_BUFFER,this._vbo),g.bufferSubData(g.ARRAY_BUFFER,0,this._stagingU8,0,s*32),this._vboVersion++;}updateLastBar(e){if(this._barCount===0||this._lodActive)return;this._fingerprintLastClose=e.close,this._writeBarIntoViews(e,this._singleBarF32,this._singleBarU8,0,0);let t=this._gl;t.bindBuffer(t.ARRAY_BUFFER,this._vbo);let r=this._visibleBarCount>0?this._drawStartOffset+this._visibleBarCount-1:this._barCount-1;t.bufferSubData(t.ARRAY_BUFFER,r*32,this._singleBarBuf),this._vboVersion++;}draw(e,t,r,i=0,o=0){if(this._barCount===0||this._vboVersion===this._drawnVersion&&e===this._lastPriceFrom&&t===this._lastPriceRange&&r===this._lastBarHalfWidth&&i===this._lastRenderMode&&o===this._lastOhlcHalfSize)return;this._drawnVersion=this._vboVersion,this._lastPriceFrom=e,this._lastPriceRange=t,this._lastBarHalfWidth=r,this._lastRenderMode=i,this._lastOhlcHalfSize=o;let a=this._gl,s=X(this._canvas),l=this._canvas.width,c=this._canvas.height;if(this._timerExt!==null&&this._timerQuery!==null){if(this._timerQueryActive&&!a.getParameter(this._timerExt.GPU_DISJOINT_EXT)&&a.getQueryParameter(this._timerQuery,a.QUERY_RESULT_AVAILABLE)){let g=a.getQueryParameter(this._timerQuery,a.QUERY_RESULT)/1e6;g>4&&console.warn(`[CandleWebGLRenderer] GPU frame ${g.toFixed(2)} ms (budget: 4 ms @ 60 fps)`);}a.beginQuery(this._timerExt.TIME_ELAPSED_EXT,this._timerQuery),this._timerQueryActive=true;}a.viewport(0,0,l,c),a.scissor(0,0,l,c),a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),a.useProgram(this._program),a.uniform1f(this._uPriceFrom,e),a.uniform1f(this._uPriceRange,t),a.uniform2f(this._uResolution,l,c),a.uniform1f(this._uPixelRatio,s),a.uniform1f(this._uBarHalfWidth,r),a.uniform1i(this._uRenderMode,i),a.uniform1f(this._uOhlcHalfSize,o),a.uniform1f(this._uPanOffset,this._panOffsetCss),a.bindVertexArray(this._vao);let u=this._drawStartOffset*32;this._drawStartOffset!==this._lastDrawStartOffset&&(a.bindBuffer(a.ARRAY_BUFFER,this._vbo),this._rebindAttribsWithOffset(a,u),this._lastDrawStartOffset=this._drawStartOffset);let d=this._visibleBarCount>0?this._visibleBarCount:this._barCount;a.drawArraysInstanced(a.TRIANGLES,0,18,d),a.bindVertexArray(null),this._timerExt!==null&&this._timerQuery!==null&&this._timerQueryActive&&a.endQuery(this._timerExt.TIME_ELAPSED_EXT);}destroy(){let e=this._gl;this._timerQuery!==null&&e.deleteQuery(this._timerQuery),e.deleteVertexArray(this._vao),e.deleteBuffer(this._vbo),e.deleteProgram(this._program),e.getExtension("WEBGL_lose_context")?.loseContext(),this._canvas.remove();}static isSupported(){return ve.isSupported()}},kr=new WeakMap;function $n(n,e){if(!ve.isSupported())return null;let t=kr.get(n);if(t===void 0)try{t=new ci(e),kr.set(n,t);}catch{return null}return t}function Fr(n){let e=kr.get(n);e!==void 0&&(e.destroy(),kr.delete(n));}var Vt=null,Nt=null;async function Ql(){return Vt!==null&&!Vt.lost?Vt:(Nt!==null||(Nt=(async()=>{let n=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(n===null)throw new Error("[CandleWebGPURenderer] No GPU adapter");let e=[];n.features.has("timestamp-query")&&e.push("timestamp-query");let t=await n.requestDevice({requiredFeatures:e});return t.lost.then(()=>{Vt=null,Nt=null;}).catch(()=>{}),Vt=t,t})()),Nt)}var Kl=`
|
|
270
|
+
struct Uniforms {
|
|
271
|
+
priceFrom : f32,
|
|
272
|
+
priceRange : f32,
|
|
273
|
+
resolutionX : f32,
|
|
274
|
+
resolutionY : f32,
|
|
275
|
+
pixelRatio : f32,
|
|
276
|
+
barHalfWidth : f32,
|
|
277
|
+
renderMode : u32, // 0 = candle, 1 = ohlc
|
|
278
|
+
ohlcHalfSize : f32,
|
|
279
|
+
panOffset : f32,
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@group(0) @binding(0) var<uniform> u : Uniforms;
|
|
283
|
+
|
|
284
|
+
struct InstanceIn {
|
|
285
|
+
@location(0) centerX : f32,
|
|
286
|
+
@location(1) open : f32,
|
|
287
|
+
@location(2) high : f32,
|
|
288
|
+
@location(3) low : f32,
|
|
289
|
+
@location(4) close : f32,
|
|
290
|
+
@location(5) wickColor : vec4<f32>, // normalised [0,1]
|
|
291
|
+
@location(6) bodyColor : vec4<f32>,
|
|
292
|
+
@location(7) borderColor : vec4<f32>,
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
struct VertOut {
|
|
296
|
+
@builtin(position) pos : vec4<f32>,
|
|
297
|
+
@location(0) color : vec4<f32>,
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Unit-quad vertex for a 2-triangle (6-vert) quad.
|
|
301
|
+
fn unitQuad(id: u32) -> vec2<f32> {
|
|
302
|
+
switch id {
|
|
303
|
+
case 0u: { return vec2(0.0, 0.0); }
|
|
304
|
+
case 1u: { return vec2(1.0, 0.0); }
|
|
305
|
+
case 2u: { return vec2(0.0, 1.0); }
|
|
306
|
+
case 3u: { return vec2(0.0, 1.0); }
|
|
307
|
+
case 4u: { return vec2(1.0, 0.0); }
|
|
308
|
+
default: { return vec2(1.0, 1.0); }
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
fn priceToPhysY(price: f32) -> f32 {
|
|
313
|
+
let rate = (price - u.priceFrom) / u.priceRange;
|
|
314
|
+
return (1.0 - rate) * u.resolutionY;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
fn physToNdc(x: f32, y: f32) -> vec4<f32> {
|
|
318
|
+
return vec4(
|
|
319
|
+
x / u.resolutionX * 2.0 - 1.0,
|
|
320
|
+
1.0 - y / u.resolutionY * 2.0,
|
|
321
|
+
0.0, 1.0
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@vertex
|
|
326
|
+
fn vs_main(inst: InstanceIn, @builtin(vertex_index) vid: u32) -> VertOut {
|
|
327
|
+
let isWick = vid < 6u;
|
|
328
|
+
let isBodyOuter = vid >= 6u && vid < 12u;
|
|
329
|
+
|
|
330
|
+
let localId = select(select(vid - 12u, vid - 6u, vid < 12u), vid, vid < 6u);
|
|
331
|
+
let unit = unitQuad(localId);
|
|
332
|
+
|
|
333
|
+
let highY = priceToPhysY(inst.high);
|
|
334
|
+
let lowY = priceToPhysY(inst.low);
|
|
335
|
+
let openY = priceToPhysY(inst.open);
|
|
336
|
+
let closeY = priceToPhysY(inst.close);
|
|
337
|
+
|
|
338
|
+
let pr = u.pixelRatio;
|
|
339
|
+
let cx = (inst.centerX + u.panOffset) * pr;
|
|
340
|
+
let bhw = u.barHalfWidth * pr;
|
|
341
|
+
|
|
342
|
+
var screenX : f32;
|
|
343
|
+
var screenY : f32;
|
|
344
|
+
var color : vec4<f32>;
|
|
345
|
+
|
|
346
|
+
if u.renderMode == 1u {
|
|
347
|
+
// OHLC mode
|
|
348
|
+
let ohw = u.ohlcHalfSize * pr;
|
|
349
|
+
let tickH = ohw * 2.0;
|
|
350
|
+
if isWick {
|
|
351
|
+
screenX = cx - ohw + unit.x * ohw * 2.0;
|
|
352
|
+
screenY = highY + (lowY - highY) * unit.y;
|
|
353
|
+
color = inst.bodyColor;
|
|
354
|
+
} else if isBodyOuter {
|
|
355
|
+
let left = cx - bhw;
|
|
356
|
+
let right = cx - ohw;
|
|
357
|
+
screenX = left + unit.x * max(right - left, 0.0);
|
|
358
|
+
screenY = openY + unit.y * tickH;
|
|
359
|
+
color = inst.bodyColor;
|
|
360
|
+
} else {
|
|
361
|
+
let left = cx + ohw;
|
|
362
|
+
let right = cx + bhw;
|
|
363
|
+
screenX = left + unit.x * max(right - left, 0.0);
|
|
364
|
+
screenY = closeY + unit.y * tickH;
|
|
365
|
+
color = inst.bodyColor;
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
// Candle mode (solid / stroke)
|
|
369
|
+
var bodyTop = min(openY, closeY);
|
|
370
|
+
var bodyBottom = max(openY, closeY);
|
|
371
|
+
bodyBottom = max(bodyBottom, bodyTop + 1.0);
|
|
372
|
+
|
|
373
|
+
if isWick {
|
|
374
|
+
screenX = cx - 0.5 + unit.x;
|
|
375
|
+
screenY = highY + (lowY - highY) * unit.y;
|
|
376
|
+
color = inst.wickColor;
|
|
377
|
+
} else if isBodyOuter {
|
|
378
|
+
screenX = cx - bhw + unit.x * bhw * 2.0;
|
|
379
|
+
screenY = bodyTop + (bodyBottom - bodyTop) * unit.y;
|
|
380
|
+
color = inst.borderColor;
|
|
381
|
+
} else {
|
|
382
|
+
let inset = 1.0;
|
|
383
|
+
let innerHW = max(bhw - inset, 0.5);
|
|
384
|
+
screenX = cx - innerHW + unit.x * innerHW * 2.0;
|
|
385
|
+
let innerTop = bodyTop + inset;
|
|
386
|
+
let innerBottom = max(bodyBottom - inset, innerTop);
|
|
387
|
+
screenY = innerTop + (innerBottom - innerTop) * unit.y;
|
|
388
|
+
color = inst.bodyColor;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return VertOut(physToNdc(screenX, screenY), color);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
@fragment
|
|
396
|
+
fn fs_main(@location(0) color: vec4<f32>) -> @location(0) vec4<f32> {
|
|
397
|
+
return color;
|
|
398
|
+
}
|
|
399
|
+
`,qn=false,Lr=false,Br=null;async function Jl(){return qn?Lr:(Br!==null||(Br=(async()=>{try{if(!("gpu"in navigator))return !1;Lr=await navigator.gpu.requestAdapter()!==null;}catch{Lr=false;}return qn=true,Lr})()),Br)}var Wt=new WeakMap,ui=new WeakMap,di=new WeakSet;function Zn(n){return Wt.get(n)??null}async function Qn(n,e){if(di.has(n))return null;let t=Wt.get(n);if(t!==void 0)return t;let r=ui.get(n);if(r!==void 0)return r;let i=hi.create(e).then(o=>di.has(n)?(o.destroy(),null):(Wt.set(n,o),o)).catch(()=>null).finally(()=>{ui.delete(n);});return ui.set(n,i),i}function Kn(n){di.add(n);let e=Wt.get(n);e!==void 0&&(e.destroy(),Wt.delete(n));}var jn=48,hi=class n{_canvas;_context;_device;_pipeline;_uniformBuffer;_uniformBindGroup;_instanceBuffer=null;_instanceCapacity=0;_stagingBuf=new ArrayBuffer(512*32);_stagingF32=new Float32Array(this._stagingBuf);_stagingU8=new Uint8Array(this._stagingBuf);_singleBarBuf=new ArrayBuffer(32);_singleBarF32=new Float32Array(this._singleBarBuf);_singleBarU8=new Uint8Array(this._singleBarBuf);_uniformData=new ArrayBuffer(jn);_uniformF32=new Float32Array(this._uniformData);_uniformU32=new Uint32Array(this._uniformData);_colorCache=new Map;_barCount=0;_fingerprintBarCount=-1;_fingerprintFirstX=0;_fingerprintLastX=0;_fingerprintLastClose=0;_fingerprintLastBodyColor="";_fingerprintFirstOpen=NaN;_fingerprintFirstClose=NaN;_fingerprintBarStep=0;_panOffsetCss=0;_vboVersion=0;_drawnVersion=-1;_lastPriceFrom=NaN;_lastPriceRange=NaN;_lastBarHalfWidth=NaN;_lastRenderMode=-1;_lastOhlcHalfSize=NaN;_canvasWidthCss=0;_lodActive=false;_lodBuf=[];_renderBundle=null;_bundleVboVersion=-1;_indirectBuffer=null;_tsQuerySet=null;_tsResolveBuffer=null;_tsReadbackBuffer=null;_tsSampleCount=0;_tsTotalNs=0;_tsCanQuery=false;constructor(e,t,r,i,o,a){this._canvas=e,this._context=t,this._device=r,this._pipeline=i,this._uniformBuffer=o,this._uniformBindGroup=a,this._indirectBuffer=r.createBuffer({size:16,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_DST});try{this._tsQuerySet=r.createQuerySet({type:"timestamp",count:2}),this._tsResolveBuffer=r.createBuffer({size:16,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this._tsReadbackBuffer=r.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),this._tsCanQuery=!0;}catch{}}static async create(e){if(!("gpu"in navigator))throw new Error("[CandleWebGPURenderer] WebGPU not supported");let t=await Ql(),r=document.createElement("canvas");r.style.cssText="position:absolute;top:0;left:0;z-index:1;pointer-events:none;",e.appendChild(r);let i=null;try{let o=r.getContext("webgpu");if(o===null)throw new Error("[CandleWebGPURenderer] Cannot get WebGPU canvas context");let a=navigator.gpu.getPreferredCanvasFormat();o.configure({device:t,format:a,alphaMode:"premultiplied"}),i=t.createBuffer({size:jn,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});let s=t.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}}]}),l=t.createBindGroup({layout:s,entries:[{binding:0,resource:{buffer:i}}]}),c=t.createShaderModule({code:Kl}),u={arrayStride:32,stepMode:"instance",attributes:[{shaderLocation:0,offset:0,format:"float32"},{shaderLocation:1,offset:4,format:"float32"},{shaderLocation:2,offset:8,format:"float32"},{shaderLocation:3,offset:12,format:"float32"},{shaderLocation:4,offset:16,format:"float32"},{shaderLocation:5,offset:20,format:"unorm8x4"},{shaderLocation:6,offset:24,format:"unorm8x4"},{shaderLocation:7,offset:28,format:"unorm8x4"}]},d=t.createRenderPipeline({layout:t.createPipelineLayout({bindGroupLayouts:[s]}),vertex:{module:c,entryPoint:"vs_main",buffers:[u]},fragment:{module:c,entryPoint:"fs_main",targets:[{format:a,blend:{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list"}});return new n(r,o,t,d,i,l)}catch(o){throw i?.destroy(),r.remove(),o}}static async isSupported(){return Jl()}resize(e,t){if(this._canvasWidthCss===e&&this._canvas.style.width===`${e}px`)return;this._canvasWidthCss=e;let r=X(this._canvas),i=Math.round(e*r),o=Math.round(t*r);this._canvas.width===i&&this._canvas.height===o||(this._canvas.width=i,this._canvas.height=o,this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`,this._vboVersion++);}_parseColorCached(e){return Be(e,this._colorCache)}_packColor(e,t,r){Rr(e,t,r);}_writeBarIntoViews(e,t,r,i,o){t[i+0]=e.centerX-this._panOffsetCss,t[i+1]=e.open,t[i+2]=e.high,t[i+3]=e.low,t[i+4]=e.close,this._packColor(this._parseColorCached(e.wickColor),r,o+20),this._packColor(this._parseColorCached(e.bodyColor),r,o+20+4),this._packColor(this._parseColorCached(e.borderColor),r,o+20+8);}_applyLod(e,t){for(;this._lodBuf.length<t;)this._lodBuf.push({centerX:0,open:0,high:0,low:0,close:0,wickColor:"",bodyColor:"",borderColor:""});let r=e.length,i=r/t;for(let o=0;o<t;o++){let a=Math.floor(o*i),s=Math.min(Math.floor((o+1)*i)-1,r-1),l=e[a],c=e[s],u=l.high,d=l.low;for(let m=a+1;m<=s;m++)e[m].high>u&&(u=e[m].high),e[m].low<d&&(d=e[m].low);let h=this._lodBuf[o];h.centerX=l.centerX,h.open=l.open,h.high=u,h.low=d,h.close=c.close,h.wickColor=c.wickColor,h.bodyColor=c.bodyColor,h.borderColor=c.borderColor;}}_ensureInstanceBuffer(e){if(this._instanceBuffer!==null&&e<=this._instanceCapacity)return this._instanceBuffer;let t=Math.max(e,this._instanceCapacity*2,512);this._instanceBuffer?.destroy();let r=t*32;return this._instanceBuffer=this._device.createBuffer({size:r+3&-4,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),this._instanceCapacity=t,this._stagingBuf=new ArrayBuffer(t*32),this._stagingF32=new Float32Array(this._stagingBuf),this._stagingU8=new Uint8Array(this._stagingBuf),this._instanceBuffer}setData(e){let r;if(this._canvasWidthCss>0&&e.length>this._canvasWidthCss*1.5){let u=Math.max(1,Math.floor(this._canvasWidthCss));this._applyLod(e,u),r=this._lodBuf,this._lodActive=true;}else r=e,this._lodActive=false;let i=r.length;if(this._barCount=i,i===0){this._fingerprintBarCount=0,this._clear();return}let o=r[0],a=r[i-1],s=i>=2?r[1].centerX-o.centerX:this._fingerprintBarStep;this._panOffsetCss=0,this._fingerprintBarCount=i,this._fingerprintFirstX=o.centerX,this._fingerprintLastX=a.centerX,this._fingerprintLastClose=a.close,this._fingerprintLastBodyColor=a.bodyColor,this._fingerprintFirstOpen=o.open,this._fingerprintFirstClose=o.close,this._fingerprintBarStep=s,this._ensureInstanceBuffer(i);let l=this._stagingF32,c=this._stagingU8;for(let u=0;u<i;u++)this._writeBarIntoViews(r[u],l,c,u<<3,u*32);if(this._device.queue.writeBuffer(this._instanceBuffer,0,this._stagingBuf,0,i*32),this._indirectBuffer!==null){let u=new Uint32Array([18,i,0,0]);this._device.queue.writeBuffer(this._indirectBuffer,0,u);}this._renderBundle=null,this._vboVersion++;}updateLastBar(e){this._barCount===0||this._lodActive||this._instanceBuffer===null||(this._fingerprintLastClose=e.close,this._writeBarIntoViews(e,this._singleBarF32,this._singleBarU8,0,0),this._device.queue.writeBuffer(this._instanceBuffer,(this._barCount-1)*32,this._singleBarBuf),this._renderBundle=null,this._vboVersion++);}_clear(){let e=this._device.createCommandEncoder();e.beginRenderPass({colorAttachments:[{view:this._context.getCurrentTexture().createView(),loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0},storeOp:"store"}]}).end(),this._device.queue.submit([e.finish()]),this._drawnVersion=this._vboVersion;}draw(e,t,r,i=0,o=0){if(this._barCount===0||this._instanceBuffer===null||this._vboVersion===this._drawnVersion&&e===this._lastPriceFrom&&t===this._lastPriceRange&&r===this._lastBarHalfWidth&&i===this._lastRenderMode&&o===this._lastOhlcHalfSize)return;this._drawnVersion=this._vboVersion,this._lastPriceFrom=e,this._lastPriceRange=t,this._lastBarHalfWidth=r,this._lastRenderMode=i,this._lastOhlcHalfSize=o;let a=X(this._canvas),s=this._canvas.width,l=this._canvas.height;if(this._uniformF32[0]=e,this._uniformF32[1]=t,this._uniformF32[2]=s,this._uniformF32[3]=l,this._uniformF32[4]=a,this._uniformF32[5]=r,this._uniformU32[6]=i,this._uniformF32[7]=o,this._uniformF32[8]=this._panOffsetCss,this._device.queue.writeBuffer(this._uniformBuffer,0,this._uniformData),!(this._renderBundle!==null&&this._bundleVboVersion===this._vboVersion))try{let m=this._context.getCurrentTexture().format,p=this._device.createRenderBundleEncoder({colorFormats:[m]});p.setPipeline(this._pipeline),p.setBindGroup(0,this._uniformBindGroup),p.setVertexBuffer(0,this._instanceBuffer),this._indirectBuffer!==null?p.drawIndirect(this._indirectBuffer,0):p.draw(18,this._barCount,0,0),this._renderBundle=p.finish(),this._bundleVboVersion=this._vboVersion;}catch{this._renderBundle=null;}let u=this._device.createCommandEncoder(),d=this._tsCanQuery&&this._tsQuerySet!==null?{querySet:this._tsQuerySet,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}:void 0,h=u.beginRenderPass({colorAttachments:[{view:this._context.getCurrentTexture().createView(),loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0},storeOp:"store"}],...d!==void 0?{timestampWrites:d}:{}});if(this._renderBundle!==null?h.executeBundles([this._renderBundle]):(h.setPipeline(this._pipeline),h.setBindGroup(0,this._uniformBindGroup),h.setVertexBuffer(0,this._instanceBuffer),this._indirectBuffer!==null?h.drawIndirect(this._indirectBuffer,0):h.draw(18,this._barCount,0,0)),h.end(),this._tsCanQuery&&this._tsQuerySet!==null&&this._tsResolveBuffer!==null&&this._tsReadbackBuffer!==null&&(u.resolveQuerySet(this._tsQuerySet,0,2,this._tsResolveBuffer,0),u.copyBufferToBuffer(this._tsResolveBuffer,0,this._tsReadbackBuffer,0,16)),this._device.queue.submit([u.finish()]),this._tsCanQuery&&this._tsReadbackBuffer!==null){let m=this._tsReadbackBuffer;m.mapAsync(GPUMapMode.READ).then(()=>{try{let p=new BigUint64Array(m.getMappedRange()),g=Number(p[1]-p[0]);this._tsTotalNs+=g,this._tsSampleCount++;}finally{m.unmap();}}).catch(()=>{});}}getAverageGpuMs(){return this._tsSampleCount===0?0:this._tsTotalNs/this._tsSampleCount/1e6}resetGpuMetrics(){this._tsTotalNs=0,this._tsSampleCount=0;}destroy(){this._instanceBuffer?.destroy(),this._uniformBuffer.destroy(),this._indirectBuffer?.destroy();try{this._tsQuerySet?.destroy();}catch{}try{this._tsResolveBuffer?.destroy();}catch{}try{this._tsReadbackBuffer?.destroy();}catch{}this._canvas.remove();}};var ec=131072,mi=class{_pool;_cursor=0;constructor(){this._pool=[];for(let e=0;e<ec;e++)this._pool.push({dataIndex:0,centerX:0,open:0,high:0,low:0,close:0,wickColor:"",bodyColor:"",borderColor:""});}reset(){this._cursor=0;}alloc(){return this._cursor>=this._pool.length&&this._pool.push({dataIndex:0,centerX:0,open:0,high:0,low:0,close:0,wickColor:"",bodyColor:"",borderColor:""}),this._pool[this._cursor++]}},$e=class extends Xe{_boundCandleBarClickEvent=e=>()=>(this.getWidget().getPane().getChart().getChartStore().executeAction("onCandleBarClick",e),false);_barPool=new mi;_webGPUInitStarted=false;_webGPUActive=false;_drawWithWebGL(e){let{type:t,styles:r}=e,i=this.getWidget(),o=i.getPane(),a=o.getChart().getChartStore(),s=Zn(i);s===null&&!this._webGPUInitStarted&&(this._webGPUInitStarted=true,Qn(i,i.getContainer()).catch(()=>{}));let l=null,c=null;if(s!==null)l=s,this._webGPUActive||(this._webGPUActive=true,Fr(i));else {if(c=$n(i,i.getContainer()),c===null)return false;l=c;}let{width:u,height:d}=i.getBounding();l.resize(u,d);let h="rgba(0,0,0,0)",m=a.getVisibleRangeDataList(),p=a.getBarSpace(),g=this._barPool;g.reset();let f=[],y=(D,E,M,F)=>{let{open:W,high:H,low:Y,close:N}=M,O=r.compareRule==="current_open"?W:F??N,ee,U,$;N>O?(ee=r.upWickColor,U=r.upColor,$=r.upBorderColor):N<O?(ee=r.downWickColor,U=r.downColor,$=r.downBorderColor):(ee=r.noChangeWickColor,U=r.noChangeColor,$=r.noChangeBorderColor),(t==="candle_stroke"||t==="candle_up_stroke"&&N>W||t==="candle_down_stroke"&&W>N)&&(U=h);let Z=g.alloc();return Z.dataIndex=D,Z.centerX=E,Z.open=W,Z.high=H,Z.low=Y,Z.close=N,Z.wickColor=ee,Z.bodyColor=U,Z.borderColor=$,Z},v=64,b=0;if(c!==null&&m.length>0){let D=a.getDataList(),E=m[0];m[m.length-1];let F=Math.min(v,E.dataIndex);for(let W=F;W>=1;W--){let H=E.dataIndex-W,Y=D[H];if(!_(Y))continue;let N=H>0?D[H-1]:null,O=E.x-W*p.gapBar;f.push(y(H,O,Y,N?.close));}b=f.length;}let S=f.length;for(let D of m){let{x:E,dataIndex:M,data:{current:F,prev:W}}=D;_(F)&&f.push(y(M,E,F,W?.close));}let x=f.length-S;if(c!==null&&m.length>0){let D=a.getDataList(),E=m[m.length-1],M=Math.min(v,D.length-1-E.dataIndex);for(let F=1;F<=M;F++){let W=E.dataIndex+F,H=D[W];if(!_(H))continue;let Y=D[W-1]??null,N=E.x+F*p.gapBar;f.push(y(W,N,H,Y?.close));}}let T=o.getAxisComponent().getDisplayRange(),A=T.realFrom,P=T.realTo-T.realFrom,I=0,R=0;if(t==="ohlc"){I=1;let{gapBar:D}=p,E=Math.min(Math.max(Math.round(D*.2),1),8);E>2&&E%2===1&&E--,R=Math.floor(E/2);}return c!==null?c.setData(f,b,x):l.setData(f),l.draw(A,P,p.halfGapBar,I,R),true}drawImp(e){let t=this.getWidget().getPane(),r=t.getId()===B.CANDLE,i=t.getChart().getChartStore(),o=this.getCandleBarOptions();if(o!==null){if(this._drawWithWebGL(o))return;let{type:a,styles:s}=o,l=0,c=0;if(o.type==="ohlc"){let{gapBar:d}=i.getBarSpace();l=Math.min(Math.max(Math.round(d*.2),1),8),l>2&&l%2===1&&l--,c=Math.floor(l/2);}let u=t.getAxisComponent();this.eachChildren((d,h)=>{let{x:m,data:{current:p,prev:g}}=d;if(_(p)){let{open:f,high:y,low:v,close:b}=p,S=s.compareRule==="current_open"?f:g?.close??b,x=[];b>S?(x[0]=s.upColor,x[1]=s.upBorderColor,x[2]=s.upWickColor):b<S?(x[0]=s.downColor,x[1]=s.downBorderColor,x[2]=s.downWickColor):(x[0]=s.noChangeColor,x[1]=s.noChangeBorderColor,x[2]=s.noChangeWickColor);let C=u.convertToPixel(f),T=u.convertToPixel(b),A=[C,T,u.convertToPixel(y),u.convertToPixel(v)];A.sort((R,D)=>R-D);let P=h.gapBar%2===0?1:0,I=[];switch(a){case "candle_solid":{I=this._createSolidBar(m,A,h,x,P);break}case "candle_stroke":{I=this._createStrokeBar(m,A,h,x,P);break}case "candle_up_stroke":{b>f?I=this._createStrokeBar(m,A,h,x,P):I=this._createSolidBar(m,A,h,x,P);break}case "candle_down_stroke":{f>b?I=this._createStrokeBar(m,A,h,x,P):I=this._createSolidBar(m,A,h,x,P);break}case "ohlc":{I=[{name:"rect",attrs:[{x:m-c,y:A[0],width:l,height:A[3]-A[0]},{x:m-h.halfGapBar,y:C+l>A[3]?A[3]-l:C,width:h.halfGapBar-c,height:l},{x:m+c,y:T+l>A[3]?A[3]-l:T,width:h.halfGapBar-c,height:l}],styles:{color:x[0]}}];break}}I.forEach(R=>{let D=null;r&&(D={mouseClickEvent:this._boundCandleBarClickEvent(d)}),this.createFigure(R,D??void 0)?.draw(e);});}});}}getCandleBarOptions(){let e=this.getWidget().getPane().getChart().getStyles().candle;return {type:e.type,styles:e.bar}}_createSolidBar(e,t,r,i,o){return [{name:"rect",attrs:{x:e,y:t[0],width:1,height:t[3]-t[0]},styles:{color:i[2]}},{name:"rect",attrs:{x:e-r.halfGapBar,y:t[1],width:r.gapBar+o,height:Math.max(1,t[2]-t[1])},styles:{style:"stroke_fill",color:i[0],borderColor:i[1]}}]}_createStrokeBar(e,t,r,i,o){return [{name:"rect",attrs:[{x:e,y:t[0],width:1,height:t[1]-t[0]},{x:e,y:t[2],width:1,height:t[3]-t[2]}],styles:{color:i[2]}},{name:"rect",attrs:{x:e-r.halfGapBar,y:t[1],width:r.gapBar+o,height:Math.max(1,t[2]-t[1])},styles:{style:"stroke",borderColor:i[1]}}]}};function tc(n){if(n.extendData===null||typeof n.extendData!="object")return null;let e=n.extendData[Bn];return e===null||typeof e!="object"?null:e}function rc(n,e,t){let r=n.getDataList(),i=n.getVisibleRange(),o=e.getRange(),a=Math.max(1,Math.floor(t.width)),s=Math.max(1,Math.floor(t.height)),l=Math.min(o.realFrom,o.realTo),c=Math.max(o.realFrom,o.realTo);if(r.length===0)return {priceMin:l,priceMax:c,timeMin:0,timeMax:0,resolution:[a,s]};let u=r.length-1,d=Math.min(u,Math.max(0,Math.floor(i.realFrom))),h=Math.min(r.length,Math.max(1,Math.ceil(i.realTo))),m=Math.min(u,Math.max(d,h-1)),p=Number(r[d]?.timestamp??0),g=Number(r[m]?.timestamp??p);return {priceMin:l,priceMax:c,timeMin:Math.min(p,g),timeMax:Math.max(p,g),resolution:[a,s]}}var Yt=class extends $e{getCandleBarOptions(){let e=this.getWidget().getPane();if(!e.getAxisComponent().isInCandle()){let r=e.getChart().getChartStore(),i=r.getIndicatorsByPaneId(e.getId());for(let o of i)if(o.shouldOhlc&&o.visible){let a=o.styles,s=r.getStyles().indicator,l=Q(a,"ohlc.compareRule",s.ohlc.compareRule),c=Q(a,"ohlc.upColor",s.ohlc.upColor),u=Q(a,"ohlc.downColor",s.ohlc.downColor),d=Q(a,"ohlc.noChangeColor",s.ohlc.noChangeColor);return {type:"ohlc",styles:{compareRule:l,upColor:c,downColor:u,noChangeColor:d,upBorderColor:c,downBorderColor:u,noChangeBorderColor:d,upWickColor:c,downWickColor:u,noChangeWickColor:d}}}}return null}drawImp(e){super.drawImp(e);let t=this.getWidget(),r=t.getPane(),i=r.getChart(),o=t.getBounding(),a=i.getXAxisPane().getAxisComponent(),s=r.getAxisComponent(),l=i.getChartStore(),c=l.getIndicatorsByPaneId(r.getId()),u=l.getStyles().indicator;if(c.some(x=>x.visible&&x.series==="volume")){let x=e.createLinearGradient(0,o.height,0,0);x.addColorStop(0,"rgba(46, 116, 255, 0.24)"),x.addColorStop(.45,"rgba(46, 116, 255, 0.08)"),x.addColorStop(1,"rgba(46, 116, 255, 0)"),e.save(),e.fillStyle=x,e.fillRect(0,0,o.width,o.height),e.restore();}let h=[],m=[],p=[],g;e.save(),c.forEach(x=>{if(x.visible){x.zLevel<0?e.globalCompositeOperation="destination-over":e.globalCompositeOperation="source-over";let C=false,T=tc(x),A=T?.renderGL;if(x.zLevel>=0&&q(A)&&(g===void 0&&(g=Vn(t,t.getContainer())),g!==null&&(p.push({indicatorId:x.id,indicator:x,output:Array.isArray(T.output)?T.output:[],runtimeData:T,renderGL:A}),C=true)),!C&&x.draw!==null&&(e.save(),C=x.draw({ctx:e,chart:i,indicator:x,bounding:o,xAxis:a,yAxis:s}),e.restore()),!C){let P=x.result,I=[];this.eachChildren((R,D)=>{let{halfGapBar:E}=D,{dataIndex:M,x:F}=R,W=a.convertToPixel(M-1),H=a.convertToPixel(M+1),Y=P[M-1]??null,N=P[M]??null,O=P[M+1]??null,ee={x:W},U={x:F},$={x:H};x.figures.forEach(({key:z})=>{let Z=Y?.[z];w(Z)&&(ee[z]=s.convertToPixel(Z));let le=N?.[z];w(le)&&(U[z]=s.convertToPixel(le));let _e=O?.[z];w(_e)&&($[z]=s.convertToPixel(_e));}),lt(x,M,u,(z,Z,le)=>{if(_(N?.[z.key])){let _e=U[z.key],pe=z.attrs?.({data:{prev:Y,current:N,next:O},coordinate:{prev:ee,current:U,next:$},bounding:o,barSpace:D,xAxis:a,yAxis:s});if(!_(pe))switch(z.type){case "circle":{pe={x:F,y:_e,r:Math.max(1,E)};break}case "rect":case "bar":{let it=z.baseValue??s.getRange().from,Oe=s.convertToPixel(it),ot=Math.abs(Oe-_e);it!==N?.[z.key]&&(ot=Math.max(1,ot));let ce=0;_e>Oe?ce=Oe:ce=_e,pe={x:F-E,y:ce,width:Math.max(1,E*2),height:ot};break}case "line":{_(I[le])||(I[le]=[]),Z.show!==false&&w(U[z.key])&&w($[z.key])&&I[le].push({coordinates:[{x:U.x,y:U[z.key]},{x:$.x,y:$[z.key]}],styles:Z});break}}let fe=z.type;_(pe)&&fe!=="line"&&(x.zLevel>=0&&x.series!=="volume"&&(fe==="rect"||fe==="bar")&&Xn(Z)?m.push({x:pe.x,y:pe.y,width:pe.width,height:pe.height,color:Z.color}):this.createFigure({name:fe==="bar"?"rect":fe,attrs:pe,styles:Z})?.draw(e));}});}),I.forEach(R=>{if(R.length>1){let D=[{coordinates:[R[0].coordinates[0],R[0].coordinates[1]],styles:R[0].styles}];for(let E=1;E<R.length;E++){let M=D[D.length-1],F=R[E],W=M.coordinates[M.coordinates.length-1];W.x===F.coordinates[0].x&&W.y===F.coordinates[0].y&&M.styles.style===F.styles.style&&M.styles.color===F.styles.color&&M.styles.size===F.styles.size&&M.styles.smooth===F.styles.smooth&&M.styles.dashedValue?.[0]===F.styles.dashedValue?.[0]&&M.styles.dashedValue?.[1]===F.styles.dashedValue?.[1]?M.coordinates.push(F.coordinates[1]):D.push({coordinates:[F.coordinates[0],F.coordinates[1]],styles:F.styles});}D.forEach(({coordinates:E,styles:M})=>{this.createFigure({name:"line",attrs:{coordinates:E},styles:M})?.draw(e);});}});}}}),e.restore();let f=g===void 0?On(t):g;if(f!==null){let{width:x,height:C}=o;if(f.resize(x,C),f.beginFrame(),p.length>0){let T=f.getContext(),A=rc(i,s,o);p.forEach(({indicatorId:P,indicator:I,output:R,runtimeData:D,renderGL:E})=>{try{let M=f.getOrCreateVbo(P);E(T,R,A,M);}catch(M){D!==null&&(D.renderGL=null);let F=M instanceof Error?M.message:String(M);me("IndicatorView.drawImp","indicator.renderGL",`plugin \`${P}\` renderGL failed (${F}). Falling back to render2D when available.`);let W=I.draw;if(q(W))try{e.save(),e.globalCompositeOperation="source-over",W({ctx:e,chart:i,indicator:I,bounding:o,xAxis:a,yAxis:s}),e.restore();}catch(H){let Y=H instanceof Error?H.message:String(H);me("IndicatorView.drawImp","indicator.draw",`plugin \`${P}\` render2D fallback failed (${Y}).`);}}});}}let{width:y,height:v}=o,b=m.length>0||h.length>0,S=b?ni(t,t.getContainer()):Rt(t);if(S!==null){if(S.resize(y,v),!b){S.beginFrame();return}let x=m.length>0?Hn(t,S):zn(t),C=h.length>0?Fn(t,S):Mr(t);x?.setData(m),C?.setData(h),((x?.isDirty()??false)||(C?.isDirty()??false)||(C?.isGridDirty()??false))&&(S.beginFrame(),x?.draw(),C?.drawGrid(),C?.draw());}else if(b){e.save();for(let x of m)e.fillStyle=x.color,e.fillRect(x.x,x.y,x.width,x.height);for(let x of h)e.beginPath(),e.strokeStyle=x.color,e.lineWidth=x.halfWidth*2,e.moveTo(x.x0,x.y0),e.lineTo(x.x1,x.y1),e.stroke();e.restore();}}};var zt=class extends K{drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getBounding(),o=t.getPane().getChart().getChartStore(),a=o.getCrosshair(),s=o.getStyles().crosshair;if(L(a.paneId)&&s.show){if(a.paneId===r.getId()){let c=a.y;this._drawLine(e,[{x:0,y:c},{x:i.width,y:c}],s.horizontal);}let l=a.realX;this._drawLine(e,[{x:l,y:0},{x:l,y:i.height}],s.vertical);}}_drawLine(e,t,r){if(r.show){let i=r.line;i.show&&this.createFigure({name:"line",attrs:{coordinates:t},styles:i})?.draw(e);}}};var qe=class extends K{_activeFeatureInfo=null;_collapsed=new Set;_rowBounds=new Map;_hoveredIndicatorId=null;_featureClickEvent=(e,t)=>()=>(this.getWidget().getPane().getChart().getChartStore().executeAction(e,t),true);_featureMouseMoveEvent=e=>()=>(this._activeFeatureInfo=e,true);_toggleCollapseEvent=e=>()=>(this._collapsed.has(e)?this._collapsed.delete(e):this._collapsed.add(e),true);constructor(e){super(e),this.registerEvent("mouseMoveEvent",t=>{this._activeFeatureInfo=null,this._hoveredIndicatorId=null;for(let[r,i]of this._rowBounds)if(t.y>=i.top&&t.y<=i.bottom){this._hoveredIndicatorId=r;break}return false}),this.registerEvent("mouseLeaveEvent",()=>(this._activeFeatureInfo=null,this._hoveredIndicatorId=null,false));}drawImp(e){let t=this.getWidget(),i=t.getPane().getChart().getChartStore();if(i.getDataList().length===0)return;let o=t.getBounding(),{offsetLeft:a,offsetTop:s,offsetRight:l}=i.getStyles().indicator.tooltip;this.drawIndicatorTooltip(e,a,s,o.width-l);}drawIndicatorTooltip(e,t,r,i){let o=this.getWidget().getPane(),a=o.getChart().getChartStore(),l=a.getStyles().indicator.tooltip;if(this.isDrawTooltip(a.getCrosshair(),l)){let c=a.getIndicatorsByPaneId(o.getId()),u=l.title,d=l.legend;this._rowBounds.clear(),c.forEach(h=>{let m=r,p=0,g={x:t,y:r},{name:f,calcParamsText:y,legends:v,features:b}=this.getIndicatorTooltipData(h),S=f.length>0,x=v.length>0;if(S||x){let C=this._collapsed.has(h.id),T=h.id===this._hoveredIndicatorId,A=T?this.classifyTooltipFeatures(b):[[],[],[]];if(p=this.drawChevron(e,h.id,C,g,p,u),S){let P=f;y.length>0&&(P=`${P}${y}`);let I=u.color;p=this.drawStandardTooltipLegends(e,[{title:{text:"",color:I},value:{text:P,color:I}}],g,t,p,i,u);}if(!C&&x&&(p=this.drawStandardTooltipLegends(e,v,g,t,p,i,d)),T){let P=[...A[0],...A[1],...A[2]];p=this.drawStandardTooltipFeatures(e,P,g,h,t,p,i);}r=g.y+p,this._rowBounds.set(h.id,{top:m,bottom:r});}});}return r}drawChevron(e,t,r,i,o,a){let{marginLeft:s=0,marginTop:l=0,marginRight:c=0,marginBottom:u=0,size:d=12,family:h,weight:m,color:p}=a,g=r?"\u203A":"\u2228";e.font=se(d,m,h);let f=Ie(e,g),y=l+d+u;return o=Math.max(o,y),this.createFigure({name:"text",attrs:{text:g,x:i.x+s,y:i.y+l},styles:{color:p,size:d,family:h,weight:m,paddingLeft:2,paddingTop:0,paddingRight:4,paddingBottom:0}},{mouseDownEvent:this._toggleCollapseEvent(t)})?.draw(e),i.x+=s+f+8,o}drawStandardTooltipFeatures(e,t,r,i,o,a,s){if(t.length>0){let l=0,c=0;t.forEach(h=>{let{marginLeft:m=0,marginTop:p=0,marginRight:g=0,marginBottom:f=0,paddingLeft:y=0,paddingTop:v=0,paddingRight:b=0,paddingBottom:S=0,size:x=0,type:C,content:T}=h,A=0;if(C==="icon_font"){let P=T;e.font=se(x,"normal",P.family),A=Ie(e,P.code);}else A=x;l+=m+y+A+b+g,c=Math.max(c,p+v+x+S+f);}),r.x+l>s?(r.x=o,r.y+=a,a=c):a=Math.max(a,c);let d=this.getWidget().getPane().getId();t.forEach(h=>{let{marginLeft:m=0,marginTop:p=0,marginRight:g=0,paddingLeft:f=0,paddingTop:y=0,paddingRight:v=0,paddingBottom:b=0,backgroundColor:S,activeBackgroundColor:x,borderRadius:C,size:T=0,color:A,activeColor:P,type:I,content:R}=h,D=A,E=S;this._activeFeatureInfo?.paneId===d&&this._activeFeatureInfo.indicator?.id===i?.id&&this._activeFeatureInfo.feature.id===h.id&&(D=P??A,E=x??S);let M="onCandleTooltipFeatureClick",F={paneId:d,feature:h};_(i)&&(M="onIndicatorTooltipFeatureClick",F.indicator=i);let W={mouseDownEvent:this._featureClickEvent(M,F),mouseMoveEvent:this._featureMouseMoveEvent(F)},H=0;if(I==="icon_font"){let Y=R;this.createFigure({name:"text",attrs:{text:Y.code,x:r.x+m,y:r.y+p},styles:{paddingLeft:f,paddingTop:y,paddingRight:v,paddingBottom:b,borderRadius:C,size:T,family:Y.family,color:D,backgroundColor:E}},W)?.draw(e),H=Ie(e,Y.code);}else {this.createFigure({name:"rect",attrs:{x:r.x+m,y:r.y+p,width:T,height:T},styles:{paddingLeft:f,paddingTop:y,paddingRight:v,paddingBottom:b,color:E}},W)?.draw(e);let Y=R;this.createFigure({name:"path",attrs:{path:Y.path,x:r.x+m+f,y:r.y+p+y,width:T,height:T},styles:{style:Y.style,lineWidth:Y.lineWidth,color:D}})?.draw(e),H=T;}r.x+=m+f+H+v+g;});}return a}drawStandardTooltipLegends(e,t,r,i,o,a,s){if(t.length>0){let{marginLeft:l,marginTop:c,marginRight:u,marginBottom:d,size:h,family:m,weight:p}=s;e.font=se(h,p,m),t.forEach(g=>{let f=g.title,y=g.value,v=Ie(e,f.text),b=Ie(e,y.text),S=v+b,x=c+h+d;r.x+l+S+u>a?(r.x=i,r.y+=o,o=x):o=Math.max(o,x),f.text.length>0&&this.createFigure({name:"text",attrs:{x:r.x+l,y:r.y+c,text:f.text},styles:{color:f.color,size:h,family:m,weight:p}})?.draw(e),this.createFigure({name:"text",attrs:{x:r.x+l+v,y:r.y+c,text:y.text},styles:{color:y.color,size:h,family:m,weight:p}})?.draw(e),r.x+=l+S+u;});}return o}isDrawTooltip(e,t){let r=t.showRule;return r==="always"||r==="follow_cross"&&L(e.paneId)}getIndicatorTooltipData(e){let t=this.getWidget().getPane().getChart().getChartStore(),r=t.getStyles().indicator,i=r.tooltip,o=i.title,a="",s="";if(o.show&&(o.showName&&(a=e.shortName),o.showParams)){let g=e.calcParams;g.length>0&&(s=`(${g.join(",")})`);}let l={name:a,calcParamsText:s,legends:[],features:i.features},c=e.result,u=t.getCrosshair().dataIndex??Math.max(0,c.length-1),d=t.getInnerFormatter(),h=t.getDecimalFold(),m=t.getThousandsSeparator(),p=[];if(e.visible){let g=c[u]??{},f=i.legend.defaultValue;lt(e,u,r,(y,v)=>{if(L(y.title)){let b=v.color,S=g[y.key];w(S)&&(S=J(S,e.precision),e.shouldFormatBigNumber&&(S=d.formatBigNumber(S)),S=h.format(m.format(S))),p.push({title:{text:y.title,color:b},value:{text:S??f,color:b}});}}),l.legends=p;}if(q(e.createTooltipDataSource)){let g=this.getWidget(),f=g.getPane(),y=f.getChart(),{name:v,calcParamsText:b,legends:S,features:x}=e.createTooltipDataSource({chart:y,indicator:e,crosshair:t.getCrosshair(),bounding:g.getBounding(),xAxis:f.getChart().getXAxisPane().getAxisComponent(),yAxis:f.getAxisComponent()});if(o.show&&(v!==void 0&&o.showName&&(l.name=v),b!==void 0&&o.showParams&&(l.calcParamsText=b)),_(x)&&(l.features=x),S!==void 0&&e.visible){let C=[],T=r.tooltip.legend.color;S.forEach(A=>{let P={text:"",color:T};ae(A.title)?P=A.title:P.text=A.title;let I={text:"",color:T};ae(A.value)?I=A.value:I.text=A.value,w(Number(I.text))&&(I.text=h.format(m.format(I.text))),C.push({title:P,value:I});}),l.legends=C;}}return l}classifyTooltipFeatures(e){let t=[],r=[],i=[];return e.forEach(o=>{switch(o.position){case "left":{t.push(o);break}case "middle":{r.push(o);break}case "right":{i.push(o);break}}}),[t,r,i]}};var je=class extends K{constructor(e){super(e),this._initEvent();}_initEvent(){let e=this.getWidget(),t=e.getPane(),r=t.getId(),i=t.getChart(),o=i.getChartStore();this.registerEvent("mouseMoveEvent",a=>{let s=o.getProgressOverlayInfo();if(s!==null){let l=s.overlay,c=s.paneId;l.isStart()&&(o.updateProgressOverlayInfo(r),c=r);let u=l.points.length-1;return l.isDrawing()&&c===r&&(l.eventMoveForDrawing(this._coordinateToPoint(l,a)),l.onDrawing?.({chart:i,overlay:l,...a})),this._figureMouseMoveEvent(l,"point",u,{key:`${Ne}point_${u}`,type:"circle",attrs:{}})(a)}return o.setHoverOverlayInfo({paneId:r,overlay:null,figureType:"none",figureIndex:-1,figure:null},(l,c)=>this._processOverlayMouseEnterEvent(l,c,a),(l,c)=>this._processOverlayMouseLeaveEvent(l,c,a)),e.setForceCursor(null),false}).registerEvent("mouseClickEvent",a=>{let s=o.getProgressOverlayInfo();if(s!==null){let l=s.overlay,c=s.paneId;l.isStart()&&(o.updateProgressOverlayInfo(r,true),c=r);let u=l.points.length-1;return l.isDrawing()&&c===r&&(l.eventMoveForDrawing(this._coordinateToPoint(l,a)),l.onDrawing?.({chart:i,overlay:l,...a}),l.nextStep(),l.isDrawing()||(o.progressOverlayComplete(),l.onDrawEnd?.({chart:i,overlay:l,...a}))),this._figureMouseClickEvent(l,"point",u,{key:`${Ne}point_${u}`,type:"circle",attrs:{}})(a)}return o.setClickOverlayInfo({paneId:r,overlay:null,figureType:"none",figureIndex:-1,figure:null},(l,c)=>this._processOverlaySelectedEvent(l,c,a),(l,c)=>this._processOverlayDeselectedEvent(l,c,a)),false}).registerEvent("mouseDoubleClickEvent",a=>{let s=o.getProgressOverlayInfo();if(s!==null){let l=s.overlay,c=s.paneId;l.isDrawing()&&c===r&&(l.forceComplete(),l.isDrawing()||(o.progressOverlayComplete(),l.onDrawEnd?.({chart:i,overlay:l,...a})));let u=l.points.length-1;return this._figureMouseClickEvent(l,"point",u,{key:`${Ne}point_${u}`,type:"circle",attrs:{}})(a)}return false}).registerEvent("mouseRightClickEvent",a=>{let s=o.getProgressOverlayInfo();if(s!==null){let l=s.overlay;if(l.isDrawing()){let c=l.points.length-1;return this._figureMouseRightClickEvent(l,"point",c,{key:`${Ne}point_${c}`,type:"circle",attrs:{}})(a)}}return false}).registerEvent("mouseUpEvent",a=>{let{overlay:s,figure:l}=o.getPressedOverlayInfo();return s!==null&&ge("onPressedMoveEnd",l)&&s.onPressedMoveEnd?.({chart:i,overlay:s,figure:l??void 0,...a}),o.setPressedOverlayInfo({paneId:r,overlay:null,figureType:"none",figureIndex:-1,figure:null}),false}).registerEvent("pressedMouseMoveEvent",a=>{let{overlay:s,figureType:l,figureIndex:c,figure:u}=o.getPressedOverlayInfo();if(s!==null&&ge("onPressedMoving",u)){if(!s.lock){let d=this._coordinateToPoint(s,a);l==="point"?s.eventPressedPointMove(d,c):s.eventPressedOtherMove(d,this.getWidget().getPane().getChart().getChartStore());let h=false;s.onPressedMoving?.({chart:i,overlay:s,figure:u??void 0,...a,preventDefault:()=>{h=true;}}),h?this.getWidget().setForceCursor(null):this.getWidget().setForceCursor("pointer");}return true}return this.getWidget().setForceCursor(null),false});}_createFigureEvents(e,t,r,i){return e.isDrawing()?null:{mouseMoveEvent:this._figureMouseMoveEvent(e,t,r,i),mouseDownEvent:this._figureMouseDownEvent(e,t,r,i),mouseClickEvent:this._figureMouseClickEvent(e,t,r,i),mouseRightClickEvent:this._figureMouseRightClickEvent(e,t,r,i),mouseDoubleClickEvent:this._figureMouseDoubleClickEvent(e,t,r,i)}}_processOverlayMouseEnterEvent(e,t,r){return q(e.onMouseEnter)&&ge("onMouseEnter",t)?(e.onMouseEnter({chart:this.getWidget().getPane().getChart(),overlay:e,figure:t??void 0,...r}),true):false}_processOverlayMouseLeaveEvent(e,t,r){return q(e.onMouseLeave)&&ge("onMouseLeave",t)?(e.onMouseLeave({chart:this.getWidget().getPane().getChart(),overlay:e,figure:t??void 0,...r}),true):false}_processOverlaySelectedEvent(e,t,r){return ge("onSelected",t)?(e.onSelected?.({chart:this.getWidget().getPane().getChart(),overlay:e,figure:t??void 0,...r}),true):false}_processOverlayDeselectedEvent(e,t,r){return ge("onDeselected",t)?(e.onDeselected?.({chart:this.getWidget().getPane().getChart(),overlay:e,figure:t??void 0,...r}),true):false}_figureMouseMoveEvent(e,t,r,i){return o=>{let a=this.getWidget().getPane(),s=!e.isDrawing()&&ge("onMouseMove",i);if(s){let l=false;e.onMouseMove?.({chart:a.getChart(),overlay:e,figure:i,...o,preventDefault:()=>{l=true;}}),l?this.getWidget().setForceCursor(null):this.getWidget().setForceCursor("pointer");}return a.getChart().getChartStore().setHoverOverlayInfo({paneId:a.getId(),overlay:e,figureType:t,figure:i,figureIndex:r},(l,c)=>this._processOverlayMouseEnterEvent(l,c,o),(l,c)=>this._processOverlayMouseLeaveEvent(l,c,o)),s}}_figureMouseDownEvent(e,t,r,i){return o=>{let a=this.getWidget().getPane(),s=a.getId();return e.startPressedMove(this._coordinateToPoint(e,o)),ge("onPressedMoveStart",i)?(e.onPressedMoveStart?.({chart:a.getChart(),overlay:e,figure:i,...o}),a.getChart().getChartStore().setPressedOverlayInfo({paneId:s,overlay:e,figureType:t,figureIndex:r,figure:i}),!e.isDrawing()):false}}_figureMouseClickEvent(e,t,r,i){return o=>{let a=this.getWidget().getPane(),s=a.getId(),l=!e.isDrawing()&&ge("onClick",i);return l&&e.onClick?.({chart:this.getWidget().getPane().getChart(),overlay:e,figure:i,...o}),a.getChart().getChartStore().setClickOverlayInfo({paneId:s,overlay:e,figureType:t,figureIndex:r,figure:i},(c,u)=>this._processOverlaySelectedEvent(c,u,o),(c,u)=>this._processOverlayDeselectedEvent(c,u,o)),l}}_figureMouseDoubleClickEvent(e,t,r,i){return o=>ge("onDoubleClick",i)?(e.onDoubleClick?.({...o,chart:this.getWidget().getPane().getChart(),figure:i,overlay:e}),!e.isDrawing()):false}_figureMouseRightClickEvent(e,t,r,i){return o=>{if(ge("onRightClick",i)){let a=false;return e.onRightClick?.({chart:this.getWidget().getPane().getChart(),overlay:e,figure:i,...o,preventDefault:()=>{a=true;}}),a||this.getWidget().getPane().getChart().getChartStore().removeOverlay(e),!e.isDrawing()}return false}}_coordinateToPoint(e,t){let r={},i=this.getWidget().getPane(),o=i.getChart(),a=i.getId(),s=o.getChartStore();if(this.coordinateToPointTimestampDataIndexFlag()){let c=o.getXAxisPane().getAxisComponent().convertFromPixel(t.x),u=s.dataIndexToTimestamp(c)??void 0;r.timestamp=u,r.dataIndex=c;}if(this.coordinateToPointValueFlag()){let l=i.getAxisComponent(),c=l.convertFromPixel(t.y);if(e.mode!=="normal"&&a===B.CANDLE&&w(r.dataIndex)){let u=s.getDataByDataIndex(r.dataIndex);if(u!==null){let d=e.modeSensitivity;if(c>u.high)if(e.mode==="weak_magnet"){let h=l.convertToPixel(u.high),m=l.convertFromPixel(h-d);c<m&&(c=u.high);}else c=u.high;else if(c<u.low)if(e.mode==="weak_magnet"){let h=l.convertToPixel(u.low),m=l.convertFromPixel(h-d);c>m&&(c=u.low);}else c=u.low;else {let h=Math.max(u.open,u.close),m=Math.min(u.open,u.close);c>h?c-h<u.high-c?c=h:c=u.high:c<m?c-u.low<m-c?c=u.low:c=m:h-c<c-m?c=h:c=m;}}}r.value=c;}return r}coordinateToPointValueFlag(){return true}coordinateToPointTimestampDataIndexFlag(){return true}dispatchEvent(e,t){return this.getWidget().getPane().getChart().getChartStore().isOverlayDrawing()?this.onEvent(e,t):super.dispatchEvent(e,t)}drawImp(e){this.getCompleteOverlays().forEach(i=>{i.visible&&this._drawOverlay(e,i);});let r=this.getProgressOverlay();_(r)&&r.visible&&this._drawOverlay(e,r);}_drawOverlay(e,t){let{points:r}=t,i=this.getWidget().getPane(),o=i.getChart(),a=o.getChartStore(),s=i.getAxisComponent(),l=o.getXAxisPane().getAxisComponent(),c=r.reduce((u,d)=>{let h=d.dataIndex??null;if(!w(h)&&w(d.timestamp)&&(h=a.timestampToDataIndex(d.timestamp)),!w(h)||!w(d.value))return u;let m=l.convertToPixel(h),p=s?.convertToPixel(d.value);return !w(m)||!w(p)||u.push({x:m,y:p}),u},[]);if(c.length>0){let u=[].concat(this.getFigures(t,c));this.drawFigures(e,t,u);}this.drawDefaultFigures(e,t,c);}drawFigures(e,t,r){let i=this.getWidget().getPane().getChart().getStyles().overlay;r.forEach((o,a)=>{let{type:s,styles:l,attrs:c}=o;[].concat(c).forEach(d=>{let h=this._createFigureEvents(t,"other",a,o),m={...i[s],...t.styles?.[s],...l};this.createFigure({name:s,attrs:d,styles:m},h??void 0)?.draw(e);});});}getCompleteOverlays(){let e=this.getWidget().getPane();return e.getChart().getChartStore().getOverlaysByPaneId(e.getId())}getProgressOverlay(){let e=this.getWidget().getPane(),t=e.getChart().getChartStore().getProgressOverlayInfo();return _(t)&&t.paneId===e.getId()?t.overlay:null}getFigures(e,t){let r=this.getWidget(),i=r.getPane(),o=i.getChart(),a=i.getAxisComponent(),s=o.getXAxisPane().getAxisComponent(),l=r.getBounding();return e.createPointFigures?.({chart:o,overlay:e,coordinates:t,bounding:l,xAxis:s,yAxis:a})??[]}drawDefaultFigures(e,t,r){if(t.needDefaultPointFigure){let i=this.getWidget().getPane().getChart().getChartStore(),o=i.getHoverOverlayInfo(),a=i.getClickOverlayInfo();if(o.overlay?.id===t.id&&o.figureType!=="none"||a.overlay?.id===t.id&&a.figureType!=="none"){let s=i.getStyles().overlay,l=t.styles,c={...s.point,...l?.point};r.forEach(({x:u,y:d},h)=>{let m=c.radius,p=c.color,g=c.borderColor,f=c.borderSize;o.overlay?.id===t.id&&o.figureType==="point"&&o.figure?.key===`${Ne}point_${h}`&&(m=c.activeRadius,p=c.activeColor,g=c.activeBorderColor,f=c.activeBorderSize),this.createFigure({name:"circle",attrs:{x:u,y:d,r:m+f},styles:{color:g}},this._createFigureEvents(t,"point",h,{key:`${Ne}point_${h}`,type:"circle",attrs:{x:u,y:d,r:m+f},styles:{color:g}})??void 0)?.draw(e),this.createFigure({name:"circle",attrs:{x:u,y:d,r:m},styles:{color:p}})?.draw(e);});}}}};var Ze=class extends De{_gridView=new kt(this);_indicatorView=new Yt(this);_crosshairLineView=new zt(this);_tooltipView=this.createTooltipView();_overlayView=new je(this);constructor(e,t){super(e,t),this.addChild(this._tooltipView),this.addChild(this._overlayView);}getName(){return V.MAIN}updateMain(e){this.getPane().getOptions().state!=="minimize"&&(this.updateMainContent(e),this._gridView.draw(e),this._indicatorView.draw(e));}createTooltipView(){return new qe(this)}updateMainContent(e){}updateOverlayContent(e){}updateOverlay(e){this.getPane().getOptions().state!=="minimize"&&(this._overlayView.draw(e),this._crosshairLineView.draw(e),this.updateOverlayContent(e)),this._tooltipView.draw(e);}destroy(){Ln(this),Gn(this),Nn(this),Rn(this),super.destroy();}};var Ht=class extends Xe{_ripplePoint=this.createFigure({name:"circle",attrs:{x:0,y:0,r:0},styles:{style:"fill"}});_animationFrameTime=0;_gradientCache=null;_animation=new Le({iterationCount:1/0}).doFrame(e=>{this._animationFrameTime=e;let t=this.getWidget().getPane();t.getChart().updatePane(0,t.getId());});drawImp(e){let t=this.getWidget(),r=t.getPane(),i=r.getChart(),a=i.getDataList().length-1,s=t.getBounding(),l=r.getAxisComponent(),c=i.getStyles().candle.area,u=[],d=Number.MAX_SAFE_INTEGER,h=Number.MIN_SAFE_INTEGER,m=null;if(this.eachChildren(g=>{let f=g.x,{current:y}=g.data,v=y?.[c.value];if(w(v)){let b=l.convertToPixel(v);h===Number.MIN_SAFE_INTEGER&&(h=f),u.push({x:f,y:b}),d=Math.min(d,b),g.dataIndex===a&&(m={x:f,y:b});}}),u.length>0){this.createFigure({name:"line",attrs:{coordinates:u},styles:{color:c.lineColor,size:c.lineSize,smooth:c.smooth}})?.draw(e);let g=c.backgroundColor,f="";if(ne(g)){if(this._gradientCache===null||this._gradientCache.height!==s.height||this._gradientCache.minY!==d){let y=e.createLinearGradient(0,s.height,0,d);try{g.forEach(({offset:v,color:b})=>{y.addColorStop(v,b);});}catch{}this._gradientCache={gradient:y,height:s.height,minY:d};}f=this._gradientCache.gradient;}else f=g;e.fillStyle=f,e.beginPath(),e.moveTo(h,s.height),e.lineTo(u[0].x,u[0].y),Hr(e,u,c.smooth),e.lineTo(u[u.length-1].x,s.height),e.closePath(),e.fill();}let p=c.point;if(p.show&&_(m)){this.createFigure({name:"circle",attrs:{x:m.x,y:m.y,r:p.radius},styles:{style:"fill",color:p.color}})?.draw(e);let g=p.rippleRadius;p.animation&&(g=p.radius+this._animationFrameTime/p.animationDuration*(p.rippleRadius-p.radius),this._animation.setDuration(p.animationDuration).start()),this._ripplePoint?.setAttrs({x:m.x,y:m.y,r:g}).setStyles({style:"fill",color:p.rippleColor}).draw(e);}else this.stopAnimation();}stopAnimation(){this._animation.stop();}};var Gt=class extends K{drawImp(e){let r=this.getWidget().getPane(),i=r.getChart().getChartStore(),o=i.getStyles().candle.priceMark,a=o.high,s=o.low;if(o.show&&(a.show||s.show)){let l=i.getVisibleRangeHighLowPrice(),c=i.getSymbol()?.pricePrecision??j.PRICE,u=r.getAxisComponent(),{price:d,x:h}=l[0],{price:m,x:p}=l[1],g=u.convertToPixel(d),f=u.convertToPixel(m),y=i.getDecimalFold(),v=i.getThousandsSeparator();a.show&&d!==Number.MIN_SAFE_INTEGER&&this._drawMark(e,y.format(v.format(J(d,c))),{x:h,y:g},g<f?[-2,-5]:[2,5],a),s.show&&m!==Number.MAX_SAFE_INTEGER&&this._drawMark(e,y.format(v.format(J(m,c))),{x:p,y:f},g<f?[2,5]:[-2,-5],s);}}_drawMark(e,t,r,i,o){let a=r.x,s=r.y+i[0];this.createFigure({name:"line",attrs:{coordinates:[{x:a-2,y:s+i[0]},{x:a,y:s},{x:a+2,y:s+i[0]}]},styles:{color:o.color}})?.draw(e);let l=0,c=0,u="left",{width:d}=this.getWidget().getBounding();a>d/2?(l=a-5,c=l-o.textOffset,u="right"):(l=a+5,u="left",c=l+o.textOffset);let h=s+i[1];this.createFigure({name:"line",attrs:{coordinates:[{x:a,y:s},{x:a,y:h},{x:l,y:h}]},styles:{color:o.color}})?.draw(e);let m=Math.max(o.textSize,11);e.save(),e.font=se(m,"400",o.textFamily),e.textAlign=u,e.textBaseline="middle",e.shadowColor="rgba(0, 0, 0, 0.9)",e.shadowBlur=4,e.shadowOffsetX=0,e.shadowOffsetY=0,e.fillStyle=o.color,e.fillText(t,c,h),e.shadowBlur=0,e.fillText(t,c,h),e.restore();}};var Xt=class extends K{drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getBounding(),o=r.getChart().getChartStore(),a=o.getStyles().candle.priceMark,s=a.last,l=s.line;if(a.show&&s.show&&l.show){let c=r.getAxisComponent(),u=o.getDataList(),d=u[u.length-1];if(_(d)){let{close:h,open:m}=d,p=s.compareRule==="current_open"?m:u[u.length-2]?.close??h,g=c.convertToNicePixel(h),f="";h>p?f=s.upColor:h<p?f=s.downColor:f=s.noChangeColor,this.createFigure({name:"line",attrs:{coordinates:[{x:0,y:g},{x:i.width,y:g}]},styles:{style:l.style,color:f,size:l.size,dashedValue:l.dashedValue}})?.draw(e);}}}};var Ut=class extends qe{drawImp(e){let t=this.getWidget(),r=t.getPane().getChart().getChartStore();if(r.getDataList().length===0)return;let i=r.getCrosshair(),o=t.getBounding(),a=r.getStyles(),s=a.candle,l=a.indicator;if(s.tooltip.showType==="rect"&&l.tooltip.showType==="rect"){let c=this.isDrawTooltip(i,s.tooltip),u=this.isDrawTooltip(i,l.tooltip);this._drawRectTooltip(e,c,u,s.tooltip.offsetTop);}else if(s.tooltip.showType==="standard"&&l.tooltip.showType==="standard"){let{offsetLeft:c,offsetTop:u,offsetRight:d}=s.tooltip,h=o.width-d,m=this._drawCandleStandardTooltip(e,c,u,h);this.drawIndicatorTooltip(e,c,m,h);}else if(s.tooltip.showType==="rect"&&l.tooltip.showType==="standard"){let{offsetLeft:c,offsetTop:u,offsetRight:d}=s.tooltip,h=o.width-d,m=this.drawIndicatorTooltip(e,c,u,h),p=this.isDrawTooltip(i,s.tooltip);this._drawRectTooltip(e,p,false,m);}else {let{offsetLeft:c,offsetTop:u,offsetRight:d}=s.tooltip,h=o.width-d,m=this._drawCandleStandardTooltip(e,c,u,h),p=this.isDrawTooltip(i,l.tooltip);this._drawRectTooltip(e,false,p,m);}}_drawCandleStandardTooltip(e,t,r,i){let o=this.getWidget().getPane().getChart().getChartStore(),s=o.getStyles().candle.tooltip,l=s.legend,c=0,u={x:t,y:r},d=o.getCrosshair();if(this.isDrawTooltip(d,s)){let h=s.title,m=this._getCandleTooltipLegends();if(h.show){let{type:g="",span:f=""}=o.getPeriod()??{},y=Nr(h.template,{...o.getSymbol(),period:`${f}${jr(g,o.getLocale())}`}),v=h.color;m.unshift({title:{text:"",color:v},value:{text:y,color:v}});}let p=this.classifyTooltipFeatures(s.features);c=this.drawStandardTooltipFeatures(e,p[0],u,null,t,c,i),c=this.drawStandardTooltipFeatures(e,p[1],u,null,t,c,i),m.length>0&&(c=this.drawStandardTooltipLegends(e,m,u,t,c,i,l)),c=this.drawStandardTooltipFeatures(e,p[2],u,null,t,c,i);}return u.y+c}_drawRectTooltip(e,t,r,i){let o=this.getWidget(),a=o.getPane(),s=a.getChart().getChartStore(),l=s.getStyles(),c=l.candle,u=l.indicator,d=c.tooltip,h=u.tooltip;if(t||r){let m=this._getCandleTooltipLegends(),{offsetLeft:p,offsetTop:g,offsetRight:f,offsetBottom:y}=d,{marginLeft:v,marginRight:b,marginTop:S,marginBottom:x,size:C,weight:T,family:A}=d.legend,{position:P,paddingLeft:I,paddingRight:R,paddingTop:D,paddingBottom:E,offsetLeft:M,offsetRight:F,offsetTop:W,offsetBottom:H,borderSize:Y,borderRadius:N,borderColor:O,color:ee}=d.rect,U=0,$=0,z=0;t&&(e.font=se(C,T,A),m.forEach(ce=>{let Me=ce.title,Ve=ce.value,nt=`${Me.text}${Ve.text}`,at=Ie(e,nt)+v+b;U=Math.max(U,at);}),z+=(x+S+C)*m.length);let{marginLeft:Z,marginRight:le,marginTop:_e,marginBottom:pe,size:fe,weight:it,family:Oe}=h.legend,ot=[];if(r){let ce=s.getIndicatorsByPaneId(a.getId());e.font=se(fe,it,Oe),ce.forEach(Me=>{let Ve=this.getIndicatorTooltipData(Me).legends;ot.push(Ve),Ve.forEach(nt=>{let at=nt.title,dr=nt.value,ue=`${at.text}${dr.text}`,Ce=Ie(e,ue)+Z+le;U=Math.max(U,Ce),z+=_e+pe+fe;});});}if($+=U,$!==0&&z!==0){let ce=s.getCrosshair(),Me=o.getBounding(),Ve=a.getYAxisWidget().getBounding();$+=Y*2+I+R,z+=Y*2+D+E;let nt=Me.width/2,at=P==="pointer"&&ce.paneId===B.CANDLE,dr=(ce.realX??0)>nt,ue=0;if(at){let de=ce.realX;dr?ue=de-F-$:ue=de+M;}else {let de=this.getWidget().getPane().getAxisComponent();dr?(ue=M+p,de.inside&&de.position==="left"&&(ue+=Ve.width)):(ue=Me.width-F-$-f,de.inside&&de.position==="right"&&(ue-=Ve.width));}let Ce=i+W;at&&(Ce=ce.y-z/2,Ce+z>Me.height-H-y&&(Ce=Me.height-H-z-y),Ce<i+W&&(Ce=i+W+g)),this.createFigure({name:"rect",attrs:{x:ue,y:Ce,width:$,height:z},styles:{style:"stroke_fill",color:ee,borderColor:O,borderSize:Y,borderRadius:N}})?.draw(e);let ra=ue+Y+I+v,ke=Ce+Y+D;if(t&&m.forEach(de=>{ke+=S;let hr=de.title;this.createFigure({name:"text",attrs:{x:ra,y:ke,text:hr.text},styles:{color:hr.color,size:C,family:A,weight:T}})?.draw(e);let bt=de.value;this.createFigure({name:"text",attrs:{x:ue+$-Y-b-R,y:ke,text:bt.text,align:"right"},styles:{color:bt.color,size:C,family:A,weight:T}})?.draw(e),ke+=C+x;}),r){let de=ue+Y+I+Z;ot.forEach(hr=>{hr.forEach(bt=>{ke+=_e;let vi=bt.title,yi=bt.value;this.createFigure({name:"text",attrs:{x:de,y:ke,text:vi.text},styles:{color:vi.color,size:fe,family:Oe,weight:it}})?.draw(e),this.createFigure({name:"text",attrs:{x:ue+$-Y-le-R,y:ke,text:yi.text,align:"right"},styles:{color:yi.color,size:fe,family:Oe,weight:it}})?.draw(e),ke+=fe+pe;});});}}}}_getCandleTooltipLegends(){let e=this.getWidget().getPane().getChart().getChartStore(),t=e.getStyles().candle,r=e.getDataList(),i=e.getInnerFormatter(),o=e.getDecimalFold(),a=e.getThousandsSeparator(),s=e.getLocale(),{pricePrecision:l=j.PRICE,volumePrecision:c=j.VOLUME}=e.getSymbol()??{},u=e.getPeriod(),d=e.getCrosshair().dataIndex??r.length-1,h=t.tooltip,{color:m,defaultValue:p,template:g}=h.legend,f=r[d-1]??null,y=r[d],v=f?.close??y.close,b=y.close-v,S={...y,time:i.formatDate(y.timestamp,Pr[u?.timespan??"day"],"tooltip"),open:o.format(a.format(J(y.open,l))),high:o.format(a.format(J(y.high,l))),low:o.format(a.format(J(y.low,l))),close:o.format(a.format(J(y.close,l))),volume:o.format(a.format(i.formatBigNumber(J(y.volume??p,c)))),turnover:o.format(a.format(J(y.turnover??p,l))),change:v===0?p:`${a.format(J(b/v*100))}%`};return (q(g)?g({prev:f,current:y,next:r[d+1]??null},t):g).map(({title:C,value:T})=>{let A={text:"",color:m};ae(C)?A={...C}:A.text=C,A.text=jr(A.text,s);let P={text:p,color:m};return ae(T)?P={...T}:P.text=T,_(/{change}/.exec(P.text))&&(P.color=b===0?t.priceMark.last.noChangeColor:b>0?t.priceMark.last.upColor:t.priceMark.last.downColor),P.text=Nr(P.text,S),{title:A,value:P}})}};var $t=class extends K{_activeFeatureInfo=null;_featureClickEvent=e=>()=>(this.getWidget().getPane().getChart().getChartStore().executeAction("onCrosshairFeatureClick",e),true);_featureMouseMoveEvent=e=>()=>(this._activeFeatureInfo=e,this.getWidget().setForceCursor("pointer"),true);constructor(e){super(e),this.registerEvent("mouseMoveEvent",t=>(this._activeFeatureInfo=null,this.getWidget().setForceCursor(null),false));}drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getPane().getChart().getChartStore(),o=i.getCrosshair(),a=this.getWidget(),s=a.getPane().getAxisComponent();if(L(o.paneId)&&o.paneId===r.getId()&&s.isInCandle()){let l=i.getStyles().crosshair,c=l.horizontal.features;if(l.show&&l.horizontal.show&&c.length>0){let u=s.position==="right",d=a.getBounding(),h=0,m=l.horizontal.text;if(s.inside&&m.show){let f=s.convertFromPixel(o.y),y=s.getRange(),v=s.displayValueToText(s.realValueToDisplayValue(s.valueToRealValue(f,{range:y}),{range:y}),i.getSymbol()?.pricePrecision??j.PRICE);v=i.getDecimalFold().format(i.getThousandsSeparator().format(v)),h=m.paddingLeft+ie(v,m.size,m.weight,m.family)+m.paddingRight;}let p=h;u&&(p=d.width-h);let g=o.y;c.forEach(f=>{let{marginLeft:y=0,marginTop:v=0,marginRight:b=0,paddingLeft:S=0,paddingTop:x=0,paddingRight:C=0,paddingBottom:T=0,color:A,activeColor:P,backgroundColor:I,activeBackgroundColor:R,borderRadius:D,size:E=0,type:M,content:F}=f,W=E;if(M==="icon_font"){let O=F;W=S+ie(O.code,E,"normal",O.family)+C;}u?p-=W+b:p+=y;let H=A,Y=I;this._activeFeatureInfo?.feature.id===f.id&&(H=P??A,Y=R??I);let N={mouseDownEvent:this._featureClickEvent({crosshair:o,feature:f}),mouseMoveEvent:this._featureMouseMoveEvent({crosshair:o,feature:f})};if(M==="icon_font"){let O=F;this.createFigure({name:"text",attrs:{text:O.code,x:p,y:g+v,baseline:"middle"},styles:{paddingLeft:S,paddingTop:x,paddingRight:C,paddingBottom:T,borderRadius:D,size:E,family:O.family,color:H,backgroundColor:Y}},N)?.draw(e);}else {this.createFigure({name:"rect",attrs:{x:p,y:g+v-E/2,width:E,height:E},styles:{paddingLeft:S,paddingTop:x,paddingRight:C,paddingBottom:T,color:Y}},N)?.draw(e);let O=F;this.createFigure({name:"path",attrs:{path:O.path,x:p,y:g+v+x-E/2,width:E,height:E},styles:{style:O.style,lineWidth:O.lineWidth,color:H}})?.draw(e);}u?p-=y:p+=W+b;});}}}};var qt=class extends Ze{_candleBarView=new $e(this);_candleAreaView=new Ht(this);_candleHighLowPriceView=new Gt(this);_candleLastPriceLineView=new Xt(this);_crosshairFeatureView=new $t(this);constructor(e,t){super(e,t),this.addChild(this._candleBarView),this.addChild(this._crosshairFeatureView);}updateMainContent(e){this.getPane().getChart().getStyles().candle.type!=="area"?(this._candleBarView.draw(e),this._candleHighLowPriceView.draw(e),this._candleAreaView.stopAnimation()):this._candleAreaView.draw(e),this._candleLastPriceLineView.draw(e);}updateOverlayContent(e){this._crosshairFeatureView.draw(e);}createTooltipView(){return new Ut(this)}destroy(){this._candleAreaView.stopAnimation(),Kn(this),Fr(this),super.destroy();}};var Qe=class extends K{drawImp(e,t){let r=this.getWidget(),i=r.getPane(),o=r.getBounding(),a=i.getAxisComponent(),s=this.getAxisStyles(i.getChart().getStyles());if(s.show&&(s.axisLine.show&&this.createFigure({name:"line",attrs:this.createAxisLine(o,s),styles:s.axisLine})?.draw(e),!t[0])){let l=a.getTicks();if(s.tickLine.show&&this.createTickLines(l,o,s).forEach(u=>{this.createFigure({name:"line",attrs:u,styles:s.tickLine})?.draw(e);}),s.tickText.show){let c=this.createTickTexts(l,o,s),u=r.getTextRenderer();if(u!==null){let d=s.tickText,h=d.color??"#888888",m=d.size??12,p=d.family??"Helvetica Neue";for(let g of c)u.queue({text:g.text,x:g.x,y:g.y,fontSize:m,fontFamily:p,color:h,align:g.align,baseline:g.baseline});}else this.createFigure({name:"text",attrs:c,styles:s.tickText})?.draw(e);}}}};var jt=class extends Qe{getAxisStyles(e){return e.yAxis}createAxisLine(e,t){let r=this.getWidget().getPane().getAxisComponent(),i=t.axisLine.size,o=0;return r.isFromZero()?o=0:o=e.width-i,{coordinates:[{x:o,y:0},{x:o,y:e.height}]}}createTickLines(e,t,r){let i=this.getWidget().getPane().getAxisComponent(),o=r.axisLine,a=r.tickLine,s=0,l=0;return i.isFromZero()?(s=0,o.show&&(s+=o.size),l=s+a.length):(s=t.width,o.show&&(s-=o.size),l=s-a.length),e.map(c=>{let u=i instanceof he?i.tickCoord(c):c.coord;return {coordinates:[{x:s,y:u},{x:l,y:u}]}})}createTickTexts(e,t,r){let i=this.getWidget().getPane().getAxisComponent(),o=r.axisLine,a=r.tickLine,s=r.tickText,l=0;i.isFromZero()?(l=s.marginStart,o.show&&(l+=o.size),a.show&&(l+=a.length)):(l=t.width-s.marginEnd,o.show&&(l-=o.size),a.show&&(l-=a.length));let c=this.getWidget().getPane().getAxisComponent().isFromZero()?"left":"right";return e.map(u=>{let d=i instanceof he?i.tickCoord(u):u.coord;return {x:l,y:d,text:u.text,align:c,baseline:"middle"}})}};var Zt=class extends K{drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getBounding(),o=r.getChart().getChartStore(),a=o.getStyles().candle.priceMark,s=a.last,l=s.text;if(a.show&&s.show&&l.show){let c=o.getSymbol()?.pricePrecision??j.PRICE,u=r.getAxisComponent(),d=o.getDataList(),h=d[d.length-1];if(_(h)){let{close:m,open:p}=h,g=s.compareRule==="current_open"?p:d[d.length-2]?.close??m,f=u.convertToNicePixel(m),y="";m>g?y=s.upColor:m<g?y=s.downColor:y=s.noChangeColor;let v=0,b="left";u.isFromZero()?(v=0,b="left"):(v=i.width,b="right");let S=[],x=u.getRange(),C=u.displayValueToText(u.realValueToDisplayValue(u.valueToRealValue(m,{range:x}),{range:x}),c);C=o.getDecimalFold().format(o.getThousandsSeparator().format(C));let{paddingLeft:T,paddingRight:A,paddingTop:P,paddingBottom:I,size:R,family:D,weight:E}=l,M=T+ie(C,R,E,D)+A,F=P+R+I;S.push({name:"text",attrs:{x:v,y:f,width:M,height:F,text:C,align:b,baseline:"middle"},styles:{...l,backgroundColor:y}});let W=o.getInnerFormatter().formatExtendText,H=R/2,Y=f-H-P,N=f+H+I;s.extendTexts.forEach((O,ee)=>{let U=W({type:"last_price",data:h,index:ee});if(U.length>0&&O.show){let $=O.size/2,z=0;O.position==="above_price"?(Y-=O.paddingBottom+$,z=Y,Y-=$+O.paddingTop):(N+=O.paddingTop+$,z=N,N+=$+O.paddingBottom),M=Math.max(M,O.paddingLeft+ie(U,O.size,O.weight,O.family)+O.paddingRight),S.push({name:"text",attrs:{x:v,y:z,width:M,height:O.paddingTop+O.size+O.paddingBottom,text:U,align:b,baseline:"middle"},styles:{...O,backgroundColor:y}});}}),S.forEach(O=>{O.attrs.width=M,this.createFigure(O)?.draw(e);});}}}};var Qt=class extends K{drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getBounding(),o=r.getChart().getChartStore(),a=o.getStyles().indicator,s=a.lastValueMark,l=s.text;if(s.show){let c=r.getAxisComponent(),u=c.getRange(),h=o.getDataList().length-1,m=o.getIndicatorsByPaneId(r.getId()),p=o.getInnerFormatter(),g=o.getDecimalFold(),f=o.getThousandsSeparator();m.forEach(y=>{let b=y.result[h]??{};if(_(b)&&y.visible){let S=y.precision;lt(y,h,a,(x,C)=>{let T=b[x.key];if(w(T)){let A=c.convertToNicePixel(T),P=c.displayValueToText(c.realValueToDisplayValue(c.valueToRealValue(T,{range:u}),{range:u}),S);y.shouldFormatBigNumber&&(P=p.formatBigNumber(P)),P=g.format(f.format(P));let I=0,R="left";c.isFromZero()?(I=0,R="left"):(I=i.width,R="right");let D={...l,backgroundColor:C.color},E={x:I,y:A,text:P,align:R,baseline:"middle"},M=t.getTextRenderer();if(M!==null){let F=D.backgroundColor;if(F){let W=ht(E,D);We(e,[W],{...D,color:F});}M.queue({text:P,x:I,y:A,fontSize:D.size??12,fontFamily:D.family??"Helvetica Neue",color:D.color??"#ffffff",align:R,baseline:"middle",paddingLeft:D.paddingLeft,paddingTop:D.paddingTop});}else this.createFigure({name:"text",attrs:E,styles:D})?.draw(e);}});}});}}};var Ke=class extends je{coordinateToPointTimestampDataIndexFlag(){return false}drawDefaultFigures(e,t,r){this.drawFigures(e,t,this.getDefaultFigures(t,r));}getDefaultFigures(e,t){let r=this.getWidget(),i=r.getPane(),o=i.getChart().getChartStore(),a=o.getClickOverlayInfo(),s=[];if(e.needDefaultYAxisFigure&&e.id===a.overlay?.id&&a.paneId===i.getId()){let l=i.getAxisComponent(),c=r.getBounding(),u=Number.MAX_SAFE_INTEGER,d=Number.MIN_SAFE_INTEGER,h=l.isFromZero(),m="left",p=0;h?(m="left",p=0):(m="right",p=c.width);let g=o.getDecimalFold(),f=o.getThousandsSeparator();t.forEach((y,v)=>{let b=e.points[v];if(w(b.value)){u=Math.min(u,y.y),d=Math.max(d,y.y);let S=g.format(f.format(J(b.value,o.getSymbol()?.pricePrecision??j.PRICE)));s.push({type:"text",attrs:{x:p,y:y.y,text:S,align:m,baseline:"middle"},ignoreEvent:true});}}),t.length>1&&s.unshift({type:"rect",attrs:{x:0,y:u,width:c.width,height:d-u},ignoreEvent:true});}return s}getFigures(e,t){let r=this.getWidget(),i=r.getPane(),o=i.getChart(),a=i.getAxisComponent(),s=o.getXAxisPane().getAxisComponent(),l=r.getBounding();return e.createYAxisFigures?.({chart:o,overlay:e,coordinates:t,bounding:l,xAxis:s,yAxis:a})??[]}};var Je=class extends K{drawImp(e){let t=this.getWidget(),r=t.getPane(),i=t.getPane().getChart().getChartStore(),o=i.getCrosshair();if(L(o.paneId)&&this.compare(o,r.getId())){let a=i.getStyles().crosshair;if(a.show){let s=this.getDirectionStyles(a),l=s.text;if(s.show&&l.show){let c=t.getBounding(),u=r.getAxisComponent(),d=this.getText(o,i,u);e.font=se(l.size,l.weight,l.family);let h=e.measureText(d).width,m=this.getTextAttrs(d,h,o,c,u,l),p=t.getTextRenderer();if(p!==null){if(l.backgroundColor){let g=ht(m,l);We(e,[g],{...l,color:l.backgroundColor});}p.queue({text:d,x:m.x,y:m.y,fontSize:l.size,fontFamily:l.family,color:l.color,align:m.align,baseline:m.baseline,paddingLeft:l.paddingLeft,paddingTop:l.paddingTop});}else this.createFigure({name:"text",attrs:m,styles:l})?.draw(e);}}}}compare(e,t){return e.paneId===t}getDirectionStyles(e){return e.horizontal}getText(e,t,r){let i=r,o=r.convertFromPixel(e.y),a=0,s=false;i.isInCandle()?a=t.getSymbol()?.pricePrecision??j.PRICE:t.getIndicatorsByPaneId(e.paneId).forEach(d=>{a=Math.max(d.precision,a),s||=d.shouldFormatBigNumber;});let l=i.getRange(),c=i.displayValueToText(i.realValueToDisplayValue(i.valueToRealValue(o,{range:l}),{range:l}),a);return s&&(c=t.getInnerFormatter().formatBigNumber(c)),t.getDecimalFold().format(t.getThousandsSeparator().format(c))}getTextAttrs(e,t,r,i,o,a){let s=o,l=0,c="left";return s.isFromZero()?(l=0,c="left"):(l=i.width,c="right"),{x:l,y:r.y,text:e,align:c,baseline:"middle"}}};var Kt=class extends De{_yAxisView=new jt(this);_candleLastPriceLabelView=new Zt(this);_indicatorLastValueView=new Qt(this);_overlayYAxisView=new Ke(this);_crosshairHorizontalLabelView=new Je(this);constructor(e,t){super(e,t),this.setCursor("ns-resize"),this.addChild(this._overlayYAxisView);}getName(){return V.Y_AXIS}updateMain(e){let t=this.getPane().getOptions().state==="minimize";this._yAxisView.draw(e,t),t||(this.getPane().getAxisComponent().isInCandle()&&this._candleLastPriceLabelView.draw(e),this._indicatorLastValueView.draw(e));}updateOverlay(e){this.getPane().getOptions().state!=="minimize"&&(this._overlayYAxisView.draw(e),this._crosshairHorizontalLabelView.draw(e));}};var et=class{_container;_id;_chart;_bounding=ze();_originalBounding=ze();_visible=true;constructor(e,t){this._chart=e,this._id=t,this._container=oe("div",{width:"100%",margin:"0",padding:"0",position:"relative",overflow:"hidden",boxSizing:"border-box",backgroundColor:"inherit"});}getContainer(){return this._container}setVisible(e){this._visible!==e&&(this._container.style.display=e?"block":"none",this._visible=e);}getVisible(){return this._visible}getId(){return this._id}getChart(){return this._chart}getBounding(){return this._bounding}setOriginalBounding(e){G(this._originalBounding,e);}getOriginalBounding(){return this._originalBounding}update(e){this._bounding.height!==this._container.clientHeight&&(this._container.style.height=`${this._bounding.height}px`),this.updateImp(e??3,this._container,this._bounding);}};var tt=class extends et{_mainWidget;_yAxisWidget=null;_axis;_options={id:"",minHeight:30,dragEnabled:true,order:0,height:100,state:"normal",axis:{name:"normal",scrollZoomEnabled:true}};constructor(e,t,r){super(e,t);let i=this.getContainer();this._mainWidget=this.createMainWidget(i),this._yAxisWidget=this.createYAxisWidget(i),this.setOptions(r);}setOptions(e){let t=this.getId();if(t===B.CANDLE||t===B.X_AXIS){let o=e.axis?.name;(!_(this._axis)||_(o)&&this._options.axis.name!==o)&&(this._axis=this.createAxisComponent(o??"normal"));}else _(this._axis)||(this._axis=this.createAxisComponent("normal"));this._axis instanceof he&&this._axis.setAutoCalcTickFlag(true),G(this._options,e),this._axis.override({...this._options.axis,name:e.axis?.name??"normal"});let r=null,i="default";return this.getId()===B.X_AXIS?(r=this.getMainWidget().getContainer(),i="ew-resize"):(r=this.getYAxisWidget().getContainer(),i="ns-resize"),e.axis?.scrollZoomEnabled??true?r.style.cursor=i:r.style.cursor="default",this}getOptions(){return this._options}getAxisComponent(){return this._axis}setBounding(e,t,r,i){G(this.getBounding(),e);let o={};_(e.height)&&(o.height=e.height),_(e.top)&&(o.top=e.top),this._mainWidget.setBounding(o);let a=_(t);return a&&this._mainWidget.setBounding(t),_(this._yAxisWidget)&&(this._yAxisWidget.setBounding(o),this._axis.position==="left"?_(r)&&this._yAxisWidget.setBounding({...r,left:0}):_(i)&&(this._yAxisWidget.setBounding(i),a&&this._yAxisWidget.setBounding({left:(t.left??0)+(t.width??0)+(t.right??0)-(i.width??0)}))),this}getMainWidget(){return this._mainWidget}getYAxisWidget(){return this._yAxisWidget}updateImp(e){this._mainWidget.update(e),this._yAxisWidget?.update(e);}destroy(){this.getContainer().style.willChange="",this._mainWidget.destroy(),this._yAxisWidget?.destroy();}getImage(e){let{width:t,height:r}=this.getBounding(),i=oe("canvas",{width:`${t}px`,height:`${r}px`,boxSizing:"border-box"}),o=i.getContext("2d"),a=X(i);i.width=t*a,i.height=r*a,o.scale(a,a);let s=this._mainWidget.getBounding();if(o.drawImage(this._mainWidget.getImage(e),s.left,0,s.width,s.height),this._yAxisWidget!==null){let l=this._yAxisWidget.getBounding();o.drawImage(this._yAxisWidget.getImage(e),l.left,0,l.width,l.height);}return i}createYAxisWidget(e){return null}};var rt=class extends tt{createAxisComponent(e){let t=yn(e??"default");return new t(this)}createMainWidget(e){return new Ze(e,this)}createYAxisWidget(e){return new Kt(e,this)}};var er=class extends rt{createMainWidget(e){return new qt(e,this)}};var tr=class extends Qe{getAxisStyles(e){return e.xAxis}createAxisLine(e){return {coordinates:[{x:0,y:0},{x:e.width,y:0}]}}createTickLines(e,t,r){let i=r.tickLine,o=r.axisLine.size;return e.map(a=>({coordinates:[{x:a.coord,y:0},{x:a.coord,y:o+i.length}]}))}createTickTexts(e,t,r){let i=r.tickText,o=r.axisLine.size,a=r.tickLine.length;return e.map(s=>({x:s.coord,y:o+a+i.marginStart,text:s.text,align:"center",baseline:"top"}))}};var rr=class extends Ke{coordinateToPointTimestampDataIndexFlag(){return true}coordinateToPointValueFlag(){return false}getCompleteOverlays(){return this.getWidget().getPane().getChart().getChartStore().getOverlaysByPaneId()}getProgressOverlay(){return this.getWidget().getPane().getChart().getChartStore().getProgressOverlayInfo()?.overlay??null}getDefaultFigures(e,t){let r=[],i=this.getWidget(),a=i.getPane().getChart().getChartStore(),s=a.getClickOverlayInfo();if(e.needDefaultXAxisFigure&&e.id===s.overlay?.id){let l=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER;t.forEach((u,d)=>{l=Math.min(l,u.x),c=Math.max(c,u.x);let h=e.points[d];if(w(h.timestamp)){let m=a.getInnerFormatter().formatDate(h.timestamp,"YYYY-MM-DD HH:mm","crosshair");r.push({type:"text",attrs:{x:u.x,y:0,text:m,align:"center"},ignoreEvent:true});}}),t.length>1&&r.unshift({type:"rect",attrs:{x:l,y:0,width:c-l,height:i.getBounding().height},ignoreEvent:true});}return r}getFigures(e,t){let r=this.getWidget(),i=r.getPane(),o=i.getChart(),a=i.getAxisComponent(),s=o.getXAxisPane().getAxisComponent(),l=r.getBounding();return e.createXAxisFigures?.({chart:o,overlay:e,coordinates:t,bounding:l,xAxis:s,yAxis:a})??[]}};var ir=class extends Je{compare(e){return _(e.timestamp)}getDirectionStyles(e){return e.vertical}getText(e,t){let r=e.timestamp;return t.getInnerFormatter().formatDate(r,Pr[t.getPeriod()?.timespan??"day"],"crosshair")}getTextAttrs(e,t,r,i,o,a){let s=r.realX,l=0,c="center";return s-t/2-a.paddingLeft<0?(l=0,c="left"):s+t/2+a.paddingRight>i.width?(l=i.width,c="right"):l=s,{x:l,y:0,text:e,align:c,baseline:"top"}}};var or=class extends De{_xAxisView=new tr(this);_overlayXAxisView=new rr(this);_crosshairVerticalLabelView=new ir(this);constructor(e,t){super(e,t),this.setCursor("ew-resize"),this.addChild(this._overlayXAxisView);}getName(){return V.X_AXIS}updateMain(e){this._xAxisView.draw(e);}updateOverlay(e){this._overlayXAxisView.draw(e),this._crosshairVerticalLabelView.draw(e);}};var nr=class extends tt{createAxisComponent(e){let t=bn(e);return new t(this)}createMainWidget(e){return new or(e,this)}};function Jn(n,e){let t=0;return function(){let r=Date.now();r-t>(e)&&(n.apply(this,arguments),t=r);}}var ar=class extends Ge{_dragFlag=false;_dragStartY=0;_topPaneHeight=0;_bottomPaneHeight=0;_topPane=null;_bottomPane=null;constructor(e,t){super(e,t),this.registerEvent("touchStartEvent",this._mouseDownEvent.bind(this)).registerEvent("touchMoveEvent",this._pressedMouseMoveEvent.bind(this)).registerEvent("touchEndEvent",this._mouseUpEvent.bind(this)).registerEvent("mouseDownEvent",this._mouseDownEvent.bind(this)).registerEvent("mouseUpEvent",this._mouseUpEvent.bind(this)).registerEvent("pressedMouseMoveEvent",this._pressedMouseMoveEvent.bind(this)).registerEvent("mouseEnterEvent",this._mouseEnterEvent.bind(this)).registerEvent("mouseLeaveEvent",this._mouseLeaveEvent.bind(this));}getName(){return V.SEPARATOR}_mouseDownEvent(e){this._dragFlag=true,this._dragStartY=e.pageY;let t=this.getPane(),r=t.getChart();this._topPane=t.getTopPane(),this._bottomPane=t.getBottomPane();let i=r.getDrawPanes();if(this._topPane.getOptions().state==="minimize"){let o=i.findIndex(a=>a.getId()===this._topPane?.getId());for(let a=o-1;a>-1;a--){let s=i[a];if(s.getOptions().state!=="minimize"){this._topPane=s;break}}}if(this._bottomPane.getOptions().state==="minimize"){let o=i.findIndex(a=>a.getId()===this._bottomPane?.getId());for(let a=o+1;a<i.length;a++){let s=i[a];if(s.getOptions().state!=="minimize"){this._bottomPane=s;break}}}return this._topPaneHeight=this._topPane.getBounding().height,this._bottomPaneHeight=this._bottomPane.getBounding().height,true}_mouseUpEvent(){return this._dragFlag=false,this._topPane=null,this._bottomPane=null,this._topPaneHeight=0,this._bottomPaneHeight=0,this._mouseLeaveEvent()}_pressedMouseMoveEvent=Jn(this._pressedTouchMouseMoveEvent,20);_pressedTouchMouseMoveEvent(e){let t=e.pageY-this._dragStartY,r=t<0;if(_(this._topPane)&&_(this._bottomPane)){let i=this._bottomPane.getOptions();if(this._topPane.getOptions().state!=="minimize"&&i.state!=="minimize"&&i.dragEnabled){let o=null,a=null,s=0,l=0;r?(o=this._topPane,a=this._bottomPane,s=this._topPaneHeight,l=this._bottomPaneHeight):(o=this._bottomPane,a=this._topPane,s=this._bottomPaneHeight,l=this._topPaneHeight);let c=o.getOptions().minHeight;if(s>c){let u=Math.max(s-Math.abs(t),c),d=s-u;o.setBounding({height:u}),a.setBounding({height:l+d});let h=this.getPane(),m=h.getChart();m.getChartStore().executeAction("onPaneDrag",{paneId:h.getId()}),m.layout({measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});}}}return true}_mouseEnterEvent(){let e=this.getPane();if(e.getBottomPane().getOptions().dragEnabled){let i=e.getChart().getStyles().separator;return this.getContainer().style.background=i.activeBackgroundColor,true}return false}_mouseLeaveEvent(){return this._dragFlag?false:(this.getContainer().style.background="transparent",true)}createContainer(){return oe("div",{width:"100%",height:`${He}px`,margin:"0",padding:"0",position:"absolute",top:"-3px",zIndex:"20",boxSizing:"border-box",cursor:"ns-resize"})}updateImp(e,t,r){if(r===4||r===2){let i=this.getPane().getChart().getStyles().separator;e.style.top=`${-Math.floor((He-i.size)/2)}px`,e.style.height=`${He}px`;}}};var sr=class extends et{_topPane;_bottomPane;_separatorWidget;constructor(e,t,r,i){super(e,t),this.getContainer().style.overflow="",this._topPane=r,this._bottomPane=i,this._separatorWidget=new ar(this.getContainer(),this);}setBounding(e){return G(this.getBounding(),e),this}getTopPane(){return this._topPane}setTopPane(e){return this._topPane=e,this}getBottomPane(){return this._bottomPane}setBottomPane(e){return this._bottomPane=e,this}getWidget(){return this._separatorWidget}getImage(e){let{width:t,height:r}=this.getBounding(),i=this.getChart().getStyles().separator,o=oe("canvas",{width:`${t}px`,height:`${r}px`,boxSizing:"border-box"}),a=o.getContext("2d"),s=X(o);return o.width=t*s,o.height=r*s,a.scale(s,s),a.fillStyle=i.color,a.fillRect(0,0,t,r),o}updateImp(e,t,r){if(e===4||e===2){let i=this.getChart().getStyles().separator;t.style.backgroundColor=i.color,t.style.height=`${r.height}px`,t.style.marginLeft=`${r.left}px`,t.style.width=`${r.width}px`,this._separatorWidget.update(e);}}};function gi(){return typeof window>"u"?false:window.navigator.userAgent.toLowerCase().includes("firefox")}function Or(){return typeof window>"u"?false:/iPhone|iPad|iPod|iOS/.test(window.navigator.userAgent)}var Vr={ResetClick:500,LongTap:500,PreventFiresTouchEvents:500},yt={CancelClick:5,CancelTap:5,DoubleClick:5,DoubleTap:30},lr={Left:0,Middle:1,Right:2},ea=10,cr=class{_target;_handler;_options;_clickCount=0;_clickTimeoutId=null;_clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY};_tapCount=0;_tapTimeoutId=null;_tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY};_longTapTimeoutId=null;_longTapActive=false;_mouseMoveStartCoordinate=null;_touchMoveStartCoordinate=null;_touchMoveExceededManhattanDistance=false;_cancelClick=false;_cancelTap=false;_unsubscribeOutsideMouseEvents=null;_unsubscribeOutsideTouchEvents=null;_unsubscribeMobileSafariEvents=null;_unsubscribeMousemove=null;_unsubscribeMouseWheel=null;_unsubscribeContextMenu=null;_unsubscribeRootMouseEvents=null;_unsubscribeRootTouchEvents=null;_startPinchMiddleCoordinate=null;_startPinchDistance=0;_pinchPrevented=false;_preventTouchDragProcess=false;_mousePressed=false;_lastTouchEventTimeStamp=0;_activeTouchId=null;_acceptMouseLeave=!Or();constructor(e,t,r){this._target=e,this._handler=t,this._options=r,this._init();}destroy(){this._unsubscribeOutsideMouseEvents!==null&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),this._unsubscribeOutsideTouchEvents!==null&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),this._unsubscribeMousemove!==null&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),this._unsubscribeMouseWheel!==null&&(this._unsubscribeMouseWheel(),this._unsubscribeMouseWheel=null),this._unsubscribeContextMenu!==null&&(this._unsubscribeContextMenu(),this._unsubscribeContextMenu=null),this._unsubscribeRootMouseEvents!==null&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),this._unsubscribeRootTouchEvents!==null&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),this._unsubscribeMobileSafariEvents!==null&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout();}_mouseEnterHandler(e){this._unsubscribeMousemove?.(),this._unsubscribeMouseWheel?.(),this._unsubscribeContextMenu?.();let t=this._mouseMoveHandler.bind(this);this._unsubscribeMousemove=()=>{this._target.removeEventListener("mousemove",t);},this._target.addEventListener("mousemove",t);let r=this._mouseWheelHandler.bind(this);this._unsubscribeMouseWheel=()=>{this._target.removeEventListener("wheel",r);},this._target.addEventListener("wheel",r,{passive:false});let i=this._contextMenuHandler.bind(this);this._unsubscribeContextMenu=()=>{this._target.removeEventListener("contextmenu",i);},this._target.addEventListener("contextmenu",i,{passive:false}),!this._firesTouchEvents(e)&&(this._processEvent(this._makeCompatEvent(e),this._handler.mouseEnterEvent),this._acceptMouseLeave=true);}_resetClickTimeout(){this._clickTimeoutId!==null&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY};}_resetTapTimeout(){this._tapTimeoutId!==null&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY};}_mouseMoveHandler(e){if(this._mousePressed||this._touchMoveStartCoordinate!==null||this._firesTouchEvents(e))return;let r=e.getCoalescedEvents?.(),i=r!==void 0&&r.length>0?r[r.length-1]:e;this._processEvent(this._makeCompatEvent(i),this._handler.mouseMoveEvent),this._acceptMouseLeave=true;}_mouseWheelHandler(e){if(Math.abs(e.deltaX)>Math.abs(e.deltaY)){if(!_(this._handler.mouseWheelHortEvent)||(this._preventDefault(e),Math.abs(e.deltaX)===0))return;this._handler.mouseWheelHortEvent(this._makeCompatEvent(e),-e.deltaX);}else {if(!_(this._handler.mouseWheelVertEvent))return;let t=-(e.deltaY/100);if(t===0)return;switch(this._preventDefault(e),e.deltaMode){case e.DOM_DELTA_PAGE:{t*=120;break}case e.DOM_DELTA_LINE:{t*=32;break}}if(t!==0){let r=Math.sign(t)*Math.min(1,Math.abs(t));this._handler.mouseWheelVertEvent(this._makeCompatEvent(e),r);}}}_contextMenuHandler(e){this._preventDefault(e);}_touchMoveHandler(e){let t=this._touchWithId(e.changedTouches,this._activeTouchId);if(t===null||(this._lastTouchEventTimeStamp=this._eventTimeStamp(e),this._startPinchMiddleCoordinate!==null)||this._preventTouchDragProcess)return;this._pinchPrevented=true;let r=this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._touchMoveStartCoordinate),{xOffset:i,yOffset:o,manhattanDistance:a}=r;if(!(!this._touchMoveExceededManhattanDistance&&a<yt.CancelTap)){if(!this._touchMoveExceededManhattanDistance){let s=i*.5,l=o>=s&&!this._options.treatVertDragAsPageScroll(),c=s>o&&!this._options.treatHorzDragAsPageScroll();!l&&!c&&(this._preventTouchDragProcess=true),this._touchMoveExceededManhattanDistance=true,this._cancelTap=true,this._clearLongTapTimeout(),this._resetTapTimeout();}this._preventTouchDragProcess||this._processEvent(this._makeCompatEvent(e,t),this._handler.touchMoveEvent);}}_mouseMoveWithDownHandler(e){if(e.button!==lr.Left)return;let t=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._mouseMoveStartCoordinate),{manhattanDistance:r}=t;r>=yt.CancelClick&&(this._cancelClick=true,this._resetClickTimeout()),this._cancelClick&&this._processEvent(this._makeCompatEvent(e),this._handler.pressedMouseMoveEvent);}_mouseTouchMoveWithDownInfo(e,t){let r=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y),o=r+i;return {xOffset:r,yOffset:i,manhattanDistance:o}}_onFirefoxOutsideMouseUp=e=>{this._mouseUpHandler(e);};_onMobileSafariDoubleClick=e=>{if(this._firesTouchEvents(e)){if(++this._tapCount,this._tapTimeoutId!==null&&this._tapCount>1){let{manhattanDistance:t}=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._tapCoordinate);t<yt.DoubleTap&&!this._cancelTap&&this._processEvent(this._makeCompatEvent(e),this._handler.doubleTapEvent),this._resetTapTimeout();}}else if(++this._clickCount,this._clickTimeoutId!==null&&this._clickCount>1){let{manhattanDistance:t}=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._clickCoordinate);t<yt.DoubleClick&&!this._cancelClick&&this._processEvent(this._makeCompatEvent(e),this._handler.mouseDoubleClickEvent),this._resetClickTimeout();}};_touchEndHandler(e){let t=this._touchWithId(e.changedTouches,this._activeTouchId);if(t===null&&e.touches.length===0&&(t=e.changedTouches[0]),t===null)return;this._activeTouchId=null,this._lastTouchEventTimeStamp=this._eventTimeStamp(e),this._clearLongTapTimeout(),this._touchMoveStartCoordinate=null,this._unsubscribeRootTouchEvents!==null&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);let r=this._makeCompatEvent(e,t);if(this._processEvent(r,this._handler.touchEndEvent),++this._tapCount,this._tapTimeoutId!==null&&this._tapCount>1){let{manhattanDistance:i}=this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._tapCoordinate);i<yt.DoubleTap&&!this._cancelTap&&this._processEvent(r,this._handler.doubleTapEvent),this._resetTapTimeout();}else this._cancelTap||(this._processEvent(r,this._handler.tapEvent),_(this._handler.tapEvent)&&this._preventDefault(e));this._tapCount===0&&this._preventDefault(e),e.touches.length===0&&this._longTapActive&&(this._longTapActive=false,this._preventDefault(e));}_mouseUpHandler(e){if(e.button!==lr.Left)return;let t=this._makeCompatEvent(e);if(this._mouseMoveStartCoordinate=null,this._mousePressed=false,this._unsubscribeRootMouseEvents!==null&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),gi()&&this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp),!this._firesTouchEvents(e))if(this._processEvent(t,this._handler.mouseUpEvent),++this._clickCount,this._clickTimeoutId!==null&&this._clickCount>1){let{manhattanDistance:r}=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._clickCoordinate);r<yt.DoubleClick&&!this._cancelClick&&this._processEvent(t,this._handler.mouseDoubleClickEvent),this._resetClickTimeout();}else this._cancelClick||this._processEvent(t,this._handler.mouseClickEvent);}_clearLongTapTimeout(){this._longTapTimeoutId!==null&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null);}_touchStartHandler(e){if(this._activeTouchId!==null)return;let t=e.changedTouches[0];this._activeTouchId=t.identifier,this._lastTouchEventTimeStamp=this._eventTimeStamp(e);let r=this._target.ownerDocument.documentElement;this._cancelTap=false,this._touchMoveExceededManhattanDistance=false,this._preventTouchDragProcess=false,this._touchMoveStartCoordinate=this._getCoordinate(t),this._unsubscribeRootTouchEvents!==null&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);{let i=this._touchMoveHandler.bind(this),o=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=()=>{r.removeEventListener("touchmove",i),r.removeEventListener("touchend",o);},r.addEventListener("touchmove",i,{passive:false}),r.addEventListener("touchend",o,{passive:false}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,e),Vr.LongTap);}this._processEvent(this._makeCompatEvent(e,t),this._handler.touchStartEvent),this._tapTimeoutId===null&&(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),Vr.ResetClick),this._tapCoordinate=this._getCoordinate(t));}_mouseDownHandler(e){if(e.button===lr.Right){this._preventDefault(e),this._processEvent(this._makeCompatEvent(e),this._handler.mouseRightClickEvent);return}if(e.button!==lr.Left)return;let t=this._target.ownerDocument.documentElement;gi()&&t.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=false,this._mouseMoveStartCoordinate=this._getCoordinate(e),this._unsubscribeRootMouseEvents!==null&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);{let r=this._mouseMoveWithDownHandler.bind(this),i=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=()=>{t.removeEventListener("mousemove",r),t.removeEventListener("mouseup",i);},t.addEventListener("mousemove",r),t.addEventListener("mouseup",i);}this._mousePressed=true,!this._firesTouchEvents(e)&&(this._processEvent(this._makeCompatEvent(e),this._handler.mouseDownEvent),this._clickTimeoutId===null&&(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),Vr.ResetClick),this._clickCoordinate=this._getCoordinate(e)));}_init(){this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));{let e=this._target.ownerDocument,t=r=>{this._handler.mouseDownOutsideEvent!=null&&(r.composed&&this._target.contains(r.composedPath()[0])||r.target!==null&&this._target.contains(r.target)||this._handler.mouseDownOutsideEvent({x:0,y:0,pageX:0,pageY:0}));};this._unsubscribeOutsideTouchEvents=()=>{e.removeEventListener("touchstart",t);},this._unsubscribeOutsideMouseEvents=()=>{e.removeEventListener("mousedown",t);},e.addEventListener("mousedown",t),e.addEventListener("touchstart",t,{passive:true});}Or()&&(this._unsubscribeMobileSafariEvents=()=>{this._target.removeEventListener("dblclick",this._onMobileSafariDoubleClick);},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:true}),this._target.addEventListener("mousedown",e=>{if(e.button===lr.Middle)return e.preventDefault(),false}),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",()=>{},{passive:false});}_initPinch(){!_(this._handler.pinchStartEvent)&&!_(this._handler.pinchEvent)&&!_(this._handler.pinchEndEvent)||(this._target.addEventListener("touchstart",e=>{this._checkPinchState(e.touches);},{passive:true}),this._target.addEventListener("touchmove",e=>{if(!(e.touches.length!==2||this._startPinchMiddleCoordinate===null)&&_(this._handler.pinchEvent)){let r=this._getTouchDistance(e.touches[0],e.touches[1])/this._startPinchDistance;this._handler.pinchEvent({...this._startPinchMiddleCoordinate,pageX:0,pageY:0},r),this._preventDefault(e);}},{passive:false}),this._target.addEventListener("touchend",e=>{this._checkPinchState(e.touches);}));}_checkPinchState(e){e.length===1&&(this._pinchPrevented=false),e.length!==2||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(e);}_startPinch(e){let t=this._target.getBoundingClientRect();this._startPinchMiddleCoordinate={x:(e[0].clientX-t.left+(e[1].clientX-t.left))/2,y:(e[0].clientY-t.top+(e[1].clientY-t.top))/2},this._startPinchDistance=this._getTouchDistance(e[0],e[1]),_(this._handler.pinchStartEvent)&&this._handler.pinchStartEvent({x:0,y:0,pageX:0,pageY:0}),this._clearLongTapTimeout();}_stopPinch(){this._startPinchMiddleCoordinate!==null&&(this._startPinchMiddleCoordinate=null,_(this._handler.pinchEndEvent)&&this._handler.pinchEndEvent({x:0,y:0,pageX:0,pageY:0}));}_mouseLeaveHandler(e){this._unsubscribeMousemove?.(),this._unsubscribeMouseWheel?.(),this._unsubscribeContextMenu?.(),!this._firesTouchEvents(e)&&this._acceptMouseLeave&&(this._processEvent(this._makeCompatEvent(e),this._handler.mouseLeaveEvent),this._acceptMouseLeave=!Or());}_longTapHandler(e){let t=this._touchWithId(e.touches,this._activeTouchId);t!==null&&(this._processEvent(this._makeCompatEvent(e,t),this._handler.longTapEvent),this._cancelTap=true,this._longTapActive=true);}_firesTouchEvents(e){return _(e.sourceCapabilities?.firesTouchEvents)?e.sourceCapabilities.firesTouchEvents:this._eventTimeStamp(e)<this._lastTouchEventTimeStamp+Vr.PreventFiresTouchEvents}_processEvent(e,t){t?.call(this._handler,e);}_makeCompatEvent(e,t){let r=t??e,i=this._target.getBoundingClientRect();return {x:r.clientX-i.left,y:r.clientY-i.top,pageX:r.pageX,pageY:r.pageY,isTouch:!e.type.startsWith("mouse")&&e.type!=="contextmenu"&&e.type!=="click"&&e.type!=="wheel",preventDefault:()=>{e.type!=="touchstart"&&this._preventDefault(e);}}}_getTouchDistance(e,t){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(r*r+i*i)}_preventDefault(e){e.cancelable&&e.preventDefault();}_getCoordinate(e){return {x:e.pageX,y:e.pageY}}_eventTimeStamp(e){return e.timeStamp??performance.now()}_touchWithId(e,t){for(let r=0;r<e.length;++r)if(e[r].identifier===t)return e[r];return null}};var ur=class{_container;_chart;_event;_flingStartTime=new Date().getTime();_flingScrollRequestId=null;_startScrollCoordinate=null;_touchCoordinate=null;_touchCancelCrosshair=false;_touchZoomed=false;_pinchScale=1;_mouseDownWidget=null;_prevYAxisRange=null;_xAxisStartScaleCoordinate=null;_xAxisStartScaleDistance=0;_xAxisScale=1;_yAxisStartScaleDistance=0;_mouseMoveTriggerWidgetInfo={pane:null,widget:null};constructor(e,t){this._container=e,this._chart=t,this._event=new cr(e,this,{treatVertDragAsPageScroll:()=>false,treatHorzDragAsPageScroll:()=>false});}pinchStartEvent(){return this._touchZoomed=true,this._pinchScale=1,true}pinchEvent(e,t){let{pane:r,widget:i}=this._findWidgetByEvent(e);if(r?.getId()!==B.X_AXIS&&i?.getName()===V.MAIN){let o=this._makeWidgetEvent(e,i),a=(t-this._pinchScale)*5;return this._pinchScale=t,this._chart.getChartStore().zoom(a,{x:o.x,y:o.y},"main"),true}return false}mouseWheelHortEvent(e,t){let r=this._chart.getChartStore();return r.startScroll(),r.scroll(t),true}mouseWheelVertEvent(e,t){let{widget:r}=this._findWidgetByEvent(e),i=this._makeWidgetEvent(e,r);return r?.getName()===V.MAIN?(this._chart.getChartStore().zoom(t,{x:i.x,y:i.y},"main"),true):false}mouseDownEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e);if(this._mouseDownWidget=r,r!==null){let i=this._makeWidgetEvent(e,r);switch(r.getName()){case V.SEPARATOR:return r.dispatchEvent("mouseDownEvent",i);case V.MAIN:{let a=t.getAxisComponent();if(!a.getAutoCalcTickFlag()){let s=a.getRange();this._prevYAxisRange={...s};}return this._startScrollCoordinate={x:i.x,y:i.y},this._chart.getChartStore().startScroll(),r.dispatchEvent("mouseDownEvent",i)}case V.X_AXIS:return this._processXAxisScrollStartEvent(r,i);case V.Y_AXIS:return this._processYAxisScaleStartEvent(r,i)}}return false}mouseMoveEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e),i=this._makeWidgetEvent(e,r);if((this._mouseMoveTriggerWidgetInfo.pane?.getId()!==t?.getId()||this._mouseMoveTriggerWidgetInfo.widget?.getName()!==r?.getName())&&(r?.dispatchEvent("mouseEnterEvent",i),this._mouseMoveTriggerWidgetInfo.widget?.dispatchEvent("mouseLeaveEvent",i),this._mouseMoveTriggerWidgetInfo={pane:t,widget:r}),r!==null)switch(r.getName()){case V.MAIN:{let a=r.dispatchEvent("mouseMoveEvent",i),s={x:i.x,y:i.y,paneId:t?.getId()};return a?(r.getForceCursor()!=="pointer"&&(s=void 0),r.setCursor("pointer")):r.setCursor("crosshair"),this._chart.getChartStore().setCrosshair(s),a}case V.SEPARATOR:case V.X_AXIS:case V.Y_AXIS:{let a=r.dispatchEvent("mouseMoveEvent",i);return this._chart.getChartStore().setCrosshair(),a}}return false}pressedMouseMoveEvent(e){if(this._mouseDownWidget!==null&&this._mouseDownWidget.getName()===V.SEPARATOR)return this._mouseDownWidget.dispatchEvent("pressedMouseMoveEvent",e);let{pane:t,widget:r}=this._findWidgetByEvent(e);if(r!==null&&this._mouseDownWidget?.getPane().getId()===t?.getId()&&this._mouseDownWidget?.getName()===r.getName()){let i=this._makeWidgetEvent(e,r);switch(r.getName()){case V.MAIN:{let a,s=r.dispatchEvent("pressedMouseMoveEvent",i);return s||this._processMainScrollingEvent(r,i),(!s||r.getForceCursor()==="pointer")&&(a={x:i.x,y:i.y,paneId:t?.getId()}),this._chart.getChartStore().setCrosshair(a,{forceInvalidate:true}),s}case V.X_AXIS:return this._processXAxisScrollingEvent(r,i);case V.Y_AXIS:return this._processYAxisScalingEvent(r,i)}}return false}mouseUpEvent(e){let{widget:t}=this._findWidgetByEvent(e),r=false;if(t!==null){let i=this._makeWidgetEvent(e,t);switch(t.getName()){case V.MAIN:case V.SEPARATOR:case V.X_AXIS:case V.Y_AXIS:{r=t.dispatchEvent("mouseUpEvent",i);break}}r&&this._chart.updatePane(1);}return this._mouseDownWidget=null,this._startScrollCoordinate=null,this._prevYAxisRange=null,this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0,r}mouseClickEvent(e){let{widget:t}=this._findWidgetByEvent(e);if(t!==null){let r=this._makeWidgetEvent(e,t);return t.dispatchEvent("mouseClickEvent",r)}return false}mouseRightClickEvent(e){let{widget:t}=this._findWidgetByEvent(e),r=false;if(t!==null){let i=this._makeWidgetEvent(e,t);switch(t.getName()){case V.MAIN:case V.X_AXIS:case V.Y_AXIS:{r=t.dispatchEvent("mouseRightClickEvent",i);break}}r&&this._chart.updatePane(1);}return false}mouseDoubleClickEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e);if(r!==null)switch(r.getName()){case V.MAIN:{let o=this._makeWidgetEvent(e,r);return r.dispatchEvent("mouseDoubleClickEvent",o)}case V.Y_AXIS:{let o=t.getAxisComponent();if(!o.getAutoCalcTickFlag())return o.setAutoCalcTickFlag(true),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true}),true;break}}return false}mouseLeaveEvent(){return this._chart.getChartStore().setCrosshair(),true}touchStartEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e);if(r!==null){let i=this._makeWidgetEvent(e,r);switch(i.preventDefault?.(),r.getName()){case V.MAIN:{let a=this._chart.getChartStore();if(r.dispatchEvent("mouseDownEvent",i))return this._touchCancelCrosshair=true,this._touchCoordinate=null,a.setCrosshair(void 0,{notInvalidate:true}),this._chart.updatePane(1),true;this._flingScrollRequestId!==null&&(Sr(this._flingScrollRequestId),this._flingScrollRequestId=null),this._flingStartTime=new Date().getTime();let s=t.getAxisComponent();if(!s.getAutoCalcTickFlag()){let l=s.getRange();this._prevYAxisRange={...l};}if(this._startScrollCoordinate={x:i.x,y:i.y},a.startScroll(),this._touchZoomed=false,this._touchCoordinate!==null){let l=i.x-this._touchCoordinate.x,c=i.y-this._touchCoordinate.y;Math.sqrt(l*l+c*c)<ea?(this._touchCoordinate={x:i.x,y:i.y},a.setCrosshair({x:i.x,y:i.y,paneId:t?.getId()})):(this._touchCoordinate=null,this._touchCancelCrosshair=true,a.setCrosshair());}return true}case V.X_AXIS:return this._processXAxisScrollStartEvent(r,i);case V.Y_AXIS:return this._processYAxisScaleStartEvent(r,i)}}return false}touchMoveEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e);if(r!==null){let i=this._makeWidgetEvent(e,r),o=r.getName(),a=this._chart.getChartStore();switch(o){case V.MAIN:return r.dispatchEvent("pressedMouseMoveEvent",i)?(i.preventDefault?.(),a.setCrosshair(void 0,{notInvalidate:true}),this._chart.updatePane(1),true):(this._touchCoordinate!==null?(i.preventDefault?.(),a.setCrosshair({x:i.x,y:i.y,paneId:t?.getId()})):this._processMainScrollingEvent(r,i),true);case V.X_AXIS:return i.preventDefault?.(),this._processXAxisScrollingEvent(r,i);case V.Y_AXIS:return this._processYAxisScalingEvent(r,i)}}return false}touchEndEvent(e){let{widget:t}=this._findWidgetByEvent(e);if(t!==null){let r=this._makeWidgetEvent(e,t);switch(t.getName()){case V.MAIN:{if(t.dispatchEvent("mouseUpEvent",r),this._startScrollCoordinate!==null){let o=new Date().getTime()-this._flingStartTime,s=(r.x-this._startScrollCoordinate.x)/(o>0?o:1)*20;if(o<200&&Math.abs(s)>0){let l=this._chart.getChartStore(),c=()=>{this._flingScrollRequestId=xe(()=>{l.startScroll(),l.scroll(s),s=s*(1-.025),Math.abs(s)<1?this._flingScrollRequestId!==null&&(Sr(this._flingScrollRequestId),this._flingScrollRequestId=null):c();});};c();}}return true}case V.X_AXIS:case V.Y_AXIS:t.dispatchEvent("mouseUpEvent",r)&&this._chart.updatePane(1);}this._startScrollCoordinate=null,this._prevYAxisRange=null,this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0;}return false}tapEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e),i=false;if(r!==null){let o=this._makeWidgetEvent(e,r),a=r.dispatchEvent("mouseClickEvent",o);if(r.getName()===V.MAIN){let s=this._makeWidgetEvent(e,r),l=this._chart.getChartStore();a?(this._touchCancelCrosshair=true,this._touchCoordinate=null,l.setCrosshair(void 0,{notInvalidate:true}),i=true):(!this._touchCancelCrosshair&&!this._touchZoomed&&(this._touchCoordinate={x:s.x,y:s.y},l.setCrosshair({x:s.x,y:s.y,paneId:t?.getId()},{notInvalidate:true}),i=true),this._touchCancelCrosshair=false);}(i||a)&&this._chart.updatePane(1);}return i}doubleTapEvent(e){return this.mouseDoubleClickEvent(e)}longTapEvent(e){let{pane:t,widget:r}=this._findWidgetByEvent(e);if(r!==null&&r.getName()===V.MAIN){let i=this._makeWidgetEvent(e,r);return this._touchCoordinate={x:i.x,y:i.y},this._chart.getChartStore().setCrosshair({x:i.x,y:i.y,paneId:t?.getId()}),true}return false}_processMainScrollingEvent(e,t){if(this._startScrollCoordinate!==null){let r=e.getPane().getAxisComponent();if(this._prevYAxisRange!==null&&!r.getAutoCalcTickFlag()&&r.scrollZoomEnabled){t.preventDefault?.();let{from:o,to:a,range:s}=this._prevYAxisRange,l=0;r.reverse?l=this._startScrollCoordinate.y-t.y:l=t.y-this._startScrollCoordinate.y;let c=e.getBounding(),u=l/c.height,d=s*u,h=o+d,m=a+d,p=r.valueToRealValue(h,{range:this._prevYAxisRange}),g=r.valueToRealValue(m,{range:this._prevYAxisRange}),f=r.realValueToDisplayValue(p,{range:this._prevYAxisRange}),y=r.realValueToDisplayValue(g,{range:this._prevYAxisRange});r.setRange({from:h,to:m,range:m-h,realFrom:p,realTo:g,realRange:g-p,displayFrom:f,displayTo:y,displayRange:y-f});}let i=t.x-this._startScrollCoordinate.x;this._chart.getChartStore().scroll(i);}}_processXAxisScrollStartEvent(e,t){let r=e.dispatchEvent("mouseDownEvent",t);return r&&this._chart.updatePane(1),this._xAxisStartScaleCoordinate={x:t.x,y:t.y},this._xAxisStartScaleDistance=t.pageX,r}_processXAxisScrollingEvent(e,t){let r=e.dispatchEvent("pressedMouseMoveEvent",t);if(r)this._chart.updatePane(1);else if(e.getPane().getAxisComponent().scrollZoomEnabled&&this._xAxisStartScaleDistance!==0){let o=this._xAxisStartScaleDistance/t.pageX;if(Number.isFinite(o)){let a=(o-this._xAxisScale)*10;this._xAxisScale=o,this._chart.getChartStore().zoom(a,this._xAxisStartScaleCoordinate,"xAxis");}}return r}_processYAxisScaleStartEvent(e,t){let r=e.dispatchEvent("mouseDownEvent",t);r&&this._chart.updatePane(1);let i=e.getPane().getAxisComponent().getRange();return this._prevYAxisRange={...i},this._yAxisStartScaleDistance=t.pageY,r}_processYAxisScalingEvent(e,t){let r=e.dispatchEvent("pressedMouseMoveEvent",t);if(r)this._chart.updatePane(1);else {let i=e.getPane().getAxisComponent();if(this._prevYAxisRange!==null&&i.scrollZoomEnabled&&this._yAxisStartScaleDistance!==0){t.preventDefault?.();let{from:o,to:a,range:s}=this._prevYAxisRange,l=t.pageY/this._yAxisStartScaleDistance,c=s*l,u=(c-s)/2,d=o-u,h=a+u,m=i.valueToRealValue(d,{range:this._prevYAxisRange}),p=i.valueToRealValue(h,{range:this._prevYAxisRange}),g=i.realValueToDisplayValue(m,{range:this._prevYAxisRange}),f=i.realValueToDisplayValue(p,{range:this._prevYAxisRange});i.setRange({from:d,to:h,range:c,realFrom:m,realTo:p,realRange:p-m,displayFrom:g,displayTo:f,displayRange:f-g}),this._chart.layout({measureWidth:true,update:true,buildYAxisTick:true});}}return r}_findWidgetByEvent(e){let{x:t,y:r}=e,i=this._chart.getSeparatorPanes(),o=this._chart.getStyles().separator.size;for(let c of i){let u=c[1],d=u.getBounding(),h=d.top-Math.round((He-o)/2);if(t>=d.left&&t<=d.left+d.width&&r>=h&&r<=h+He)return {pane:u,widget:u.getWidget()}}let a=this._chart.getDrawPanes(),s=null;for(let c of a){let u=c.getBounding();if(t>=u.left&&t<=u.left+u.width&&r>=u.top&&r<=u.top+u.height){s=c;break}}let l=null;if(s!==null){if(!_(l)){let c=s.getMainWidget(),u=c.getBounding();t>=u.left&&t<=u.left+u.width&&r>=u.top&&r<=u.top+u.height&&(l=c);}if(!_(l)){let c=s.getYAxisWidget();if(c!==null){let u=c.getBounding();t>=u.left&&t<=u.left+u.width&&r>=u.top&&r<=u.top+u.height&&(l=c);}}}return {pane:s,widget:l}}_makeWidgetEvent(e,t){let r=t?.getBounding()??null;return {...e,x:e.x-(r?.left??0),y:e.y-(r?.top??0)}}destroy(){this._flingScrollRequestId!==null&&(Sr(this._flingScrollRequestId),this._flingScrollRequestId=null),this._event.destroy();}};var _t=class{id;_container;_chartContainer;_chartBounding=ze();_chartEvent;_chartStore;_drawPanes=[];_candlePane;_xAxisPane;_separatorPanes=new Map;_animations=new Set;_layoutOptions={sort:true,measureHeight:true,measureWidth:true,update:true,buildYAxisTick:false,cacheYAxisWidth:false,forceBuildYAxisTick:false};_layoutPending=false;_layoutRafId=0;_destroyed=false;_cacheYAxisWidth={left:0,right:0};_visible=true;_intersectionObserver=null;_qualityTier="high";_longTaskCount=0;_longTaskWindowStart=0;_perfObserver=null;_resizeTimer=null;_resizeObserver=null;_frameCount=0;_frameTotalMs=0;constructor(e,t){this._initContainer(e),this._chartEvent=new ur(this._chartContainer,this),this._chartStore=new Et(this,t),this._initPanes(t),this._layout(),this._initObservers();}_initObservers(){if(typeof IntersectionObserver<"u"&&(this._intersectionObserver=new IntersectionObserver(([e])=>{this._visible=e.isIntersecting;},{threshold:0}),this._intersectionObserver.observe(this._chartContainer)),typeof PerformanceObserver<"u")try{this._perfObserver=new PerformanceObserver(e=>{let t=performance.now();t-this._longTaskWindowStart>1e3&&(this._longTaskWindowStart=t,this._longTaskCount=0),this._longTaskCount+=e.getEntries().length,this._longTaskCount>=3?this._qualityTier="low":this._qualityTier==="low"&&this._longTaskCount===0&&(this._qualityTier="high");}),this._perfObserver.observe({entryTypes:["longtask"]});}catch{}typeof ResizeObserver<"u"&&(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimer!==null&&clearTimeout(this._resizeTimer),this._resizeTimer=setTimeout(()=>{this._resizeTimer=null,this._applyResize();},150);}),this._resizeObserver.observe(this._chartContainer));}setQualityTier(e){this._qualityTier=e;}getQualityTier(){return this._qualityTier}getPerformanceMetrics(){let e=typeof performance<"u"?[...performance.getEntriesByName("astroneum:frame-start"),...performance.getEntriesByName("astroneum:frame-end")]:[],t=this._frameCount>0?this._frameTotalMs/this._frameCount:0;return {frameCount:this._frameCount,avgFrameMs:t,entries:e}}_initContainer(e){this._container=e,this._chartContainer=oe("div",{position:"relative",width:"100%",height:"100%",outline:"none",borderStyle:"none",cursor:"crosshair",boxSizing:"border-box",userSelect:"none",webkitUserSelect:"none",overflow:"hidden",backgroundColor:"inherit",msUserSelect:"none",MozUserSelect:"none",webkitTapHighlightColor:"transparent"}),this._chartContainer.tabIndex=1,e.appendChild(this._chartContainer),this._cacheChartBounding();}_cacheChartBounding(){this._chartBounding.width=Math.floor(this._chartContainer.clientWidth),this._chartBounding.height=Math.floor(this._chartContainer.clientHeight);}_initPanes(e){let t=e?.layout??[{type:"candle"}],r=o=>{if(!_(this._candlePane)){let a=o.options??{};G(a,{id:B.CANDLE}),this._candlePane=this._createPane(er,B.CANDLE,a),(o.content??[]).forEach(l=>{this.createIndicator(l,true,a);});}},i=o=>{if(!_(this._xAxisPane)){let a=this._createPane(nr,B.X_AXIS,o??{});this._xAxisPane=a;}};t.forEach(o=>{switch(o.type){case "candle":{r(o);break}case "indicator":{let a=o.content??[];if(a.length>0){let s=o.options?.id??null;_(s)&&(s=gt(B.INDICATOR));let l={...o.options,id:s};a.forEach(c=>{this.createIndicator(c,true,l);});}break}case "xAxis":{i(o.options);break}}}),r({}),i({order:Number.MAX_SAFE_INTEGER});}_createPane(e,t,r){let i=new e(this,t,r??{});return this._drawPanes.push(i),i}_recalculatePaneHeight(e,t,r){if(r===0)return false;let i=this._drawPanes.filter(a=>{let s=a.getId();return a.getOptions().state==="normal"&&s!==e.getId()&&s!==B.X_AXIS}),o=i.length;if(o===0)return false;if(e.getId()!==B.CANDLE&&_(this._candlePane)&&this._candlePane.getOptions().state==="normal"){let a=this._candlePane.getBounding().height;if(a>0){let s=this._candlePane.getOptions().minHeight,l=a+r;l<s&&(l=s,t-=a+r-l),this._candlePane.setBounding({height:l});}}else {let a=r,s=Math.floor(r/o);i.forEach((l,c)=>{let u=l.getBounding().height,d=0;c===o-1?d=u+a:d=u+s,d<l.getOptions().minHeight&&(d=l.getOptions().minHeight),l.setBounding({height:d}),a-=d-u;}),Math.abs(a)>0&&(t-=a);}return e.setBounding({height:t}),true}getDrawPaneById(e){return e===B.CANDLE?this._candlePane:e===B.X_AXIS?this._xAxisPane:this._drawPanes.find(r=>r.getId()===e)??null}getContainer(){return this._container}getChartStore(){return this._chartStore}getXAxisPane(){return this._xAxisPane}getDrawPanes(){return this._drawPanes}getSeparatorPanes(){return this._separatorPanes}layout(e){(e.sort??false)&&(this._layoutOptions.sort=e.sort),(e.measureHeight??false)&&(this._layoutOptions.measureHeight=e.measureHeight),(e.measureWidth??false)&&(this._layoutOptions.measureWidth=e.measureWidth),(e.update??false)&&(this._layoutOptions.update=e.update),(e.buildYAxisTick??false)&&(this._layoutOptions.buildYAxisTick=e.buildYAxisTick),(e.cacheYAxisWidth??false)&&(this._layoutOptions.cacheYAxisWidth=e.cacheYAxisWidth),(e.buildYAxisTick??false)&&(this._layoutOptions.forceBuildYAxisTick=e.forceBuildYAxisTick),this._layoutPending||(this._layoutPending=true,this._layoutRafId=requestAnimationFrame(()=>{this._layout(),this._layoutPending=false;}));}_layout(){if(!this._visible)return;let e=typeof performance<"u"?performance.now():0;typeof performance<"u"&&performance.mark("astroneum:frame-start");let{sort:t,measureHeight:r,measureWidth:i,update:o,buildYAxisTick:a,cacheYAxisWidth:s,forceBuildYAxisTick:l}=this._layoutOptions;if(t){for(;_(this._chartContainer.firstChild);)this._chartContainer.removeChild(this._chartContainer.firstChild);this._separatorPanes.clear(),this._drawPanes.sort((d,h)=>d.getOptions().order-h.getOptions().order);let u=null;this._drawPanes.forEach(d=>{if(d.getId()!==B.X_AXIS){if(_(u)){let h=new sr(this,"",u,d);this._chartContainer.appendChild(h.getContainer()),this._separatorPanes.set(d,h);}u=d;}this._chartContainer.appendChild(d.getContainer());});}if(r){let u=this._chartBounding.height,d=this.getStyles().separator.size,h=this._xAxisPane.getAxisComponent().getAutoSize(),m=u-h;m<0&&(m=0),this._drawPanes.forEach(g=>{let f=g.getId();if(_(this._separatorPanes.get(g))&&(m-=d),f!==B.X_AXIS&&f!==B.CANDLE&&g.getVisible()){let y=g.getBounding().height;y>m?(y=m,m=0):m-=y,g.setBounding({height:y});}}),this._candlePane.setBounding({height:Math.max(m,0)}),this._xAxisPane.setBounding({height:h});let p=0;this._drawPanes.forEach(g=>{let f=this._separatorPanes.get(g);_(f)&&(f.setBounding({height:d,top:p}),p+=d),g.setBounding({top:p}),p+=g.getBounding().height;});}let c=i;if((a||l)&&this._drawPanes.forEach(u=>{let d=u.getAxisComponent().buildTicks(l);c||=d;}),c){let u=this._chartBounding.width,d=this.getStyles(),h=0,m=true,p=0,g=true;this._drawPanes.forEach(P=>{if(P.getId()!==B.X_AXIS){let I=P.getAxisComponent(),R=I.inside,D=I.getAutoSize();I.position==="left"?(h=Math.max(h,D),R&&(m=false)):(p=Math.max(p,D),R&&(g=false));}}),s&&(h=Math.max(this._cacheYAxisWidth.left,h),p=Math.max(this._cacheYAxisWidth.right,p)),this._cacheYAxisWidth.left=h,this._cacheYAxisWidth.right=p;let f=u,y=0,v=0;m&&(f-=h,y=h),g&&(f-=p,v=p),this._chartStore.setTotalBarSpace(f);let b={width:u},S={width:f,left:y,right:v},x={width:h},C={width:p},T=d.separator.fill,A={};T?A=b:A=S,this._drawPanes.forEach(P=>{this._separatorPanes.get(P)?.setBounding(A),P.setBounding(b,S,x,C);});}o&&(this._xAxisPane.getAxisComponent().buildTicks(true),this.updatePane(4)),this._layoutOptions={sort:false,measureHeight:false,measureWidth:false,update:false,buildYAxisTick:false,cacheYAxisWidth:false,forceBuildYAxisTick:false},typeof performance<"u"&&(performance.mark("astroneum:frame-end"),this._frameTotalMs+=performance.now()-e,this._frameCount++);}updatePane(e,t){_(t)?this.getDrawPaneById(t)?.update(e):this._drawPanes.forEach(r=>{r.update(e),this._separatorPanes.get(r)?.update(e);});}getDom(e,t){if(_(e)){let r=this.getDrawPaneById(e);if(_(r))switch(t??"root"){case "root":return r.getContainer();case "main":return r.getMainWidget().getContainer();case "yAxis":return r.getYAxisWidget()?.getContainer()??null}}else return this._chartContainer;return null}getSize(e,t){if(_(e)){let r=this.getDrawPaneById(e);if(_(r))switch(t??"root"){case "root":return r.getBounding();case "main":return r.getMainWidget().getBounding();case "yAxis":return r.getYAxisWidget()?.getBounding()??null}}else return this._chartBounding;return null}_resetYAxisAutoCalcTickFlag(){this._drawPanes.forEach(e=>{e.getAxisComponent().setAutoCalcTickFlag(true);});}setSymbol(e){e!==this.getSymbol()&&(this._resetYAxisAutoCalcTickFlag(),this._chartStore.setSymbol(e));}getSymbol(){return this._chartStore.getSymbol()}setPeriod(e){e!==this.getPeriod()&&(this._resetYAxisAutoCalcTickFlag(),this._chartStore.setPeriod(e));}getPeriod(){return this._chartStore.getPeriod()}setStyles(e){this._setOptions(()=>{this._chartStore.setStyles(e);});}getStyles(){return this._chartStore.getStyles()}setFormatter(e){this._setOptions(()=>{this._chartStore.setFormatter(e);});}getFormatter(){return this._chartStore.getFormatter()}setLocale(e){this._setOptions(()=>{this._chartStore.setLocale(e);});}getLocale(){return this._chartStore.getLocale()}setTimezone(e){this._setOptions(()=>{this._chartStore.setTimezone(e);});}getTimezone(){return this._chartStore.getTimezone()}setThousandsSeparator(e){this._setOptions(()=>{this._chartStore.setThousandsSeparator(e);});}getThousandsSeparator(){return this._chartStore.getThousandsSeparator()}setDecimalFold(e){this._setOptions(()=>{this._chartStore.setDecimalFold(e);});}getDecimalFold(){return this._chartStore.getDecimalFold()}_setOptions(e){e(),this.layout({measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});}setOffsetRightDistance(e){this._chartStore.setOffsetRightDistance(e,true);}getOffsetRightDistance(){return this._chartStore.getOffsetRightDistance()}setMaxOffsetLeftDistance(e){if(e<0){me("setMaxOffsetLeftDistance","distance","distance must greater than zero!!!");return}this._chartStore.setMaxOffsetLeftDistance(e);}setMaxOffsetRightDistance(e){if(e<0){me("setMaxOffsetRightDistance","distance","distance must greater than zero!!!");return}this._chartStore.setMaxOffsetRightDistance(e);}setLeftMinVisibleBarCount(e){if(e<0){me("setLeftMinVisibleBarCount","barCount","barCount must greater than zero!!!");return}this._chartStore.setLeftMinVisibleBarCount(Math.ceil(e));}setRightMinVisibleBarCount(e){if(e<0){me("setRightMinVisibleBarCount","barCount","barCount must greater than zero!!!");return}this._chartStore.setRightMinVisibleBarCount(Math.ceil(e));}setBarSpace(e){this._chartStore.setBarSpace(e);}getBarSpace(){return this._chartStore.getBarSpace()}getVisibleRange(){return this._chartStore.getVisibleRange()}getViewportState(){return {version:1,barSpace:this._chartStore.getBarSpace().bar,rightOffsetBarCount:this._chartStore.getLastBarRightSideDiffBarCount()}}setViewportState(e){if(e.version!==1||!Number.isFinite(e.barSpace)||e.barSpace<1||e.barSpace>50||!Number.isFinite(e.rightOffsetBarCount))throw new RangeError("viewport state is invalid");this._chartStore.setViewportState(e.barSpace,e.rightOffsetBarCount);}resetData(){this._chartStore.resetData();}replaceBars(e){this._resetYAxisAutoCalcTickFlag(),this._chartStore.replaceBars(e);}updateBar(e){this._chartStore.updateBar(e);}getBars(){return this._chartStore.getDataList().map(e=>({...e}))}getDataList(){return this._chartStore.getDataList()}setDataLoader(e){this._resetYAxisAutoCalcTickFlag(),this._chartStore.setDataLoader(e);}createIndicator(e,t,r){let i=L(e)?{name:e}:e;if(_r(i.name)===null)return me("createIndicator","value","indicator not supported, you may need to use registerIndicator to add one!!!"),null;let o=r??{};if(L(o.id)||(o.id=gt(B.INDICATOR)),L(i.id)||(i.id=gt(i.name)),this._chartStore.addIndicator(i,o.id,t??false)){let s=false;return _(this.getDrawPaneById(o.id))||(this._createPane(rt,o.id,o),o.height??=100,s=true),this.setPaneOptions(o),this.layout({sort:s,measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true}),i.id}return null}overrideIndicator(e){return this._chartStore.overrideIndicator(e)}getIndicators(e){return this._chartStore.getIndicatorsByFilter(e??{})}removeIndicator(e){let t=this._chartStore.removeIndicator(e??{});if(t){let r=false,i=[];this._drawPanes.forEach(o=>{let a=o.getId();a!==B.CANDLE&&a!==B.X_AXIS&&i.push(a);}),i.forEach(o=>{if(!this._chartStore.hasIndicators(o)){let a=this._drawPanes.findIndex(l=>l.getId()===o),s=this._drawPanes[a];_(s)&&(r=true,this._recalculatePaneHeight(s,0,s.getBounding().height),this._drawPanes.splice(a,1),s.destroy());}}),this._drawPanes.length===2&&(this._candlePane.setVisible(true),this._candlePane.setBounding({height:this._chartBounding.height-this._xAxisPane.getBounding().height})),this.layout({sort:r,measureHeight:r,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});}return t}createOverlay(e){let t=[],r=[],i=a=>{!_(a.paneId)||this.getDrawPaneById(a.paneId)===null?(a.paneId=B.CANDLE,r.push(false)):r.push(true),t.push(a);};L(e)?i({name:e}):ne(e)?e.forEach(a=>{let s=null;L(a)?s={name:a}:s=a,i(s);}):i(e);let o=this._chartStore.addOverlays(t,r);return ne(e)?o:o[0]}getOverlays(e){return this._chartStore.getOverlaysByFilter(e??{})}overrideOverlay(e){return this._chartStore.overrideOverlay(e)}removeOverlay(e){return this._chartStore.removeOverlay(e??{})}setPaneOptions(e){let t=false,r=false,i=_(e.id);for(let o of this._drawPanes){let a=o.getId();if(i&&e.id===a||!i){if(a!==B.X_AXIS){if(w(e.height)&&e.height>0){let l=Math.max(e.minHeight??o.getOptions().minHeight,0),c=Math.max(l,e.height);r=true,t=true,o.setOriginalBounding({height:c}),this._recalculatePaneHeight(o,c,-c);}if(_(e.state)&&o.getOptions().state!==e.state){t=true,r=true;let l=e.state;switch(l){case "maximize":{let c=this._drawPanes.find(u=>{let d=u.getId();return u.getOptions().state==="maximize"&&d!==B.X_AXIS});if(!_(c)){o.getOptions().state==="normal"&&o.setOriginalBounding({height:o.getBounding().height}),o.setOptions({state:l});let u=this._chartBounding.height;o.setBounding({height:u-this._xAxisPane.getBounding().height}),this._drawPanes.forEach(d=>{d.getId()!==B.X_AXIS&&d.getId()!==a&&(d.setBounding({height:d.getOriginalBounding().height}),d.setVisible(false),this._separatorPanes.get(d)?.setVisible(false));});}break}case "minimize":{let c=o.getBounding().height,u=o.getOptions().state,d=c-30;u==="maximize"&&(d=o.getOriginalBounding().height-30),this._recalculatePaneHeight(o,30,d)&&(u==="normal"&&o.setOriginalBounding({height:c}),o.setOptions({state:l})),this._drawPanes.forEach(h=>{h.getId()!==B.X_AXIS&&(h.setVisible(true),this._separatorPanes.get(h)?.setVisible(true));});break}default:{let c=o.getOriginalBounding().height;this._recalculatePaneHeight(o,c,o.getBounding().height-c)&&o.setOptions({state:l}),this._drawPanes.forEach(u=>{u.getId()!==B.X_AXIS&&(u.setVisible(true),this._separatorPanes.get(u)?.setVisible(true));});break}}}}_(e.axis)&&(r=true);let s={...e};if(delete s.state,o.setOptions(s),a===e.id)break}}r&&this.layout({measureHeight:t,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});}getPaneOptions(e){return _(e)?this.getDrawPaneById(e)?.getOptions()??null:this._drawPanes.map(t=>t.getOptions())}setZoomEnabled(e){this._chartStore.setZoomEnabled(e);}isZoomEnabled(){return this._chartStore.isZoomEnabled()}setZoomAnchor(e){this._chartStore.setZoomAnchor(e);}getZoomAnchor(){return this._chartStore.getZoomAnchor()}setScrollEnabled(e){this._chartStore.setScrollEnabled(e);}isScrollEnabled(){return this._chartStore.isScrollEnabled()}scrollByDistance(e,t){let r=w(t)&&t>0?t:0;if(this._chartStore.startScroll(),r>0){let i=new Le({duration:r});i.doFrame(o=>{let a=e*(o/r);this._chartStore.scroll(a);}),this._startAnimation(i);}else this._chartStore.scroll(e);}scrollToRealTime(e){let{bar:t}=this._chartStore.getBarSpace(),i=(this._chartStore.getLastBarRightSideDiffBarCount()-this._chartStore.getInitialOffsetRightDistance()/t)*t;this.scrollByDistance(i,e);}scrollToDataIndex(e,t){let r=(this._chartStore.getLastBarRightSideDiffBarCount()+(this.getDataList().length-1-e))*this._chartStore.getBarSpace().bar;this.scrollByDistance(r,t);}scrollToTimestamp(e,t){let r=xt(this.getDataList(),"timestamp",e);this.scrollToDataIndex(r,t);}zoomAtCoordinate(e,t,r){let i=w(r)&&r>0?r:0,{bar:o}=this._chartStore.getBarSpace(),s=o*e-o;if(i>0){let l=0,c=new Le({duration:i});c.doFrame(u=>{let d=s*(u/i),h=(d-l)/this._chartStore.getBarSpace().bar*Er;this._chartStore.zoom(h,t??null,"main"),l=d;}),this._startAnimation(c);}else this._chartStore.zoom(s/o*Er,t??null,"main");}zoomAtDataIndex(e,t,r){let i=this._chartStore.dataIndexToCoordinate(t);this.zoomAtCoordinate(e,{x:i,y:0},r);}zoomAtTimestamp(e,t,r){let i=xt(this.getDataList(),"timestamp",t);this.zoomAtDataIndex(e,i,r);}convertToPixel(e,t){let{paneId:r=B.CANDLE,absolute:i=false}=t??{},o=[];if(r!==B.X_AXIS){let a=this.getDrawPaneById(r);if(a!==null){let s=a.getBounding(),l=[].concat(e),c=this._xAxisPane.getAxisComponent(),u=a.getAxisComponent();o=l.map(d=>{let h={},m=d.dataIndex;if(w(d.timestamp)&&(m=this._chartStore.timestampToDataIndex(d.timestamp)),w(m)&&(h.x=c.convertToPixel(m)),w(d.value)){let p=u.convertToPixel(d.value);h.y=i?s.top+p:p;}return h});}}return ne(e)?o:o[0]??{}}convertFromPixel(e,t){let{paneId:r=B.CANDLE,absolute:i=false}=t??{},o=[];if(r!==B.X_AXIS){let a=this.getDrawPaneById(r);if(a!==null){let s=a.getBounding(),l=[].concat(e),c=this._xAxisPane.getAxisComponent(),u=a.getAxisComponent();o=l.map(d=>{let h={};if(w(d.x)){let m=c.convertFromPixel(d.x);h.dataIndex=m,h.timestamp=this._chartStore.dataIndexToTimestamp(m)??void 0;}if(w(d.y)){let m=i?d.y-s.top:d.y;h.value=u.convertFromPixel(m);}return h});}}return ne(e)?o:o[0]??{}}executeAction(e,t){if(e==="onCrosshairChange"){let r=null;_(t)&&(r={...t},r.paneId??=B.CANDLE),this._chartStore.setCrosshair(r,{notExecuteAction:true});}}subscribeAction(e,t){this._chartStore.subscribeAction(e,t);}unsubscribeAction(e,t){this._chartStore.unsubscribeAction(e,t);}getConvertPictureUrl(e,t,r){let{width:i,height:o}=this._chartBounding,a=oe("canvas",{width:`${i}px`,height:`${o}px`,boxSizing:"border-box"}),s=a.getContext("2d"),l=X(a);a.width=i*l,a.height=o*l,s.scale(l,l),s.fillStyle=r??"#FFFFFF",s.fillRect(0,0,i,o);let c=e??false;return this._drawPanes.forEach(u=>{let d=this._separatorPanes.get(u);if(_(d)){let m=d.getBounding();s.drawImage(d.getImage(c),m.left,m.top,m.width,m.height);}let h=u.getBounding();s.drawImage(u.getImage(c),0,h.top,i,h.height);}),a.toDataURL(`image/${t??"jpeg"}`)}_applyResize(){this._cacheChartBounding(),this.layout({measureHeight:true,measureWidth:true,update:true,buildYAxisTick:true,forceBuildYAxisTick:true});}resize(){this._applyResize();}_startAnimation(e){this._animations.add(e),e.onFinish(()=>{this._animations.delete(e);}),e.start();}destroy(){this._destroyed||(this._destroyed=true,this._layoutRafId!==0&&(cancelAnimationFrame(this._layoutRafId),this._layoutRafId=0),this._resizeTimer!==null&&(clearTimeout(this._resizeTimer),this._resizeTimer=null),this._intersectionObserver?.disconnect(),this._perfObserver?.disconnect(),this._resizeObserver?.disconnect(),this._animations.forEach(e=>{e.cancel();}),this._animations.clear(),this._chartEvent.destroy(),this._drawPanes.forEach(e=>{e.destroy();}),this._drawPanes=[],this._separatorPanes.clear(),this._chartStore.destroy(),this._container.removeChild(this._chartContainer));}};var ta=false,fi=new At;function L_(){return "__VERSION__"}function B_(n,e){ta||(ta=true,xn());let t=null;if(L(n)?t=typeof document>"u"?null:document.getElementById(n):t=n,t===null)return ei("","","The chart cannot be initialized correctly. Please check the parameters. The chart container cannot be null and child elements need to be added!!!"),null;let r=fi.getOrCreate(t,i=>{let o=new _t(t,e);return o.id=i,o});return r===null?(ei("","","The chart container is already owned by another chart registry."),null):(r.created||me("","","The chart has been initialized on the dom\uFF01\uFF01\uFF01"),r.chart)}function O_(n){if(n instanceof _t)fi.dispose(n);else {let e=null;L(n)?e=typeof document>"u"?null:document.getElementById(n):e=n,e!==null&&fi.dispose(e);}}var V_={clone:Te,merge:G,isString:L,isNumber:w,isValid:_,isObject:ae,isArray:ne,isFunction:q,isBoolean:Se,formatValue:Q,formatPrecision:J,formatBigNumber:pr,formatDate:mr,formatThousands:gr,formatFoldDecimal:fr,calcTextWidth:ie,getLinearSlopeIntercept:dt,getLinearYFromSlopeIntercept:br,getLinearYFromCoordinates:Fe,checkCoordinateOnArc:qr,checkCoordinateOnCircle:Xr,checkCoordinateOnLine:zr,checkCoordinateOnPolygon:Ur,checkCoordinateOnRect:Tt,checkCoordinateOnText:$r};export{as as a,ss as b,ls as c,Es as d,Is as e,Ds as f,ks as g,js as h,Zs as i,_g as j,Bn as k,ll as l,cl as m,ml as n,yl as o,L_ as p,B_ as q,O_ as r,V_ as s};
|