1import{A as Gt}from"./AppLayout.903b227d.js";/* empty css */import{e as L,h as Yt}from"./laravel-vite-plugin_inertia-helpers.9c4f003d.js";import{n as bt}from"./plugin-vue2_normalizer.000ba15c.js";import"./vuex.9a713e87.js";import"./AnimatedParagraph.898882e0.js";import"./featureSlugs.b4bb1dc1.js";import"./Tooltip.37f2b546.js";import"./btc.38c7b727.js";import"./PrimaryButton.4ea37368.js";import"./GhostButton.be455fab.js";import"./Logo.d79c0716.js";import"./mdx.21cb3b8e.js";import"./socketService.5b6e8b75.js";import"./chunk-7TXMVMS6.80c94c5e.js";import"./Modal.55f10e39.js";import"./SignupAndPayModal.865fe969.js";import"./SignupAndPay.846aea00.js";import"./TextInput.accc894b.js";import"./Checkbox.76dac451.js";import"./lodash_flatMap.c1aa4c3b.js";import"./chunk-EQKERSRP.6ba6c6f9.js";import"./2.543b16fc.js";import"./DialogModal.9bec62c6.js";const q=t=>{const e=Zt(t),r={1:"1m",5:"5m",15:"15m",30:"30m",60:"1h",240:"4h",720:"12h",1440:"1d"};if(r[e])return r[e];if(typeof t=="string"){const s=t.toUpperCase();if(s.endsWith("D")||s.endsWith("W")||s.endsWith("M"))return"1d"}return"1h"},Zt=t=>{if(typeof t=="number")return t;if(typeof t=="string"){const e=t.toUpperCase().trim();if(e.endsWith("D"))return 1440*(parseInt(e,10)||1);if(e.endsWith("W"))return 10080*(parseInt(e,10)||1);if(e.endsWith("M"))return 43200*(parseInt(e,10)||1);const r=parseInt(e,10);if(!isNaN(r))return r}return 60},Jt=t=>{var n;const e=String(t||"1h").toLowerCase().trim(),r=e.match(/^(\d+)([mhdw])$/);if(r){const o=parseInt(r[1],10),l=r[2];if(l==="m")return o*60;if(l==="h")return o*3600;if(l==="d")return o*86400;if(l==="w")return o*604800}return(n={m1:60,"1m":60,m5:300,"5m":300,m15:900,"15m":900,m30:1800,"30m":1800,h1:3600,"1h":3600,h4:14400,"4h":14400,h12:43200,"12h":43200,h24:86400,d1:86400,"1d":86400}[e])!=null?n:3600},Xt=(t,e,r)=>{const s=Jt(r);return{from:Math.floor(t/s)*s,to:Math.ceil(e/s)*s}},G=(t,e,r,s,n,o)=>{const{from:l,to:i}=Xt(n,o,s);return`${t}-${e}-${r}-${s}-${l}-${i}`},Bt=L.__esModule?L.default:L,J=new Map,X=new Map,At=async(t,e,r,s,n="Binance")=>{var o,l;try{const i=q(s),c={1:1,5:5,15:15,30:30,60:1,"1D":1,"1W":1,"1M":1};if(r.from<0||r.to<0)return console.error("Invalid timestamps:",{from:r.from,to:r.to}),[];const a=G("price",n,e,i,r.from,r.to);if(J.has(a))return J.get(a);if(X.has(a))return X.get(a);const u={params:{target:i,ticker:e,multiplier:c[s],from:r.from,to:r.to,exchange:n}},d=Bt.get("/api/polygon/aggregates",u).then(h=>{const m=(Array.isArray(h==null?void 0:h.data)?h.data:[]).map(y=>{var b,R;return{...y,volume:(R=(b=y.volume)!=null?b:y.volume_usd)!=null?R:0}});return m.length>0&&(J.set(a,m),setTimeout(()=>{J.delete(a)},5*60*1e3)),m}).finally(()=>{X.delete(a)});return X.set(a,d),d}catch(i){return console.error("Error fetching stock data:",{error:i.message,ticker:e,resolution:s,timeframe:r,status:(o=i.response)==null?void 0:o.status,data:(l=i.response)==null?void 0:l.data}),[]}},Qt="tv_supported_exchange_pairs_v1",te=60*60*1e3,Q=new Map,ee=t=>`${Qt}:${(t||"all").toLowerCase()}`,re=async(t=null)=>{var e,r,s;try{const n=await Bt.get("/api/polygon/supported-exchange-pairs",{params:t?{exchange:t}:void 0}),o=n==null?void 0:n.data;return o&&typeof o=="object"&&!Array.isArray(o)&&"data"in o?(e=o.data)!=null?e:[]:o!=null?o:[]}catch(n){return console.error("Error fetching supported exchange pairs:",{error:n.message,status:(r=n.response)==null?void 0:r.status,data:(s=n.response)==null?void 0:s.data}),[]}},Mt=async(t=null)=>{const e=ee(t);if(typeof sessionStorage<"u")try{const s=sessionStorage.getItem(e);if(s){const{ts:n,data:o}=JSON.parse(s);if(Date.now()-n<te)return o}}catch{}if(Q.has(e))return Q.get(e);const r=re(t).then(s=>{if(typeof sessionStorage<"u")try{sessionStorage.setItem(e,JSON.stringify({ts:Date.now(),data:s}))}catch{}return s}).finally(()=>{Q.delete(e)});return Q.set(e,r),r},Nt=(t=null)=>Mt(t);let ht=null;function _t(){return ht||(ht=Yt(()=>import("./charting_library.esm.379352fe.js"),[])),ht}function se(){return _t().then(t=>t.widget)}const Ut=L.__esModule?L.default:L;let tt=new Map,et=new Map,rt=new Map,st=new Map,V=[],K=[],dt=!1,ft=!1;const Ot=300,ne=async()=>
1{if(!(dt||V.length===0)){for(dt=!0;V.length>0;){const{resolve:t,reject:e,url:r,requestConfig:s}=V.shift();try{const n=await Ut.get(r,s);t(n)}catch(n){e(n)}V.length>0&&await new Promise(n=>setTimeout(n,Ot))}dt=!1}},ae=async()=>{if(!(ft||K.length===0)){for(ft=!0;K.length>0;){const{resolve:t,reject:e,url:r,requestConfig:s}=K.shift();try{const n=await Ut.get(r,s);t(n)}catch(n){e(n)}K.length>0&&await new Promise(n=>setTimeout(n,Ot))}ft=!1}},ie=(t,e={})=>new Promise((r,s)=>{V.push({resolve:r,reject:s,url:t,requestConfig:e}),ne()}),oe=(t,e={})=>new Promise((r,s)=>{K.push({resolve:r,reject:s,url:t,requestConfig:e}),ae()}),$t={1:1,5:5,15:15,30:30,60:1,"1D":1,"1W":1,"1M":1},le=async(t,e,r,s,n="Binance")=>{const o=q(s),l=G("global",n,e,o,r.from,r.to);if(tt.has(l))return tt.get(l);if(rt.has(l))return rt.get(l);const i={params:{target:o,ticker:e,multiplier:$t[s],from:r.from,to:r.to,exchange:n}},c=ie("/api/longshort/global-long-short",i).then(a=>{const d=(Array.isArray(a==null?void 0:a.data)?a.data:[]).map(h=>{var S,m,y,b;return{...h,long:(m=(S=h.long)!=null?S:h.global_account_long_percent)!=null?m:50,short:(b=(y=h.short)!=null?y:h.global_account_short_percent)!=null?b:50}});return d.length>0&&(tt.set(l,d),setTimeout(()=>{tt.delete(l)},5*60*1e3)),d}).finally(()=>{rt.delete(l)});return rt.set(l,c),c},ce=async(t,e,r,s,n="Binance")=>{const o=q(s),l=G("top",n,e,o,r.from,r.to);if(et.has(l))return et.get(l);if(st.has(l))return st.get(l);const i={params:{target:o,ticker:e,multiplier:$t[s],from:r.from,to:r.to,exchange:n}},c=oe("/api/longshort/top-long-short",i).then(a=>{const d=(Array.isArray(a==null?void 0:a.data)?a.data:[]).map(h=>{var S,m,y,b;return{...h,long:(m=(S=h.long)!=null?S:h.top_account_long_percent)!=null?m:50,short:(b=(y=h.short)!=null?y:h.top_account_short_percent)!=null?b:50}});return d.length>0&&(et.set(l,d),setTimeout(()=>{et.delete(l)},5*60*1e3)),d}).finally(()=>{st.delete(l)});return st.set(l,c),c},ue=L.__esModule?L.default:L,nt=new Map,at=new Map,O=(t,e=0)=>{const r=Number(t);return Number.isFinite(r)?r:e},he=async(t,e,r,s="Binance")=>{var n,o;try{const l=q(r);if(e.from<0||e.to<0)return console.error("Invalid funding rate timestamps:",{from:e.from,to:e.to}),[];const i=G("funding-rate",s,t,l,e.from,e.to);if(nt.has(i))return nt.get(i);if(at.has(i))return at.get(i);const c=ue.get("/api/funding-rate/history",{params:{target:l,ticker:t,from:e.from,to:e.to,exchange:s}}).then(a=>{const d=(Array.isArray(a==null?void 0:a.data)?a.data:[]).map(h=>{const S=O(h.close,O(h.funding_rate));return{time:Number(h.time),open:O(h.open,S),high:O(h.high,S),low:O(h.low,S),close:S}}).filter(h=>Number.isFinite(h.time));return d.length>0&&(nt.set(i,d),setTimeout(()=>{nt.delete(i)},5*60*1e3)),d}).finally(()=>{at.delete(i)});return at.set(i,c),c}catch(l){return console.error("Error fetching funding rate data:",{error:l.message,ticker:t,resolution:r,timeframe:e,status:(n=l.response)==null?void 0:n.status,data:(o=l.response)==null?void 0:o.data}),[]}},de=L.__esModule?L.default:L,it=new Map,ot=new Map,gt=(t,e=0)=>{const r=Number(t);return Number.isFinite(r)?r:e},fe=t=>{const e=Number(t);return Number.isFinite(e)?e<1e12?e*1e3:e:null},ge=async(t,e,r,s,n="Binance")=>{var i,c;const l=t==="spot"?"/api/cvd/spot/history":"/api/cvd/futures/history";try{const a=q(s);if(r.from<0||r.to<0)return console.error("Invalid CVD timestamps:",{from:r.from,to:r.to}),[];const u=G(`cvd-${t}`,n,e,a,r.from,r.to);if(it.has(u))return it.get(u);if(ot.has(u))return ot.get(u);const d=de.get(l,{params:{target:a,ticker:e,from:r.from,to:r.to,exchange:n}}).then(h=>{const m=(Array.isArray(h==null?void 0:h.data)?h.data:[]).map(y=>{var x;const b=fe(y.time);if(b===null)return null;const R=gt(y.taker_buy_vol),I=gt(y.taker_sell_vol),B=gt((x=y.close)!=null?x:y.cum_vol_delta,R-I);return{time:b,taker_buy_vol:R,taker_sell_vol:I,close:B}}).filter(Boolean);return m.length>0&&(it.set(u,m),setTimeout(()=>{it.delete(u)},5*60*1e3)),m}).finally(()=>{ot.delete(u)});return ot.set(u,d),d}catch(a){return console.error("Error fetching CVD data:",{error:a.message,marketType:t,ticker:e,resolution:s,timeframe:r,status:(i=a.response)==null?void 0:i.status,data:(c=a.response)==null?void 0:c.data}),[]}}
1,yt={style:1,esdShowDividends:!0,esdShowSplits:!0,esdShowEarnings:!0,esdShowBreaks:!1,esdFlagSize:2,showContinuousContractSwitches:!0,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!0,showLastNews:!0,showCountdown:!1,bidAsk:{visible:!1,lineStyle:1,lineWidth:1,bidLineColor:"#2962FF",askLineColor:"#F7525F"},prePostMarket:{visible:!0,lineStyle:1,lineWidth:1,preMarketColor:"#FB8C00",postMarketColor:"#2962FF"},highLowAvgPrice:{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLineVisible:!1,averageClosePriceLabelVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:1,averagePriceLineColor:"",averagePriceLineWidth:1},showPriceLine:!0,priceLineWidth:1,priceLineColor:"",baseLineColor:"#5d606b",showPrevClosePriceLine:!1,prevClosePriceLineWidth:1,prevClosePriceLineColor:"#555555",minTick:"default",dividendsAdjustment:{},backAdjustment:!1,settlementAsClose:!0,sessionId:"regular",sessVis:!1,useVolumeWeightBars:!1,statusViewStyle:{fontSize:16,showExchange:!0,showInterval:!0,symbolTextSource:"description"},candleStyle:{upColor:"rgba(178, 181, 190, 0.5)",downColor:"rgba(178, 181, 190, 0.5)",drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:"rgba(178, 181, 190, 1)",borderDownColor:"rgba(178, 181, 190, 1)",wickColor:"#B5B5B8",wickUpColor:"rgba(178, 181, 190, 1)",wickDownColor:"rgba(178, 181, 190, 1)",barColorsOnPrevClose:!1,drawBody:!0},hollowCandleStyle:{upColor:"#089981",downColor:"#F23645",drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:"#089981",borderDownColor:"#F23645",wickColor:"#B5B5B8",wickUpColor:"#089981",wickDownColor:"#F23645",drawBody:!0},haStyle:{upColor:"#089981",downColor:"#F23645",drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:"#089981",borderDownColor:"#F23645",wickColor:"#B5B5B8",wickUpColor:"#089981",wickDownColor:"#F23645",showRealLastPrice:!1,barColorsOnPrevClose:!1,inputs:{},inputInfo:{},drawBody:!0},barStyle:{upColor:"#089981",downColor:"#F23645",barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},hiloStyle:{color:"#2962FF",showBorders:!0,borderColor:"#2962FF",showLabels:!0,labelColor:"#2962FF",drawBody:!0},columnStyle:{upColor:"rgba(8, 153, 129, 0.5)",downColor:"rgba(242, 54, 69, 0.5)",barColorsOnPrevClose:!0,priceSource:"close"},lineStyle:{color:"#2962FF",linestyle:0,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{color:"#2962FF",linestyle:0,linewidth:2,priceSource:"close"},steplineStyle:{color:"#2962FF",linestyle:0,linewidth:2,priceSource:"close"},areaStyle:{color1:"rgba(41, 98, 255, 0.28)",color2:"#2962FF",linecolor:"#2962FF",linestyle:0,linewidth:2,priceSource:"close",transparency:100},hlcAreaStyle:{highLineColor:"#089981",highLineStyle:0,highLineWidth:2,lowLineColor:"#F23645",lowLineStyle:0,lowLineWidth:2,closeLineColor:"#868993",closeLineStyle:0,closeLineWidth:2,highCloseFillColor:"rgba(8, 153, 129, 0.2)",closeLowFillColor:"rgba(242, 54, 69, 0.2)"},renkoStyle:{upColor:"#089981",downColor:"#F23645",borderUpColor:"#089981",borderDownColor:"#F23645",upColorProjection:"#336854",downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f",wickUpColor:"#089981",wickDownColor:"#F23645",inputs:{source:"close",sources:"Close",boxSize:3,style:"ATR",atrLength:14,wicks:!0},inputInfo:{source:{name:"Source"},sources:{name:"Source"},boxSize:{name:"Box size"},style:{name:"Style"},atrLength:{name:"ATR length"},wicks:{name:"Wicks"}}},pbStyle:{upColor:"#089981",downColor:"#F23645",borderUpColor:"#089981",borderDownColor:"#F23645",upColorProjection:"#336854",downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f",inputs:{source:"close",lb:3},inputInfo:{source:{name:"Source"},lb:{name:"Number of line"}}},kagiStyle:{upColor:"#089981",downColor:"#F23645",upColorProjection:"#336854",downColorProjection:"#7f323f",inputs:{source:"close",style:"ATR",atrLength:14,reversalAmount:1},inputInfo:{source:{name:"Source"},style:{name:"Style"},atrLength:{name:"ATR length"},reversalAmount:{name:"Reversal amount"}}},pnfStyle:{upColor:"#089981",downColor:"#F23645",upColorProjection:"#336854",downColorProjection:"#7f323f",input
1s:{sources:"Close",reversalAmount:3,boxSize:1,style:"ATR",atrLength:14,oneStepBackBuilding:!1},inputInfo:{sources:{name:"Source"},boxSize:{name:"Box size"},reversalAmount:{name:"Reversal amount"},style:{name:"Style"},atrLength:{name:"ATR length"},oneStepBackBuilding:{name:"One step back building"}}},baselineStyle:{baselineColor:"#758696",topFillColor1:"rgba(8, 153, 129, 0.28)",topFillColor2:"rgba(8, 153, 129, 0.05)",bottomFillColor1:"rgba(242, 54, 69, 0.05)",bottomFillColor2:"rgba(242, 54, 69, 0.28)",topLineColor:"#089981",bottomLineColor:"#F23645",topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},rangeStyle:{barStyle:0,upColor:"#089981",downColor:"#F23645",upColorProjection:"#336854",downColorProjection:"#7f323f",thinBars:!0,candlesUpColor:"#089981",candlesDownColor:"#F23645",candlesBorderUpColor:"#089981",candlesBorderDownColor:"#F23645",candlesWickUpColor:"#089981",candlesWickDownColor:"#F23645",inputs:{range:10,phantomBars:!1},inputInfo:{range:{name:"Range"},phantomBars:{name:"Phantom bars"}}},volFootprintStyle:{upColor:"#089981",downColor:"#F23645",drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:"#089981",borderDownColor:"#F23645",wickColor:"#737375",wickUpColor:"#089981",wickDownColor:"#F23645",barColorsOnPrevClose:!1,drawBody:!0,deltaAdjust:!0,showSummary:!0,type:"Buy and sell",pointOfControl:!0,imbalanceHighlight:{buyColor:"#089981",sellColor:"#F23645",visible:!0},stackedLevels:{visible:!0,count:3},inputs:{rowSize:"Auto",atrLength:14,imbalancePercent:300,ticksPerRow:100,showVA:!0,vaPercent:70},bgColors:{}},symbol:"X:BTCUSD",shortName:"X:BTCUSD",timeframe:"",onWidget:!1,interval:"60",unitId:null,priceAxisProperties:{autoScale:!0,alignLabels:!0}};function pe(){const t=yt.candleStyle;return{"mainSeriesProperties.style":yt.style,"mainSeriesProperties.candleStyle.upColor":t.upColor,"mainSeriesProperties.candleStyle.downColor":t.downColor,"mainSeriesProperties.candleStyle.drawWick":t.drawWick,"mainSeriesProperties.candleStyle.drawBorder":t.drawBorder,"mainSeriesProperties.candleStyle.borderColor":t.borderColor,"mainSeriesProperties.candleStyle.borderUpColor":t.borderUpColor,"mainSeriesProperties.candleStyle.borderDownColor":t.borderDownColor,"mainSeriesProperties.candleStyle.wickColor":t.wickColor,"mainSeriesProperties.candleStyle.wickUpColor":t.wickUpColor,"mainSeriesProperties.candleStyle.wickDownColor":t.wickDownColor,"mainSeriesProperties.candleStyle.barColorsOnPrevClose":t.barColorsOnPrevClose,"mainSeriesProperties.candleStyle.drawBody":t.drawBody}}const A={clientId:"tradingview.com",user_id:"public_user_id",library_path:"/charting_library/",interval:"60",charts_storage_url:"https://saveload.tradingview.com",charts_storage_api_version:"1.1",enabled_features:[],disabled_features:["create_volume_indicator_by_default","create_volume_indicator_by_default_once","display_market_status","popup_hints","symbol_info","header_compare","compare_symbol","timezone_menu","scales_context_menu"],supported_resolutions:["60","1D","1W"],chartPane:{gradientStart:"#181716",gradientEnd:"#000000",loadingSpinner:"#868993"},getChartLegendPropertiesState(){return{showStudyArguments:!1,showSeriesOHLC:!1}},getChartThemeOverrides(){return{"paneProperties.background":this.chartPane.gradientStart,"paneProperties.backgroundGradientStartColor":this.chartPane.gradientStart,"paneProperties.backgroundGradientEndColor":this.chartPane.gradientEnd,"paneProperties.backgroundType":"gradient"}},getChartPaneOverrides(){const t=this.getChartLegendPropertiesState();return{...this.getChartThemeOverrides(),"paneProperties.legendProperties.showStudyArguments":t.showStudyArguments,"paneProperties.legendProperties.showSeriesOHLC":t.showSeriesOHLC,"scalesProperties.showStudyLastValue":!0,"scalesProperties.showStudyPlotLabels":!0}},getChartOverrides(){return{...this.getChartPaneOverrides(),...pe()}},getChartPanePropertiesState(){return{background:this.chartPane.gradientStart,backgroundType:"gradient",backgroundGradientStartColor:this.chartPane.gradientStart,backgroundGradientEndColor:this.chartPane.gradientEnd,legendProperties:this.getChartLegendPropertiesState()}},getChartLoadingScreen(){return{backgroundColor:this.chartPane.gradientStart,foregroundColor:this.chartPane.loadingSpinner}},getChartSettingsAdapter(){const t="chartproperties.paneProperties.",e=this.getChartPanePropertiesState(),r={};for(const[s,n]of Object.entries(e)){if(s==="legendProperties"&&n&&typeof n=="object"){for(const[o,l]of Object.entries(n))r[`${t}legendProperties.${o}`]=String(l);continue}r[`${t}${s}`]=String(n)}return{initialSettings:r,setValue(s,n){try{localStorage.setItem(`tradingview.${s}`,n)}catch{}},removeValue(s){try{localStorage.removeItem(`tradingview.${s}`)}catch{}}}}
1,getChartPaneBackgroundStyle(){return{background:`linear-gradient(180deg, ${this.chartPane.gradientStart} 0%, ${this.chartPane.gradientEnd} 100%)`}}},ct="Long/Short Ratio",ye="Funding Rates",Wt="Funding Rate (Hyperliquid)",Se=[Wt,ye],Vt="mdx_chart_funding_rates",Kt="mdx_chart_cvd_perps",zt="mdx_chart_cvd_spot",z="CVD Perps",H="CVD Spot",me=[z],Ce=[H],j=3,Tt=[{id:"mdx_chart_btc",name:"BTC",symbol:"Binance:BTCUSDT",fixed:!0,defaultStudies:[ct]},{id:"mdx_chart_eth",name:"ETH",symbol:"Binance:ETHUSDT",fixed:!0,defaultStudies:[ct]},{id:"mdx_chart_sol",name:"SOL",symbol:"Binance:SOLUSDT",fixed:!0,defaultStudies:[ct]}],St=[{id:Vt,name:"Funding Rates",symbol:"Binance:BTCUSDT",fixed:!1,defaultStudies:[...Se]},{id:Kt,name:"CVD (Perps)",symbol:"Binance:BTCUSDT",fixed:!1,defaultStudies:[...me]},{id:zt,name:"CVD (Spot)",symbol:"Binance:BTCUSDT",fixed:!1,defaultStudies:[...Ce]}],Ht=[...Tt,...St],jt=new Set(Tt.map(t=>t.id)),mt=20;function ve(t){return`tv_chart_state_${t}`}function be(t){const e="tv_chart_state_";return typeof t!="string"||!t.startsWith(e)?null:t.slice(e.length)}function _e(t){return!t||typeof t!="object"||!Array.isArray(t.charts)||t.charts.length===0?!1:t.charts.some(e=>Array.isArray(e.panes)&&e.panes.some(r=>Array.isArray(r.sources)&&r.sources.length>0))}function Te(t){return(t==null?void 0:t.type)==="MainSeries"||(t==null?void 0:t.type)==="series"}function we(t){var r;if(!t||Te(t))return null;const e=t.metaInfo||t.metainfo||{};
1return e.name||e.description||e.shortDescription||((r=t.state)==null?void 0:r.description)||t.shortName||t.name||null}function Ae(t){if(!_e(t))return!1;for(const e of t.charts)if(!!Array.isArray(e.panes)){for(const r of e.panes)if(!!Array.isArray(r.sources))for(const s of r.sources){const n=we(s);if(n&&n!==ct)return!0}}return!1}function Ft(t,e){if(!Ae(t))return t;const r=(t==null?void 0:t._mdxSymbol)&&String(t._mdxSymbol)||e;return r?{_mdxSymbol:r}:{}}const Fe="Binance:BTCUSDT";function Ct(t,e=null){return{...t,name:(e==null?void 0:e.name)&&String(e.name).trim()||t.name,locked:qt(e),defaultStudies:Array.isArray(t.defaultStudies)?[...t.defaultStudies]:[]}}function De(t){const e=Number.parseInt(t,10);return Number.isFinite(e)&&e>0?e:0}function Pe(){return`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,9)}`}function qt(t){return Boolean(t==null?void 0:t.locked)}function Dt(t){return Boolean(t&&!t.fixed&&!t.locked)}function Pt(){const t=Ht.map(e=>Ct(e));return{version:j,tabs:t,activeTabId:t[0].id}}function Rt(t,e,r){const s=Array.isArray(t)?t:[],n=De(r),o=Tt.map(i=>Ct(i,s.find(c=>c.id===i.id)));for(const i of St){const c=s.find(a=>a.id===i.id);!c&&n>=j||o.push(Ct(i,c))}if(s.length>0)for(const i of s)!(i!=null&&i.id)||jt.has(i.id)||St.some(c=>c.id===i.id)||o.push({id:i.id,name:i.name&&String(i.name).trim()||"Chart",symbol:i.symbol||Fe,fixed:!1,locked:qt(i),defaultStudies:[]});const l=o.some(i=>i.id===e);return{version:j,tabs:o.slice(0,mt),activeTabId:l?e:o[0].id}}const Re="tv_chart_state",pt=new Set(["apex omni","aster","binance","bitmex","bybit","bitunix","hyperliquid","lbank"]),kt="All Exchanges",ke="Funding Rates",xt="hyperliquid",xe="Funding Rate(All Exchanges)",lt=7,$="zero_line",Lt=1,E="__cumulative__",F="futures",P="spot",It={[F]:["Binance","Bybit","Bitunix"],[P]:["Binance","Bybit","Bitget"]},W="zero_line";function Le(){const e=/[?&]lang=([^&#]*)/.exec(window.location.search);return e===null?null:decodeURIComponent(e[1].replace(/\+/g," "))}const Ie={name:"TVChartContainer",props:{chartStateKey:{type:String,default:Re},fillContainer:{type:Boolean,default:!1},initialSymbol:{type:String,default:null},defaultStudies:{type:Array,default:()=>[]},isActive:{type:Boolean,default:!0}},data(){return{widget:null,selectedTarget:"crypto",selectedTicker:"Binance:BTCUSDT",supportedSymbols:[],allSupportedSymbols:[],longShortData:[],longShortDataMap:new Map,longShortSubscription:null,topTradersData:[],topTradersDataMap:new Map,fundingRateDataMap:new Map,cvdDataMap:new Map,subscriptions:new Map,lastBarBySymbol:new Map,lastLongShortPollByKey:new Map,pendingLongShortFetchByKey:new Set,lastFundingRatePollByKey:new Map,pendingFundingRateFetchByKey:new Set,lastFundingRateStudySyncSignature:null,lastCvdPollByKey:new Map,pendingCvdFetchByKey:new Set,lastCvdStudySyncSignature:null,chartStateRestoring:!1,chartReady:!1,initialSavedData:null,defaultStudiesPending:!1,defaultStudiesCreated:!1,onAutoSaveNeededHandler:null,onDrawingEventHandler:null,symbolChangedSubscription:null,beforeUnloadHandler:null,saveChartStateTimer:null,chartInitPending:!1,chartReadyListenerAttached:!1,initRetryTimer:null,ensureDefaultStudiesTimer:null,destroyed:!1,pendingSavedData:null,bootstrapGeneration:0,skipDestroySave:!1}},methods:{clearChartTimers(){clearTimeout(this.saveChartStateTimer),clearTimeout(this.initRetryTimer),clearTimeout(this.ensureDefaultStudiesTimer),this.saveChartStateTimer=null,this.initRetryTimer=null,this.ensureDefaultStudiesTimer=null},runWhenChartUsable(t){if(!(this.destroyed||!this.widget||!this.chartReady))try{const e=this.widget.activeChart();if(!e||typeof e.dataReady!="function")return;e.dataReady(()=>{this.destroyed||!this.widget||!this.chartReady||t(e)})}catch(e){console.warn("Chart not ready for operation:",e)}},normalizeChartTicker(t){const e=(t||"").trim();if(!e)return null;if(!e.includes(":"))return`Binance:${e.toUpperCase()}`;const[r,s]=e.split(":");return`${r||"Binance"}:${(s||"BTCUSDT").toUpperCase()}`},getActiveChartTicker(){var t,e;try{const r=(e=(t=this.widget)==null?void 0:t.activeChart)==null?void 0:e.call(t);if(!r)return null;if(typeof r.symbol=="function")return r.symbol();if(typeof r.symbolExt=="function"){const s=r.symbolExt();return(s==null?void 0:s.ticker)||(s==null?void 0:s.name)||(s==null?void 0:s.symbol)||null}}catch{}return null},resolveSavedSymbol(t){var r,s,n;if(!t||typeof t!="object")return null;if(t._mdxSymbol)return this.normalizeChartTicker(t._mdxSymbol);const e=t.charts;if(!Array.isArray(e))return null;for(const o of e){const l=o.panes;if(!!Array.isArray(l))for(const i of l){const c=i.sources;if(!!Array.isArray(c))for(const a of c){if(a.type!=="MainSeries"&&a.type!=="series")continue;const u=((r=a.state)==null?void 0:r.symbol)||((s=a.state)==null?void 0:s.shortName)||((n=a.state)==null?void 0:n.ticker),d=this.normalizeChartTicker(u);if(d)return d}}}return null},attachSymbolToSavedState(t){const e=this.normalizeChartTicker(this.getActiveChartTicker());return e&&(t._mdxSymbol=e,this.selectedTicker=e),t},hasPersistedChartLayout(t){return!t||typeof t!="object"||!Array.isArray(t.charts)||t.charts.length===0?!1:t.charts.some(e=>Array.isArray(e.panes)&&e.panes.some(r=>Array.isArray(r.sources)&&r.sources.length>0))},sanitizeChartSavedState(t){var e;if(!t||typeof t!="object")return null;try{const r=JSON.parse(JSON.stringify(t));if(r.charts!=null&&!Array.isArray(r.charts)&&delete r.charts,Array.isArray(r.charts)){for(const l of r.charts)if(l.panes!=null&&!Array.isArray(l.panes)&&(l.panes=[]),!!Array.isArray(l.panes))for(const i of l.panes)i.sources!=null&&!Array.isArray(i.sources)&&(i.sources=[]),Array.isArray(i.sources)&&(i.sources=i.sources.filter(c=>c&&typeof c=="object"))}r.chartProperties||(r.chartProperties={});const s=A.getChartPanePropertiesState(),{legendProperties:n,...o}=s;return r.chartProperties.paneProperties={...r.chartProperties.paneProperties||{},...o,legendProperties:{...((e=r.chartProperties.paneProperties)==null?void 0:e.legendProperties)||{},...n}},r}catch(r){return console.warn("Could not sanitize chart state:",r),null}},readSavedChartState(){try{const t=localStorage.getItem(this.chartStateKey);return t?this.sanitizeChartSavedState(JSON.parse(t)):null}catch(t){return console.warn("Could not parse chart state:",t),localStorage.removeItem(this.chartStateKey),null}},writeSavedChartState(t){localStorage.setItem(this.chartStateKey,JSON.stringify(t))},saveChartState(){this.saveChartStateAsync().catch(t=>{console.warn("Could not save chart state:",t)})},skipNextDestroySave(){this.skipDestroySave=!0},saveChartStateAsync({emitEvent:t=!0}={}){return clearTimeout(this.saveChartStateTimer),this.saveChartStateTimer=null,this.skipDestroySave=!1,new Promise(e=>{if(!this.widget||this.chartStateRestoring||!this.chartReady){e();return}try{this.widget.save(r=>{try{const s=this.attachSymbolToSavedState(r);this.writeSavedChartState(s),t&&this.$emit("chart-state-saved",{chartStateKey:this.chartStateKey,state:s})}catch(s){console.warn("Could not save chart state:",s)}e()},{includeDrawings:!0})}catch(r){console.warn("Could not save chart state:",r),e()}})},scheduleSaveChartState(){clearTimeout(this.saveChartStateTimer),this.saveChartStateTimer=setTimeout(()=>{this.saveChartState()},400)},async waitForVisibleContainer(){const t=this.$refs.chartContainer;for(let e=0;e<30;e++){if(this.destroyed)return!1;if(t&&t.offsetWidth>0&&t.offsetHeight>0)return!0;await new Promise(r=>requestAnimationFrame(r))}return!1},refreshChartLayout(){},setupChartPersistence(t){var e;this.onAutoSaveNeededHandler=()=>{this.scheduleSaveChartState(),this.syncFundingRateDataForActiveStudies().catch(r=>{console.warn("Could not sync funding-rate studies after autosave:",r)}),this.syncCvdDataForActiveStudies().catch(r=>{console.warn("Could not sync CVD studies after autosave:",r)})},t.subscribe("onAutoSaveNeeded",this.onAutoSaveNeededHandler),this.onDrawingEventHandler=()=>this.scheduleSaveChartState(),t.subscribe("drawing_event",this.onDrawingEventHandler);try{const r=(e=t.activeChart)==null?void 0:e.call(t);r!=null&&r.onSymbolChanged&&(this.symbolChangedSubscription=r.onSymbolChanged().subscribe(null,()=>{const s=this.normalizeChartTicker(this.getActiveChartTicker());s&&(this.selectedTicker=s),this.lastFundingRateStudySyncSignature=null,this.lastCvdStudySyncSignature=null,this.scheduleSaveChartState()}))}catch(r){console.warn("Could not subscribe to symbol changes:",r)}this.beforeUnloadHandler=()=>{if(clearTimeout(this.saveChartStateTimer),!(!this.widget||!this.chartReady||this.chartStateRestoring))try{this.widget.save(r=>{try{this.writeSavedChartState(this.attachSymbolToSavedState(r))}catch(s){console.warn("Could not save chart state:",s)}},{includeDrawings:!0})}catch(r){console.warn("Could not save chart state:",r)}},window.addEventListener("beforeunload",this.beforeUnloadHandler)},teardownChartPersistence(){if(clearTimeout(this.saveChartStateTimer),this.saveChartStateTimer=null,this.symbolChangedSubscription){try{this.symbolChangedSubscription.unsubscribe()}catch{}this.symbolChangedSubscription=null}this.widget&&this.onAutoSaveNeededHandler&&this.widget.unsubscribe("onAutoSaveNeeded",this.onAutoSaveNeededHandler),this.widget&&this.onDrawingEventHandler&&this.widget.unsubscribe("drawing_event",this.onDrawingEventHandler),this.beforeUnloadHandler&&window.removeEventListener("beforeunload",this.beforeUnloadHandler),this.onAutoSaveNeededHandler=null,this.onDrawingEventHandler=null,this.beforeUnloadHandler=null},applyChartOverrides(t){t.applyOverrides(A.getChartPaneOverrides())},getChartStudies(t=null){var r,s;const e=t||((s=(r=this.widget)==null?void 0:r.activeChart)==null?void 0:s.call(r));if(!e||typeof e.getAllStudies!="function")return[];try{const n=e.getAllStudies();return Array.isArray(n)?n:[]}catch{return[]}},getActiveFundingRateStudyExchanges(t=null){const e=this.getChartStudies(t).flatMap(r=>{var l;const s=String((r==null?void 0:r.name)||"").trim();if(this.isAllFundingRateStudyName(s))return this.getAllFundingRateExchanges();const n=s.match(/^Funding Rate\s*\((.+)\)$/),o=((l=n==null?void 0:n[1])==null?void 0:l.trim())||null;return!o||o===kt?[]:[o]}
1).filter(Boolean);return[...new Set(e)]},hasActiveFundingRateStudy(t=null){return this.getActiveFundingRateStudyExchanges(t).length>0},getActiveChartResolution(t=null){var r,s;const e=t||((s=(r=this.widget)==null?void 0:r.activeChart)==null?void 0:s.call(r));if(!e||typeof e.resolution!="function")return A.interval;try{return e.resolution()||A.interval}catch{return A.interval}},buildFundingRatePeriodParams(t,e=null){var c,a;const r=e||((a=(c=this.widget)==null?void 0:c.activeChart)==null?void 0:a.call(c)),s=this.keyFor({ticker:this.getActiveChartTicker()||this.selectedTicker},t),o=this.resolutionToMinutes(t)*60,l=Math.floor(Date.now()/1e3);try{if(r&&typeof r.getVisibleRange=="function"){const u=r.getVisibleRange();if(u&&Number.isFinite(u.from)&&Number.isFinite(u.to)&&u.from>0&&u.to>0&&u.to>=u.from){const d=h=>h>1e12?Math.floor(h/1e3):Math.floor(h);return{from:d(u.from),to:d(u.to),firstDataRequest:!1}}}}catch{}const i=this.lastBarBySymbol.get(s);if(i!=null&&i.time){const u=Math.floor(i.time/1e3);return{from:u-o*300,to:Math.max(u,l),firstDataRequest:!1}}return{from:l-o*300,to:l,firstDataRequest:!1}},refreshChartDataForStudies(t=null){var r,s;const e=t||((s=(r=this.widget)==null?void 0:r.activeChart)==null?void 0:s.call(r));if(!(!e||typeof e.resetData!="function"))try{e.resetData()}catch(n){console.warn("Could not refresh chart data for studies:",n)}},async syncFundingRateDataForActiveStudies({chart:t=null,force:e=!1}={}){var a,u;const r=t||((u=(a=this.widget)==null?void 0:a.activeChart)==null?void 0:u.call(a));if(!r)return;const s=this.getActiveFundingRateStudyExchanges(r);if(s.length===0){this.lastFundingRateStudySyncSignature=null;return}const n=this.getActiveChartTicker()||this.selectedTicker,{symbol:o}=this.parseTicker(n),l=this.getActiveChartResolution(r),i=`${o}|${l}|${[...s].sort().join(",")}`;if(!e&&i===this.lastFundingRateStudySyncSignature)return;const c=await this.fetchFundingRateData(o,this.buildFundingRatePeriodParams(l,r),l,null,s);((c==null?void 0:c.successCount)||0)>0?(this.lastFundingRateStudySyncSignature=i,this.refreshChartDataForStudies(r)):this.lastFundingRateStudySyncSignature=null},getDefaultStudyNames(){return Array.isArray(this.defaultStudies)?[...new Set(this.defaultStudies.map(t=>String(t||"").trim()).filter(Boolean))]:[]},createDefaultStudies(t){const e=this.getDefaultStudyNames();if(e.length===0)return;const r=new Set;try{if(typeof t.getAllStudies=="function"){const s=t.getAllStudies();Array.isArray(s)&&s.map(n=>String((n==null?void 0:n.name)||"").trim()).filter(Boolean).forEach(n=>r.add(n))}}catch{}for(const s of e)if(!r.has(s))try{t.createStudy(s,!1,!1,{},this.getStudyCreationOverrides(s),{}),r.add(s)}catch(n){console.warn(`Could not add study "${s}":`,n)}},scheduleDefaultStudies(){this.defaultStudiesCreated||!this.defaultStudiesPending||!this.widget||this.runWhenChartUsable(t=>{if(!this.defaultStudiesCreated)try{this.createDefaultStudies(t),this.defaultStudiesCreated=!0,this.defaultStudiesPending=!1,this.saveChartState()}catch(e){console.warn("Could not create default studies:",e)}})},ensureDefaultStudies({attempt:t=0}={}){if(this.getDefaultStudyNames().length!==0&&!this.destroyed){if(!this.widget||!this.chartReady){if(t>=30)return;clearTimeout(this.ensureDefaultStudiesTimer),this.ensureDefaultStudiesTimer=setTimeout(()=>this.ensureDefaultStudies({attempt:t+1}),100);return}clearTimeout(this.ensureDefaultStudiesTimer),this.ensureDefaultStudiesTimer=null,this.runWhenChartUsable(e=>{try{const r=this.getDefaultStudyNames();this.createDefaultStudies(e),r.some(s=>this.isFundingRateStudyName(s))&&this.syncFundingRateDataForActiveStudies({chart:e,force:!0}).catch(s=>{console.warn("Could not sync funding-rate studies:",s)}),r.some(s=>this.isCvdStudyName(s))&&this.syncCvdDataForActiveStudies({chart:e,force:!0}).catch(s=>{console.warn("Could not sync CVD studies:",s)}),this.saveChartState()}catch(r){console.warn("Could not ensure default studies:",r)}})}},resolutionToMinutes(t){if(typeof t=="number")return t;if(typeof t=="string"){const e=t.toUpperCase().trim();if(e.endsWith("S")){const s=parseInt(e,10);if(!isNaN(s))return Math.max(1,Math.round(s/60))}if(e.endsWith("D"))return 1440*(parseInt(e,10)||1);if(e.endsWith("W"))return 10080*(parseInt(e,10)||1);if(e.endsWith("M"))return 43200*(parseInt(e,10)||1);const r=parseInt(e,10);if(!isNaN(r))return r}return 60},minutesToMs(t){return t*60*1e3},keyFor(t,e){return`${t.ticker}|${e}`},parseTicker(t){const e=(t||"").trim();
1if(!e.includes(":"))return{exchange:"Binance",symbol:e||"BTCUSDT"};const[r,s]=e.split(":");return{exchange:r||"Binance",symbol:s||"BTCUSDT"}},normalizeSupportedSymbols(t){if(!t)return[];const e=(s,n)=>({symbol:`${s}:${n}`,full_name:`${s}:${n}`,description:"",exchange:s,ticker:`${s}:${n}`,type:"crypto"}),r=s=>typeof s=="string"?s:s&&typeof s=="object"&&(s.symbol||s.ticker||s.pair||s.instrument||s.instrument_id||s.instrumentId)||null;return!Array.isArray(t)&&typeof t=="object"?Object.entries(t).flatMap(([n,o])=>{const l=Array.isArray(o)?o:(o==null?void 0:o.pairs)||(o==null?void 0:o.symbols)||(o==null?void 0:o.data);return Array.isArray(l)?l.map(r).filter(i=>typeof i=="string"&&i).map(i=>e(n,i)):[]}):Array.isArray(t)?t.flatMap(s=>{if(!s||typeof s!="object")return[];const n=typeof s.exchange=="string"&&s.exchange?s.exchange:"Binance",o=Array.isArray(s.pairs)?s.pairs:Array.isArray(s.symbols)?s.symbols:Array.isArray(s.data)?s.data:null;if(Array.isArray(o))return o.map(r).filter(i=>typeof i=="string"&&i).map(i=>e(n,i));const l=r(s);return typeof l=="string"&&l?[e(n,l)]:[]}):[]},getFallbackSymbols(){return[{symbol:"Binance:BTCUSDT",full_name:"Binance:BTCUSDT",description:"BTCUSDT on Binance",exchange:"Binance",ticker:"Binance:BTCUSDT",type:"crypto"},{symbol:"Binance:ETHUSDT",full_name:"Binance:ETHUSDT",description:"ETHUSDT on Binance",exchange:"Binance",ticker:"Binance:ETHUSDT",type:"crypto"}]},getFundingRateSymbolUniverse(){return this.allSupportedSymbols.length>0?this.allSupportedSymbols:this.supportedSymbols.length>0?this.supportedSymbols:this.getFallbackSymbols()},getAllFundingRateExchanges(){const t=this.getFundingRateSymbolUniverse().map(e=>typeof(e==null?void 0:e.exchange)=="string"?e.exchange.trim():"").filter(e=>e&&pt.has(e.toLowerCase()));return[...new Set(t)]},getIndividualFundingRateIndicatorExchanges(){return this.getAllFundingRateExchanges().filter(t=>t.toLowerCase()===xt)},getFundingRateExchangesForSymbol(t){const e=String(t||"").trim().toUpperCase(),r=this.getFundingRateSymbolUniverse().filter(n=>this.parseTicker((n==null?void 0:n.ticker)||(n==null?void 0:n.symbol)).symbol.toUpperCase()===e).map(n=>typeof(n==null?void 0:n.exchange)=="string"?n.exchange.trim():"").filter(n=>n&&pt.has(n.toLowerCase()));if(r.length>0)return[...new Set(r)];const s=this.parseTicker(this.selectedTicker).exchange;return s&&pt.has(s.toLowerCase())?[s]:["Binance"]},fundingRateSeriesKey(t,e){return`${String(e||"Binance").trim()}|${String(t||"BTCUSDT").trim().toUpperCase()}`},getFundingRateSeriesMap(t,e,r=!1){const s=this.fundingRateSeriesKey(t,e);if(!this.fundingRateDataMap.has(s)){if(!r)return null;this.fundingRateDataMap.set(s,new Map)}return this.fundingRateDataMap.get(s)},getFundingRateStudyName(t){return String(t||"").trim().toLowerCase()===xt?Wt:`Funding Rate (${t})`},getAllFundingRateStudyName(){return ke},getLegacyAllFundingRateStudyName(){return xe},isAllFundingRateStudyName(t){return t===this.getAllFundingRateStudyName()||t===this.getLegacyAllFundingRateStudyName()},isFundingRateStudyName(t){const e=String(t||"").trim();return this.isAllFundingRateStudyName(e)||/^Funding Rate\s*\(.+\)$/.test(e)},getStudyCreationOverrides(t){return!this.isFundingRateStudyName(t)&&!this.isCvdStudyName(t)?{}:{showLabelsOnPriceScale:!0,showLegendValues:!1}},getFundingRateStudyId(t){return`FundingRate${String(t||"Exchange").replace(/[^a-z0-9]+/gi,"").trim()||"Exchange"}@tv-basicstudies-1`},getFundingRatePlotId(t){return`funding_rate_${String(t||"exchange").replace(/[^a-z0-9]+/gi,"_").replace(/^_+|_+$/g,"").toLowerCase()||"exchange"}`},getFundingRateZeroLinePlot(){return{id:$,type:"line"}},getFundingRateZeroLineStyleDefaults(){return{color:"#FFFFFF",linestyle:1,linewidth:1,plottype:0,trackPrice:!1,display:Lt}},getFundingRateZeroLineStyleMeta(){return{title:"",histogramBase:0}},getDatafeedConfig(){const t=[...new Set(this.supportedSymbols.map(e=>e.exchange))].map(e=>({value:e,name:e,desc:e}));return{supported_resolutions:A.supported_resolutions,supports_search:!0,supports_group_request:!1,supports_marks:!1,supports_timescale_marks:!1,supports_time:!0,exchanges:t,symbols_types:[{name:"Crypto",value:"crypto"}]}},applySupportedSymbols(t){const e=this.normalizeSupportedSymbols(t),r=this.getFallbackSymbols(),s=e.length>0?e:r;this.allSupportedSymbols=s;const n=s.filter(i=>{var c;return((c=i.exchange)==null?void 0:c.toLowerCase())==="binance"}),o=n.length>0?n:s;if(this.supportedSymbols=o,!this.supportedSymbols.length)return;this.supportedSymbols.some(i=>i.ticker===this.selectedTicker)||(this.selectedTicker=this.supportedSymbols[0].ticker)},refreshSupportedSymbols(){return Mt().then(t=>{this.applySupportedSymbols(t)}
1).catch(()=>{})},mergeLongShortData(t=[],e=[]){if(Array.isArray(t))for(const r of t){const s=Math.floor(r.time/1e3);this.longShortDataMap.set(s,r)}if(Array.isArray(e))for(const r of e){const s=Math.floor(r.time/1e3);this.topTradersDataMap.set(s,r)}},mergeFundingRateData(t,e,r=[]){if(!Array.isArray(r))return;const s=this.getFundingRateSeriesMap(t,e,!0);for(const n of r){const o=Math.floor(n.time/1e3);s.set(o,n)}},async fetchLongShortData(t,e,r,s,n=null){n&&this.pendingLongShortFetchByKey.add(n);try{const[o,l]=await Promise.all([le(this.selectedTarget,t,e,r,s),ce(this.selectedTarget,t,e,r,s)]);return this.mergeLongShortData(o,l),n&&this.lastLongShortPollByKey.set(n,Date.now()),{globalLSData:o,topLSData:l}}finally{n&&this.pendingLongShortFetchByKey.delete(n)}},async fetchFundingRateData(t,e,r,s=null,n=null){s&&this.pendingFundingRateFetchByKey.add(s);try{const o=Array.isArray(n)&&n.length>0?n:this.getFundingRateExchangesForSymbol(t),l=await Promise.allSettled(o.map(async a=>{const u=await he(t,e,r,a);return this.mergeFundingRateData(t,a,u),a})),i=l.map((a,u)=>a.status==="rejected"?o[u]:null).filter(Boolean),c=l.filter(a=>a.status==="fulfilled").length;return i.length>0&&console.warn("Funding rate exchange fetch failed:",{symbol:t,resolution:r,failedExchanges:i}),s&&c>0&&this.lastFundingRatePollByKey.set(s,Date.now()),{successCount:c,failedExchanges:i,requestedExchanges:o}}finally{s&&this.pendingFundingRateFetchByKey.delete(s)}},getCvdTopExchanges(t=F){return[...It[t]||It[F]]},getCvdMarketTypeFromStudyName(t){const e=String(t||"").trim();return e===z||/^CVD Perps\s*\(.+\)$/.test(e)?F:e===H||/^CVD Spot\s*\(.+\)$/.test(e)?P:null},isAllCvdStudyName(t){const e=String(t||"").trim();return e===z||e===H},isCvdStudyName(t){return this.getCvdMarketTypeFromStudyName(t)!==null},getCvdStudyName(t,e){const r=t===P?"Spot":"Perps";return e===E?`CVD ${r} (Cumulative)`:`CVD ${r} (${e})`},getAllCvdStudyName(t){return t===P?H:z},getCvdStudyId(t,e){const r=String(t||"futures").replace(/[^a-z]/gi,""),s=String(e||"Exchange").replace(/[^a-z0-9]/gi,"");return`CVD${r}${s}@tv-basicstudies-1`},getCvdPlotId(t){return t===E?"cvd_cumulative":`cvd_${String(t||"exchange").toLowerCase().replace(/[^a-z0-9]/g,"")}`},getCvdZeroLinePlot(){return{id:W,type:"line"}},getCvdZeroLineStyleDefaults(){return{color:"#787B86",display:Lt,linewidth:1,plottype:0,trackPrice:!1}},getCvdZeroLineStyleMeta(){return{title:"Zero",histogramBase:0}},cvdSeriesKey(t,e,r){return`${String(e||F).trim()}|${String(r||"Binance").trim()}|${String(t||"BTCUSDT").trim()}`},getCvdSeriesMap(t,e,r,s=!1){const n=this.cvdSeriesKey(t,e,r);if(!this.cvdDataMap.has(n)){if(!s)return null;this.cvdDataMap.set(n,new Map)}return this.cvdDataMap.get(n)},mergeCvdData(t,e,r,s=[]){if(!Array.isArray(s))return;const n=this.getCvdSeriesMap(t,e,r,!0);for(const o of s){const l=Math.floor(o.time/1e3);n.set(l,o)}},rebuildCvdCumulativeSeries(t,e){const r=this.getCvdSeriesMap(t,e,E,!0);r.clear();const s=new Map;for(const o of this.getCvdTopExchanges(e)){const l=this.getCvdSeriesMap(t,e,o);if(!!l)for(const[i,c]of l){const a=s.get(i)||{buy:0,sell:0};a.buy+=Number(c==null?void 0:c.taker_buy_vol)||0,a.sell+=Number(c==null?void 0:c.taker_sell_vol)||0,s.set(i,a)}}let n=0;for(const o of[...s.keys()].sort((l,i)=>l-i)){const{buy:l,sell:i}=s.get(o);n+=l-i,r.set(o,{time:o*1e3,taker_buy_vol:l,taker_sell_vol:i,close:n})}},getActiveCvdFetchPlan(t=null){var r;const e={[F]:new Set,[P]:new Set};for(const s of this.getChartStudies(t)){const n=String((s==null?void 0:s.name)||"").trim(),o=this.getCvdMarketTypeFromStudyName(n);if(!o)continue;if(this.isAllCvdStudyName(n)){this.getCvdTopExchanges(o).forEach(c=>{e[o].add(c)});continue}const l=n.match(/^CVD (?:Perps|Spot)\s*\((.+)\)$/),i=((r=l==null?void 0:l[1])==null?void 0:r.trim())||null;if(!i||i==="Cumulative"){this.getCvdTopExchanges(o).forEach(c=>{e[o].add(c)});continue}e[o].add(i)}return e},hasActiveCvdStudy(t=null){const e=this.getActiveCvdFetchPlan(t);return e[F].size>0||e[P].size>0},getActiveCvdStudyExchanges(t=null){const e=this.getActiveCvdFetchPlan(t);return[...new Set([...e[F],...e[P]])]},async syncCvdDataForActiveStudies({chart:t=null,force:e=!1}={}){var d,h;const r=t||((h=(d=this.widget)==null?void 0:d.activeChart)==null?void 0:h.call(d));if(!r)return;const s=this.getActiveCvdFetchPlan(r),n=[...s[F]],o=[...s[P]];if(n.length===0&&o.length===0){this.lastCvdStudySyncSignature=null;return}const l=this.getActiveChartTicker()||this.selectedTicker,{symbol:i}=this.parseTicker(l),c=this.getActiveChartResolution(r),a=`${i}|${c}|f:${n.sort().join(",")}|s:${o.sort().join(",")}`;if(!e&&a===this.lastCvdStudySyncSignature)return;const u=await this.fetchCvdData(i,this.buildFundingRatePeriodParams(c,r),c,null,s);((u==null?void 0:u.successCount)||0)>0?(this.lastCvdStudySyncSignature=a,this.refreshChartDataForStudies(r)):this.lastCvdStudySyncSignature=null},async fetchCvdData(t,e,r,s=null,n=null){s&&this.pendingCvdFetchByKey.add(s);const o=n||this.getActiveCvdFetchPlan(),l=[];for(const i of[F,P])for(const c of o[i])l.push({marketType:i,exchange:c});try{const i=await Promise.allSettled(l.map(async({marketType:u,exchange:d})=>{const h=await ge(u,t,e,r,d);return this.mergeCvdData(t,u,d,h),{marketType:u,exchange:d}}));for(const u of[F,P])o[u].size>0&&this.rebuildCvdCumulativeSeries(t,u);const c=i.map((u,d)=>
1u.status==="rejected"?l[d]:null).filter(Boolean),a=i.filter(u=>u.status==="fulfilled").length;return c.length>0&&console.warn("CVD exchange fetch failed:",{symbol:t,resolution:r,failed:c}),s&&a>0&&this.lastCvdPollByKey.set(s,Date.now()),{successCount:a,failed:c,requests:l}}finally{s&&this.pendingCvdFetchByKey.delete(s)}},onlyHourly(){return!1},msUntilNextBoundary(t){const e=this.minutesToMs(this.resolutionToMinutes(t)),r=Date.now(),s=Math.floor(r/e)*e+e,n=2e3;return Math.max(0,s-r+n)},async pollLatestAndPush({symbolInfo:t,resolution:e,onRealtimeCallback:r,onResetCacheNeededCallback:s}){try{const n=this.keyFor(t,e),l=this.resolutionToMinutes(e)*60,i=this.lastBarBySymbol.get(n),c=Math.floor(Date.now()/1e3),u={from:i?Math.floor(i.time/1e3)-l*2:c-l*50,to:c,firstDataRequest:!1},{exchange:d,symbol:h}=this.parseTicker(t.ticker),S=5*60*1e3,m=this.lastLongShortPollByKey.get(n)||0,y=!this.pendingLongShortFetchByKey.has(n)&&Date.now()-m>=S,b=5*60*1e3,R=this.lastFundingRatePollByKey.get(n)||0,I=this.getActiveFundingRateStudyExchanges(),B=I.length>0&&!this.pendingFundingRateFetchByKey.has(n)&&Date.now()-R>=b,x=5*60*1e3,M=this.lastCvdPollByKey.get(n)||0,Y=this.getActiveCvdFetchPlan(),ut=this.hasActiveCvdStudy()&&!this.pendingCvdFetchByKey.has(n)&&Date.now()-M>=x,Z=At(this.selectedTarget,h,u,e,d);let g;const p=[];if(y&&p.push(this.fetchLongShortData(h,u,e,d,n).catch(f=>{console.warn("Realtime long/short refresh failed:",f)})),B&&p.push(this.fetchFundingRateData(h,u,e,n,I).catch(f=>{console.warn("Realtime funding-rate refresh failed:",f)})),ut&&p.push(this.fetchCvdData(h,u,e,n,Y).catch(f=>{console.warn("Realtime CVD refresh failed:",f)})),p.length>0){const[f]=await Promise.all([Z,...p]);g=f}else g=await Z;if(Array.isArray(g)&&g.length){const f=g[g.length-1];i?f.time>i.time?(this.lastBarBySymbol.set(n,f),r(f)):f.time===i.time&&(f.open!==i.open||f.high!==i.high||f.low!==i.low||f.close!==i.close||f.volume!==i.volume)&&(this.lastBarBySymbol.set(n,f),r(f)):(this.lastBarBySymbol.set(n,f),r(f))}}catch(n){if(console.error("Realtime poll failed:",n),typeof s=="function")try{s()}catch{}}},clearSubscription(t){const e=this.subscriptions.get(t);!e||(e.intervalId&&clearInterval(e.intervalId),e.timeoutId&&clearTimeout(e.timeoutId),this.subscriptions.delete(t))},clearAllSubscriptions(){for(const t of this.subscriptions.keys())this.clearSubscription(t)},finishChartReady(t,e){var r,s;if(!(this.destroyed||e!==this.bootstrapGeneration||!this.widget||this.widget!==t)){this.chartReady=!0,this.setupChartPersistence(t);try{this.applyChartOverrides(t)}catch(n){console.warn("Could not apply chart overrides:",n)}this.initialSavedData=null,this.pendingSavedData=null,this.defaultStudiesPending&&this.scheduleDefaultStudies(),this.syncFundingRateDataForActiveStudies({chart:(r=t.activeChart)==null?void 0:r.call(t),force:!0}).catch(n=>{console.warn("Could not sync funding-rate studies on chart ready:",n)}),this.syncCvdDataForActiveStudies({chart:(s=t.activeChart)==null?void 0:s.call(t),force:!0}).catch(n=>{console.warn("Could not sync CVD studies on chart ready:",n)}),this.$nextTick(()=>{requestAnimationFrame(()=>{if(!(this.destroyed||!this.widget||this.widget!==t||!this.chartReady))try{typeof t.resize=="function"&&t.resize()}catch{}})})}},loadPendingSavedLayout(t,e){const r=this.pendingSavedData;if(!(!r||this.destroyed||e!==this.bootstrapGeneration)){this.pendingSavedData=null,this.chartStateRestoring=!0;try{typeof t.load=="function"&&t.load(r),this.applyChartOverrides(t)}catch(s){console.warn("Could not load saved chart layout:",s)}requestAnimationFrame(()=>{this.chartStateRestoring=!1,this.finishChartReady(t,e)})}},bootstrapChart(){if(this.destroyed||this.widget||this.chartInitPending)return Promise.resolve();const t=this.bootstrapGeneration;return this.initializeChart().then(()=>{if(this.destroyed||t!==this.bootstrapGeneration)return;const e=this.widget;!e||this.chartReadyListenerAttached||(this.chartReadyListenerAttached=!0,e.onChartReady(()=>{if(!(this.destroyed||t!==this.bootstrapGeneration||this.widget!==e)){try{this.applyChartOverrides(e)}catch(r){console.warn("Could not apply chart overrides on ready:",r)}if(this.pendingSavedData){this.loadPendingSavedLayout(e,t);return}this.finishChartReady(e,t)}}))})},async initializeChart(){if(this.destroyed||this.widget||this.chartInitPending)return;this.chartInitPending=!0;const t=await this.waitForVisibleContainer();if(this.destroyed){this.chartInitPending=!1;return}if(!t){this.chartInitPending=!1,!this.widget&&!this.destroyed&&(clearTimeout(this.initRetryTimer),this.initRetryTimer=setTimeout(()=>this.bootstrapChart(),100));return}try{const e=this.$refs.chartContainer,r=this.readSavedChartState(),s=this.resolveSavedSymbol(r),n=this.normalizeChartTicker(this.initialSymbol);s?this.selectedTicker=s:n&&(this.selectedTicker=n);const o=this.hasPersistedChartLayout(r);if(this.initialSavedData=r,this.pendingSavedData=o?r:null,o?(this.defaultStudiesCreated=!0,this.defaultStudiesPending=!1):this.getDefaultStudyNames().length>0?(this.defaultStudiesCreated=!1,this.defaultStudiesPending=!0):(this.defaultStudiesCreated=!0,this.defaultStudiesPending=!1),this.destroyed)return;const l=await se();if(this.destroyed)return;const i={datafeed:{onReady:c=>{c(this.getDatafeedConfig())},resolveSymbol:(c,a,u)=>{const d=this.parseTicker(c),h=`${d.exchange}:${d.symbol}`;a({name:d.symbol,ticker:h,full_name:h,description:`${d.symbol}`,exchange:d.exchange,type:this.selectedTarget,minmov:1,pricescale:100,visible_plots_set:"ohlcv",volume_precision:2,has_weekly_and_monthly:!1,session:"24x7",timezone:"Etc/UTC",has_intraday:!0,data_status:"delayed_streaming",supported_resolutions:A.supported_resolutions})},searchSymbols:(c,a,u,d)=>{const h=(c||"").toLowerCase().trim(),S=(a||"").toLowerCase().trim(),m=this.supportedSymbols.filter(y=>S&&y.exchange.toLowerCase()!==S?!1:h?y.symbol.toLowerCase().includes(h)||y.description.toLowerCase().includes(h):!0);d((Array.isArray(m)?m:[]).slice(0,100))},getBars:async(c,a,u,d,h)=>{try{const{exchange:S,symbol:m}=this.parseTicker(c.ticker),y=this.keyFor(c,a),b=this.fetchLongShortData(m,u,a,S,y).catch(M=>{console.warn("Long/short data fetch failed:",M)}),R=this.hasActiveFundingRateStudy()?this.fetchFundingRateData(m,u,a,y,this.getActiveFundingRateStudyExchanges()).catch(M=>{console.warn("Funding rate data fetch failed:",M)}):null,I=this.hasActiveCvdStudy()?this.fetchCvdData(m,u,a,y,this.getActiveCvdFetchPlan()).catch(M=>{console.warn("CVD data fetch failed:",M)}):null,B=[b];R&&B.push(R),I&&B.push(I);const[x]=await Promise.all([At(this.selectedTarget,m,u,a,S),...B]);Array.isArray(x)&&x.length>0?(d(x,{noData:!1}),this.lastBarBySymbol.set(y,x[x.length-1]),this.scheduleDefaultStudies()):(console.warn("No data returned for",c.ticker,a),d([],{noData:!0}))}catch(S){console.error("Chart data fetch error:",S),h(`Failed to fetch chart data: ${S.message}`)}},subscribeBars:(c,a,u,d,h)=>{if(this.onlyHourly()&&this.resolutionToMinutes(a)!==60){this.subscriptions.set(d,{intervalId:null,timeoutId:null,symbolInfo:c,resolution:a});return}const S=()=>{const m=setTimeout(async()=>{await this.pollLatestAndPush({symbolInfo:c,resolution:a,onRealtimeCallback:u,onResetCacheNeededCallback:h});const y=setInterval(()=>{this.pollLatestAndPush({symbolInfo:c,resolution:a,onRealtimeCallback:u,onResetCacheNeededCallback:h})},this.minutesToMs(this.resolutionToMinutes(a))),b=this.subscriptions.get(d)||{};b.intervalId=y,b.timeoutId=null,b.symbolInfo=c,b.resolution=a,this.subscriptions.set(d,b)},this.msUntilNextBoundary(a));this.subscriptions.set(d,{intervalId:null,timeoutId:m,symbolInfo:c,resolution:a})};this.pollLatestAndPush({symbolInfo:c,resolution:a,onRealtimeCallback:u,onResetCacheNeededCallback:h}).finally(()=>S())},unsubscribeBars:c=>{this.clearSubscription(c)}},interval:A.interval,container:e,library_path:A.library_path,locale:Le()||"en",custom_css_url:"/tradingview.css",enabled_features:A.enabled_features,disabled_features:A.disabled_features,client_id:A.clientId,user_id:this.chartStateKey,load_last_chart:!1,supports_search:!0,autosize:!0,fullscreen:!1,supports_group_request:!1,supports_marks:!1,supports_timescale_marks:!1,supports_time:!0,theme:"dark",auto_save_delay:2,studies_access:{type:"white",tools:[{name:"Long/S
1hort Ratio"},{name:"Long/Short Ratio (Top Traders)"},{name:this.getAllFundingRateStudyName()},...this.getIndividualFundingRateIndicatorExchanges().map(c=>({name:this.getFundingRateStudyName(c)})),{name:z},{name:H},...this.getCvdTopExchanges(F).map(c=>({name:this.getCvdStudyName(F,c)})),...this.getCvdTopExchanges(P).map(c=>({name:this.getCvdStudyName(P,c)})),{name:this.getCvdStudyName(F,E)},{name:this.getCvdStudyName(P,E)}]},loading_screen:A.getChartLoadingScreen(),settings_adapter:A.getChartSettingsAdapter(),overrides:A.getChartOverrides(),custom_indicators_getter:c=>{const a=this,u=this.longShortDataMap,d=this.topTradersDataMap,h=(g,p,f=86400)=>{if(!g||typeof g.has!="function")return null;if(g.has(p))return g.get(p);let _=null,v=1/0;for(const[C,T]of g){const w=Math.abs(C-p);w<v&&w<f&&(v=w,_=T)}return _},S=[{name:"Long/Short Ratio",metainfo:{_metainfoVersion:53,id:"BTCLongShortRatio@tv-basicstudies-1",description:"Long/Short Ratio",shortDescription:"L/S % (Retail Traders)",isCustomIndicator:!0,is_price_study:!1,format:{type:"percent",precision:2},plots:[{id:"long_pct",type:"line"},{id:"short_pct",type:"line"}],defaults:{styles:{long_pct:{color:"#3CFF00",linewidth:1,plottype:0,trackPrice:!1},short_pct:{color:"#EE0202",linewidth:1,plottype:0,trackPrice:!1}},inputs:{}},styles:{long_pct:{title:"Long %",histogramBase:0},short_pct:{title:"Short %",histogramBase:0}},inputs:[]},constructor:function(){const g=u;this.init=function(p,f){this._context=p,this._input=f},this.main=function(p,f){var D,k;this._context=p,this._input=f;const _=this._context.symbol.time,v=Math.floor(_/1e3),C=h(g,v),T=(D=C==null?void 0:C.long)!=null?D:50,w=(k=C==null?void 0:C.short)!=null?k:50;return[T,w]}}},{name:"Long/Short Ratio (Top Traders)",metainfo:{_metainfoVersion:53,id:"BTCLongShortRatioTopTraders@tv-basicstudies-1",description:"Long/Short Ratio (Top Traders)",shortDescription:"L/S % (Top Traders)",isCustomIndicator:!0,is_price_study:!1,format:{type:"percent",precision:2},plots:[{id:"long_pct",type:"line"},{id:"short_pct",type:"line"}],defaults:{styles:{long_pct:{color:"#3CFF00",linewidth:1,plottype:0,trackPrice:!1},short_pct:{color:"#EE0202",linewidth:1,plottype:0,trackPrice:!1}},inputs:{}},styles:{long_pct:{title:"Long % (Top)",histogramBase:0},short_pct:{title:"Short % (Top)",histogramBase:0}},inputs:[]},constructor:function(){const g=d;this.init=function(p,f){this._context=p,this._input=f},this.main=function(p,f){var D,k;this._context=p,this._input=f;const _=this._context.symbol.time,v=Math.floor(_/1e3),C=h(g,v),T=(D=C==null?void 0:C.long)!=null?D:50,w=(k=C==null?void 0:C.short)!=null?k:50;return[T,w]}}}],m=["#F5A623","#4A90E2","#50E3C2","#BD10E0","#FF5B5B","#7ED321","#B8E986","#9013FE"],y=this.getAllFundingRateExchanges(),b=g=>{const p=Math.max(0,y.indexOf(g));return m[p%m.length]},R=(g,p)=>({name:g,metainfo:{_metainfoVersion:53,id:this.getFundingRateStudyId(p),description:g,shortDescription:g,isCustomIndicator:!0,is_price_study:!1,format:{type:"percent",precision:6},plots:[...y.map(f=>({id:this.getFundingRatePlotId(f),type:"line"})),this.getFundingRateZeroLinePlot()],defaults:{styles:{...Object.fromEntries(y.map(f=>
1[this.getFundingRatePlotId(f),{color:b(f),display:lt,linewidth:1,plottype:0,trackPrice:!1}])),[$]:this.getFundingRateZeroLineStyleDefaults()},inputs:{}},styles:{...Object.fromEntries(y.map(f=>[this.getFundingRatePlotId(f),{title:f,histogramBase:0}])),[$]:this.getFundingRateZeroLineStyleMeta()},inputs:[]},constructor:function(){const f=y;this.init=function(_,v){this._context=_,this._input=v},this.main=function(_,v){this._context=_,this._input=v;const C=this._context.symbol.time,T=Math.floor(C/1e3),{symbol:w}=a.parseTicker(a.selectedTicker);return[...f.map(D=>{var N;const k=h(a.getFundingRateSeriesMap(w,D),T);return(N=k==null?void 0:k.close)!=null?N:0}),0]}}}),I=y.length>0?R(this.getAllFundingRateStudyName(),"AllExchanges"):null,B=y.length>0?R(this.getLegacyAllFundingRateStudyName(),kt):null,x=this.getIndividualFundingRateIndicatorExchanges().map(g=>({name:this.getFundingRateStudyName(g),metainfo:{_metainfoVersion:53,id:this.getFundingRateStudyId(g),description:this.getFundingRateStudyName(g),shortDescription:this.getFundingRateStudyName(g),isCustomIndicator:!0,is_price_study:!1,format:{type:"percent",precision:6},plots:[{id:"funding_rate",type:"line"},this.getFundingRateZeroLinePlot()],defaults:{styles:{funding_rate:{color:b(g),display:lt,line
1width:1,plottype:0,trackPrice:!1},[$]:this.getFundingRateZeroLineStyleDefaults()},inputs:{}},styles:{funding_rate:{title:this.getFundingRateStudyName(g),histogramBase:0},[$]:this.getFundingRateZeroLineStyleMeta()},inputs:[]},constructor:function(){const p=g;this.init=function(f,_){this._context=f,this._input=_},this.main=function(f,_){var D;this._context=f,this._input=_;const v=this._context.symbol.time,C=Math.floor(v/1e3),{symbol:T}=a.parseTicker(a.selectedTicker),w=h(a.getFundingRateSeriesMap(T,p),C);return[(D=w==null?void 0:w.close)!=null?D:0,0]}}}));I&&S.push(I),B&&S.push(B),S.push(...x);const M=m,Y=(g,p)=>{if(g===E)return"#FFFFFF";const f=Math.max(0,p.indexOf(g));return M[f%M.length]},ut=g=>{const p=a.getCvdTopExchanges(g),f=[...p,E],_=a.getAllCvdStudyName(g);return{name:_,metainfo:{_metainfoVersion:53,id:a.getCvdStudyId(g,"AllExchanges"),description:_,shortDescription:_,isCustomIndicator:!0,is_price_study:!1,format:{type:"volume",precision:0},plots:[...f.map(v=>({id:a.getCvdPlotId(v),type:"line"})),a.getCvdZeroLinePlot()],defaults:{styles:{...Object.fromEntries(f.map(v=>
1[a.getCvdPlotId(v),{color:Y(v,p),display:lt,linewidth:v===E?2:1,plottype:0,trackPrice:!1}])),[W]:a.getCvdZeroLineStyleDefaults()},inputs:{}},styles:{...Object.fromEntries(f.map(v=>[a.getCvdPlotId(v),{title:v===E?"Cumulative":v,histogramBase:0}])),[W]:a.getCvdZeroLineStyleMeta()},inputs:[]},constructor:function(){const v=g;this.init=function(C,T){this._context=C,this._input=T},this.main=function(C,T){this._context=C,this._input=T;const w=this._context.symbol.time,D=Math.floor(w/1e3),{symbol:k}=a.parseTicker(a.selectedTicker);return[...f.map(N=>{var wt;const U=h(a.getCvdSeriesMap(k,v,N),D);return(wt=U==null?void 0:U.close)!=null?wt:0}),0]}}}},Z=(g,p)=>{const f=a.getCvdTopExchanges(g);return{name:a.getCvdStudyName(g,p),metainfo:{_metainfoVersion:53,id:a.getCvdStudyId(g,p),description:a.getCvdStudyName(g,p),shortDescription:a.getCvdStudyName(g,p),isCustomIndicator:!0,is_price_study:!1,format:{type:"volume",precision:0},plots:[{id:"cvd_value",type:"line"},a.getCvdZeroLinePlot()],defaults:{styles:{cvd_value:{color:Y(p,f),display:lt,line
1width:p===E?2:1,plottype:0,trackPrice:!1},[W]:a.getCvdZeroLineStyleDefaults()},inputs:{}},styles:{cvd_value:{title:a.getCvdStudyName(g,p),histogramBase:0},[W]:a.getCvdZeroLineStyleMeta()},inputs:[]},constructor:function(){const _=g,v=p;this.init=function(C,T){this._context=C,this._input=T},this.main=function(C,T){var U;this._context=C,this._input=T;const w=this._context.symbol.time,D=Math.floor(w/1e3),{symbol:k}=a.parseTicker(a.selectedTicker),N=h(a.getCvdSeriesMap(k,_,v),D);return[(U=N==null?void 0:N.close)!=null?U:0,0]}}}};for(const g of[F,P]){S.push(ut(g));for(const p of[...a.getCvdTopExchanges(g),E])S.push(Z(g,p))}return Promise.resolve(S)}};if(s?i.symbol=s:i.symbol=n||this.selectedTicker,this.widget=new l(i),this.destroyed){try{this.widget.remove()}catch{}this.widget=null,this.pendingSavedData=null;return}}catch(e){console.warn("Could not initialize chart:",e)}finally{this.chartInitPending=!1}}},watch:{isActive(t){!t||this.$nextTick(()=>{requestAnimationFrame(()=>{if(!(this.destroyed||!this.widget||!this.chartReady))try{typeof this.widget.resize=="function"&&this.widget.resize()}catch{}})})}},mounted(){try{localStorage.getItem("tradingview.chartproperties.mainSeriesProperties")||localStorage.setItem("tradingview.chartproperties.mainSeriesProperties",JSON.stringify(yt)),localStorage.getItem("tradingview.IntervalWidget.quicks")||localStorage.setItem("tradingview.IntervalWidget.quicks",JSON.stringify(["60","1D","1W"]))}catch(e){console.warn("Could not set chart favorites:",e)}const t=this.getFallbackSymbols();this.supportedSymbols=t,this.allSupportedSymbols=t,this.refreshSupportedSymbols().finally(()=>{this.$nextTick(()=>{requestAnimationFrame(()=>{this.destroyed||this.bootstrapChart()})})})},beforeDestroy(){this.destroyed=!0,this.bootstrapGeneration+=1,this.pendingSavedData=null,this.clearChartTimers()},destroyed(){this.clearChartTimers(),this.teardownChartPersistence(),this.clearAllSubscriptions();const t=this.widget;if(!t)return;const e=()=>{try{t.remove()}catch(r){console.warn("Could not remove chart widget:",r)}this.widget=null,this.chartReady=!1,this.chartInitPending=!1,this.chartReadyListenerAttached=!1};if(this.skipDestroySave||!this.chartReady||this.chartStateRestoring){e();return}try{t.save(r=>{try{this.writeSavedChartState(this.attachSymbolToSavedState(r))}catch(s){console.warn("Could not save chart state:",s)}e()},{includeDrawings:!0})}catch(r){console.warn("Could not save chart state on destroy:",r),e()}}};var Ee=function(){var e=this,r=e._self._c;return r("div",{staticClass:"h-full min-h-0 flex flex-col"},[r("div",{ref:"chartContainer",staticClass:"chart-pane-surface border-t border-gray-400",class:e.fillContainer?"h-full w-full min-h-0":"h-[calc(100vh-99px)] max-lg:min-h-[calc(100dvh-100px)] lg:h-full"})])},Be=[],Me=bt(Ie,Ee,Be,!1,null,"6d3c0e75",null,null);const Ne=Me.exports;async function Ue(){const{data:t}=await window.axios.get("/api/charts/workspace");return t}async function Oe(t){const{data:e}=await window.axios.put("/api/charts/workspace",t);return e}const Et="mdx_chart_workspace_storage_version",vt="charts_workspace_tabs",$e="tv_chart_state",We="tv_chart_state_";function Ve(){const t={}.VITE_CHART_WORKSPACE_STORAGE_VERSION;return t==null||String(t).trim()===""?"1":String(t).trim()}function Ke(t){return!t||typeof t!="string"?!1:t===vt||t===$e||t.startsWith(We)}function ze(){const t=[];try{for(let e=0;e<localStorage.length;e++){const r=localStorage.key(e);Ke(r)&&t.push(r)}for(const e of t)localStorage.removeItem(e)}catch(e){console.warn("Could not clear chart workspace localStorage:",e)}}function He(){const t=Ve();let e=null;try{e=localStorage.getItem(Et)}catch{e=null}if(e===t)return{migrated:!1,version:t};ze();try{localStorage.setItem(Et,t)}catch(r){console.warn("Could not persist chart workspace storage version:",r)}return{migrated:!0,version:t}}const je="Binance:BTCUSDT",qe=1e3,Ge="bi bi-graph-up-arrow",Ye={name:"ChartWorkspaceTabs",components:{TVChartContainer:Ne},data(){return{tabs:[],activeTabId:null,chartMountReady:!1,nameSnapshot:"",chartTabIcon:Ge,serverSaveTimer:null,serverSaveInFlight:!1,chartStorageReset:!1,mountedTabIds:[],chartStateCache:{}}},computed:{isAuthenticated(){var t,e;return Boolean((e=(t=this.$page)==null?void 0:t.props)==null?void 0:e.user)},mountedTabs(){return this.tabs.filter(t=>this.isTabMounted(t.id))},maxTabs(){return mt}},created(){const{migrated:t}=He();this.chartStorageReset=t,_t(),Nt();const e=this.loadWorkspace();
1this.ensureTabsInitialized(),this.seedDefaultChartStates(),this.migrateLegacyChartState(),this.removeLegacyChartStateKey(),this.markTabMounted(this.activeTabId),this.chartStorageReset&&this.isAuthenticated&&e&&this.scheduleServerSave(),this.$nextTick(()=>{requestAnimationFrame(()=>{this.chartMountReady=!0})}),this.isAuthenticated&&this.syncWorkspaceFromAccount(e)},beforeDestroy(){clearTimeout(this.serverSaveTimer),this.serverSaveTimer=null,this.saveAllCharts().then(()=>(this.mountedTabIds.forEach(t=>this.skipDestroySaveForTab(t)),this.flushServerSave()))},methods:{getChartRef(t){const e=this.$refs[`chart-${t}`];return Array.isArray(e)?e[0]:e},isTabMounted(t){return this.mountedTabIds.includes(t)},markTabMounted(t){!t||this.isTabMounted(t)||!this.tabs.some(e=>e.id===t)||(this.mountedTabIds=[...this.mountedTabIds,t])},syncMountedTabs(){const t=new Set(this.tabs.map(e=>e.id));this.mountedTabIds=this.mountedTabIds.filter(e=>t.has(e)),this.markTabMounted(this.activeTabId)},cacheChartState(t,e){!t||!e||typeof e!="object"||(this.chartStateCache={...this.chartStateCache,[t]:e})},dropCachedChartState(t){if(!t||!Object.prototype.hasOwnProperty.call(this.chartStateCache,t))return;const e={...this.chartStateCache};delete e[t],this.chartStateCache=e},readCachedChartState(t){if(!t)return null;if(Object.prototype.hasOwnProperty.call(this.chartStateCache,t))return this.chartStateCache[t];const e=localStorage.getItem(t);if(!e)return null;try{const r=JSON.parse(e);return this.cacheChartState(t,r),r}catch{return null}},writeChartStateToLocalStorage(t,e){if(!(!t||!e||typeof e!="object"))try{localStorage.setItem(t,JSON.stringify(e)),this.cacheChartState(t,e)}catch(r){console.warn("Could not save chart state:",t,r)}},saveChartForTab(t){const e=this.getChartRef(t);return e&&typeof e.saveChartStateAsync=="function"?e.saveChartStateAsync():Promise.resolve()},skipDestroySaveForTab(t){const e=this.getChartRef(t);e&&typeof e.skipNextDestroySave=="function"&&e.skipNextDestroySave()},saveAllCharts(){return this.mountedTabIds.length===0?Promise.resolve():Promise.all(this.mountedTabIds.map(t=>this.saveChartForTab(t)))},onChartStateSaved(t){(t==null?void 0:t.chartStateKey)&&(t==null?void 0:t.state)&&this.cacheChartState(t.chartStateKey,t.state),this.scheduleServerSave()},workspacePayload(){return{version:j,tabs:this.tabs.map(({id:t,name:e,locked:r,fixed:s})=>({id:t,name:e,locked:s?!1:Boolean(r)})),activeTabId:this.activeTabId}},tabCanClose(t){return Dt(t)},isTabLocked(t){return Boolean(t&&(t.fixed||t.locked))},tabLockTitle(t){return!t||t.fixed?"Default tabs cannot be closed":this.isTabLocked(t)?"Unlock tab (allow close)":"Lock tab (prevent close)"},toggleTabLock(t){if(!t||t.fixed)return;const e=Boolean(t.locked);t.locked=!t.locked,this.persistWorkspace(),e&&(t.id===Vt||t.id===Kt||t.id===zt)&&(this.markTabMounted(t.id),this.$nextTick(()=>this.ensureTabDefaultStudies(t.id)))},ensureTabDefaultStudies(t,e=0){const r=this.getChartRef(t);if(r&&typeof r.ensureDefaultStudies=="function"){r.ensureDefaultStudies();return}e>=30||setTimeout(()=>this.ensureTabDefaultStudies(t,e+1),100)},ensureTabsInitialized(){if(!Array.isArray(this.tabs)||this.tabs.length===0){const t=Pt();this.tabs=t.tabs,this.activeTabId=t.activeTabId}},applyWorkspace(t){if(!t||!Array.isArray(t.tabs))return!1;const e=Rt(t.tabs,t.activeTabId,t.version);return this.tabs=e.tabs,this.activeTabId=e.activeTabId,this.ensureTabsInitialized(),this.syncMountedTabs(),!0},seedDefaultChartStates(){for(const t of this.tabs){if(!t.symbol)continue;const e=this.chartStateKeyFor(t.id);if(!localStorage.getItem(e))try{this.writeChartStateToLocalStorage(e,{_mdxSymbol:t.symbol})}catch(r){console.warn("Could not seed chart state:",e,r)}}},loadWorkspaceFromLocalStorage(){try{const t=localStorage.getItem(vt);if(!t)return null;const e=JSON.parse(t);if(this.applyWorkspace(e))return this.persistWorkspaceLocal(),e}catch{}return null},hydrateChartStatesToLocalStorage(t){if(!t||typeof t!="object")return;const e=new Map(this.tabs.map(r=>[r.id,r]));for(const[r,s]of Object.entries(t)){if(!r||s==null||typeof s!="object")continue;let n=s;const o=be(r);if(o&&jt.has(o)){const l=e.get(o);n=Ft(s,l==null?void 0:l.symbol)}try{this.writeChartStateToLocalStorage(r,n)}catch(l){console.warn("Could not hydrate chart state:",r,l)}}},collectChartStatesForSync(){const t={};for(const e of this.tabs){const r=this.chartStateKeyFor(e.id),s=this.readCachedChartState(r);!s||(t[r]=s)}return t},loadWorkspace(){if(this.chartStorageReset?null:this.loadWorkspaceFromLocalStorage())return this.isAuthenticated&&this.scheduleServerSave(),!0;const e=Pt();return this.tabs=e.tabs,this.activeTabId=e.activeTabId,this.persistWorksp
1aceLocal(),!1},async syncWorkspaceFromAccount(t){try{const e=await Ue();if(!(e!=null&&e.workspace)){t||this.scheduleServerSave();return}if(!t&&this.applyWorkspace(e.workspace)){this.chartStorageReset||this.hydrateChartStatesToLocalStorage(e.chartStates),this.persistWorkspaceLocal(),this.workspaceNeedsUpgrade(e.workspace)&&this.scheduleServerSave();return}const r=this.normalizedWorkspacePayload(e.workspace),s=this.workspacePayload();JSON.stringify(r)!==JSON.stringify(s)&&this.scheduleServerSave()}catch(e){console.warn("Could not load chart workspace from account:",e),t||this.scheduleServerSave()}},normalizedWorkspacePayload(t){const e=Rt((t==null?void 0:t.tabs)||[],t==null?void 0:t.activeTabId,t==null?void 0:t.version);return{version:e.version,tabs:e.tabs.map(({id:r,name:s,locked:n,fixed:o})=>({id:r,name:s,locked:o?!1:Boolean(n)})),activeTabId:e.activeTabId}},workspaceNeedsUpgrade(t){const e=Number.parseInt(t==null?void 0:t.version,10);return Number.isFinite(e)?e<j:!0},persistWorkspaceLocal(){try{localStorage.setItem(vt,JSON.stringify(this.workspacePayload()))}catch(t){console.warn("Could not save chart workspace:",t)}},persistWorkspace(){this.persistWorkspaceLocal(),this.scheduleServerSave()},scheduleServerSave(){!this.isAuthenticated||(clearTimeout(this.serverSaveTimer),this.serverSaveTimer=setTimeout(()=>{this.flushServerSave()},qe))},async flushServerSave(){if(!(!this.isAuthenticated||this.serverSaveInFlight)){clearTimeout(this.serverSaveTimer),this.serverSaveTimer=null,this.serverSaveInFlight=!0;try{await Oe({workspace:this.workspacePayload(),chartStates:this.collectChartStatesForSync()})}catch(t){console.warn("Could not save chart workspace to account:",t)}finally{this.serverSaveInFlight=!1}}},chartStateKeyFor(t){return ve(t)},migrateLegacyChartState(){const t=localStorage.getItem("tv_chart_state"),e=this.tabs[0];if(!t||!e)return;const r=this.chartStateKeyFor(e.id);if(!localStorage.getItem(r))try{const s=JSON.parse(t),n=e.fixed?Ft(s,e.symbol):s;this.writeChartStateToLocalStorage(r,n)}catch{localStorage.setItem(r,t)}},removeLegacyChartStateKey(){try{localStorage.removeItem("tv_chart_state")}catch{}},isTabActive(t){return t===this.activeTabId},tabItemClasses(t){return this.isTabActive(t)?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-100 hover:text-gray-900"},tabIconClasses(t){const e=[this.chartTabIcon,"shrink-0 text-[11px] leading-none"];return this.isTabActive(t)?e.push("text-primary-500"):e.push("text-gray-700 group-hover/tab:text-primary-500"),e},onTabNameClick(t,e){e===this.activeTabId&&t.stopPropagation()},async handleTabClick(t){if(t===this.activeTabId){this.focusTabInput(t,!0);return}await this.saveChartForTab(this.activeTabId),this.markTabMounted(t),this.activeTabId=t,this.persistWorkspace()},async addTab(){if(this.tabs.length>=mt)return;await this.saveChartForTab(this.activeTabId);const t=this.tabs.filter(s=>!s.fixed).length,e=Pe(),r={id:e,name:`Chart ${t+1}`,symbol:je,fixed:!1,locked:!1};this.tabs.push(r),this.syncMountedTabs(),this.activeTabId=e,this.markTabMounted(e);try{this.writeChartStateToLocalStorage(this.chartStateKeyFor(e),{_mdxSymbol:r.symbol})}catch(s){console.warn("Could not seed new chart tab state:",s)}this.persistWorkspace(),this.$nextTick(()=>this.focusTabInput(e))},async removeTab(t){const e=this.tabs.find(n=>n.id===t);if(!Dt(e))return;const r=this.tabs.findIndex(n=>n.id===t);if(r===-1)return;const s=t===this.activeTabId;s&&await this.saveChartForTab(t),this.skipDestroySaveForTab(t),this.tabs.splice(r,1);try{localStorage.removeItem(this.chartStateKeyFor(t))}catch{}if(this.dropCachedChartState(this.chartStateKeyFor(t)),s){const n=this.tabs[r]||this.tabs[r-1]||this.tabs[0];this.activeTabId=n.id,this.markTabMounted(n.id)}this.syncMountedTabs(),this.persistWorkspace()},focusTabInput(t,e=!0){const r=this.$refs[`tabInput-${t}`],s=Array.isArray(r)?r[0]:r;!s||(s.focus(),e&&s.select())},onTabNameFocus(t){this.nameSnapshot=t.name},defaultTabDisplayName(t){const e=Ht.find(r=>r.id===t);return(e==null?void 0:e.name)||"Chart"},onTabNameBlur(t){const e=(t.name||"").trim();t.fixed?t.name=e||this.nameSnapshot||this.defaultTabDisplayName(t.id):t.name=e||this.nameSnapshot||"Chart",this.persistWorksp
1ace()},onTabNameEscape(t,e){e.name=this.nameSnapshot,t.target.blur()}}};var Ze=function(){var e=this,r=e._self._c;return r("div",{staticClass:"charts-workspace flex flex-col h-full min-h-0 w-full overflow-hidden"},[r("div",{staticClass:"flex items-stretch shrink-0 h-[18px] min-h-[18px] border-b border-gray-400 bg-gray-200 overflow-x-auto hide-scrollbar",attrs:{role:"tablist"}},[e._l(e.tabs,function(s){return r("div",{key:s.id,staticClass:"group/tab shrink-0 h-full cursor-pointer",attrs:{role:"tab","aria-selected":s.id===e.activeTabId},on:{click:function(n){return e.handleTabClick(s.id)}}},[r("div",{staticClass:"flex items-center gap-1 h-full pl-2.5 pr-1.5 text-[11px] transition-colors duration-150 rounded-t-[6px]",class:e.tabItemClasses(s.id)},[r("i",{class:e.tabIconClasses(s.id),attrs:{"aria-hidden":"true"}}),r("div",{staticClass:"tab-label shrink-0 ml-1 whitespace-nowrap"},[r("input",{directives:[{name:"model",rawName:"v-model",value:s.name,expression:"tab.name"}],ref:`tabInput-${s.id}`,refInFor:!0,staticClass:"inline-tab-name block bg-transparent border-0 border-b border-transparent text-inherit font-inherit text-[11px] leading-none p-0 m-0 outline-none rounded-none focus:border-primary-500",class:{"pointer-events-none cursor-pointer focus:border-transparent":s.id!==e.activeTabId},attrs:{type:"text",readonly:s.id!==e.activeTabId,size:Math.max((s.name||"").length,3)},domProps:{value:s.name},on:{click:function(n){return n.stopPropagation(),e.onTabNameClick(n,s.id)},focus:function(n){return e.onTabNameFocus(s)},blur:function(n){return e.onTabNameBlur(s)},keydown:[function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"enter",13,n.key,"Enter")?null:(n.preventDefault(),n.target.blur())},function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"esc",27,n.key,["Esc","Escape"])?null:(n.preventDefault(),e.onTabNameEscape(n,s))}],input:function(n){n.target.composing||e.$set(s,"name",n.target.value)}}})]),s.fixed?e._e():r("button",{staticClass:"shrink-0 w-3.5 h-3.5 flex items-center justify-center rounded text-gray-700 hover:text-gray-900 transition-opacity",class:s.locked?"opacity-100":"opacity-0 group-hover/tab:opacity-100",attrs:{type:"button","aria-label":s.locked?`Unlock ${s.name}`:`Lock ${s.name}`,"aria-pressed":Boolean(s.locked),title:e.tabLockTitle(s)},on:{click:function(n){return n.stopPropagation(),e.toggleTabLock(s)}}},[r("i",{staticClass:"bi text-[11px] leading-none",class:s.locked?"bi-lock-fill":"bi-unlock",attrs:{"aria-hidden":"true"}})]),e.tabCanClose(s)?r("button",{staticClass:"opacity-0 group-hover/tab:opacity-100 shrink-0 w-3.5 h-3.5 flex items-center justify-center rounded text-gray-700 hover:text-gray-900 transition-opacity",attrs:{type:"button","aria-label":`Close ${s.name}`},on:{click:function(n){return n.stopPropagation(),e.removeTab(s.id)}}},[r("i",{staticClass:"bi bi-x text-[11px] leading-none"})]):e._e()])])}),e.tabs.length<e.maxTabs?r("button",{staticClass:"shrink-0 h-full px-1.5 text-[11px] text-gray-700 hover:bg-gray-100 hover:text-gray-900 transition-colors duration-150 rounded",attrs:{type:"button","aria-label":"Add chart tab"},on:{click:e.addTab}},[r("i",{staticClass:"bi bi-plus text-[11px] leading-none"})]):e._e()],2),r("div",{staticClass:"flex-1 min-h-0 relative chart-workspace-panel"},e._l(e.mountedTabs,function(s){return e.chartMountReady?r("TVChartContainer",{directives:[{name:"show",rawName:"v-show",value:s.id===e.activeTabId,expression:"tab.id === activeTabId"}],key:s.id,ref:"chart-"+s.id,refInFor:!0,staticClass:"chart-tab-panel",attrs:{"chart-state-key":e.chartStateKeyFor(s.id),"initial-symbol":s.symbol,"default-studies":s.defaultStudies||[],"is-active":s.id===e.activeTabId,"fill-container":""},on:{"chart-state-saved":e.onChartStateSaved}}):e._e()}),1)])},Je=[],Xe=bt(Ye,Ze,Je,!1,null,"a6db6885",null,null);const Qe=Xe.exports;_t();Nt();const tr={components:{ChartWorkspaceTabs:Qe,AppLayout:Gt},props:["user"]};var er=function(){var e=this,r=e._self._c;return r("app-layout",{attrs:{boxed:!1,"has-padding":!1}},[r("div",{staticClass:"charts-page flex flex-col w-full overflow-hidden max-lg:h-[calc(100dvh-100px)] max-lg:max-h-[calc(100dvh-100px)] lg:h-full lg:min-h-0 bg-[#181716]"},[r("ChartWorkspaceTabs")],1)])},rr=[],sr=bt(tr,er,rr,!1,null,null,null,null);const Pr=sr.exports;export{Pr as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.