@liberfi.io/ui-tradingview 0.1.233 → 0.1.234

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/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),jotai=require('jotai'),utils=require('jotai/utils'),lodashEs=require('lodash-es'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@liberfi.io/i18n');var te=(t=>(t.TradingView="TradingView",t.Original="Original",t))(te||{}),Ue=(t=>(t.Price="price",t.MarketCap="market_cap",t))(Ue||{}),ze=(o=>(o.USD="USD",o.SOL="SOL",o.ETH="ETH",o.TRX="TRX",o.BNB="BNB",o))(ze||{}),re=(l=>(l[l.Bars=0]="Bars",l[l.Candles=1]="Candles",l[l.Line=2]="Line",l[l.Area=3]="Area",l[l.HeikenAshi=8]="HeikenAshi",l[l.HollowCandles=9]="HollowCandles",l[l.Baseline=10]="Baseline",l[l.HiLo=12]="HiLo",l[l.Column=13]="Column",l[l.LineWithMarkers=14]="LineWithMarkers",l[l.Stepline=15]="Stepline",l[l.HLCArea=16]="HLCArea",l[l.VolCandle=19]="VolCandle",l[l.Renko=4]="Renko",l[l.Kagi=5]="Kagi",l[l.PointAndFigure=6]="PointAndFigure",l[l.LineBreak=7]="LineBreak",l))(re||{}),$e=(t=>(t.Light="light",t.Dark="dark",t))($e||{}),ae=(C=>(C.HeaderWidget="header_widget",C.HeaderCandleStyleMenu="header_candle_style_menu",C.HeaderFullscreenButton="header_fullscreen_button",C.TradingAccountManager="trading_account_manager",C.MultiCharts="multi_charts",C.CreateVolumeIndicatorByDefault="create_volume_indicator_by_default",C.VolumeForceOverlay="volume_force_overlay",C.HideDrawingToolsByDefault="hide_drawing_tools_by_default",C.LegendSeriesTitle="legend_series_title",C.LegendVolume="legend_volume",C.TimeframesToolbar="timeframes_toolbar",C.SaveDrawingToServer="save_drawing_to_server",C))(ae||{}),I=(g=>(g.Layout1A="1A",g.Layout2A="2A",g.Layout2B="2B",g.Layout3A="3A",g.Layout3B="3B",g.Layout3C="3C",g.Layout3D="3D",g.Layout3E="3E",g.Layout3F="3F",g.Layout4A="4A",g.Layout4B="4B",g.Layout4C="4C",g.Layout4D="4D",g.Layout4E="4E",g.Layout4F="4F",g.Layout5A="5A",g.Layout5B="5B",g.Layout5C="5C",g.Layout5D="5D",g.Layout6A="6A",g.Layout6B="6B",g.Layout6C="6C",g.Layout7A="7A",g.Layout8A="8A",g.Layout8B="8B",g.Layout8C="8C",g))(I||{}),qe=(r=>(r[r.None=0]="None",r[r.ResetData=1]="ResetData",r[r.ResetChart=2]="ResetChart",r))(qe||{});var pe=["header_widget","header_candle_style_menu","header_fullscreen_button","multi_charts","volume_force_overlay","legend_series_title","timeframes_toolbar","save_drawing_to_server"],T=["1s","30s","1m","1h","4h","1d"],w=["1s","15s","30s","1m","5m","15m","1h","4h","12h","1d"],ye=["1A","2A","2B","3A","3B","3C","3D","3E","3F","4A","4B","4C","4D","4E","4F","5A","5B","5C","5D","6A","6B","6C","7A","8A","8B","8C"],Je=["click","keydown","mousedown","mouseup","contextmenu"],S={decrease:"#f76816",increase:"#c7ff2e",chartBg:"#050807",card:"#0e1211"},Ge={card:"#242424"};var M=utils.atomFamily(a=>jotai.atom(true)),_=utils.atomFamily(a=>jotai.atom(false)),b=utils.atomFamily(a=>jotai.atom(0)),x=utils.atomFamily(a=>jotai.atom([...T])),y=utils.atomFamily(a=>jotai.atom([])),L=utils.atomFamily(a=>jotai.atom(false)),P=utils.atomFamily(a=>jotai.atom("1A")),A=utils.atomFamily(a=>jotai.atom("TradingView")),D=utils.atomFamily(a=>jotai.atom("dark")),ie=utils.atomFamily(a=>jotai.atom("en")),oe=utils.atomFamily(a=>jotai.atom("Etc/UTC")),se=utils.atomFamily(a=>jotai.atom("")),O=utils.atomFamily(a=>jotai.atom("kline")),ne=utils.atomFamily(a=>jotai.atom(false)),le=utils.atomFamily(a=>jotai.atom(null)),Ce=utils.atomFamily(a=>jotai.atom(null)),be=utils.atomFamily(a=>jotai.atom(null)),F=utils.atomFamily(a=>jotai.atom([])),V=utils.atomFamily(a=>jotai.atom([])),W=utils.atomFamily(a=>jotai.atom(false)),N=utils.atomFamily(a=>jotai.atom(e=>{let t=e(P(a)),r=e(A(a)),i=e(b(a)),o=e(x(a)),s=e(L(a)),n=e(y(a));return {layout:t,chartType:r,selectedIndex:i,pinnedResolutions:o,showDrawingToolbar:s,areaContents:n}}),lodashEs.isEqual);var k=class{settings;chartManager;chartIndex;store;prefix;pendingTickerSymbol=null;pendingResolution=null;constructor(e,t,r,i,o,s){this.settings=e,this.chartManager=t,this.chartIndex=r,this.store=i,this.prefix=o;let d={...{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false},...s};this.patchArea(d);}get state(){return this.store.get(y(this.prefix))[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false}}patchArea(e){let t=[...this.store.get(y(this.prefix))],r=t[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false};t[this.chartIndex]={...r,...e},this.store.set(y(this.prefix),t);}setState(e,t){t!=null&&this.patchArea({[e]:t});}get tickerSymbol(){return this.state.tickerSymbol}get symbol(){return this.state.symbol}get resolution(){return this.state.resolution}get chartStyle(){return this.state.chartStyle}get rightOffset(){return this.state.rightOffset}get barSpacing(){return this.state.barSpacing}get dataReady(){return this.state.dataReady}get internalChartWidget(){return this.chartManager.internalWidget?.chartByIndex(this.chartIndex)}setChartStyle(e){this.setState("chartStyle",e),this.internalChartWidget?.setChartStyle(e);}async setSymbol(e){if(this.state.tickerSymbol!==e){this.setState("tickerSymbol",e),this.setState("dataReady",false),this.pendingTickerSymbol=e;try{let t=[this.internalChartWidget?.handleSymbolChange(e,this.tickerSymbol),this.chartManager.symbolResolver?.resolveSymbolInfo(e).then(r=>{r&&this.setState("symbol",r.name);})];for(let r of await Promise.allSettled(t))if(r.status==="rejected")throw r.reason}catch(t){console.error(t);}finally{this.pendingTickerSymbol===e&&(this.pendingTickerSymbol=null);}this.tickerSymbol===e&&this.setState("dataReady",true);}}async setResolution(e){if(this.resolution!==e){this.setState("resolution",e),this.setState("dataReady",false),this.pendingResolution=e;try{await this.internalChartWidget?.handleResolutionChange(e,this.resolution);}finally{this.pendingResolution===e&&(this.pendingResolution=null);}}}toJSON(){return {...this.state}}widgetReady(){this.internalChartWidget?.dataReady()?.then(()=>this.handleChartReady())?.catch(()=>{});}get active(){return this.chartIndex<this.chartManager.chartCount}get selected(){return this.chartManager.selectedIndex===this.chartIndex}get symbolInfo(){return this.chartManager.symbolResolver?.getSymbolInfo(this.tickerSymbol)??null}destroy(){}async handleChartReady(){this.internalChartWidget&&(this.setState("dataReady",true),this.selected&&this.internalChartWidget.setBarSpacing(this.barSpacing));}};var H=class{prefix;settings;store;initialized=false;focused=false;reloadId=0;internalWidget=null;datafeed=null;symbolResolver=null;unsubAutoSave=null;constructor(e,t,r){this.prefix=e,this.store=t,this.settings=r;}get loading(){return this.store.get(M(this.prefix))}get fullscreen(){return this.store.get(_(this.prefix))}set fullscreen(e){this.store.set(_(this.prefix),e),e?document.body.classList.add("fullScreen"):document.body.classList.remove("fullScreen");}get selectedIndex(){return this.store.get(b(this.prefix))}set selectedIndex(e){this.store.set(b(this.prefix),e);}get pinnedResolutions(){return this.store.get(x(this.prefix))}set pinnedResolutions(e){this.store.set(x(this.prefix),e);}get showDrawingToolbar(){return this.store.get(L(this.prefix))}get chartCount(){return parseInt(this.settings.layout,10)||1}get areas(){let e=this.store.get(y(this.prefix));return this._areaManagers.slice(0,e.length)}_areaManagers=[];areaByIndex(e){return this.initialized&&this.updateChartContents(),this._areaManagers[e]??null}get activeArea(){return this.areaByIndex(this.selectedIndex)}async init(){if(this.initialized)return;let e=this.settings.saveLoadAdapter.getSettings();if(e?.selectedIndex!=null&&(this.selectedIndex=e.selectedIndex),e?.pinnedResolutions){let r=e.pinnedResolutions;r.length===T.length&&r.every(i=>T.includes(i))?this.pinnedResolutions=[...T]:this.pinnedResolutions=r;}if(e?.areaContents&&e.areaContents.forEach((r,i)=>{let o=new k(this.settings,this,i,this.store,this.prefix,r);this._areaManagers[i]=o;}),e?.showDrawingToolbar!=null&&this.store.set(L(this.prefix),e.showDrawingToolbar),this.settings.updateValue("layout",e?.layout),this.settings.updateValue("chartType",e?.chartType),this.settings.enableMultiCharts||this.settings.updateValue("layout","1A"),this.settings.enableHideDrawingToolsByDefault&&this.store.set(L(this.prefix),false),this.updateChartContents(),this.settings.tickerSymbol&&this.activeArea)try{await this.activeArea.setSymbol(this.settings.tickerSymbol);}catch(r){console.warn("ChartManager init failed to set symbol",r);}this.initialized=true;let t=lodashEs.debounce(()=>{let r=this.store.get(N(this.prefix));this.settings.saveLoadAdapter.saveSettings(r).catch(console.error);},1e3);this.unsubAutoSave=this.store.sub(N(this.prefix),t);}destroy(){this.unsubAutoSave?.(),this._areaManagers.forEach(e=>e.destroy()),this._areaManagers=[];}setLoading(e){this.store.set(M(this.prefix),e);}setLocale(e){this.settings.updateValue("locale",e);}setTimezone(e){this.settings.updateValue("timezone",e);}setFocused(e){this.focused=e;}setShowDrawingToolbar(e){this.store.set(L(this.prefix),e);}setInternalWidget(e){this.internalWidget=e,this.store.set(W(this.prefix),false);}onInternalWidgetReady(){this.store.set(W(this.prefix),true),this.areas.forEach((e,t)=>{t<this.chartCount&&e.widgetReady();});}setChartType(e){this.settings.updateValue("chartType",e);}setTheme(e){this.settings.theme!==e&&(this.settings.updateValue("theme",e),this.internalWidget?.onThemeChange?.(e,this.settings.reverseColor));}setColorPalette(e){this.settings.updateValue("backgroundColor",e.backgroundColor),this.settings.updateValue("increaseColor",e.increaseColor),this.settings.updateValue("decreaseColor",e.decreaseColor),this.internalWidget?.bridge.applyColorPaletteOverrides();}setReverseColor(e){this.settings.reverseColor!==e&&(this.settings.updateValue("reverseColor",e),this.internalWidget?.onThemeChange?.(this.settings.theme,e));}setLayout(e){let t=this.settings.enableMultiCharts?e:"1A";if(this.settings.layout!==t){this.settings.updateValue("layout",t),this.updateChartContents(),this.internalWidget?.onLayoutChange?.(t);let r=this.chartCount;setTimeout(()=>{if(this.store.get(W(this.prefix)))for(let i=r;i<this.chartCount;i++)this.areaByIndex(i)?.widgetReady();});}}reloadChart(){this.reloadId+=1;}updateChartContents(){if(this.chartCount>this._areaManagers.length)for(let e=this._areaManagers.length;e<this.chartCount;e++){let t=this._areaManagers[this.selectedIndex],r=t?.toJSON(),i=new k(this.settings,this,e,this.store,this.prefix,r);this._areaManagers[e]=i,this.selectedIndex!==e&&!t&&i.setSymbol(this.settings.tickerSymbol).catch(()=>{});}this.selectedIndex>=this.chartCount&&(this.selectedIndex=this.chartCount-1);}get settingsData(){return this.store.get(N(this.prefix))}getAllCharts(){return this.updateChartContents(),this._areaManagers.slice(0,this.chartCount)}};var U=class{storageId;constructor(e){this.storageId=e;}get settingsKey(){return `${this.storageId}.TvChart.Settings`}get shapesKey(){return `${this.storageId}.TvChart.Shapes`}getSettings(){let e=this.getLocalSettingsData(),t=this.getChartStoreData();return {layout:t?.layout,selectedIndex:t?.currentAreaIndex,chartType:t?.chartType,pinnedResolutions:t?.pinnedResolutions,areaContents:t?.areas?.map(i=>({resolution:i.resolution||i.period||"1m",chartStyle:i.chartStyle,symbol:i.symbol,tickerSymbol:i.tickerSymbol,rightOffset:i.rightOffset,barSpacing:i.barSpacing})),showDrawingToolbar:t?.drawing?.toolbarSwitch,drawing:e?.drawing?{...e.drawing,defaultStates:lodashEs.omit(e,["drawing","DrawingToolGroupLastUsedTool","riskRewardAvailableChanged","riskRewardRiskSizeChanged","drawingShapeTemplate"]),lastUsedTools:e.DrawingToolGroupLastUsedTool,riskRewardAvailableChanged:e.riskRewardAvailableChanged,riskRewardRiskSizeChanged:e.riskRewardRiskSizeChanged,drawingShapeTemplate:e.drawingShapeTemplate}:void 0}}getChartStoreData(){return this.getLocalData(this.storageId)}setChartStoreData(e){this.setLocalData(this.storageId,e);}async saveSettings(e){let t=this.getChartStoreData(),r={...t,layout:e.layout,currentAreaIndex:e.selectedIndex,chartType:e.chartType,pinnedResolutions:e.pinnedResolutions,areas:e.areaContents?.map((i,o)=>({...t?.areas?.[o],...i})),drawing:{...t?.drawing,toolbarSwitch:e.showDrawingToolbar}};this.setChartStoreData(r);}async getShapes(e){let t=this.getLocalShapesData();return !t||!t[e]?[]:Object.values(t[e])}async saveShapes(e,t){let r=this.getLocalShapesData()||{};r[e]={...r[e],...t},Object.keys(r[e]).forEach(i=>{r[e][i]||delete r[e][i];}),this.setLocalShapesData(r);}getLocalData(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}setLocalData(e,t){localStorage.setItem(e,JSON.stringify(t));}getLocalSettingsData(){return this.getLocalData(this.settingsKey)}getLocalShapesData(){return this.getLocalData(this.shapesKey)}setLocalShapesData(e){this.setLocalData(this.shapesKey,e);}};function de(a){let[e,t,r,i]=a.split("/");return {address:t,chain:e,quote:r,priceType:i}}function wt(a){return !a.quote||!a.priceType?`${a.chain}/${a.address}`:`${a.chain}/${a.address}/${a.quote}/${a.priceType}`}function he(a){return `${a.chain}/${a.address}`}var xt={dark:"Dark",light:"Light"};function B(a){return xt[a.toLowerCase()]??"Dark"}var Ke={"1s":"1S","5s":"5S","15s":"15S","30s":"30S","1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","12h":"720","1d":"1D"};function f(a="1m"){return Ke[a]??Ke["1m"]}var Lt={"1S":"1s","5S":"5s","15S":"15s","30S":"30s",1:"1m",5:"5m",15:"15m",30:"30m",60:"1h",240:"4h",720:"12h","1D":"1d"};function z(a){return Lt[a]??"1s"}var Rt={en:"en","zh-CN":"zh","zh-TW":"zh"};function It(a){return Rt[a]??a}var Ye={"1A":"s","2A":"2h","2B":"2v","3A":"3s","3B":"3h","3C":"3v","3D":"2-1","3E":"1-2","3F":"3r","4A":"4","4B":"4h","4C":"4v","4D":"4s","4E":"1-3","4F":"2-2","5A":"1-4","5B":"5s","5C":"2-3","5D":"5h","6A":"6","6B":"6c","6C":"6h","7A":"7h","8A":"8","8B":"8c","8C":"8h"};function $(a){return Ye[a]??"s"}var Mt=Object.fromEntries(Object.entries(Ye).map(([a,e])=>[e,a]));function fe(a){return Mt[a]??"1A"}var _t={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"4h":144e5,"12h":432e5,"1d":864e5};function ge(a){let e=_t[a];if(!e)throw new Error(`Invalid interval: ${a}`);return e}function ve(a,e){let t=a.toString().length>10?a:1e3*a;return Math.floor(t/e)*e}var q=class{prefix;store;supportedResolutions=w.map(f);supportedLayouts=ye;supportedChartTypes=["TradingView"];chartNames={};priceFormatterFactory=null;saveLoadAdapter;constructor(e,t){this.prefix=e,this.store=t,this.saveLoadAdapter=new U(e),this.store.set(O(e),e);}get layout(){return this.store.get(P(this.prefix))}get chartType(){return this.store.get(A(this.prefix))}get theme(){return this.store.get(D(this.prefix))}get reverseColor(){return this.store.get(ne(this.prefix))}get locale(){return this.store.get(ie(this.prefix))}get timezone(){return this.store.get(oe(this.prefix))}get tickerSymbol(){return this.store.get(se(this.prefix))}get storageId(){return this.store.get(O(this.prefix))}get backgroundColor(){return this.store.get(le(this.prefix))}get increaseColor(){return this.store.get(Ce(this.prefix))}get decreaseColor(){return this.store.get(be(this.prefix))}get enabledFeatures(){return this.store.get(F(this.prefix))}get disabledFeatures(){return this.store.get(V(this.prefix))}updateValue(e,t){if(t==null)return;let i={layout:()=>this.store.set(P(this.prefix),t),chartType:()=>this.store.set(A(this.prefix),t),theme:()=>this.store.set(D(this.prefix),t),reverseColor:()=>this.store.set(ne(this.prefix),t),locale:()=>this.store.set(ie(this.prefix),t),timezone:()=>this.store.set(oe(this.prefix),t),tickerSymbol:()=>this.store.set(se(this.prefix),t),storageId:()=>this.store.set(O(this.prefix),t),backgroundColor:()=>this.store.set(le(this.prefix),t),increaseColor:()=>this.store.set(Ce(this.prefix),t),decreaseColor:()=>this.store.set(be(this.prefix),t),enabledFeatures:()=>this.store.set(F(this.prefix),t),disabledFeatures:()=>this.store.set(V(this.prefix),t)}[e];i&&i();}isFeatureEnabled(e){return !this.disabledFeatures.includes(e)&&this.enabledFeatures.includes(e)||pe.includes(e)}setFeature(e,t){this.resetFeature(e),t?this.store.set(F(this.prefix),[...this.enabledFeatures,e]):this.store.set(V(this.prefix),[...this.disabledFeatures,e]);}resetFeature(e){this.store.set(F(this.prefix),this.enabledFeatures.filter(t=>t!==e)),this.store.set(V(this.prefix),this.disabledFeatures.filter(t=>t!==e));}get enableMultiCharts(){return this.isFeatureEnabled("multi_charts")}get enableCreateVolumeIndicatorByDefault(){return this.isFeatureEnabled("create_volume_indicator_by_default")}get enableHideDrawingToolsByDefault(){return this.isFeatureEnabled("hide_drawing_tools_by_default")}get enableLegendSeriesTitle(){return this.isFeatureEnabled("legend_series_title")}get enableLegendVolume(){return this.isFeatureEnabled("legend_volume")}get enableTimeframesToolbar(){return this.isFeatureEnabled("timeframes_toolbar")}get enableVolumeForceOverlay(){return this.isFeatureEnabled("volume_force_overlay")}sub(e,t){let i={layout:P(this.prefix),chartType:A(this.prefix),theme:D(this.prefix)}[e];return i?this.store.sub(i,t):()=>{}}};var J=class{datafeed;cache=new Map;pendingRequests=new Map;constructor(e){this.datafeed=e;}async resolveSymbolInfo(e){return this.datafeed.resolveSymbol(e)}async resolveSymbolInfos(e){return e.filter(r=>!this.cache.has(r)&&!this.pendingRequests.has(r)).forEach(r=>{let i=this.resolveSymbolInfo(r);i.then(o=>{o&&this.cache.set(r,o);}).catch(()=>{}).finally(()=>this.pendingRequests.delete(r)),this.pendingRequests.set(r,i);}),await Promise.all(e.filter(r=>this.pendingRequests.has(r)).map(r=>this.pendingRequests.get(r))),e.map(r=>this.cache.get(r)??null).filter(r=>r!==null)}getSymbolInfo(e){return this.resolveSymbolInfo(e).catch(t=>{console.error("ChartSymbolResolver.getSymbolInfo",t);}),this.cache.get(e)??null}};var Te=({initConfig:a,children:e})=>{let{chartManager:t,chartSettings:r}=h(),[i,o]=react.useState(false);return react.useEffect(()=>{t.initialized||(r.updateValue("tickerSymbol",a.tickerSymbol),r.updateValue("theme",a.theme),r.updateValue("reverseColor",a.reverseColor),r.updateValue("layout",a.layout),r.updateValue("chartType",a.chartType),r.updateValue("timezone",a.timezone),r.updateValue("locale",a.locale),r.updateValue("backgroundColor",a.backgroundColor),r.updateValue("increaseColor",a.increaseColor),r.updateValue("decreaseColor",a.decreaseColor),r.updateValue("storageId",a.storageId),r.updateValue("enabledFeatures",a.enabledFeatures),r.updateValue("disabledFeatures",a.disabledFeatures),a.chartNames&&(r.chartNames=a.chartNames),a.priceFormatterFactory&&(r.priceFormatterFactory=a.priceFormatterFactory),a.supportedResolutions&&(r.supportedResolutions=a.supportedResolutions),a.supportedLayouts&&(r.supportedLayouts=a.supportedLayouts),a.supportedChartTypes&&(r.supportedChartTypes=a.supportedChartTypes),t.datafeed=a.datafeed,t.symbolResolver=new J(a.datafeed));},[t,r,a]),react.useEffect(()=>{i&&(t.setTheme(a.theme),t.setColorPalette({backgroundColor:a.backgroundColor,increaseColor:a.increaseColor,decreaseColor:a.decreaseColor}));},[t,i,a.backgroundColor,a.decreaseColor,a.increaseColor,a.theme]),react.useEffect(()=>(t.init().then(()=>o(true)).catch(s=>{console.error("TradingViewConfig chartManager init error",s);}),()=>{t.destroy();}),[t]),i&&t.initialized?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):null};var Qe=react.createContext(null);function h(){let a=react.useContext(Qe);if(!a)throw new Error("useTvChartContext must be used within TradingViewProvider");return a}function Ot(){return h().chartManager}function Wt(){return h().prefix}var ce=class{setting;chartManager;constructor(e,t){this.setting=e,this.chartManager=t;}get internalWidget(){return this.chartManager.internalWidget}chartCount(){return this.chartManager.chartCount}setActiveChart(e){e<this.chartCount()&&(this.chartManager.selectedIndex=e);}layout(){return this.setting.layout}setLayout(e){this.chartManager.setLayout(e);}theme(){return this.setting.theme}setTheme(e){this.chartManager.setTheme(e);}setChartType(e){this.chartManager.setChartType(e);}getSetting(){return this.setting}getChartManager(){return this.chartManager}},we=react.forwardRef(({children:a,initConfig:e,widgetConstructor:t,libraryPath:r,customCssUrl:i},o)=>{let s=jotai.useStore(),n=e.storageId,d=react.useMemo(()=>new q(n,s),[n,s]),u=react.useMemo(()=>new H(n,s,d),[n,s,d]),c=react.useMemo(()=>new ce(d,u),[d,u]);react.useImperativeHandle(o,()=>c,[c]);let v=react.useMemo(()=>({prefix:n,chartSettings:d,chartManager:u,widgetConstructor:t,libraryPath:r,customCssUrl:i}),[n,d,u,t,r,i]);return jsxRuntime.jsx(Qe.Provider,{value:v,children:jsxRuntime.jsx(Te,{initConfig:e,children:a})})});var xe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(_(e)),i=react.useCallback(()=>{t.fullscreen=!t.fullscreen;},[t]);return jsxRuntime.jsx("button",{type:"button",onClick:i,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a(r?"tradingView.exitFullscreen":"tradingView.fullscreen"),children:a(r?"tradingView.exit":"tradingView.fullscreen")})});var je=react.createContext(null);function G(){let a=react.useContext(je);if(!a)throw new Error("useTvChartToolbarContext must be used within TradingViewToolbarProvider");return a}var Re=({children:a})=>{let{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(b(e)),i=jotai.useAtomValue(y(e)),o=react.useMemo(()=>i.length?t.areaByIndex(r):null,[t,r,i]),s=react.useMemo(()=>o?.symbolInfo??null,[o]),n=react.useMemo(()=>({activeAreaManager:o,symbolInfo:s}),[o,s]);return jsxRuntime.jsx(je.Provider,{value:n,children:a})};var tt={0:"tradingView.style.bars",1:"tradingView.style.candles",2:"tradingView.style.line",3:"tradingView.style.area",8:"tradingView.style.heikenAshi",9:"tradingView.style.hollowCandles",10:"tradingView.style.baseline"},Qt=[1,0,2,3,9,8,10],Ie=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e}=h(),{activeAreaManager:t}=G(),r=jotai.useAtomValue(y(e)),i=jotai.useAtomValue(b(e)),o=r[i]?.chartStyle??1,s=react.useCallback(n=>{let d=parseInt(n.target.value,10);t?.setChartStyle(d);},[t]);return jsxRuntime.jsx("select",{value:o,onChange:s,className:"text-xs bg-transparent text-muted-foreground hover:text-foreground cursor-pointer border-none outline-none px-1 py-0.5",title:a("tradingView.klineStyle"),children:Qt.map(n=>jsxRuntime.jsx("option",{value:n,children:tt[n]?a(tt[n]):n},n))})});var Me=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openIndicatorSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.indicators"),children:a("tradingView.indicators")})});var _e=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.chartSettings"),children:a("tradingView.settings")})});var Ae=react.memo(()=>{let{prefix:a}=h(),{activeAreaManager:e}=G(),t=jotai.useAtomValue(x(a)),r=jotai.useAtomValue(y(a)),i=jotai.useAtomValue(b(a)),o=r[i]?.resolution,s=react.useCallback(n=>{e?.setResolution(n);},[e]);return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",children:t.map(n=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(n),className:`px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${o===n?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:n},n))})});var Fe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(async()=>{try{let r=await e.internalWidget?.takeClientScreenshot();if(!r)return;let i=document.createElement("a");i.download=`chart-${Date.now()}.png`,i.href=r.toDataURL("image/png"),i.click();}catch(r){console.error("TradingViewSnapshot",r);}},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.takeSnapshot"),children:a("tradingView.snapshot")})});var ke=react.memo(({children:a,prefix:e,suffix:t,showResolutions:r=true,showKlineStyleSelect:i=true,showOpenIndicator:o=true,showOpenSettings:s=true,showFullscreen:n=true,showSnapshot:d=true})=>jsxRuntime.jsx(Re,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border min-h-[36px] flex-shrink-0",children:[e,a??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r&&jsxRuntime.jsx(Ae,{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[i&&jsxRuntime.jsx(Ie,{}),o&&jsxRuntime.jsx(Me,{}),s&&jsxRuntime.jsx(_e,{}),d&&jsxRuntime.jsx(Fe,{}),n&&jsxRuntime.jsx(xe,{})]})]}),t]})}));var K=class{settings;chartManager;bridge;chartIndex;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.bridge=r,this.chartIndex=i;}get chartAreaManager(){return this.chartManager.areaByIndex(this.chartIndex)}get widget(){return this.bridge.getWidget()}get chartWidget(){return this.widget?.chart(this.chartIndex)??null}setChartStyle(e){this.chartWidget?.setChartType(e);}getChartStyle(){return this.chartWidget?.chartType()??1}handleSymbolChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{r.chart(this.chartIndex).setSymbol(e,{dataReady:()=>i(),doNotActivateChart:false});})}handleResolutionChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{let o=r.chart(this.chartIndex);o.dataReady(()=>{o.setResolution(f(e),{dataReady:i,doNotActivateChart:true}).catch(()=>{});});})}setPrecision(e){this.widget?.applyOverrides({"mainSeriesProperties.minTick":e===null?"default":`${Math.pow(10,e)},1,false`});}async dataReady(){if(await this.bridge.onReady(),!this.chartWidget)throw Error("ChartWidget: chartWidget is null");return new Promise(e=>{this.chartWidget?.dataReady(()=>setTimeout(e));})}timeScaleWidth(){return this.chartWidget?.getTimeScale()?.width()??NaN}rightOffset(){return this.chartWidget?.getTimeScale()?.rightOffset()??NaN}setRightOffset(e){this.chartWidget?.getTimeScale()?.setRightOffset(e);}barSpacing(){return this.chartWidget?.getTimeScale()?.barSpacing()??NaN}setBarSpacing(e){this.chartWidget?.getTimeScale()?.setBarSpacing(e);}};var Y=class{settings;chartManager;bridge;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}get widget(){return this.bridge.getWidget()}chartByIndex(e){return new K(this.settings,this.chartManager,this.bridge,e)}activeChart(){let e=this.widget?.activeChartIndex();return e===void 0?void 0:this.chartByIndex(e)}openIndicatorSettingsDialog(){this.widget?.activeChart().executeActionById("insertIndicator");}openSettingsDialog(){this.widget?.activeChart().executeActionById("chartProperties");}takeClientScreenshot(){return this.widget?.takeClientScreenshot()}onLayoutChange(e){this.widget?.setLayout($(e));}async onThemeChange(e,t){let r=B(e);await this.widget?.changeTheme(r,{disableUndo:true}),this.bridge.applyColorPaletteOverrides();}};var X=class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.listeners.get(e)?.delete(t);}}emit(e,t){this.listeners.get(e)?.forEach(r=>r(t));}off(e,t){this.listeners.get(e)?.delete(t);}clear(){this.listeners.clear();}};var Q=class{settings;chartManager;bridge;abortController=new AbortController;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}toJSON(){return null}async onReady(e){setTimeout(()=>{e({supported_resolutions:w.map(f),supports_marks:true,exchanges:[]});}),await this.chartManager.datafeed?.onReady({setting:this.settings,chartManager:this.chartManager,instance:this.bridge});}destroy(){this.abortController.abort();}async resolveSymbol(e,t,r,i){try{let o=await this.chartManager.datafeed?.resolveSymbol(e,i);o&&t(o);}catch(o){console.error("ChartDataFeed.resolveSymbol",o),r(o);}}async getBars(e,t,r,i,o){try{let s=await this.chartManager.datafeed?.getBars(e,t,r);s&&i(s,{noData:s.length===0});}catch(s){console.error("ChartDataFeed.getBars",s),o(s);}}subscribeBars(e,t,r,i,o){this.chartManager.datafeed?.subscribeBars(e,t,r,i,o);}unsubscribeBars(e){this.chartManager.datafeed?.unsubscribeBars(e);}async getMarks(e,t,r,i,o){this.chartManager.datafeed?.getMarks?.(e,t,r,i,o);}getQuotes(e,t,r){t(e.map(i=>({s:"ok",n:i,v:{}})));}subscribeQuotes(e,t,r,i){}unsubscribeQuotes(e){}};var Z=class{settings;chartManager;bridge;data;drawings;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r,this.data=null,this.drawings=null,this.loadDataFromLocalStorage();}get layoutId(){return this.settings.storageId}get shouldResetColorPalette(){let e=this.data?.theme,t=this.data?.reverseColor;return e!==this.settings.theme||t!==this.settings.reverseColor}toJSON(){return null}getAllCharts(){return new Promise(e=>{let t=[];this.data&&t.push({id:this.data.id,name:this.data.name,symbol:this.data.symbol,resolution:this.data.resolution,timestamp:this.data.timestamp}),e(t);})}removeChart(e){throw Error("Method not implemented.")}async saveChart(e){return this.data={...e,theme:this.settings.theme,reverseColor:this.settings.reverseColor,id:this.layoutId,timestamp:0},this.saveDataToLocalStorage(),this.data.id}getChartContent(e){return new Promise(t=>{let r=JSON.parse(this.data.content),i=JSON.parse(r.charts_symbols),o=JSON.parse(r.content);t(JSON.stringify({...r,chart_symbols:JSON.stringify(i),content:JSON.stringify(o)}));})}async saveLineToolsAndGroups(e,t,r){this.drawings=this.drawings||{data:{},timestamp:0},this.drawings.data=this.drawings.data||{},this.drawings.data[t]=this.drawings.data[t]||{};try{if(!r.sources)return;for(let[i,o]of r.sources)if(!o||!o.symbol||!o.state||Object.keys(o.state).length===0||i.includes("/"))o===null&&delete this.drawings.data[t][i];else {let{address:s,chain:n}=de(o.symbol),d=he({address:s,chain:n}),u={...o,symbol:d,id:o.id.indexOf("/")>0?o.id.split("/")[0]:o.id};this.drawings.data[t][i]=u;}this.saveDataToLocalStorage();}catch(i){console.error("saveLineToolsAndGroups",i);}}async loadLineToolsAndGroups(e,t,r,i){if(!i?.symbol||!this.drawings?.data?.[t])return null;let o=i.symbol,{address:s,chain:n}=de(o),d=he({address:s,chain:n}),u=lodashEs.uniqBy(Object.values(lodashEs.cloneDeep(this.drawings.data[t])).filter(c=>c.symbol===d),"id");try{return {sources:new Map(u.map(c=>{let v=lodashEs.cloneDeep({...c,symbol:o});return [v.id,v]}))}}catch(c){return console.error("ChartSaveLoadAdapter.loadLineToolsAndGroups",c),null}}getLayoutKey(e){return `charts.tradingview.data.${e}`}getDrawingKey(e){return `charts.tradingview.drawing.${e}`}loadDataFromLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=localStorage.getItem(e),i=localStorage.getItem(t);if(r)try{let o=JSON.parse(r),s=JSON.parse(o.content);o.content=JSON.stringify(s),this.data=o;}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse layout error",o);}if(i)try{this.drawings=JSON.parse(i);}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse drawing error",o);}}saveDataToLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=Math.round(Date.now()/1e3);this.data&&(this.data.timestamp=r,localStorage.setItem(e,JSON.stringify(this.data))),this.drawings&&(this.drawings.timestamp=r,localStorage.setItem(t,JSON.stringify(this.drawings)));}};var Be="trading.chart.proterty",j=class{storagePrefix;initialSettings;constructor(e,t,r){this.storagePrefix=`tradingview.${e.storageId}.`,this.initialSettings={};for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);if(s&&s.startsWith(this.storagePrefix)){let n=s.slice(this.storagePrefix.length);this.initialSettings[n]=localStorage.getItem(s);}}let i={noConfirmEnabled:1};if(this.initialSettings[Be])try{let o=JSON.parse(this.initialSettings[Be]);Object.assign(i,o),Object.assign(i,{noConfirmEnabled:!0});}catch(o){console.error("ChartSettingsAdapter: failed to parse chart settings",o);}this.initialSettings[Be]=JSON.stringify(i);}toJSON(){return null}removeValue(e){delete this.initialSettings[e],localStorage.removeItem(`${this.storagePrefix}${e}`);}setValue(e,t){this.initialSettings[e]=t,localStorage.setItem(`${this.storagePrefix}${e}`,t);}};var ee=class{settings;chartManager;WidgetCtor;moduleInstances=new Map;symbolIntervalSubs=new Map;abortController=new AbortController;widgetReadyPromise=null;readyPromise=null;widget=null;container=null;ready=false;layoutReady=true;events=new X;libraryPath;customCssUrl;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.WidgetCtor=r,this.libraryPath=i?.libraryPath??"/static/charting_library/",this.customCssUrl=i?.customCssUrl??"custom-styles.css",this.initModules();}getWidget(){return this.widget}async init(e){if(this.widgetReadyPromise)throw new Error("ChartWidgetBridge already initialized.");let t=this.getWidgetOptions();this.container=e,this.widget=new this.WidgetCtor({...t,container:e});let r=new Promise(i=>{this.widget?.onChartReady(()=>i());});this.widgetReadyPromise=r,this.readyPromise=r.then(()=>(this.ready=true,this.handleChartReady())).catch(i=>{console.warn("ChartWidgetBridge widget ready failed",i);}),this.moduleInstances.forEach((i,o)=>{try{i.init?.call(i);}catch(s){console.warn(`ChartWidgetBridge init module ${o}`,s);}}),await Promise.race([this.readyPromise,new Promise((i,o)=>setTimeout(o,6e4,new Error("ChartWidgetBridge init timeout")))]);}async destroy(){this.moduleInstances.forEach(e=>e.destroy?.call(e)),this.symbolIntervalSubs.forEach(e=>e()),this.symbolIntervalSubs.clear(),this.events.clear(),this.abortController.abort(),this.ready=false,this.widgetReadyPromise=null,this.readyPromise=null,this.widget?.remove(),this.widget=null;}async onReady(){return new Promise((e,t)=>{this.widget?this.widget.onChartReady(()=>this.readyPromise?.then(e).catch(t)):t(Error("cannot call `onReady` before `init`"));})}async asyncWidgetMethodContext(e){return new Promise((t,r)=>{if(!this.widgetReadyPromise){r(new Error("ChartWidgetBridge: widget not ready"));return}let i=this.widgetReadyPromise.then(()=>this.waitForLayout()),o=this.abortController.signal,s=()=>r(o.reason);o.addEventListener("abort",s),i.then(()=>e(this.widget,t)).catch(r).finally(()=>o.removeEventListener("abort",s));})}getModule(e){return this.moduleInstances.get(e)}applyColorPaletteOverrides(){this.widget?.applyOverrides(this.getColorPaletteOverrides()),this.widget?.applyStudiesOverrides(this.getColorPaletteStudiesOverrides());}getWidgetOptions(){let e=["header_widget","legend_inplace_edit","display_market_status","save_shortcut","show_interval_dialog_on_key_press","symbol_info","symbol_search_hot_key","uppercase_instrument_names","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","drawing_templates",...this.settings.disabledFeatures],t=["determine_first_data_request_size_using_visible_range","request_only_visible_range_on_reset","show_exchange_logos","show_symbol_logos","dont_show_boolean_study_arguments","hide_last_na_study_output","hide_right_toolbar","seconds_resolution","saveload_separate_drawings_storage","volume_force_overlay","create_volume_indicator_by_default","two_character_bar_marks_labels",...this.settings.enabledFeatures];return this.settings.enableHideDrawingToolsByDefault&&t.push("hide_left_toolbar_by_default"),this.settings.enableTimeframesToolbar||e.push("timeframes_toolbar"),this.settings.enableCreateVolumeIndicatorByDefault||e.push("create_volume_indicator_by_default"),this.settings.enableVolumeForceOverlay||e.push("volume_force_overlay"),{container:"",autosize:true,debug:false,load_last_chart:true,auto_save_delay:1,timezone:this.localTimezone,library_path:this.libraryPath,custom_css_url:this.customCssUrl,theme:B(this.settings.theme),custom_font_family:window.getComputedStyle(document.body).fontFamily,symbol:this.chartManager.activeArea?.tickerSymbol,interval:f(this.chartManager.activeArea?.resolution),locale:this.settings.locale,datafeed:this.getModule("datafeed"),save_load_adapter:this.getModule("saveLoadAdapter"),settings_adapter:this.getModule("settingsAdapter"),custom_formatters:{priceFormatterFactory:this.settings.priceFormatterFactory?(r,i)=>this.settings.priceFormatterFactory(r,i):()=>null},overrides:{...this.getSettingsOverrides(),...this.getColorPaletteOverrides()},studies_overrides:this.getColorPaletteStudiesOverrides(),disabled_features:[...new Set(e)],enabled_features:[...new Set(t)].filter(r=>!e.includes(r)),supported_resolutions:w.map(f)}}async handleChartReady(){let e=$(this.settings.layout);e!==this.widget?.layout()&&await this.waitForLayout(e),this.widget?.setActiveChart(this.chartManager.selectedIndex),this.getModule("saveLoadAdapter")?.shouldResetColorPalette&&await this.widget?.changeTheme(B(this.settings.theme),{disableUndo:true}),this.applyColorPaletteOverrides(),this.widget?.subscribe("onAutoSaveNeeded",this.onAutoSaveNeeded.bind(this)),this.widget?.subscribe("activeChartChanged",this.activeChartChanged.bind(this)),this.widget?.subscribe("layout_about_to_be_changed",this.layoutWillChange.bind(this)),this.widget?.subscribe("layout_changed",this.layoutChanged.bind(this)),this.syncChartsChanges(),this.subscribeChartsChanges(),this.installEventHooks(),this.resetTimezone();}onAutoSaveNeeded(){try{this.widget?.saveChartToServer(void 0,void 0,{defaultChartName:"DEFAULT"});}catch(e){console.warn("ChartWidgetBridge.onAutoSaveNeeded",e);}}activeChartChanged(e){this.chartManager.selectedIndex=e,this.chartManager.settings.saveLoadAdapter.saveSettings(this.chartManager.settingsData).catch(console.error);}layoutWillChange(e){this.layoutReady=false,this.chartManager.setLayout(fe(e));}layoutChanged(){this.layoutReady=true,this.syncChartsChanges(),this.subscribeChartsChanges(),this.widget?.unloadUnusedCharts(),this.widget?.saveChartToServer();}syncChartsChanges(){this.widget?.symbolSync()?.setValue(false),this.widget?.intervalSync()?.setValue(false);let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++){let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.setSymbol(r?.tickerSymbol??"",{doNotActivateChart:true}),i.setResolution(f(r?.resolution),{doNotActivateChart:true});}}subscribeChartsChanges(){let e=this.widget?.chartsCount()??0;this.symbolIntervalSubs.forEach((t,r)=>{parseInt(r)>=e&&(t(),this.symbolIntervalSubs.delete(r));});for(let t=0;t<e;t++){if(this.symbolIntervalSubs.has(`${t}`))continue;let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.getPanes().forEach(u=>u.getMainSourcePriceScale()?.setAutoScale(true));let o=i.onSymbolChanged(),s=i.onIntervalChanged(),n=()=>{this.events.emit("symbolChanged",[t,i.symbol()]),r?.setSymbol(i.symbol()).catch(()=>{}),this.onAutoSaveNeeded();},d=u=>{let c=z(u);this.events.emit("resolutionChanged",[t,c]),r?.setResolution(c).catch(()=>{});};o.subscribe(r,n),s.subscribe(r,d),this.symbolIntervalSubs.set(`${t}`,()=>{o.unsubscribe(r,n),s.unsubscribe(r,d);});}}installEventHooks(){let e=this.container?.lastElementChild,t=e?.contentWindow?.document;if(t&&(t.addEventListener("click",()=>e?.click()),t.defaultView?.MutationObserver)){let r=new WeakSet,i=t.querySelector(".layout__area--center");if(i){let o=()=>{i.querySelectorAll(".chart-container").forEach((s,n)=>{r.has(s)||(r.add(s),Je.forEach(d=>{s.addEventListener(d,u=>this.events.emit("domEvent",[n,d,u]),{passive:true});}));});};new t.defaultView.MutationObserver(o).observe(i,{childList:true}),o();}}}resetTimezone(){try{let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++)this.widget?.chart(t)?.getTimezoneApi()?.setTimezone(this.localTimezone);}catch(e){console.error("ChartWidgetBridge: Reset timezone",e);}}get localTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}async waitForLayout(e){if(!this.widget||this.layoutReady&&!e)return;let t;return new Promise(i=>{t=i,this.widget.subscribe("layout_changed",i),e&&this.widget.setLayout(e);}).finally(()=>{this.widget.unsubscribe("layout_changed",t);})}getSettingsOverrides(){return {"mainSeriesProperties.minTick":"default","paneProperties.legendProperties.showSeriesTitle":this.settings.enableLegendSeriesTitle}}getColorPaletteOverrides(){let e=this.resolveThemeColor(this.settings.backgroundColor,S.chartBg),t=this.resolveThemeColor(this.settings.increaseColor,S.increase),r=this.resolveThemeColor(this.settings.decreaseColor,S.decrease),i=this.settings.theme==="dark"?S.card:Ge.card;return {"paneProperties.background":e,"paneProperties.backgroundType":"solid",volumePaneSize:"medium","mainSeriesProperties.candleStyle.upColor":t,"mainSeriesProperties.barStyle.upColor":t,"mainSeriesProperties.columnStyle.upColor":t,"mainSeriesProperties.candleStyle.downColor":r,"mainSeriesProperties.barStyle.downColor":r,"mainSeriesProperties.columnStyle.downColor":r,"mainSeriesProperties.candleStyle.borderUpColor":t,"mainSeriesProperties.candleStyle.borderDownColor":r,"mainSeriesProperties.candleStyle.wickUpColor":t,"mainSeriesProperties.candleStyle.wickDownColor":r,"mainSeriesProperties.hollowCandleStyle.upColor":t,"mainSeriesProperties.hollowCandleStyle.downColor":r,"mainSeriesProperties.hollowCandleStyle.borderUpColor":t,"mainSeriesProperties.hollowCandleStyle.borderDownColor":r,"mainSeriesProperties.hollowCandleStyle.wickUpColor":t,"mainSeriesProperties.hollowCandleStyle.wickDownColor":r,"mainSeriesProperties.haStyle.upColor":t,"mainSeriesProperties.haStyle.downColor":r,"mainSeriesProperties.haStyle.borderUpColor":t,"mainSeriesProperties.haStyle.borderDownColor":r,"mainSeriesProperties.haStyle.wickUpColor":t,"mainSeriesProperties.haStyle.wickDownColor":r,"mainSeriesProperties.lineStyle.color":t,"mainSeriesProperties.areaStyle.color1":t,"mainSeriesProperties.areaStyle.color2":e,"mainSeriesProperties.areaStyle.linecolor":t,"mainSeriesProperties.areaStyle.transparency":65,"mainSeriesProperties.baselineStyle.topFillColor1":t,"mainSeriesProperties.baselineStyle.topFillColor2":e,"mainSeriesProperties.baselineStyle.bottomFillColor1":r,"mainSeriesProperties.baselineStyle.bottomFillColor2":e,"mainSeriesProperties.baselineStyle.topLineColor":t,"mainSeriesProperties.baselineStyle.bottomLineColor":r,"mainSeriesProperties.baselineStyle.transparency":65,"linetoolorder.bodyBackgroundColor":i,"linetoolorder.bodyBackgroundTransparency":0}}getColorPaletteStudiesOverrides(){let e=this.resolveThemeColor(this.settings.increaseColor,S.increase);return {"volume.volume.color.0":this.resolveThemeColor(this.settings.decreaseColor,S.decrease),"volume.volume.color.1":e,"volume.volume.transparency":80}}resolveThemeColor(e,t){if(!e||!e.includes("var("))return e??t;if(typeof document>"u"||!document.body)return t;let r=document.createElement("span");r.style.color=e,r.style.display="none",document.body.appendChild(r);let i=window.getComputedStyle(r).color;return r.remove(),i||t}initModules(){Object.entries({datafeed:Q,saveLoadAdapter:Z,settingsAdapter:j}).forEach(([t,r])=>{this.moduleInstances.set(t,new r(this.settings,this.chartManager,this));});}};var Ee=react.memo(()=>null);var Oe=react.forwardRef(({onReady:a},e)=>{let{chartManager:t,chartSettings:r,widgetConstructor:i,libraryPath:o,customCssUrl:s}=h(),n=react.useRef(a),[d,u]=react.useState(),[c,v]=react.useState(null),[C,He]=react.useState(false);return react.useEffect(()=>{C&&n.current&&setTimeout(n.current);},[C]),react.useImperativeHandle(e,()=>d,[d]),react.useEffect(()=>{if(!c)return;let me=new ee(r,t,i,{libraryPath:o,customCssUrl:s}),bt=new Y(r,t,me);return u(bt),me.init(c).then(()=>He(true)).catch(ft=>{console.error("TradingViewWidgetContainer: failed to init bridge",ft);}),()=>{me.destroy().then(()=>{u(void 0),He(false);}).catch(()=>{console.error("TradingViewWidgetContainer: failed to destroy bridge");});}},[c,r,t,i,o,s]),jsxRuntime.jsxs("div",{className:"w-full h-full",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("div",{id:"tv_chart_container",className:"w-full h-full",ref:v})]})});var We=react.memo(({onReady:a})=>{let{chartManager:e,chartSettings:t}=h(),r=react.useMemo(()=>`${t.timezone}_${e.reloadId}`,[t.timezone,e.reloadId]);react.useLayoutEffect(()=>{e.setLoading(true);},[e,t.chartType,r]);let i=react.useCallback(()=>{a?.(),e.onInternalWidgetReady(),e.setLoading(false);},[e,a]);return jsxRuntime.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:jsxRuntime.jsx(Oe,{onReady:i,ref:o=>e.setInternalWidget(o??null)})})});var Ir=react.memo(({toolbar:a,loadingOverlay:e,onReady:t,children:r})=>{let{prefix:i}=h(),o=jotai.useAtomValue(M(i));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a!==false&&jsxRuntime.jsx(ke,{...a||{}}),jsxRuntime.jsxs("div",{className:"relative flex-1 w-full overflow-hidden",children:[o&&e&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80",children:e}),jsxRuntime.jsx(We,{onReady:t})]}),r]})}),Mr=react.forwardRef(({initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,toolbar:i,loadingOverlay:o,onReady:s,children:n,className:d},u)=>jsxRuntime.jsx("div",{className:`flex flex-col w-full h-full ${d??""}`,children:jsxRuntime.jsx(we,{ref:u,initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,children:jsxRuntime.jsx(Ir,{toolbar:i,loadingOverlay:o,onReady:s,children:n})})}));var Ar=react.memo(({index:a})=>{let{prefix:e}=h(),t=jotai.useAtomValue(y(e)),r=jotai.useAtomValue(b(e)),o=t[a??r];return o?jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:o.tickerSymbol||o.symbol}),jsxRuntime.jsx("span",{children:o.resolution})]}):null});function Vr(){return h().chartManager}function Br(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),r=jotai.useAtomValue(y(a));return react.useMemo(()=>r.length?e.areaByIndex(t):null,[e,t,r])}function Dr(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),i=jotai.useAtomValue(y(a))[t];return react.useMemo(()=>i?.tickerSymbol?e.symbolResolver?.getSymbolInfo(i.tickerSymbol)??null:null,[e,i?.tickerSymbol])}var yt=768;function Ct(a,e=yt){return a>0&&a<e}function ct(a){try{return ge(a)}catch{return ge(z(a))}}function Or(a){return a instanceof Date?a.getTime():a}function mt(a,e){let t={time:ve(Or(a.time),e),open:a.open,high:a.high,low:a.low,close:a.close};return a.volume!==void 0&&(t.volume=a.volume),t}function pt(a,e){return `${a.ticker??a.name}:${e}`}var Ne=class{source;options;liveListeners=new Map;lastHistoryBarTime=new Map;liveGeneration=0;constructor(e,t={}){this.source=e,this.options=t;}isMobileViewport(e){return Ct(e,this.options.mobileBreakpointPx)}async onReady(e){await this.options.onReady?.(e);}onDestroy(){for(let e of [...this.liveListeners.keys()])this.unsubscribeLiveBars(e);this.lastHistoryBarTime.clear(),this.options.onDestroy?.();}async resolveSymbol(e,t){return await this.options.resolveSymbol?.(e,t)??null}async getBars(e,t,r){return this.getHistoryBars(e,t,r)}subscribeBars(e,t,r,i,o){this.subscribeLiveBars(e,t,r,i,o);}unsubscribeBars(e){this.unsubscribeLiveBars(e);}getMarks(e,t,r,i,o){this.options.getMarks?.(e,t,r,i,o);}getFirstBarTime(e,t,r){return this.options.getFirstBarTime?.(e,t,r)??Promise.resolve()}async getHistoryBars(e,t,r){let i=await this.source.getHistory({symbolInfo:e,resolution:t,periodParams:r}),o=ct(t),s=(i??[]).map(n=>mt(n,o));if(s.length>0){let n=pt(e,t),d=Math.max(...s.map(c=>c.time)),u=this.lastHistoryBarTime.get(n)??0;d>u&&this.lastHistoryBarTime.set(n,d);}return s}subscribeLiveBars(e,t,r,i,o){this.unsubscribeLiveBars(i);let s=pt(e,t),n=ct(t),d=++this.liveGeneration;this.liveListeners.set(i,{symbolKey:s,lastBarTime:this.lastHistoryBarTime.get(s)??0,generation:d}),this.source.subscribe({symbolInfo:e,resolution:t,listenerGuid:i,onResetCacheNeededCallback:o},u=>{let c=this.liveListeners.get(i);if(!c||c.generation!==d)return;let v=mt(u,n),C=Math.max(c.lastBarTime,this.lastHistoryBarTime.get(c.symbolKey)??0);v.time<C||(c.lastBarTime=v.time,r(v));});}unsubscribeLiveBars(e){this.liveListeners.has(e)&&(this.liveListeners.delete(e),this.source.unsubscribe(e));}};exports.ALL_TV_CHART_RESOLUTIONS=w;exports.ChartAreaManager=k;exports.ChartDataFeed=Q;exports.ChartLibraryWidget=Y;exports.ChartManager=H;exports.ChartSaveLoadAdapter=Z;exports.ChartSettings=q;exports.ChartSettingsAdapter=j;exports.ChartSettingsStore=U;exports.ChartSymbolResolver=J;exports.ChartWidget=K;exports.ChartWidgetBridge=ee;exports.DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX=yt;exports.DEFAULT_TV_CHART_RESOLUTIONS=T;exports.ENABLED_TV_CHART_FEATURES=pe;exports.EventEmitter=X;exports.SUPPORTED_TV_CHART_LAYOUTS=ye;exports.TV_CHART_THEME_COLORS=S;exports.TradingView=Mr;exports.TradingViewAreaTitle=Ar;exports.TradingViewConfig=Te;exports.TradingViewDatafeedAdapter=Ne;exports.TradingViewFullscreen=xe;exports.TradingViewKlineStyleSelect=Ie;exports.TradingViewLayout=Ee;exports.TradingViewOpenIndicator=Me;exports.TradingViewOpenSettings=_e;exports.TradingViewProvider=we;exports.TradingViewResolutions=Ae;exports.TradingViewSnapshot=Fe;exports.TradingViewToolbar=ke;exports.TradingViewToolbarProvider=Re;exports.TradingViewWidgetContainer=Oe;exports.TradingViewWidgetProvider=We;exports.TvChartErrorResetType=qe;exports.TvChartFeature=ae;exports.TvChartHandle=ce;exports.TvChartKlineStyle=re;exports.TvChartLayout=I;exports.TvChartPriceType=Ue;exports.TvChartQuoteType=ze;exports.TvChartTheme=$e;exports.TvChartType=te;exports.chartAreasFamily=y;exports.chartFullscreenFamily=_;exports.chartLoadingFamily=M;exports.chartPinnedResolutionsFamily=x;exports.chartSelectedIndexFamily=b;exports.chartShowDrawingToolbarFamily=L;exports.getTvChartLayoutReverse=fe;exports.getTvChartLibraryLayout=$;exports.getTvChartLibraryLocale=It;exports.getTvChartLibraryResolution=f;exports.getTvChartLibraryTheme=B;exports.getTvChartResolutionFrame=ge;exports.getTvChartResolutionReverse=z;exports.getTvChartTickTimestamp=ve;exports.isTvChartMobileViewport=Ct;exports.parseSymbol=de;exports.settingsBackgroundColorFamily=le;exports.settingsChartTypeFamily=A;exports.settingsDataFamily=N;exports.settingsDisabledFeaturesFamily=V;exports.settingsEnabledFeaturesFamily=F;exports.settingsLayoutFamily=P;exports.settingsLocaleFamily=ie;exports.settingsReverseColorFamily=ne;exports.settingsStorageIdFamily=O;exports.settingsThemeFamily=D;exports.settingsTickerSymbolFamily=se;exports.settingsTimezoneFamily=oe;exports.stringifySymbol=wt;exports.stringifySymbolShort=he;exports.useActiveAreaManager=Br;exports.useChartManager=Vr;exports.useSymbolInfo=Dr;exports.useTvChartContext=h;exports.useTvChartManager=Ot;exports.useTvChartPrefix=Wt;exports.useTvChartToolbarContext=G;exports.widgetReadyFamily=W;//# sourceMappingURL=index.js.map
1
+ 'use strict';var react=require('react'),jotai=require('jotai'),utils=require('jotai/utils'),lodashEs=require('lodash-es'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@liberfi.io/i18n');var te=(t=>(t.TradingView="TradingView",t.Original="Original",t))(te||{}),Ue=(t=>(t.Price="price",t.MarketCap="market_cap",t))(Ue||{}),ze=(o=>(o.USD="USD",o.SOL="SOL",o.ETH="ETH",o.TRX="TRX",o.BNB="BNB",o))(ze||{}),re=(d=>(d[d.Bars=0]="Bars",d[d.Candles=1]="Candles",d[d.Line=2]="Line",d[d.Area=3]="Area",d[d.HeikenAshi=8]="HeikenAshi",d[d.HollowCandles=9]="HollowCandles",d[d.Baseline=10]="Baseline",d[d.HiLo=12]="HiLo",d[d.Column=13]="Column",d[d.LineWithMarkers=14]="LineWithMarkers",d[d.Stepline=15]="Stepline",d[d.HLCArea=16]="HLCArea",d[d.VolCandle=19]="VolCandle",d[d.Renko=4]="Renko",d[d.Kagi=5]="Kagi",d[d.PointAndFigure=6]="PointAndFigure",d[d.LineBreak=7]="LineBreak",d))(re||{}),$e=(t=>(t.Light="light",t.Dark="dark",t))($e||{}),ae=(C=>(C.HeaderWidget="header_widget",C.HeaderCandleStyleMenu="header_candle_style_menu",C.HeaderFullscreenButton="header_fullscreen_button",C.TradingAccountManager="trading_account_manager",C.MultiCharts="multi_charts",C.CreateVolumeIndicatorByDefault="create_volume_indicator_by_default",C.VolumeForceOverlay="volume_force_overlay",C.HideDrawingToolsByDefault="hide_drawing_tools_by_default",C.LegendSeriesTitle="legend_series_title",C.LegendVolume="legend_volume",C.TimeframesToolbar="timeframes_toolbar",C.SaveDrawingToServer="save_drawing_to_server",C))(ae||{}),I=(g=>(g.Layout1A="1A",g.Layout2A="2A",g.Layout2B="2B",g.Layout3A="3A",g.Layout3B="3B",g.Layout3C="3C",g.Layout3D="3D",g.Layout3E="3E",g.Layout3F="3F",g.Layout4A="4A",g.Layout4B="4B",g.Layout4C="4C",g.Layout4D="4D",g.Layout4E="4E",g.Layout4F="4F",g.Layout5A="5A",g.Layout5B="5B",g.Layout5C="5C",g.Layout5D="5D",g.Layout6A="6A",g.Layout6B="6B",g.Layout6C="6C",g.Layout7A="7A",g.Layout8A="8A",g.Layout8B="8B",g.Layout8C="8C",g))(I||{}),qe=(r=>(r[r.None=0]="None",r[r.ResetData=1]="ResetData",r[r.ResetChart=2]="ResetChart",r))(qe||{});var pe=["header_widget","header_candle_style_menu","header_fullscreen_button","multi_charts","volume_force_overlay","legend_series_title","timeframes_toolbar","save_drawing_to_server"],T=["1s","30s","1m","1h","4h","1d"],w=["1s","15s","30s","1m","5m","15m","1h","4h","12h","1d"],ye=["1A","2A","2B","3A","3B","3C","3D","3E","3F","4A","4B","4C","4D","4E","4F","5A","5B","5C","5D","6A","6B","6C","7A","8A","8B","8C"],Je=["click","keydown","mousedown","mouseup","contextmenu"],S={decrease:"#f76816",increase:"#c7ff2e",chartBg:"#050807",card:"#0e1211"},Ge={card:"#242424"};var M=utils.atomFamily(a=>jotai.atom(true)),_=utils.atomFamily(a=>jotai.atom(false)),b=utils.atomFamily(a=>jotai.atom(0)),x=utils.atomFamily(a=>jotai.atom([...T])),y=utils.atomFamily(a=>jotai.atom([])),L=utils.atomFamily(a=>jotai.atom(false)),P=utils.atomFamily(a=>jotai.atom("1A")),A=utils.atomFamily(a=>jotai.atom("TradingView")),D=utils.atomFamily(a=>jotai.atom("dark")),ie=utils.atomFamily(a=>jotai.atom("en")),oe=utils.atomFamily(a=>jotai.atom("Etc/UTC")),se=utils.atomFamily(a=>jotai.atom("")),O=utils.atomFamily(a=>jotai.atom("kline")),ne=utils.atomFamily(a=>jotai.atom(false)),le=utils.atomFamily(a=>jotai.atom(null)),Ce=utils.atomFamily(a=>jotai.atom(null)),be=utils.atomFamily(a=>jotai.atom(null)),F=utils.atomFamily(a=>jotai.atom([])),V=utils.atomFamily(a=>jotai.atom([])),W=utils.atomFamily(a=>jotai.atom(false)),N=utils.atomFamily(a=>jotai.atom(e=>{let t=e(P(a)),r=e(A(a)),i=e(b(a)),o=e(x(a)),s=e(L(a)),n=e(y(a));return {layout:t,chartType:r,selectedIndex:i,pinnedResolutions:o,showDrawingToolbar:s,areaContents:n}}),lodashEs.isEqual);var k=class{settings;chartManager;chartIndex;store;prefix;pendingTickerSymbol=null;pendingResolution=null;constructor(e,t,r,i,o,s){this.settings=e,this.chartManager=t,this.chartIndex=r,this.store=i,this.prefix=o;let l={...{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false},...s};this.patchArea(l);}get state(){return this.store.get(y(this.prefix))[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false}}patchArea(e){let t=[...this.store.get(y(this.prefix))],r=t[this.chartIndex]??{resolution:"1m",chartStyle:1,symbol:"",tickerSymbol:"",rightOffset:10,barSpacing:6,dataReady:false};t[this.chartIndex]={...r,...e},this.store.set(y(this.prefix),t);}setState(e,t){t!=null&&this.patchArea({[e]:t});}get tickerSymbol(){return this.state.tickerSymbol}get symbol(){return this.state.symbol}get resolution(){return this.state.resolution}get chartStyle(){return this.state.chartStyle}get rightOffset(){return this.state.rightOffset}get barSpacing(){return this.state.barSpacing}get dataReady(){return this.state.dataReady}get internalChartWidget(){return this.chartManager.internalWidget?.chartByIndex(this.chartIndex)}setChartStyle(e){this.setState("chartStyle",e),this.internalChartWidget?.setChartStyle(e);}async setSymbol(e){if(this.state.tickerSymbol!==e){this.setState("tickerSymbol",e),this.setState("dataReady",false),this.pendingTickerSymbol=e;try{let t=[this.internalChartWidget?.handleSymbolChange(e,this.tickerSymbol),this.chartManager.symbolResolver?.resolveSymbolInfo(e).then(r=>{r&&this.setState("symbol",r.name);})];for(let r of await Promise.allSettled(t))if(r.status==="rejected")throw r.reason}catch(t){console.error(t);}finally{this.pendingTickerSymbol===e&&(this.pendingTickerSymbol=null);}this.tickerSymbol===e&&this.setState("dataReady",true);}}async setResolution(e){if(this.resolution!==e){this.setState("resolution",e),this.setState("dataReady",false),this.pendingResolution=e;try{await this.internalChartWidget?.handleResolutionChange(e,this.resolution);}finally{this.pendingResolution===e&&(this.pendingResolution=null);}}}toJSON(){return {...this.state}}widgetReady(){this.internalChartWidget?.dataReady()?.then(()=>this.handleChartReady())?.catch(()=>{});}get active(){return this.chartIndex<this.chartManager.chartCount}get selected(){return this.chartManager.selectedIndex===this.chartIndex}get symbolInfo(){return this.chartManager.symbolResolver?.getSymbolInfo(this.tickerSymbol)??null}destroy(){}async handleChartReady(){this.internalChartWidget&&(this.setState("dataReady",true),this.selected&&this.internalChartWidget.setBarSpacing(this.barSpacing));}};var H=class{prefix;settings;store;initialized=false;focused=false;reloadId=0;internalWidget=null;datafeed=null;symbolResolver=null;unsubAutoSave=null;constructor(e,t,r){this.prefix=e,this.store=t,this.settings=r;}get loading(){return this.store.get(M(this.prefix))}get fullscreen(){return this.store.get(_(this.prefix))}set fullscreen(e){this.store.set(_(this.prefix),e),e?document.body.classList.add("fullScreen"):document.body.classList.remove("fullScreen");}get selectedIndex(){return this.store.get(b(this.prefix))}set selectedIndex(e){this.store.set(b(this.prefix),e);}get pinnedResolutions(){return this.store.get(x(this.prefix))}set pinnedResolutions(e){this.store.set(x(this.prefix),e);}get showDrawingToolbar(){return this.store.get(L(this.prefix))}get chartCount(){return parseInt(this.settings.layout,10)||1}get areas(){let e=this.store.get(y(this.prefix));return this._areaManagers.slice(0,e.length)}_areaManagers=[];areaByIndex(e){return this.initialized&&this.updateChartContents(),this._areaManagers[e]??null}get activeArea(){return this.areaByIndex(this.selectedIndex)}async init(){if(this.initialized)return;let e=this.settings.saveLoadAdapter.getSettings();if(e?.selectedIndex!=null&&(this.selectedIndex=e.selectedIndex),e?.pinnedResolutions){let r=e.pinnedResolutions;r.length===T.length&&r.every(i=>T.includes(i))?this.pinnedResolutions=[...T]:this.pinnedResolutions=r;}if(e?.areaContents&&e.areaContents.forEach((r,i)=>{let o=new k(this.settings,this,i,this.store,this.prefix,r);this._areaManagers[i]=o;}),e?.showDrawingToolbar!=null&&this.store.set(L(this.prefix),e.showDrawingToolbar),this.settings.updateValue("layout",e?.layout),this.settings.updateValue("chartType",e?.chartType),this.settings.enableMultiCharts||this.settings.updateValue("layout","1A"),this.settings.enableHideDrawingToolsByDefault&&this.store.set(L(this.prefix),false),this.updateChartContents(),this.settings.tickerSymbol&&this.activeArea)try{await this.activeArea.setSymbol(this.settings.tickerSymbol);}catch(r){console.warn("ChartManager init failed to set symbol",r);}this.initialized=true;let t=lodashEs.debounce(()=>{let r=this.store.get(N(this.prefix));this.settings.saveLoadAdapter.saveSettings(r).catch(console.error);},1e3);this.unsubAutoSave=this.store.sub(N(this.prefix),t);}destroy(){this.unsubAutoSave?.(),this._areaManagers.forEach(e=>e.destroy()),this._areaManagers=[];}setLoading(e){this.store.set(M(this.prefix),e);}setLocale(e){this.settings.updateValue("locale",e);}setTimezone(e){this.settings.updateValue("timezone",e);}setFocused(e){this.focused=e;}setShowDrawingToolbar(e){this.store.set(L(this.prefix),e);}setInternalWidget(e){this.internalWidget=e,this.store.set(W(this.prefix),false);}onInternalWidgetReady(){this.store.set(W(this.prefix),true),this.areas.forEach((e,t)=>{t<this.chartCount&&e.widgetReady();});}setChartType(e){this.settings.updateValue("chartType",e);}setTheme(e){this.settings.theme!==e&&(this.settings.updateValue("theme",e),this.internalWidget?.onThemeChange?.(e,this.settings.reverseColor));}setColorPalette(e){this.settings.updateValue("backgroundColor",e.backgroundColor),this.settings.updateValue("increaseColor",e.increaseColor),this.settings.updateValue("decreaseColor",e.decreaseColor),this.internalWidget?.bridge.applyColorPaletteOverrides();}setReverseColor(e){this.settings.reverseColor!==e&&(this.settings.updateValue("reverseColor",e),this.internalWidget?.onThemeChange?.(this.settings.theme,e));}setLayout(e){let t=this.settings.enableMultiCharts?e:"1A";if(this.settings.layout!==t){this.settings.updateValue("layout",t),this.updateChartContents(),this.internalWidget?.onLayoutChange?.(t);let r=this.chartCount;setTimeout(()=>{if(this.store.get(W(this.prefix)))for(let i=r;i<this.chartCount;i++)this.areaByIndex(i)?.widgetReady();});}}reloadChart(){this.reloadId+=1;}updateChartContents(){if(this.chartCount>this._areaManagers.length)for(let e=this._areaManagers.length;e<this.chartCount;e++){let t=this._areaManagers[this.selectedIndex],r=t?.toJSON(),i=new k(this.settings,this,e,this.store,this.prefix,r);this._areaManagers[e]=i,this.selectedIndex!==e&&!t&&i.setSymbol(this.settings.tickerSymbol).catch(()=>{});}this.selectedIndex>=this.chartCount&&(this.selectedIndex=this.chartCount-1);}get settingsData(){return this.store.get(N(this.prefix))}getAllCharts(){return this.updateChartContents(),this._areaManagers.slice(0,this.chartCount)}};var U=class{storageId;constructor(e){this.storageId=e;}get settingsKey(){return `${this.storageId}.TvChart.Settings`}get shapesKey(){return `${this.storageId}.TvChart.Shapes`}getSettings(){let e=this.getLocalSettingsData(),t=this.getChartStoreData();return {layout:t?.layout,selectedIndex:t?.currentAreaIndex,chartType:t?.chartType,pinnedResolutions:t?.pinnedResolutions,areaContents:t?.areas?.map(i=>({resolution:i.resolution||i.period||"1m",chartStyle:i.chartStyle,symbol:i.symbol,tickerSymbol:i.tickerSymbol,rightOffset:i.rightOffset,barSpacing:i.barSpacing})),showDrawingToolbar:t?.drawing?.toolbarSwitch,drawing:e?.drawing?{...e.drawing,defaultStates:lodashEs.omit(e,["drawing","DrawingToolGroupLastUsedTool","riskRewardAvailableChanged","riskRewardRiskSizeChanged","drawingShapeTemplate"]),lastUsedTools:e.DrawingToolGroupLastUsedTool,riskRewardAvailableChanged:e.riskRewardAvailableChanged,riskRewardRiskSizeChanged:e.riskRewardRiskSizeChanged,drawingShapeTemplate:e.drawingShapeTemplate}:void 0}}getChartStoreData(){return this.getLocalData(this.storageId)}setChartStoreData(e){this.setLocalData(this.storageId,e);}async saveSettings(e){let t=this.getChartStoreData(),r={...t,layout:e.layout,currentAreaIndex:e.selectedIndex,chartType:e.chartType,pinnedResolutions:e.pinnedResolutions,areas:e.areaContents?.map((i,o)=>({...t?.areas?.[o],...i})),drawing:{...t?.drawing,toolbarSwitch:e.showDrawingToolbar}};this.setChartStoreData(r);}async getShapes(e){let t=this.getLocalShapesData();return !t||!t[e]?[]:Object.values(t[e])}async saveShapes(e,t){let r=this.getLocalShapesData()||{};r[e]={...r[e],...t},Object.keys(r[e]).forEach(i=>{r[e][i]||delete r[e][i];}),this.setLocalShapesData(r);}getLocalData(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}setLocalData(e,t){localStorage.setItem(e,JSON.stringify(t));}getLocalSettingsData(){return this.getLocalData(this.settingsKey)}getLocalShapesData(){return this.getLocalData(this.shapesKey)}setLocalShapesData(e){this.setLocalData(this.shapesKey,e);}};function de(a){let[e,t,r,i]=a.split("/");return {address:t,chain:e,quote:r,priceType:i}}function wt(a){return !a.quote||!a.priceType?`${a.chain}/${a.address}`:`${a.chain}/${a.address}/${a.quote}/${a.priceType}`}function he(a){return `${a.chain}/${a.address}`}var xt={dark:"Dark",light:"Light"};function B(a){return xt[a.toLowerCase()]??"Dark"}var Ke={"1s":"1S","5s":"5S","15s":"15S","30s":"30S","1m":"1","5m":"5","15m":"15","30m":"30","1h":"60","4h":"240","12h":"720","1d":"1D"};function f(a="1m"){return Ke[a]??Ke["1m"]}var Lt={"1S":"1s","5S":"5s","15S":"15s","30S":"30s",1:"1m",5:"5m",15:"15m",30:"30m",60:"1h",240:"4h",720:"12h","1D":"1d"};function z(a){return Lt[a]??"1s"}var Rt={en:"en","zh-CN":"zh","zh-TW":"zh"};function It(a){return Rt[a]??a}var Ye={"1A":"s","2A":"2h","2B":"2v","3A":"3s","3B":"3h","3C":"3v","3D":"2-1","3E":"1-2","3F":"3r","4A":"4","4B":"4h","4C":"4v","4D":"4s","4E":"1-3","4F":"2-2","5A":"1-4","5B":"5s","5C":"2-3","5D":"5h","6A":"6","6B":"6c","6C":"6h","7A":"7h","8A":"8","8B":"8c","8C":"8h"};function $(a){return Ye[a]??"s"}var Mt=Object.fromEntries(Object.entries(Ye).map(([a,e])=>[e,a]));function fe(a){return Mt[a]??"1A"}var _t={"1s":1e3,"5s":5e3,"15s":15e3,"30s":3e4,"1m":6e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"4h":144e5,"12h":432e5,"1d":864e5};function ge(a){let e=_t[a];if(!e)throw new Error(`Invalid interval: ${a}`);return e}function ve(a,e){let t=a.toString().length>10?a:1e3*a;return Math.floor(t/e)*e}var q=class{prefix;store;supportedResolutions=w.map(f);supportedLayouts=ye;supportedChartTypes=["TradingView"];chartNames={};priceFormatterFactory=null;saveLoadAdapter;constructor(e,t){this.prefix=e,this.store=t,this.saveLoadAdapter=new U(e),this.store.set(O(e),e);}get layout(){return this.store.get(P(this.prefix))}get chartType(){return this.store.get(A(this.prefix))}get theme(){return this.store.get(D(this.prefix))}get reverseColor(){return this.store.get(ne(this.prefix))}get locale(){return this.store.get(ie(this.prefix))}get timezone(){return this.store.get(oe(this.prefix))}get tickerSymbol(){return this.store.get(se(this.prefix))}get storageId(){return this.store.get(O(this.prefix))}get backgroundColor(){return this.store.get(le(this.prefix))}get increaseColor(){return this.store.get(Ce(this.prefix))}get decreaseColor(){return this.store.get(be(this.prefix))}get enabledFeatures(){return this.store.get(F(this.prefix))}get disabledFeatures(){return this.store.get(V(this.prefix))}updateValue(e,t){if(t==null)return;let i={layout:()=>this.store.set(P(this.prefix),t),chartType:()=>this.store.set(A(this.prefix),t),theme:()=>this.store.set(D(this.prefix),t),reverseColor:()=>this.store.set(ne(this.prefix),t),locale:()=>this.store.set(ie(this.prefix),t),timezone:()=>this.store.set(oe(this.prefix),t),tickerSymbol:()=>this.store.set(se(this.prefix),t),storageId:()=>this.store.set(O(this.prefix),t),backgroundColor:()=>this.store.set(le(this.prefix),t),increaseColor:()=>this.store.set(Ce(this.prefix),t),decreaseColor:()=>this.store.set(be(this.prefix),t),enabledFeatures:()=>this.store.set(F(this.prefix),t),disabledFeatures:()=>this.store.set(V(this.prefix),t)}[e];i&&i();}isFeatureEnabled(e){return !this.disabledFeatures.includes(e)&&this.enabledFeatures.includes(e)||pe.includes(e)}setFeature(e,t){this.resetFeature(e),t?this.store.set(F(this.prefix),[...this.enabledFeatures,e]):this.store.set(V(this.prefix),[...this.disabledFeatures,e]);}resetFeature(e){this.store.set(F(this.prefix),this.enabledFeatures.filter(t=>t!==e)),this.store.set(V(this.prefix),this.disabledFeatures.filter(t=>t!==e));}get enableMultiCharts(){return this.isFeatureEnabled("multi_charts")}get enableCreateVolumeIndicatorByDefault(){return this.isFeatureEnabled("create_volume_indicator_by_default")}get enableHideDrawingToolsByDefault(){return this.isFeatureEnabled("hide_drawing_tools_by_default")}get enableLegendSeriesTitle(){return this.isFeatureEnabled("legend_series_title")}get enableLegendVolume(){return this.isFeatureEnabled("legend_volume")}get enableTimeframesToolbar(){return this.isFeatureEnabled("timeframes_toolbar")}get enableVolumeForceOverlay(){return this.isFeatureEnabled("volume_force_overlay")}sub(e,t){let i={layout:P(this.prefix),chartType:A(this.prefix),theme:D(this.prefix)}[e];return i?this.store.sub(i,t):()=>{}}};var J=class{datafeed;cache=new Map;pendingRequests=new Map;constructor(e){this.datafeed=e;}async resolveSymbolInfo(e){return this.datafeed.resolveSymbol(e)}async resolveSymbolInfos(e){return e.filter(r=>!this.cache.has(r)&&!this.pendingRequests.has(r)).forEach(r=>{let i=this.resolveSymbolInfo(r);i.then(o=>{o&&this.cache.set(r,o);}).catch(()=>{}).finally(()=>this.pendingRequests.delete(r)),this.pendingRequests.set(r,i);}),await Promise.all(e.filter(r=>this.pendingRequests.has(r)).map(r=>this.pendingRequests.get(r))),e.map(r=>this.cache.get(r)??null).filter(r=>r!==null)}getSymbolInfo(e){return this.resolveSymbolInfo(e).catch(t=>{console.error("ChartSymbolResolver.getSymbolInfo",t);}),this.cache.get(e)??null}};var Te=({initConfig:a,children:e})=>{let{chartManager:t,chartSettings:r}=h(),[i,o]=react.useState(false);return react.useEffect(()=>{t.initialized||(r.updateValue("tickerSymbol",a.tickerSymbol),r.updateValue("theme",a.theme),r.updateValue("reverseColor",a.reverseColor),r.updateValue("layout",a.layout),r.updateValue("chartType",a.chartType),r.updateValue("timezone",a.timezone),r.updateValue("locale",a.locale),r.updateValue("backgroundColor",a.backgroundColor),r.updateValue("increaseColor",a.increaseColor),r.updateValue("decreaseColor",a.decreaseColor),r.updateValue("storageId",a.storageId),r.updateValue("enabledFeatures",a.enabledFeatures),r.updateValue("disabledFeatures",a.disabledFeatures),a.chartNames&&(r.chartNames=a.chartNames),a.priceFormatterFactory&&(r.priceFormatterFactory=a.priceFormatterFactory),a.supportedResolutions&&(r.supportedResolutions=a.supportedResolutions),a.supportedLayouts&&(r.supportedLayouts=a.supportedLayouts),a.supportedChartTypes&&(r.supportedChartTypes=a.supportedChartTypes),t.datafeed=a.datafeed,t.symbolResolver=new J(a.datafeed));},[t,r,a]),react.useEffect(()=>{i&&(t.setTheme(a.theme),t.setColorPalette({backgroundColor:a.backgroundColor,increaseColor:a.increaseColor,decreaseColor:a.decreaseColor}));},[t,i,a.backgroundColor,a.decreaseColor,a.increaseColor,a.theme]),react.useEffect(()=>(t.init().then(()=>o(true)).catch(s=>{console.error("TradingViewConfig chartManager init error",s);}),()=>{t.destroy();}),[t]),i&&t.initialized?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):null};var Qe=react.createContext(null);function h(){let a=react.useContext(Qe);if(!a)throw new Error("useTvChartContext must be used within TradingViewProvider");return a}function Ot(){return h().chartManager}function Wt(){return h().prefix}var ce=class{setting;chartManager;constructor(e,t){this.setting=e,this.chartManager=t;}get internalWidget(){return this.chartManager.internalWidget}chartCount(){return this.chartManager.chartCount}setActiveChart(e){e<this.chartCount()&&(this.chartManager.selectedIndex=e);}layout(){return this.setting.layout}setLayout(e){this.chartManager.setLayout(e);}theme(){return this.setting.theme}setTheme(e){this.chartManager.setTheme(e);}setChartType(e){this.chartManager.setChartType(e);}getSetting(){return this.setting}getChartManager(){return this.chartManager}},we=react.forwardRef(({children:a,initConfig:e,widgetConstructor:t,libraryPath:r,customCssUrl:i},o)=>{let s=jotai.useStore(),n=e.storageId,l=react.useMemo(()=>new q(n,s),[n,s]),u=react.useMemo(()=>new H(n,s,l),[n,s,l]),c=react.useMemo(()=>new ce(l,u),[l,u]);react.useImperativeHandle(o,()=>c,[c]);let v=react.useMemo(()=>({prefix:n,chartSettings:l,chartManager:u,widgetConstructor:t,libraryPath:r,customCssUrl:i}),[n,l,u,t,r,i]);return jsxRuntime.jsx(Qe.Provider,{value:v,children:jsxRuntime.jsx(Te,{initConfig:e,children:a})})});var xe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(_(e)),i=react.useCallback(()=>{t.fullscreen=!t.fullscreen;},[t]);return jsxRuntime.jsx("button",{type:"button",onClick:i,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a(r?"tradingView.exitFullscreen":"tradingView.fullscreen"),children:a(r?"tradingView.exit":"tradingView.fullscreen")})});var je=react.createContext(null);function G(){let a=react.useContext(je);if(!a)throw new Error("useTvChartToolbarContext must be used within TradingViewToolbarProvider");return a}var Re=({children:a})=>{let{prefix:e,chartManager:t}=h(),r=jotai.useAtomValue(b(e)),i=jotai.useAtomValue(y(e)),o=react.useMemo(()=>i.length?t.areaByIndex(r):null,[t,r,i]),s=react.useMemo(()=>o?.symbolInfo??null,[o]),n=react.useMemo(()=>({activeAreaManager:o,symbolInfo:s}),[o,s]);return jsxRuntime.jsx(je.Provider,{value:n,children:a})};var tt={0:"tradingView.style.bars",1:"tradingView.style.candles",2:"tradingView.style.line",3:"tradingView.style.area",8:"tradingView.style.heikenAshi",9:"tradingView.style.hollowCandles",10:"tradingView.style.baseline"},Qt=[1,0,2,3,9,8,10],Ie=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e}=h(),{activeAreaManager:t}=G(),r=jotai.useAtomValue(y(e)),i=jotai.useAtomValue(b(e)),o=r[i]?.chartStyle??1,s=react.useCallback(n=>{let l=parseInt(n.target.value,10);t?.setChartStyle(l);},[t]);return jsxRuntime.jsx("select",{value:o,onChange:s,className:"text-xs bg-transparent text-muted-foreground hover:text-foreground cursor-pointer border-none outline-none px-1 py-0.5",title:a("tradingView.klineStyle"),children:Qt.map(n=>jsxRuntime.jsx("option",{value:n,children:tt[n]?a(tt[n]):n},n))})});var Me=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openIndicatorSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.indicators"),children:a("tradingView.indicators")})});var _e=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(()=>{e.internalWidget?.openSettingsDialog();},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.chartSettings"),children:a("tradingView.settings")})});var Ae=react.memo(()=>{let{t:a}=i18n.useTranslation(),{prefix:e}=h(),{activeAreaManager:t}=G(),r=jotai.useAtomValue(x(e)),i=jotai.useAtomValue(y(e)),o=jotai.useAtomValue(b(e)),s=i[o]?.resolution,n=react.useCallback(l=>{t?.setResolution(l);},[t]);return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",children:r.map(l=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(l),className:`px-2 py-0.5 text-xs rounded cursor-pointer transition-colors ${s===l?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,children:a(`common.resolution.${l}`)},l))})});var Fe=react.memo(()=>{let{t:a}=i18n.useTranslation(),{chartManager:e}=h(),t=react.useCallback(async()=>{try{let r=await e.internalWidget?.takeClientScreenshot();if(!r)return;let i=document.createElement("a");i.download=`chart-${Date.now()}.png`,i.href=r.toDataURL("image/png"),i.click();}catch(r){console.error("TradingViewSnapshot",r);}},[e]);return jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded hover:bg-muted cursor-pointer transition-colors",title:a("tradingView.takeSnapshot"),children:a("tradingView.snapshot")})});var ke=react.memo(({children:a,prefix:e,suffix:t,showResolutions:r=true,showKlineStyleSelect:i=true,showOpenIndicator:o=true,showOpenSettings:s=true,showFullscreen:n=true,showSnapshot:l=true})=>jsxRuntime.jsx(Re,{children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border min-h-[36px] flex-shrink-0",children:[e,a??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r&&jsxRuntime.jsx(Ae,{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[i&&jsxRuntime.jsx(Ie,{}),o&&jsxRuntime.jsx(Me,{}),s&&jsxRuntime.jsx(_e,{}),l&&jsxRuntime.jsx(Fe,{}),n&&jsxRuntime.jsx(xe,{})]})]}),t]})}));var K=class{settings;chartManager;bridge;chartIndex;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.bridge=r,this.chartIndex=i;}get chartAreaManager(){return this.chartManager.areaByIndex(this.chartIndex)}get widget(){return this.bridge.getWidget()}get chartWidget(){return this.widget?.chart(this.chartIndex)??null}setChartStyle(e){this.chartWidget?.setChartType(e);}getChartStyle(){return this.chartWidget?.chartType()??1}handleSymbolChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{r.chart(this.chartIndex).setSymbol(e,{dataReady:()=>i(),doNotActivateChart:false});})}handleResolutionChange(e,t){return this.bridge.asyncWidgetMethodContext((r,i)=>{let o=r.chart(this.chartIndex);o.dataReady(()=>{o.setResolution(f(e),{dataReady:i,doNotActivateChart:true}).catch(()=>{});});})}setPrecision(e){this.widget?.applyOverrides({"mainSeriesProperties.minTick":e===null?"default":`${Math.pow(10,e)},1,false`});}async dataReady(){if(await this.bridge.onReady(),!this.chartWidget)throw Error("ChartWidget: chartWidget is null");return new Promise(e=>{this.chartWidget?.dataReady(()=>setTimeout(e));})}timeScaleWidth(){return this.chartWidget?.getTimeScale()?.width()??NaN}rightOffset(){return this.chartWidget?.getTimeScale()?.rightOffset()??NaN}setRightOffset(e){this.chartWidget?.getTimeScale()?.setRightOffset(e);}barSpacing(){return this.chartWidget?.getTimeScale()?.barSpacing()??NaN}setBarSpacing(e){this.chartWidget?.getTimeScale()?.setBarSpacing(e);}};var Y=class{settings;chartManager;bridge;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}get widget(){return this.bridge.getWidget()}chartByIndex(e){return new K(this.settings,this.chartManager,this.bridge,e)}activeChart(){let e=this.widget?.activeChartIndex();return e===void 0?void 0:this.chartByIndex(e)}openIndicatorSettingsDialog(){this.widget?.activeChart().executeActionById("insertIndicator");}openSettingsDialog(){this.widget?.activeChart().executeActionById("chartProperties");}takeClientScreenshot(){return this.widget?.takeClientScreenshot()}onLayoutChange(e){this.widget?.setLayout($(e));}async onThemeChange(e,t){let r=B(e);await this.widget?.changeTheme(r,{disableUndo:true}),this.bridge.applyColorPaletteOverrides();}};var X=class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.listeners.get(e)?.delete(t);}}emit(e,t){this.listeners.get(e)?.forEach(r=>r(t));}off(e,t){this.listeners.get(e)?.delete(t);}clear(){this.listeners.clear();}};var Q=class{settings;chartManager;bridge;abortController=new AbortController;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r;}toJSON(){return null}async onReady(e){setTimeout(()=>{e({supported_resolutions:w.map(f),supports_marks:true,exchanges:[]});}),await this.chartManager.datafeed?.onReady({setting:this.settings,chartManager:this.chartManager,instance:this.bridge});}destroy(){this.abortController.abort();}async resolveSymbol(e,t,r,i){try{let o=await this.chartManager.datafeed?.resolveSymbol(e,i);o&&t(o);}catch(o){console.error("ChartDataFeed.resolveSymbol",o),r(o);}}async getBars(e,t,r,i,o){try{let s=await this.chartManager.datafeed?.getBars(e,t,r);s&&i(s,{noData:s.length===0});}catch(s){console.error("ChartDataFeed.getBars",s),o(s);}}subscribeBars(e,t,r,i,o){this.chartManager.datafeed?.subscribeBars(e,t,r,i,o);}unsubscribeBars(e){this.chartManager.datafeed?.unsubscribeBars(e);}async getMarks(e,t,r,i,o){this.chartManager.datafeed?.getMarks?.(e,t,r,i,o);}getQuotes(e,t,r){t(e.map(i=>({s:"ok",n:i,v:{}})));}subscribeQuotes(e,t,r,i){}unsubscribeQuotes(e){}};var Z=class{settings;chartManager;bridge;data;drawings;constructor(e,t,r){this.settings=e,this.chartManager=t,this.bridge=r,this.data=null,this.drawings=null,this.loadDataFromLocalStorage();}get layoutId(){return this.settings.storageId}get shouldResetColorPalette(){let e=this.data?.theme,t=this.data?.reverseColor;return e!==this.settings.theme||t!==this.settings.reverseColor}toJSON(){return null}getAllCharts(){return new Promise(e=>{let t=[];this.data&&t.push({id:this.data.id,name:this.data.name,symbol:this.data.symbol,resolution:this.data.resolution,timestamp:this.data.timestamp}),e(t);})}removeChart(e){throw Error("Method not implemented.")}async saveChart(e){return this.data={...e,theme:this.settings.theme,reverseColor:this.settings.reverseColor,id:this.layoutId,timestamp:0},this.saveDataToLocalStorage(),this.data.id}getChartContent(e){return new Promise(t=>{let r=JSON.parse(this.data.content),i=JSON.parse(r.charts_symbols),o=JSON.parse(r.content);t(JSON.stringify({...r,chart_symbols:JSON.stringify(i),content:JSON.stringify(o)}));})}async saveLineToolsAndGroups(e,t,r){this.drawings=this.drawings||{data:{},timestamp:0},this.drawings.data=this.drawings.data||{},this.drawings.data[t]=this.drawings.data[t]||{};try{if(!r.sources)return;for(let[i,o]of r.sources)if(!o||!o.symbol||!o.state||Object.keys(o.state).length===0||i.includes("/"))o===null&&delete this.drawings.data[t][i];else {let{address:s,chain:n}=de(o.symbol),l=he({address:s,chain:n}),u={...o,symbol:l,id:o.id.indexOf("/")>0?o.id.split("/")[0]:o.id};this.drawings.data[t][i]=u;}this.saveDataToLocalStorage();}catch(i){console.error("saveLineToolsAndGroups",i);}}async loadLineToolsAndGroups(e,t,r,i){if(!i?.symbol||!this.drawings?.data?.[t])return null;let o=i.symbol,{address:s,chain:n}=de(o),l=he({address:s,chain:n}),u=lodashEs.uniqBy(Object.values(lodashEs.cloneDeep(this.drawings.data[t])).filter(c=>c.symbol===l),"id");try{return {sources:new Map(u.map(c=>{let v=lodashEs.cloneDeep({...c,symbol:o});return [v.id,v]}))}}catch(c){return console.error("ChartSaveLoadAdapter.loadLineToolsAndGroups",c),null}}getLayoutKey(e){return `charts.tradingview.data.${e}`}getDrawingKey(e){return `charts.tradingview.drawing.${e}`}loadDataFromLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=localStorage.getItem(e),i=localStorage.getItem(t);if(r)try{let o=JSON.parse(r),s=JSON.parse(o.content);o.content=JSON.stringify(s),this.data=o;}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse layout error",o);}if(i)try{this.drawings=JSON.parse(i);}catch(o){console.error("ChartSaveLoadAdapter loadDataFromLocalStorage parse drawing error",o);}}saveDataToLocalStorage(){let e=this.getLayoutKey(this.layoutId),t=this.getDrawingKey(this.layoutId),r=Math.round(Date.now()/1e3);this.data&&(this.data.timestamp=r,localStorage.setItem(e,JSON.stringify(this.data))),this.drawings&&(this.drawings.timestamp=r,localStorage.setItem(t,JSON.stringify(this.drawings)));}};var Be="trading.chart.proterty",j=class{storagePrefix;initialSettings;constructor(e,t,r){this.storagePrefix=`tradingview.${e.storageId}.`,this.initialSettings={};for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);if(s&&s.startsWith(this.storagePrefix)){let n=s.slice(this.storagePrefix.length);this.initialSettings[n]=localStorage.getItem(s);}}let i={noConfirmEnabled:1};if(this.initialSettings[Be])try{let o=JSON.parse(this.initialSettings[Be]);Object.assign(i,o),Object.assign(i,{noConfirmEnabled:!0});}catch(o){console.error("ChartSettingsAdapter: failed to parse chart settings",o);}this.initialSettings[Be]=JSON.stringify(i);}toJSON(){return null}removeValue(e){delete this.initialSettings[e],localStorage.removeItem(`${this.storagePrefix}${e}`);}setValue(e,t){this.initialSettings[e]=t,localStorage.setItem(`${this.storagePrefix}${e}`,t);}};var ee=class{settings;chartManager;WidgetCtor;moduleInstances=new Map;symbolIntervalSubs=new Map;abortController=new AbortController;widgetReadyPromise=null;readyPromise=null;widget=null;container=null;ready=false;layoutReady=true;events=new X;libraryPath;customCssUrl;constructor(e,t,r,i){this.settings=e,this.chartManager=t,this.WidgetCtor=r,this.libraryPath=i?.libraryPath??"/static/charting_library/",this.customCssUrl=i?.customCssUrl??"custom-styles.css",this.initModules();}getWidget(){return this.widget}async init(e){if(this.widgetReadyPromise)throw new Error("ChartWidgetBridge already initialized.");let t=this.getWidgetOptions();this.container=e,this.widget=new this.WidgetCtor({...t,container:e});let r=new Promise(i=>{this.widget?.onChartReady(()=>i());});this.widgetReadyPromise=r,this.readyPromise=r.then(()=>(this.ready=true,this.handleChartReady())).catch(i=>{console.warn("ChartWidgetBridge widget ready failed",i);}),this.moduleInstances.forEach((i,o)=>{try{i.init?.call(i);}catch(s){console.warn(`ChartWidgetBridge init module ${o}`,s);}}),await Promise.race([this.readyPromise,new Promise((i,o)=>setTimeout(o,6e4,new Error("ChartWidgetBridge init timeout")))]);}async destroy(){this.moduleInstances.forEach(e=>e.destroy?.call(e)),this.symbolIntervalSubs.forEach(e=>e()),this.symbolIntervalSubs.clear(),this.events.clear(),this.abortController.abort(),this.ready=false,this.widgetReadyPromise=null,this.readyPromise=null,this.widget?.remove(),this.widget=null;}async onReady(){return new Promise((e,t)=>{this.widget?this.widget.onChartReady(()=>this.readyPromise?.then(e).catch(t)):t(Error("cannot call `onReady` before `init`"));})}async asyncWidgetMethodContext(e){return new Promise((t,r)=>{if(!this.widgetReadyPromise){r(new Error("ChartWidgetBridge: widget not ready"));return}let i=this.widgetReadyPromise.then(()=>this.waitForLayout()),o=this.abortController.signal,s=()=>r(o.reason);o.addEventListener("abort",s),i.then(()=>e(this.widget,t)).catch(r).finally(()=>o.removeEventListener("abort",s));})}getModule(e){return this.moduleInstances.get(e)}applyColorPaletteOverrides(){this.widget?.applyOverrides(this.getColorPaletteOverrides()),this.widget?.applyStudiesOverrides(this.getColorPaletteStudiesOverrides());}getWidgetOptions(){let e=["header_widget","legend_inplace_edit","display_market_status","save_shortcut","show_interval_dialog_on_key_press","symbol_info","symbol_search_hot_key","uppercase_instrument_names","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","drawing_templates",...this.settings.disabledFeatures],t=["determine_first_data_request_size_using_visible_range","request_only_visible_range_on_reset","show_exchange_logos","show_symbol_logos","dont_show_boolean_study_arguments","hide_last_na_study_output","hide_right_toolbar","seconds_resolution","saveload_separate_drawings_storage","volume_force_overlay","create_volume_indicator_by_default","two_character_bar_marks_labels",...this.settings.enabledFeatures];return this.settings.enableHideDrawingToolsByDefault&&t.push("hide_left_toolbar_by_default"),this.settings.enableTimeframesToolbar||e.push("timeframes_toolbar"),this.settings.enableCreateVolumeIndicatorByDefault||e.push("create_volume_indicator_by_default"),this.settings.enableVolumeForceOverlay||e.push("volume_force_overlay"),{container:"",autosize:true,debug:false,load_last_chart:true,auto_save_delay:1,timezone:this.localTimezone,library_path:this.libraryPath,custom_css_url:this.customCssUrl,theme:B(this.settings.theme),custom_font_family:window.getComputedStyle(document.body).fontFamily,symbol:this.chartManager.activeArea?.tickerSymbol,interval:f(this.chartManager.activeArea?.resolution),locale:this.settings.locale,datafeed:this.getModule("datafeed"),save_load_adapter:this.getModule("saveLoadAdapter"),settings_adapter:this.getModule("settingsAdapter"),custom_formatters:{priceFormatterFactory:this.settings.priceFormatterFactory?(r,i)=>this.settings.priceFormatterFactory(r,i):()=>null},overrides:{...this.getSettingsOverrides(),...this.getColorPaletteOverrides()},studies_overrides:this.getColorPaletteStudiesOverrides(),disabled_features:[...new Set(e)],enabled_features:[...new Set(t)].filter(r=>!e.includes(r)),supported_resolutions:w.map(f)}}async handleChartReady(){let e=$(this.settings.layout);e!==this.widget?.layout()&&await this.waitForLayout(e),this.widget?.setActiveChart(this.chartManager.selectedIndex),this.getModule("saveLoadAdapter")?.shouldResetColorPalette&&await this.widget?.changeTheme(B(this.settings.theme),{disableUndo:true}),this.applyColorPaletteOverrides(),this.widget?.subscribe("onAutoSaveNeeded",this.onAutoSaveNeeded.bind(this)),this.widget?.subscribe("activeChartChanged",this.activeChartChanged.bind(this)),this.widget?.subscribe("layout_about_to_be_changed",this.layoutWillChange.bind(this)),this.widget?.subscribe("layout_changed",this.layoutChanged.bind(this)),this.syncChartsChanges(),this.subscribeChartsChanges(),this.installEventHooks(),this.resetTimezone();}onAutoSaveNeeded(){try{this.widget?.saveChartToServer(void 0,void 0,{defaultChartName:"DEFAULT"});}catch(e){console.warn("ChartWidgetBridge.onAutoSaveNeeded",e);}}activeChartChanged(e){this.chartManager.selectedIndex=e,this.chartManager.settings.saveLoadAdapter.saveSettings(this.chartManager.settingsData).catch(console.error);}layoutWillChange(e){this.layoutReady=false,this.chartManager.setLayout(fe(e));}layoutChanged(){this.layoutReady=true,this.syncChartsChanges(),this.subscribeChartsChanges(),this.widget?.unloadUnusedCharts(),this.widget?.saveChartToServer();}syncChartsChanges(){this.widget?.symbolSync()?.setValue(false),this.widget?.intervalSync()?.setValue(false);let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++){let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.setSymbol(r?.tickerSymbol??"",{doNotActivateChart:true}),i.setResolution(f(r?.resolution),{doNotActivateChart:true});}}subscribeChartsChanges(){let e=this.widget?.chartsCount()??0;this.symbolIntervalSubs.forEach((t,r)=>{parseInt(r)>=e&&(t(),this.symbolIntervalSubs.delete(r));});for(let t=0;t<e;t++){if(this.symbolIntervalSubs.has(`${t}`))continue;let r=this.chartManager.areaByIndex(t),i=this.widget.chart(t);i.getPanes().forEach(u=>u.getMainSourcePriceScale()?.setAutoScale(true));let o=i.onSymbolChanged(),s=i.onIntervalChanged(),n=()=>{this.events.emit("symbolChanged",[t,i.symbol()]),r?.setSymbol(i.symbol()).catch(()=>{}),this.onAutoSaveNeeded();},l=u=>{let c=z(u);this.events.emit("resolutionChanged",[t,c]),r?.setResolution(c).catch(()=>{});};o.subscribe(r,n),s.subscribe(r,l),this.symbolIntervalSubs.set(`${t}`,()=>{o.unsubscribe(r,n),s.unsubscribe(r,l);});}}installEventHooks(){let e=this.container?.lastElementChild,t=e?.contentWindow?.document;if(t&&(t.addEventListener("click",()=>e?.click()),t.defaultView?.MutationObserver)){let r=new WeakSet,i=t.querySelector(".layout__area--center");if(i){let o=()=>{i.querySelectorAll(".chart-container").forEach((s,n)=>{r.has(s)||(r.add(s),Je.forEach(l=>{s.addEventListener(l,u=>this.events.emit("domEvent",[n,l,u]),{passive:true});}));});};new t.defaultView.MutationObserver(o).observe(i,{childList:true}),o();}}}resetTimezone(){try{let e=this.widget?.chartsCount()??0;for(let t=0;t<e;t++)this.widget?.chart(t)?.getTimezoneApi()?.setTimezone(this.localTimezone);}catch(e){console.error("ChartWidgetBridge: Reset timezone",e);}}get localTimezone(){return Intl.DateTimeFormat().resolvedOptions().timeZone}async waitForLayout(e){if(!this.widget||this.layoutReady&&!e)return;let t;return new Promise(i=>{t=i,this.widget.subscribe("layout_changed",i),e&&this.widget.setLayout(e);}).finally(()=>{this.widget.unsubscribe("layout_changed",t);})}getSettingsOverrides(){return {"mainSeriesProperties.minTick":"default","paneProperties.legendProperties.showSeriesTitle":this.settings.enableLegendSeriesTitle}}getColorPaletteOverrides(){let e=this.resolveThemeColor(this.settings.backgroundColor,S.chartBg),t=this.resolveThemeColor(this.settings.increaseColor,S.increase),r=this.resolveThemeColor(this.settings.decreaseColor,S.decrease),i=this.settings.theme==="dark"?S.card:Ge.card;return {"paneProperties.background":e,"paneProperties.backgroundType":"solid",volumePaneSize:"medium","mainSeriesProperties.candleStyle.upColor":t,"mainSeriesProperties.barStyle.upColor":t,"mainSeriesProperties.columnStyle.upColor":t,"mainSeriesProperties.candleStyle.downColor":r,"mainSeriesProperties.barStyle.downColor":r,"mainSeriesProperties.columnStyle.downColor":r,"mainSeriesProperties.candleStyle.borderUpColor":t,"mainSeriesProperties.candleStyle.borderDownColor":r,"mainSeriesProperties.candleStyle.wickUpColor":t,"mainSeriesProperties.candleStyle.wickDownColor":r,"mainSeriesProperties.hollowCandleStyle.upColor":t,"mainSeriesProperties.hollowCandleStyle.downColor":r,"mainSeriesProperties.hollowCandleStyle.borderUpColor":t,"mainSeriesProperties.hollowCandleStyle.borderDownColor":r,"mainSeriesProperties.hollowCandleStyle.wickUpColor":t,"mainSeriesProperties.hollowCandleStyle.wickDownColor":r,"mainSeriesProperties.haStyle.upColor":t,"mainSeriesProperties.haStyle.downColor":r,"mainSeriesProperties.haStyle.borderUpColor":t,"mainSeriesProperties.haStyle.borderDownColor":r,"mainSeriesProperties.haStyle.wickUpColor":t,"mainSeriesProperties.haStyle.wickDownColor":r,"mainSeriesProperties.lineStyle.color":t,"mainSeriesProperties.areaStyle.color1":t,"mainSeriesProperties.areaStyle.color2":e,"mainSeriesProperties.areaStyle.linecolor":t,"mainSeriesProperties.areaStyle.transparency":65,"mainSeriesProperties.baselineStyle.topFillColor1":t,"mainSeriesProperties.baselineStyle.topFillColor2":e,"mainSeriesProperties.baselineStyle.bottomFillColor1":r,"mainSeriesProperties.baselineStyle.bottomFillColor2":e,"mainSeriesProperties.baselineStyle.topLineColor":t,"mainSeriesProperties.baselineStyle.bottomLineColor":r,"mainSeriesProperties.baselineStyle.transparency":65,"linetoolorder.bodyBackgroundColor":i,"linetoolorder.bodyBackgroundTransparency":0}}getColorPaletteStudiesOverrides(){let e=this.resolveThemeColor(this.settings.increaseColor,S.increase);return {"volume.volume.color.0":this.resolveThemeColor(this.settings.decreaseColor,S.decrease),"volume.volume.color.1":e,"volume.volume.transparency":80}}resolveThemeColor(e,t){if(!e||!e.includes("var("))return e??t;if(typeof document>"u"||!document.body)return t;let r=document.createElement("span");r.style.color=e,r.style.display="none",document.body.appendChild(r);let i=window.getComputedStyle(r).color;return r.remove(),i||t}initModules(){Object.entries({datafeed:Q,saveLoadAdapter:Z,settingsAdapter:j}).forEach(([t,r])=>{this.moduleInstances.set(t,new r(this.settings,this.chartManager,this));});}};var Ee=react.memo(()=>null);var Oe=react.forwardRef(({onReady:a},e)=>{let{chartManager:t,chartSettings:r,widgetConstructor:i,libraryPath:o,customCssUrl:s}=h(),n=react.useRef(a),[l,u]=react.useState(),[c,v]=react.useState(null),[C,He]=react.useState(false);return react.useEffect(()=>{C&&n.current&&setTimeout(n.current);},[C]),react.useImperativeHandle(e,()=>l,[l]),react.useEffect(()=>{if(!c)return;let me=new ee(r,t,i,{libraryPath:o,customCssUrl:s}),bt=new Y(r,t,me);return u(bt),me.init(c).then(()=>He(true)).catch(ft=>{console.error("TradingViewWidgetContainer: failed to init bridge",ft);}),()=>{me.destroy().then(()=>{u(void 0),He(false);}).catch(()=>{console.error("TradingViewWidgetContainer: failed to destroy bridge");});}},[c,r,t,i,o,s]),jsxRuntime.jsxs("div",{className:"w-full h-full",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("div",{id:"tv_chart_container",className:"w-full h-full",ref:v})]})});var We=react.memo(({onReady:a})=>{let{chartManager:e,chartSettings:t}=h(),r=react.useMemo(()=>`${t.timezone}_${e.reloadId}`,[t.timezone,e.reloadId]);react.useLayoutEffect(()=>{e.setLoading(true);},[e,t.chartType,r]);let i=react.useCallback(()=>{a?.(),e.onInternalWidgetReady(),e.setLoading(false);},[e,a]);return jsxRuntime.jsx("div",{className:"h-full min-h-0 w-full overflow-hidden",children:jsxRuntime.jsx(Oe,{onReady:i,ref:o=>e.setInternalWidget(o??null)})})});var Mr=react.memo(({toolbar:a,loadingOverlay:e,onReady:t,children:r})=>{let{prefix:i}=h(),o=jotai.useAtomValue(M(i));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a!==false&&jsxRuntime.jsx(ke,{...a||{}}),jsxRuntime.jsxs("div",{className:"relative flex-1 w-full overflow-hidden",children:[o&&e&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/80",children:e}),jsxRuntime.jsx(We,{onReady:t})]}),r]})}),_r=react.forwardRef(({initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,toolbar:i,loadingOverlay:o,onReady:s,children:n,className:l},u)=>jsxRuntime.jsx("div",{className:`flex flex-col w-full h-full ${l??""}`,children:jsxRuntime.jsx(we,{ref:u,initConfig:a,widgetConstructor:e,libraryPath:t,customCssUrl:r,children:jsxRuntime.jsx(Mr,{toolbar:i,loadingOverlay:o,onReady:s,children:n})})}));var Fr=react.memo(({index:a})=>{let{prefix:e}=h(),t=jotai.useAtomValue(y(e)),r=jotai.useAtomValue(b(e)),o=t[a??r];return o?jsxRuntime.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:o.tickerSymbol||o.symbol}),jsxRuntime.jsx("span",{children:o.resolution})]}):null});function kr(){return h().chartManager}function Er(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),r=jotai.useAtomValue(y(a));return react.useMemo(()=>r.length?e.areaByIndex(t):null,[e,t,r])}function Or(){let{prefix:a,chartManager:e}=h(),t=jotai.useAtomValue(b(a)),i=jotai.useAtomValue(y(a))[t];return react.useMemo(()=>i?.tickerSymbol?e.symbolResolver?.getSymbolInfo(i.tickerSymbol)??null:null,[e,i?.tickerSymbol])}var yt=768;function Ct(a,e=yt){return a>0&&a<e}function ct(a){try{return ge(a)}catch{return ge(z(a))}}function Wr(a){return a instanceof Date?a.getTime():a}function mt(a,e){let t={time:ve(Wr(a.time),e),open:a.open,high:a.high,low:a.low,close:a.close};return a.volume!==void 0&&(t.volume=a.volume),t}function pt(a,e){return `${a.ticker??a.name}:${e}`}var Ne=class{source;options;liveListeners=new Map;lastHistoryBarTime=new Map;liveGeneration=0;constructor(e,t={}){this.source=e,this.options=t;}isMobileViewport(e){return Ct(e,this.options.mobileBreakpointPx)}async onReady(e){await this.options.onReady?.(e);}onDestroy(){for(let e of [...this.liveListeners.keys()])this.unsubscribeLiveBars(e);this.lastHistoryBarTime.clear(),this.options.onDestroy?.();}async resolveSymbol(e,t){return await this.options.resolveSymbol?.(e,t)??null}async getBars(e,t,r){return this.getHistoryBars(e,t,r)}subscribeBars(e,t,r,i,o){this.subscribeLiveBars(e,t,r,i,o);}unsubscribeBars(e){this.unsubscribeLiveBars(e);}getMarks(e,t,r,i,o){this.options.getMarks?.(e,t,r,i,o);}getFirstBarTime(e,t,r){return this.options.getFirstBarTime?.(e,t,r)??Promise.resolve()}async getHistoryBars(e,t,r){let i=await this.source.getHistory({symbolInfo:e,resolution:t,periodParams:r}),o=ct(t),s=(i??[]).map(n=>mt(n,o));if(s.length>0){let n=pt(e,t),l=Math.max(...s.map(c=>c.time)),u=this.lastHistoryBarTime.get(n)??0;l>u&&this.lastHistoryBarTime.set(n,l);}return s}subscribeLiveBars(e,t,r,i,o){this.unsubscribeLiveBars(i);let s=pt(e,t),n=ct(t),l=++this.liveGeneration;this.liveListeners.set(i,{symbolKey:s,lastBarTime:this.lastHistoryBarTime.get(s)??0,generation:l}),this.source.subscribe({symbolInfo:e,resolution:t,listenerGuid:i,onResetCacheNeededCallback:o},u=>{let c=this.liveListeners.get(i);if(!c||c.generation!==l)return;let v=mt(u,n),C=Math.max(c.lastBarTime,this.lastHistoryBarTime.get(c.symbolKey)??0);v.time<C||(c.lastBarTime=v.time,r(v));});}unsubscribeLiveBars(e){this.liveListeners.has(e)&&(this.liveListeners.delete(e),this.source.unsubscribe(e));}};exports.ALL_TV_CHART_RESOLUTIONS=w;exports.ChartAreaManager=k;exports.ChartDataFeed=Q;exports.ChartLibraryWidget=Y;exports.ChartManager=H;exports.ChartSaveLoadAdapter=Z;exports.ChartSettings=q;exports.ChartSettingsAdapter=j;exports.ChartSettingsStore=U;exports.ChartSymbolResolver=J;exports.ChartWidget=K;exports.ChartWidgetBridge=ee;exports.DEFAULT_TV_CHART_MOBILE_BREAKPOINT_PX=yt;exports.DEFAULT_TV_CHART_RESOLUTIONS=T;exports.ENABLED_TV_CHART_FEATURES=pe;exports.EventEmitter=X;exports.SUPPORTED_TV_CHART_LAYOUTS=ye;exports.TV_CHART_THEME_COLORS=S;exports.TradingView=_r;exports.TradingViewAreaTitle=Fr;exports.TradingViewConfig=Te;exports.TradingViewDatafeedAdapter=Ne;exports.TradingViewFullscreen=xe;exports.TradingViewKlineStyleSelect=Ie;exports.TradingViewLayout=Ee;exports.TradingViewOpenIndicator=Me;exports.TradingViewOpenSettings=_e;exports.TradingViewProvider=we;exports.TradingViewResolutions=Ae;exports.TradingViewSnapshot=Fe;exports.TradingViewToolbar=ke;exports.TradingViewToolbarProvider=Re;exports.TradingViewWidgetContainer=Oe;exports.TradingViewWidgetProvider=We;exports.TvChartErrorResetType=qe;exports.TvChartFeature=ae;exports.TvChartHandle=ce;exports.TvChartKlineStyle=re;exports.TvChartLayout=I;exports.TvChartPriceType=Ue;exports.TvChartQuoteType=ze;exports.TvChartTheme=$e;exports.TvChartType=te;exports.chartAreasFamily=y;exports.chartFullscreenFamily=_;exports.chartLoadingFamily=M;exports.chartPinnedResolutionsFamily=x;exports.chartSelectedIndexFamily=b;exports.chartShowDrawingToolbarFamily=L;exports.getTvChartLayoutReverse=fe;exports.getTvChartLibraryLayout=$;exports.getTvChartLibraryLocale=It;exports.getTvChartLibraryResolution=f;exports.getTvChartLibraryTheme=B;exports.getTvChartResolutionFrame=ge;exports.getTvChartResolutionReverse=z;exports.getTvChartTickTimestamp=ve;exports.isTvChartMobileViewport=Ct;exports.parseSymbol=de;exports.settingsBackgroundColorFamily=le;exports.settingsChartTypeFamily=A;exports.settingsDataFamily=N;exports.settingsDisabledFeaturesFamily=V;exports.settingsEnabledFeaturesFamily=F;exports.settingsLayoutFamily=P;exports.settingsLocaleFamily=ie;exports.settingsReverseColorFamily=ne;exports.settingsStorageIdFamily=O;exports.settingsThemeFamily=D;exports.settingsTickerSymbolFamily=se;exports.settingsTimezoneFamily=oe;exports.stringifySymbol=wt;exports.stringifySymbolShort=he;exports.useActiveAreaManager=Er;exports.useChartManager=kr;exports.useSymbolInfo=Or;exports.useTvChartContext=h;exports.useTvChartManager=Ot;exports.useTvChartPrefix=Wt;exports.useTvChartToolbarContext=G;exports.widgetReadyFamily=W;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map