@candleview/core 3.0.1 → 3.0.3

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.d.ts CHANGED
@@ -935,8 +935,8 @@ export declare interface CandleViewConfig {
935
935
  technologyPanel?: boolean;
936
936
  drawingPanel?: boolean;
937
937
  chartType?: MainChartType;
938
- activeTimeframe?: TimeframeEnum;
939
- currentTimezone?: TimezoneEnum;
938
+ timeframe?: TimeframeEnum;
939
+ timezone?: TimezoneEnum;
940
940
  onToolSelect?: (tool: string) => void;
941
941
  onTimeframeChange?: (timeframe: TimeframeEnum) => void;
942
942
  onChartTypeChange?: (type: MainChartType) => void;
@@ -7092,7 +7092,7 @@ declare interface IStaticMarkItem {
7092
7092
  options?: IStaticMarkOptions;
7093
7093
  }
7094
7094
 
7095
- declare interface IStaticMarkOptions {
7095
+ export declare interface IStaticMarkOptions {
7096
7096
  textColor?: string;
7097
7097
  backgroundColor?: string;
7098
7098
  isCircular?: boolean;
package/dist/index.js CHANGED
@@ -1777,8 +1777,8 @@
1777
1777
  align-items: center;
1778
1778
  justify-content: center;
1779
1779
  min-width: 0;
1780
- `,p.onmouseenter=()=>{p.style.background=t.buttonHover,p.style.transform="scale(1.05)",p.style.borderColor=t.panelBorder},p.onmouseleave=()=>{p.style.background="transparent",p.style.transform="scale(1)",p.style.borderColor="transparent"},p.onclick=()=>{this.setState({selectedEmoji:g.character}),this.options.onEmojiSelect?.(g.character),this.toolManager.handleDrawingToolSelect(this,"emoji"),this.closeModal("emoji")},u.appendChild(p)}),r.appendChild(u),this.emojiPickerRef=r,this.container.appendChild(r),this.bindOutsideClick(r,()=>this.closeModal("emoji"))}closeModal(t){const e={drawing:this.drawingModalRef,brush:this.brushModalRef,cursor:this.cursorModalRef,fibonacci:this.fibonacciModalRef,projectInfo:this.projectInfoModalRef,irregularShape:this.irregularShapeModalRef,textTool:this.textToolModalRef,aiTools:this.aiModalRef,script:this.scriptModalRef,emoji:this.emojiPickerRef};e[t]&&(e[t]?.remove(),e[t]=null),this.setState({isDrawingModalOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,isEmojiSelectPopUpOpen:!1,arrowButtonStates:{}})}closeAllModals(){this.closeModal("drawing"),this.closeModal("brush"),this.closeModal("cursor"),this.closeModal("fibonacci"),this.closeModal("projectInfo"),this.closeModal("irregularShape"),this.closeModal("textTool"),this.closeModal("aiTools"),this.closeModal("script"),this.closeModal("emoji"),this.setState({arrowButtonStates:{}}),this.element?.querySelectorAll(".arrow-button")?.forEach(e=>{e.innerHTML='<span style="font-size:18px;">›</span>'})}bindOutsideClick(t,e){const i=r=>{const s=r.target;t.contains(s)||s.closest(".tool-btn-drawing")||s.closest(".tool-btn-brush")||s.closest(".tool-btn-cursor")||s.closest(".tool-btn-fibonacci")||s.closest(".tool-btn-project-info")||s.closest(".tool-btn-irregular-shape")||s.closest(".tool-btn-text")||s.closest(".tool-btn-ai")||s.closest(".tool-btn-script")||s.closest(".tool-btn-emoji")||(e(),document.removeEventListener("click",i))};setTimeout(()=>{document.addEventListener("click",i)},0)}setActiveTool(t){if(t&&["emoji","text","price-event","time-event"].includes(t))return;const i=this.theme.getColors();this.element?.querySelectorAll(".tool-btn")?.forEach(s=>{const a=s;a.className.includes(`tool-btn-${t}`)?(a.style.background=i.buttonActive,a.style.color="#FFFFFF"):!a.className.includes("tool-btn-lock")&&!a.className.includes("tool-btn-eye")&&!a.className.includes("tool-btn-trash")&&!a.className.includes("tool-btn-terminal")&&(a.style.background="transparent",a.style.color=i.buttonColor)})}toggleLock(){this.setState({isMarkLocked:!this.state.isMarkLocked}),this.updateOtherTools()}toggleVisibility(){const t=!this.state.isMarkVisibility;this.setState({isMarkVisibility:t}),t?this.options.chart?.showAllMark?.():this.options.chart?.hideAllMark?.(),this.updateOtherTools()}updateOtherTools(){const t=this.element?.querySelector(".tool-btn-lock"),e=this.element?.querySelector(".tool-btn-eye");t&&(t.innerHTML=this.state.isMarkLocked?this.getIconSvg("lock"):this.getIconSvg("unlock")),e&&(e.innerHTML=this.state.isMarkVisibility?this.getIconSvg("eyeOpen"):this.getIconSvg("eyeClosed"))}getToolConfig(){return Yc(this.i18n)}findToolInGroups(t,e){for(const i of t){const r=i.tools.find(s=>s.id===e);if(r)return r}return null}getIconSvg(t){return{script:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6C5.44772 2 5 2.44772 5 3V21C5 21.5523 5.44772 22 6 22H18C18.5523 22 19 21.5523 19 21V8L14 2Z"/><path d="M14 2V8H19"/><path d="M9 12H15"/><path d="M9 16H12"/></svg>',emoji:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><circle cx="9" cy="9" r="1" fill="currentColor"/><circle cx="15" cy="9" r="1" fill="currentColor"/></svg>',ai:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="12" cy="20" rx="10" ry="3"/><circle cx="12" cy="10.5" r="8"/><path d="M7 8C9 6 15 6 17 8"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><path d="M12 5L14 2L16 5L19 6L16 7L14 10L12 7L9 6Z" fill="currentColor"/></svg>',terminal:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M6 9L9 12L6 15"/><path d="M11 15H15"/></svg>',lock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7V10"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',unlock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7" stroke-dasharray="12 12"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',eyeOpen:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"/><circle cx="12" cy="12" r="3"/></svg>',eyeClosed:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 12C2 12 6 4 13 4C20 4 24 12 24 12C24 12 20 20 13 20C6 20 2 12 2 12Z"/><path d="M4.93 4.93L19.07 19.07"/><path d="M9.76 14.24C8.79 13.27 8.79 11.73 9.76 10.76C10.73 9.79 12.27 9.79 13.24 10.76"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 6H5H21"/><path d="M8 6V4C8 3.44772 8.44772 3 9 3H15C15.5523 3 16 3.44772 16 4V6M19 6V20C19 20.5523 18.5523 21 18 21H6C5.44772 21 5 20.5523 5 20V6H19Z"/><path d="M10 11V17"/><path d="M14 11V17"/></svg>'}[t]||""}getModalTop(){const t=this.getContainerRect();return(this.element?.getBoundingClientRect()?.top||t.top)-t.top+50}updateContainerHeight(){if(this.element){const t=this.element.clientHeight;this.setState({containerHeight:t}),this.updateScrollButtons()}}updateScrollButtons(){if(this.scrollContainerRef){const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.scrollContainerRef,r=t>10,s=t<e-i-10;this.state.scrollButtonVisibility={showTop:r,showBottom:s},this.updateScrollButtonsUI()}}updateScrollButtonsUI(){this.scrollTopBtn&&(this.scrollTopBtn.style.display=this.state.scrollButtonVisibility.showTop?"flex":"none"),this.scrollBottomBtn&&(this.scrollBottomBtn.style.display=this.state.scrollButtonVisibility.showBottom?"flex":"none")}bindEvents(){this.scrollContainerRef&&this.scrollContainerRef.addEventListener("scroll",()=>this.updateScrollButtons()),document.addEventListener("click",this.handleClickOutside)}setState(t){Object.assign(this.state,t),(t.isMarkLocked!==void 0||t.isMarkVisibility!==void 0)&&this.updateOtherTools()}updateTheme(t){this.theme=t;const e=t.getColors(),i=t.isDark(),r=i?e.buttonHover:"#E1E5E9",s=i?e.panelBorder:"#EEEEEE";if(this.element){const l=this.element.querySelector("div");l&&(l.style.background=e.panelBg,l.style.borderRightColor=e.panelBorder)}this.scrollContainerRef?.querySelectorAll("div")?.forEach(l=>{const c=l;c.style.height==="1px"&&(c.style.background=s)}),this.element?.querySelectorAll(".tool-btn")?.forEach(l=>{const c=l,d=c.style.background===e.buttonActive;d||(c.style.background="transparent"),c.style.color=d?"#FFFFFF":e.buttonColor,c.onmouseenter=()=>{d||(c.style.background=r)},c.onmouseleave=()=>{d||(c.style.background="transparent")}}),this.element?.querySelectorAll(".arrow-button")?.forEach(l=>{const c=l;c.style.background="transparent",c.style.color=e.buttonColor,c.onmouseenter=d=>{d.target.style.background=r},c.onmouseleave=d=>{d.target.style.background="transparent"}});const h=document.getElementById("candleview-scrollbar-styles");h&&h.remove(),this.injectScrollbarStyles(),this.closeAllModals()}updateI18n(t){this.i18n=t,this.closeAllModals()}destroy(){this.closeAllModals(),this.element?.remove(),document.removeEventListener("click",this.handleClickOutside)}updateState(t){Object.assign(this.state,t)}isMarkLocked(){return this.state.isMarkLocked}getContainerRect(){return this.container.getBoundingClientRect()}getState(){return this.state}}const la={isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isAIModalOpen:!1,isMobileMenuOpen:!1,activeTimeframe:x.FIFTEEN_MINUTES,currentMainChartType:R.Candle,currentTimezone:Y.SHANGHAI,selectedSubChartIndicators:[],selectedMainChartIndicator:null,mainIndicatorsSearch:"",timezoneSearch:"",subChartIndicatorsSearch:"",chartTypeSearch:"",aiSearch:"",selectedMainIndicator:null,selectedChartMap:null,selectedSubIndicator:null,timeframeSections:{second:!0,minute:!0,hour:!0,day:!0,week:!0,month:!0},indicatorSections:{technicalIndicators:!0,chart:!0,subChartIndicators:!0},aiSections:{},scrollButtonVisibility:{showTop:!1,showBottom:!1},isDataLoading:!1,dataLoadProgress:0,loadError:null},ha={isDrawingModalOpen:!1,isEmojiSelectPopUpOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,selectedEmoji:"😀",selectedEmojiCategory:"smileys",selectedCursor:"crosshair",selectedAITool:null,selectedScriptTool:null,lastSelectedTools:{drawing:"line-segment",brush:"pencil",cursor:"crosshair",fibonacci:"fibonacci-retracement",projectInfo:"time-range",irregularShape:"rectangle",textTool:"text",aiTools:"describe-chart",script:"price-event"},arrowButtonStates:{},toolHoverStates:{},isMarkLocked:!1,isMarkVisibility:!0,toolSearch:"",containerHeight:0,scrollButtonVisibility:{showTop:!1,showBottom:!1},isBrushActive:!1};class $c{constructor(t){this.topPanel=null,this.leftPanel=null,this.topPanelState={...la},this.leftPanelState={...ha},this.config=t}init(){this.initTopPanel(),this.initLeftPanel()}initTopPanel(){this.config.technologyPanelContainer&&(this.topPanel=new Xc({container:this.config.technologyPanelContainer,rootContainer:this.config.rootContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.topPanelState,activeTimeframe:this.topPanelState.activeTimeframe,activeMainChartType:this.topPanelState.currentMainChartType,currentTimezone:this.topPanelState.currentTimezone,onStateChange:t=>this.updateTopPanelState(t),onTimeframeSelect:t=>this.config.onTimeframeChange(t),onChartTypeSelect:t=>this.config.onChartTypeChange(t),onMainChartIndicatorSelect:t=>this.config.onMainChartIndicatorSelect(t),onSubChartIndicatorSelect:t=>this.config.onSubChartIndicatorSelect(t),onThemeToggle:()=>this.config.onThemeToggle(),onCameraClick:async()=>{if(typeof window>"u"||typeof document>"u")return;const t=await this.config.candleView.captureScreenshot(),e=document.createElement("a");e.download=`candleview-screenshot-${Date.now()}.png`,e.href=t,e.click()},onFullscreenClick:()=>{if(typeof window>"u"||typeof document>"u")return;const e=this.config.candleView.dom.getRootEl();if(!e)return;!!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement)?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen():e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()},onTimezoneSelect:t=>this.config.onTimezoneSelect(t)}))}initLeftPanel(){if(!this.config.drawingPanelContainer)return;this.leftPanel=new zc({container:this.config.drawingPanelContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.leftPanelState,onStateChange:e=>{this.updateLeftPanelState(e),e.isBrushActive!==void 0&&(e.isBrushActive&&this.config.drawingPanelContainer?this.config.brushHint?.show(this.config.drawingPanelContainer):this.config.brushHint?.hide())},onToolSelect:e=>this.config.onToolSelect(e),chart:this.config.chartManager?.getChart()});const t=this.config.chartManager?.getChart();t&&(t.leftPanel=this.leftPanel)}updateTopPanelState(t){this.topPanelState={...this.topPanelState,...t}}updateLeftPanelState(t){this.leftPanelState={...this.leftPanelState,...t}}updateSubChartIndicatorsState(t){this.topPanel&&typeof this.topPanel.setSelectedSubChartIndicators=="function"&&this.topPanel.setSelectedSubChartIndicators(t)}getTopPanel(){return this.topPanel}updateTheme(t){this.topPanel?.updateTheme(t),this.leftPanel?.updateTheme(t)}updateI18n(t){this.topPanel?.updateI18n(t),this.leftPanel?.updateI18n(t)}destroy(){this.topPanel?.destroy(),this.leftPanel?.destroy(),this.topPanel=null,this.leftPanel=null}}class Qc{constructor(t,e,i){this.priceEventMarkManager=null,this.chartManager=t,this.dataManager=e,this.currentTheme=i}initManager(){const t=this.chartManager.getChart();!t||!t.chartSeries||(this.priceEventMarkManager=new oa({chartSeries:t.chartSeries,chart:t.chart,containerRef:t.containerRef?.current,onCloseDrawing:()=>{},onDoubleClick:()=>{}}))}register(t){const e=this.chartManager.getChart();if(!e||!e.chartSeries){console.warn("[CandleView] Chart not ready, will retry in 100ms"),setTimeout(()=>this.register(t),100);return}if(this.priceEventMarkManager||this.initManager(),!this.priceEventMarkManager){console.error("[CandleView] Failed to initialize PriceEventMarkManager");return}t.forEach(i=>{this.dataManager.addPriceEvent(i.price,i);const r={price:i.price,time:Date.now(),title:`Price: ${i.price}`,description:"",color:"#FF5722",backgroundColor:this.currentTheme.panel?.backgroundColor||"#1a1a2e",textColor:this.currentTheme.modal?.textColor||"#ffffff",fontSize:12,padding:8,arrowWidth:6,borderRadius:4,isPreview:!1,showPrice:!0},s=new na(r);e.chartSeries.series.attachPrimitive(s),this.priceEventMarkManager.priceEventMarks?.push(s),this.priceEventMarkManager.priceToMarkMap?.set(i.price,s)})}remove(t){if(this.priceEventMarkManager){const e=this.priceEventMarkManager.priceToMarkMap?.get(t);if(e){this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(e),this.priceEventMarkManager.priceToMarkMap?.delete(t);const i=this.priceEventMarkManager.priceEventMarks?.indexOf(e);i>-1&&this.priceEventMarkManager.priceEventMarks?.splice(i,1)}}this.dataManager.removePriceEvent(t)}clearAll(){this.priceEventMarkManager&&(this.priceEventMarkManager.priceEventMarks?.forEach(t=>{this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(t)}),this.priceEventMarkManager.priceEventMarks=[],this.priceEventMarkManager.priceToMarkMap?.clear()),this.dataManager.clearPriceEvents()}getAll(){return this.dataManager.getPriceEvents()}}class Gc{constructor(t,e){this.indicator=null,this.theme=t,this.i18n=e}injectStyles(){if(document.getElementById("candleview-brush-styles"))return;const t=document.createElement("style");t.id="candleview-brush-styles",t.textContent="@keyframes brush-pulse{0%{opacity:1;transform:scale(1)}50%{opacity:0.5;transform:scale(1.2)}100%{opacity:1;transform:scale(1)}}",document.head.appendChild(t)}show(t){if(this.indicator){this.indicator.style.display="flex";return}this.indicator=document.createElement("div"),this.indicator.className="candleview-brush-indicator",Object.assign(this.indicator.style,{position:"absolute",bottom:"38px",left:"60px",zIndex:"100",display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"20px",fontSize:"12px",pointerEvents:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',whiteSpace:"nowrap"}),this.indicator.innerHTML=`
1780
+ `,p.onmouseenter=()=>{p.style.background=t.buttonHover,p.style.transform="scale(1.05)",p.style.borderColor=t.panelBorder},p.onmouseleave=()=>{p.style.background="transparent",p.style.transform="scale(1)",p.style.borderColor="transparent"},p.onclick=()=>{this.setState({selectedEmoji:g.character}),this.options.onEmojiSelect?.(g.character),this.toolManager.handleDrawingToolSelect(this,"emoji"),this.closeModal("emoji")},u.appendChild(p)}),r.appendChild(u),this.emojiPickerRef=r,this.container.appendChild(r),this.bindOutsideClick(r,()=>this.closeModal("emoji"))}closeModal(t){const e={drawing:this.drawingModalRef,brush:this.brushModalRef,cursor:this.cursorModalRef,fibonacci:this.fibonacciModalRef,projectInfo:this.projectInfoModalRef,irregularShape:this.irregularShapeModalRef,textTool:this.textToolModalRef,aiTools:this.aiModalRef,script:this.scriptModalRef,emoji:this.emojiPickerRef};e[t]&&(e[t]?.remove(),e[t]=null),this.setState({isDrawingModalOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,isEmojiSelectPopUpOpen:!1,arrowButtonStates:{}})}closeAllModals(){this.closeModal("drawing"),this.closeModal("brush"),this.closeModal("cursor"),this.closeModal("fibonacci"),this.closeModal("projectInfo"),this.closeModal("irregularShape"),this.closeModal("textTool"),this.closeModal("aiTools"),this.closeModal("script"),this.closeModal("emoji"),this.setState({arrowButtonStates:{}}),this.element?.querySelectorAll(".arrow-button")?.forEach(e=>{e.innerHTML='<span style="font-size:18px;">›</span>'})}bindOutsideClick(t,e){const i=r=>{const s=r.target;t.contains(s)||s.closest(".tool-btn-drawing")||s.closest(".tool-btn-brush")||s.closest(".tool-btn-cursor")||s.closest(".tool-btn-fibonacci")||s.closest(".tool-btn-project-info")||s.closest(".tool-btn-irregular-shape")||s.closest(".tool-btn-text")||s.closest(".tool-btn-ai")||s.closest(".tool-btn-script")||s.closest(".tool-btn-emoji")||(e(),document.removeEventListener("click",i))};setTimeout(()=>{document.addEventListener("click",i)},0)}setActiveTool(t){if(t&&["emoji","text","price-event","time-event"].includes(t))return;const i=this.theme.getColors();this.element?.querySelectorAll(".tool-btn")?.forEach(s=>{const a=s;a.className.includes(`tool-btn-${t}`)?(a.style.background=i.buttonActive,a.style.color="#FFFFFF"):!a.className.includes("tool-btn-lock")&&!a.className.includes("tool-btn-eye")&&!a.className.includes("tool-btn-trash")&&!a.className.includes("tool-btn-terminal")&&(a.style.background="transparent",a.style.color=i.buttonColor)})}toggleLock(){this.setState({isMarkLocked:!this.state.isMarkLocked}),this.updateOtherTools()}toggleVisibility(){const t=!this.state.isMarkVisibility;this.setState({isMarkVisibility:t}),t?this.options.chart?.showAllMark?.():this.options.chart?.hideAllMark?.(),this.updateOtherTools()}updateOtherTools(){const t=this.element?.querySelector(".tool-btn-lock"),e=this.element?.querySelector(".tool-btn-eye");t&&(t.innerHTML=this.state.isMarkLocked?this.getIconSvg("lock"):this.getIconSvg("unlock")),e&&(e.innerHTML=this.state.isMarkVisibility?this.getIconSvg("eyeOpen"):this.getIconSvg("eyeClosed"))}getToolConfig(){return Yc(this.i18n)}findToolInGroups(t,e){for(const i of t){const r=i.tools.find(s=>s.id===e);if(r)return r}return null}getIconSvg(t){return{script:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6C5.44772 2 5 2.44772 5 3V21C5 21.5523 5.44772 22 6 22H18C18.5523 22 19 21.5523 19 21V8L14 2Z"/><path d="M14 2V8H19"/><path d="M9 12H15"/><path d="M9 16H12"/></svg>',emoji:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><circle cx="9" cy="9" r="1" fill="currentColor"/><circle cx="15" cy="9" r="1" fill="currentColor"/></svg>',ai:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="12" cy="20" rx="10" ry="3"/><circle cx="12" cy="10.5" r="8"/><path d="M7 8C9 6 15 6 17 8"/><circle cx="9" cy="9" r="1.5" fill="currentColor"/><path d="M12 5L14 2L16 5L19 6L16 7L14 10L12 7L9 6Z" fill="currentColor"/></svg>',terminal:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M6 9L9 12L6 15"/><path d="M11 15H15"/></svg>',lock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7V10"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',unlock:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="10" width="18" height="12" rx="2"/><path d="M7 10V7C7 4.23858 9.23858 2 12 2C14.7614 2 17 4.23858 17 7" stroke-dasharray="12 12"/><circle cx="12" cy="15" r="1" fill="currentColor"/><path d="M12 15V17"/></svg>',eyeOpen:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"/><circle cx="12" cy="12" r="3"/></svg>',eyeClosed:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 12C2 12 6 4 13 4C20 4 24 12 24 12C24 12 20 20 13 20C6 20 2 12 2 12Z"/><path d="M4.93 4.93L19.07 19.07"/><path d="M9.76 14.24C8.79 13.27 8.79 11.73 9.76 10.76C10.73 9.79 12.27 9.79 13.24 10.76"/></svg>',trash:'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 6H5H21"/><path d="M8 6V4C8 3.44772 8.44772 3 9 3H15C15.5523 3 16 3.44772 16 4V6M19 6V20C19 20.5523 18.5523 21 18 21H6C5.44772 21 5 20.5523 5 20V6H19Z"/><path d="M10 11V17"/><path d="M14 11V17"/></svg>'}[t]||""}getModalTop(){const t=this.getContainerRect();return(this.element?.getBoundingClientRect()?.top||t.top)-t.top+50}updateContainerHeight(){if(this.element){const t=this.element.clientHeight;this.setState({containerHeight:t}),this.updateScrollButtons()}}updateScrollButtons(){if(this.scrollContainerRef){const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.scrollContainerRef,r=t>10,s=t<e-i-10;this.state.scrollButtonVisibility={showTop:r,showBottom:s},this.updateScrollButtonsUI()}}updateScrollButtonsUI(){this.scrollTopBtn&&(this.scrollTopBtn.style.display=this.state.scrollButtonVisibility.showTop?"flex":"none"),this.scrollBottomBtn&&(this.scrollBottomBtn.style.display=this.state.scrollButtonVisibility.showBottom?"flex":"none")}bindEvents(){this.scrollContainerRef&&this.scrollContainerRef.addEventListener("scroll",()=>this.updateScrollButtons()),document.addEventListener("click",this.handleClickOutside)}setState(t){Object.assign(this.state,t),(t.isMarkLocked!==void 0||t.isMarkVisibility!==void 0)&&this.updateOtherTools()}updateTheme(t){this.theme=t;const e=t.getColors(),i=t.isDark(),r=i?e.buttonHover:"#E1E5E9",s=i?e.panelBorder:"#EEEEEE";if(this.element){const l=this.element.querySelector("div");l&&(l.style.background=e.panelBg,l.style.borderRightColor=e.panelBorder)}this.scrollContainerRef?.querySelectorAll("div")?.forEach(l=>{const c=l;c.style.height==="1px"&&(c.style.background=s)}),this.element?.querySelectorAll(".tool-btn")?.forEach(l=>{const c=l,d=c.style.background===e.buttonActive;d||(c.style.background="transparent"),c.style.color=d?"#FFFFFF":e.buttonColor,c.onmouseenter=()=>{d||(c.style.background=r)},c.onmouseleave=()=>{d||(c.style.background="transparent")}}),this.element?.querySelectorAll(".arrow-button")?.forEach(l=>{const c=l;c.style.background="transparent",c.style.color=e.buttonColor,c.onmouseenter=d=>{d.target.style.background=r},c.onmouseleave=d=>{d.target.style.background="transparent"}});const h=document.getElementById("candleview-scrollbar-styles");h&&h.remove(),this.injectScrollbarStyles(),this.closeAllModals()}updateI18n(t){this.i18n=t,this.closeAllModals()}destroy(){this.closeAllModals(),this.element?.remove(),document.removeEventListener("click",this.handleClickOutside)}updateState(t){Object.assign(this.state,t)}isMarkLocked(){return this.state.isMarkLocked}getContainerRect(){return this.container.getBoundingClientRect()}getState(){return this.state}}const la={isTimeframeModalOpen:!1,isIndicatorModalOpen:!1,isChartTypeModalOpen:!1,isSubChartModalOpen:!1,isTimezoneModalOpen:!1,isTimeFormatModalOpen:!1,isCloseTimeModalOpen:!1,isTradingDayModalOpen:!1,isAIModalOpen:!1,isMobileMenuOpen:!1,activeTimeframe:x.FIFTEEN_MINUTES,currentMainChartType:R.Candle,currentTimezone:Y.SHANGHAI,selectedSubChartIndicators:[],selectedMainChartIndicator:null,mainIndicatorsSearch:"",timezoneSearch:"",subChartIndicatorsSearch:"",chartTypeSearch:"",aiSearch:"",selectedMainIndicator:null,selectedChartMap:null,selectedSubIndicator:null,timeframeSections:{second:!0,minute:!0,hour:!0,day:!0,week:!0,month:!0},indicatorSections:{technicalIndicators:!0,chart:!0,subChartIndicators:!0},aiSections:{},scrollButtonVisibility:{showTop:!1,showBottom:!1},isDataLoading:!1,dataLoadProgress:0,loadError:null},ha={isDrawingModalOpen:!1,isEmojiSelectPopUpOpen:!1,isBrushModalOpen:!1,isCursorModalOpen:!1,isFibonacciModalOpen:!1,isProjectInfoModalOpen:!1,isIrregularShapeModalOpen:!1,isTextToolModalOpen:!1,isAIToolsModalOpen:!1,isScriptModalOpen:!1,selectedEmoji:"😀",selectedEmojiCategory:"smileys",selectedCursor:"crosshair",selectedAITool:null,selectedScriptTool:null,lastSelectedTools:{drawing:"line-segment",brush:"pencil",cursor:"crosshair",fibonacci:"fibonacci-retracement",projectInfo:"time-range",irregularShape:"rectangle",textTool:"text",aiTools:"describe-chart",script:"price-event"},arrowButtonStates:{},toolHoverStates:{},isMarkLocked:!1,isMarkVisibility:!0,toolSearch:"",containerHeight:0,scrollButtonVisibility:{showTop:!1,showBottom:!1},isBrushActive:!1};class $c{constructor(t){this.topPanel=null,this.leftPanel=null,this.topPanelState={...la},this.leftPanelState={...ha},this.config=t,this.topPanelState=t.topPanelState,this.leftPanelState=t.leftPanelState}init(){this.initTopPanel(),this.initLeftPanel()}initTopPanel(){this.config.technologyPanelContainer&&(this.topPanel=new Xc({container:this.config.technologyPanelContainer,rootContainer:this.config.rootContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.topPanelState,activeTimeframe:this.topPanelState.activeTimeframe,activeMainChartType:this.topPanelState.currentMainChartType,currentTimezone:this.topPanelState.currentTimezone,onStateChange:t=>this.updateTopPanelState(t),onTimeframeSelect:t=>this.config.onTimeframeChange(t),onChartTypeSelect:t=>this.config.onChartTypeChange(t),onMainChartIndicatorSelect:t=>this.config.onMainChartIndicatorSelect(t),onSubChartIndicatorSelect:t=>this.config.onSubChartIndicatorSelect(t),onThemeToggle:()=>this.config.onThemeToggle(),onCameraClick:async()=>{if(typeof window>"u"||typeof document>"u")return;const t=await this.config.candleView.captureScreenshot(),e=document.createElement("a");e.download=`candleview-screenshot-${Date.now()}.png`,e.href=t,e.click()},onFullscreenClick:()=>{if(typeof window>"u"||typeof document>"u")return;const e=this.config.candleView.dom.getRootEl();if(!e)return;!!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement)?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen():e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()},onTimezoneSelect:t=>this.config.onTimezoneSelect(t)}))}initLeftPanel(){if(!this.config.drawingPanelContainer)return;this.leftPanel=new zc({container:this.config.drawingPanelContainer,theme:this.config.theme,i18n:this.config.i18n,state:this.leftPanelState,onStateChange:e=>{this.updateLeftPanelState(e),e.isBrushActive!==void 0&&(e.isBrushActive&&this.config.drawingPanelContainer?this.config.brushHint?.show(this.config.drawingPanelContainer):this.config.brushHint?.hide())},onToolSelect:e=>this.config.onToolSelect(e),chart:this.config.chartManager?.getChart()});const t=this.config.chartManager?.getChart();t&&(t.leftPanel=this.leftPanel)}updateTopPanelState(t){this.topPanelState={...this.topPanelState,...t}}updateLeftPanelState(t){this.leftPanelState={...this.leftPanelState,...t}}updateSubChartIndicatorsState(t){this.topPanel&&typeof this.topPanel.setSelectedSubChartIndicators=="function"&&this.topPanel.setSelectedSubChartIndicators(t)}getTopPanel(){return this.topPanel}updateTheme(t){this.topPanel?.updateTheme(t),this.leftPanel?.updateTheme(t)}updateI18n(t){this.topPanel?.updateI18n(t),this.leftPanel?.updateI18n(t)}destroy(){this.topPanel?.destroy(),this.leftPanel?.destroy(),this.topPanel=null,this.leftPanel=null}}class Qc{constructor(t,e,i){this.priceEventMarkManager=null,this.chartManager=t,this.dataManager=e,this.currentTheme=i}initManager(){const t=this.chartManager.getChart();!t||!t.chartSeries||(this.priceEventMarkManager=new oa({chartSeries:t.chartSeries,chart:t.chart,containerRef:t.containerRef?.current,onCloseDrawing:()=>{},onDoubleClick:()=>{}}))}register(t){const e=this.chartManager.getChart();if(!e||!e.chartSeries){console.warn("[CandleView] Chart not ready, will retry in 100ms"),setTimeout(()=>this.register(t),100);return}if(this.priceEventMarkManager||this.initManager(),!this.priceEventMarkManager){console.error("[CandleView] Failed to initialize PriceEventMarkManager");return}t.forEach(i=>{this.dataManager.addPriceEvent(i.price,i);const r={price:i.price,time:Date.now(),title:`Price: ${i.price}`,description:"",color:"#FF5722",backgroundColor:this.currentTheme.panel?.backgroundColor||"#1a1a2e",textColor:this.currentTheme.modal?.textColor||"#ffffff",fontSize:12,padding:8,arrowWidth:6,borderRadius:4,isPreview:!1,showPrice:!0},s=new na(r);e.chartSeries.series.attachPrimitive(s),this.priceEventMarkManager.priceEventMarks?.push(s),this.priceEventMarkManager.priceToMarkMap?.set(i.price,s)})}remove(t){if(this.priceEventMarkManager){const e=this.priceEventMarkManager.priceToMarkMap?.get(t);if(e){this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(e),this.priceEventMarkManager.priceToMarkMap?.delete(t);const i=this.priceEventMarkManager.priceEventMarks?.indexOf(e);i>-1&&this.priceEventMarkManager.priceEventMarks?.splice(i,1)}}this.dataManager.removePriceEvent(t)}clearAll(){this.priceEventMarkManager&&(this.priceEventMarkManager.priceEventMarks?.forEach(t=>{this.chartManager.getChart()?.chartSeries?.series.detachPrimitive(t)}),this.priceEventMarkManager.priceEventMarks=[],this.priceEventMarkManager.priceToMarkMap?.clear()),this.dataManager.clearPriceEvents()}getAll(){return this.dataManager.getPriceEvents()}}class Gc{constructor(t,e){this.indicator=null,this.theme=t,this.i18n=e}injectStyles(){if(document.getElementById("candleview-brush-styles"))return;const t=document.createElement("style");t.id="candleview-brush-styles",t.textContent="@keyframes brush-pulse{0%{opacity:1;transform:scale(1)}50%{opacity:0.5;transform:scale(1.2)}100%{opacity:1;transform:scale(1)}}",document.head.appendChild(t)}show(t){if(this.indicator){this.indicator.style.display="flex";return}this.indicator=document.createElement("div"),this.indicator.className="candleview-brush-indicator",Object.assign(this.indicator.style,{position:"absolute",bottom:"38px",left:"60px",zIndex:"100",display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"20px",fontSize:"12px",pointerEvents:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',whiteSpace:"nowrap"}),this.indicator.innerHTML=`
1781
1781
  <span class="brush-pulse" style="display:inline-block;width:8px;height:8px;border-radius:50%;animation:brush-pulse 1.5s infinite;"></span>
1782
1782
  <span class="brush-text">${this.i18n.t("brushActive")||"Brush Mode"}</span>
1783
1783
  <span class="brush-hint" style="margin-left:4px;font-size:10px;opacity:0.7;">ESC</span>
1784
- `,this.updateTheme(),t.style.position="relative",t.appendChild(this.indicator)}hide(){this.indicator&&(this.indicator.style.display="none")}updateTheme(){if(!this.indicator)return;const t=this.theme.getColors();Object.assign(this.indicator.style,{background:t.panelBg,border:`1px solid ${t.panelBorder}`,color:t.textColor});const e=this.indicator.querySelector(".brush-pulse");e&&(e.style.background=this.theme.isDark()?"#FF6B35":"#E64A19")}updateI18n(t){this.i18n=t;const e=this.indicator?.querySelector(".brush-text");e&&(e.textContent=this.i18n.t("brushActive")||"Brush Mode")}}class Jc{constructor(t){this.panels=null,this.priceEvents=null,this.marks=null,this.brushHint=null,this.topPanelState={...la},this.leftPanelState={...ha},this.onTimeframeChangeCallback=null,this.isDataLoaded=!1,this.pendingData=null,this.config=t;const{container:e,isOwn:i}=this.resolveContainer(t);this.container=e,this.isOwnContainer=i,this.chartType=t.chartType||R.Candle,this.currentTimeframe=t.activeTimeframe||x.FIFTEEN_MINUTES,this.currentTimezone=t.currentTimezone||Y.NEW_YORK,this.topPanelState.activeTimeframe=this.currentTimeframe,this.topPanelState.currentTimezone=this.currentTimezone,this.topPanelState.currentMainChartType=this.chartType,this.theme=new zs(t.theme||"dark"),this.currentTheme=this.theme.isDark()?nt:ht,Ht(t.locale||"zh-cn"),this.i18n=ge(),this.dom=new Ma,this.initDOM(),this.candleViewChart=new Oc(this.dom.getChartContainerEl(),this.theme,this.i18n,this.chartType,t.title),this.candleViewChart.showLoader(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(5,"Creating DOM...")},1),this.dataManager=new _a(t.data||[],this.currentTimeframe,this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(20,"Data Manager Initialized")},2),this.candleViewChart.init(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(35,"Chart Initialized")},3),this.initPanels(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(50,"Panels Initialized")},4),this.marks=new fa(this.candleViewChart),this.marks.setTimezone(this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(65,"Marks Initialized")},5),this.brushHint=new Gc(this.theme,this.i18n),this.brushHint.injectStyles(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(80,"Brush Hint Initialized")},6),this.priceEvents=new Qc(this.candleViewChart,this.dataManager,this.currentTheme),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(95,"Price Events Initialized")},7),this.isDataLoaded=!0,this.candleViewChart.updateLoaderProgress(100,"Ready"),setTimeout(()=>{this.candleViewChart.hideLoader()},200),window.addEventListener("resize",()=>this.handleResize())}resolveContainer(t){if(t.container)return{container:t.container,isOwn:!1};if(t.containerSelector){const e=document.querySelector(t.containerSelector);if(!e)throw new Error(`[CandleView] Container not found: ${t.containerSelector}`);return{container:e,isOwn:!1}}if(t.id){const e=document.getElementById(t.id);if(!e)throw new Error(`[CandleView] Container not found: #${t.id}`);return{container:e,isOwn:!1}}if(t.parent){const e=this.createAutoContainer();return t.parent.appendChild(e),{container:e,isOwn:!0}}if(t.parentSelector){const e=document.querySelector(t.parentSelector);if(!e)throw new Error(`[CandleView] Parent not found: ${t.parentSelector}`);const i=this.createAutoContainer();return e.appendChild(i),{container:i,isOwn:!0}}throw new Error("[CandleView] Must provide container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;position:relative;overflow:hidden;",t}initDOM(){this.dom.create(this.container,this.theme.getColors())}initPanels(){this.panels=new $c({technologyPanelContainer:this.config.technologyPanel!==!1?this.dom.getTechnologyPanelContainer():null,drawingPanelContainer:this.config.drawingPanel!==!1?this.dom.getDrawingPanelContainer():null,rootContainer:this.dom.getRootEl(),theme:this.theme,i18n:this.i18n,chartManager:this.candleViewChart,dataManager:this.dataManager,brushHint:this.brushHint,marks:this.marks,candleView:this,onTimeframeChange:t=>this.handleTimeframeChange(t),onChartTypeChange:t=>this.handleChartTypeChange(t),onThemeToggle:()=>this.handleThemeToggle(),onToolSelect:t=>this.config.onToolSelect?.(t),onFullscreenClick:()=>this.config.onFullscreenClick?.(),onTimezoneSelect:t=>this.handleTimezoneSelect(t),onMainChartIndicatorSelect:t=>{this.candleViewChart.getChart()?.addOrUpdateMainChartIndicator(t),this.config.onMainChartIndicatorSelect?.(t)},onSubChartIndicatorSelect:t=>{const e=this.candleViewChart.getChart();if(!e)return;const i=this.getEnabledSubChartIndicators(),r=t.filter(a=>!i.includes(a));i.filter(a=>!t.includes(a)).forEach(a=>{e.removeSubChart(a)}),r.forEach(a=>{e.addSubChart(a,n=>{if(e){const o=e.chartPanesManager?.getParamsByIndicatorType(n)||[];e.openSubChartIndicatorsModal(o,n)}},n=>{e.removeSubChart(n),this.syncSubChartIndicatorState()})}),this.config.onSubChartIndicatorSelect?.(t)}}),this.panels.init()}handleTimeframeChange(t){this.onTimeframeChangeCallback?this.onTimeframeChangeCallback(this,t):(this.currentTimeframe=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimeframe")),this.dataManager.setTimeframe(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimeframeChange?.(t))}handleTimezoneSelect(t){this.currentTimezone=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimezone")),this.dataManager.setTimezone(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),this.marks?.setTimezone(t),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimezoneSelect?.(t)}handleChartTypeChange(t){this.chartType=t,this.isDataLoaded&&this.candleViewChart.updateChartType(t),this.config.onChartTypeChange?.(t)}handleThemeToggle(){const t=this.theme.isDark()?"light":"dark";this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme),this.config.onThemeToggle?.(t)}handleResize(){this.candleViewChart.getChart()?.handleResize()}setData(t,e=!1){if(!this.isDataLoaded){this.pendingData=t,this.dataManager.setData(t);return}e?(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"loadingData"),this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.hideLoader()},300)):(this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()))}updateData(t){if(!this.isDataLoaded){this.pendingData=[...this.pendingData||[],...t],this.dataManager.appendData(t);return}const e=this.candleViewChart.getChart(),i=e?.getChart()?.timeScale().getVisibleLogicalRange();this.dataManager.appendData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),i&&e?.getChart()&&setTimeout(()=>e.getChart()?.timeScale().setVisibleLogicalRange(i),0)}setTheme(t){this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme)}setLocale(t){Ht(t),this.i18n=ge(),this.panels?.updateI18n(this.i18n),this.isDataLoaded&&this.candleViewChart.updateI18n(this.i18n),this.brushHint?.updateI18n(this.i18n)}setOnTimeframeChangeCallback(t){this.onTimeframeChangeCallback=t}getOnTimeframeChangeCallback(){return this.onTimeframeChangeCallback}setChartType(t){this.isDataLoaded&&this.candleViewChart.updateChartType(t)}getCurrentTheme(){return this.currentTheme}getTopPanelState(){return{...this.topPanelState}}getLeftPanelState(){return{...this.leftPanelState}}getDrawingState(){return this.candleViewChart.getChart()?.getDrawingState()||null}setCursorType(t){this.candleViewChart.getChart()?.setCursorType(t)}showAllMarks(){this.candleViewChart.getChart()?.showAllMark()}hideAllMarks(){this.candleViewChart.getChart()?.hideAllMark()}clearAllMarks(){this.candleViewChart.getChart()?.clearAllMark()}clearCurrentTool(){}getCurrentTool(){return null}registerPriceEvents(t){this.isDataLoaded&&this.priceEvents?.register(t)}removePriceEventMarker(t){this.priceEvents?.remove(t)}clearAllPriceEventMarkers(){this.priceEvents?.clearAll()}getPriceEvents(){return this.priceEvents?.getAll()||[]}addStaticMark(t,e,i,r,s){this.marks?.addStaticMark(t,e,i,r,s)}addStaticMarks(t){this.marks?.addStaticMarks(t)}addTextMark(t,e,i,r){this.marks?.addTextMark(t,e,i,r)}addArrowMark(t,e,i){this.marks?.addArrowMark(t,e,i)}addTextMarks(t){this.marks?.addTextMarks(t)}addArrowMarks(t){this.marks?.addArrowMarks(t)}clearAllStaticMarks(){this.marks?.clearAllStaticMarks()}getStaticMarkCount(){return this.marks?.getStaticMarkCount()||0}getChart(){return this.candleViewChart.getChart()}setTitle(t){this.getChart()?.setTitle(t)}openMainChartIndicator(t,e){const i=this.candleViewChart.getChart();if(!i||!this.isDataLoaded)return;let r=null;switch(t){case w.MA:r={...$s,nonce:Date.now()};break;case w.EMA:r={...Qs,nonce:Date.now()};break;case w.BOLLINGER:r={...Gs,nonce:Date.now()};break;case w.ICHIMOKU:r={...Js,nonce:Date.now()};break;case w.DONCHIAN:r={...Zs,nonce:Date.now()};break;case w.ENVELOPE:r={...ta,nonce:Date.now()};break;case w.VWAP:r={...ea,nonce:Date.now()};break;case w.HEATMAP:r={...ia,nonce:Date.now()};break;case w.MARKETPROFILE:r={...ra,nonce:Date.now()};break;default:return}e&&r&&(r.parameters={...r.parameters,...e}),r&&i.addOrUpdateMainChartIndicator(r)}closeMainChartIndicator(t){const e=this.candleViewChart.getChart();if(!(!e||!this.isDataLoaded)){if(t===w.HEATMAP){e.hideHeatMap(),e.removeMainChartIndicator(t);return}if(t===w.MARKETPROFILE){e.hideMarketProfile(),e.removeMainChartIndicator(t);return}e.removeMainChartIndicator(t)}}closeAllMainChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;t.hideHeatMap(),t.removeMainChartIndicator(w.HEATMAP),t.hideMarketProfile(),t.removeMainChartIndicator(w.MARKETPROFILE),[w.MA,w.EMA,w.BOLLINGER,w.ICHIMOKU,w.DONCHIAN,w.ENVELOPE,w.VWAP].forEach(i=>{t.removeMainChartIndicator(i)})}openSubChartIndicator(t,e,i){const r=this.candleViewChart.getChart();!r||!this.isDataLoaded||(r.addSubChart(t,s=>{if(r){const a=r.chartPanesManager?.getParamsByIndicatorType(s)||[];r.openSubChartIndicatorsModal(a,s)}e?.(s)},s=>{r.removeSubChart(s),i?.(s)}),this.syncSubChartIndicatorState())}closeSubChartIndicator(t){const e=this.candleViewChart.getChart();!e||!this.isDataLoaded||(e.removeSubChart(t),this.syncSubChartIndicatorState())}closeAllSubChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;[B.RSI,B.MACD,B.VOLUME,B.SAR,B.KDJ,B.ATR,B.STOCHASTIC,B.CCI,B.BBWIDTH,B.ADX,B.OBV].forEach(i=>{t.removeSubChart(i)}),this.syncSubChartIndicatorState()}syncSubChartIndicatorState(){const t=this.getEnabledSubChartIndicators();if(this.panels&&this.panels.topPanel){const e=this.panels.topPanel;e&&typeof e.setSelectedSubChartIndicators=="function"&&e.setSelectedSubChartIndicators(t)}}isMainChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isMainChartIndicatorEnabled?.(t)??!1:!1}isSubChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isSubChartIndicatorEnabled?.(t)??!1:!1}getEnabledMainChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledMainChartIndicators?.()??[]:[]}getEnabledSubChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledSubChartIndicators?.()??[]:[]}async captureScreenshot(t="CandleView",e=.15){const i=this.dom.getChartContainerEl();if(!i)throw new Error("[CandleView] Chart container not found");await new Promise(l=>setTimeout(l,100));const r=i.getBoundingClientRect(),s=document.createElement("canvas");s.width=r.width*devicePixelRatio,s.height=r.height*devicePixelRatio;const a=s.getContext("2d");a.scale(devicePixelRatio,devicePixelRatio),a.fillStyle=this.theme.getColors().background,a.fillRect(0,0,r.width,r.height);const n=i.querySelectorAll("canvas");for(let l=0;l<n.length;l++){const c=n[l],d=c.getBoundingClientRect();a.drawImage(c,d.left-r.left,d.top-r.top,d.width,d.height)}const o=Math.max(40,Math.min(r.width/8,80));a.font=`${o}px Arial, sans-serif`,a.textAlign="center",a.textBaseline="middle";const h=this.theme.isDark();return a.fillStyle=h?`rgba(255, 255, 255, ${e})`:`rgba(0, 0, 0, ${e})`,a.fillText(t,r.width/2,r.height/2),s.toDataURL("image/png")}destroy(){this.panels?.destroy(),this.candleViewChart.destroy(),this.marks?.destroy(),this.dom.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove(),window.removeEventListener("resize",()=>this.handleResize())}}exports.CandleView=Jc;exports.ChartType=ms;exports.CursorType=j;exports.Dark=nt;exports.DataPreprocessor=Ce;exports.DrawingType=C;exports.EN=sa;exports.Light=ht;exports.MainChartIndicatorType=w;exports.MainChartType=R;exports.ScriptType=ks;exports.StaticMarkDirection=bt;exports.StaticMarkType=Z;exports.SubChartIndicatorType=B;exports.TIMEFRAME_CONFIGS=Ss;exports.TIMEZONE_CONFIGS=Ps;exports.Theme=zs;exports.TimeframeEnum=x;exports.TimezoneEnum=Y;exports.drawingTypeName=se;exports.getI18n=ge;exports.setLocale=Ht;exports.zhCN=Kt;
1784
+ `,this.updateTheme(),t.style.position="relative",t.appendChild(this.indicator)}hide(){this.indicator&&(this.indicator.style.display="none")}updateTheme(){if(!this.indicator)return;const t=this.theme.getColors();Object.assign(this.indicator.style,{background:t.panelBg,border:`1px solid ${t.panelBorder}`,color:t.textColor});const e=this.indicator.querySelector(".brush-pulse");e&&(e.style.background=this.theme.isDark()?"#FF6B35":"#E64A19")}updateI18n(t){this.i18n=t;const e=this.indicator?.querySelector(".brush-text");e&&(e.textContent=this.i18n.t("brushActive")||"Brush Mode")}}class Jc{constructor(t){this.panels=null,this.priceEvents=null,this.marks=null,this.brushHint=null,this.topPanelState={...la},this.leftPanelState={...ha},this.onTimeframeChangeCallback=null,this.isDataLoaded=!1,this.pendingData=null,this.config=t;const{container:e,isOwn:i}=this.resolveContainer(t);this.container=e,this.isOwnContainer=i,this.chartType=t.chartType||R.Candle,this.currentTimeframe=t.timeframe||x.FIFTEEN_MINUTES,this.currentTimezone=t.timezone||Y.NEW_YORK,this.topPanelState.activeTimeframe=this.currentTimeframe,this.topPanelState.currentTimezone=this.currentTimezone,this.topPanelState.currentMainChartType=this.chartType,this.theme=new zs(t.theme||"dark"),this.currentTheme=this.theme.isDark()?nt:ht,Ht(t.locale||"zh-cn"),this.i18n=ge(),this.dom=new Ma,this.initDOM(),this.candleViewChart=new Oc(this.dom.getChartContainerEl(),this.theme,this.i18n,this.chartType,t.title),this.candleViewChart.showLoader(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(5,"Creating DOM...")},1),this.dataManager=new _a(t.data||[],this.currentTimeframe,this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(20,"Data Manager Initialized")},2),this.candleViewChart.init(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(35,"Chart Initialized")},3),this.initPanels(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(50,"Panels Initialized")},4),this.marks=new fa(this.candleViewChart),this.marks.setTimezone(this.currentTimezone),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(65,"Marks Initialized")},5),this.brushHint=new Gc(this.theme,this.i18n),this.brushHint.injectStyles(),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(80,"Brush Hint Initialized")},6),this.priceEvents=new Qc(this.candleViewChart,this.dataManager,this.currentTheme),setTimeout(()=>{this.candleViewChart.updateLoaderProgress(95,"Price Events Initialized")},7),this.isDataLoaded=!0,this.candleViewChart.updateLoaderProgress(100,"Ready"),setTimeout(()=>{this.candleViewChart.hideLoader()},200),window.addEventListener("resize",()=>this.handleResize())}resolveContainer(t){if(t.container)return{container:t.container,isOwn:!1};if(t.containerSelector){const e=document.querySelector(t.containerSelector);if(!e)throw new Error(`[CandleView] Container not found: ${t.containerSelector}`);return{container:e,isOwn:!1}}if(t.id){const e=document.getElementById(t.id);if(!e)throw new Error(`[CandleView] Container not found: #${t.id}`);return{container:e,isOwn:!1}}if(t.parent){const e=this.createAutoContainer();return t.parent.appendChild(e),{container:e,isOwn:!0}}if(t.parentSelector){const e=document.querySelector(t.parentSelector);if(!e)throw new Error(`[CandleView] Parent not found: ${t.parentSelector}`);const i=this.createAutoContainer();return e.appendChild(i),{container:i,isOwn:!0}}throw new Error("[CandleView] Must provide container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;position:relative;overflow:hidden;",t}initDOM(){this.dom.create(this.container,this.theme.getColors())}initPanels(){this.panels=new $c({technologyPanelContainer:this.config.technologyPanel!==!1?this.dom.getTechnologyPanelContainer():null,drawingPanelContainer:this.config.drawingPanel!==!1?this.dom.getDrawingPanelContainer():null,rootContainer:this.dom.getRootEl(),theme:this.theme,i18n:this.i18n,chartManager:this.candleViewChart,dataManager:this.dataManager,brushHint:this.brushHint,marks:this.marks,candleView:this,topPanelState:this.topPanelState,leftPanelState:this.leftPanelState,onTimeframeChange:t=>this.handleTimeframeChange(t),onChartTypeChange:t=>this.handleChartTypeChange(t),onThemeToggle:()=>this.handleThemeToggle(),onToolSelect:t=>this.config.onToolSelect?.(t),onFullscreenClick:()=>this.config.onFullscreenClick?.(),onTimezoneSelect:t=>this.handleTimezoneSelect(t),onMainChartIndicatorSelect:t=>{this.candleViewChart.getChart()?.addOrUpdateMainChartIndicator(t),this.config.onMainChartIndicatorSelect?.(t)},onSubChartIndicatorSelect:t=>{const e=this.candleViewChart.getChart();if(!e)return;const i=this.getEnabledSubChartIndicators(),r=t.filter(a=>!i.includes(a));i.filter(a=>!t.includes(a)).forEach(a=>{e.removeSubChart(a)}),r.forEach(a=>{e.addSubChart(a,n=>{if(e){const o=e.chartPanesManager?.getParamsByIndicatorType(n)||[];e.openSubChartIndicatorsModal(o,n)}},n=>{e.removeSubChart(n),this.syncSubChartIndicatorState()})}),this.config.onSubChartIndicatorSelect?.(t)}}),this.panels.init()}handleTimeframeChange(t){this.onTimeframeChangeCallback?this.onTimeframeChangeCallback(this,t):(this.currentTimeframe=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimeframe")),this.dataManager.setTimeframe(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimeframeChange?.(t))}handleTimezoneSelect(t){this.currentTimezone=t,this.isDataLoaded&&(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"changingTimezone")),this.dataManager.setTimezone(t),this.dataManager.refresh(),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),this.marks?.setTimezone(t),setTimeout(()=>this.marks?.reapplyMarks(),100),this.isDataLoaded&&setTimeout(()=>{this.candleViewChart.hideLoader()},300),this.config.onTimezoneSelect?.(t)}handleChartTypeChange(t){this.chartType=t,this.isDataLoaded&&this.candleViewChart.updateChartType(t),this.config.onChartTypeChange?.(t)}handleThemeToggle(){const t=this.theme.isDark()?"light":"dark";this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme),this.config.onThemeToggle?.(t)}handleResize(){this.candleViewChart.getChart()?.handleResize()}setData(t,e=!1){if(!this.isDataLoaded){this.pendingData=t,this.dataManager.setData(t);return}e?(this.candleViewChart.showLoader(),this.candleViewChart.updateLoaderProgress(100,"loadingData"),this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),setTimeout(()=>{this.candleViewChart.hideLoader()},300)):(this.dataManager.setData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()))}updateData(t){if(!this.isDataLoaded){this.pendingData=[...this.pendingData||[],...t],this.dataManager.appendData(t);return}const e=this.candleViewChart.getChart(),i=e?.getChart()?.timeScale().getVisibleLogicalRange();this.dataManager.appendData(t),this.candleViewChart.setData(this.dataManager.getPreprocessedData()),i&&e?.getChart()&&setTimeout(()=>e.getChart()?.timeScale().setVisibleLogicalRange(i),0)}setTheme(t){this.theme.setTheme(t),this.currentTheme=this.theme.isDark()?nt:ht,this.dom.getRootEl()?.style.setProperty("background",this.theme.getColors().background),this.isDataLoaded&&this.candleViewChart.updateTheme(this.theme),this.brushHint?.updateTheme(),this.panels?.updateTheme(this.theme)}setLocale(t){Ht(t),this.i18n=ge(),this.panels?.updateI18n(this.i18n),this.isDataLoaded&&this.candleViewChart.updateI18n(this.i18n),this.brushHint?.updateI18n(this.i18n)}setOnTimeframeChangeCallback(t){this.onTimeframeChangeCallback=t}getOnTimeframeChangeCallback(){return this.onTimeframeChangeCallback}setChartType(t){this.isDataLoaded&&this.candleViewChart.updateChartType(t)}getCurrentTheme(){return this.currentTheme}getTopPanelState(){return{...this.topPanelState}}getLeftPanelState(){return{...this.leftPanelState}}getDrawingState(){return this.candleViewChart.getChart()?.getDrawingState()||null}setCursorType(t){this.candleViewChart.getChart()?.setCursorType(t)}showAllMarks(){this.candleViewChart.getChart()?.showAllMark()}hideAllMarks(){this.candleViewChart.getChart()?.hideAllMark()}clearAllMarks(){this.candleViewChart.getChart()?.clearAllMark()}clearCurrentTool(){}getCurrentTool(){return null}registerPriceEvents(t){this.isDataLoaded&&this.priceEvents?.register(t)}removePriceEventMarker(t){this.priceEvents?.remove(t)}clearAllPriceEventMarkers(){this.priceEvents?.clearAll()}getPriceEvents(){return this.priceEvents?.getAll()||[]}addStaticMark(t,e,i,r,s){this.marks?.addStaticMark(t,e,i,r,s)}addStaticMarks(t){this.marks?.addStaticMarks(t)}addTextMark(t,e,i,r){this.marks?.addTextMark(t,e,i,r)}addArrowMark(t,e,i){this.marks?.addArrowMark(t,e,i)}addTextMarks(t){this.marks?.addTextMarks(t)}addArrowMarks(t){this.marks?.addArrowMarks(t)}clearAllStaticMarks(){this.marks?.clearAllStaticMarks()}getStaticMarkCount(){return this.marks?.getStaticMarkCount()||0}getChart(){return this.candleViewChart.getChart()}setTitle(t){this.getChart()?.setTitle(t)}openMainChartIndicator(t,e){const i=this.candleViewChart.getChart();if(!i||!this.isDataLoaded)return;let r=null;switch(t){case w.MA:r={...$s,nonce:Date.now()};break;case w.EMA:r={...Qs,nonce:Date.now()};break;case w.BOLLINGER:r={...Gs,nonce:Date.now()};break;case w.ICHIMOKU:r={...Js,nonce:Date.now()};break;case w.DONCHIAN:r={...Zs,nonce:Date.now()};break;case w.ENVELOPE:r={...ta,nonce:Date.now()};break;case w.VWAP:r={...ea,nonce:Date.now()};break;case w.HEATMAP:r={...ia,nonce:Date.now()};break;case w.MARKETPROFILE:r={...ra,nonce:Date.now()};break;default:return}e&&r&&(r.parameters={...r.parameters,...e}),r&&i.addOrUpdateMainChartIndicator(r)}closeMainChartIndicator(t){const e=this.candleViewChart.getChart();if(!(!e||!this.isDataLoaded)){if(t===w.HEATMAP){e.hideHeatMap(),e.removeMainChartIndicator(t);return}if(t===w.MARKETPROFILE){e.hideMarketProfile(),e.removeMainChartIndicator(t);return}e.removeMainChartIndicator(t)}}closeAllMainChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;t.hideHeatMap(),t.removeMainChartIndicator(w.HEATMAP),t.hideMarketProfile(),t.removeMainChartIndicator(w.MARKETPROFILE),[w.MA,w.EMA,w.BOLLINGER,w.ICHIMOKU,w.DONCHIAN,w.ENVELOPE,w.VWAP].forEach(i=>{t.removeMainChartIndicator(i)})}openSubChartIndicator(t,e,i){const r=this.candleViewChart.getChart();!r||!this.isDataLoaded||(r.addSubChart(t,s=>{if(r){const a=r.chartPanesManager?.getParamsByIndicatorType(s)||[];r.openSubChartIndicatorsModal(a,s)}e?.(s)},s=>{r.removeSubChart(s),i?.(s)}),this.syncSubChartIndicatorState())}closeSubChartIndicator(t){const e=this.candleViewChart.getChart();!e||!this.isDataLoaded||(e.removeSubChart(t),this.syncSubChartIndicatorState())}closeAllSubChartIndicators(){const t=this.candleViewChart.getChart();if(!t||!this.isDataLoaded)return;[B.RSI,B.MACD,B.VOLUME,B.SAR,B.KDJ,B.ATR,B.STOCHASTIC,B.CCI,B.BBWIDTH,B.ADX,B.OBV].forEach(i=>{t.removeSubChart(i)}),this.syncSubChartIndicatorState()}syncSubChartIndicatorState(){const t=this.getEnabledSubChartIndicators();if(this.panels&&this.panels.topPanel){const e=this.panels.topPanel;e&&typeof e.setSelectedSubChartIndicators=="function"&&e.setSelectedSubChartIndicators(t)}}isMainChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isMainChartIndicatorEnabled?.(t)??!1:!1}isSubChartIndicatorEnabled(t){const e=this.candleViewChart.getChart();return e?e.isSubChartIndicatorEnabled?.(t)??!1:!1}getEnabledMainChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledMainChartIndicators?.()??[]:[]}getEnabledSubChartIndicators(){const t=this.candleViewChart.getChart();return t?t.getEnabledSubChartIndicators?.()??[]:[]}async captureScreenshot(t="CandleView",e=.15){const i=this.dom.getChartContainerEl();if(!i)throw new Error("[CandleView] Chart container not found");await new Promise(l=>setTimeout(l,100));const r=i.getBoundingClientRect(),s=document.createElement("canvas");s.width=r.width*devicePixelRatio,s.height=r.height*devicePixelRatio;const a=s.getContext("2d");a.scale(devicePixelRatio,devicePixelRatio),a.fillStyle=this.theme.getColors().background,a.fillRect(0,0,r.width,r.height);const n=i.querySelectorAll("canvas");for(let l=0;l<n.length;l++){const c=n[l],d=c.getBoundingClientRect();a.drawImage(c,d.left-r.left,d.top-r.top,d.width,d.height)}const o=Math.max(40,Math.min(r.width/8,80));a.font=`${o}px Arial, sans-serif`,a.textAlign="center",a.textBaseline="middle";const h=this.theme.isDark();return a.fillStyle=h?`rgba(255, 255, 255, ${e})`:`rgba(0, 0, 0, ${e})`,a.fillText(t,r.width/2,r.height/2),s.toDataURL("image/png")}destroy(){this.panels?.destroy(),this.candleViewChart.destroy(),this.marks?.destroy(),this.dom.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove(),window.removeEventListener("resize",()=>this.handleResize())}}exports.CandleView=Jc;exports.ChartType=ms;exports.CursorType=j;exports.Dark=nt;exports.DataPreprocessor=Ce;exports.DrawingType=C;exports.EN=sa;exports.Light=ht;exports.MainChartIndicatorType=w;exports.MainChartType=R;exports.ScriptType=ks;exports.StaticMarkDirection=bt;exports.StaticMarkType=Z;exports.SubChartIndicatorType=B;exports.TIMEFRAME_CONFIGS=Ss;exports.TIMEZONE_CONFIGS=Ps;exports.Theme=zs;exports.TimeframeEnum=x;exports.TimezoneEnum=Y;exports.drawingTypeName=se;exports.getI18n=ge;exports.setLocale=Ht;exports.zhCN=Kt;
package/dist/index.mjs CHANGED
@@ -57482,7 +57482,7 @@ const ia = {
57482
57482
  };
57483
57483
  class $c {
57484
57484
  constructor(t) {
57485
- this.topPanel = null, this.leftPanel = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.config = t;
57485
+ this.topPanel = null, this.leftPanel = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.config = t, this.topPanelState = t.topPanelState, this.leftPanelState = t.leftPanelState;
57486
57486
  }
57487
57487
  init() {
57488
57488
  this.initTopPanel(), this.initLeftPanel();
@@ -57679,7 +57679,7 @@ class Zc {
57679
57679
  constructor(t) {
57680
57680
  this.panels = null, this.priceEvents = null, this.marks = null, this.brushHint = null, this.topPanelState = { ...ia }, this.leftPanelState = { ...ra }, this.onTimeframeChangeCallback = null, this.isDataLoaded = !1, this.pendingData = null, this.config = t;
57681
57681
  const { container: e, isOwn: i } = this.resolveContainer(t);
57682
- this.container = e, this.isOwnContainer = i, this.chartType = t.chartType || R.Candle, this.currentTimeframe = t.activeTimeframe || E.FIFTEEN_MINUTES, this.currentTimezone = t.currentTimezone || Y.NEW_YORK, this.topPanelState.activeTimeframe = this.currentTimeframe, this.topPanelState.currentTimezone = this.currentTimezone, this.topPanelState.currentMainChartType = this.chartType, this.theme = new Jo(t.theme || "dark"), this.currentTheme = this.theme.isDark() ? lt : ut, de(t.locale || "zh-cn"), this.i18n = ii(), this.dom = new pa(), this.initDOM(), this.candleViewChart = new Oc(this.dom.getChartContainerEl(), this.theme, this.i18n, this.chartType, t.title), this.candleViewChart.showLoader(), setTimeout(() => {
57682
+ this.container = e, this.isOwnContainer = i, this.chartType = t.chartType || R.Candle, this.currentTimeframe = t.timeframe || E.FIFTEEN_MINUTES, this.currentTimezone = t.timezone || Y.NEW_YORK, this.topPanelState.activeTimeframe = this.currentTimeframe, this.topPanelState.currentTimezone = this.currentTimezone, this.topPanelState.currentMainChartType = this.chartType, this.theme = new Jo(t.theme || "dark"), this.currentTheme = this.theme.isDark() ? lt : ut, de(t.locale || "zh-cn"), this.i18n = ii(), this.dom = new pa(), this.initDOM(), this.candleViewChart = new Oc(this.dom.getChartContainerEl(), this.theme, this.i18n, this.chartType, t.title), this.candleViewChart.showLoader(), setTimeout(() => {
57683
57683
  this.candleViewChart.updateLoaderProgress(5, "Creating DOM...");
57684
57684
  }, 1), this.dataManager = new Pa(
57685
57685
  t.data || [],
@@ -57744,6 +57744,8 @@ class Zc {
57744
57744
  brushHint: this.brushHint,
57745
57745
  marks: this.marks,
57746
57746
  candleView: this,
57747
+ topPanelState: this.topPanelState,
57748
+ leftPanelState: this.leftPanelState,
57747
57749
  onTimeframeChange: (t) => this.handleTimeframeChange(t),
57748
57750
  onChartTypeChange: (t) => this.handleChartTypeChange(t),
57749
57751
  onThemeToggle: () => this.handleThemeToggle(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@candleview/core",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "A time-series data visualization and charting engine designed specifically for the financial industry.",
5
5
  "keywords": [
6
6
  "Finance",