@363045841yyt/klinechart 0.6.10 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/favicon.ico +0 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +20330 -8582
- package/dist/klinechart.css +1 -1
- package/dist/mock-stock-data.json +1 -0
- package/dist/src/components/IndicatorSelector.vue.d.ts +0 -1
- package/dist/src/components/KLineChart.vue.d.ts +1 -1
- package/dist/src/config/chartSettings.d.ts +6 -0
- package/dist/src/core/chart.d.ts +208 -11
- package/dist/src/core/draw/pixelAlign.d.ts +7 -7
- package/dist/src/core/drawing/plugin.d.ts +19 -0
- package/dist/src/core/indicators/calculators.d.ts +129 -0
- package/dist/src/core/indicators/chaikinVolState.d.ts +18 -0
- package/dist/src/core/indicators/cmfState.d.ts +16 -0
- package/dist/src/core/indicators/fibState.d.ts +26 -0
- package/dist/src/core/indicators/hvState.d.ts +18 -0
- package/dist/src/core/indicators/ichimokuState.d.ts +44 -0
- package/dist/src/core/indicators/indicatorDefinitionRegistry.d.ts +30 -0
- package/dist/src/core/indicators/indicatorMetadata.d.ts +81 -0
- package/dist/src/core/indicators/indicatorRegistry.d.ts +57 -0
- package/dist/src/core/indicators/indicatorRuntime.d.ts +35 -0
- package/dist/src/core/indicators/mfiState.d.ts +16 -0
- package/dist/src/core/indicators/obvState.d.ts +14 -0
- package/dist/src/core/indicators/parkinsonState.d.ts +18 -0
- package/dist/src/core/indicators/pivotState.d.ts +29 -0
- package/dist/src/core/indicators/pvtState.d.ts +14 -0
- package/dist/src/core/indicators/rocState.d.ts +16 -0
- package/dist/src/core/indicators/rsiState.d.ts +4 -0
- package/dist/src/core/indicators/scheduler.d.ts +82 -3
- package/dist/src/core/indicators/stateComposer.d.ts +51 -0
- package/dist/src/core/indicators/structureState.d.ts +43 -0
- package/dist/src/core/indicators/trixState.d.ts +20 -0
- package/dist/src/core/indicators/vmaState.d.ts +16 -0
- package/dist/src/core/indicators/volumeProfileState.d.ts +34 -0
- package/dist/src/core/indicators/vwapState.d.ts +16 -0
- package/dist/src/core/indicators/workerProtocol.d.ts +198 -1
- package/dist/src/core/indicators/zonesState.d.ts +26 -0
- package/dist/src/core/renderers/Indicator/cci.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/chaikinVol.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/cmf.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/ene.d.ts +0 -8
- package/dist/src/core/renderers/Indicator/fastk.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/fib.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/hv.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/ichimoku.d.ts +5 -0
- package/dist/src/core/renderers/Indicator/index.d.ts +27 -1
- package/dist/src/core/renderers/Indicator/kst.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/macd.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/mfi.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/mom.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/obv.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/parkinson.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/pivot.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/pvt.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/roc.d.ts +5 -0
- package/dist/src/core/renderers/Indicator/rsi.d.ts +3 -2
- package/dist/src/core/renderers/Indicator/scale/indicator_scale.d.ts +4 -1
- package/dist/src/core/renderers/Indicator/stoch.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/structure.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/subPaneConfig.d.ts +2 -2
- package/dist/src/core/renderers/Indicator/trix.d.ts +5 -0
- package/dist/src/core/renderers/Indicator/vma.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/volumeProfile.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/vwap.d.ts +4 -0
- package/dist/src/core/renderers/Indicator/wmsr.d.ts +2 -1
- package/dist/src/core/renderers/Indicator/zones.d.ts +4 -0
- package/dist/src/core/renderers/candle.d.ts +2 -1
- package/dist/src/core/theme/colors.d.ts +207 -228
- package/dist/src/plugin/PluginHost.d.ts +3 -0
- package/dist/src/plugin/types.d.ts +6 -0
- package/dist/src/semantic/types.d.ts +59 -0
- package/dist/src/utils/kLineDraw/MA.d.ts +5 -10
- package/dist/src/utils/kLineDraw/axis.d.ts +7 -7
- package/dist/src/utils/kLineDraw/grid.d.ts +2 -2
- package/dist/src/utils/kLineDraw/kLine.d.ts +1 -1
- package/dist/src/utils/kline/format.d.ts +4 -7
- package/package.json +111 -103
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vue`);var t=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[EventBus] Error in handler for "${e}":`,t)}})}once(e,t){let n=r=>{this.off(e,n),t(r)};this.on(e,n)}clear(){this.listeners.clear()}listenerCount(e){return this.listeners.get(e)?.size??0}},n=class e extends Error{constructor(e){super(e),this.name=`HttpError`}static isHttpError(t){return t instanceof e}};async function r(e,t){let r=new URLSearchParams;if(t?.params)for(let[e,n]of Object.entries(t.params))n!==void 0&&n!==``&&r.set(e,String(n));let i=r.toString(),a=i?`${e}?${i}`:e,o=new AbortController,s=t?.timeout?setTimeout(()=>o.abort(),t.timeout):void 0;try{let e=await fetch(a,{signal:o.signal});if(!e.ok)throw new n(`HTTP ${e.status}: ${e.statusText}`);return{data:await e.json()}}catch(e){throw e instanceof n?e:e?.name===`AbortError`?new n(`请求超时`):new n(e?.message||`网络请求失败`)}finally{clearTimeout(s)}}function i(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function a(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function o(e){return e&&{daily:`d`,weekly:`w`,monthly:`m`,5:`5`,15:`15`,30:`30`,60:`60`}[e]||`d`}function s(e){return e&&{qfq:`2`,hfq:`1`,none:`3`}[e]||`3`}function c(e){let t=i(e.date),n=e=>{let t=parseFloat(e);return Number.isNaN(t)?0:t};return{timestamp:a(t),stockCode:e.code,open:n(e.open),high:n(e.high),low:n(e.low),close:n(e.close),volume:n(e.volume),turnover:n(e.amount),changePercent:n(e.pctChg),turnoverRate:n(e.turn)}}var l=``,u=`/api/stock/kdata`;async function d(){let e=await(await fetch(`mock-stock-data.json`)).json();if(e.success&&e.data)return e.data.map(c).sort((e,t)=>e.timestamp-t.timestamp);throw Error(`Mock data failed`)}async function f(e){if(typeof window<`u`&&window.location.hostname.includes(`github.io`))return d();let{timeout:t,...n}=e,i=`${l}${u}`,a={stock_code:n.symbol,start_date:n.start_date,end_date:n.end_date,frequency:o(n.period),adjustflag:s(n.adjust),timeout:t};try{let e=(await r(i,{params:a,timeout:t?t*1e3:void 0})).data;if(!e.success)throw Error(`获取K线数据失败: ${e.error_msg||`未知错误`} (code: ${e.error_code})`);return!e.data||e.data.length===0?[]:e.data.map(c).sort((e,t)=>e.timestamp-t.timestamp)}catch(e){try{return await d()}catch{}throw Error(`获取K线数据失败: ${e instanceof Error?e.message:String(e)}`)}}function p(e){return e.map(e=>({timestamp:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,stockCode:e.stockCode,volume:e.volume,turnover:e.turnover,amplitude:e.amplitude,changePercent:e.changePercent,changeAmount:e.changeAmount,turnoverRate:e.turnoverRate})).sort((e,t)=>e.timestamp-t.timestamp)}var m=`/api/public/stock_zh_a_hist`;function h(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function g(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function _(e){return{timestamp:g(h(e.日期)),stockCode:e.股票代码,open:e.开盘,close:e.收盘,high:e.最高,low:e.最低,volume:e.成交量,turnover:e.成交额,amplitude:e.振幅,changePercent:e.涨跌幅,changeAmount:e.涨跌额,turnoverRate:e.换手率}}async function v(e){try{let{timeout:t,...n}=e;return(await r(m,{params:n,timeout:t?t*1e3:void 0})).data.map(_)}catch(e){throw Error(`获取K线数据失败: ${e instanceof Error?e.message:String(e)}`)}}var y=new class{set(e,t){let n={data:t,timestamp:Date.now()};localStorage.setItem(e,JSON.stringify(n))}get(e,t=3600*1e3){let n=localStorage.getItem(e);if(!n)return null;try{let r=JSON.parse(n);return Date.now()-r.timestamp>t?(localStorage.removeItem(e),null):r.data}catch{return localStorage.removeItem(e),null}}remove(e){localStorage.removeItem(e)}clear(){localStorage.clear()}generateKey(e,t){return`${e}:${Object.keys(t).sort().map(e=>`${e}:${t[e]}`).join(`|`)}`}},b=class{name=`baostock`;async fetchKLineData(e){return f({symbol:this.addMarketPrefix(e.symbol),start_date:e.startDate,end_date:e.endDate,period:{daily:`daily`,weekly:`weekly`,monthly:`monthly`,"5min":`5`,"15min":`15`,"30min":`30`,"60min":`60`}[e.period]||`daily`,adjust:e.adjust,timeout:e.timeout})}addMarketPrefix(e){return/^(6|68)\d{5}$/.test(e)?`sh.${e}`:/^(0|3)\d{5}$/.test(e)?`sz.${e}`:e}},x=class{name=`dongcai`;async fetchKLineData(e){let t=e.startDate.replace(/-/g,``),n=e.endDate.replace(/-/g,``),r={daily:`daily`,weekly:`weekly`,monthly:`monthly`}[e.period];if(!r)throw Error(`东财数据源不支持周期: ${e.period}`);return p(await v({symbol:e.symbol,start_date:t,end_date:n,period:r,adjust:e.adjust===`none`?void 0:e.adjust,timeout:e.timeout}))}},S=class{static instances=new Map;static create(e){if(!this.instances.has(e))switch(e){case`baostock`:this.instances.set(e,new b);break;case`dongcai`:this.instances.set(e,new x);break;default:throw Error(`未知的数据源类型: ${e}`)}return this.instances.get(e)}},C=3600*1e3;function w(e,t){return y.generateKey(`kline:${e}`,{symbol:t.symbol,startDate:t.startDate,endDate:t.endDate,period:t.period,adjust:t.adjust})}async function T(e,t,n=!0){if(typeof window<`u`&&window.location.hostname.includes(`github.io`))return console.log(`[KLine] GitHub Pages 模式,加载 mock 数据`),d();let r=w(e,t);if(n){let e=y.get(r,C);if(e)return console.log(`[KLineCache] 命中缓存: ${r}`),e}try{let i=await S.create(e).fetchKLineData(t);return n&&i.length>0&&(y.set(r,i),console.log(`[KLineCache] 写入缓存: ${r}, ${i.length} 条数据`)),i}catch(e){let t=y.get(r,2**53-1);if(t)return console.warn(`[KLineCache] 网络请求失败,使用缓存回退: ${r}`,e),t;throw e}}var E=[`__proto__`,`constructor`,`prototype`],D=/^(#[0-9a-fA-F]{3,8}|rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*[\d.]+\s*\))$/,O={SH:/^(600|601|603|605|688)\d{3}$/,SZ:/^(000|001|002|003|300|301)\d{3}$/,BJ:/^(83|87|43|82)\d{4}$/};function k(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var A=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,j=class e{limits;_ajv=null;constructor(){this.limits={maxJsonSize:64*1024,maxIndicators:10,maxCustomMarkers:100}}async getAjv(){return this._ajv||=(async()=>{let e=(await import(`ajv`)).default,t=new e({allErrors:!0,allowUnionTypes:!0});t.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)});let n=await Promise.resolve().then(()=>require(`./schema-CzmPW09E.cjs`));return t.addSchema(n.default||n),t})(),this._ajv}validateRawInput(e){return(typeof TextEncoder<`u`?new TextEncoder().encode(e).byteLength:e.length*3)>this.limits.maxJsonSize?{valid:!1,errors:[`JSON payload too large (max 64KB)`]}:{valid:!0}}async validate(e){if(!e||typeof e!=`object`)return{valid:!1,errors:[`Config must be an object`]};let t=this.checkPrototypePollution(e);if(!t.valid)return t;try{let t=await this.getAjv();if(!t.validate(`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,e))return{valid:!1,errors:t.errors?.map(e=>`${e.instancePath} ${e.message}`)||[`Schema validation failed`]}}catch{return{valid:!1,errors:[`Schema validation unavailable (ajv not loaded)`]}}return{valid:!0}}securityCheck(e){let t=[],n=this.checkDateRange(e.data);n.valid||t.push(...n.errors||[]);let r=this.checkSymbol(e.data);if(r.valid||t.push(...r.errors||[]),e.indicators&&(e.indicators.main?.length||0)+(e.indicators.sub?.length||0)>this.limits.maxIndicators&&t.push(`Too many indicators (max ${this.limits.maxIndicators})`),(e.markers?.customMarkers?.length||0)>this.limits.maxCustomMarkers&&t.push(`Too many custom markers (max ${this.limits.maxCustomMarkers})`),e.markers?.customMarkers)for(let n of e.markers.customMarkers){if(n.style){let e=this.checkMarkerStyle(n.style,n.id);t.push(...e)}let e=this.checkMarkerDate(n.date,n.id);t.push(...e)}return{passed:t.length===0,violations:t.length>0?t:void 0}}checkPrototypePollution(e,t=``){if(!e||typeof e!=`object`)return{valid:!0};let n=[];for(let r of Object.keys(e))E.includes(r)&&n.push(`Forbidden key "${r}" found at ${t}`);return n.length>0?{valid:!1,errors:n}:{valid:!0}}checkDateRange(e){let t=[],n=new Date(e.startDate),r=new Date(e.endDate);if(isNaN(n.getTime())&&t.push(`Invalid startDate: ${e.startDate}`),isNaN(r.getTime())&&t.push(`Invalid endDate: ${e.endDate}`),t.length>0)return{valid:!1,errors:t};let i=k(e.period),a=Math.ceil((r.getTime()-n.getTime())/(1e3*60*60*24));return a>i&&t.push(`Date range exceeds maximum for period "${e.period}" (max ${i} days, got ${a})`),a<0&&t.push(`endDate must be after startDate`),t.length>0?{valid:!1,errors:t}:{valid:!0}}checkSymbol(e){let{symbol:t,exchange:n}=e;if(n){if(!O[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(O).some(e=>e.test(t)))return{valid:!1,errors:[`Invalid symbol format: "${t}"`]};return{valid:!0}}checkMarkerStyle(e,t){let n=[],r=[`fillColor`,`strokeColor`,`textColor`];for(let i of r){let r=e[i];typeof r==`string`&&!D.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(A)for(let i of r){let r=e[i];typeof r==`string`&&(A.fillStyle=`#000000`,A.fillStyle=r,A.fillStyle===`#000000`&&r!==`#000000`&&!r.startsWith(`#000`)&&n.push(`Potentially unsafe ${i} in marker "${t}": ${r}`))}return n}static DATE_PATTERN=/^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;checkMarkerDate(t,n){let r=[];if(!e.DATE_PATTERN.test(t))return r.push(`Invalid date format in marker "${n}": ${t} (expected YYYY-MM-DD or YYYY-MM-DD HH:mm)`),r;let i=t.includes(` `),a;if(i)a=new Date(t);else{let[e,n,r]=t.split(`-`).map(Number);a=new Date(Date.UTC(e,n-1,r))}return isNaN(a.getTime())&&r.push(`Invalid date value in marker "${n}": ${t}`),r}},M=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new j,this.events=new t}async applyConfig(e){let t=await this.validator.validate(e);if(!t.valid)return{success:!1,errors:t.errors};let n=this.validator.securityCheck(e);if(!n.passed)return{success:!1,errors:n.violations};this.events.emit(`config:loading`,void 0);try{return await this.doApplyConfig(e),this.events.emit(`config:ready`,void 0),{success:!0}}catch(e){return this.events.emit(`config:error`,e),{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async doApplyConfig(e){console.log(`[Semantic] doApplyConfig start, data config:`,e.data);let t=await T(e.data.source,{symbol:e.data.symbol,startDate:e.data.startDate,endDate:e.data.endDate,period:e.data.period,adjust:e.data.adjust});console.log(`[Semantic] fetched data:`,t.length,`items`),this.chart.updateData(t),e.indicators&&(console.log(`[Semantic] applying indicators:`,e.indicators),this.applyIndicators(e.indicators.main,e.indicators.sub)),e.markers&&(console.log(`[Semantic] applying markers:`,e.markers.customMarkers?.length,`markers`),this.applyMarkers(e.markers.customMarkers,e.data.period)),e.chart&&this.applyChartOptions(e.chart),console.log(`[Semantic] doApplyConfig done`)}applyIndicators(e,t){if(e){for(let t of e)if(t.enabled)switch(t.type){case`MA`:this.applyMAIndicator(t);break;case`BOLL`:this.applyBOLLIndicator(t);break;case`EXPMA`:this.applyEXPMAIndicator(t);break;case`ENE`:this.applyENEIndicator(t);break}}if(this.chart.clearSubPanes(),t)for(let e of t)this.applySubIndicator(e)}applyMAIndicator(e){let t=e.params?.periods||[5,10,20,30,60],n={};for(let e of t)e===5?n.ma5=!0:e===10?n.ma10=!0:e===20?n.ma20=!0:e===30?n.ma30=!0:e===60&&(n.ma60=!0);console.log(`[Semantic] applyMAIndicator, periods:`,t,`maFlags:`,n),this.chart.updateRendererConfig(`ma`,n)}applyBOLLIndicator(e){let t={period:e.params?.period||20,multiplier:e.params?.multiplier||2};this.chart.updateRendererConfig(`boll`,t)}applyEXPMAIndicator(e){let t={fastPeriod:e.params?.fastPeriod||12,slowPeriod:e.params?.slowPeriod||50};this.chart.updateRendererConfig(`expma`,t)}applyENEIndicator(e){let t={period:e.params?.period||10,deviation:e.params?.deviation||11};this.chart.updateRendererConfig(`ene`,t)}applySubIndicator(e){if(!e.enabled)return;let{type:t,params:n}=e,r=`${t}_0`;this.chart.createSubPane(r,t,n)||console.warn(`[Semantic] Failed to create sub pane for ${t}`)}applyMarkers(e,t){if(!e||e.length===0){this.chart.clearCustomMarkers();return}let n=e.map(e=>({id:e.id,date:e.date,timestamp:N(e.date,t||`daily`),shape:e.shape,groupKey:e.groupKey,offset:e.offset,style:e.style,label:e.label,metadata:e.metadata}));this.chart.updateCustomMarkers(n)}applyChartOptions(e){e.autoScrollToRight}};function N(e,t){if(e.includes(` `)){let[t,n]=e.split(` `),r=t.split(`-`).map(Number),i=r[0],a=r[1],o=r[2],s=n.split(`:`).map(Number),c=s[0],l=s[1];return Date.UTC(i,a-1,o,c-8,l,0,0)}else{let t=e.split(`-`).map(Number),n=t[0],r=t[1],i=t[2];return Date.UTC(n,r-1,i,-8,0,0,0)}}var P={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function F(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||P[t];switch(e.fillStyle=o,e.strokeStyle=s,e.lineWidth=a.lineWidth||1,a.opacity!==void 0&&(e.globalAlpha=a.opacity),t){case`arrow_up`:ne(e,n,r,c);break;case`arrow_down`:re(e,n,r,c);break;case`circle`:ie(e,n,r,c);break;case`rectangle`:ae(e,n,r,c);break;case`diamond`:oe(e,n,r,c);break;case`flag`:se(e,n,r,c);break}e.globalAlpha=1}var I=2.5,L=4;function ee(e,t,n,r,i,a,o=!1){let s=t.fontSize||12,c=a.textColor||`#333333`,l=i/2;e.font=`${s}px sans-serif`,e.fillStyle=c,e.textBaseline=`middle`;let u=i*I,d=te(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-L;break;case`right`:p=n+l+f/2+L;break;case`top`:m=r-l-s/2-L;break;case`bottom`:m=r+l+s/2+L;break;default:m=o?r-l-s/2-L:r+l+s/2+L;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function te(e,t,n){if(e.measureText(t).width<=n)return t;let r=e.measureText(`…`).width,i=0,a=t.length;for(;i<a;){let o=Math.ceil((i+a)/2),s=t.slice(0,o);e.measureText(s).width+r<=n?i=o:a=o-1}return t.slice(0,i)+`…`}function ne(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t-r/2,n+r/2),e.lineTo(t+r/2,n+r/2),e.closePath(),e.fill()}function re(e,t,n,r){e.beginPath(),e.moveTo(t,n+r/2),e.lineTo(t-r/2,n-r/2),e.lineTo(t+r/2,n-r/2),e.closePath(),e.fill()}function ie(e,t,n,r){e.beginPath(),e.arc(t,n,r/2,0,Math.PI*2),e.fill()}function ae(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function oe(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t+r/2,n),e.lineTo(t,n+r/2),e.lineTo(t-r/2,n),e.closePath(),e.fill()}function se(e,t,n,r){e.beginPath(),e.moveTo(t-r/4,n+r/2),e.lineTo(t-r/4,n-r/2),e.stroke(),e.beginPath(),e.moveTo(t-r/4,n-r/2),e.lineTo(t+r/2,n-r/4),e.lineTo(t-r/4,n),e.closePath(),e.fill()}function ce(e,t,n,r,i,a){let o=a/2;switch(n){case`circle`:let n=e-r,a=t-i;return n*n+a*a<=o*o;default:return e>=r-o&&e<=r+o&&t>=i-o&&t<=i+o}}var le=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function ue(e){return{id:e.id,role:e.role,capabilities:{...e.capabilities},top:e.top,height:e.height,yAxis:{priceToY:t=>e.yAxis.priceToY(t),yToPrice:t=>e.yAxis.yToPrice(t),getPaddingTop:()=>e.yAxis.getPaddingTop(),getPaddingBottom:()=>e.yAxis.getPaddingBottom(),getPriceOffset:()=>e.yAxis.getPriceOffset(),getDisplayRange:t=>e.yAxis.getDisplayRange(t),getScaleType:()=>e.yAxis.getScaleType()},priceRange:e.priceRange}}var de=Symbol(`global-pane`),R={LAST_PRICE_LABEL:-25,SYSTEM_YAXIS:-20,SYSTEM_XAXIS:-20,BACKGROUND:0,GRID:10,INDICATOR:30,MAIN:50,INDICATOR_SCALE:55,OVERLAY:80,FOREGROUND:100,SYSTEM_BORDER:120,SYSTEM_CROSSHAIR:150},fe=class{plugins=new Map;register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);let n={plugin:e,config:{enabled:!0,priority:0,...t},state:`registered`};return this.plugins.set(e.name,n),n}unregister(e){return this.plugins.delete(e)}get(e){return this.plugins.get(e)}getPlugin(e){return this.plugins.get(e)?.plugin}getAll(){return Array.from(this.plugins.values())}getEnabled(){return this.getAll().filter(e=>e.config?.enabled!==!1)}updateState(e,t,n){let r=this.plugins.get(e);r&&(r.state=t,n&&(r.error=n))}has(e){return this.plugins.has(e)}clear(){this.plugins.clear()}},pe=class{hooks=new Map;tap(e,t,n=0){this.hooks.has(e)||this.hooks.set(e,[]);let r=this.hooks.get(e);r.push({name:e,fn:t,priority:n}),r.sort((e,t)=>e.priority-t.priority)}untap(e,t){let n=this.hooks.get(e);if(n){let e=n.findIndex(e=>e.fn===t);e!==-1&&n.splice(e,1)}}async call(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=await a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}callSync(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}clear(){this.hooks.clear()}hookCount(e){return this.hooks.get(e)?.length??0}},z=class{configs=new Map;defaults=new Map;registerDefaults(e,t){this.defaults.set(e,{...t}),this.configs.has(e)||this.configs.set(e,new Map);let n=this.configs.get(e);for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r)}get(e,t,n){let r=this.configs.get(e);if(r?.has(t))return r.get(t);let i=this.defaults.get(e);return i&&t in i?i[t]:n}set(e,t,n){this.configs.has(e)||this.configs.set(e,new Map),this.configs.get(e).set(t,n)}setAll(e,t){for(let[n,r]of Object.entries(t))this.set(e,n,r)}getAll(e){let t=this.configs.get(e);return{...this.defaults.get(e)||{},...t?Object.fromEntries(t):{}}}clear(e){e?(this.configs.delete(e),this.defaults.delete(e)):(this.configs.clear(),this.defaults.clear())}},me=class{states=new Map;ownerNamespaces=new Map;setState(e,t,n){this.states.set(e,t)}getState(e){return this.states.get(e)}clearState(e){this.states.delete(e)}registerStateOwner(e,t){this.ownerNamespaces.set(e,new Set(t))}clearByOwner(e){let t=this.ownerNamespaces.get(e);t&&(t.forEach(e=>{this.states.delete(e)}),this.ownerNamespaces.delete(e))}clear(){this.states.clear(),this.ownerNamespaces.clear()}},he=class{registry;eventBus;hookSystem;configManager;stateStore;isDestroyed=!1;logger;constructor(e){this.registry=new fe,this.eventBus=new t,this.hookSystem=new pe,this.configManager=new z,this.stateStore=new me,this.logger=e??console}events={on:(e,t)=>{this.eventBus.on(e,t)},off:(e,t)=>{this.eventBus.off(e,t)},emit:(e,t)=>{this.eventBus.emit(e,t)},once:(e,t)=>{this.eventBus.once(e,t)}};hooks={tap:(e,t,n=0)=>{this.hookSystem.tap(e,t,n)},untap:(e,t)=>{this.hookSystem.untap(e,t)},call:async(e,t,n)=>this.hookSystem.call(e,t,n),callSync:(e,t,n)=>this.hookSystem.callSync(e,t,n)};getConfig(e,t,n){return this.configManager.get(e,t,n)}setConfig(e,t,n){this.configManager.set(e,t,n)}getPlugin(e){return this.registry.getPlugin(e)}log(e,t,...n){let r=`[${new Date().toISOString()}] [${e.toUpperCase()}]`;this.logger[e](`${r} ${t}`,...n)}setSharedState(e,t,n){this.stateStore.setState(e,t,n)}getSharedState(e){return this.stateStore.getState(e)}clearSharedState(e){this.stateStore.clearState(e)}registerStateOwner(e,t){this.stateStore.registerStateOwner(e,t)}clearByOwner(e){this.stateStore.clearByOwner(e)}async use(e,t){if(this.ensureNotDestroyed(),this.registry.has(e.name))throw Error(`Plugin "${e.name}" is already installed`);try{let n=this.registry.register(e,t);t&&this.configManager.setAll(e.name,t),await this.hooks.call(`plugin:beforeInstall`,{plugin:e,config:t},{throwOnError:!0}),await e.install(this,n.config),this.registry.updateState(e.name,`installed`),await this.hooks.call(`plugin:afterInstall`,{plugin:e,config:t},{throwOnError:!0}),this.log(`info`,`Plugin "${e.name}" installed successfully`)}catch(t){throw this.registry.updateState(e.name,`error`,t instanceof Error?t:Error(String(t))),this.log(`error`,`Failed to install plugin "${e.name}":`,t),t}}async remove(e){this.ensureNotDestroyed();let t=this.registry.get(e);if(!t)throw Error(`Plugin "${e}" is not installed`);try{await this.hooks.call(`plugin:beforeUninstall`,{name:e},{throwOnError:!0}),t.plugin.uninstall&&await t.plugin.uninstall(),this.registry.unregister(e),this.configManager.clear(e),await this.hooks.call(`plugin:afterUninstall`,{name:e},{throwOnError:!0}),this.log(`info`,`Plugin "${e}" removed successfully`)}catch(t){throw this.log(`error`,`Failed to remove plugin "${e}":`,t),t}}getPlugins(){return this.registry.getAll()}getState(e){return this.registry.get(e)?.state}async destroy(){if(!this.isDestroyed){for(let e of this.registry.getAll())try{e.plugin.uninstall&&await e.plugin.uninstall()}catch(t){this.log(`error`,`Error uninstalling "${e.plugin.name}":`,t)}this.registry.clear(),this.eventBus.clear(),this.hookSystem.clear(),this.configManager.clear(),this.stateStore.clear(),this.isDestroyed=!0,this.log(`info`,`PluginHost destroyed`)}}ensureNotDestroyed(){if(this.isDestroyed)throw Error(`PluginHost has been destroyed`)}};function ge(e){return new he(e)}function _e(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function B(e,t,n){let r=_e(e,n),i=Math.round(t*n),a=r+i,o=i;return{kWidthPx:r,kGapPx:i,unitPx:a,startXPx:o,kWidthLogical:r/n,kGapLogical:i/n,unitLogical:a/n,startXLogical:o/n}}function ve(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=B(n,r,a),c=e*a,l=t*a;return{start:Math.max(0,Math.floor((c-s)/o)-1),end:Math.min(i,Math.ceil((c+l-s)/o)+1)}}function ye(e,t,n){let r=-1/0,i=1/0;for(let a=t;a<n&&a<e.length;a++){let t=e[a];t&&(t.high>r&&(r=t.high),t.low<i&&(i=t.low))}return!Number.isFinite(r)||!Number.isFinite(i)?{maxPrice:100,minPrice:0}:{maxPrice:r,minPrice:i}}var be={logicalOffset:4,coordOffset:1e-4};function xe(e){return Math.abs(e)<1e-15}function V(e,t){let n=Math.abs(e);if(xe(n))return 0;let r=Math.log10(n+t.coordOffset)+t.logicalOffset;return e<0?-r:r}function Se(e,t){let n=Math.abs(e);if(xe(n))return 0;let r=10**(n-t.logicalOffset)-t.coordOffset;return e<0?-r:r}function Ce(e){if(e===null)return{...be};let t=Math.abs(e.maxPrice-e.minPrice);if(t>=1||t<1e-15)return{...be};let n=Math.ceil(Math.abs(Math.log10(t))),r=be.logicalOffset+n;return{logicalOffset:r,coordOffset:1/10**r}}function we(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}var Te=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;scaleType=`linear`;logFormula=Ce(null);setRange(e){if(this.range=e,this.scaleType===`log`&&e.minPrice>0){let t=Ce(e);if(!we(t,this.logFormula)){let n=V(e.minPrice,this.logFormula),r=(V(e.maxPrice,this.logFormula)+n)/2+this.priceOffset;this.logFormula=t;let i=V(e.minPrice,this.logFormula),a=(V(e.maxPrice,this.logFormula)+i)/2;this.priceOffset=this.clampOffset(r-a)}}}setHeight(e){this.height=Math.max(1,e)}setPadding(e,t){this.paddingTop=Math.max(0,e),this.paddingBottom=Math.max(0,t)}getRange(){return this.range}getPaddingTop(){return this.paddingTop}getPaddingBottom(){return this.paddingBottom}setPriceOffset(e){this.priceOffset=this.clampOffset(e)}getPriceOffset(){return this.priceOffset}resetPriceOffset(){this.priceOffset=0}clampOffset(e){if(this.scaleType===`log`&&this.range.minPrice>0){let t=V(this.range.minPrice,this.logFormula),n=V(this.range.maxPrice,this.logFormula)-t;if(n<=0)return 0;let r=n*(1+1/this.verticalScale)/2;return Math.max(-r,Math.min(r,e))}let t=this.range.maxPrice-this.range.minPrice;if(t<=0)return 0;let n=t*(1+1/this.verticalScale)/2;return Math.max(-n,Math.min(n,e))}scaleByDelta(e){if(!Number.isFinite(e)||e===0)return;let t=Math.exp(-e*.01),n=this.verticalScale*t;this.verticalScale=Math.min(8,Math.max(.2,n)),this.priceOffset=this.clampOffset(this.priceOffset)}getVerticalScale(){return this.verticalScale}setScaleType(e){if(e!==this.scaleType){if(e===`log`&&this.range.minPrice>0){this.logFormula=Ce(this.range);let e=(this.range.maxPrice+this.range.minPrice)/2,t=e+this.priceOffset;this.priceOffset=V(t,this.logFormula)-V(e,this.logFormula),this.priceOffset=this.clampOffset(this.priceOffset)}else if(e===`linear`&&this.scaleType===`log`){let e=V(this.range.minPrice,this.logFormula),t=Se((V(this.range.maxPrice,this.logFormula)+e)/2+this.priceOffset,this.logFormula),n=(this.range.maxPrice+this.range.minPrice)/2;this.priceOffset=t-n,this.priceOffset=this.clampOffset(this.priceOffset)}this.scaleType=e}}getScaleType(){return this.scaleType}getDisplayRange(e){let{minPrice:t,maxPrice:n}=e??this.range;if(this.scaleType===`log`&&t>0){let e=V(t,this.logFormula),r=V(n,this.logFormula),i=r-e||1,a=(r+e)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:Se(a+o,this.logFormula),minPrice:Se(a-o,this.logFormula)}}let r=n-t||1,i=(n+t)/2+this.priceOffset,a=r/(2*this.verticalScale);return{maxPrice:i+a,minPrice:i-a}}priceToY(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i;if(this.scaleType===`log`&&n>0){let r=V(n,this.logFormula),a=V(t,this.logFormula);i=(V(e,this.logFormula)-r)/(a-r||1)}else i=(e-n)/(t-n||1);return this.paddingTop+r*(1-i)}yToPrice(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i=1-(e-this.paddingTop)/r;if(this.scaleType===`log`&&n>0){let e=V(n,this.logFormula);return Se(e+i*(V(t,this.logFormula)-e),this.logFormula)}return n+i*(t-n)}deltaYToPriceOffset(e){let t=Math.max(1,this.height-this.paddingTop-this.paddingBottom);if(this.scaleType===`log`&&this.range.minPrice>0){let n=V(this.range.minPrice,this.logFormula);return e*((V(this.range.maxPrice,this.logFormula)-n)/t)}return e*((this.range.maxPrice-this.range.minPrice||1)/t)}},H=function(e){return e.Main=`main`,e.Overlay=`overlay`,e.All=`all`,e}({});function Ee(e){return e===`price`?{showPriceAxisTicks:!0,showCrosshairPriceLabel:!0,candleHitTest:!0,supportsPriceTranslate:!0}:e===`indicator`?{showPriceAxisTicks:!1,showCrosshairPriceLabel:!0,candleHitTest:!1,supportsPriceTranslate:!0}:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1}}var De=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new Te;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...Ee(this.role),...t.capabilities??{}}}setLayout(e,t){this.top=e,this.height=Math.max(1,t),this.yAxis.setHeight(this.height)}setPadding(e,t){this.yAxis.setPadding(e,t)}addRenderer(e){this.renderers.push(e)}updateRange(e,t,n){this.priceRange=ye(e,t.start,t.end),n&&Number.isFinite(n.min)&&Number.isFinite(n.max)&&(this.priceRange.minPrice=Math.min(this.priceRange.minPrice,n.min),this.priceRange.maxPrice=Math.max(this.priceRange.maxPrice,n.max)),this.yAxis.setRange(this.priceRange)}},Oe=Symbol(`renderer:global-cache`),ke=class{plugins=new Map;pluginHost=null;enabledState=new Map;groupCache=new Map;mergedCache=new Map;knownPaneIds=new Set;cacheInvalid=!0;onInvalidate=null;setInvalidateCallback(e){this.onInvalidate=e}setPluginHost(e){this.pluginHost=e}addKnownPaneId(e){this.knownPaneIds.add(e),this.cacheInvalid=!0}removeKnownPaneId(e){this.knownPaneIds.delete(e),this.cacheInvalid=!0}setKnownPaneIds(e){this.knownPaneIds=new Set(e),this.cacheInvalid=!0}register(e){if(this.plugins.has(e.name)){console.warn(`Renderer plugin "${e.name}" already registered`);return}this.plugins.set(e.name,e),e.enabled!==void 0&&this.enabledState.set(e.name,e.enabled),this.cacheInvalid=!0;let t=e;if(t.onInstall&&this.pluginHost)try{t.onInstall(this.pluginHost)}catch(t){console.error(`[RendererPlugin] ${e.name} onInstall error:`,t)}let n=t.getDeclaredNamespaces?.();n&&this.pluginHost&&this.pluginHost.registerStateOwner(e.name,n),this.onInvalidate?.()}unregister(e){let t=this.plugins.get(e);if(t){if(t.getDeclaredNamespaces&&this.pluginHost?.clearByOwner(e),t.onUninstall)try{t.onUninstall()}catch(e){console.error(`[RendererPlugin] ${t.name} onUninstall error:`,e)}this.plugins.delete(e),this.enabledState.delete(e),this.cacheInvalid=!0,this.onInvalidate?.()}}clear(){for(let e of this.plugins.values())if(e.onUninstall)try{e.onUninstall()}catch(t){console.error(`[RendererPlugin] ${e.name} onUninstall error:`,t)}this.plugins.clear(),this.enabledState.clear(),this.groupCache.clear(),this.mergedCache.clear(),this.cacheInvalid=!1}mergeSorted(e,t){let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].priority<=t[i].priority?n.push(e[r++]):n.push(t[i++]);return[...n,...e.slice(r),...t.slice(i)]}rebuildCache(){if(!this.cacheInvalid)return;this.groupCache.clear(),this.mergedCache.clear();for(let e of this.plugins.values()){let t=typeof e.paneId==`symbol`?Oe:e.paneId;this.groupCache.has(t)||this.groupCache.set(t,[]),this.groupCache.get(t).push(e)}for(let[,e]of this.groupCache)e.sort((e,t)=>e.priority-t.priority);let e=this.groupCache.get(Oe)??[];for(let t of this.knownPaneIds){let n=this.groupCache.get(t)??[],r=this.mergeSorted(n,e);this.mergedCache.set(t,r)}this.mergedCache.set(Oe,[...e]),this.cacheInvalid=!1}isRendererEnabled(e){let t=this.enabledState.get(e.name);return t===void 0?e.enabled!==!1:t}getMergedRenderers(e){this.rebuildCache();let t=this.mergedCache.get(e);if(!t){let n=this.groupCache.get(e)??[],r=this.groupCache.get(Oe)??[];t=this.mergeSorted(n,r),this.mergedCache.set(e,t)}return t}getRenderers(e){return this.getMergedRenderers(e).filter(e=>e.isSystem?!1:this.isRendererEnabled(e))}render(e,t,n){let r=this.getRenderers(e),i=[];for(let e of r){if(n){let t=e.layer??`main`;if(n===H.Overlay&&t!==`overlay`||n===H.Main&&t===`overlay`)continue}try{e.draw(t)}catch(n){let r=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,r),i.push({name:e.name,error:{message:r.message,stack:r.stack},paneId:t.pane.id,timestamp:Date.now()})}}return i}renderPlugin(e,t){let n=this.plugins.get(e);if(!n||!this.isRendererEnabled(n))return[];let r=[];try{n.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e} draw error:`,i),r.push({name:e,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}setEnabled(e,t){this.plugins.has(e)&&(this.enabledState.set(e,t),this.onInvalidate?.())}updateConfig(e,t){let n=this.plugins.get(e);return n?.setConfig?(n.setConfig(t),this.onInvalidate?.(),!0):!1}getAllPlugins(){return Array.from(this.plugins.values())}getPlugin(e){return this.plugins.get(e)}notifyDataUpdate(e,t){for(let n of this.plugins.values())if(n.onDataUpdate&&this.isRendererEnabled(n))try{n.onDataUpdate(e,t)}catch(e){console.error(`[RendererPlugin] ${n.name} onDataUpdate error:`,e)}}notifyResize(e,t){let n=this.getMergedRenderers(e).filter(e=>this.isRendererEnabled(e));for(let e of n)if(e.onResize)try{e.onResize(t)}catch(t){console.error(`[RendererPlugin] ${e.name} onResize error:`,t)}}},Ae={PRIMARY:`hsl(210, 9%, 31%)`,SECONDARY:`hsl(210, 9%, 35%)`,TERTIARY:`hsl(210, 8%, 50%)`,WEAK:`hsl(210, 7%, 65%)`,WHITE:`rgba(255, 255, 255, 0.92)`},U={UP:`rgba(214, 10, 34, 1)`,UP_LIGHT:`rgba(214, 10, 34, 0.92)`,UP_TICK:`hsl(0, 60%, 50%)`,DOWN:`rgba(3, 123, 102, 1)`,DOWN_LIGHT:`rgba(3, 123, 102, 0.92)`,DOWN_TICK:`hsl(150, 30%, 60%)`,NEUTRAL:`rgba(0, 0, 0, 0.78)`,LAST_PRICE:`rgba(196, 74, 86, 0.95)`},je={WHITE:`rgb(255, 255, 255)`,LIGHT_GRAY:`rgba(255, 255, 255, 0.92)`,PURE_WHITE:`#ffffff`,TRANSPARENT:`transparent`,ACTIVE:`#1890ff`,ACTIVE_HOVER:`#40a9ff`,HOVER:`#f0f0f0`},Me={DARK:`rgba(0, 0, 0, 0.12)`,MEDIUM:`rgba(0, 0, 0, 0.10)`,LIGHT:`rgba(0, 0, 0, 0.08)`,SEPARATOR:`rgba(0, 0, 0, 0.10)`,BUTTON:`#d0d0d0`},W={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},Ne={MA5:`rgba(255, 193, 37, 1)`,MA10:`rgba(190, 131, 12, 1)`,MA20:`rgba(69, 112, 249, 1)`,MA30:`rgba(76, 175, 80, 1)`,MA60:`rgba(156, 39, 176, 1)`},G={UPPER:`rgba(178, 34, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(34, 139, 34, 1)`,BAND_FILL:`rgba(100, 149, 237, 0.1)`},K={DIF:`rgba(69, 112, 249, 1)`,DEA:`rgba(255, 152, 0, 1)`,BAR_UP:`#ff5252`,BAR_UP_LIGHT:`#fccbcd`,BAR_DOWN:`#22ab94`,BAR_DOWN_LIGHT:`#ace5dc`},Pe={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},q={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},Fe={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Ie={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},Le={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},Re={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},ze={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},Be={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},J={UPPER:`rgba(214, 10, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(3, 123, 102, 1)`,BAND_FILL:`rgba(69, 112, 249, 0.08)`},Ve={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`};function Y(e,t){return Math.round(e*t)/t}function X(e,t){return(Math.floor(e*t)+.5)/t}function He(e,t,n,r){if(t===n)return null;let i=Math.min(t,n),a=Math.max(t,n),o=Math.round(e*r),s=Math.round(i*r),c=Math.round(a*r);return{x:o/r,y:s/r,width:1/r,height:Math.max(1,c-s)/r}}function Ue(e,t,n,r){if(e===t)return null;let i=Math.min(e,t),a=Math.max(e,t),o=Math.round(i*r),s=Math.round(a*r),c=Math.round(n*r);return{x:o/r,y:c/r,width:Math.max(1,s-o)/r,height:1/r}}function We(e,t,n,r,i){let a=e+n,o=n,s=Math.round(t*i),c=Math.round((t+r)*i),l=Math.max(1,c-s),u=e+(n-1)/2,d=u,f=o%2==1;return{bodyRect:{x:e/i,y:s/i,width:n/i,height:l/i},physBodyLeft:e,physBodyRight:a,physBodyWidth:o,physBodyCenter:d,physWickX:u,wickRect:{x:u/i,width:1/i},isPerfectlyAligned:f}}var Ge=1.2,Ke=24,qe=6;function Je(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function Ye(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:de,priority:R.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kLineCenters:s,dpr:c,markerManager:l,zoomLevel:u}=e;if(!l||(u??1)<2)return;let d=l.getCustomMarkers();if(!d||d.length===0)return;let f=r;if(f.length&&n.role===`price`){t.save(),t.translate(-a,0);for(let e of d){let r=Ze(f,e.timestamp);if(r===-1||r<i.start||r>=i.end)continue;let u=r-i.start;if(u<0||u>=s.length)continue;let d=s[u],p=f[r],m=e.style?.size,h=Xe(o,m),g=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:Je(e.shape),_;_=g?n.yAxis.priceToY(p.high)-h/2-4+(e.offset?.y??0):n.yAxis.priceToY(p.low)+h/2+4+(e.offset?.y??0);let v=d+(e.offset?.x??0),y=_,b=v,x=y,S=Math.round(h*c/2)*2/c;F(t,e.shape,b,x,S,e.style||{}),e.label&&ee(t,e.label,b,x,S,e.style||{},g),l.setCustomMarkerPosition(e.id,b-a,x,S,e.shape)}t.restore()}}}}function Xe(e,t){let n=e*Ge;return Math.max(qe,Math.min(n,t??Ke))}function Ze(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=e[i]?.timestamp;if(a===void 0)break;if(a===t)return i;a<t?n=i+1:r=i-1}return-1}var Qe=new Intl.DateTimeFormat(`zh-CN`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}),$e=1024,et=new Map;function tt(e){let t=et.get(e);if(t!==void 0)return t;let n=Qe.formatToParts(new Date(e)),r=``,i=``,a=``;for(let e=0;e<n.length;e++){let t=n[e];t.type===`year`?r=t.value:t.type===`month`?i=t.value:t.type===`day`&&(a=t.value)}let o=`${r}-${i}-${a}`;return et.size>=$e&&et.clear(),et.set(e,o),o}var nt=512,rt=new Map;function it(e){let t=rt.get(e);if(t!==void 0)return t;let n=new Date(e),r=n.getFullYear(),i=n.getMonth()+1,a=i===1?{text:String(r),isYear:!0}:{text:`${i}月`,isYear:!1};return rt.size>=nt&&rt.clear(),rt.set(e,a),a}function at(e){let t=new Date(e);return t.getFullYear()*12+t.getMonth()}var ot=tt,st=tt,ct=null,lt=0,ut=0,dt=0,ft=[];function pt(e){if(e.length===0)return[];if(ct===e&<===e.length){let t=e[0]?.timestamp,n=e[e.length-1]?.timestamp;if(t===ut&&n===dt)return ft}let t=[0],n=at(e[0].timestamp);for(let r=1;r<e.length;r++){let i=e[r];if(!i)continue;let a=at(i.timestamp);a!==n&&(t.push(r),n=a)}return ct=e,lt=e.length,ut=e[0]?.timestamp??0,dt=e[e.length-1]?.timestamp??0,ft=t,t}var mt=U.UP,ht=U.DOWN,gt=U.NEUTRAL;function _t(e){return e>0?mt:e<0?ht:gt}function vt(e,t=2){let n=Math.abs(e);return n>=1e8?`${(e/1e8).toFixed(t)}亿`:n>=1e4?`${(e/1e4).toFixed(t)}万`:`${Math.round(e)}`}function yt(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function bt(e,t=2){return`${e.toFixed(t)}%`}function xt(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function St(e,t){let n=t?.close??e.open;return _t(e.open-n)}function Ct(e){return _t(e.close-e.open)}function wt(e){return typeof e.changePercent==`number`?_t(e.changePercent):typeof e.changeAmount==`number`?_t(e.changeAmount):gt}var Tt={class:`kline-tooltip__title`},Et={key:0},Dt={class:`kline-tooltip__grid`},Ot={class:`row`},kt={class:`row`},At={class:`row`},jt={class:`row`},Mt={key:0,class:`row`},Nt={key:1,class:`row`},Pt={key:2,class:`row`},Ft={key:3,class:`row`},It={key:4,class:`row`},Lt={key:5,class:`row`},Rt=(0,e.defineComponent)({__name:`KLineTooltip`,props:{k:{},index:{},data:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(t){let n=t,r=(0,e.computed)(()=>n.useAnchor===!0),i=(0,e.computed)(()=>n.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function a(e){n.setEl?.(e)}let o=(0,e.computed)(()=>{let e=n.k;if(!e)return gt;let t=n.index;return St(e,typeof t==`number`&&t>0?n.data[t-1]:void 0)}),s=(0,e.computed)(()=>{let e=n.k;return e?Ct(e):gt}),c=(0,e.computed)(()=>{let e=n.k;return e?wt(e):gt});return(n,l)=>t.k?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,ref:a,class:(0,e.normalizeClass)([`kline-tooltip`,[{"use-anchor":r.value},i.value]]),style:(0,e.normalizeStyle)(r.value?void 0:{left:`${t.pos.x}px`,top:`${t.pos.y}px`})},[(0,e.createElementVNode)(`div`,Tt,[t.k.stockCode?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Et,(0,e.toDisplayString)(t.k.stockCode),1)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(ot)(t.k.timestamp)),1)]),(0,e.createElementVNode)(`div`,Dt,[(0,e.createElementVNode)(`div`,Ot,[l[0]||=(0,e.createElementVNode)(`span`,null,`开`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:o.value})},(0,e.toDisplayString)(t.k.open.toFixed(2)),5)]),(0,e.createElementVNode)(`div`,kt,[l[1]||=(0,e.createElementVNode)(`span`,null,`高`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.high.toFixed(2)),1)]),(0,e.createElementVNode)(`div`,At,[l[2]||=(0,e.createElementVNode)(`span`,null,`低`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.low.toFixed(2)),1)]),(0,e.createElementVNode)(`div`,jt,[l[3]||=(0,e.createElementVNode)(`span`,null,`收`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:s.value})},(0,e.toDisplayString)(t.k.close.toFixed(2)),5)]),typeof t.k.volume==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Mt,[l[4]||=(0,e.createElementVNode)(`span`,null,`成交量`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(vt)(t.k.volume)),1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.turnover==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Nt,[l[5]||=(0,e.createElementVNode)(`span`,null,`成交额`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(vt)(t.k.turnover)),1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.amplitude==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Pt,[l[6]||=(0,e.createElementVNode)(`span`,null,`振幅`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.amplitude)+`%`,1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.changePercent==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Ft,[l[7]||=(0,e.createElementVNode)(`span`,null,`涨跌幅`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:c.value})},(0,e.toDisplayString)((0,e.unref)(xt)(t.k.changePercent)),5)])):(0,e.createCommentVNode)(``,!0),typeof t.k.changeAmount==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,It,[l[8]||=(0,e.createElementVNode)(`span`,null,`涨跌额`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:c.value})},(0,e.toDisplayString)((0,e.unref)(yt)(t.k.changeAmount)),5)])):(0,e.createCommentVNode)(``,!0),typeof t.k.turnoverRate==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Lt,[l[9]||=(0,e.createElementVNode)(`span`,null,`换手率`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(bt)(t.k.turnoverRate)),1)])):(0,e.createCommentVNode)(``,!0)])],6)):(0,e.createCommentVNode)(``,!0)}}),zt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Bt=zt(Rt,[[`__scopeId`,`data-v-d0fe85e6`]]),Vt={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},Ht=class{markers=new Map;hoveredMarkerId=null;lastHoveredId=null;customMarkers=new Map;customMarkerPositions=new Map;clear(){this.markers.clear()}register(e){this.markers.set(e.id,e)}getState(e){return this.hoveredMarkerId===e?`hovered`:`normal`}hitTest(e,t,n=3){for(let r of this.markers.values())if(e>=r.x-n&&e<=r.x+r.width+n&&t>=r.y-n&&t<=r.y+r.height+n)return r;return null}setHover(e){this.hoveredMarkerId=e,this.lastHoveredId=e}validateHoverState(){this.hoveredMarkerId!==null&&!this.markers.has(this.hoveredMarkerId)&&(this.hoveredMarkerId=null)}getHoveredMarker(){return this.hoveredMarkerId===null?null:this.markers.get(this.hoveredMarkerId)||null}getLastHoverId(){return this.lastHoveredId}getAllMarkers(){return Array.from(this.markers.values())}registerCustomMarker(e){this.customMarkers.set(e.id,e)}setCustomMarkers(e){this.clearCustomMarkers();for(let t of e)this.customMarkers.set(t.id,t)}clearCustomMarkers(){this.customMarkers.clear(),this.customMarkerPositions.clear()}getCustomMarkers(){return Array.from(this.customMarkers.values())}setCustomMarkerPosition(e,t,n,r,i){this.customMarkerPositions.set(e,{x:t,y:n,size:r,shape:i})}hitTestCustomMarker(e,t){for(let n of this.customMarkers.values()){let r=this.customMarkerPositions.get(n.id);if(r&&ce(e,t,r.shape,r.x,r.y,r.size))return n}return null}},Ut={class:`marker-tooltip__title`},Wt={key:0,class:`marker-tooltip__content`},Gt=zt((0,e.defineComponent)({__name:`MarkerTooltip`,props:{marker:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(t){let n=t,r=(0,e.computed)(()=>n.useAnchor===!0),i=(0,e.computed)(()=>n.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function a(e){n.setEl?.(e)}let o=(0,e.computed)(()=>n.marker&&`date`in n.marker),s=(0,e.computed)(()=>{if(!n.marker)return``;if(o.value){let e=n.marker;return e.label?.text||e.shape}let e=n.marker;return Vt[e.markerType]||e.markerType}),c=(0,e.computed)(()=>{if(!n.marker)return{};if(o.value){let e=n.marker;return{日期:e.date,...e.metadata}}return n.marker.metadata}),l=(0,e.computed)(()=>Object.keys(c.value).length>0);function u(e){return typeof e==`number`?e.toFixed(2):String(e)}return(n,o)=>t.marker?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,ref:a,class:(0,e.normalizeClass)([`marker-tooltip`,[{"use-anchor":r.value},i.value]]),style:(0,e.normalizeStyle)(r.value?void 0:{left:`${t.pos.x+12}px`,top:`${t.pos.y+12}px`})},[(0,e.createElementVNode)(`div`,Ut,(0,e.toDisplayString)(s.value),1),l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Wt,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(c.value,(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n,class:`row`},[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(n),1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(u(t)),1)]))),128))])):(0,e.createCommentVNode)(``,!0)],6)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-5574cc25`]]),Kt=Symbol(`fullscreen-teleport-target`);function qt(){let t=(0,e.inject)(Kt,null);return(0,e.computed)(()=>t?.value??`body`)}var Jt={class:`params-header`},Yt={class:`header-left`},Xt={class:`params-title`},Zt={class:`header-right`},Qt={key:0,class:`indicator-description`},$t={class:`params-body`},en={class:`param-header`},tn={class:`param-label`},nn={class:`param-label-text`},rn={key:0,class:`param-range`},an={class:`input-wrapper`},on=[`disabled`,`onClick`],sn=[`value`,`min`,`max`,`step`,`onInput`],cn=[`disabled`,`onClick`],ln={key:0,class:`param-description`},un={class:`params-footer`},dn={class:`footer-right`},fn=zt((0,e.defineComponent)({__name:`IndicatorParams`,props:{visible:{type:Boolean},indicatorId:{},indicatorName:{},indicatorDescription:{},params:{},values:{}},emits:[`close`,`confirm`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.ref)({...r.values}),o=(0,e.ref)(!0),s=qt();(0,e.watch)(()=>r.values,e=>{a.value={...e}},{deep:!0,immediate:!0}),(0,e.watch)(()=>r.visible,e=>{e&&(a.value={...r.values})});function c(e,t){let n=t.target,r=parseFloat(n.value);isNaN(r)||(a.value[e]=r)}function l(e,t){let n=e.step||1,r=(a.value[e.key]||0)+t*n;e.min!==void 0&&(r=Math.max(e.min,r)),e.max!==void 0&&(r=Math.min(e.max,r)),a.value[e.key]=parseFloat(r.toFixed(10))}function u(){let e={};r.params.forEach(t=>{e[t.key]=t.default??r.values[t.key]??0}),a.value=e}function d(){i(`confirm`,{...a.value})}return(n,r)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(s)},[(0,e.createVNode)(e.Transition,{name:`overlay`},{default:(0,e.withCtx)(()=>[t.visible?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`params-overlay`,onClick:r[4]||=e=>n.$emit(`close`)},[(0,e.createVNode)(e.Transition,{name:`modal`},{default:(0,e.withCtx)(()=>[(0,e.createElementVNode)(`div`,{class:`indicator-params`,onClick:r[3]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,Jt,[(0,e.createElementVNode)(`div`,Yt,[(0,e.createElementVNode)(`span`,Xt,(0,e.toDisplayString)(t.indicatorName),1),r[5]||=(0,e.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,e.createElementVNode)(`div`,Zt,[(0,e.createElementVNode)(`button`,{class:(0,e.normalizeClass)([`toggle-desc-btn`,{active:o.value}]),onClick:r[0]||=e=>o.value=!o.value,title:`显示/隐藏说明`},[...r[6]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 1024 1024`},[(0,e.createElementVNode)(`path`,{d:`M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 268.190476v292.571428h-73.142858V438.857143h73.142858z m0-121.904762v73.142857h-73.142858v-73.142857h73.142858z`,fill:`currentColor`})],-1)]],2),(0,e.createElementVNode)(`button`,{class:`params-close`,onClick:r[1]||=e=>n.$emit(`close`)},[...r[7]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,e.createVNode)(e.Transition,{name:`slide`},{default:(0,e.withCtx)(()=>[o.value&&t.indicatorDescription?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Qt,[(0,e.createElementVNode)(`p`,null,(0,e.toDisplayString)(t.indicatorDescription),1)])):(0,e.createCommentVNode)(``,!0)]),_:1}),(0,e.createElementVNode)(`div`,$t,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.params,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:(0,e.normalizeClass)([`param-item`,{"has-desc":o.value&&t.description}])},[(0,e.createElementVNode)(`div`,en,[(0,e.createElementVNode)(`label`,tn,[(0,e.createElementVNode)(`span`,nn,(0,e.toDisplayString)(t.label),1),t.min!==void 0||t.max!==void 0?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,rn,(0,e.toDisplayString)(t.min??`-∞`)+` ~ `+(0,e.toDisplayString)(t.max??`+∞`),1)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,an,[(0,e.createElementVNode)(`button`,{class:`stepper-btn`,disabled:t.min!==void 0&&(a.value[t.key]??0)<=t.min,onClick:e=>l(t,-1)},` − `,8,on),t.type===`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`number`,class:`param-input`,value:a.value[t.key],min:t.min,max:t.max,step:t.step||1,onInput:e=>c(t.key,e)},null,40,sn)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`stepper-btn`,disabled:t.max!==void 0&&(a.value[t.key]??0)>=t.max,onClick:e=>l(t,1)},` + `,8,cn)])]),(0,e.createVNode)(e.Transition,{name:`slide`},{default:(0,e.withCtx)(()=>[o.value&&t.description?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,ln,(0,e.toDisplayString)(t.description),1)):(0,e.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,e.createElementVNode)(`div`,un,[(0,e.createElementVNode)(`button`,{class:`params-btn reset`,onClick:u},[...r[8]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,e.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,e.createTextVNode)(` 重置 `,-1)]]),(0,e.createElementVNode)(`div`,dn,[(0,e.createElementVNode)(`button`,{class:`params-btn cancel`,onClick:r[2]||=e=>n.$emit(`close`)},`取消`),(0,e.createElementVNode)(`button`,{class:`params-btn confirm`,onClick:d},[...r[9]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,e.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,e.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))}}),[[`__scopeId`,`data-v-bb1d1eb3`]]),pn=[{id:`MA`,label:`MA`,name:`均线`,pane:`main`},{id:`VOLUME`,label:`VOL`,name:`成交量`,pane:`sub`,description:`成交量反映市场活跃度,柱状图显示每根K线的交易量。上涨时柱子为红色,下跌时为绿色。`},{id:`BOLL`,label:`BOLL`,name:`布林带`,pane:`main`,description:`布林带由三条轨道线组成,用于判断价格的波动范围和趋势强度。价格触及上轨可能超买,触及下轨可能超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算移动平均线的周期数,周期越长轨道越平滑`},{key:`multiplier`,label:`倍数`,type:`number`,min:.1,max:5,step:.1,default:2,description:`标准差倍数,决定轨道宽度,通常为 2`}]},{id:`EXPMA`,label:`EXPMA`,name:`指数平滑移动平均线`,pane:`main`,description:`EXPMA 对近期价格给予更高权重,比普通 MA 更敏感。快线上穿慢线为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:100,step:1,default:12,description:`快线周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:200,step:1,default:50,description:`慢线周期,用于判断趋势方向`}]},{id:`ENE`,label:`ENE`,name:`轨道线`,pane:`main`,description:`ENE 轨道线由三条轨道组成,价格突破上轨可能超买,突破下轨可能超卖,适合判断震荡行情的买卖点。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`计算中轨的周期数`},{key:`deviation`,label:`偏离率`,type:`number`,min:1,max:30,step:.5,default:11,description:`轨道偏离率百分比,决定轨道宽度`}]},{id:`MACD`,label:`MACD`,name:`指数平滑异同移动平均线`,pane:`sub`,description:`MACD 通过快慢均线的交叉判断趋势方向和动量。DIF 上穿 DEA 为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:50,step:1,default:12,description:`快线 EMA 周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:100,step:1,default:26,description:`慢线 EMA 周期,用于计算 DIF`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`DEA 的 EMA 周期,用于生成买卖信号`}]},{id:`RSI`,label:`RSI`,name:`相对强弱指标`,pane:`sub`,description:`RSI 衡量价格变动的速度和幅度,判断超买超卖状态。RSI > 70 超买,RSI < 30 超卖。`,params:[{key:`period1`,label:`周期 1`,type:`number`,min:2,max:100,step:1,default:6,description:`第一条 RSI 周期,通常为 6(快线)`},{key:`period2`,label:`周期 2`,type:`number`,min:2,max:100,step:1,default:12,description:`第二条 RSI 周期,通常为 12(中线)`},{key:`period3`,label:`周期 3`,type:`number`,min:2,max:100,step:1,default:24,description:`第三条 RSI 周期,通常为 24(慢线)`}]},{id:`CCI`,label:`CCI`,name:`顺势指标`,pane:`sub`,description:`CCI 衡量价格与统计平均值的偏离程度。CCI > 100 超买,CCI < -100 超卖,适合捕捉趋势反转。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期,周期越短信号越灵敏`}]},{id:`STOCH`,label:`STOCH`,name:`随机指标`,pane:`sub`,description:`KDJ 随机指标通过比较收盘价与价格区间判断超买超卖。K > 80 超买,K < 20 超卖,K 上穿 D 金叉。`,params:[{key:`n`,label:`K 周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算 K 值的周期,统计 N 日内价格区间`},{key:`m`,label:`D 周期`,type:`number`,min:1,max:50,step:1,default:3,description:`D 值是 K 的 M 日移动平均,使信号更平滑`}]},{id:`MOM`,label:`MOM`,name:`动量指标`,pane:`sub`,description:`动量指标衡量价格变化的速度,MOM > 0 表示上涨动能,MOM < 0 表示下跌动能。适合判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`与多少日前价格比较,周期越短越灵敏`}]},{id:`WMSR`,label:`WMSR`,name:`威廉指标`,pane:`sub`,description:`威廉指标衡量超买超卖程度,范围为 -100 到 0。WMSR > -20 超买,WMSR < -80 超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`回溯周期,统计周期内最高最低价`}]},{id:`KST`,label:`KST`,name:`确然指标`,pane:`sub`,description:`KST 综合多个 ROC 判断长期趋势,KST 上穿信号线看涨,下穿看跌。适合捕捉主要趋势转换。`,params:[{key:`roc1`,label:`ROC1`,type:`number`,min:2,max:100,step:1,default:10,description:`短期变化率周期`},{key:`roc2`,label:`ROC2`,type:`number`,min:2,max:100,step:1,default:15,description:`中短期变化率周期`},{key:`roc3`,label:`ROC3`,type:`number`,min:2,max:100,step:1,default:20,description:`中长期变化率周期`},{key:`roc4`,label:`ROC4`,type:`number`,min:2,max:100,step:1,default:30,description:`长期变化率周期`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`信号线的 SMA 周期`}]},{id:`FASTK`,label:`FASTK`,name:`快速随机指标`,pane:`sub`,description:`FASTK 是未经过平滑处理的随机指标,比普通 KDJ 更敏感,能更快捕捉价格转折点,但假信号也更多。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算周期,周期越短越敏感`}]},{id:`ATR`,label:`ATR`,name:`平均真实波幅`,pane:`sub`,description:`ATR(Average True Range)衡量市场波动性,值越大表示波动越剧烈。Wilder 平滑算法,常用于设置止损位和判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:1,max:100,step:1,default:14,description:`ATR 计算周期,周期越长曲线越平滑`}]}],mn=pn.filter(e=>e.pane===`main`),hn=pn.filter(e=>e.pane===`sub`);function gn(e){return pn.find(t=>t.id===e)}function _n(e){return pn.find(t=>t.id===e)?.pane===`sub`}var vn={class:`indicator-selector`},yn={class:`indicator-scroll-container`},bn={class:`indicator-list`},xn={key:0,class:`indicator-divider`,"aria-hidden":`true`},Sn=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],Cn=[`onMouseenter`],wn={class:`btn-content`},Tn={key:0,class:`param-hint`},En={key:0,class:`hover-overlay`},Dn=[`onClick`],On={key:1,class:`divider`},kn=[`onClick`],An={class:`indicator-item`},jn={class:`menu-section`},Mn={class:`menu-items`},Nn=[`disabled`,`onClick`],Pn={class:`param-hint`},Fn={key:0,class:`active-tag`},In={class:`menu-section`},Ln={class:`menu-items`},Rn=[`disabled`,`onClick`],zn={class:`param-hint`},Bn={key:0,class:`active-tag`},Vn=zt((0,e.defineComponent)({__name:`IndicatorSelector`,props:{activeIndicators:{},indicatorParams:{}},emits:[`toggle`,`updateParams`,`reorderSubIndicators`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.ref)(null),o=(0,e.ref)(null),s=(0,e.ref)(!1),c=(0,e.ref)(null),l=(0,e.ref)(null),u=(0,e.ref)(!1),d=(0,e.ref)({left:`0`,bottom:`0`}),f=(0,e.ref)(!1),p=(0,e.ref)(null),m=(0,e.ref)(null),h=qt(),g=(0,e.computed)(()=>r.activeIndicators?.length?r.activeIndicators.map(e=>gn(e)).filter(e=>e!==void 0).sort((e,t)=>e.pane===t.pane?0:e.pane===`main`?-1:1):[]),_=(0,e.computed)(()=>g.value.some(e=>e.pane===`main`)?g.value.find(e=>e.pane===`sub`)?.id??null:null),v=(0,e.computed)(()=>c.value?gn(c.value):null);function y(e){return r.activeIndicators?.includes(e)??!1}function b(e){if(y(e))return;let t=gn(e);t&&(t.pane===`main`&&mn.filter(t=>t.id!==e&&y(t.id)).forEach(e=>i(`toggle`,e.id,!1)),i(`toggle`,e,!0),u.value=!1)}function x(e){i(`toggle`,e,!1)}function S(e){c.value=e,s.value=!0}function C(e){let t=gn(e);if(!t?.params)return{};let n={};for(let e of t.params)n[e.key]=e.default??e.min??1;let i=r.indicatorParams?.[e]||{},a={...n};for(let[e,t]of Object.entries(i))typeof t==`number`&&(a[e]=t);return a}function w(e){let t=C(e.id);return e.params?e.params.map(e=>t[e.key]??``).join(`,`):``}function T(e){c.value&&i(`updateParams`,c.value,e),s.value=!1}function E(e,t){if(!_n(t)){e.preventDefault();return}m.value=t,p.value=null,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}function D(e,t){!m.value||!_n(t)||m.value===t||(p.value=t,e.dataTransfer&&(e.dataTransfer.dropEffect=`move`))}function O(e,t){let n=m.value||e.dataTransfer?.getData(`text/plain`)||``;if(!n||n===t){k();return}if(!_n(n)||!_n(t)){k();return}let r=g.value.findIndex(e=>e.id===n),a=g.value.findIndex(e=>e.id===t);if(r<0||a<0){k();return}let o=[...g.value.map(e=>e.id)],[s]=o.splice(r,1);if(!s){k();return}o.splice(a,0,s),i(`reorderSubIndicators`,o.filter(e=>_n(e))),k()}function k(){p.value=null,m.value=null}function A(){if(!u.value&&a.value&&!f.value){let e=a.value.getBoundingClientRect(),t=window.innerWidth,n=e.left+e.width/2;n+160>t-8&&(n=t-160-8),n-160<8&&(n=168),d.value={left:`${n}px`,bottom:`${window.innerHeight-e.top+8}px`}}u.value=!u.value}function j(e){let t=o.value&&!o.value.contains(e.target),n=a.value&&!a.value.contains(e.target);t&&n&&(u.value=!1)}function M(){u.value&&=!1}return(0,e.onMounted)(()=>{f.value=typeof CSS<`u`&&CSS.supports(`anchor-name: --kmap-anchor`)&&CSS.supports(`position-anchor: --kmap-anchor`),document.addEventListener(`click`,j),window.addEventListener(`resize`,M)}),(0,e.onUnmounted)(()=>{document.removeEventListener(`click`,j),window.removeEventListener(`resize`,M)}),(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,vn,[(0,e.createElementVNode)(`div`,yn,[(0,e.createElementVNode)(`div`,bn,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(g.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:t.id},[t.id===_.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,xn)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`indicator-item`,{draggable:(0,e.unref)(_n)(t.id),"drag-over":p.value===t.id,"is-dragging":m.value===t.id}]),draggable:(0,e.unref)(_n)(t.id),onDragstart:e=>E(e,t.id),onDragover:(0,e.withModifiers)(e=>D(e,t.id),[`prevent`]),onDrop:(0,e.withModifiers)(e=>O(e,t.id),[`prevent`]),onDragend:k},[(0,e.createElementVNode)(`div`,{class:`indicator-btn-wrapper`,onMouseenter:e=>l.value=t.id,onMouseleave:n[0]||=e=>l.value=null},[(0,e.createElementVNode)(`button`,{class:(0,e.normalizeClass)([`indicator-btn`,{active:!0,hovering:l.value===t.id}])},[(0,e.createElementVNode)(`span`,wn,[(0,e.createTextVNode)((0,e.toDisplayString)(t.label)+` `,1),t.params?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Tn,` (`+(0,e.toDisplayString)(w(t))+`) `,1)):(0,e.createCommentVNode)(``,!0)]),(0,e.createVNode)(e.Transition,{name:`fade`},{default:(0,e.withCtx)(()=>[l.value===t.id?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,En,[t.params?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`action-btn settings-btn`,onClick:(0,e.withModifiers)(e=>S(t.id),[`stop`]),title:`编辑参数`},[...n[2]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,Dn)):(0,e.createCommentVNode)(``,!0),t.params?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,On)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`action-btn remove-btn`,onClick:(0,e.withModifiers)(e=>x(t.id),[`stop`]),title:`移除指标`},[...n[3]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})],-1)]],8,kn)])):(0,e.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,Cn)],42,Sn)],64))),128)),(0,e.createElementVNode)(`div`,An,[(0,e.createElementVNode)(`button`,{ref_key:`addBtnRef`,ref:a,class:`add-btn`,onClick:A,title:`添加指标`},[...n[4]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`})],-1)]],512)])])]),((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(h)},[(0,e.createVNode)(e.Transition,{name:`slide`},{default:(0,e.withCtx)(()=>[u.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:(0,e.normalizeClass)([`add-menu`,{"use-anchor":f.value}]),ref_key:`addMenuRef`,ref:o,style:(0,e.normalizeStyle)(f.value?void 0:d.value)},[(0,e.createElementVNode)(`div`,jn,[n[6]||=(0,e.createElementVNode)(`div`,{class:`menu-title`},`主图指标`,-1),(0,e.createElementVNode)(`div`,Mn,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)((0,e.unref)(mn),t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,class:(0,e.normalizeClass)([`menu-item`,{disabled:y(t.id)}]),disabled:y(t.id),onClick:e=>b(t.id)},[(0,e.createTextVNode)((0,e.toDisplayString)(t.label)+` `,1),(0,e.createElementVNode)(`span`,Pn,` (`+(0,e.toDisplayString)(t.name)+`) `,1),y(t.id)?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Fn,[...n[5]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,e.createCommentVNode)(``,!0)],10,Nn))),128))])]),(0,e.createElementVNode)(`div`,In,[n[8]||=(0,e.createElementVNode)(`div`,{class:`menu-title`},`副图指标`,-1),(0,e.createElementVNode)(`div`,Ln,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)((0,e.unref)(hn),t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,class:(0,e.normalizeClass)([`menu-item`,{disabled:y(t.id)}]),disabled:y(t.id),onClick:e=>b(t.id)},[(0,e.createTextVNode)((0,e.toDisplayString)(t.label)+` `,1),(0,e.createElementVNode)(`span`,zn,` (`+(0,e.toDisplayString)(t.name)+`) `,1),y(t.id)?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Bn,[...n[7]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})],-1)]])):(0,e.createCommentVNode)(``,!0)],10,Rn))),128))])])],6)):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`])),v.value?((0,e.openBlock)(),(0,e.createBlock)(fn,{key:0,visible:s.value,"indicator-id":v.value.id,"indicator-name":v.value.name,"indicator-description":v.value.description,params:v.value.params||[],values:C(v.value.id),onClose:n[1]||=e=>s.value=!1,onConfirm:T},null,8,[`visible`,`indicator-id`,`indicator-name`,`indicator-description`,`params`,`values`])):(0,e.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-b8333f39`]]),Hn={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Un(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Hn,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 7h16m-10 4v6m4-6v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`},null,-1)]])}var Wn=(0,e.markRaw)({name:`tabler-trash`,render:Un}),Gn={class:`toolbar-item color-item`,title:`颜色`},Kn=[`value`],qn=[`value`],Jn=[`value`],Yn=zt((0,e.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(t,{emit:n}){let r=n;function i(e){e.key===`Delete`&&(e.preventDefault(),r(`delete`))}(0,e.onMounted)(()=>document.addEventListener(`keydown`,i)),(0,e.onUnmounted)(()=>document.removeEventListener(`keydown`,i));function a(e){r(`updateStyle`,{stroke:e})}function o(e){r(`updateStyle`,{strokeWidth:e})}function s(e){r(`updateStyle`,{strokeStyle:e})}return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:`drawing-style-toolbar`,onPointerdown:r[4]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[5]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[6]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,Gn,[(0,e.createElementVNode)(`span`,{class:`color-swatch`,style:(0,e.normalizeStyle)({background:t.drawing.style.stroke??`#2962ff`})},null,4),(0,e.createElementVNode)(`input`,{type:`color`,class:`color-input`,value:t.drawing.style.stroke??`#2962ff`,onInput:r[0]||=e=>a(e.target.value)},null,40,Kn)]),(0,e.createElementVNode)(`select`,{class:`toolbar-select`,value:t.drawing.style.strokeWidth??1,onChange:r[1]||=e=>o(Number(e.target.value)),title:`线宽`},[...r[7]||=[(0,e.createElementVNode)(`option`,{value:1},`1px`,-1),(0,e.createElementVNode)(`option`,{value:2},`2px`,-1),(0,e.createElementVNode)(`option`,{value:3},`3px`,-1),(0,e.createElementVNode)(`option`,{value:4},`4px`,-1)]],40,qn),(0,e.createElementVNode)(`select`,{class:`toolbar-select`,value:t.drawing.style.strokeStyle??`solid`,onChange:r[2]||=e=>s(e.target.value),title:`线型`},[...r[8]||=[(0,e.createElementVNode)(`option`,{value:`solid`},`实线`,-1),(0,e.createElementVNode)(`option`,{value:`dashed`},`虚线`,-1),(0,e.createElementVNode)(`option`,{value:`dotted`},`点线`,-1)]],40,Jn),(0,e.createElementVNode)(`button`,{type:`button`,class:`toolbar-btn delete-btn`,title:`删除`,onClick:r[3]||=e=>n.$emit(`delete`)},[(0,e.createVNode)((0,e.unref)(Wn),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-92699cb2`]]),Xn=class{hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;hoveredCustomMarker=null;onMarkerHoverCallback;onMarkerClickCallback;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;setOnMarkerHover(e){this.onMarkerHoverCallback=e}setOnMarkerClick(e){this.onMarkerClickCallback=e}setOnCustomMarkerHover(e){this.onCustomMarkerHoverCallback=e}setOnCustomMarkerClick(e){this.onCustomMarkerClickCallback=e}handleClick(e){this.clickedMarkerId=e.id,this.clickedMarkerData=e,this.onMarkerClickCallback?.(e)}updateHoverFromPoint(e,t,n,r){let i=r.hitTest(e,n,3);if(i)return this.enterMarkerHover(i,r);this.leaveMarkerHover(r);let a=r.hitTestCustomMarker(t,n);return a?this.enterCustomMarkerHover(a,r):(this.leaveCustomMarkerHover(),!1)}enterMarkerHover(e,t){return this.hoveredMarkerId!==e.id&&(this.hoveredMarkerId=e.id,this.hoveredMarkerData=e,t.setHover(e.id),this.onMarkerHoverCallback?.(e)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null)),!0}leaveMarkerHover(e){this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,e.setHover(null),this.onMarkerHoverCallback?.(null))}enterCustomMarkerHover(e,t){return this.hoveredCustomMarker?.id!==e.id&&(this.hoveredCustomMarker=e,this.onCustomMarkerHoverCallback?.(e)),this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,t.setHover(null),this.onMarkerHoverCallback?.(null)),!0}leaveCustomMarkerHover(){this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null))}clearAll(e){this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,e.setHover(null),this.onMarkerHoverCallback?.(null)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null))}reset(){this.hoveredMarkerId=null,this.clickedMarkerId=null,this.hoveredMarkerData=null,this.clickedMarkerData=null,this.hoveredCustomMarker=null}},Zn=class{activePointers=new Map;lastPinchDistance=0;pinchCenter={x:0,y:0};isPinching=!1;onPinchZoomCallback;setOnPinchZoom(e){this.onPinchZoomCallback=e}getIsPinching(){return this.isPinching}getPointerCount(){return this.activePointers.size}handlePointerDown(e,t){if(this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.activePointers.size===2&&t){this.isPinching=!0;let e=Array.from(this.activePointers.values()),t=e[0],n=e[1];return this.lastPinchDistance=Math.hypot(n.x-t.x,n.y-t.y),this.pinchCenter={x:(t.x+n.x)/2,y:(t.y+n.y)/2},!0}return!1}handlePointerUp(e){this.activePointers.delete(e.pointerId),this.isPinching&&this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0)}handlePointerLeave(e){this.activePointers.delete(e.pointerId),this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0)}handlePointerMove(e){if(this.activePointers.has(e.pointerId)&&this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.isPinching&&this.activePointers.size===2){let e=Array.from(this.activePointers.values()),t=e[0],n=e[1],r=Math.hypot(n.x-t.x,n.y-t.y),i=r-this.lastPinchDistance;if(Math.abs(i)>10){let e=i>0?1:-1,a=(t.x+n.x)/2;this.onPinchZoomCallback?.(e,a),this.lastPinchDistance=r}return!0}return!1}reset(){this.activePointers.clear(),this.isPinching=!1,this.lastPinchDistance=0}};function Qn(e){if(e.useAnchorPositioning){let t=e.tooltipSize.width;return{anchorPlacement:e.mouseX+14+t+12>e.plotWidth?`left-bottom`:`right-bottom`,pos:{x:Math.min(Math.max(e.mouseX,12),Math.max(12,e.plotWidth-12)),y:Math.min(Math.max(e.mouseY,12),Math.max(12,e.plotHeight-12))}}}let t=e.tooltipSize.width,n=e.tooltipSize.height,r=e.mouseX+14,i=e.mouseX-14-t,a=r+t+12<=e.viewWidth?r:i,o=e.mouseY+14,s=Math.max(12,e.viewWidth-t-12),c=Math.max(12,e.viewHeight-n-12);return{pos:{x:Math.min(Math.max(a,12),s),y:Math.min(Math.max(o,12),c)}}}var $n=class{chart;isDragging=!1;dragMode=`none`;dragStartX=0;scrollStartX=0;applyPanScroll(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,t),n),i=this.chart.getCurrentDpr();e.scrollLeft=Math.round(r*i)/i}dragStartY=0;activePaneIdOnDrag=null;activeSeparatorUpperPaneId=null;hoveredSeparatorUpperPaneId=null;hoveredRightAxisPaneId=null;isTouchSession=!1;pinchTracker=new Zn;crosshairPos=null;crosshairIndex=null;crosshairPrice=null;hoveredIndex=null;activePaneId=null;tooltipPos={x:0,y:0};tooltipSize={width:220,height:180};tooltipAnchorPlacement=`right-bottom`;useTooltipAnchorPositioning=!1;onInteractionChangeCallback;settings={};markerState=new Xn;kLinePositions=null;visibleRange=null;lastHoverRenderKey=``;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.pinchTracker.setOnPinchZoom(e)}updateSettings(e){let t=this.settings.disableMainPaneVerticalScroll;this.settings={...e},!t&&this.settings.disableMainPaneVerticalScroll&&this.chart.resetPriceOffset(`main`)}getInteractionSnapshot(){return{crosshairPos:this.crosshairPos?{...this.crosshairPos}:null,crosshairIndex:this.crosshairIndex,crosshairPrice:this.crosshairPrice,hoveredIndex:this.hoveredIndex,activePaneId:this.activePaneId,tooltipPos:{...this.tooltipPos},tooltipAnchorPlacement:this.tooltipAnchorPlacement,hoveredMarkerData:this.markerState.hoveredMarkerData,hoveredCustomMarker:this.markerState.hoveredCustomMarker,isDragging:this.isDragging,isResizingPaneBoundary:this.dragMode===`resize-separator`,isHoveringPaneBoundary:this.hoveredSeparatorUpperPaneId!==null,hoveredPaneBoundaryId:this.hoveredSeparatorUpperPaneId,isHoveringRightAxis:this.hoveredRightAxisPaneId!==null}}setOnInteractionChange(e){this.onInteractionChangeCallback=e}notifyInteractionChange(){this.onInteractionChangeCallback?.(this.getInteractionSnapshot())}getHoverRenderKey(){let e=this.crosshairPos?Math.round(this.crosshairPos.x*this.chart.getCurrentDpr()):`n`,t=this.crosshairPos?Math.round(this.crosshairPos.y*this.chart.getCurrentDpr()):`n`;return[this.crosshairIndex??`n`,this.hoveredIndex??`n`,this.activePaneId??`n`,this.hoveredRightAxisPaneId??`n`,this.hoveredSeparatorUpperPaneId??`n`,this.markerState.hoveredMarkerId??`n`,this.markerState.hoveredCustomMarker?.id??`n`,e,t].join(`|`)}onPointerDown(e){if(this.isTouchSession=e.pointerType===`touch`,this.pinchTracker.handlePointerDown(e,this.isTouchSession)){this.isDragging=!1,this.dragMode=`none`;return}if(e.isPrimary===!1||this.pinchTracker.getIsPinching()||this.pinchTracker.getPointerCount()>1)return;let t=this.getPlotPointerLocation(e.clientX,e.clientY);if(!t)return;let{mouseX:n,mouseY:r}=t,i=this.chart.getCachedScrollLeft(),a=this.chart.getMarkerManager(),o=i+n,s=a.hitTest(o,r,3);if(s){this.markerState.handleClick(s);return}let c=this.hitTestPaneSeparator(r);if(c){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=c,this.hoveredSeparatorUpperPaneId=c,this.clearHover(),this.chart.scheduleDraw();return}let l=this.getPaneByY(r);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=this.chart.getCachedScrollLeft(),this.activePaneIdOnDrag=l?.id||null,this.chart.scheduleDraw()}setTooltipSize(e){this.tooltipSize=e}setTooltipAnchorPositioning(e){this.useTooltipAnchorPositioning=e}onPointerUp(e){this.pinchTracker.handlePointerUp(e),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.activeSeparatorUpperPaneId=null,this.notifyInteractionChange())}onPointerLeave(e){this.pinchTracker.handlePointerLeave(e),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange())}onScroll(){this.kLinePositions=null,this.visibleRange=null,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange()}onPointerMove(e){if(this.pinchTracker.handlePointerMove(e)||!e.isPrimary)return;e.pointerType===`touch`&&(this.isTouchSession=!0);let t=this.chart.getDom().container;if(this.isDragging){if(this.dragMode===`resize-separator`){let t=e.clientY-this.dragStartY;t!==0&&this.activeSeparatorUpperPaneId&&this.chart.resizePaneBoundary(this.activeSeparatorUpperPaneId,t)&&(this.dragStartY=e.clientY);return}if(this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}if(this.dragMode===`pan`){let n=this.dragStartX-e.clientX;this.applyPanScroll(t,this.scrollStartX+n);let r=e.clientY-this.dragStartY;this.dragStartY=e.clientY,r!==0&&this.activePaneIdOnDrag===`main`&&(this.settings.disableMainPaneVerticalScroll||this.chart.translatePrice(this.activePaneIdOnDrag,r))}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);if(!n)return;this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY);let r=this.getHoverRenderKey();r!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=r,this.chart.scheduleDraw(H.Overlay)),this.notifyInteractionChange()}setKLinePositions(e,t,n){this.kLinePositions=e,this.visibleRange=t,n!==void 0&&(this.kWidthPx=n)}onRightAxisPointerDown(e){if(e.isPrimary===!1)return;this.isTouchSession=e.pointerType===`touch`;let t=this.getRightAxisPointerLocation(e.clientX,e.clientY);t&&this.beginScalePriceDrag(e.clientY,t.mouseY)&&(this.chart.scheduleDraw(),this.notifyInteractionChange())}onRightAxisPointerMove(e){if(!e.isPrimary)return;if(e.pointerType===`touch`&&(this.isTouchSession=!0),this.isDragging&&this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}this.updateRightAxisHoverFromPoint(e.clientX,e.clientY);let t=this.getHoverRenderKey();t!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=t,this.chart.scheduleDraw(H.Overlay)),this.notifyInteractionChange()}onRightAxisPointerUp(e){this.onPointerUp(e)}onRightAxisPointerLeave(e){e.isPrimary!==!1&&(this.isDragging&&this.dragMode===`scale-price`||(this.hoveredRightAxisPaneId=null,this.notifyInteractionChange()))}isDraggingState(){return this.isDragging}setOnMarkerHover(e){this.markerState.setOnMarkerHover(e)}setOnMarkerClick(e){this.markerState.setOnMarkerClick(e)}setOnCustomMarkerHover(e){this.markerState.setOnCustomMarkerHover(e)}setOnCustomMarkerClick(e){this.markerState.setOnCustomMarkerClick(e)}hitTestPaneSeparator(e){let t=this.chart.getPaneRenderers();if(t.length<2)return null;for(let n=0;n<t.length-1;n++){let r=t[n]?.getPane(),i=t[n+1]?.getPane();if(!r||!i)continue;let a=r.top+r.height;if(Math.abs(e-a)<=5)return r.id}return null}getPaneByY(e){return this.chart.getPaneRenderers().find(t=>{let n=t.getPane();return e>=n.top&&e<=n.top+n.height})?.getPane()||null}getPlotPointerLocation(e,t){let n=this.chart.getDom().container.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}getRightAxisPointerLocation(e,t){let n=this.chart.getDom().rightAxisLayer.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}beginScalePriceDrag(e,t){let n=this.getPaneByY(t);return!n||n.id===`main`&&this.settings.disableMainPaneVerticalScroll?!1:(this.isDragging=!0,this.dragMode=`scale-price`,this.dragStartY=e,this.activePaneIdOnDrag=n.id,this.hoveredRightAxisPaneId=n.id,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=n.id,!0)}clearHover(){this.lastHoverRenderKey=``,this.hoveredRightAxisPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.markerState.clearAll(this.chart.getMarkerManager())}clearSeparatorState(){this.activeSeparatorUpperPaneId=null,this.hoveredSeparatorUpperPaneId=null,this.hoveredRightAxisPaneId=null}updateRightAxisHoverFromPoint(e,t){let n=this.getRightAxisPointerLocation(e,t);if(!n)return;let{mouseY:r}=n,i=this.chart.getViewport()?.plotHeight??Math.max(1,Math.round(this.chart.getDom().container.clientHeight));if(r<0||r>i){this.hoveredRightAxisPaneId=null;return}let a=this.getPaneByY(r);this.hoveredRightAxisPaneId=a?.id||null,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=a?.id||null}updatePlotHoverFromPoint(e,t){let n=this.getPlotPointerLocation(e,t);if(!n)return;let{mouseX:r,mouseY:i}=n,a=this.chart.getDom().container,o=this.chart.getViewport(),s=o?.viewWidth??Math.max(1,Math.round(a.clientWidth)),c=o?.viewHeight??Math.max(1,Math.round(a.clientHeight)),l=o?.plotWidth??s,u=o?.plotHeight??c;if(r<0||i<0||r>l||i>u){this.clearHover();return}this.hoveredRightAxisPaneId=null;let d=this.chart.getCachedScrollLeft(),f=this.chart.getCurrentDpr(),p=this.hitTestPaneSeparator(i);if(this.hoveredSeparatorUpperPaneId=p,p){this.clearHover();return}let m=this.chart.getMarkerManager(),h=d+r;if(this.markerState.updateHoverFromPoint(h,r,i,m)){this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}if(!this.kLinePositions||!this.visibleRange||!this.kWidthPx){this.clearHover();return}let g=this.kWidthPx/f,_=0,v=this.kLinePositions.length;for(;_<v;){let e=_+v>>1;this.kLinePositions[e]<h?_=e+1:v=e}let y=_;if(_>0&&_<this.kLinePositions.length){let e=this.kLinePositions[_-1]+g/2,t=this.kLinePositions[_]+g/2;Math.abs(h-e)<Math.abs(h-t)&&(y=_-1)}else _===this.kLinePositions.length&&this.kLinePositions.length>0&&(y=this.kLinePositions.length-1);let b=y+this.visibleRange.start,x=this.chart.getData(),S=this.getPaneByY(i);if(this.activePaneId=S?.id||null,b>=0&&b<(x?.length??0)){this.crosshairIndex=b;let e=this.kLinePositions[y],t=(Math.round(e*f)+(this.kWidthPx-1)/2)/f-d;if(this.crosshairPos={x:Math.min(Math.max(t,0),l),y:Math.min(Math.max(i,0),u)},S){let e=i-S.top;this.crosshairPrice=S.yAxis.yToPrice(e)}else this.crosshairPrice=null}else this.crosshairIndex=null,this.crosshairPos=null,this.crosshairPrice=null;let C=typeof this.crosshairIndex==`number`?x[this.crosshairIndex]:void 0;if(!C||!S||!S.capabilities.candleHitTest){this.hoveredIndex=null;return}let w=i-S.top,T=S.yAxis.priceToY(C.open),E=S.yAxis.priceToY(C.close),D=S.yAxis.priceToY(C.high),O=S.yAxis.priceToY(C.low),k=Math.min(T,E),A=Math.max(T,E),j=h-this.kLinePositions[y],M=g/2,N=Math.abs(A-k),P=N<8?(k+A)/2-8/2:k,F=N<8?(k+A)/2+8/2:A,I=w>=P&&w<=F&&j>=0&&j<=g,L=Math.abs(j-M)<=3&&w>=Math.min(D,O)&&w<=Math.max(D,O);if(!I&&!L){this.hoveredIndex=null;return}this.hoveredIndex=this.crosshairIndex;let ee=Qn({mouseX:r,mouseY:i,viewWidth:s,viewHeight:c,plotWidth:l,plotHeight:u,tooltipSize:this.tooltipSize,useAnchorPositioning:this.useTooltipAnchorPositioning});ee.anchorPlacement&&(this.tooltipAnchorPlacement=ee.anchorPlacement),this.tooltipPos=ee.pos}reset(){this.isDragging=!1,this.dragMode=`none`,this.dragStartX=0,this.dragStartY=0,this.scrollStartX=0,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.pinchTracker.reset(),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.markerState.reset(),this.kLinePositions=null,this.visibleRange=null,this.lastHoverRenderKey=``,this.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},er=class{canvas;gl=null;constructor(e){this.canvas=e??document.createElement(`canvas`),this.gl=this.initContext()}isAvailable(){return this.gl!==null}getGL(){return this.gl}getCanvas(){return this.canvas}resize(e,t,n){let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}getPhysicalRegion(e){return this.toPhysicalRegion(e)}bindRegion(e){let t=this.gl,n=this.toPhysicalRegion(e);if(!t||!n)return!1;let r=this.canvas.height-n.sourceY-n.heightPx;return t.enable(t.SCISSOR_TEST),t.viewport(n.sourceX,r,n.widthPx,n.heightPx),t.scissor(n.sourceX,r,n.widthPx,n.heightPx),!0}clearRegion(e){let t=this.gl;!t||!this.bindRegion(e)||(t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT))}compositeRegionTo(e,t,n={}){let r=this.toPhysicalRegion(t);if(!r||r.widthPx<=0||r.heightPx<=0)return;let i=e.imageSmoothingEnabled,a=e.globalAlpha,o=e.getTransform();n.imageSmoothingEnabled!==void 0&&(e.imageSmoothingEnabled=n.imageSmoothingEnabled),n.alpha!==void 0&&(e.globalAlpha=a*n.alpha),e.setTransform(1,0,0,1,0,0),e.drawImage(this.canvas,r.sourceX,r.sourceY,r.widthPx,r.heightPx,0,0,r.widthPx,r.heightPx),e.setTransform(o),e.globalAlpha=a,e.imageSmoothingEnabled=i}destroy(){this.canvas.width=1,this.canvas.height=1,this.gl=null}toPhysicalRegion(e){let t=Math.max(0,Math.round(e.width*e.dpr)),n=Math.max(0,Math.round(e.height*e.dpr));return t<=0||n<=0?null:{sourceX:Math.max(0,Math.round(e.x*e.dpr)),sourceY:Math.max(0,Math.round(e.y*e.dpr)),widthPx:t,heightPx:n}}initContext(){try{return this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{return null}}},tr=`#version 300 es
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vue`);var t=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}emit(e,t){let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[EventBus] Error in handler for "${e}":`,t)}})}once(e,t){let n=r=>{this.off(e,n),t(r)};this.on(e,n)}clear(){this.listeners.clear()}listenerCount(e){return this.listeners.get(e)?.size??0}},n=class e extends Error{constructor(e){super(e),this.name=`HttpError`}static isHttpError(t){return t instanceof e}};async function r(e,t){let r=new URLSearchParams;if(t?.params)for(let[e,n]of Object.entries(t.params))n!==void 0&&n!==``&&r.set(e,String(n));let i=r.toString(),a=i?`${e}?${i}`:e,o=new AbortController,s=t?.timeout?setTimeout(()=>o.abort(),t.timeout):void 0;try{let e=await fetch(a,{signal:o.signal});if(!e.ok)throw new n(`HTTP ${e.status}: ${e.statusText}`);return{data:await e.json()}}catch(e){throw e instanceof n?e:e?.name===`AbortError`?new n(`请求超时`):new n(e?.message||`网络请求失败`)}finally{clearTimeout(s)}}function i(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function a(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function o(e){return e&&{daily:`d`,weekly:`w`,monthly:`m`,5:`5`,15:`15`,30:`30`,60:`60`}[e]||`d`}function s(e){return e&&{qfq:`2`,hfq:`1`,none:`3`}[e]||`3`}function c(e){let t=i(e.date),n=e=>{let t=parseFloat(e);return Number.isNaN(t)?0:t};return{timestamp:a(t),stockCode:e.code,open:n(e.open),high:n(e.high),low:n(e.low),close:n(e.close),volume:n(e.volume),turnover:n(e.amount),changePercent:n(e.pctChg),turnoverRate:n(e.turn)}}var l=``,u=`/api/stock/kdata`;async function d(){let e=await(await fetch(`mock-stock-data.json`)).json();if(e.success&&e.data)return e.data.map(c).sort((e,t)=>e.timestamp-t.timestamp);throw Error(`Mock data failed`)}async function f(e){if(typeof window<`u`&&(window.location.hostname.includes(`github.io`)||window.location.hostname.includes(`localhost`)||window.location.hostname.includes(`127.0.0.1`)))return await d();let{timeout:t,...n}=e,i=`${l}${u}`,a={stock_code:n.symbol,start_date:n.start_date,end_date:n.end_date,frequency:o(n.period),adjustflag:s(n.adjust),timeout:t};try{let e=(await r(i,{params:a,timeout:t?t*1e3:void 0})).data;if(!e.success)throw Error(`获取K线数据失败: ${e.error_msg||`未知错误`} (code: ${e.error_code})`);return!e.data||e.data.length===0?[]:e.data.map(c).sort((e,t)=>e.timestamp-t.timestamp)}catch(e){try{return await d()}catch{}throw Error(`获取K线数据失败: ${e instanceof Error?e.message:String(e)}`)}}var p=`/api/public/stock_zh_a_hist`;function m(e){if(/^\d{8}$/.test(e))return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;if(/^\d{4}-\d{2}-\d{2}T/.test(e))return e.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function h(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)throw Error(`无法解析日期: ${e}`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return Date.UTC(n,r-1,i,-8,0,0,0)}function g(e){return{timestamp:h(m(e.日期)),stockCode:e.股票代码,open:e.开盘,close:e.收盘,high:e.最高,low:e.最低,volume:e.成交量,turnover:e.成交额,amplitude:e.振幅,changePercent:e.涨跌幅,changeAmount:e.涨跌额,turnoverRate:e.换手率}}async function _(e){try{let{timeout:t,...n}=e;return(await r(p,{params:n,timeout:t?t*1e3:void 0})).data.map(g)}catch(e){throw Error(`获取K线数据失败: ${e instanceof Error?e.message:String(e)}`)}}function v(e){return e.map(e=>({timestamp:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,stockCode:e.stockCode,volume:e.volume,turnover:e.turnover,amplitude:e.amplitude,changePercent:e.changePercent,changeAmount:e.changeAmount,turnoverRate:e.turnoverRate})).sort((e,t)=>e.timestamp-t.timestamp)}var y=new class{set(e,t){let n={data:t,timestamp:Date.now()};localStorage.setItem(e,JSON.stringify(n))}get(e,t=3600*1e3){let n=localStorage.getItem(e);if(!n)return null;try{let r=JSON.parse(n);return Date.now()-r.timestamp>t?(localStorage.removeItem(e),null):r.data}catch{return localStorage.removeItem(e),null}}remove(e){localStorage.removeItem(e)}clear(){localStorage.clear()}generateKey(e,t){return`${e}:${Object.keys(t).sort().map(e=>`${e}:${t[e]}`).join(`|`)}`}},b=class{name=`baostock`;async fetchKLineData(e){return f({symbol:this.addMarketPrefix(e.symbol),start_date:e.startDate,end_date:e.endDate,period:{daily:`daily`,weekly:`weekly`,monthly:`monthly`,"5min":`5`,"15min":`15`,"30min":`30`,"60min":`60`}[e.period]||`daily`,adjust:e.adjust,timeout:e.timeout})}addMarketPrefix(e){return/^(6|68)\d{5}$/.test(e)?`sh.${e}`:/^(0|3)\d{5}$/.test(e)?`sz.${e}`:e}},x=class{name=`dongcai`;async fetchKLineData(e){let t=e.startDate.replace(/-/g,``),n=e.endDate.replace(/-/g,``),r={daily:`daily`,weekly:`weekly`,monthly:`monthly`}[e.period];if(!r)throw Error(`东财数据源不支持周期: ${e.period}`);return v(await _({symbol:e.symbol,start_date:t,end_date:n,period:r,adjust:e.adjust===`none`?void 0:e.adjust,timeout:e.timeout}))}},S=class{static instances=new Map;static create(e){if(!this.instances.has(e))switch(e){case`baostock`:this.instances.set(e,new b);break;case`dongcai`:this.instances.set(e,new x);break;default:throw Error(`未知的数据源类型: ${e}`)}return this.instances.get(e)}},C=3600*1e3;function w(e,t){return y.generateKey(`kline:${e}`,{symbol:t.symbol,startDate:t.startDate,endDate:t.endDate,period:t.period,adjust:t.adjust})}async function T(e,t,n=!0){if(typeof window<`u`&&window.location.hostname.includes(`github.io`))return console.log(`[KLine] GitHub Pages 模式,加载 mock 数据`),d();let r=w(e,t);if(n){let e=y.get(r,C);if(e)return console.log(`[KLineCache] 命中缓存: ${r}`),e}try{let i=await S.create(e).fetchKLineData(t);return n&&i.length>0&&(y.set(r,i),console.log(`[KLineCache] 写入缓存: ${r}, ${i.length} 条数据`)),i}catch(e){let t=y.get(r,2**53-1);if(t)return console.warn(`[KLineCache] 网络请求失败,使用缓存回退: ${r}`,e),t;throw e}}var E=[`__proto__`,`constructor`,`prototype`],D=/^(#[0-9a-fA-F]{3,8}|rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*[\d.]+\s*\))$/,O={SH:/^(600|601|603|605|688)\d{3}$/,SZ:/^(000|001|002|003|300|301)\d{3}$/,BJ:/^(83|87|43|82)\d{4}$/};function k(e){return{"5min":30,"15min":60,"30min":90,"60min":180,daily:365*3,weekly:365*5,monthly:365*10}[e]??365}var A=(typeof document<`u`?document.createElement(`canvas`):null)?.getContext(`2d`)??null,j=class e{limits;_ajv=null;constructor(){this.limits={maxJsonSize:64*1024,maxIndicators:10,maxCustomMarkers:100}}async getAjv(){return this._ajv||=(async()=>{let e=(await import(`ajv`)).default,t=new e({allErrors:!0,allowUnionTypes:!0});t.addFormat(`date`,{type:`string`,validate:e=>/^\d{4}-\d{2}-\d{2}$/.test(e)});let n=await Promise.resolve().then(()=>require(`./schema-CzmPW09E.cjs`));return t.addSchema(n.default||n),t})(),this._ajv}validateRawInput(e){return(typeof TextEncoder<`u`?new TextEncoder().encode(e).byteLength:e.length*3)>this.limits.maxJsonSize?{valid:!1,errors:[`JSON payload too large (max 64KB)`]}:{valid:!0}}async validate(e){if(!e||typeof e!=`object`)return{valid:!1,errors:[`Config must be an object`]};let t=this.checkPrototypePollution(e);if(!t.valid)return t;try{let t=await this.getAjv();if(!t.validate(`https://kmap.dev/schemas/semantic-chart-config/1.0.0`,e))return{valid:!1,errors:t.errors?.map(e=>`${e.instancePath} ${e.message}`)||[`Schema validation failed`]}}catch{return{valid:!1,errors:[`Schema validation unavailable (ajv not loaded)`]}}return{valid:!0}}securityCheck(e){let t=[],n=this.checkDateRange(e.data);n.valid||t.push(...n.errors||[]);let r=this.checkSymbol(e.data);if(r.valid||t.push(...r.errors||[]),e.indicators&&(e.indicators.main?.length||0)+(e.indicators.sub?.length||0)>this.limits.maxIndicators&&t.push(`Too many indicators (max ${this.limits.maxIndicators})`),(e.markers?.customMarkers?.length||0)>this.limits.maxCustomMarkers&&t.push(`Too many custom markers (max ${this.limits.maxCustomMarkers})`),e.markers?.customMarkers)for(let n of e.markers.customMarkers){if(n.style){let e=this.checkMarkerStyle(n.style,n.id);t.push(...e)}let e=this.checkMarkerDate(n.date,n.id);t.push(...e)}return{passed:t.length===0,violations:t.length>0?t:void 0}}checkPrototypePollution(e,t=``){if(!e||typeof e!=`object`)return{valid:!0};let n=[];for(let r of Object.keys(e))E.includes(r)&&n.push(`Forbidden key "${r}" found at ${t}`);return n.length>0?{valid:!1,errors:n}:{valid:!0}}checkDateRange(e){let t=[],n=new Date(e.startDate),r=new Date(e.endDate);if(isNaN(n.getTime())&&t.push(`Invalid startDate: ${e.startDate}`),isNaN(r.getTime())&&t.push(`Invalid endDate: ${e.endDate}`),t.length>0)return{valid:!1,errors:t};let i=k(e.period),a=Math.ceil((r.getTime()-n.getTime())/(1e3*60*60*24));return a>i&&t.push(`Date range exceeds maximum for period "${e.period}" (max ${i} days, got ${a})`),a<0&&t.push(`endDate must be after startDate`),t.length>0?{valid:!1,errors:t}:{valid:!0}}checkSymbol(e){let{symbol:t,exchange:n}=e;if(n){if(!O[n].test(t))return{valid:!1,errors:[`Invalid symbol "${t}" for exchange "${n}"`]}}else if(!Object.values(O).some(e=>e.test(t)))return{valid:!1,errors:[`Invalid symbol format: "${t}"`]};return{valid:!0}}checkMarkerStyle(e,t){let n=[],r=[`fillColor`,`strokeColor`,`textColor`];for(let i of r){let r=e[i];typeof r==`string`&&!D.test(r)&&n.push(`Invalid ${i} in marker "${t}": ${r}`)}if(A)for(let i of r){let r=e[i];typeof r==`string`&&(A.fillStyle=`#000000`,A.fillStyle=r,A.fillStyle===`#000000`&&r!==`#000000`&&!r.startsWith(`#000`)&&n.push(`Potentially unsafe ${i} in marker "${t}": ${r}`))}return n}static DATE_PATTERN=/^\d{4}-\d{2}-\d{2}( \d{2}:\d{2})?$/;checkMarkerDate(t,n){let r=[];if(!e.DATE_PATTERN.test(t))return r.push(`Invalid date format in marker "${n}": ${t} (expected YYYY-MM-DD or YYYY-MM-DD HH:mm)`),r;let i=t.includes(` `),a;if(i)a=new Date(t);else{let[e,n,r]=t.split(`-`).map(Number);a=new Date(Date.UTC(e,n-1,r))}return isNaN(a.getTime())&&r.push(`Invalid date value in marker "${n}": ${t}`),r}},M=class{chart;validator;events;constructor(e){this.chart=e,this.validator=new j,this.events=new t}async applyConfig(e){let t=await this.validator.validate(e);if(!t.valid)return{success:!1,errors:t.errors};let n=this.validator.securityCheck(e);if(!n.passed)return{success:!1,errors:n.violations};this.events.emit(`config:loading`,void 0);try{return await this.doApplyConfig(e),this.events.emit(`config:ready`,void 0),{success:!0}}catch(e){return this.events.emit(`config:error`,e),{success:!1,errors:[e instanceof Error?e.message:String(e)]}}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async doApplyConfig(e){console.log(`[Semantic] doApplyConfig start, data config:`,e.data);let t=await T(e.data.source,{symbol:e.data.symbol,startDate:e.data.startDate,endDate:e.data.endDate,period:e.data.period,adjust:e.data.adjust});console.log(`[Semantic] fetched data:`,t.length,`items`),this.chart.updateData(t),e.indicators&&(console.log(`[Semantic] applying indicators:`,e.indicators),this.applyIndicators(e.indicators.main,e.indicators.sub)),e.markers&&(console.log(`[Semantic] applying markers:`,e.markers.customMarkers?.length,`markers`),this.applyMarkers(e.markers.customMarkers,e.data.period)),e.chart&&this.applyChartOptions(e.chart),console.log(`[Semantic] doApplyConfig done`)}applyIndicators(e,t){if(e){for(let t of e)if(t.enabled)switch(t.type){case`MA`:this.applyMAIndicator(t);break;case`BOLL`:this.applyBOLLIndicator(t);break;case`EXPMA`:this.applyEXPMAIndicator(t);break;case`ENE`:this.applyENEIndicator(t);break}}if(this.chart.clearSubPanes(),t)for(let e of t)this.applySubIndicator(e)}applyMAIndicator(e){let t=e.params?.periods||[5,10,20,30,60],n={};for(let e of t)e===5?n.ma5=!0:e===10?n.ma10=!0:e===20?n.ma20=!0:e===30?n.ma30=!0:e===60&&(n.ma60=!0);console.log(`[Semantic] applyMAIndicator, periods:`,t,`maFlags:`,n),this.chart.updateRendererConfig(`ma`,n)}applyBOLLIndicator(e){let t={period:e.params?.period||20,multiplier:e.params?.multiplier||2};this.chart.updateRendererConfig(`boll`,t)}applyEXPMAIndicator(e){let t={fastPeriod:e.params?.fastPeriod||12,slowPeriod:e.params?.slowPeriod||50};this.chart.updateRendererConfig(`expma`,t)}applyENEIndicator(e){let t={period:e.params?.period||10,deviation:e.params?.deviation||11};this.chart.updateRendererConfig(`ene`,t)}applySubIndicator(e){if(!e.enabled)return;let{type:t,params:n}=e,r=`${t}_0`;this.chart.createSubPane(r,t,n)||console.warn(`[Semantic] Failed to create sub pane for ${t}`)}applyMarkers(e,t){if(!e||e.length===0){this.chart.clearCustomMarkers();return}let n=e.map(e=>({id:e.id,date:e.date,timestamp:N(e.date,t||`daily`),shape:e.shape,groupKey:e.groupKey,offset:e.offset,style:e.style,label:e.label,metadata:e.metadata}));this.chart.updateCustomMarkers(n)}applyChartOptions(e){e.autoScrollToRight}};function N(e,t){if(e.includes(` `)){let[t,n]=e.split(` `),r=t.split(`-`).map(Number),i=r[0],a=r[1],o=r[2],s=n.split(`:`).map(Number),c=s[0],l=s[1];return Date.UTC(i,a-1,o,c-8,l,0,0)}else{let t=e.split(`-`).map(Number),n=t[0],r=t[1],i=t[2];return Date.UTC(n,r-1,i,-8,0,0,0)}}var P={arrow_up:16,arrow_down:16,flag:14,circle:12,rectangle:14,diamond:12};function F(e,t,n,r,i,a){let o=a.fillColor||`#000000`,s=a.strokeColor||o,c=i||P[t];switch(e.fillStyle=o,e.strokeStyle=s,e.lineWidth=a.lineWidth||1,a.opacity!==void 0&&(e.globalAlpha=a.opacity),t){case`arrow_up`:te(e,n,r,c);break;case`arrow_down`:ne(e,n,r,c);break;case`circle`:re(e,n,r,c);break;case`rectangle`:ie(e,n,r,c);break;case`diamond`:ae(e,n,r,c);break;case`flag`:oe(e,n,r,c);break}e.globalAlpha=1}var I=2.5,L=4;function ee(e,t,n,r,i,a,o=!1){let s=t.fontSize||12,c=a.textColor||`#333333`,l=i/2;e.font=`${s}px sans-serif`,e.fillStyle=c,e.textBaseline=`middle`;let u=i*I,d=R(e,t.text,u),f=e.measureText(d).width,p=n,m=r;switch(t.position){case`left`:p=n-l-f/2-L;break;case`right`:p=n+l+f/2+L;break;case`top`:m=r-l-s/2-L;break;case`bottom`:m=r+l+s/2+L;break;default:m=o?r-l-s/2-L:r+l+s/2+L;break}t.offset&&(p+=t.offset.x||0,m+=t.offset.y||0),e.textAlign=t.align||`center`,e.fillText(d,p,m)}function R(e,t,n){if(e.measureText(t).width<=n)return t;let r=e.measureText(`…`).width,i=0,a=t.length;for(;i<a;){let o=Math.ceil((i+a)/2),s=t.slice(0,o);e.measureText(s).width+r<=n?i=o:a=o-1}return t.slice(0,i)+`…`}function te(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t-r/2,n+r/2),e.lineTo(t+r/2,n+r/2),e.closePath(),e.fill()}function ne(e,t,n,r){e.beginPath(),e.moveTo(t,n+r/2),e.lineTo(t-r/2,n-r/2),e.lineTo(t+r/2,n-r/2),e.closePath(),e.fill()}function re(e,t,n,r){e.beginPath(),e.arc(t,n,r/2,0,Math.PI*2),e.fill()}function ie(e,t,n,r){e.fillRect(t-r/2,n-r/2,r,r)}function ae(e,t,n,r){e.beginPath(),e.moveTo(t,n-r/2),e.lineTo(t+r/2,n),e.lineTo(t,n+r/2),e.lineTo(t-r/2,n),e.closePath(),e.fill()}function oe(e,t,n,r){e.beginPath(),e.moveTo(t-r/4,n+r/2),e.lineTo(t-r/4,n-r/2),e.stroke(),e.beginPath(),e.moveTo(t-r/4,n-r/2),e.lineTo(t+r/2,n-r/4),e.lineTo(t-r/4,n),e.closePath(),e.fill()}function se(e,t,n,r,i,a){let o=a/2;switch(n){case`circle`:let n=e-r,a=t-i;return n*n+a*a<=o*o;default:return e>=r-o&&e<=r+o&&t>=i-o&&t<=i+o}}var ce=new Intl.DateTimeFormat(`zh-CN`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`}),le=1024,ue=new Map;function de(e){let t=ue.get(e);if(t!==void 0)return t;let n=ce.formatToParts(new Date(e)),r=``,i=``,a=``;for(let e=0;e<n.length;e++){let t=n[e];t.type===`year`?r=t.value:t.type===`month`?i=t.value:t.type===`day`&&(a=t.value)}let o=`${r}-${i}-${a}`;return ue.size>=le&&ue.clear(),ue.set(e,o),o}var fe=512,pe=new Map;function me(e){let t=pe.get(e);if(t!==void 0)return t;let n=new Date(e),r=n.getFullYear(),i=n.getMonth()+1,a=i===1?{text:String(r),isYear:!0}:{text:`${i}月`,isYear:!1};return pe.size>=fe&&pe.clear(),pe.set(e,a),a}function he(e){let t=new Date(e);return t.getFullYear()*12+t.getMonth()}var ge=de,_e=de,ve=null,ye=0,be=0,xe=0,Se=[];function Ce(e){if(e.length===0)return[];if(ve===e&&ye===e.length){let t=e[0]?.timestamp,n=e[e.length-1]?.timestamp;if(t===be&&n===xe)return Se}let t=[0],n=he(e[0].timestamp);for(let r=1;r<e.length;r++){let i=e[r];if(!i)continue;let a=he(i.timestamp);a!==n&&(t.push(r),n=a)}return ve=e,ye=e.length,be=e[0]?.timestamp??0,xe=e[e.length-1]?.timestamp??0,Se=t,t}var we={PRIMARY:`hsl(210, 9%, 31%)`,SECONDARY:`hsl(210, 9%, 35%)`,TERTIARY:`hsl(210, 8%, 50%)`,WEAK:`hsl(210, 7%, 65%)`,WHITE:`rgba(255, 255, 255, 0.92)`},Te={UP:`rgba(214, 10, 34, 1)`,UP_LIGHT:`rgba(214, 10, 34, 0.92)`,UP_TICK:`hsl(0, 60%, 50%)`,DOWN:`rgba(3, 123, 102, 1)`,DOWN_LIGHT:`rgba(3, 123, 102, 0.92)`,DOWN_TICK:`hsl(150, 30%, 60%)`,NEUTRAL:`rgba(0, 0, 0, 0.78)`,LAST_PRICE:`rgba(196, 74, 86, 0.95)`},Ee={WHITE:`rgb(255, 255, 255)`,LIGHT_GRAY:`rgba(255, 255, 255, 0.92)`,PURE_WHITE:`#ffffff`,TRANSPARENT:`transparent`,ACTIVE:`#1890ff`,ACTIVE_HOVER:`#40a9ff`,HOVER:`#f0f0f0`},De={DARK:`rgba(0, 0, 0, 0.12)`,MEDIUM:`rgba(0, 0, 0, 0.10)`,LIGHT:`rgba(0, 0, 0, 0.08)`,SEPARATOR:`rgba(0, 0, 0, 0.10)`,BUTTON:`#d0d0d0`},Oe={HORIZONTAL:`rgba(0, 0, 0, 0.06)`,VERTICAL:`rgba(0, 0, 0, 0.12)`},ke={LINE:`rgba(0, 0, 0, 0.28)`,LABEL_BG:`rgb(0, 0, 0)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`},Ae={MA5:`rgba(255, 193, 37, 1)`,MA10:`rgba(190, 131, 12, 1)`,MA20:`rgba(69, 112, 249, 1)`,MA30:`rgba(76, 175, 80, 1)`,MA60:`rgba(156, 39, 176, 1)`},je={UPPER:`rgba(178, 34, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(34, 139, 34, 1)`,BAND_FILL:`rgba(100, 149, 237, 0.1)`},Me={DIF:`rgba(69, 112, 249, 1)`,DEA:`rgba(255, 152, 0, 1)`,BAR_UP:`#ff5252`,BAR_UP_LIGHT:`#fccbcd`,BAR_DOWN:`#22ab94`,BAR_DOWN_LIGHT:`#ace5dc`},Ne={UP:`#ff5252`,DOWN:`#22ab94`,NEUTRAL:`rgba(0, 0, 0, 0.78)`},Pe={RSI1:`rgba(69, 112, 249, 1)`,RSI2:`rgba(255, 152, 0, 1)`,RSI3:`rgba(156, 39, 176, 1)`},Fe={CCI:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Ie={K:`rgba(69, 112, 249, 1)`,D:`rgba(255, 152, 0, 1)`,J:`rgba(156, 39, 176, 1)`},z={MOM:`rgba(69, 112, 249, 1)`,ZERO:`rgba(0, 0, 0, 0.2)`},Le={WMSR:`rgba(69, 112, 249, 1)`,OVERBOUGHT:`rgba(214, 10, 34, 0.5)`,OVERSOLD:`rgba(3, 123, 102, 0.5)`},Re={KST:`rgba(69, 112, 249, 1)`,SIGNAL:`rgba(255, 152, 0, 1)`},ze={FAST:`rgba(255, 152, 0, 1)`,SLOW:`rgba(69, 112, 249, 1)`},Be={UPPER:`rgba(214, 10, 34, 1)`,MIDDLE:`rgba(69, 112, 249, 1)`,LOWER:`rgba(3, 123, 102, 1)`,BAND_FILL:`rgba(69, 112, 249, 0.08)`},Ve={BG:`rgba(0, 0, 0, 0.8)`,TEXT:`#ffffff`},He={BG:`rgba(255, 247, 248, 0.98)`},Ue={RISE_WITH:`#FF4444`,RISE_WITHOUT:`#00C853`,FALL_WITH:`#FF4444`,FALL_WITHOUT:`#00C853`},We={HH:`#16a34a`,HL:`#22c55e`,LH:`#dc2626`,LL:`#ef4444`,CHOCH:`#8b5cf6`,BOS:`#f59e0b`},B={FVG_BULL_FILL:`rgba(34, 197, 94, 0.15)`,FVG_BEAR_FILL:`rgba(239, 68, 68, 0.15)`,FVG_BULL_BORDER:`rgba(34, 197, 94, 0.6)`,FVG_BEAR_BORDER:`rgba(239, 68, 68, 0.6)`,OB_BULL_FILL:`rgba(34, 197, 94, 0.25)`,OB_BEAR_FILL:`rgba(239, 68, 68, 0.25)`},Ge={PRIMARY:`hsl(210, 10%, 85%)`,SECONDARY:`hsl(210, 8%, 75%)`,TERTIARY:`hsl(210, 6%, 60%)`,WEAK:`hsl(210, 5%, 45%)`,WHITE:`rgba(255, 255, 255, 0.95)`},Ke={UP:`rgba(255, 80, 100, 1)`,UP_LIGHT:`rgba(255, 80, 100, 0.85)`,UP_TICK:`hsl(0, 70%, 60%)`,DOWN:`rgba(60, 200, 160, 1)`,DOWN_LIGHT:`rgba(60, 200, 160, 0.85)`,DOWN_TICK:`hsl(150, 50%, 65%)`,NEUTRAL:`rgba(255, 255, 255, 0.7)`,LAST_PRICE:`rgba(230, 100, 115, 0.95)`},qe={WHITE:`rgb(40, 40, 55)`,LIGHT_GRAY:`rgba(50, 50, 65, 0.92)`,PURE_WHITE:`#282837`,TRANSPARENT:`transparent`,ACTIVE:`#1890ff`,ACTIVE_HOVER:`#40a9ff`,HOVER:`#3a3a4a`},Je={DARK:`rgba(255, 255, 255, 0.15)`,MEDIUM:`rgba(255, 255, 255, 0.12)`,LIGHT:`rgba(255, 255, 255, 0.08)`,SEPARATOR:`rgba(255, 255, 255, 0.10)`,BUTTON:`#505060`},Ye={HORIZONTAL:`rgba(255, 255, 255, 0.06)`,VERTICAL:`rgba(255, 255, 255, 0.10)`},Xe={LINE:`rgba(255, 255, 255, 0.4)`,LABEL_BG:`rgb(40, 40, 55)`,LABEL_TEXT:`rgba(255, 255, 255, 0.92)`},Ze={MA5:`rgba(255, 200, 50, 1)`,MA10:`rgba(200, 150, 30, 1)`,MA20:`rgba(90, 140, 255, 1)`,MA30:`rgba(90, 190, 95, 1)`,MA60:`rgba(170, 60, 195, 1)`},Qe={UPPER:`rgba(200, 60, 60, 1)`,MIDDLE:`rgba(90, 140, 255, 1)`,LOWER:`rgba(50, 170, 60, 1)`,BAND_FILL:`rgba(120, 170, 255, 0.15)`},$e={DIF:`rgba(90, 140, 255, 1)`,DEA:`rgba(255, 170, 50, 1)`,BAR_UP:`#ff6b6b`,BAR_UP_LIGHT:`#ffb3b3`,BAR_DOWN:`#4ecdc4`,BAR_DOWN_LIGHT:`#a8e6e1`},et={UP:`#ff6b6b`,DOWN:`#4ecdc4`,NEUTRAL:`rgba(255, 255, 255, 0.6)`},tt={RSI1:`rgba(90, 140, 255, 1)`,RSI2:`rgba(255, 170, 50, 1)`,RSI3:`rgba(180, 70, 205, 1)`},nt={CCI:`rgba(90, 140, 255, 1)`,OVERBOUGHT:`rgba(255, 80, 100, 0.6)`,OVERSOLD:`rgba(60, 200, 160, 0.6)`},rt={K:`rgba(90, 140, 255, 1)`,D:`rgba(255, 170, 50, 1)`,J:`rgba(180, 70, 205, 1)`},it={MOM:`rgba(90, 140, 255, 1)`,ZERO:`rgba(255, 255, 255, 0.2)`},at={WMSR:`rgba(90, 140, 255, 1)`,OVERBOUGHT:`rgba(255, 80, 100, 0.6)`,OVERSOLD:`rgba(60, 200, 160, 0.6)`},ot={KST:`rgba(90, 140, 255, 1)`,SIGNAL:`rgba(255, 170, 50, 1)`},st={FAST:`rgba(255, 170, 50, 1)`,SLOW:`rgba(90, 140, 255, 1)`},ct={UPPER:`rgba(255, 80, 100, 1)`,MIDDLE:`rgba(90, 140, 255, 1)`,LOWER:`rgba(60, 200, 160, 1)`,BAND_FILL:`rgba(90, 140, 255, 0.12)`},lt={BG:`rgba(30, 30, 40, 0.9)`,TEXT:`#ffffff`},ut={BG:`rgba(60, 50, 55, 0.98)`},dt={RISE_WITH:`#FF6666`,RISE_WITHOUT:`#66FF99`,FALL_WITH:`#FF6666`,FALL_WITHOUT:`#66FF99`},ft={HH:`#4ade80`,HL:`#22c55e`,LH:`#f87171`,LL:`#ef4444`,CHOCH:`#a78bfa`,BOS:`#fbbf24`},pt={FVG_BULL_FILL:`rgba(74, 222, 128, 0.20)`,FVG_BEAR_FILL:`rgba(248, 113, 113, 0.20)`,FVG_BULL_BORDER:`rgba(74, 222, 128, 0.8)`,FVG_BEAR_BORDER:`rgba(248, 113, 113, 0.8)`,OB_BULL_FILL:`rgba(74, 222, 128, 0.35)`,OB_BEAR_FILL:`rgba(248, 113, 113, 0.35)`},mt={TEXT:we,PRICE:Te,TAG_BG:Ee,BORDER:De,GRID:Oe,CROSSHAIR:ke,MA:Ae,BOLL:je,MACD:Me,VOLUME:Ne,RSI:Pe,CCI:Fe,KDJ:Ie,MOM:z,WMSR:Le,KST:Re,EXPMA:ze,ENE:Be,LABEL:Ve,LAST_PRICE_LABEL:He,VOLUME_PRICE:Ue,STRUCTURE:We,ZONES:B,WMSR_GRID:`rgba(0, 0, 0, 0.1)`},ht={TEXT:Ge,PRICE:Ke,TAG_BG:qe,BORDER:Je,GRID:Ye,CROSSHAIR:Xe,MA:Ze,BOLL:Qe,MACD:$e,VOLUME:et,RSI:tt,CCI:nt,KDJ:rt,MOM:it,WMSR:at,KST:ot,EXPMA:st,ENE:ct,LABEL:lt,LAST_PRICE_LABEL:ut,VOLUME_PRICE:dt,STRUCTURE:ft,ZONES:pt,WMSR_GRID:`rgba(255, 255, 255, 0.1)`};function V(e){return e===`dark`?ht:mt}function gt(e,t=`light`){let n=V(t);return e>0?n.PRICE.UP:e<0?n.PRICE.DOWN:n.PRICE.NEUTRAL}function _t(e,t=2){let n=Math.abs(e);return n>=1e8?`${(e/1e8).toFixed(t)}亿`:n>=1e4?`${(e/1e4).toFixed(t)}万`:`${Math.round(e)}`}function vt(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}`}function yt(e,t=2){return`${e.toFixed(t)}%`}function bt(e,t=2){return`${e>0?`+`:``}${e.toFixed(t)}%`}function xt(e,t,n=`light`){let r=t?.close??e.open;return gt(e.open-r,n)}function St(e,t=`light`){return gt(e.close-e.open,t)}function Ct(e,t=`light`){let n=V(t);return typeof e.changePercent==`number`?gt(e.changePercent,t):typeof e.changeAmount==`number`?gt(e.changeAmount,t):n.PRICE.NEUTRAL}var wt={class:`kline-tooltip__title`},Tt={key:0},Et={class:`kline-tooltip__grid`},Dt={class:`row`},Ot={class:`row`},kt={class:`row`},At={class:`row`},jt={key:0,class:`row`},Mt={key:1,class:`row`},Nt={key:2,class:`row`},Pt={key:3,class:`row`},Ft={key:4,class:`row`},It={key:5,class:`row`},Lt=(0,e.defineComponent)({__name:`KLineTooltip`,props:{k:{},index:{},data:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(t){let n=t,r=(0,e.computed)(()=>n.useAnchor===!0),i=(0,e.computed)(()=>n.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function a(e){n.setEl?.(e)}let o=(0,e.computed)(()=>{let e=n.k;if(!e)return V(`light`).PRICE.NEUTRAL;let t=n.index;return xt(e,typeof t==`number`&&t>0?n.data[t-1]:void 0)}),s=(0,e.computed)(()=>{let e=n.k;return e?St(e):V(`light`).PRICE.NEUTRAL}),c=(0,e.computed)(()=>{let e=n.k;return e?Ct(e):V(`light`).PRICE.NEUTRAL});return(n,l)=>t.k?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,ref:a,class:(0,e.normalizeClass)([`kline-tooltip`,[{"use-anchor":r.value},i.value]]),style:(0,e.normalizeStyle)(r.value?void 0:{left:`${t.pos.x}px`,top:`${t.pos.y}px`})},[(0,e.createElementVNode)(`div`,wt,[t.k.stockCode?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Tt,(0,e.toDisplayString)(t.k.stockCode),1)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(ge)(t.k.timestamp)),1)]),(0,e.createElementVNode)(`div`,Et,[(0,e.createElementVNode)(`div`,Dt,[l[0]||=(0,e.createElementVNode)(`span`,null,`开`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:o.value})},(0,e.toDisplayString)(t.k.open.toFixed(2)),5)]),(0,e.createElementVNode)(`div`,Ot,[l[1]||=(0,e.createElementVNode)(`span`,null,`高`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.high.toFixed(2)),1)]),(0,e.createElementVNode)(`div`,kt,[l[2]||=(0,e.createElementVNode)(`span`,null,`低`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.low.toFixed(2)),1)]),(0,e.createElementVNode)(`div`,At,[l[3]||=(0,e.createElementVNode)(`span`,null,`收`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:s.value})},(0,e.toDisplayString)(t.k.close.toFixed(2)),5)]),typeof t.k.volume==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,jt,[l[4]||=(0,e.createElementVNode)(`span`,null,`成交量`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(_t)(t.k.volume)),1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.turnover==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Mt,[l[5]||=(0,e.createElementVNode)(`span`,null,`成交额`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(_t)(t.k.turnover)),1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.amplitude==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Nt,[l[6]||=(0,e.createElementVNode)(`span`,null,`振幅`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.k.amplitude)+`%`,1)])):(0,e.createCommentVNode)(``,!0),typeof t.k.changePercent==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Pt,[l[7]||=(0,e.createElementVNode)(`span`,null,`涨跌幅`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:c.value})},(0,e.toDisplayString)((0,e.unref)(bt)(t.k.changePercent)),5)])):(0,e.createCommentVNode)(``,!0),typeof t.k.changeAmount==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Ft,[l[8]||=(0,e.createElementVNode)(`span`,null,`涨跌额`,-1),(0,e.createElementVNode)(`span`,{style:(0,e.normalizeStyle)({color:c.value})},(0,e.toDisplayString)((0,e.unref)(vt)(t.k.changeAmount)),5)])):(0,e.createCommentVNode)(``,!0),typeof t.k.turnoverRate==`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,It,[l[9]||=(0,e.createElementVNode)(`span`,null,`换手率`,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)((0,e.unref)(yt)(t.k.turnoverRate)),1)])):(0,e.createCommentVNode)(``,!0)])],6)):(0,e.createCommentVNode)(``,!0)}}),Rt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},zt=Rt(Lt,[[`__scopeId`,`data-v-623c9424`]]),Bt={RISE_WITH_VOLUME:`量价齐升`,RISE_WITHOUT_VOLUME:`量缩价升`,FALL_WITH_VOLUME:`量价齐缩`,FALL_WITHOUT_VOLUME:`量升价缩`},Vt=class{markers=new Map;hoveredMarkerId=null;lastHoveredId=null;customMarkers=new Map;customMarkerPositions=new Map;clear(){this.markers.clear()}register(e){this.markers.set(e.id,e)}getState(e){return this.hoveredMarkerId===e?`hovered`:`normal`}hitTest(e,t,n=3){for(let r of this.markers.values())if(e>=r.x-n&&e<=r.x+r.width+n&&t>=r.y-n&&t<=r.y+r.height+n)return r;return null}setHover(e){this.hoveredMarkerId=e,this.lastHoveredId=e}validateHoverState(){this.hoveredMarkerId!==null&&!this.markers.has(this.hoveredMarkerId)&&(this.hoveredMarkerId=null)}getHoveredMarker(){return this.hoveredMarkerId===null?null:this.markers.get(this.hoveredMarkerId)||null}getLastHoverId(){return this.lastHoveredId}getAllMarkers(){return Array.from(this.markers.values())}registerCustomMarker(e){this.customMarkers.set(e.id,e)}setCustomMarkers(e){this.clearCustomMarkers();for(let t of e)this.customMarkers.set(t.id,t)}clearCustomMarkers(){this.customMarkers.clear(),this.customMarkerPositions.clear()}getCustomMarkers(){return Array.from(this.customMarkers.values())}setCustomMarkerPosition(e,t,n,r,i){this.customMarkerPositions.set(e,{x:t,y:n,size:r,shape:i})}hitTestCustomMarker(e,t){for(let n of this.customMarkers.values()){let r=this.customMarkerPositions.get(n.id);if(r&&se(e,t,r.shape,r.x,r.y,r.size))return n}return null}},Ht={class:`marker-tooltip__title`},Ut={key:0,class:`marker-tooltip__content`},Wt=Rt((0,e.defineComponent)({__name:`MarkerTooltip`,props:{marker:{},pos:{},useAnchor:{type:Boolean},anchorPlacement:{},setEl:{type:Function}},setup(t){let n=t,r=(0,e.computed)(()=>n.useAnchor===!0),i=(0,e.computed)(()=>n.anchorPlacement===`left-bottom`?`anchor-left-bottom`:`anchor-right-bottom`);function a(e){n.setEl?.(e)}let o=(0,e.computed)(()=>n.marker&&`date`in n.marker),s=(0,e.computed)(()=>{if(!n.marker)return``;if(o.value){let e=n.marker;return e.label?.text||e.shape}let e=n.marker;return Bt[e.markerType]||e.markerType}),c=(0,e.computed)(()=>{if(!n.marker)return{};if(o.value){let e=n.marker;return{日期:e.date,...e.metadata}}return n.marker.metadata}),l=(0,e.computed)(()=>Object.keys(c.value).length>0);function u(e){return typeof e==`number`?e.toFixed(2):String(e)}return(n,o)=>t.marker?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,ref:a,class:(0,e.normalizeClass)([`marker-tooltip`,[{"use-anchor":r.value},i.value]]),style:(0,e.normalizeStyle)(r.value?void 0:{left:`${t.pos.x+12}px`,top:`${t.pos.y+12}px`})},[(0,e.createElementVNode)(`div`,Ht,(0,e.toDisplayString)(s.value),1),l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Ut,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(c.value,(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n,class:`row`},[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(n),1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(u(t)),1)]))),128))])):(0,e.createCommentVNode)(``,!0)],6)):(0,e.createCommentVNode)(``,!0)}}),[[`__scopeId`,`data-v-5574cc25`]]),Gt=Symbol(`fullscreen-teleport-target`);function Kt(){let t=(0,e.inject)(Gt,null);return(0,e.computed)(()=>t?.value??`body`)}var qt={class:`params-header`},Jt={class:`header-left`},Yt={class:`params-title`},Xt={class:`header-right`},Zt={key:0,class:`indicator-description`},Qt={class:`params-body`},$t={class:`param-header`},en={class:`param-label`},tn={class:`param-label-text`},nn={key:0,class:`param-range`},rn={class:`input-wrapper`},an=[`disabled`,`onClick`],on=[`value`,`min`,`max`,`step`,`onInput`],sn=[`disabled`,`onClick`],cn={key:0,class:`param-description`},ln={class:`params-footer`},un={class:`footer-right`},dn=Rt((0,e.defineComponent)({__name:`IndicatorParams`,props:{visible:{type:Boolean},indicatorId:{},indicatorName:{},indicatorDescription:{},params:{},values:{}},emits:[`close`,`confirm`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.ref)({...r.values}),o=(0,e.ref)(!0),s=Kt();(0,e.watch)(()=>r.values,e=>{a.value={...e}},{deep:!0,immediate:!0}),(0,e.watch)(()=>r.visible,e=>{e&&(a.value={...r.values})});function c(e,t){let n=t.target,r=parseFloat(n.value);isNaN(r)||(a.value[e]=r)}function l(e,t){let n=e.step||1,r=(a.value[e.key]||0)+t*n;e.min!==void 0&&(r=Math.max(e.min,r)),e.max!==void 0&&(r=Math.min(e.max,r)),a.value[e.key]=parseFloat(r.toFixed(10))}function u(){let e={};r.params.forEach(t=>{e[t.key]=t.default??r.values[t.key]??0}),a.value=e}function d(){i(`confirm`,{...a.value})}return(n,r)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(s)},[(0,e.createVNode)(e.Transition,{name:`overlay`},{default:(0,e.withCtx)(()=>[t.visible?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`params-overlay`,onClick:r[4]||=e=>n.$emit(`close`)},[(0,e.createVNode)(e.Transition,{name:`modal`},{default:(0,e.withCtx)(()=>[(0,e.createElementVNode)(`div`,{class:`indicator-params`,onClick:r[3]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,qt,[(0,e.createElementVNode)(`div`,Jt,[(0,e.createElementVNode)(`span`,Yt,(0,e.toDisplayString)(t.indicatorName),1),r[5]||=(0,e.createElementVNode)(`span`,{class:`params-subtitle`},`参数设置`,-1)]),(0,e.createElementVNode)(`div`,Xt,[(0,e.createElementVNode)(`button`,{class:(0,e.normalizeClass)([`toggle-desc-btn`,{active:o.value}]),onClick:r[0]||=e=>o.value=!o.value,title:`显示/隐藏说明`},[...r[6]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 1024 1024`},[(0,e.createElementVNode)(`path`,{d:`M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 268.190476v292.571428h-73.142858V438.857143h73.142858z m0-121.904762v73.142857h-73.142858v-73.142857h73.142858z`,fill:`currentColor`})],-1)]],2),(0,e.createElementVNode)(`button`,{class:`params-close`,onClick:r[1]||=e=>n.$emit(`close`)},[...r[7]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,e.createVNode)(e.Transition,{name:`slide`},{default:(0,e.withCtx)(()=>[o.value&&t.indicatorDescription?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Zt,[(0,e.createElementVNode)(`p`,null,(0,e.toDisplayString)(t.indicatorDescription),1)])):(0,e.createCommentVNode)(``,!0)]),_:1}),(0,e.createElementVNode)(`div`,Qt,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.params,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:(0,e.normalizeClass)([`param-item`,{"has-desc":o.value&&t.description}])},[(0,e.createElementVNode)(`div`,$t,[(0,e.createElementVNode)(`label`,en,[(0,e.createElementVNode)(`span`,tn,(0,e.toDisplayString)(t.label),1),t.min!==void 0||t.max!==void 0?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,nn,(0,e.toDisplayString)(t.min??`-∞`)+` ~ `+(0,e.toDisplayString)(t.max??`+∞`),1)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,rn,[(0,e.createElementVNode)(`button`,{class:`stepper-btn`,disabled:t.min!==void 0&&(a.value[t.key]??0)<=t.min,onClick:e=>l(t,-1)},` − `,8,an),t.type===`number`?((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`number`,class:`param-input`,value:a.value[t.key],min:t.min,max:t.max,step:t.step||1,onInput:e=>c(t.key,e)},null,40,on)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`stepper-btn`,disabled:t.max!==void 0&&(a.value[t.key]??0)>=t.max,onClick:e=>l(t,1)},` + `,8,sn)])]),(0,e.createVNode)(e.Transition,{name:`slide`},{default:(0,e.withCtx)(()=>[o.value&&t.description?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,cn,(0,e.toDisplayString)(t.description),1)):(0,e.createCommentVNode)(``,!0)]),_:2},1024)],2))),128))]),(0,e.createElementVNode)(`div`,ln,[(0,e.createElementVNode)(`button`,{class:`params-btn reset`,onClick:u},[...r[8]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,e.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,e.createTextVNode)(` 重置 `,-1)]]),(0,e.createElementVNode)(`div`,un,[(0,e.createElementVNode)(`button`,{class:`params-btn cancel`,onClick:r[2]||=e=>n.$emit(`close`)},`取消`),(0,e.createElementVNode)(`button`,{class:`params-btn confirm`,onClick:d},[...r[9]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,e.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,e.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))}}),[[`__scopeId`,`data-v-bb1d1eb3`]]),fn=[{id:`MA`,label:`MA`,name:`均线`,pane:`main`},{id:`VOLUME`,label:`VOL`,name:`成交量`,pane:`sub`,description:`成交量反映市场活跃度,柱状图显示每根K线的交易量。上涨时柱子为红色,下跌时为绿色。`},{id:`BOLL`,label:`BOLL`,name:`布林带`,pane:`main`,description:`布林带由三条轨道线组成,用于判断价格的波动范围和趋势强度。价格触及上轨可能超买,触及下轨可能超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算移动平均线的周期数,周期越长轨道越平滑`},{key:`multiplier`,label:`倍数`,type:`number`,min:.1,max:5,step:.1,default:2,description:`标准差倍数,决定轨道宽度,通常为 2`}]},{id:`EXPMA`,label:`EXPMA`,name:`指数平滑移动平均线`,pane:`main`,description:`EXPMA 对近期价格给予更高权重,比普通 MA 更敏感。快线上穿慢线为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:100,step:1,default:12,description:`快线周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:200,step:1,default:50,description:`慢线周期,用于判断趋势方向`}]},{id:`ENE`,label:`ENE`,name:`轨道线`,pane:`main`,description:`ENE 轨道线由三条轨道组成,价格突破上轨可能超买,突破下轨可能超卖,适合判断震荡行情的买卖点。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`计算中轨的周期数`},{key:`deviation`,label:`偏离率`,type:`number`,min:1,max:30,step:.5,default:11,description:`轨道偏离率百分比,决定轨道宽度`}]},{id:`MACD`,label:`MACD`,name:`指数平滑异同移动平均线`,pane:`sub`,description:`MACD 通过快慢均线的交叉判断趋势方向和动量。DIF 上穿 DEA 为金叉看涨,下穿为死叉看跌。`,params:[{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:50,step:1,default:12,description:`快线 EMA 周期,对价格变化更敏感`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:100,step:1,default:26,description:`慢线 EMA 周期,用于计算 DIF`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`DEA 的 EMA 周期,用于生成买卖信号`}]},{id:`RSI`,label:`RSI`,name:`相对强弱指标`,pane:`sub`,description:`RSI 衡量价格变动的速度和幅度,判断超买超卖状态。RSI > 70 超买,RSI < 30 超卖。`,params:[{key:`period1`,label:`周期 1`,type:`number`,min:2,max:100,step:1,default:6,description:`第一条 RSI 周期,通常为 6(快线)`},{key:`period2`,label:`周期 2`,type:`number`,min:2,max:100,step:1,default:12,description:`第二条 RSI 周期,通常为 12(中线)`},{key:`period3`,label:`周期 3`,type:`number`,min:2,max:100,step:1,default:24,description:`第三条 RSI 周期,通常为 24(慢线)`}]},{id:`CCI`,label:`CCI`,name:`顺势指标`,pane:`sub`,description:`CCI 衡量价格与统计平均值的偏离程度。CCI > 100 超买,CCI < -100 超卖,适合捕捉趋势反转。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期,周期越短信号越灵敏`}]},{id:`STOCH`,label:`STOCH`,name:`随机指标`,pane:`sub`,description:`KDJ 随机指标通过比较收盘价与价格区间判断超买超卖。K > 80 超买,K < 20 超卖,K 上穿 D 金叉。`,params:[{key:`n`,label:`K 周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算 K 值的周期,统计 N 日内价格区间`},{key:`m`,label:`D 周期`,type:`number`,min:1,max:50,step:1,default:3,description:`D 值是 K 的 M 日移动平均,使信号更平滑`}]},{id:`MOM`,label:`MOM`,name:`动量指标`,pane:`sub`,description:`动量指标衡量价格变化的速度,MOM > 0 表示上涨动能,MOM < 0 表示下跌动能。适合判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`与多少日前价格比较,周期越短越灵敏`}]},{id:`WMSR`,label:`WMSR`,name:`威廉指标`,pane:`sub`,description:`威廉指标衡量超买超卖程度,范围为 -100 到 0。WMSR > -20 超买,WMSR < -80 超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`回溯周期,统计周期内最高最低价`}]},{id:`KST`,label:`KST`,name:`确然指标`,pane:`sub`,description:`KST 综合多个 ROC 判断长期趋势,KST 上穿信号线看涨,下穿看跌。适合捕捉主要趋势转换。`,params:[{key:`roc1`,label:`ROC1`,type:`number`,min:2,max:100,step:1,default:10,description:`短期变化率周期`},{key:`roc2`,label:`ROC2`,type:`number`,min:2,max:100,step:1,default:15,description:`中短期变化率周期`},{key:`roc3`,label:`ROC3`,type:`number`,min:2,max:100,step:1,default:20,description:`中长期变化率周期`},{key:`roc4`,label:`ROC4`,type:`number`,min:2,max:100,step:1,default:30,description:`长期变化率周期`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`信号线的 SMA 周期`}]},{id:`FASTK`,label:`FASTK`,name:`快速随机指标`,pane:`sub`,description:`FASTK 是未经过平滑处理的随机指标,比普通 KDJ 更敏感,能更快捕捉价格转折点,但假信号也更多。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:9,description:`计算周期,周期越短越敏感`}]},{id:`ATR`,label:`ATR`,name:`平均真实波幅`,pane:`sub`,description:`ATR(Average True Range)衡量市场波动性,值越大表示波动越剧烈。Wilder 平滑算法,常用于设置止损位和判断趋势强度。`,params:[{key:`period`,label:`周期`,type:`number`,min:1,max:100,step:1,default:14,description:`ATR 计算周期,周期越长曲线越平滑`}]},{id:`WMA`,label:`WMA`,name:`加权移动平均`,pane:`main`,description:`WMA 对近期价格赋予更高权重,比普通 MA 反应更快,适用于短期趋势跟踪。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`计算周期`}]},{id:`DEMA`,label:`DEMA`,name:`双指数移动平均`,pane:`main`,description:`DEMA 通过双重平滑减少滞后,比传统 EMA 更贴近价格,适合快速趋势判断。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期`}]},{id:`TEMA`,label:`TEMA`,name:`三指数移动平均`,pane:`main`,description:`TEMA 三重平滑,滞后最小,响应最快,适合敏锐捕捉价格变化。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期`}]},{id:`HMA`,label:`HMA`,name:`赫尔移动平均`,pane:`main`,description:`HMA 通过加权移动平均和平方根计算,在平滑度和响应速度之间取得极佳平衡。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`计算周期`}]},{id:`KAMA`,label:`KAMA`,name:`考夫曼自适应移动平均`,pane:`main`,description:`KAMA 根据市场噪音自适应调整平滑度,趋势强时快速跟随,震荡时平滑过滤。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:10,description:`ER 计算周期`},{key:`fastPeriod`,label:`快线`,type:`number`,min:2,max:30,step:1,default:2,description:`最快平滑系数`},{key:`slowPeriod`,label:`慢线`,type:`number`,min:2,max:60,step:1,default:30,description:`最慢平滑系数`}]},{id:`SAR`,label:`SAR`,name:`抛物线转向`,pane:`main`,description:`SAR(Parabolic Stop and Reverse)通过抛物线轨迹跟踪趋势,提供动态止损和反转信号。`,params:[{key:`step`,label:`步长`,type:`number`,min:.001,max:.1,step:.001,default:.02,description:`加速度步长`},{key:`maxStep`,label:`最大步长`,type:`number`,min:.01,max:.5,step:.01,default:.2,description:`最大加速度上限`}]},{id:`SUPERTREND`,label:`ST`,name:`超级趋势`,pane:`main`,description:`SuperTrend 基于 ATR 的通道突破系统,价格在通道上方为多头趋势,下方为空头趋势。`,params:[{key:`atrPeriod`,label:`ATR 周期`,type:`number`,min:2,max:100,step:1,default:10,description:`ATR 计算周期`},{key:`multiplier`,label:`倍数`,type:`number`,min:.5,max:10,step:.5,default:3,description:`ATR 倍数`}]},{id:`KELTNER`,label:`KC`,name:`肯特纳通道`,pane:`main`,description:`Keltner Channel 以 EMA 为中轨,ATR 倍数确定通道宽度,适合判断突破与回归。`,params:[{key:`emaPeriod`,label:`EMA 周期`,type:`number`,min:2,max:100,step:1,default:20,description:`中轨 EMA 周期`},{key:`atrPeriod`,label:`ATR 周期`,type:`number`,min:2,max:100,step:1,default:10,description:`ATR 计算周期`},{key:`multiplier`,label:`倍数`,type:`number`,min:.5,max:10,step:.5,default:2,description:`ATR 倍数`}]},{id:`DONCHIAN`,label:`DC`,name:`唐奇安通道`,pane:`main`,description:`Donchian Channel 显示 N 日内最高价和最低价的通道,价格突破上下轨视为趋势信号。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:200,step:1,default:20,description:`通道周期`}]},{id:`ICHIMOKU`,label:`IK`,name:`一目均衡表`,pane:`main`,description:`Ichimoku Kinko Hyo(一目均衡表)综合显示支撑阻力、趋势方向和动量,云区变色提示趋势转换。`,params:[{key:`tenkanPeriod`,label:`转折线`,type:`number`,min:2,max:100,step:1,default:9,description:`Tenkan-sen 周期`},{key:`kijunPeriod`,label:`基准线`,type:`number`,min:2,max:100,step:1,default:26,description:`Kijun-sen 周期`},{key:`spanBPeriod`,label:`领先线 B`,type:`number`,min:2,max:200,step:1,default:52,description:`Senkou Span B 周期`},{key:`displacement`,label:`偏移`,type:`number`,min:1,max:52,step:1,default:26,description:`偏移量`}]},{id:`ROC`,label:`ROC`,name:`变化率`,pane:`sub`,description:`ROC 衡量当前价格与 N 日前价格的百分比变化,正值表示上涨动能,负值表示下跌动能。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:12,description:`ROC 周期`}]},{id:`TRIX`,label:`TRIX`,name:`三重指数平滑平均`,pane:`sub`,description:`TRIX 三平滑后取 ROC,过滤短期波动,上穿信号线为买入信号,下穿为卖出信号。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:15,description:`TRIX 周期`},{key:`signalPeriod`,label:`信号`,type:`number`,min:2,max:50,step:1,default:9,description:`信号线周期`}]},{id:`HV`,label:`HV`,name:`历史波动率`,pane:`sub`,description:`HV 衡量过去 N 日对数收益率的年化标准差,值越高表示市场波动越大。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算周期`},{key:`annualizationFactor`,label:`年化因子`,type:`number`,min:1,max:365,step:1,default:252,description:`年化天数`}]},{id:`PARKINSON`,label:`PK`,name:`帕金森波动率`,pane:`sub`,description:`Parkinson 利用最高最低价估算波动率,比 HV 更高效,捕捉日内波动范围。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`计算周期`},{key:`annualizationFactor`,label:`年化因子`,type:`number`,min:1,max:365,step:1,default:252,description:`年化天数`}]},{id:`CHAIKIN_VOL`,label:`CV`,name:`蔡金波动率`,pane:`sub`,description:`Chaikin Volatility 衡量价格区间的宽度变化,波动率扩张预示突破,收缩预示盘整。`,params:[{key:`emaPeriod`,label:`EMA 周期`,type:`number`,min:2,max:100,step:1,default:10,description:`平滑周期`},{key:`rocPeriod`,label:`ROC 周期`,type:`number`,min:2,max:100,step:1,default:10,description:`变化率周期`}]},{id:`VMA`,label:`VMA`,name:`成交量移动平均`,pane:`sub`,description:`VMA 对成交量做移动平均,量能上升确认趋势,量能萎缩预示反转。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:5,description:`VMA 周期`}]},{id:`OBV`,label:`OBV`,name:`能量潮`,pane:`sub`,description:`OBV 累积量能,价格上涨时加量,下跌时减量。OBV 趋势与价格背离常预示反转。`,params:[]},{id:`PVT`,label:`PVT`,name:`价量趋势`,pane:`sub`,description:`PVT 将成交量按价格变化率加权累计,比 OBV 更精细,反映资金流入流出力度。`,params:[]},{id:`VWAP`,label:`VWAP`,name:`成交量加权均价`,pane:`sub`,description:`VWAP(Volume-Weighted Average Price)以成交量加权的均价线,机构常用作日内交易基准。`,params:[{key:`sessionResetGapMs`,label:`重置间隔`,type:`number`,min:0,max:864e5,step:36e5,default:0,description:`0=不重置,>0=超过间隔毫秒重置`}]},{id:`CMF`,label:`CMF`,name:`蔡金资金流`,pane:`sub`,description:`CMF(Chaikin Money Flow)衡量资金流入流出强度,正值看涨,负值看跌。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:20,description:`CMF 周期`}]},{id:`MFI`,label:`MFI`,name:`资金流量指数`,pane:`sub`,description:`MFI(Money Flow Index)类似 RSI 但用量能加权,判断超买超卖。MFI > 80 超买,MFI < 20 超卖。`,params:[{key:`period`,label:`周期`,type:`number`,min:2,max:100,step:1,default:14,description:`MFI 周期`}]},{id:`PIVOT`,label:`PP`,name:`枢轴点`,pane:`main`,description:`Pivot Points 根据前日最高/最低/收盘计算支撑阻力位,R1-R3 为阻力,S1-S3 为支撑。`,params:[]},{id:`FIB`,label:`FIB`,name:`斐波那契`,pane:`main`,description:`Fibonacci 回调线标记关键回撤位(0.236/0.382/0.5/0.618/0.786),用于判断回调目标。`,params:[{key:`period`,label:`周期`,type:`number`,min:5,max:500,step:1,default:50,description:`计算周期`}]},{id:`STRUCTURE`,label:`SMC`,name:`SMC 结构`,pane:`main`,description:`Swing / BOS / CHOCH 识别市场结构转换,突破结构(BOS)确认趋势,趋势反转(CHOCH)提示反转。`,params:[{key:`leftWindow`,label:`左窗口`,type:`number`,min:1,max:20,step:1,default:2,description:`摆点左侧 K 线数`},{key:`rightWindow`,label:`右窗口`,type:`number`,min:1,max:20,step:1,default:2,description:`摆点右侧 K 线数`}]},{id:`ZONES`,label:`ZONES`,name:`SMC 区域`,pane:`main`,description:`FVG(公允价值缺口)和 Order Block(订单块)识别机构交易行为中的关键流动性区域。`,params:[{key:`obLookback`,label:`OB 回溯`,type:`number`,min:1,max:50,step:1,default:5,description:`Order Block 回溯窗口`}]},{id:`VOLUME_PROFILE`,label:`VP`,name:`成交量分布`,pane:`sub`,description:`Volume Profile 显示各价位成交量分布,识别高量区域(价值区)和低量区域(缺口),POC 为成交量最大价位。`,params:[{key:`bins`,label:`分箱数`,type:`number`,min:5,max:100,step:1,default:24,description:`价格分箱数`},{key:`lookback`,label:`回溯`,type:`number`,min:0,max:500,step:1,default:0,description:`0=全部数据`},{key:`valueAreaPercent`,label:`价值区%`,type:`number`,min:.1,max:1,step:.05,default:.7,description:`价值区占比`}]}],pn=fn.filter(e=>e.pane===`main`),mn=fn.filter(e=>e.pane===`sub`);function hn(e){return fn.find(t=>t.id===e)}function gn(e){return fn.find(t=>t.id===e)?.pane===`sub`}var _n={class:`indicator-selector`},vn={class:`indicator-scroll-container`},yn={class:`indicator-list`},bn={key:0,class:`indicator-divider`,"aria-hidden":`true`},xn=[`draggable`,`onDragstart`,`onDragover`,`onDrop`],Sn=[`onMouseenter`],Cn={class:`btn-content`},wn={key:0,class:`param-hint`},Tn={key:0,class:`hover-overlay`},En=[`onClick`],Dn={key:1,class:`divider`},On=[`onClick`],kn={class:`indicator-item`},An={class:`modal-header`},jn={class:`header-title`},Mn={class:`title-sub`},Nn={class:`header-actions`},Pn={key:0,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},Fn={key:1,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},In={class:`modal-body`},Ln={class:`indicator-section`},Rn={class:`section-header`},zn={class:`section-count`},Bn=[`onClick`],Vn={class:`card-label`},Hn={class:`card-tooltip`},Un={class:`card-header`},Wn={class:`card-label`},Gn={class:`card-header-actions`},Kn=[`onClick`],qn={class:`card-name`},Jn={class:`indicator-section`},Yn={class:`section-header`},Xn={class:`section-count`},Zn=[`onClick`],Qn={class:`card-label`},$n={class:`card-tooltip`},er={class:`card-header`},tr={class:`card-label`},nr={class:`card-header-actions`},rr=[`onClick`],ir={class:`card-name`},ar={class:`modal-footer`},or={class:`footer-info`},sr={class:`info-text`},cr=Rt((0,e.defineComponent)({__name:`IndicatorSelector`,props:{activeIndicators:{},indicatorParams:{}},emits:[`toggle`,`updateParams`,`reorderSubIndicators`],setup(t,{emit:n}){let r=t,i=n,a=(0,e.ref)(null),o=(0,e.ref)(!1),s=(0,e.ref)(null),c=(0,e.ref)(null),l=(0,e.ref)(!1),u=(0,e.ref)(null),d=(0,e.ref)(null),f=(0,e.ref)(!1),p=Kt(),m=(0,e.computed)(()=>r.activeIndicators?.length?r.activeIndicators.map(e=>hn(e)).filter(e=>e!==void 0).sort((e,t)=>e.pane===t.pane?0:e.pane===`main`?-1:1):[]),h=(0,e.computed)(()=>m.value.some(e=>e.pane===`main`)?m.value.find(e=>e.pane===`sub`)?.id??null:null),g=(0,e.computed)(()=>s.value?hn(s.value):null),_=(0,e.computed)(()=>pn.length+mn.length),v=(0,e.computed)(()=>r.activeIndicators?.length??0);function y(e){return r.activeIndicators?.includes(e)??!1}function b(e){if(y(e))return;let t=hn(e);t&&(t.pane===`main`&&pn.filter(t=>t.id!==e&&y(t.id)).forEach(e=>i(`toggle`,e.id,!1)),i(`toggle`,e,!0))}function x(e){i(`toggle`,e,!1)}function S(e){s.value=e,o.value=!0}function C(){l.value=!1}function w(e){let t=hn(e);if(!t?.params)return{};let n={};for(let e of t.params)n[e.key]=e.default??e.min??1;let i=r.indicatorParams?.[e]||{},a={...n};for(let[e,t]of Object.entries(i))typeof t==`number`&&(a[e]=t);return a}function T(e){let t=w(e.id);return e.params?e.params.map(e=>t[e.key]??``).join(`,`):``}function E(e){s.value&&i(`updateParams`,s.value,e),o.value=!1}function D(e,t){if(!gn(t)){e.preventDefault();return}d.value=t,u.value=null,e.dataTransfer?.setData(`text/plain`,t),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`)}function O(e,t){!d.value||!gn(t)||d.value===t||(u.value=t,e.dataTransfer&&(e.dataTransfer.dropEffect=`move`))}function k(e,t){let n=d.value||e.dataTransfer?.getData(`text/plain`)||``;if(!n||n===t){A();return}if(!gn(n)||!gn(t)){A();return}let r=m.value.findIndex(e=>e.id===n),a=m.value.findIndex(e=>e.id===t);if(r<0||a<0){A();return}let o=[...m.value.map(e=>e.id)],[s]=o.splice(r,1);if(!s){A();return}o.splice(a,0,s),i(`reorderSubIndicators`,o.filter(e=>gn(e))),A()}function A(){u.value=null,d.value=null}function j(){l.value=!l.value}function M(e){e.key===`Escape`&&l.value&&(l.value=!1)}return(0,e.onMounted)(()=>{document.addEventListener(`keydown`,M)}),(0,e.onUnmounted)(()=>{document.removeEventListener(`keydown`,M)}),(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,_n,[(0,e.createElementVNode)(`div`,vn,[(0,e.createElementVNode)(`div`,yn,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(m.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:t.id},[t.id===h.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,bn)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`indicator-item`,{draggable:(0,e.unref)(gn)(t.id),"drag-over":u.value===t.id,"is-dragging":d.value===t.id}]),draggable:(0,e.unref)(gn)(t.id),onDragstart:e=>D(e,t.id),onDragover:(0,e.withModifiers)(e=>O(e,t.id),[`prevent`]),onDrop:(0,e.withModifiers)(e=>k(e,t.id),[`prevent`]),onDragend:A},[(0,e.createElementVNode)(`div`,{class:`indicator-btn-wrapper`,onMouseenter:e=>c.value=t.id,onMouseleave:n[0]||=e=>c.value=null},[(0,e.createElementVNode)(`button`,{class:(0,e.normalizeClass)([`indicator-btn`,{active:!0,hovering:c.value===t.id}])},[(0,e.createElementVNode)(`span`,Cn,[(0,e.createTextVNode)((0,e.toDisplayString)(t.label)+` `,1),t.params?.length?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,wn,` (`+(0,e.toDisplayString)(T(t))+`) `,1)):(0,e.createCommentVNode)(``,!0)]),(0,e.createVNode)(e.Transition,{name:`fade`},{default:(0,e.withCtx)(()=>[c.value===t.id?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Tn,[t.params?.length?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`action-btn settings-btn`,onClick:(0,e.withModifiers)(e=>S(t.id),[`stop`]),title:`编辑参数`},[...n[4]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,En)):(0,e.createCommentVNode)(``,!0),t.params?.length?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,Dn)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`button`,{class:`action-btn remove-btn`,onClick:(0,e.withModifiers)(e=>x(t.id),[`stop`]),title:`移除指标`},[...n[5]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})],-1)]],8,On)])):(0,e.createCommentVNode)(``,!0)]),_:2},1024)],2)],40,Sn)],42,xn)],64))),128)),(0,e.createElementVNode)(`div`,kn,[(0,e.createElementVNode)(`button`,{ref_key:`addBtnRef`,ref:a,class:`add-btn`,onClick:j,title:`添加指标`},[...n[6]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`})],-1)]],512)])])]),((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(p)},[(0,e.createVNode)(e.Transition,{name:`overlay`},{default:(0,e.withCtx)(()=>[l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`selector-overlay`,onClick:C},[(0,e.createVNode)(e.Transition,{name:`modal`},{default:(0,e.withCtx)(()=>[l.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`selector-modal`,onClick:n[2]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,An,[(0,e.createElementVNode)(`div`,jn,[n[7]||=(0,e.createElementVNode)(`span`,{class:`title-text`},`添加指标`,-1),(0,e.createElementVNode)(`span`,Mn,(0,e.toDisplayString)(_.value)+` 个可用指标`,1)]),(0,e.createElementVNode)(`div`,Nn,[(0,e.createElementVNode)(`button`,{class:(0,e.normalizeClass)([`view-toggle-btn`,{active:f.value}]),onClick:n[1]||=e=>f.value=!f.value,title:`简洁模式`},[f.value?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Fn,[...n[9]||=[(0,e.createElementVNode)(`path`,{d:`M3 3h18v18H3V3zm16 16V5H5v14h14zM7 7h4v4H7V7zm0 6h4v4H7v-4zm6-6h4v4h-4V7zm0 6h4v4h-4v-4z`},null,-1)]])):((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Pn,[...n[8]||=[(0,e.createElementVNode)(`path`,{d:`M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z`},null,-1)]]))],2),(0,e.createElementVNode)(`button`,{class:`modal-close`,onClick:C,title:`关闭`},[...n[10]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})],-1)]])])]),(0,e.createElementVNode)(`div`,In,[(0,e.createElementVNode)(`div`,Ln,[(0,e.createElementVNode)(`div`,Rn,[n[11]||=(0,e.createElementVNode)(`span`,{class:`section-title`},`主图指标`,-1),(0,e.createElementVNode)(`span`,zn,(0,e.toDisplayString)((0,e.unref)(pn).length),1)]),(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`indicator-grid`,{compact:f.value}])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)((0,e.unref)(pn),t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,class:(0,e.normalizeClass)([`indicator-card`,{active:y(t.id),compact:f.value}]),onClick:e=>y(t.id)?x(t.id):b(t.id)},[f.value?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:0},[(0,e.createElementVNode)(`span`,Vn,(0,e.toDisplayString)(t.label),1),(0,e.createElementVNode)(`span`,Hn,(0,e.toDisplayString)(t.name),1)],64)):((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:1},[(0,e.createElementVNode)(`div`,Un,[(0,e.createElementVNode)(`span`,Wn,(0,e.toDisplayString)(t.label),1),(0,e.createElementVNode)(`div`,Gn,[t.params?.length?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`card-settings-btn`,onClick:(0,e.withModifiers)(e=>S(t.id),[`stop`]),title:`编辑参数`},[...n[12]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,Kn)):(0,e.createCommentVNode)(``,!0)])]),(0,e.createElementVNode)(`div`,qn,(0,e.toDisplayString)(t.name),1)],64))],10,Bn))),128))],2)]),n[15]||=(0,e.createElementVNode)(`div`,{class:`section-divider`},null,-1),(0,e.createElementVNode)(`div`,Jn,[(0,e.createElementVNode)(`div`,Yn,[n[13]||=(0,e.createElementVNode)(`span`,{class:`section-title`},`副图指标`,-1),(0,e.createElementVNode)(`span`,Xn,(0,e.toDisplayString)((0,e.unref)(mn).length),1)]),(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`indicator-grid`,{compact:f.value}])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)((0,e.unref)(mn),t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,class:(0,e.normalizeClass)([`indicator-card`,{active:y(t.id),compact:f.value}]),onClick:e=>y(t.id)?x(t.id):b(t.id)},[f.value?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:0},[(0,e.createElementVNode)(`span`,Qn,(0,e.toDisplayString)(t.label),1),(0,e.createElementVNode)(`span`,$n,(0,e.toDisplayString)(t.name),1)],64)):((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:1},[(0,e.createElementVNode)(`div`,er,[(0,e.createElementVNode)(`span`,tr,(0,e.toDisplayString)(t.label),1),(0,e.createElementVNode)(`div`,nr,[t.params?.length?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,class:`card-settings-btn`,onClick:(0,e.withModifiers)(e=>S(t.id),[`stop`]),title:`编辑参数`},[...n[14]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`},[(0,e.createElementVNode)(`path`,{d:`M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z`})],-1)]],8,rr)):(0,e.createCommentVNode)(``,!0)])]),(0,e.createElementVNode)(`div`,ir,(0,e.toDisplayString)(t.name),1)],64))],10,Zn))),128))],2)])]),(0,e.createElementVNode)(`div`,ar,[(0,e.createElementVNode)(`div`,or,[(0,e.createElementVNode)(`span`,sr,`已激活 `+(0,e.toDisplayString)(v.value)+` 个指标`,1)]),(0,e.createElementVNode)(`button`,{class:`btn btn-confirm`,onClick:C},`完成`)])])):(0,e.createCommentVNode)(``,!0)]),_:1})])):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`])),g.value?((0,e.openBlock)(),(0,e.createBlock)(dn,{key:0,visible:o.value,"indicator-id":g.value.id,"indicator-name":g.value.name,"indicator-description":g.value.description,params:g.value.params||[],values:w(g.value.id),onClose:n[3]||=e=>o.value=!1,onConfirm:E},null,8,[`visible`,`indicator-id`,`indicator-name`,`indicator-description`,`params`,`values`])):(0,e.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-e9eb306c`]]),lr={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ur(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,lr,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 7h16m-10 4v6m4-6v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`},null,-1)]])}var dr=(0,e.markRaw)({name:`tabler-trash`,render:ur}),fr={class:`toolbar-item color-item`,title:`颜色`},pr=[`value`],mr=[`value`],hr=[`value`],gr=Rt((0,e.defineComponent)({__name:`DrawingStyleToolbar`,props:{drawing:{}},emits:[`updateStyle`,`delete`],setup(t,{emit:n}){let r=n;function i(e){e.key===`Delete`&&(e.preventDefault(),r(`delete`))}(0,e.onMounted)(()=>document.addEventListener(`keydown`,i)),(0,e.onUnmounted)(()=>document.removeEventListener(`keydown`,i));function a(e){r(`updateStyle`,{stroke:e})}function o(e){r(`updateStyle`,{strokeWidth:e})}function s(e){r(`updateStyle`,{strokeStyle:e})}return(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:`drawing-style-toolbar`,onPointerdown:r[4]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[5]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[6]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,fr,[(0,e.createElementVNode)(`span`,{class:`color-swatch`,style:(0,e.normalizeStyle)({background:t.drawing.style.stroke??`#2962ff`})},null,4),(0,e.createElementVNode)(`input`,{type:`color`,class:`color-input`,value:t.drawing.style.stroke??`#2962ff`,onInput:r[0]||=e=>a(e.target.value)},null,40,pr)]),(0,e.createElementVNode)(`select`,{class:`toolbar-select`,value:t.drawing.style.strokeWidth??1,onChange:r[1]||=e=>o(Number(e.target.value)),title:`线宽`},[...r[7]||=[(0,e.createElementVNode)(`option`,{value:1},`1px`,-1),(0,e.createElementVNode)(`option`,{value:2},`2px`,-1),(0,e.createElementVNode)(`option`,{value:3},`3px`,-1),(0,e.createElementVNode)(`option`,{value:4},`4px`,-1)]],40,mr),(0,e.createElementVNode)(`select`,{class:`toolbar-select`,value:t.drawing.style.strokeStyle??`solid`,onChange:r[2]||=e=>s(e.target.value),title:`线型`},[...r[8]||=[(0,e.createElementVNode)(`option`,{value:`solid`},`实线`,-1),(0,e.createElementVNode)(`option`,{value:`dashed`},`虚线`,-1),(0,e.createElementVNode)(`option`,{value:`dotted`},`点线`,-1)]],40,hr),(0,e.createElementVNode)(`button`,{type:`button`,class:`toolbar-btn delete-btn`,title:`删除`,onClick:r[3]||=e=>n.$emit(`delete`)},[(0,e.createVNode)((0,e.unref)(dr),{class:`delete-icon`,"aria-hidden":`true`})])],32))}}),[[`__scopeId`,`data-v-92699cb2`]]),_r=null;function vr(e){let t=e,n=new Set;return Object.assign(()=>(_r!==null&&(n.add(_r.run),_r.deps.add(n)),t),{peek:()=>t,set:e=>{if(!Object.is(t,e)){t=e;for(let e of[...n])e()}},subscribe:e=>(n.add(e),()=>{n.delete(e)})})}function yr(e,t){let n=Math.round(e*t);return n%2==0&&(n+=1),Math.max(1,n)}function br(e,t,n){let r=yr(e,n),i=Math.round(t*n),a=r+i,o=i;return{kWidthPx:r,kGapPx:i,unitPx:a,startXPx:o,kWidthLogical:r/n,kGapLogical:i/n,unitLogical:a/n,startXLogical:o/n}}function xr(e,t,n,r,i,a=1){let{unitPx:o,startXPx:s}=br(n,r,a),c=e*a,l=t*a;return{start:Math.max(0,Math.floor((c-s)/o)-1),end:Math.min(i,Math.ceil((c+l-s)/o)+1)}}function Sr(e,t,n){let r=-1/0,i=1/0;for(let a=t;a<n&&a<e.length;a++){let t=e[a];t&&(t.high>r&&(r=t.high),t.low<i&&(i=t.low))}return!Number.isFinite(r)||!Number.isFinite(i)?{maxPrice:100,minPrice:0}:{maxPrice:r,minPrice:i}}var Cr={logicalOffset:4,coordOffset:1e-4};function wr(e){return Math.abs(e)<1e-15}function H(e,t){let n=Math.abs(e);if(wr(n))return 0;let r=Math.log10(n+t.coordOffset)+t.logicalOffset;return e<0?-r:r}function Tr(e,t){let n=Math.abs(e);if(wr(n))return 0;let r=10**(n-t.logicalOffset)-t.coordOffset;return e<0?-r:r}function Er(e){if(e===null)return{...Cr};let t=Math.abs(e.maxPrice-e.minPrice);if(t>=1||t<1e-15)return{...Cr};let n=Math.ceil(Math.abs(Math.log10(t))),r=Cr.logicalOffset+n;return{logicalOffset:r,coordOffset:1/10**r}}function Dr(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}var Or=class{range={maxPrice:100,minPrice:0};height=1;paddingTop=0;paddingBottom=0;priceOffset=0;verticalScale=1;scaleType=`linear`;logFormula=Er(null);setRange(e){if(this.range=e,this.scaleType===`log`&&e.minPrice>0){let t=Er(e);if(!Dr(t,this.logFormula)){let n=H(e.minPrice,this.logFormula),r=(H(e.maxPrice,this.logFormula)+n)/2+this.priceOffset;this.logFormula=t;let i=H(e.minPrice,this.logFormula),a=(H(e.maxPrice,this.logFormula)+i)/2;this.priceOffset=this.clampOffset(r-a)}}}setHeight(e){this.height=Math.max(1,e)}setPadding(e,t){this.paddingTop=Math.max(0,e),this.paddingBottom=Math.max(0,t)}getRange(){return this.range}getPaddingTop(){return this.paddingTop}getPaddingBottom(){return this.paddingBottom}setPriceOffset(e){this.priceOffset=this.clampOffset(e)}getPriceOffset(){return this.priceOffset}resetPriceOffset(){this.priceOffset=0}clampOffset(e){if(this.scaleType===`log`&&this.range.minPrice>0){let t=H(this.range.minPrice,this.logFormula),n=H(this.range.maxPrice,this.logFormula)-t;if(n<=0)return 0;let r=n*(1+1/this.verticalScale)/2;return Math.max(-r,Math.min(r,e))}let t=this.range.maxPrice-this.range.minPrice;if(t<=0)return 0;let n=t*(1+1/this.verticalScale)/2;return Math.max(-n,Math.min(n,e))}scaleByDelta(e){if(!Number.isFinite(e)||e===0)return;let t=Math.exp(-e*.01),n=this.verticalScale*t;this.verticalScale=Math.min(8,Math.max(.2,n)),this.priceOffset=this.clampOffset(this.priceOffset)}getVerticalScale(){return this.verticalScale}setScaleType(e){if(e!==this.scaleType){if(e===`log`&&this.range.minPrice>0){this.logFormula=Er(this.range);let e=(this.range.maxPrice+this.range.minPrice)/2,t=e+this.priceOffset;this.priceOffset=H(t,this.logFormula)-H(e,this.logFormula),this.priceOffset=this.clampOffset(this.priceOffset)}else if(e===`linear`&&this.scaleType===`log`){let e=H(this.range.minPrice,this.logFormula),t=Tr((H(this.range.maxPrice,this.logFormula)+e)/2+this.priceOffset,this.logFormula),n=(this.range.maxPrice+this.range.minPrice)/2;this.priceOffset=t-n,this.priceOffset=this.clampOffset(this.priceOffset)}this.scaleType=e}}getScaleType(){return this.scaleType}getDisplayRange(e){let{minPrice:t,maxPrice:n}=e??this.range;if(this.scaleType===`log`&&t>0){let e=H(t,this.logFormula),r=H(n,this.logFormula),i=r-e||1,a=(r+e)/2+this.priceOffset,o=i/(2*this.verticalScale);return{maxPrice:Tr(a+o,this.logFormula),minPrice:Tr(a-o,this.logFormula)}}let r=n-t||1,i=(n+t)/2+this.priceOffset,a=r/(2*this.verticalScale);return{maxPrice:i+a,minPrice:i-a}}priceToY(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i;if(this.scaleType===`log`&&n>0){let r=H(n,this.logFormula),a=H(t,this.logFormula);i=(H(e,this.logFormula)-r)/(a-r||1)}else i=(e-n)/(t-n||1);return this.paddingTop+r*(1-i)}yToPrice(e){let{maxPrice:t,minPrice:n}=this.getDisplayRange(),r=Math.max(1,this.height-this.paddingTop-this.paddingBottom),i=1-(e-this.paddingTop)/r;if(this.scaleType===`log`&&n>0){let e=H(n,this.logFormula);return Tr(e+i*(H(t,this.logFormula)-e),this.logFormula)}return n+i*(t-n)}deltaYToPriceOffset(e){let t=Math.max(1,this.height-this.paddingTop-this.paddingBottom);if(this.scaleType===`log`&&this.range.minPrice>0){let n=H(this.range.minPrice,this.logFormula);return e*((H(this.range.maxPrice,this.logFormula)-n)/t)}return e*((this.range.maxPrice-this.range.minPrice||1)/t)}},U=function(e){return e.Main=`main`,e.Overlay=`overlay`,e.All=`all`,e}({});function kr(e){return e===`price`?{showPriceAxisTicks:!0,showCrosshairPriceLabel:!0,candleHitTest:!0,supportsPriceTranslate:!0}:e===`indicator`?{showPriceAxisTicks:!1,showCrosshairPriceLabel:!0,candleHitTest:!1,supportsPriceTranslate:!0}:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1}}var Ar=class{id;role;capabilities;top=0;height=0;priceRange={maxPrice:100,minPrice:0};yAxis=new Or;renderers=[];constructor(e,t={}){this.id=e,this.role=t.role??(e===`main`?`price`:`indicator`),this.capabilities={...kr(this.role),...t.capabilities??{}}}setLayout(e,t){this.top=e,this.height=Math.max(1,t),this.yAxis.setHeight(this.height)}setPadding(e,t){this.yAxis.setPadding(e,t)}addRenderer(e){this.renderers.push(e)}updateRange(e,t,n){this.priceRange=Sr(e,t.start,t.end),n&&Number.isFinite(n.min)&&Number.isFinite(n.max)&&(this.priceRange.minPrice=Math.min(this.priceRange.minPrice,n.min),this.priceRange.maxPrice=Math.max(this.priceRange.maxPrice,n.max)),this.yAxis.setRange(this.priceRange)}},jr=class{hoveredMarkerId=null;clickedMarkerId=null;hoveredMarkerData=null;clickedMarkerData=null;hoveredCustomMarker=null;onMarkerHoverCallback;onMarkerClickCallback;onCustomMarkerHoverCallback;onCustomMarkerClickCallback;setOnMarkerHover(e){this.onMarkerHoverCallback=e}setOnMarkerClick(e){this.onMarkerClickCallback=e}setOnCustomMarkerHover(e){this.onCustomMarkerHoverCallback=e}setOnCustomMarkerClick(e){this.onCustomMarkerClickCallback=e}handleClick(e){this.clickedMarkerId=e.id,this.clickedMarkerData=e,this.onMarkerClickCallback?.(e)}updateHoverFromPoint(e,t,n,r){let i=r.hitTest(e,n,3);if(i)return this.enterMarkerHover(i,r);this.leaveMarkerHover(r);let a=r.hitTestCustomMarker(t,n);return a?this.enterCustomMarkerHover(a,r):(this.leaveCustomMarkerHover(),!1)}enterMarkerHover(e,t){return this.hoveredMarkerId!==e.id&&(this.hoveredMarkerId=e.id,this.hoveredMarkerData=e,t.setHover(e.id),this.onMarkerHoverCallback?.(e)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null)),!0}leaveMarkerHover(e){this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,e.setHover(null),this.onMarkerHoverCallback?.(null))}enterCustomMarkerHover(e,t){return this.hoveredCustomMarker?.id!==e.id&&(this.hoveredCustomMarker=e,this.onCustomMarkerHoverCallback?.(e)),this.hoveredMarkerId!==null&&(this.hoveredMarkerId=null,this.hoveredMarkerData=null,t.setHover(null),this.onMarkerHoverCallback?.(null)),!0}leaveCustomMarkerHover(){this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null))}clearAll(e){this.hoveredMarkerId===null?this.hoveredMarkerData=null:(this.hoveredMarkerId=null,this.hoveredMarkerData=null,e.setHover(null),this.onMarkerHoverCallback?.(null)),this.hoveredCustomMarker!==null&&(this.hoveredCustomMarker=null,this.onCustomMarkerHoverCallback?.(null))}reset(){this.hoveredMarkerId=null,this.clickedMarkerId=null,this.hoveredMarkerData=null,this.clickedMarkerData=null,this.hoveredCustomMarker=null}},Mr=class{activePointers=new Map;lastPinchDistance=0;pinchCenter={x:0,y:0};isPinching=!1;onPinchZoomCallback;setOnPinchZoom(e){this.onPinchZoomCallback=e}getIsPinching(){return this.isPinching}getPointerCount(){return this.activePointers.size}handlePointerDown(e,t){if(this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.activePointers.size===2&&t){this.isPinching=!0;let e=Array.from(this.activePointers.values()),t=e[0],n=e[1];return this.lastPinchDistance=Math.hypot(n.x-t.x,n.y-t.y),this.pinchCenter={x:(t.x+n.x)/2,y:(t.y+n.y)/2},!0}return!1}handlePointerUp(e){this.activePointers.delete(e.pointerId),this.isPinching&&this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0)}handlePointerLeave(e){this.activePointers.delete(e.pointerId),this.activePointers.size<2&&(this.isPinching=!1,this.lastPinchDistance=0)}handlePointerMove(e){if(this.activePointers.has(e.pointerId)&&this.activePointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.isPinching&&this.activePointers.size===2){let e=Array.from(this.activePointers.values()),t=e[0],n=e[1],r=Math.hypot(n.x-t.x,n.y-t.y),i=r-this.lastPinchDistance;if(Math.abs(i)>10){let e=i>0?1:-1,a=(t.x+n.x)/2;this.onPinchZoomCallback?.(e,a),this.lastPinchDistance=r}return!0}return!1}reset(){this.activePointers.clear(),this.isPinching=!1,this.lastPinchDistance=0}};function Nr(e){if(e.useAnchorPositioning){let t=e.tooltipSize.width;return{anchorPlacement:e.mouseX+14+t+12>e.plotWidth?`left-bottom`:`right-bottom`,pos:{x:Math.min(Math.max(e.mouseX,12),Math.max(12,e.plotWidth-12)),y:Math.min(Math.max(e.mouseY,12),Math.max(12,e.plotHeight-12))}}}let t=e.tooltipSize.width,n=e.tooltipSize.height,r=e.mouseX+14,i=e.mouseX-14-t,a=r+t+12<=e.viewWidth?r:i,o=e.mouseY+14,s=Math.max(12,e.viewWidth-t-12),c=Math.max(12,e.viewHeight-n-12);return{pos:{x:Math.min(Math.max(a,12),s),y:Math.min(Math.max(o,12),c)}}}var Pr=class{chart;isDragging=!1;dragMode=`none`;dragStartX=0;scrollStartX=0;applyPanScroll(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,t),n),i=this.chart.getCurrentDpr();e.scrollLeft=Math.round(r*i)/i}dragStartY=0;activePaneIdOnDrag=null;activeSeparatorUpperPaneId=null;hoveredSeparatorUpperPaneId=null;hoveredRightAxisPaneId=null;isTouchSession=!1;pinchTracker=new Mr;crosshairPos=null;crosshairIndex=null;crosshairPrice=null;hoveredIndex=null;activePaneId=null;tooltipPos={x:0,y:0};tooltipSize={width:220,height:180};tooltipAnchorPlacement=`right-bottom`;useTooltipAnchorPositioning=!1;onInteractionChangeCallback;settings={};markerState=new jr;kLinePositions=null;visibleRange=null;lastHoverRenderKey=``;kWidthPx=null;constructor(e){this.chart=e}setOnPinchZoom(e){this.pinchTracker.setOnPinchZoom(e)}updateSettings(e){let t=this.settings.disableMainPaneVerticalScroll;this.settings={...e},!t&&this.settings.disableMainPaneVerticalScroll&&this.chart.resetPriceOffset(`main`)}getInteractionSnapshot(){return{crosshairPos:this.crosshairPos?{...this.crosshairPos}:null,crosshairIndex:this.crosshairIndex,crosshairPrice:this.crosshairPrice,hoveredIndex:this.hoveredIndex,activePaneId:this.activePaneId,tooltipPos:{...this.tooltipPos},tooltipAnchorPlacement:this.tooltipAnchorPlacement,hoveredMarkerData:this.markerState.hoveredMarkerData,hoveredCustomMarker:this.markerState.hoveredCustomMarker,isDragging:this.isDragging,isResizingPaneBoundary:this.dragMode===`resize-separator`,isHoveringPaneBoundary:this.hoveredSeparatorUpperPaneId!==null,hoveredPaneBoundaryId:this.hoveredSeparatorUpperPaneId,isHoveringRightAxis:this.hoveredRightAxisPaneId!==null}}setOnInteractionChange(e){this.onInteractionChangeCallback=e}notifyInteractionChange(){this.onInteractionChangeCallback?.(this.getInteractionSnapshot())}getHoverRenderKey(){let e=this.crosshairPos?Math.round(this.crosshairPos.x*this.chart.getCurrentDpr()):`n`,t=this.crosshairPos?Math.round(this.crosshairPos.y*this.chart.getCurrentDpr()):`n`;return[this.crosshairIndex??`n`,this.hoveredIndex??`n`,this.activePaneId??`n`,this.hoveredRightAxisPaneId??`n`,this.hoveredSeparatorUpperPaneId??`n`,this.markerState.hoveredMarkerId??`n`,this.markerState.hoveredCustomMarker?.id??`n`,e,t].join(`|`)}onPointerDown(e){if(this.isTouchSession=e.pointerType===`touch`,this.pinchTracker.handlePointerDown(e,this.isTouchSession)){this.isDragging=!1,this.dragMode=`none`;return}if(e.isPrimary===!1||this.pinchTracker.getIsPinching()||this.pinchTracker.getPointerCount()>1)return;let t=this.getPlotPointerLocation(e.clientX,e.clientY);if(!t)return;let{mouseX:n,mouseY:r}=t,i=this.chart.getCachedScrollLeft(),a=this.chart.getMarkerManager(),o=i+n,s=a.hitTest(o,r,3);if(s){this.markerState.handleClick(s);return}let c=this.hitTestPaneSeparator(r);if(c){this.isDragging=!0,this.dragMode=`resize-separator`,this.dragStartY=e.clientY,this.activeSeparatorUpperPaneId=c,this.hoveredSeparatorUpperPaneId=c,this.clearHover(),this.chart.scheduleDraw();return}let l=this.getPaneByY(r);this.isDragging=!0,this.dragMode=`pan`,this.updatePlotHoverFromPoint(e.clientX,e.clientY),this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.scrollStartX=this.chart.getCachedScrollLeft(),this.activePaneIdOnDrag=l?.id||null,this.chart.scheduleDraw()}setTooltipSize(e){this.tooltipSize=e}setTooltipAnchorPositioning(e){this.useTooltipAnchorPositioning=e}onPointerUp(e){this.pinchTracker.handlePointerUp(e),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.activeSeparatorUpperPaneId=null,this.notifyInteractionChange())}onPointerLeave(e){this.pinchTracker.handlePointerLeave(e),e.isPrimary!==!1&&(this.isDragging=!1,this.dragMode=`none`,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange())}onScroll(){this.kLinePositions=null,this.visibleRange=null,this.clearHover(),this.chart.scheduleDraw(),this.notifyInteractionChange()}onPointerMove(e){if(this.pinchTracker.handlePointerMove(e)||!e.isPrimary)return;e.pointerType===`touch`&&(this.isTouchSession=!0);let t=this.chart.getDom().container;if(this.isDragging){if(this.dragMode===`resize-separator`){let t=e.clientY-this.dragStartY;t!==0&&this.activeSeparatorUpperPaneId&&this.chart.resizePaneBoundary(this.activeSeparatorUpperPaneId,t)&&(this.dragStartY=e.clientY);return}if(this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}if(this.dragMode===`pan`){let n=this.dragStartX-e.clientX;this.applyPanScroll(t,this.scrollStartX+n);let r=e.clientY-this.dragStartY;this.dragStartY=e.clientY,r!==0&&this.activePaneIdOnDrag===`main`&&(this.settings.disableMainPaneVerticalScroll||this.chart.translatePrice(this.activePaneIdOnDrag,r))}return}let n=this.getPlotPointerLocation(e.clientX,e.clientY);if(!n)return;this.hoveredSeparatorUpperPaneId=this.hitTestPaneSeparator(n.mouseY),this.updatePlotHoverFromPoint(e.clientX,e.clientY);let r=this.getHoverRenderKey();r!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=r,this.chart.scheduleDraw(U.Overlay)),this.notifyInteractionChange()}setKLinePositions(e,t,n){this.kLinePositions=e,this.visibleRange=t,n!==void 0&&(this.kWidthPx=n)}onRightAxisPointerDown(e){if(e.isPrimary===!1)return;this.isTouchSession=e.pointerType===`touch`;let t=this.getRightAxisPointerLocation(e.clientX,e.clientY);t&&this.beginScalePriceDrag(e.clientY,t.mouseY)&&(this.chart.scheduleDraw(),this.notifyInteractionChange())}onRightAxisPointerMove(e){if(!e.isPrimary)return;if(e.pointerType===`touch`&&(this.isTouchSession=!0),this.isDragging&&this.dragMode===`scale-price`){let t=e.clientY-this.dragStartY;t!==0&&this.activePaneIdOnDrag&&(this.chart.scalePrice(this.activePaneIdOnDrag,t),this.dragStartY=e.clientY);return}this.updateRightAxisHoverFromPoint(e.clientX,e.clientY);let t=this.getHoverRenderKey();t!==this.lastHoverRenderKey&&(this.lastHoverRenderKey=t,this.chart.scheduleDraw(U.Overlay)),this.notifyInteractionChange()}onRightAxisPointerUp(e){this.onPointerUp(e)}onRightAxisPointerLeave(e){e.isPrimary!==!1&&(this.isDragging&&this.dragMode===`scale-price`||(this.hoveredRightAxisPaneId=null,this.notifyInteractionChange()))}isDraggingState(){return this.isDragging}setOnMarkerHover(e){this.markerState.setOnMarkerHover(e)}setOnMarkerClick(e){this.markerState.setOnMarkerClick(e)}setOnCustomMarkerHover(e){this.markerState.setOnCustomMarkerHover(e)}setOnCustomMarkerClick(e){this.markerState.setOnCustomMarkerClick(e)}hitTestPaneSeparator(e){let t=this.chart.getPaneRenderers();if(t.length<2)return null;for(let n=0;n<t.length-1;n++){let r=t[n]?.getPane(),i=t[n+1]?.getPane();if(!r||!i)continue;let a=r.top+r.height;if(Math.abs(e-a)<=5)return r.id}return null}getPaneByY(e){return this.chart.getPaneRenderers().find(t=>{let n=t.getPane();return e>=n.top&&e<=n.top+n.height})?.getPane()||null}getPlotPointerLocation(e,t){let n=this.chart.getDom().container.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}getRightAxisPointerLocation(e,t){let n=this.chart.getDom().rightAxisLayer.getBoundingClientRect();return{mouseX:e-n.left,mouseY:t-n.top}}beginScalePriceDrag(e,t){let n=this.getPaneByY(t);return!n||n.id===`main`&&this.settings.disableMainPaneVerticalScroll?!1:(this.isDragging=!0,this.dragMode=`scale-price`,this.dragStartY=e,this.activePaneIdOnDrag=n.id,this.hoveredRightAxisPaneId=n.id,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=n.id,!0)}clearHover(){this.lastHoverRenderKey=``,this.hoveredRightAxisPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.markerState.clearAll(this.chart.getMarkerManager())}clearSeparatorState(){this.activeSeparatorUpperPaneId=null,this.hoveredSeparatorUpperPaneId=null,this.hoveredRightAxisPaneId=null}updateRightAxisHoverFromPoint(e,t){let n=this.getRightAxisPointerLocation(e,t);if(!n)return;let{mouseY:r}=n,i=this.chart.getViewport()?.plotHeight??Math.max(1,Math.round(this.chart.getDom().container.clientHeight));if(r<0||r>i){this.hoveredRightAxisPaneId=null;return}let a=this.getPaneByY(r);this.hoveredRightAxisPaneId=a?.id||null,this.hoveredSeparatorUpperPaneId=null,this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=a?.id||null}updatePlotHoverFromPoint(e,t){let n=this.getPlotPointerLocation(e,t);if(!n)return;let{mouseX:r,mouseY:i}=n,a=this.chart.getDom().container,o=this.chart.getViewport(),s=o?.viewWidth??Math.max(1,Math.round(a.clientWidth)),c=o?.viewHeight??Math.max(1,Math.round(a.clientHeight)),l=o?.plotWidth??s,u=o?.plotHeight??c;if(r<0||i<0||r>l||i>u){this.clearHover();return}this.hoveredRightAxisPaneId=null;let d=this.chart.getCachedScrollLeft(),f=this.chart.getCurrentDpr(),p=this.hitTestPaneSeparator(i);if(this.hoveredSeparatorUpperPaneId=p,p){this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null;return}let m=this.chart.getMarkerManager(),h=d+r;if(this.markerState.updateHoverFromPoint(h,r,i,m)){this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null;return}if(!this.kLinePositions||!this.visibleRange||!this.kWidthPx){this.clearHover();return}let g=this.kWidthPx/f,_=0,v=this.kLinePositions.length;for(;_<v;){let e=_+v>>1;this.kLinePositions[e]<h?_=e+1:v=e}let y=_;if(_>0&&_<this.kLinePositions.length){let e=this.kLinePositions[_-1]+g/2,t=this.kLinePositions[_]+g/2;Math.abs(h-e)<Math.abs(h-t)&&(y=_-1)}else _===this.kLinePositions.length&&this.kLinePositions.length>0&&(y=this.kLinePositions.length-1);let b=y+this.visibleRange.start,x=this.chart.getData(),S=this.getPaneByY(i);if(this.activePaneId=S?.id||null,b>=0&&b<(x?.length??0)){this.crosshairIndex=b;let e=this.kLinePositions[y],t=(Math.round(e*f)+(this.kWidthPx-1)/2)/f-d;if(this.crosshairPos={x:Math.min(Math.max(t,0),l),y:Math.min(Math.max(i,0),u)},S){let e=i-S.top;this.crosshairPrice=S.yAxis.yToPrice(e)}else this.crosshairPrice=null}else this.crosshairIndex=null,this.crosshairPos=null,this.crosshairPrice=null;let C=typeof this.crosshairIndex==`number`?x[this.crosshairIndex]:void 0;if(!C||!S||!S.capabilities.candleHitTest){this.hoveredIndex=null;return}let w=i-S.top,T=S.yAxis.priceToY(C.open),E=S.yAxis.priceToY(C.close),D=S.yAxis.priceToY(C.high),O=S.yAxis.priceToY(C.low),k=Math.min(T,E),A=Math.max(T,E),j=h-this.kLinePositions[y],M=g/2,N=Math.abs(A-k),P=N<8?(k+A)/2-8/2:k,F=N<8?(k+A)/2+8/2:A,I=w>=P&&w<=F&&j>=0&&j<=g,L=Math.abs(j-M)<=3&&w>=Math.min(D,O)&&w<=Math.max(D,O);if(!I&&!L){this.hoveredIndex=null;return}this.hoveredIndex=this.crosshairIndex;let ee=Nr({mouseX:r,mouseY:i,viewWidth:s,viewHeight:c,plotWidth:l,plotHeight:u,tooltipSize:this.tooltipSize,useAnchorPositioning:this.useTooltipAnchorPositioning});ee.anchorPlacement&&(this.tooltipAnchorPlacement=ee.anchorPlacement),this.tooltipPos=ee.pos}reset(){this.isDragging=!1,this.dragMode=`none`,this.dragStartX=0,this.dragStartY=0,this.scrollStartX=0,this.activePaneIdOnDrag=null,this.clearSeparatorState(),this.isTouchSession=!1,this.pinchTracker.reset(),this.crosshairPos=null,this.crosshairIndex=null,this.crosshairPrice=null,this.hoveredIndex=null,this.activePaneId=null,this.markerState.reset(),this.kLinePositions=null,this.visibleRange=null,this.lastHoverRenderKey=``,this.kWidthPx=null}getCrosshairIndex(){return this.crosshairIndex}},Fr=`#version 300 es
|
|
2
2
|
precision mediump float;
|
|
3
3
|
|
|
4
4
|
in vec2 a_unit;
|
|
@@ -20,7 +20,7 @@ void main() {
|
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
gl_Position = vec4(clip, 0.0, 1.0);
|
|
23
|
-
}`,
|
|
23
|
+
}`,Ir=`#version 300 es
|
|
24
24
|
precision mediump float;
|
|
25
25
|
|
|
26
26
|
in vec2 a_position;
|
|
@@ -37,7 +37,7 @@ void main() {
|
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
gl_Position = vec4(clip, 0.0, 1.0);
|
|
40
|
-
}`,
|
|
40
|
+
}`,Lr=`#version 300 es
|
|
41
41
|
precision mediump float;
|
|
42
42
|
|
|
43
43
|
uniform vec4 u_color;
|
|
@@ -45,5 +45,5 @@ out vec4 outColor;
|
|
|
45
45
|
|
|
46
46
|
void main() {
|
|
47
47
|
outColor = u_color;
|
|
48
|
-
}`,ir=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ar=class{shared;handles=null;logicalWidth=0;logicalHeight=0;available=!1;rectCapacity=0;rectScratch=new Float32Array;region=null;constructor(e){this.shared=e,this.handles=this.initRectHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.shared.getCanvas()}setRegion(e){this.region=e}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t}clear(){!this.region||this.logicalWidth<=0||this.logicalHeight<=0||this.shared.clearRegion(this.region)}compositeTo(e,t={}){this.region&&this.shared.compositeRegionTo(e,this.region,t)}drawRectBuffer(e,t,n,r){let i=this.handles;if(!i||t===0||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let a=fr(n);if(!a)return!1;let o=t*4,s=this.shared.getGL();return!s||!this.region||!this.shared.bindRegion(this.region)?!1:(s.useProgram(i.program),s.bindVertexArray(i.vao),s.bindBuffer(s.ARRAY_BUFFER,i.rectBuffer),this.rectCapacity<o&&(this.rectCapacity=sr(o),s.bufferData(s.ARRAY_BUFFER,this.rectCapacity*Float32Array.BYTES_PER_ELEMENT,s.DYNAMIC_DRAW)),s.bufferSubData(s.ARRAY_BUFFER,0,e),a[3]===1?s.disable(s.BLEND):s.enable(s.BLEND),s.uniform2f(i.resolutionLocation,this.logicalWidth,this.logicalHeight),s.uniform1f(i.scrollXLocation,r),s.uniform4f(i.colorLocation,a[0],a[1],a[2],a[3]),s.drawArraysInstanced(s.TRIANGLES,0,6,t),s.bindVertexArray(null),!0)}drawRects(e,t,n){if(!this.handles||!e.length||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let r=e.length*4;this.rectScratch.length<r&&(this.rectScratch=new Float32Array(sr(r)));for(let t=0;t<e.length;t++){let n=e[t],r=t*4;this.rectScratch[r]=n.x,this.rectScratch[r+1]=n.y,this.rectScratch[r+2]=n.width,this.rectScratch[r+3]=n.height}return this.drawRectBuffer(this.rectScratch.subarray(0,r),e.length,t,n)}destroy(){let e=this.handles;if(!e)return;let t=this.shared.getGL();if(t){let{program:n,vao:r,unitBuffer:i,rectBuffer:a}=e;t.deleteBuffer(i),t.deleteBuffer(a),t.deleteVertexArray(r),t.deleteProgram(n)}this.handles=null,this.available=!1}initRectHandles(){let e=this.shared.getGL();if(!e)return null;let t=lr(e,e.VERTEX_SHADER,tr),n=lr(e,e.FRAGMENT_SHADER,rr);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=ur(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer(),o=e.createBuffer();if(!i||!a||!o)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),o&&e.deleteBuffer(o),e.deleteProgram(r),null;let s=e.getUniformLocation(r,`u_resolution`),c=e.getUniformLocation(r,`u_scrollX`),l=e.getUniformLocation(r,`u_color`);if(!s||!c||!l)return e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null;let u=e.getAttribLocation(r,`a_unit`),d=e.getAttribLocation(r,`a_rect`);return u<0||d<0?(e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,ir,e.STATIC_DRAW),e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.vertexAttribDivisor(u,0),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,4,e.FLOAT,!1,16,0),e.vertexAttribDivisor(d,1),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{program:r,vao:i,unitBuffer:a,rectBuffer:o,resolutionLocation:s,scrollXLocation:c,colorLocation:l})}},or=class{shared;handles=null;logicalWidth=0;logicalHeight=0;dpr=1;available=!1;vertexCapacity=0;fillScratch=new Float32Array;lineScratch=new Float32Array;region=null;msaaTargets=null;geoCache=new WeakMap;constructor(e){this.shared=e,this.handles=this.initLineHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.shared.getCanvas()}setRegion(e){this.region=e}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t,this.dpr=n}clear(){!this.region||this.logicalWidth<=0||this.logicalHeight<=0||this.shared.clearRegion(this.region)}compositeTo(e,t={}){this.region&&this.shared.compositeRegionTo(e,this.region,t)}drawLineStrips(e,t){let n=this.handles;if(!n||e.length===0||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let r=this.shared.getGL(),i=this.region;if(!r||!i)return!1;let a=[],o=0;for(let t of e){if(t.points.length<2)return!1;let e=fr(t.color);if(!e)return!1;if(t.width===1){let{vertexCount:n,vertices:i}=this.getThinLineVertices(t.points);a.push({colorValue:e,mode:r.LINE_STRIP,firstVertex:o/2,pointCount:n}),o+=i.length}else{let n=this.getLineGeometry(t);if(!n)return!1;a.push({colorValue:e,mode:r.TRIANGLES,firstVertex:o/2,pointCount:n.vertexCount}),o+=n.vertices.length}}this.lineScratch.length<o&&(this.lineScratch=new Float32Array(sr(o)));let s=0;for(let t of e){let e=t.width===1?this.getThinLineVertices(t.points).vertices:this.getLineGeometry(t).vertices;this.lineScratch.set(e,s),s+=e.length}let c=this.shared.getPhysicalRegion(i),l=c?this.ensureLineMsaaTargets(r,c):null,u=l!==null;if(u)r.bindFramebuffer(r.FRAMEBUFFER,l.msaaFramebuffer),r.viewport(0,0,l.widthPx,l.heightPx),r.disable(r.SCISSOR_TEST),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT);else if(!this.shared.bindRegion(i))return!1;r.useProgram(n.basic.program),r.bindVertexArray(n.basic.vao),r.bindBuffer(r.ARRAY_BUFFER,n.basic.vertexBuffer),this.vertexCapacity<o&&(this.vertexCapacity=sr(o),r.bufferData(r.ARRAY_BUFFER,this.vertexCapacity*Float32Array.BYTES_PER_ELEMENT,r.DYNAMIC_DRAW)),r.bufferSubData(r.ARRAY_BUFFER,0,this.lineScratch.subarray(0,o)),r.uniform2f(n.basic.resolutionLocation,this.logicalWidth,this.logicalHeight),r.uniform1f(n.basic.scrollXLocation,t);for(let e of a)r.uniform4f(n.basic.colorLocation,e.colorValue[0],e.colorValue[1],e.colorValue[2],e.colorValue[3]),r.drawArrays(e.mode,e.firstVertex,e.pointCount);return r.bindVertexArray(null),u&&l&&c&&this.resolveLineMsaaToSharedRegion(r,l,c),r.bindFramebuffer(r.FRAMEBUFFER,null),!0}getThinLineVertices(e){let t=this.geoCache.get(e);if(t){let e=t.get(0);if(e)return e}else t=new Map,this.geoCache.set(e,t);let n=e.length,r=new Float32Array(n*2),i=0;for(let t of e)r[i++]=t.x,r[i++]=t.y;let a={vertices:r,vertexCount:n};return t.set(0,a),a}getLineGeometry(e){let t=e.width/2,n=this.geoCache.get(e.points);if(n){let e=n.get(t);if(e)return e}else n=new Map,this.geoCache.set(e.points,n);let r=cr(e.points,t);return r&&n.set(t,r),r}drawFilledBand(e,t,n){let r=this.handles,i=Math.min(e.upperPoints.length,e.lowerPoints.length);if(!r||i<2||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let a=fr(t);if(!a)return!1;let o=i*2,s=o*2;this.fillScratch.length<s&&(this.fillScratch=new Float32Array(sr(s)));let c=0;for(let t=0;t<i;t++){let n=e.upperPoints[t],r=e.lowerPoints[t];this.fillScratch[c++]=n.x,this.fillScratch[c++]=n.y,this.fillScratch[c++]=r.x,this.fillScratch[c++]=r.y}let l=this.shared.getGL();return!l||!this.region||!this.shared.bindRegion(this.region)?!1:(l.useProgram(r.basic.program),l.bindVertexArray(r.basic.vao),l.bindBuffer(l.ARRAY_BUFFER,r.basic.vertexBuffer),this.vertexCapacity<s&&(this.vertexCapacity=sr(s),l.bufferData(l.ARRAY_BUFFER,this.vertexCapacity*Float32Array.BYTES_PER_ELEMENT,l.DYNAMIC_DRAW)),l.bufferSubData(l.ARRAY_BUFFER,0,this.fillScratch.subarray(0,s)),l.uniform2f(r.basic.resolutionLocation,this.logicalWidth,this.logicalHeight),l.uniform1f(r.basic.scrollXLocation,n),l.uniform4f(r.basic.colorLocation,a[0],a[1],a[2],a[3]),l.drawArrays(l.TRIANGLE_STRIP,0,o),l.bindVertexArray(null),!0)}destroy(){let e=this.handles,t=this.shared.getGL();if(t&&this.destroyLineMsaaTargets(t),!e){this.vertexCapacity=0;return}if(t){let{basic:n}=e;t.deleteBuffer(n.vertexBuffer),t.deleteVertexArray(n.vao),t.deleteProgram(n.program)}this.handles=null,this.available=!1,this.vertexCapacity=0}ensureLineMsaaTargets(e,t){let n=Number(e.getParameter(e.MAX_SAMPLES))||0,r=Math.max(1,Math.min(4,n));if(r<=1)return null;let i=this.msaaTargets;if(i&&i.widthPx===t.widthPx&&i.heightPx===t.heightPx&&i.samples===r)return i;this.destroyLineMsaaTargets(e);let a=e.createFramebuffer(),o=e.createRenderbuffer(),s=e.createFramebuffer(),c=e.createTexture();if(!a||!o||!s||!c)return a&&e.deleteFramebuffer(a),o&&e.deleteRenderbuffer(o),s&&e.deleteFramebuffer(s),c&&e.deleteTexture(c),null;if(e.bindFramebuffer(e.FRAMEBUFFER,a),e.bindRenderbuffer(e.RENDERBUFFER,o),e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.RGBA8,t.widthPx,t.heightPx),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,o),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.deleteFramebuffer(a),e.deleteRenderbuffer(o),e.deleteFramebuffer(s),e.deleteTexture(c),null;if(e.bindFramebuffer(e.FRAMEBUFFER,s),e.bindTexture(e.TEXTURE_2D,c),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.widthPx,t.heightPx,0,e.RGBA,e.UNSIGNED_BYTE,null),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,c,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.deleteFramebuffer(a),e.deleteRenderbuffer(o),e.deleteFramebuffer(s),e.deleteTexture(c),null;e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),e.bindRenderbuffer(e.RENDERBUFFER,null);let l={samples:r,widthPx:t.widthPx,heightPx:t.heightPx,msaaFramebuffer:a,msaaColorRenderbuffer:o,resolveFramebuffer:s,resolveTexture:c};return this.msaaTargets=l,l}destroyLineMsaaTargets(e){let t=this.msaaTargets;t&&(e.deleteFramebuffer(t.msaaFramebuffer),e.deleteRenderbuffer(t.msaaColorRenderbuffer),e.deleteFramebuffer(t.resolveFramebuffer),e.deleteTexture(t.resolveTexture),this.msaaTargets=null)}resolveLineMsaaToSharedRegion(e,t,n){e.bindFramebuffer(e.READ_FRAMEBUFFER,t.msaaFramebuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,t.resolveFramebuffer),e.blitFramebuffer(0,0,t.widthPx,t.heightPx,0,0,t.widthPx,t.heightPx,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.resolveFramebuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null);let r=this.shared.getCanvas().height-n.sourceY-n.heightPx;e.disable(e.SCISSOR_TEST),e.blitFramebuffer(0,0,t.widthPx,t.heightPx,n.sourceX,r,n.sourceX+n.widthPx,r+n.heightPx,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)}initLineHandles(){let e=this.shared.getGL();if(!e)return null;let t=lr(e,e.VERTEX_SHADER,nr),n=lr(e,e.FRAGMENT_SHADER,rr);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=ur(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer();if(!i||!a)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),e.deleteProgram(r),null;let o=e.getUniformLocation(r,`u_resolution`),s=e.getUniformLocation(r,`u_scrollX`),c=e.getUniformLocation(r,`u_color`);if(!o||!s||!c)return e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null;let l=e.getAttribLocation(r,`a_position`);return l<0?(e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.enableVertexAttribArray(l),e.vertexAttribPointer(l,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{basic:{program:r,vao:i,vertexBuffer:a,resolutionLocation:o,scrollXLocation:s,colorLocation:c}})}};function sr(e){let t=1;for(;t<e;)t<<=1;return t}function cr(e,t){if(e.length<2)return null;let n=Array(e.length-1),r=0;for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1],o=a.x-i.x,s=a.y-i.y,c=o*o+s*s;if(c<=0){n[t]={nx:0,ny:0,valid:!1};continue}let l=1/Math.sqrt(c);n[t]={nx:-s*l,ny:o*l,valid:!0},r++}if(r===0)return null;let i=(e.length-1)*12,a=new Float32Array(i),o=0;for(let r=0;r<e.length-1;r++){let i=e[r],s=e[r+1],c=r>0?n[r-1]:null,l=n[r];if(!l.valid||!c&&!l.valid)continue;let u=0,d=0;if(c?.valid&&l.valid){u=c.nx+l.nx,d=c.ny+l.ny;let e=u*u+d*d;if(e>1e-12){let t=1/Math.sqrt(e);u*=t,d*=t;let n=u*l.nx+d*l.ny,r=1/Math.max(.2,Math.abs(n));u*=r,d*=r}else u=l.nx,d=l.ny}else if(l.valid)u=l.nx,d=l.ny;else if(c?.valid)u=c.nx,d=c.ny;else continue;let f=l.nx,p=l.ny,m=r<e.length-2?n[r+1]:null;if(m?.valid&&l.valid){f=l.nx+m.nx,p=l.ny+m.ny;let e=f*f+p*p;if(e>1e-12){let t=1/Math.sqrt(e);f*=t,p*=t;let n=f*m.nx+p*m.ny,r=1/Math.max(.2,Math.abs(n));f*=r,p*=r}else f=l.nx,p=l.ny}let h=i.x+u*t,g=i.y+d*t,_=i.x-u*t,v=i.y-d*t,y=s.x+f*t,b=s.y+p*t,x=s.x-f*t,S=s.y-p*t;a[o++]=h,a[o++]=g,a[o++]=_,a[o++]=v,a[o++]=y,a[o++]=b,a[o++]=y,a[o++]=b,a[o++]=_,a[o++]=v,a[o++]=x,a[o++]=S}return o===0?null:{vertices:o===i?a:a.subarray(0,o),vertexCount:o/2}}function lr(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(e.deleteShader(r),null)):null}function ur(e,t,n){let r=e.createProgram();return r?(e.attachShader(r,t),e.attachShader(r,n),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(e.deleteProgram(r),null)):null}var dr=new Map;function fr(e){let t=dr.get(e);if(t)return t;let n=e.trim().toLowerCase(),r=null;if(n.startsWith(`rgba(`)){let e=n.slice(5,-1).split(`,`).map(e=>Number(e.trim()));e.length===4&&e.every(e=>Number.isFinite(e))&&(r=[e[0]/255,e[1]/255,e[2]/255,e[3]])}else if(n.startsWith(`rgb(`)){let e=n.slice(4,-1).split(`,`).map(e=>Number(e.trim()));e.length===3&&e.every(e=>Number.isFinite(e))&&(r=[e[0]/255,e[1]/255,e[2]/255,1])}else if(n.startsWith(`#`)){let e=n.slice(1);e.length===6?r=[Number.parseInt(e.slice(0,2),16)/255,Number.parseInt(e.slice(2,4),16)/255,Number.parseInt(e.slice(4,6),16)/255,1]:e.length===3&&(r=[Number.parseInt(e[0]+e[0],16)/255,Number.parseInt(e[1]+e[1],16)/255,Number.parseInt(e[2]+e[2],16)/255,1])}return r&&dr.set(e,r),r}var pr=class{dom;pane;opt;contexts=null;webgl;constructor(e,t,n,r){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60},this.webgl={candleSurface:new ar(r),lineSurface:new or(r)}}getPane(){return this.pane}getDom(){return this.dom}getContexts(){return this.contexts||={mainCtx:this.dom.mainCanvas.getContext(`2d`),overlayCtx:this.dom.overlayCanvas.getContext(`2d`),yAxisCtx:this.dom.yAxisCanvas.getContext(`2d`)},this.contexts}getWebGL(){return this.webgl}setWebGLRegion(e){this.webgl.candleSurface?.setRegion(e),this.webgl.lineSurface?.setRegion(e)}resize(e,t,n){let r=this.dom.mainCanvas,i=this.dom.overlayCanvas,a=this.dom.yAxisCanvas,o=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),s=a.parentElement?.clientWidth??0,c=s>0?s:o,l=Math.round(e*n);r.width!==l&&(r.width=l);let u=Math.round(t*n);r.height!==u&&(r.height=u);let d=`${l/n}px`;r.style.width!==d&&(r.style.width=d);let f=`${u/n}px`;r.style.height!==f&&(r.style.height=f),i.width!==l&&(i.width=l),i.height!==u&&(i.height=u),i.style.width!==d&&(i.style.width=d),i.style.height!==f&&(i.style.height=f);let p=Math.round(c*n);a.width!==p&&(a.width=p);let m=Math.round(t*n);a.height!==m&&(a.height=m);let h=`${p/n}px`;a.style.width!==h&&(a.style.width=h);let g=`${m/n}px`;a.style.height!==g&&(a.style.height=g),this.webgl.candleSurface?.resize(e,t,n),this.webgl.lineSurface?.resize(e,t,n)}destroy(){this.contexts=null,this.webgl.candleSurface?.destroy(),this.webgl.lineSurface?.destroy()}};function mr(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=B(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function hr(t){let n=(0,e.reactive)({zoomLevel:t.initialZoomLevel,kWidth:0,kGap:1,viewportDpr:1,dataLength:0,dataVersion:0,paneRatios:{},drawings:[],selectedDrawingId:null,drawingVersion:0,viewWidth:0}),r=(0,e.computed)(()=>t.rightAxisWidth+t.priceLabelWidth),i=(0,e.computed)(()=>mr({dataLength:n.dataLength,kWidth:n.kWidth,kGap:n.kGap,viewWidth:n.viewWidth,viewportDpr:n.viewportDpr}));function a(){n.dataVersion++}function o(){n.drawingVersion++}function s(e){n.dataLength=e}function c(e){n.viewportDpr=e}function l(e){n.viewWidth=e}function u(e,t,r){n.zoomLevel=e,n.kWidth=t,n.kGap=r}function d(e){n.paneRatios=e}function f(e){n.drawings=e,n.selectedDrawingId&&!e.some(e=>e.id===n.selectedDrawingId)&&(n.selectedDrawingId=null),n.drawingVersion++}function p(e){n.selectedDrawingId=e}return{state:n,computed:{axisHostWidth:r,totalWidth:i},actions:{bumpDataVersion:a,bumpDrawingVersion:o,setDataLength:s,setViewportDpr:c,setViewWidth:l,setZoomState:u,setPaneRatios:d,setDrawings:f,setSelectedDrawingId:p}}}var gr=[5,10,20,30,60];function _r(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0,a=[];for(let n=0;n<t;n++){let t=e[n];if(!t)return r;let o=t.close;a.push(o),i+=o}for(let o=t-1;o<e.length;o++){let s=e[o];if(!s)continue;if(o>=t){let e=a.shift();e!==void 0&&(i-=e);let t=s.close;a.push(t),i+=t}let c=i/t,l=0;for(let e=0;e<t;e++){let t=a[e];t!==void 0&&(l+=(t-c)**2)}let u=Math.sqrt(l/t);r[o]={upper:c+n*u,middle:c,lower:c-n*u}}return r}function vr(e,t,n){let r=Array(e.length);if(e.length===0)return r;let i=2/(t+1),a=2/(n+1),o=e[0].close,s=o,c=o;r[0]={fast:s,slow:c};for(let t=1;t<e.length;t++){let n=e[t].close;s=n*i+s*(1-i),c=n*a+c*(1-a),r[t]={fast:s,slow:c}}return r}function yr(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0;for(let n=0;n<t;n++){let t=e[n];if(!t)return r;i+=t.close}let a=i/t,o=n/100;r[t-1]={upper:a*(1+o),middle:a,lower:a*(1-o)};for(let a=t;a<e.length;a++){let o=e[a-t],s=e[a];if(!o||!s)continue;i=i-o.close+s.close;let c=i/t,l=n/100;r[a]={upper:c*(1+l),middle:c,lower:c*(1-l)}}return r}function br(e,t){let n=Array(e.length);if(e.length<t)return n;let r=0;for(let i=0;i<t;i++){let t=e[i];if(!t)return n;r+=t.close}n[t-1]=r/t;for(let i=t;i<e.length;i++){let a=e[i-t],o=e[i];!a||!o||(r=r-a.close+o.close,n[i]=r/t)}return n}function xr(e,t){let n=Array(e.length);if(e.length<t+1)return n;let r=[];for(let t=1;t<e.length;t++)r.push(e[t].close-e[t-1].close);let i=0,a=0;for(let e=0;e<t;e++){let t=r[e];t!==void 0&&(t>0?i+=t:a+=Math.abs(t))}let o=i/t,s=a/t;s===0?n[t]=100:n[t]=100-100/(1+o/s);for(let e=t;e<r.length;e++){let i=r[e];if(i!==void 0)if(i>0?(o=(o*(t-1)+i)/t,s=s*(t-1)/t):(o=o*(t-1)/t,s=(s*(t-1)+Math.abs(i))/t),s===0)n[e+1]=100;else{let t=o/s;n[e+1]=100-100/(1+t)}}return n}function Sr(e,t){let n=Array(e.length);if(e.length<t)return n;let r=[];for(let t of e)r.push((t.high+t.low+t.close)/3);let i=0;for(let e=0;e<t;e++)i+=r[e];for(let a=t-1;a<e.length;a++){a>=t&&(i=i-r[a-t]+r[a]);let e=i/t,o=0;for(let n=0;n<t;n++)o+=Math.abs(r[a-n]-e);o/=t,o===0?n[a]=0:n[a]=(r[a]-e)/(.015*o)}return n}function Cr(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=Array(e.length);for(let n=t-1;n<e.length;n++){let r=-1/0,a=1/0;for(let i=0;i<t;i++){let t=e[n-i];t&&(r=Math.max(r,t.high),a=Math.min(a,t.low))}let o=e[n].close;r===a?i[n]=50:i[n]=(o-a)/(r-a)*100}for(let a=t-1+n-1;a<e.length;a++){let e=i[a];if(e===void 0)continue;let t=0,o=0;for(let e=0;e<n;e++){let n=i[a-e];n!==void 0&&(t+=n,o++)}o===n&&(r[a]={k:e,d:t/n})}return r}function wr(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&(n[r]=i-a)}return n}function Tr(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=-50:n[r]=(i-o)/(i-a)*-100}return n}function Er(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&a!==0&&(n[r]=(i-a)/a*100)}return n}function Dr(e,t){let n=Array(e.length),r=0,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(r+=o,i++,i>t){let n=e[a-t];n!==void 0&&(r-=n,i--)}i===t&&(n[a]=r/t)}}return n}function Or(e,t,n,r,i,a){let o=Array(e.length),s=Er(e,t),c=Er(e,n),l=Er(e,r),u=Er(e,i),d=Dr(s,10),f=Dr(c,10),p=Dr(l,10),m=Dr(u,15),h=Array(e.length);for(let t=0;t<e.length;t++){let e=d[t],n=f[t],r=p[t],i=m[t];e!==void 0&&n!==void 0&&r!==void 0&&i!==void 0&&(h[t]=e*1+n*2+r*3+i*4)}let g=Dr(h,a);for(let t=0;t<e.length;t++){let e=h[t],n=g[t];e!==void 0&&n!==void 0&&(o[t]={kst:e,signal:n})}return o}function kr(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=50:n[r]=(o-a)/(i-a)*100}return n}function Ar(e,t){let n=Array(e.length),r=2/(t+1);if(e.length===0)return n;n[0]=e[0].close;for(let t=1;t<e.length;t++){let i=e[t];i&&(n[t]=i.close*r+n[t-1]*(1-r))}return n}function jr(e,t){let n=Array(e.length),r=2/(t+1),i=e.findIndex(e=>e!==void 0);if(i===-1)return n;n[i]=e[i];for(let t=i+1;t<e.length;t++){let i=e[t],a=n[t-1];i===void 0||a===void 0||(n[t]=i*r+a*(1-r))}return n}function Mr(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=Ar(e,t),o=Ar(e,n),s=Array(e.length);for(let t=0;t<e.length;t++){let e=a[t],n=o[t];e!==void 0&&n!==void 0&&(s[t]=e-n)}let c=jr(s,r);for(let t=0;t<e.length;t++){let e=s[t],n=c[t];e!==void 0&&n!==void 0&&(i[t]={dif:e,dea:n,macd:(e-n)*2})}return i}function Nr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;if(t===1){let t=e[0];r[0]=t.high-t.low;let i=t.close;for(let t=1;t<n;t++){let n=e[t];r[t]=Math.max(n.high-n.low,Math.abs(n.high-i),Math.abs(n.low-i)),i=n.close}return r}if(n<t)return r;let i=e[0],a=i.high-i.low,o=i.close;for(let n=1;n<t;n++){let t=e[n];a+=Math.max(t.high-t.low,Math.abs(t.high-o),Math.abs(t.low-o)),o=t.close}let s=a/t;r[t-1]=s;let c=t-1;for(let i=t;i<n;i++){let n=e[i],a=Math.max(n.high-n.low,Math.abs(n.high-o),Math.abs(n.low-o));s=(c*s+a)/t,r[i]=s,o=n.close}return r}function Pr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;let i=t*(t+1)/2;for(let a=t-1;a<n;a++){let n=0,o=!0;for(let r=0;r<t;r++){let i=e[a-t+1+r];if(i===void 0){o=!1;break}n+=(r+1)*i}o&&(r[a]=n/i)}return r}function Fr(e,t){if(e.length===0||t<=0)return Array(e.length).fill(void 0);let n=Array(e.length);for(let t=0;t<e.length;t++)n[t]=e[t].close;return Pr(n,t)}function Ir(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=2/(t+1),a=0;for(;a<n&&e[a]===void 0;)a++;if(a>=n)return r;let o=e[a];r[a]=o;for(let t=a+1;t<n;t++){let n=e[t];n!==void 0&&(o=n*i+o*(1-i),r[t]=o)}return r}function Lr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=Ir(i,t),o=Ir(a,t);for(let e=0;e<n;e++){let t=a[e],n=o[e];t===void 0||n===void 0||(r[e]=2*t-n)}return r}function Rr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=Ir(i,t),o=Ir(a,t),s=Ir(o,t);for(let e=0;e<n;e++){let t=a[e],n=o[e],i=s[e];t===void 0||n===void 0||i===void 0||(r[e]=3*t-3*n+i)}return r}function zr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=Math.max(1,Math.floor(t/2)),o=Math.max(1,Math.round(Math.sqrt(t))),s=Pr(i,a),c=Pr(i,t),l=Array(n).fill(void 0);for(let e=0;e<n;e++){let t=s[e],n=c[e];t===void 0||n===void 0||(l[e]=2*t-n)}return Pr(l,o)}function Br(e,t,n,r){let i=e.length,a=Array(i).fill(void 0);if(i===0||t<=0||n<=0||r<=0||i<=t)return a;let o=2/(n+1),s=2/(r+1),c=o-s,l=0;for(let n=1;n<=t;n++)l+=Math.abs(e[n].close-e[n-1].close);let u=e[t-1].close;a[t-1]=u;for(let n=t;n<i;n++){let r=e[n].close,o=e[n-t].close,d=Math.abs(r-o),f=((l>0?d/l:0)*c+s)**2;u+=f*(r-u),a[n]=u,n<i-1&&(l-=Math.abs(e[n-t+1].close-e[n-t].close),l+=Math.abs(e[n+1].close-e[n].close))}return a}var Vr=.02,Hr=.2;function Ur(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r<2||t<=0||n<=0)return i;let a=e[1].close>=e[0].close?`up`:`down`,o=a===`up`?e[0].low:e[0].high,s=a===`up`?e[0].high:e[0].low,c=t;i[0]={value:o,trend:a};for(let l=1;l<r;l++){let r=e[l];if(o+=c*(s-o),a===`up`){let t=e[l-1].low,n=l>=2?e[l-2].low:t;o=Math.min(o,t,n)}else{let t=e[l-1].high,n=l>=2?e[l-2].high:t;o=Math.max(o,t,n)}a===`up`&&r.low<o?(a=`down`,o=s,s=r.low,c=t):a===`down`&&r.high>o?(a=`up`,o=s,s=r.high,c=t):a===`up`&&r.high>s?(s=r.high,c=Math.min(c+t,n)):a===`down`&&r.low<s&&(s=r.low,c=Math.min(c+t,n)),i[l]={value:o,trend:a}}return i}function Wr(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r===0||t<=0||n<=0)return i;let a=Nr(e,t),o=`up`,s=1/0,c=-1/0;for(let t=0;t<r;t++){let r=e[t],l=a[t];if(l===void 0)continue;let u=(r.high+r.low)/2,d=u+n*l,f=u-n*l,p=t>0?e[t-1].close:r.close,m=d<s||p>s?d:s,h=f>c||p<c?f:c;o===`up`&&r.close<h?o=`down`:o===`down`&&r.close>m&&(o=`up`),i[t]={value:o===`up`?h:m,trend:o},s=m,c=h}return i}function Gr(e,t,n,r){let i=e.length,a=Array(i).fill(void 0);if(i===0||t<=0||n<=0)return a;let o=Array(i);for(let t=0;t<i;t++)o[t]=e[t].close;let s=Ir(o,t),c=Nr(e,n);for(let e=0;e<i;e++){let t=s[e],n=c[e];t===void 0||n===void 0||(a[e]={upper:t+r*n,middle:t,lower:t-r*n})}return a}function Kr(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;for(let i=t-1;i<n;i++){let n=-1/0,a=1/0;for(let r=0;r<t;r++){let t=e[i-r];t.high>n&&(n=t.high),t.low<a&&(a=t.low)}r[i]={upper:n,middle:(n+a)/2,lower:a}}return r}var qr=class{currentData=[];dataVersion=0;config=this.getDefaultConfig();configVersion=0;cachedSeries={};cachedBollSeries=[];cachedExpmaSeries=[];cachedEneSeries=[];cachedRsiSeries={};cachedCciSeries=[];cachedStochSeries=[];cachedMomSeries=[];cachedWmsrSeries=[];cachedKstSeries=[];cachedFastkSeries=[];cachedMacdSeries=[];cachedAtrSeries=[];cachedWmaSeries=[];cachedDemaSeries=[];cachedTemaSeries=[];cachedHmaSeries=[];cachedKamaSeries=[];cachedSarSeries=[];cachedSupertrendSeries=[];cachedKeltnerSeries=[];cachedDonchianSeries=[];dirtyData=!0;dirtyMAConfig=!0;dirtyBollConfig=!0;dirtyExpmaConfig=!0;dirtyEneConfig=!0;dirtyRsiConfig=!0;dirtyCciConfig=!0;dirtyStochConfig=!0;dirtyMomConfig=!0;dirtyWmsrConfig=!0;dirtyKstConfig=!0;dirtyFastkConfig=!0;dirtyMacdConfig=!0;dirtyAtrConfig=!0;dirtyWmaConfig=!0;dirtyDemaConfig=!0;dirtyTemaConfig=!0;dirtyHmaConfig=!0;dirtyKamaConfig=!0;dirtySarConfig=!0;dirtySupertrendConfig=!0;dirtyKeltnerConfig=!0;dirtyDonchianConfig=!0;getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},atr:{period:14,showATR:!0},wma:{period:9,showWMA:!0},dema:{period:20,showDEMA:!0},tema:{period:20,showTEMA:!0},hma:{period:9,showHMA:!0},kama:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},sar:{step:Vr,maxStep:Hr,showSAR:!0},supertrend:{atrPeriod:10,multiplier:3,showSuperTrend:!0},keltner:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},donchian:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`,atrPaneId:`sub_ATR`,wmaPaneId:`sub_WMA`,demaPaneId:`sub_DEMA`,temaPaneId:`sub_TEMA`,hmaPaneId:`sub_HMA`,kamaPaneId:`sub_KAMA`,sarPaneId:`sub_SAR`,supertrendPaneId:`sub_SuperTrend`,keltnerPaneId:`sub_Keltner`,donchianPaneId:`sub_Donchian`}}setData(e,t){this.dataVersion===t&&!this.dirtyData||(this.currentData=e,this.dataVersion=t,this.dirtyData=!0)}shallowEqual(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}setConfig(e,t){e.ma!==void 0&&!this.shallowEqual(e.ma,this.config.ma)&&(this.config.ma={...this.config.ma,...e.ma},this.dirtyMAConfig=!0),e.boll!==void 0&&!this.shallowEqual(e.boll,this.config.boll)&&(this.config.boll={...this.config.boll,...e.boll},this.dirtyBollConfig=!0),e.expma!==void 0&&!this.shallowEqual(e.expma,this.config.expma)&&(this.config.expma={...this.config.expma,...e.expma},this.dirtyExpmaConfig=!0),e.ene!==void 0&&!this.shallowEqual(e.ene,this.config.ene)&&(this.config.ene={...this.config.ene,...e.ene},this.dirtyEneConfig=!0),e.rsi!==void 0&&!this.shallowEqual(e.rsi,this.config.rsi)&&(this.config.rsi={...this.config.rsi,...e.rsi},this.dirtyRsiConfig=!0),e.cci!==void 0&&!this.shallowEqual(e.cci,this.config.cci)&&(this.config.cci={...this.config.cci,...e.cci},this.dirtyCciConfig=!0),e.stoch!==void 0&&!this.shallowEqual(e.stoch,this.config.stoch)&&(this.config.stoch={...this.config.stoch,...e.stoch},this.dirtyStochConfig=!0),e.mom!==void 0&&!this.shallowEqual(e.mom,this.config.mom)&&(this.config.mom={...this.config.mom,...e.mom},this.dirtyMomConfig=!0),e.wmsr!==void 0&&!this.shallowEqual(e.wmsr,this.config.wmsr)&&(this.config.wmsr={...this.config.wmsr,...e.wmsr},this.dirtyWmsrConfig=!0),e.kst!==void 0&&!this.shallowEqual(e.kst,this.config.kst)&&(this.config.kst={...this.config.kst,...e.kst},this.dirtyKstConfig=!0),e.fastk!==void 0&&!this.shallowEqual(e.fastk,this.config.fastk)&&(this.config.fastk={...this.config.fastk,...e.fastk},this.dirtyFastkConfig=!0),e.macd!==void 0&&!this.shallowEqual(e.macd,this.config.macd)&&(this.config.macd={...this.config.macd,...e.macd},this.dirtyMacdConfig=!0),e.atr!==void 0&&!this.shallowEqual(e.atr,this.config.atr)&&(this.config.atr={...this.config.atr,...e.atr},this.dirtyAtrConfig=!0),e.wma!==void 0&&!this.shallowEqual(e.wma,this.config.wma)&&(this.config.wma={...this.config.wma,...e.wma},this.dirtyWmaConfig=!0),e.dema!==void 0&&!this.shallowEqual(e.dema,this.config.dema)&&(this.config.dema={...this.config.dema,...e.dema},this.dirtyDemaConfig=!0),e.tema!==void 0&&!this.shallowEqual(e.tema,this.config.tema)&&(this.config.tema={...this.config.tema,...e.tema},this.dirtyTemaConfig=!0),e.hma!==void 0&&!this.shallowEqual(e.hma,this.config.hma)&&(this.config.hma={...this.config.hma,...e.hma},this.dirtyHmaConfig=!0),e.kama!==void 0&&!this.shallowEqual(e.kama,this.config.kama)&&(this.config.kama={...this.config.kama,...e.kama},this.dirtyKamaConfig=!0),e.sar!==void 0&&!this.shallowEqual(e.sar,this.config.sar)&&(this.config.sar={...this.config.sar,...e.sar},this.dirtySarConfig=!0),e.supertrend!==void 0&&!this.shallowEqual(e.supertrend,this.config.supertrend)&&(this.config.supertrend={...this.config.supertrend,...e.supertrend},this.dirtySupertrendConfig=!0),e.keltner!==void 0&&!this.shallowEqual(e.keltner,this.config.keltner)&&(this.config.keltner={...this.config.keltner,...e.keltner},this.dirtyKeltnerConfig=!0),e.donchian!==void 0&&!this.shallowEqual(e.donchian,this.config.donchian)&&(this.config.donchian={...this.config.donchian,...e.donchian},this.dirtyDonchianConfig=!0),e.rsiPaneId!==void 0&&(this.config.rsiPaneId=e.rsiPaneId),e.cciPaneId!==void 0&&(this.config.cciPaneId=e.cciPaneId),e.stochPaneId!==void 0&&(this.config.stochPaneId=e.stochPaneId),e.momPaneId!==void 0&&(this.config.momPaneId=e.momPaneId),e.wmsrPaneId!==void 0&&(this.config.wmsrPaneId=e.wmsrPaneId),e.kstPaneId!==void 0&&(this.config.kstPaneId=e.kstPaneId),e.fastkPaneId!==void 0&&(this.config.fastkPaneId=e.fastkPaneId),e.macdPaneId!==void 0&&(this.config.macdPaneId=e.macdPaneId),e.atrPaneId!==void 0&&(this.config.atrPaneId=e.atrPaneId),e.wmaPaneId!==void 0&&(this.config.wmaPaneId=e.wmaPaneId),e.demaPaneId!==void 0&&(this.config.demaPaneId=e.demaPaneId),e.temaPaneId!==void 0&&(this.config.temaPaneId=e.temaPaneId),e.hmaPaneId!==void 0&&(this.config.hmaPaneId=e.hmaPaneId),e.kamaPaneId!==void 0&&(this.config.kamaPaneId=e.kamaPaneId),e.sarPaneId!==void 0&&(this.config.sarPaneId=e.sarPaneId),e.supertrendPaneId!==void 0&&(this.config.supertrendPaneId=e.supertrendPaneId),e.keltnerPaneId!==void 0&&(this.config.keltnerPaneId=e.keltnerPaneId),e.donchianPaneId!==void 0&&(this.config.donchianPaneId=e.donchianPaneId),this.configVersion=t}forceDirty(){this.dirtyData=!0,this.dirtyMAConfig=!0,this.dirtyBollConfig=!0,this.dirtyExpmaConfig=!0,this.dirtyEneConfig=!0,this.dirtyRsiConfig=!0,this.dirtyCciConfig=!0,this.dirtyStochConfig=!0,this.dirtyMomConfig=!0,this.dirtyWmsrConfig=!0,this.dirtyKstConfig=!0,this.dirtyFastkConfig=!0,this.dirtyMacdConfig=!0,this.dirtyAtrConfig=!0,this.dirtyWmaConfig=!0,this.dirtyDemaConfig=!0,this.dirtyTemaConfig=!0,this.dirtyHmaConfig=!0,this.dirtyKamaConfig=!0,this.dirtySarConfig=!0,this.dirtySupertrendConfig=!0,this.dirtyKeltnerConfig=!0,this.dirtyDonchianConfig=!0}getDataVersion(){return this.dataVersion}getConfigVersion(){return this.configVersion}computeSeries(){let e=this.currentData,t=[];if(this.dirtyData||this.dirtyMAConfig){this.cachedSeries={};for(let t of gr){let n=`ma${t}`;this.config.ma[n]&&(this.cachedSeries[t]=br(e,t))}t.push(`ma`)}if((this.dirtyData||this.dirtyBollConfig)&&(this.cachedBollSeries=_r(e,this.config.boll.period,this.config.boll.multiplier),t.push(`boll`)),(this.dirtyData||this.dirtyExpmaConfig)&&(this.cachedExpmaSeries=vr(e,this.config.expma.fastPeriod,this.config.expma.slowPeriod),t.push(`expma`)),(this.dirtyData||this.dirtyEneConfig)&&(this.cachedEneSeries=yr(e,this.config.ene.period,this.config.ene.deviation),t.push(`ene`)),this.dirtyData||this.dirtyRsiConfig){this.cachedRsiSeries={};let n=[this.config.rsi.period1,this.config.rsi.period2,this.config.rsi.period3],r=[this.config.rsi.showRSI1,this.config.rsi.showRSI2,this.config.rsi.showRSI3];for(let t=0;t<n.length;t++)r[t]&&(this.cachedRsiSeries[n[t]]=xr(e,n[t]));t.push(`rsi`)}return(this.dirtyData||this.dirtyCciConfig)&&(this.config.cci.showCCI?this.cachedCciSeries=Sr(e,this.config.cci.period):this.cachedCciSeries=[],t.push(`cci`)),(this.dirtyData||this.dirtyStochConfig)&&(this.config.stoch.showK||this.config.stoch.showD?this.cachedStochSeries=Cr(e,this.config.stoch.n,this.config.stoch.m):this.cachedStochSeries=[],t.push(`stoch`)),(this.dirtyData||this.dirtyMomConfig)&&(this.config.mom.showMOM?this.cachedMomSeries=wr(e,this.config.mom.period):this.cachedMomSeries=[],t.push(`mom`)),(this.dirtyData||this.dirtyWmsrConfig)&&(this.config.wmsr.showWMSR?this.cachedWmsrSeries=Tr(e,this.config.wmsr.period):this.cachedWmsrSeries=[],t.push(`wmsr`)),(this.dirtyData||this.dirtyKstConfig)&&(this.config.kst.showKST||this.config.kst.showSignal?this.cachedKstSeries=Or(e,this.config.kst.roc1,this.config.kst.roc2,this.config.kst.roc3,this.config.kst.roc4,this.config.kst.signalPeriod):this.cachedKstSeries=[],t.push(`kst`)),(this.dirtyData||this.dirtyFastkConfig)&&(this.config.fastk.showFASTK?this.cachedFastkSeries=kr(e,this.config.fastk.period):this.cachedFastkSeries=[],t.push(`fastk`)),(this.dirtyData||this.dirtyMacdConfig)&&(this.config.macd.showDIF||this.config.macd.showDEA||this.config.macd.showBAR?this.cachedMacdSeries=Mr(e,this.config.macd.fastPeriod,this.config.macd.slowPeriod,this.config.macd.signalPeriod):this.cachedMacdSeries=[],t.push(`macd`)),(this.dirtyData||this.dirtyAtrConfig)&&(this.config.atr.showATR?this.cachedAtrSeries=Nr(e,this.config.atr.period):this.cachedAtrSeries=[],t.push(`atr`)),(this.dirtyData||this.dirtyWmaConfig)&&(this.config.wma.showWMA?this.cachedWmaSeries=Fr(e,this.config.wma.period):this.cachedWmaSeries=[],t.push(`wma`)),(this.dirtyData||this.dirtyDemaConfig)&&(this.config.dema.showDEMA?this.cachedDemaSeries=Lr(e,this.config.dema.period):this.cachedDemaSeries=[],t.push(`dema`)),(this.dirtyData||this.dirtyTemaConfig)&&(this.config.tema.showTEMA?this.cachedTemaSeries=Rr(e,this.config.tema.period):this.cachedTemaSeries=[],t.push(`tema`)),(this.dirtyData||this.dirtyHmaConfig)&&(this.config.hma.showHMA?this.cachedHmaSeries=zr(e,this.config.hma.period):this.cachedHmaSeries=[],t.push(`hma`)),(this.dirtyData||this.dirtyKamaConfig)&&(this.config.kama.showKAMA?this.cachedKamaSeries=Br(e,this.config.kama.period,this.config.kama.fastPeriod,this.config.kama.slowPeriod):this.cachedKamaSeries=[],t.push(`kama`)),(this.dirtyData||this.dirtySarConfig)&&(this.config.sar.showSAR?this.cachedSarSeries=Ur(e,this.config.sar.step,this.config.sar.maxStep):this.cachedSarSeries=[],t.push(`sar`)),(this.dirtyData||this.dirtySupertrendConfig)&&(this.config.supertrend.showSuperTrend?this.cachedSupertrendSeries=Wr(e,this.config.supertrend.atrPeriod,this.config.supertrend.multiplier):this.cachedSupertrendSeries=[],t.push(`supertrend`)),(this.dirtyData||this.dirtyKeltnerConfig)&&(this.config.keltner.showUpper||this.config.keltner.showMiddle||this.config.keltner.showLower?this.cachedKeltnerSeries=Gr(e,this.config.keltner.emaPeriod,this.config.keltner.atrPeriod,this.config.keltner.multiplier):this.cachedKeltnerSeries=[],t.push(`keltner`)),(this.dirtyData||this.dirtyDonchianConfig)&&(this.config.donchian.showUpper||this.config.donchian.showMiddle||this.config.donchian.showLower?this.cachedDonchianSeries=Kr(e,this.config.donchian.period):this.cachedDonchianSeries=[],t.push(`donchian`)),this.dirtyData=!1,this.dirtyMAConfig=!1,this.dirtyBollConfig=!1,this.dirtyExpmaConfig=!1,this.dirtyEneConfig=!1,this.dirtyRsiConfig=!1,this.dirtyCciConfig=!1,this.dirtyStochConfig=!1,this.dirtyMomConfig=!1,this.dirtyWmsrConfig=!1,this.dirtyKstConfig=!1,this.dirtyFastkConfig=!1,this.dirtyMacdConfig=!1,this.dirtyAtrConfig=!1,this.dirtyWmaConfig=!1,this.dirtyDemaConfig=!1,this.dirtyTemaConfig=!1,this.dirtyHmaConfig=!1,this.dirtyKamaConfig=!1,this.dirtySarConfig=!1,this.dirtySupertrendConfig=!1,this.dirtyKeltnerConfig=!1,this.dirtyDonchianConfig=!1,{ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}},atr:{series:this.cachedAtrSeries,params:{...this.config.atr}},wma:{series:this.cachedWmaSeries,params:{...this.config.wma}},dema:{series:this.cachedDemaSeries,params:{...this.config.dema}},tema:{series:this.cachedTemaSeries,params:{...this.config.tema}},hma:{series:this.cachedHmaSeries,params:{...this.config.hma}},kama:{series:this.cachedKamaSeries,params:{...this.config.kama}},sar:{series:this.cachedSarSeries,params:{...this.config.sar}},supertrend:{series:this.cachedSupertrendSeries,params:{...this.config.supertrend}},keltner:{series:this.cachedKeltnerSeries,params:{...this.config.keltner}},donchian:{series:this.cachedDonchianSeries,params:{...this.config.donchian}},_changed:t}}getCachedSeries(){return{_changed:[],ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}},atr:{series:this.cachedAtrSeries,params:{...this.config.atr}},wma:{series:this.cachedWmaSeries,params:{...this.config.wma}},dema:{series:this.cachedDemaSeries,params:{...this.config.dema}},tema:{series:this.cachedTemaSeries,params:{...this.config.tema}},hma:{series:this.cachedHmaSeries,params:{...this.config.hma}},kama:{series:this.cachedKamaSeries,params:{...this.config.kama}},sar:{series:this.cachedSarSeries,params:{...this.config.sar}},supertrend:{series:this.cachedSupertrendSeries,params:{...this.config.supertrend}},keltner:{series:this.cachedKeltnerSeries,params:{...this.config.keltner}},donchian:{series:this.cachedDonchianSeries,params:{...this.config.donchian}}}}};function Jr(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.type==`string`?[`ready`,`seriesResult`,`error`].includes(t.type):!1}var Z=(e,t)=>`indicator:${e}:${t}`,Yr=e=>Z(`rsi`,e),Xr={timestamp:0,series:{},enabledPeriods:[],params:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},Zr=e=>Z(`cci`,e),Qr={timestamp:0,series:[],params:{period:14,showCCI:!0},valueMin:-150,valueMax:150,visibleMin:1/0,visibleMax:-1/0},$r=e=>Z(`stoch`,e),ei={timestamp:0,series:[],params:{n:9,m:3,showK:!0,showD:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},ti=e=>Z(`mom`,e),ni={timestamp:0,series:[],params:{period:10,showMOM:!0},valueMin:0,valueMax:0,visibleMin:1/0,visibleMax:-1/0},ri=e=>Z(`wmsr`,e),ii={timestamp:0,series:[],params:{period:14,showWMSR:!0},valueMin:-100,valueMax:0,visibleMin:1/0,visibleMax:-1/0},ai=e=>Z(`kst`,e),oi={timestamp:0,series:[],params:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},valueMin:0,valueMax:0,visibleMin:1/0,visibleMax:-1/0},si=e=>Z(`fastk`,e),ci={timestamp:0,series:[],params:{period:9,showFASTK:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},li=`indicator:macd`;function ui(e){return`${li}:${e}`}var di={timestamp:0,series:[],params:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},visibleMin:1/0,visibleMax:-1/0,valueMin:-1/0,valueMax:1/0},fi=e=>Z(`atr`,e),pi={timestamp:0,series:[],params:{period:14,showATR:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},mi=e=>Z(`wma`,e),hi={timestamp:0,series:[],params:{period:9,showWMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},gi=e=>Z(`dema`,e),_i={timestamp:0,series:[],params:{period:20,showDEMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},vi=e=>Z(`tema`,e),yi={timestamp:0,series:[],params:{period:20,showTEMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},bi=e=>Z(`hma`,e),xi={timestamp:0,series:[],params:{period:9,showHMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Si=e=>Z(`kama`,e),Ci={timestamp:0,series:[],params:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},wi=e=>Z(`sar`,e),Ti=.02,Ei=.2,Di={timestamp:0,series:[],params:{step:Ti,maxStep:Ei,showSAR:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Oi=e=>Z(`supertrend`,e),ki={timestamp:0,series:[],params:{atrPeriod:10,multiplier:3,showSuperTrend:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Ai=e=>Z(`keltner`,e),ji={timestamp:0,series:[],params:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Mi=e=>Z(`donchian`,e),Ni={timestamp:0,series:[],params:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0};function Pi(e,t){let n=t.end-1;return n>=0&&n<e.macd.series.length?e.macd.series[n]:null}function Q(e,t,n){return{...e,...n,timestamp:t}}function Fi(e,t,n,r={}){let i=r.rsi??!0,a=r.cci??!0,o=r.stoch??!0,s=r.mom??!0,c=r.wmsr??!0,l=r.kst??!0,u=r.fastk??!0,d=r.macd??!0,f=r.atr??!0,p=r.wma??!0,m=r.dema??!0,h=r.tema??!0,g=r.hma??!0,_=r.kama??!0,v=r.sar??!0,y=r.supertrend??!0,b=r.keltner??!0,x=r.donchian??!0,S=i?Vi(e.rsi.series,t):null,C=a?Hi(e.cci.series,t):null,w=o?Ui(e.stoch.series,t):null,T=s?Wi(e.mom.series,t):null,E=c?Gi(e.wmsr.series,t):null,D=l?Ki(e.kst.series,t):null,O=u?qi(e.fastk.series,t):null,k=d?Ji(e.macd.series,t):null,A=f?Yi(e.atr.series,t):null,j=p?Qi(e.wma.series,t):null,M=m?Qi(e.dema.series,t):null,N=h?Qi(e.tema.series,t):null,P=g?Qi(e.hma.series,t):null,F=_?Qi(e.kama.series,t):null,I=v?Zi(e.sar.series,t):null,L=y?Zi(e.supertrend.series,t):null,ee=b?Xi(e.keltner.series,t):null,te=x?Xi(e.donchian.series,t):null,ne=d?Pi(e,t):null,re=k?Math.max(Math.abs(k.max),Math.abs(k.min))*.1:0,ie=k&&Number.isFinite(k.min)?k.min-re:di.valueMin,ae=k&&Number.isFinite(k.max)?k.max+re:di.valueMax,oe=C?Math.min(C.min,-150):Qr.valueMin,se=C?Math.max(C.max,150):Qr.valueMax,ce=T?Math.max(Math.abs(T.max),Math.abs(T.min))*.1:0,le=T?T.min-ce:ni.valueMin,ue=T?T.max+ce:ni.valueMax,de=(D?D.max-D.min:0)*.1,R=D?D.min-de:oi.valueMin,fe=D?D.max+de:oi.valueMax,pe=A&&Number.isFinite(A.max)?A.max*1.1:pi.valueMax,z=(e,t)=>{if(!e||!Number.isFinite(e.min)||!Number.isFinite(e.max))return{valueMin:t.valueMin,valueMax:t.valueMax};let n=e.max-e.min,r=n>0?n*.05:Math.max(1,Math.abs(e.max)*.05);return{valueMin:e.min-r,valueMax:e.max+r}},me=z(j,hi),he=z(M,_i),ge=z(N,yi),_e=z(P,xi),B=z(F,Ci),ve=z(I,Di),ye=z(L,ki),be=z(ee,ji),xe=z(te,Ni);return{rsi:i?{timestamp:n,series:e.rsi.series,enabledPeriods:e.rsi.enabledPeriods,params:e.rsi.params,valueMin:0,valueMax:100,visibleMin:S.min,visibleMax:S.max}:Q(Xr,n,{series:e.rsi.series,enabledPeriods:e.rsi.enabledPeriods,params:e.rsi.params}),cci:a?{timestamp:n,series:e.cci.series,params:e.cci.params,valueMin:oe,valueMax:se,visibleMin:C.min,visibleMax:C.max}:Q(Qr,n,{series:e.cci.series,params:e.cci.params}),stoch:o?{timestamp:n,series:e.stoch.series,params:e.stoch.params,valueMin:0,valueMax:100,visibleMin:w.min,visibleMax:w.max}:Q(ei,n,{series:e.stoch.series,params:e.stoch.params}),mom:s?{timestamp:n,series:e.mom.series,params:e.mom.params,valueMin:le,valueMax:ue,visibleMin:T.min,visibleMax:T.max}:Q(ni,n,{series:e.mom.series,params:e.mom.params}),wmsr:c?{timestamp:n,series:e.wmsr.series,params:e.wmsr.params,valueMin:-100,valueMax:0,visibleMin:E.min,visibleMax:E.max}:Q(ii,n,{series:e.wmsr.series,params:e.wmsr.params}),kst:l?{timestamp:n,series:e.kst.series,params:e.kst.params,valueMin:R,valueMax:fe,visibleMin:D.min,visibleMax:D.max}:Q(oi,n,{series:e.kst.series,params:e.kst.params}),fastk:u?{timestamp:n,series:e.fastk.series,params:e.fastk.params,valueMin:0,valueMax:100,visibleMin:O.min,visibleMax:O.max}:Q(ci,n,{series:e.fastk.series,params:e.fastk.params}),macd:d?{timestamp:n,series:e.macd.series,params:e.macd.params,valueMin:ie,valueMax:ae,visibleMin:k.min,visibleMax:k.max,latestValues:ne?{dif:ne.dif,dea:ne.dea,macd:ne.macd}:void 0}:Q(di,n,{series:e.macd.series,params:e.macd.params}),atr:f?{timestamp:n,series:e.atr.series,params:e.atr.params,valueMin:0,valueMax:pe,visibleMin:A.min,visibleMax:A.max}:Q(pi,n,{series:e.atr.series,params:e.atr.params}),wma:p?{timestamp:n,series:e.wma.series,params:e.wma.params,valueMin:me.valueMin,valueMax:me.valueMax,visibleMin:j.min,visibleMax:j.max}:Q(hi,n,{series:e.wma.series,params:e.wma.params}),dema:m?{timestamp:n,series:e.dema.series,params:e.dema.params,valueMin:he.valueMin,valueMax:he.valueMax,visibleMin:M.min,visibleMax:M.max}:Q(_i,n,{series:e.dema.series,params:e.dema.params}),tema:h?{timestamp:n,series:e.tema.series,params:e.tema.params,valueMin:ge.valueMin,valueMax:ge.valueMax,visibleMin:N.min,visibleMax:N.max}:Q(yi,n,{series:e.tema.series,params:e.tema.params}),hma:g?{timestamp:n,series:e.hma.series,params:e.hma.params,valueMin:_e.valueMin,valueMax:_e.valueMax,visibleMin:P.min,visibleMax:P.max}:Q(xi,n,{series:e.hma.series,params:e.hma.params}),kama:_?{timestamp:n,series:e.kama.series,params:e.kama.params,valueMin:B.valueMin,valueMax:B.valueMax,visibleMin:F.min,visibleMax:F.max}:Q(Ci,n,{series:e.kama.series,params:e.kama.params}),sar:v?{timestamp:n,series:e.sar.series,params:e.sar.params,valueMin:ve.valueMin,valueMax:ve.valueMax,visibleMin:I.min,visibleMax:I.max}:Q(Di,n,{series:e.sar.series,params:e.sar.params}),supertrend:y?{timestamp:n,series:e.supertrend.series,params:e.supertrend.params,valueMin:ye.valueMin,valueMax:ye.valueMax,visibleMin:L.min,visibleMax:L.max}:Q(ki,n,{series:e.supertrend.series,params:e.supertrend.params}),keltner:b?{timestamp:n,series:e.keltner.series,params:e.keltner.params,valueMin:be.valueMin,valueMax:be.valueMax,visibleMin:ee.min,visibleMax:ee.max}:Q(ji,n,{series:e.keltner.series,params:e.keltner.params}),donchian:x?{timestamp:n,series:e.donchian.series,params:e.donchian.params,valueMin:xe.valueMin,valueMax:xe.valueMax,visibleMin:te.min,visibleMax:te.max}:Q(Ni,n,{series:e.donchian.series,params:e.donchian.params})}}function Ii(e,t,n){let r=Li(e.ma.series,t),i=Ri(e.boll.series,t),a=zi(e.expma.series,t),o=Bi(e.ene.series,t),s=Fi(e,t,n);return{ma:{timestamp:n,series:e.ma.series,enabledPeriods:e.ma.enabledPeriods,visibleMin:r.min,visibleMax:r.max},boll:{timestamp:n,series:e.boll.series,params:e.boll.params,visibleMin:i.min,visibleMax:i.max},expma:{timestamp:n,series:e.expma.series,params:e.expma.params,visibleMin:a.min,visibleMax:a.max},ene:{timestamp:n,series:e.ene.series,params:e.ene.params,visibleMin:o.min,visibleMax:o.max},...s}}function Li(e,t){let n=Object.values(e);if(n.length===0||t.start>=n[0].length)return{min:1/0,max:-1/0};let r=1/0,i=-1/0;for(let e of n){let n=Math.min(t.end,e.length);for(let a=t.start;a<n;a++){let t=e[a];t!==void 0&&(r=Math.min(r,t),i=Math.max(i,t))}}return{min:r,max:i}}function Ri(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function zi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.fast,t.slow),r=Math.max(r,t.fast,t.slow))}return{min:n,max:r}}function Bi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function Vi(e,t){let n=Object.values(e);if(n.length===0||t.start>=n[0].length)return{min:1/0,max:-1/0};let r=1/0,i=-1/0;for(let e of n){let n=Math.min(t.end,e.length);for(let a=t.start;a<n;a++){let t=e[a];t!==void 0&&(r=Math.min(r,t),i=Math.max(i,t))}}return{min:r,max:i}}function Hi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Ui(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.k,t.d),r=Math.max(r,t.k,t.d))}return{min:n,max:r}}function Wi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Gi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Ki(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.kst,t.signal),r=Math.max(r,t.kst,t.signal))}return{min:n,max:r}}function qi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Ji(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.dif,t.dea,t.macd),r=Math.max(r,t.dif,t.dea,t.macd))}return{min:n,max:r}}function Yi(e,t){return Qi(e,t)}function Xi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.lower),r=Math.max(r,t.upper))}return{min:n,max:r}}function Zi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.value),r=Math.max(r,t.value))}return{min:n,max:r}}function Qi(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function $i(e,t,n){let r=1/0,i=-1/0,{start:a,end:o}=t;if(n.has(`ma`)&&Object.keys(e.ma.series).length>0)for(let t of Object.values(e.ma.series))for(let e=a;e<o&&e<t.length;e++){let n=t[e];n!==void 0&&(r=Math.min(r,n),i=Math.max(i,n))}if(n.has(`boll`)&&e.boll.series.length>0)for(let t=a;t<o&&t<e.boll.series.length;t++){let n=e.boll.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}if(n.has(`expma`)&&e.expma.series.length>0)for(let t=a;t<o&&t<e.expma.series.length;t++){let n=e.expma.series[t];n&&(r=Math.min(r,n.fast,n.slow),i=Math.max(i,n.fast,n.slow))}if(n.has(`ene`)&&e.ene.series.length>0)for(let t=a;t<o&&t<e.ene.series.length;t++){let n=e.ene.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}return!Number.isFinite(r)||!Number.isFinite(i)?null:{min:r,max:i}}var ea=Z(`ma`,`main`),ta=Z(`boll`,`main`),na=Z(`expma`,`main`),ra=Z(`ene`,`main`),ia=class{pluginHost=null;visibleRange={start:0,end:0};activeMainIndicators=new Set;dataVersion=0;configVersion=0;requestId=0;lastAppliedRequestId=0;currentData=[];configSnapshot=this.getDefaultConfig();worker=null;workerReady=!1;useWorker=!1;pendingRequest=null;inlineRuntime=null;latestResult=null;invalidateCallback=null;getActiveSubPaneIds=null;constructor(){this.initBackend()}setPluginHost(e){this.pluginHost=e}setInvalidateCallback(e){this.invalidateCallback=e}onSubPaneChanged(){this.latestResult&&this.updateVisibleStatesOnly()}setActiveSubPaneProvider(e){this.getActiveSubPaneIds=e}destroy(){this.terminateWorker(),this.inlineRuntime=null,this.latestResult=null,this.invalidateCallback=null}getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},atr:{period:14,showATR:!0},wma:{period:9,showWMA:!0},dema:{period:20,showDEMA:!0},tema:{period:20,showTEMA:!0},hma:{period:9,showHMA:!0},kama:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},sar:{step:Ti,maxStep:Ei,showSAR:!0},supertrend:{atrPeriod:10,multiplier:3,showSuperTrend:!0},keltner:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},donchian:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`,atrPaneId:`sub_ATR`,wmaPaneId:`sub_WMA`,demaPaneId:`sub_DEMA`,temaPaneId:`sub_TEMA`,hmaPaneId:`sub_HMA`,kamaPaneId:`sub_KAMA`,sarPaneId:`sub_SAR`,supertrendPaneId:`sub_SuperTrend`,keltnerPaneId:`sub_Keltner`,donchianPaneId:`sub_Donchian`}}initBackend(){this.tryInitWorker()||this.initInlineRuntime()}tryInitWorker(){if(console.log(`[IndicatorScheduler] tryInitWorker: Worker available?`,typeof Worker<`u`),typeof Worker>`u`)return!1;try{let e=new URL(`data:video/mp2t;base64,LyoqCiAqIEluZGljYXRvciBXb3JrZXIg5YWl5Y+jCiAqIOi/kOihjOWcqOeLrOeri+e6v+eoi++8jOi0n+i0o+aMh+agh+iuoeeulwogKi8KCmltcG9ydCB0eXBlIHsKICAgIEluZGljYXRvcldvcmtlclJlcXVlc3QsCiAgICBJbmRpY2F0b3JXb3JrZXJSZXNwb25zZSwKICAgIEluZGljYXRvckNvbmZpZ1NuYXBzaG90LAp9IGZyb20gJy4vd29ya2VyUHJvdG9jb2wnCmltcG9ydCB7IFBST1RPQ09MX1ZFUlNJT04gfSBmcm9tICcuL3dvcmtlclByb3RvY29sJwppbXBvcnQgdHlwZSB7IEtMaW5lRGF0YSB9IGZyb20gJ0AvdHlwZXMvcHJpY2UnCmltcG9ydCB7IEluZGljYXRvclJ1bnRpbWUgfSBmcm9tICcuL2luZGljYXRvclJ1bnRpbWUnCgovLyBXb3JrZXIg5YWo5bGA5L2c55So5Z+fCmNvbnN0IGN0eCA9IHNlbGYgYXMgdW5rbm93biBhcyBXb3JrZXIKCi8vIOi/kOihjOaXtuWunuS+iwpsZXQgcnVudGltZTogSW5kaWNhdG9yUnVudGltZSB8IG51bGwgPSBudWxsCgovKioKICog5Y+R6YCB5ZON5bqU5Yiw5Li757q/56iLCiAqLwpmdW5jdGlvbiBwb3N0UmVzcG9uc2UocmVzcG9uc2U6IEluZGljYXRvcldvcmtlclJlc3BvbnNlKTogdm9pZCB7CiAgICBjdHgucG9zdE1lc3NhZ2UocmVzcG9uc2UpCn0KCi8qKgogKiDlpITnkIbliJ3lp4vljJYKICovCmZ1bmN0aW9uIGhhbmRsZUluaXQoKTogdm9pZCB7CiAgICBydW50aW1lID0gbmV3IEluZGljYXRvclJ1bnRpbWUoKQogICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICB0eXBlOiAncmVhZHknLAogICAgICAgIHByb3RvY29sVmVyc2lvbjogUFJPVE9DT0xfVkVSU0lPTiwKICAgIH0pCn0KCi8qKgogKiDlpITnkIborr7nva7mlbDmja4KICovCmZ1bmN0aW9uIGhhbmRsZVNldERhdGEoZGF0YTogS0xpbmVEYXRhW10sIHZlcnNpb246IG51bWJlcik6IHZvaWQgewogICAgaWYgKCFydW50aW1lKSB7CiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgc3RhZ2U6ICdzZXREYXRhJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXREYXRhKGRhdGEsIHZlcnNpb24pCn0KCi8qKgogKiDlpITnkIborr7nva7phY3nva4KICovCmZ1bmN0aW9uIGhhbmRsZVNldENvbmZpZyhjb25maWc6IFBhcnRpYWw8SW5kaWNhdG9yQ29uZmlnU25hcHNob3Q+LCB2ZXJzaW9uOiBudW1iZXIpOiB2b2lkIHsKICAgIGlmICghcnVudGltZSkgewogICAgICAgIHBvc3RSZXNwb25zZSh7CiAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgIHN0YWdlOiAnc2V0Q29uZmlnJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXRDb25maWcoY29uZmlnLCB2ZXJzaW9uKQp9CgovKioKICog5aSE55CG6K6h566XIHNlcmllcwogKi8KZnVuY3Rpb24gaGFuZGxlQ29tcHV0ZVNlcmllcyhyZXF1ZXN0SWQ6IG51bWJlciwgZGF0YVZlcnNpb246IG51bWJlciwgY29uZmlnVmVyc2lvbjogbnVtYmVyKTogdm9pZCB7CiAgICBpZiAoIXJ1bnRpbWUpIHsKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnZXJyb3InLAogICAgICAgICAgICByZXF1ZXN0SWQsCiAgICAgICAgICAgIHN0YWdlOiAnY29tcHV0ZVNlcmllcycsCiAgICAgICAgICAgIG1lc3NhZ2U6ICdSdW50aW1lIG5vdCBpbml0aWFsaXplZCcsCiAgICAgICAgfSkKICAgICAgICByZXR1cm4KICAgIH0KCiAgICBjb25zdCBzdGFydFRpbWUgPSBwZXJmb3JtYW5jZS5ub3coKQoKICAgIHRyeSB7CiAgICAgICAgY29uc29sZS5sb2coYFtJbmRpY2F0b3JXb3JrZXJdIGNvbXB1dGVTZXJpZXMgU1RBUlQgcmVxSWQ9JHtyZXF1ZXN0SWR9YCkKICAgICAgICBjb25zdCByZXN1bHRzID0gcnVudGltZS5jb21wdXRlU2VyaWVzKCkKICAgICAgICBjb25zdCBjb21wdXRlTXMgPSBwZXJmb3JtYW5jZS5ub3coKSAtIHN0YXJ0VGltZQogICAgICAgIGNvbnNvbGUubG9nKGBbSW5kaWNhdG9yV29ya2VyXSBjb21wdXRlU2VyaWVzIERPTkUgaW4gJHtjb21wdXRlTXMudG9GaXhlZCgxKX1tcywgY2hhbmdlZD1bJHtyZXN1bHRzLl9jaGFuZ2VkLmpvaW4oJywnKX1dYCkKCiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ3Nlcmllc1Jlc3VsdCcsCiAgICAgICAgICAgIHJlcXVlc3RJZCwKICAgICAgICAgICAgZGF0YVZlcnNpb24sCiAgICAgICAgICAgIGNvbmZpZ1ZlcnNpb24sCiAgICAgICAgICAgIHJlc3VsdHMsCiAgICAgICAgICAgIG1ldHJpY3M6IHsKICAgICAgICAgICAgICAgIGNvbXB1dGVNcywKICAgICAgICAgICAgICAgIGRhdGFMZW5ndGg6IDAsIC8vIOeUseiwg+eUqOaWueWhq+WFhQogICAgICAgICAgICB9LAogICAgICAgIH0pCiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICBjb25zdCBtZXNzYWdlID0gZXJyIGluc3RhbmNlb2YgRXJyb3IgPyBlcnIubWVzc2FnZSA6IFN0cmluZyhlcnIpCiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgcmVxdWVzdElkLAogICAgICAgICAgICBzdGFnZTogJ2NvbXB1dGVTZXJpZXMnLAogICAgICAgICAgICBtZXNzYWdlLAogICAgICAgIH0pCiAgICB9Cn0KCi8qKgogKiDlpITnkIbplIDmr4EKICovCmZ1bmN0aW9uIGhhbmRsZURpc3Bvc2UoKTogdm9pZCB7CiAgICBydW50aW1lID0gbnVsbAogICAgLy8gV29ya2VyIOS8muiiq+S4u+e6v+eoiyB0ZXJtaW5hdGXvvIzov5nph4zlgZrmuIXnkIbljbPlj68KfQoKLyoqCiAqIOa2iOaBr+WkhOeQhuWZqAogKi8KY3R4Lm9ubWVzc2FnZSA9IChldmVudDogTWVzc2FnZUV2ZW50PEluZGljYXRvcldvcmtlclJlcXVlc3Q+KSA9PiB7CiAgICBjb25zdCBtc2cgPSBldmVudC5kYXRhCgogICAgaWYgKCFtc2cgfHwgdHlwZW9mIG1zZyAhPT0gJ29iamVjdCcpIHsKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnZXJyb3InLAogICAgICAgICAgICBzdGFnZTogJ2luaXQnLAogICAgICAgICAgICBtZXNzYWdlOiAnSW52YWxpZCBtZXNzYWdlIGZvcm1hdCcsCiAgICAgICAgfSkKICAgICAgICByZXR1cm4KICAgIH0KCiAgICBzd2l0Y2ggKG1zZy50eXBlKSB7CiAgICAgICAgY2FzZSAnaW5pdCc6CiAgICAgICAgICAgIGhhbmRsZUluaXQoKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdzZXREYXRhJzoKICAgICAgICAgICAgaGFuZGxlU2V0RGF0YShtc2cuZGF0YSwgbXNnLmRhdGFWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdzZXRDb25maWcnOgogICAgICAgICAgICBoYW5kbGVTZXRDb25maWcobXNnLmNvbmZpZ3MsIG1zZy5jb25maWdWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdjb21wdXRlU2VyaWVzJzoKICAgICAgICAgICAgaGFuZGxlQ29tcHV0ZVNlcmllcyhtc2cucmVxdWVzdElkLCBtc2cuZGF0YVZlcnNpb24sIG1zZy5jb25maWdWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdkaXNwb3NlJzoKICAgICAgICAgICAgaGFuZGxlRGlzcG9zZSgpCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGRlZmF1bHQ6IHsKICAgICAgICAgICAgY29uc3QgX2V4aGF1c3RpdmVDaGVjazogbmV2ZXIgPSBtc2cKICAgICAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgICAgICBzdGFnZTogJ2luaXQnLAogICAgICAgICAgICAgICAgbWVzc2FnZTogYFVua25vd24gbWVzc2FnZSB0eXBlOiAkeyhfZXhoYXVzdGl2ZUNoZWNrIGFzIHVua25vd24gYXMgeyB0eXBlOiBzdHJpbmcgfSkudHlwZX1gLAogICAgICAgICAgICB9KQogICAgICAgIH0KICAgIH0KfQoKLy8g6YCa55+l5Li757q/56iLIHdvcmtlciDlt7LliqDovb3vvIjlj6/pgInvvIzkuLvopoHnlKjkuo7osIPor5XvvIkKLy8gY29uc29sZS5sb2coJ1tJbmRpY2F0b3JXb3JrZXJdIExvYWRlZCcpCg==`,``+{}.url);return console.log(`[IndicatorScheduler] Creating worker from:`,e.href),this.worker=new Worker(e,{type:`module`}),console.log(`[IndicatorScheduler] Worker created, waiting for ready...`),this.worker.onmessage=e=>this.handleWorkerMessage(e.data),this.worker.onerror=e=>{console.error(`[IndicatorScheduler] Worker error:`,e),this.fallbackToInline()},this.worker.postMessage({type:`init`,protocolVersion:1}),!0}catch(e){return console.warn(`[IndicatorScheduler] Failed to init worker:`,e),!1}}initInlineRuntime(){console.log(`[IndicatorScheduler] Using INLINE runtime (fallback)`),this.inlineRuntime=new qr,this.useWorker=!1,this.workerReady=!0}fallbackToInline(){console.warn(`[IndicatorScheduler] Falling back to inline runtime`),this.terminateWorker(),this.initInlineRuntime(),this.pendingRequest&&this.computeWithInline()}terminateWorker(){this.worker&&=(this.worker.terminate(),null),this.workerReady=!1,this.useWorker=!1}handleWorkerMessage(e){if(!Jr(e)){console.warn(`[IndicatorScheduler] Invalid worker response:`,e);return}switch(e.type){case`ready`:this.workerReady=!0,this.useWorker=!0,console.log(`[IndicatorScheduler] Worker READY - using Worker backend`),this.triggerRecompute();break;case`seriesResult`:this.handleSeriesResult(e);break;case`error`:console.error(`[IndicatorScheduler] Worker error:`,e.stage,e.message),this.pendingRequest&&e.requestId===this.pendingRequest.requestId&&this.fallbackToInline();break;default:console.warn(`[IndicatorScheduler] Unknown response type:`,e.type)}}handleSeriesResult(e){e.requestId<this.lastAppliedRequestId||e.dataVersion!==this.dataVersion||e.configVersion!==this.configVersion||(console.log(`[IndicatorScheduler] << Worker result: requestId=${e.requestId} metrics=`,e.metrics),this.lastAppliedRequestId=e.requestId,this.pendingRequest=null,this.latestResult=e.results,this.applyResults(e.results),this.invalidateCallback?.())}applyResults(e){if(!this.pluginHost)return;let t=new Set(e._changed),n=Date.now(),r=Ii(e,this.visibleRange,n);if(t.has(`ma`)&&this.pluginHost.setSharedState(ea,r.ma,`ma_scheduler`),t.has(`boll`)&&this.pluginHost.setSharedState(ta,r.boll,`indicator_scheduler`),t.has(`expma`)&&this.pluginHost.setSharedState(na,r.expma,`indicator_scheduler`),t.has(`ene`)&&this.pluginHost.setSharedState(ra,r.ene,`indicator_scheduler`),t.has(`rsi`)){let e=Yr(this.configSnapshot.rsiPaneId);this.pluginHost.setSharedState(e,r.rsi,`indicator_scheduler`)}if(t.has(`cci`)){let e=Zr(this.configSnapshot.cciPaneId);this.pluginHost.setSharedState(e,r.cci,`indicator_scheduler`)}if(t.has(`stoch`)){let e=$r(this.configSnapshot.stochPaneId);this.pluginHost.setSharedState(e,r.stoch,`indicator_scheduler`)}if(t.has(`mom`)){let e=ti(this.configSnapshot.momPaneId);this.pluginHost.setSharedState(e,r.mom,`indicator_scheduler`)}if(t.has(`wmsr`)){let e=ri(this.configSnapshot.wmsrPaneId);this.pluginHost.setSharedState(e,r.wmsr,`indicator_scheduler`)}if(t.has(`kst`)){let e=ai(this.configSnapshot.kstPaneId);this.pluginHost.setSharedState(e,r.kst,`indicator_scheduler`)}if(t.has(`fastk`)){let e=si(this.configSnapshot.fastkPaneId);this.pluginHost.setSharedState(e,r.fastk,`indicator_scheduler`)}if(t.has(`macd`)){let e=ui(this.configSnapshot.macdPaneId);this.pluginHost.setSharedState(e,r.macd,`indicator_scheduler`)}if(t.has(`atr`)){let e=fi(this.configSnapshot.atrPaneId);this.pluginHost.setSharedState(e,r.atr,`indicator_scheduler`)}if(t.has(`wma`)){let e=mi(this.configSnapshot.wmaPaneId);this.pluginHost.setSharedState(e,r.wma,`indicator_scheduler`)}if(t.has(`dema`)){let e=gi(this.configSnapshot.demaPaneId);this.pluginHost.setSharedState(e,r.dema,`indicator_scheduler`)}if(t.has(`tema`)){let e=vi(this.configSnapshot.temaPaneId);this.pluginHost.setSharedState(e,r.tema,`indicator_scheduler`)}if(t.has(`hma`)){let e=bi(this.configSnapshot.hmaPaneId);this.pluginHost.setSharedState(e,r.hma,`indicator_scheduler`)}if(t.has(`kama`)){let e=Si(this.configSnapshot.kamaPaneId);this.pluginHost.setSharedState(e,r.kama,`indicator_scheduler`)}if(t.has(`sar`)){let e=wi(this.configSnapshot.sarPaneId);this.pluginHost.setSharedState(e,r.sar,`indicator_scheduler`)}if(t.has(`supertrend`)){let e=Oi(this.configSnapshot.supertrendPaneId);this.pluginHost.setSharedState(e,r.supertrend,`indicator_scheduler`)}if(t.has(`keltner`)){let e=Ai(this.configSnapshot.keltnerPaneId);this.pluginHost.setSharedState(e,r.keltner,`indicator_scheduler`)}if(t.has(`donchian`)){let e=Mi(this.configSnapshot.donchianPaneId);this.pluginHost.setSharedState(e,r.donchian,`indicator_scheduler`)}}updateVisibleStatesOnly(){if(!this.pluginHost||!this.latestResult)return;let e=Date.now(),t=this.buildActiveSubIndicatorMask(),n=Fi(this.latestResult,this.visibleRange,e,t);console.log(`[ATR-Scheduler] updateVisibleStatesOnly: atrActive=${!!t.atr} atrPaneId=${this.configSnapshot.atrPaneId} seriesLen=${n.atr.series.length}`);let r=Yr(this.configSnapshot.rsiPaneId);this.pluginHost.setSharedState(r,n.rsi,`indicator_scheduler`);let i=Zr(this.configSnapshot.cciPaneId);this.pluginHost.setSharedState(i,n.cci,`indicator_scheduler`);let a=$r(this.configSnapshot.stochPaneId);this.pluginHost.setSharedState(a,n.stoch,`indicator_scheduler`);let o=ti(this.configSnapshot.momPaneId);this.pluginHost.setSharedState(o,n.mom,`indicator_scheduler`);let s=ri(this.configSnapshot.wmsrPaneId);this.pluginHost.setSharedState(s,n.wmsr,`indicator_scheduler`);let c=ai(this.configSnapshot.kstPaneId);this.pluginHost.setSharedState(c,n.kst,`indicator_scheduler`);let l=si(this.configSnapshot.fastkPaneId);this.pluginHost.setSharedState(l,n.fastk,`indicator_scheduler`);let u=ui(this.configSnapshot.macdPaneId);this.pluginHost.setSharedState(u,n.macd,`indicator_scheduler`);let d=fi(this.configSnapshot.atrPaneId);this.pluginHost.setSharedState(d,n.atr,`indicator_scheduler`);let f=mi(this.configSnapshot.wmaPaneId);this.pluginHost.setSharedState(f,n.wma,`indicator_scheduler`);let p=gi(this.configSnapshot.demaPaneId);this.pluginHost.setSharedState(p,n.dema,`indicator_scheduler`);let m=vi(this.configSnapshot.temaPaneId);this.pluginHost.setSharedState(m,n.tema,`indicator_scheduler`);let h=bi(this.configSnapshot.hmaPaneId);this.pluginHost.setSharedState(h,n.hma,`indicator_scheduler`);let g=Si(this.configSnapshot.kamaPaneId);this.pluginHost.setSharedState(g,n.kama,`indicator_scheduler`);let _=wi(this.configSnapshot.sarPaneId);this.pluginHost.setSharedState(_,n.sar,`indicator_scheduler`);let v=Oi(this.configSnapshot.supertrendPaneId);this.pluginHost.setSharedState(v,n.supertrend,`indicator_scheduler`);let y=Ai(this.configSnapshot.keltnerPaneId);this.pluginHost.setSharedState(y,n.keltner,`indicator_scheduler`);let b=Mi(this.configSnapshot.donchianPaneId);this.pluginHost.setSharedState(b,n.donchian,`indicator_scheduler`)}buildActiveSubIndicatorMask(){let e=this.getActiveSubPaneIds?.()??[];return{rsi:e.includes(this.configSnapshot.rsiPaneId),cci:e.includes(this.configSnapshot.cciPaneId),stoch:e.includes(this.configSnapshot.stochPaneId),mom:e.includes(this.configSnapshot.momPaneId),wmsr:e.includes(this.configSnapshot.wmsrPaneId),kst:e.includes(this.configSnapshot.kstPaneId),fastk:e.includes(this.configSnapshot.fastkPaneId),macd:e.includes(this.configSnapshot.macdPaneId),atr:e.includes(this.configSnapshot.atrPaneId),wma:e.includes(this.configSnapshot.wmaPaneId),dema:e.includes(this.configSnapshot.demaPaneId),tema:e.includes(this.configSnapshot.temaPaneId),hma:e.includes(this.configSnapshot.hmaPaneId),kama:e.includes(this.configSnapshot.kamaPaneId),sar:e.includes(this.configSnapshot.sarPaneId),supertrend:e.includes(this.configSnapshot.supertrendPaneId),keltner:e.includes(this.configSnapshot.keltnerPaneId),donchian:e.includes(this.configSnapshot.donchianPaneId)}}buildActiveConfig(){let e=this.getActiveSubPaneIds?.()??[];if(e.length===0)return{...this.configSnapshot};let t={...this.configSnapshot};for(let n of[`rsi`,`cci`,`stoch`,`mom`,`wmsr`,`kst`,`fastk`,`macd`,`atr`,`wma`,`dema`,`tema`,`hma`,`kama`,`sar`,`supertrend`,`keltner`,`donchian`]){let r=t[`${n}PaneId`];if(!e.includes(r)){let e={...t[n]};for(let t of Object.keys(e))t.startsWith(`show`)&&(e[t]=!1);t[n]=e}}return t}update(e,t){this.currentData=e,this.visibleRange=t,this.dataVersion++,this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}updateVisibleRange(e){this.visibleRange=e,this.latestResult&&this.updateVisibleStatesOnly()}updateMAConfig(e){this.configSnapshot.ma={...e},this.configVersion++,this.triggerRecompute()}updateBOLLConfig(e){this.configSnapshot.boll={...this.configSnapshot.boll,...e},this.configVersion++,this.triggerRecompute()}updateEXPMAConfig(e){this.configSnapshot.expma={...this.configSnapshot.expma,...e},this.configVersion++,this.triggerRecompute()}updateENEConfig(e){this.configSnapshot.ene={...this.configSnapshot.ene,...e},this.configVersion++,this.triggerRecompute()}updateRSIConfig(e,t){t!==void 0&&(this.configSnapshot.rsiPaneId=t),this.configSnapshot.rsi={...this.configSnapshot.rsi,...e},this.configVersion++,this.triggerRecompute()}updateCCIConfig(e,t){t!==void 0&&(this.configSnapshot.cciPaneId=t),this.configSnapshot.cci={...this.configSnapshot.cci,...e},this.configVersion++,this.triggerRecompute()}updateSTOCHConfig(e,t){t!==void 0&&(this.configSnapshot.stochPaneId=t),this.configSnapshot.stoch={...this.configSnapshot.stoch,...e},this.configVersion++,this.triggerRecompute()}updateMOMConfig(e,t){t!==void 0&&(this.configSnapshot.momPaneId=t),this.configSnapshot.mom={...this.configSnapshot.mom,...e},this.configVersion++,this.triggerRecompute()}updateWMSRConfig(e,t){t!==void 0&&(this.configSnapshot.wmsrPaneId=t),this.configSnapshot.wmsr={...this.configSnapshot.wmsr,...e},this.configVersion++,this.triggerRecompute()}updateKSTConfig(e,t){t!==void 0&&(this.configSnapshot.kstPaneId=t),this.configSnapshot.kst={...this.configSnapshot.kst,...e},this.configVersion++,this.triggerRecompute()}updateFASTKConfig(e,t){t!==void 0&&(this.configSnapshot.fastkPaneId=t),this.configSnapshot.fastk={...this.configSnapshot.fastk,...e},this.configVersion++,this.triggerRecompute()}updateMACDConfig(e,t){t!==void 0&&(this.configSnapshot.macdPaneId=t),this.configSnapshot.macd={...this.configSnapshot.macd,...e},this.configVersion++,this.triggerRecompute()}updateATRConfig(e,t){t!==void 0&&(this.configSnapshot.atrPaneId=t),this.configSnapshot.atr={...this.configSnapshot.atr,...e},this.configVersion++,this.triggerRecompute()}updateWMAConfig(e,t){t!==void 0&&(this.configSnapshot.wmaPaneId=t),this.configSnapshot.wma={...this.configSnapshot.wma,...e},this.configVersion++,this.triggerRecompute()}updateDEMAConfig(e,t){t!==void 0&&(this.configSnapshot.demaPaneId=t),this.configSnapshot.dema={...this.configSnapshot.dema,...e},this.configVersion++,this.triggerRecompute()}updateTEMAConfig(e,t){t!==void 0&&(this.configSnapshot.temaPaneId=t),this.configSnapshot.tema={...this.configSnapshot.tema,...e},this.configVersion++,this.triggerRecompute()}updateHMAConfig(e,t){t!==void 0&&(this.configSnapshot.hmaPaneId=t),this.configSnapshot.hma={...this.configSnapshot.hma,...e},this.configVersion++,this.triggerRecompute()}updateKAMAConfig(e,t){t!==void 0&&(this.configSnapshot.kamaPaneId=t),this.configSnapshot.kama={...this.configSnapshot.kama,...e},this.configVersion++,this.triggerRecompute()}updateSARConfig(e,t){t!==void 0&&(this.configSnapshot.sarPaneId=t),this.configSnapshot.sar={...this.configSnapshot.sar,...e},this.configVersion++,this.triggerRecompute()}updateSuperTrendConfig(e,t){t!==void 0&&(this.configSnapshot.supertrendPaneId=t),this.configSnapshot.supertrend={...this.configSnapshot.supertrend,...e},this.configVersion++,this.triggerRecompute()}updateKeltnerConfig(e,t){t!==void 0&&(this.configSnapshot.keltnerPaneId=t),this.configSnapshot.keltner={...this.configSnapshot.keltner,...e},this.configVersion++,this.triggerRecompute()}updateDonchianConfig(e,t){t!==void 0&&(this.configSnapshot.donchianPaneId=t),this.configSnapshot.donchian={...this.configSnapshot.donchian,...e},this.configVersion++,this.triggerRecompute()}setActiveMainIndicators(e){this.activeMainIndicators=new Set(e.map(e=>e.toLowerCase()))}getMainIndicatorPriceRange(){return this.latestResult?$i(this.latestResult,this.visibleRange,this.activeMainIndicators):null}recompute(){this.inlineRuntime&&this.inlineRuntime.forceDirty(),this.dataVersion++,this.triggerRecompute()}triggerRecompute(){this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}computeWithWorker(){!this.worker||!this.workerReady||(console.log(`[IndicatorScheduler] >> Worker compute: requestId=${this.requestId+1} dataV=${this.dataVersion} configV=${this.configVersion}`),this.requestId++,this.pendingRequest={requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion},this.worker.postMessage({type:`setData`,dataVersion:this.dataVersion,format:`aos`,data:this.currentData}),this.worker.postMessage({type:`setConfig`,configVersion:this.configVersion,configs:this.buildActiveConfig()}),this.worker.postMessage({type:`computeSeries`,requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion}))}computeWithInline(){this.inlineRuntime||=new qr,console.log(`[IndicatorScheduler] >> INLINE compute: dataV=${this.dataVersion} configV=${this.configVersion}`),this.inlineRuntime.setData(this.currentData,this.dataVersion),this.inlineRuntime.setConfig(this.buildActiveConfig(),this.configVersion);let e=this.inlineRuntime.computeSeries();this.latestResult=e,this.applyResults(e),this.invalidateCallback?.()}};function aa(e={}){let{paneId:t=`sub`}=e,n=Z(`volume`,t),r=null;return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c}=e,l=o;if(!l.length)return;let{start:u,end:d}=s,f=0,p=1/0;for(let e=u;e<d&&e<l.length;e++){let t=l[e];if(!t)continue;let n=t.volume;n!=null&&(f=Math.max(f,n),p=Math.min(p,n))}if(f===0||!Number.isFinite(p))return;let m=Math.max(.05,(f-p)*.1),h=Math.max(0,p-m),g=f+m,_=a.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),v=_.minPrice,y=_.maxPrice-v||1,b=a.height-(0-v)/y*a.height,x=Math.round(b*c)/c;r?.setSharedState(n,{valueMin:h,valueMax:g,timestamp:Date.now()},`volume_${t}`);let S=Math.max(1,d-u),C=new Float32Array(S*4),w=new Float32Array(S*4),T=new Float32Array(S*4),E=0,D=0,O=0;for(let t=u;t<d;t++){let n=l[t];if(!n)continue;let r=n.volume;if(!r)continue;let i=e.kBarRects[t-u];if(!i)continue;let o=a.height-(r-v)/y*a.height,s=Math.round(o*c)/c,d=1/c,f=x-s,p=f<=0?d:Math.max(f,d),m=f<=0?x-d:x-p,h=la(n),g,_;h===Pe.UP?(g=C,_=E++):h===Pe.DOWN?(g=w,_=D++):(g=T,_=O++);let b=_*4;g[b]=i.x,g[b+1]=m,g[b+2]=i.width,g[b+3]=p}oa(e,C,E,w,D,T,O)?ca(i,e):sa(i,e.scrollLeft,C,E,w,D,T,O)}}}function oa(e,t,n,r,i,a,o){if(e.settings?.enableWebGLRendering===!1)return!1;let s=e.candleWebGLSurface;if(!s||!s.isAvailable())return!1;s.clear();let c=n===0||s.drawRectBuffer(t.subarray(0,n*4),n,Pe.UP,e.scrollLeft),l=i===0||s.drawRectBuffer(r.subarray(0,i*4),i,Pe.DOWN,e.scrollLeft),u=o===0||s.drawRectBuffer(a.subarray(0,o*4),o,Pe.NEUTRAL,e.scrollLeft);return c&&l&&u}function sa(e,t,n,r,i,a,o,s){e.save(),e.translate(-t,0),e.fillStyle=Pe.UP;for(let t=0;t<r;t++){let r=t*4;e.fillRect(n[r],n[r+1],n[r+2],n[r+3])}e.fillStyle=Pe.DOWN;for(let t=0;t<a;t++){let n=t*4;e.fillRect(i[n],i[n+1],i[n+2],i[n+3])}e.fillStyle=Pe.NEUTRAL;for(let t=0;t<s;t++){let n=t*4;e.fillRect(o[n],o[n+1],o[n+2],o[n+3])}e.restore()}function ca(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function la(e){return e.close>e.open?Pe.UP:e.close<e.open?Pe.DOWN:Pe.NEUTRAL}var ua={5:Ne.MA5,10:Ne.MA10,20:Ne.MA20,30:Ne.MA30,60:Ne.MA60};function da(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.join(`,`),n.height.toFixed(2)].join(`|`)}function fa(){let e=null,t=``,n=new Map;function r(){t=``,n=new Map}return{name:`ma`,version:`2.1.0`,description:`MA均线渲染器`,debugName:`MA均线`,paneId:`main`,priority:R.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[ea]},draw(i){let{ctx:a,pane:o,range:s,scrollLeft:c,dpr:l,kLineCenters:u,lineWebGLSurface:d}=i,f=e?.getSharedState(ea);if(!f||f.visibleMin>f.visibleMax){r();return}if(f.enabledPeriods.length===0){r();return}let p=da(s,u,o,f.enabledPeriods);if(t!==p){t=p,n=new Map;for(let[e,t]of Object.entries(f.series)){let r=Number(e),i=[];for(let e=s.start;e<s.end&&e<t.length;e++){let n=t[e];if(n===void 0)continue;let r=u[e-s.start];r!==void 0&&i.push({x:r,y:o.yAxis.priceToY(n)})}i.length>=2&&n.set(r,i)}}let m=i.settings?.enableWebGLRendering!==!1,h=!1;if(m&&d?.isAvailable()){let e=[];for(let t of f.enabledPeriods){let r=n.get(t);r&&e.push({points:r,width:1,color:ua[t]??Ne.MA5})}e.length>0&&d.drawLineStrips(e,c)&&(h=!0,d.compositeTo(a,{imageSmoothingEnabled:!1}))}if(!h){a.save(),a.translate(-c,0),a.lineWidth=1,a.lineJoin=`round`,a.lineCap=`round`;for(let e of f.enabledPeriods){let t=n.get(e);if(!(!t||t.length<2)){a.strokeStyle=ua[e]??Ne.MA5,a.beginPath(),a.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let n=t[e];a.lineTo(n.x,n.y)}a.stroke()}}a.restore()}},getConfig(){let t=e?.getSharedState(ea),n={};return t?.enabledPeriods.forEach(e=>{n[`ma${e}`]=!0}),n},setConfig(e){}}}var pa=1;function ma(e){let t=e.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([\d.]+)\)$/i);if(!t)return 1;let n=Number(t[1]);return Number.isFinite(n)?n:1}function ha(e){return e.replace(/,\s*[\d.]+\s*\)$/i,`, 1)`)}function ga(e,t,n=1){t.compositeTo(e.ctx,{alpha:n,imageSmoothingEnabled:!1})}function _a(e,t){if(e.settings?.enableWebGLRendering===!1)return!1;let n=e.lineWebGLSurface;if(!n||!n.isAvailable())return!1;n.clear();let r=!0;t.showBand&&t.bandUpperPoints.length>=2&&t.bandLowerPoints.length>=2&&(n.clear(),r=n.drawFilledBand({upperPoints:t.bandUpperPoints,lowerPoints:t.bandLowerPoints},ha(G.BAND_FILL),e.scrollLeft),r&&ga(e,n,ma(G.BAND_FILL))),n.clear();let i=[];return t.showUpper&&t.upperPoints.length>=2&&i.push({points:t.upperPoints,width:pa,color:G.UPPER}),t.showMiddle&&t.middlePoints.length>=2&&i.push({points:t.middlePoints,width:pa,color:G.MIDDLE}),t.showLower&&t.lowerPoints.length>=2&&i.push({points:t.lowerPoints,width:pa,color:G.LOWER}),i.length>0&&(r=n.drawLineStrips(i,e.scrollLeft)),r?(ga(e,n),n.clear(),!0):(n.clear(),!1)}function va(){let e=null,t=[],n=[],r=[],i=[],a=[],o=0;function s(e){if(!(e<=o)){for(let s=o;s<e;s++)t[s]={x:0,y:0},n[s]={x:0,y:0},r[s]={x:0,y:0},i[s]={x:0,y:0},a[s]={x:0,y:0};o=e}}return{name:`boll`,version:`2.2.0`,description:`布林带渲染器(无缓存优化)`,debugName:`BOLL布林带`,paneId:`main`,priority:R.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[ta]},draw(o){let{ctx:c,pane:l,data:u,range:d,scrollLeft:f,dpr:p,kLineCenters:m}=o,h=u,g=e?.getSharedState(ta);if(!g||g.visibleMin>g.visibleMax||g.series.length===0)return;let{period:_,showUpper:v,showMiddle:y,showLower:b,showBand:x}=g.params,S=g.series;if(h.length<_)return;let C=Math.max(d.start,_-1),w=Math.min(d.end,h.length);if(w<=C)return;let T=d.start,E=l.yAxis.priceToY.bind(l.yAxis),D=w-C;s(D);let O=Array(D),k=Array(D),A=Array(D),j=x?Array(D):[],M=x?Array(D):[],N=0,P=0,F=0,I=0;for(let e=C;e<w;e++){let o=S[e];if(!o)continue;let s=m[e-T];if(s===void 0)continue;let c=X(E(o.upper),p),l=X(E(o.middle),p),u=X(E(o.lower),p),d=t[N];d.x=s,d.y=c,O[N++]=d,d=n[P],d.x=s,d.y=l,k[P++]=d,d=r[F],d.x=s,d.y=u,A[F++]=d,x&&(d=i[I],d.x=s,d.y=c,j[I]=d,d=a[I],d.x=s,d.y=u,M[I]=d,I++)}if(O.length=N,k.length=P,A.length=F,x&&(j.length=I,M.length=I),_a(o,{showUpper:v,showMiddle:y,showLower:b,showBand:x,upperPoints:O,middlePoints:k,lowerPoints:A,bandUpperPoints:j,bandLowerPoints:M}))return;if(c.save(),c.translate(-f,0),c.lineWidth=pa,c.lineJoin=`round`,c.lineCap=`round`,x&&j.length>=2){let e=new Path2D;e.moveTo(j[0].x,j[0].y);for(let t=1;t<j.length;t++)e.lineTo(j[t].x,j[t].y);for(let t=M.length-1;t>=0;t--)e.lineTo(M[t].x,M[t].y);e.closePath(),c.fillStyle=G.BAND_FILL,c.fill(e)}let L=(e,t)=>{if(!(e.length<2)){c.beginPath(),c.strokeStyle=t,c.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)c.lineTo(e[t].x,e[t].y);c.stroke()}};v&&L(O,G.UPPER),y&&L(k,G.MIDDLE),b&&L(A,G.LOWER),c.restore()},getConfig(){let t=e?.getSharedState(ta);return t?{...t.params}:{}},setConfig(e){}}}function ya(e,t,n){let r=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,r.maxPrice.toFixed(6),r.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2)].join(`|`)}function ba(){let e=null,t=``,n=[],r=[];function i(){t=``,n=[],r=[]}return{name:`expma`,version:`2.1.0`,description:`EXPMA 指数平滑移动平均线渲染器(带绘制缓存)`,debugName:`EXPMA`,paneId:`main`,priority:R.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[na]},draw(a){let{ctx:o,pane:s,data:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=a,m=c,h=e?.getSharedState(na);if(!h||h.visibleMin>h.visibleMax){i();return}if(h.series.length===0||m.length<2){i();return}let g=h.series,_=l.start,v=Math.min(l.end,m.length),y=ya(l,f,s);if(t!==y){t=y,n=[],r=[];for(let e=_;e<v;e++){let t=g[e];if(!t)continue;let i=f[e-l.start];i!==void 0&&(n.push({x:i,y:s.yAxis.priceToY(t.fast)}),r.push({x:i,y:s.yAxis.priceToY(t.slow)}))}}let b=a.settings?.enableWebGLRendering!==!1,x=!1;if(b&&p?.isAvailable()){let e=[];n.length>=2&&e.push({points:n,width:1,color:Be.FAST}),r.length>=2&&e.push({points:r,width:1,color:Be.SLOW}),e.length>0&&p.drawLineStrips(e,u)&&(x=!0,p.compositeTo(o,{imageSmoothingEnabled:!1}))}if(!x){if(o.save(),o.translate(-u,0),o.lineWidth=1,o.lineJoin=`round`,o.lineCap=`round`,n.length>=2){o.strokeStyle=Be.FAST,o.beginPath(),o.moveTo(n[0].x,n[0].y);for(let e=1;e<n.length;e++){let t=n[e];o.lineTo(t.x,t.y)}o.stroke()}if(r.length>=2){o.strokeStyle=Be.SLOW,o.beginPath(),o.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++){let t=r[e];o.lineTo(t.x,t.y)}o.stroke()}o.restore()}},getConfig(){let t=e?.getSharedState(na);return t?{...t.params}:{}},setConfig(e){}}}function xa(e){let t=e.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([\d.]+)\)$/i);if(!t)return 1;let n=Number(t[1]);return Number.isFinite(n)?n:1}function Sa(e){return e.replace(/,\s*[\d.]+\s*\)$/i,`, 1)`)}function Ca(e,t,n=1){t.compositeTo(e.ctx,{alpha:n,imageSmoothingEnabled:!1})}function wa(e,t){if(e.settings?.enableWebGLRendering===!1)return!1;let n=e.lineWebGLSurface;if(!n||!n.isAvailable())return!1;n.clear();let r=!0;t.upperPoints.length>=2&&t.lowerPoints.length>=2&&(n.clear(),r=n.drawFilledBand({upperPoints:t.upperPoints,lowerPoints:t.lowerPoints},Sa(J.BAND_FILL),e.scrollLeft),r&&Ca(e,n,xa(J.BAND_FILL))),n.clear();let i=[];return t.upperPoints.length>=2&&i.push({points:t.upperPoints,width:1,color:J.UPPER}),t.middlePoints.length>=2&&i.push({points:t.middlePoints,width:1,color:J.MIDDLE}),t.lowerPoints.length>=2&&i.push({points:t.lowerPoints,width:1,color:J.LOWER}),i.length>0&&(r=n.drawLineStrips(i,e.scrollLeft)),r?(Ca(e,n),n.clear(),!0):(n.clear(),!1)}function Ta(){let e=null;return{name:`ene`,version:`2.1.0`,description:`ENE 轨道线渲染器(无状态)`,debugName:`ENE轨道线`,paneId:`main`,priority:R.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){return[ra]},draw(t){let{ctx:n,pane:r,data:i,range:a,scrollLeft:o,dpr:s,kLineCenters:c}=t,l=i,u=e?.getSharedState(ra);if(!u||u.visibleMin>u.visibleMax||u.series.length===0)return;let{period:d}=u.params,f=u.series;if(l.length<d)return;let p=Math.max(a.start,d-1),m=Math.min(a.end,l.length),h=[],g=[],_=[];for(let e=p;e<m;e++){let t=f[e];if(!t)continue;let n=c[e-a.start];n!==void 0&&(h.push({x:n,y:X(r.yAxis.priceToY(t.upper),s)}),g.push({x:n,y:X(r.yAxis.priceToY(t.middle),s)}),_.push({x:n,y:X(r.yAxis.priceToY(t.lower),s)}))}if(wa(t,{upperPoints:h,middlePoints:g,lowerPoints:_}))return;if(n.save(),n.translate(-o,0),n.fillStyle=J.BAND_FILL,n.beginPath(),h.length>0){n.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++){let t=h[e];n.lineTo(t.x,t.y)}for(let e=_.length-1;e>=0;e--){let t=_[e];n.lineTo(t.x,t.y)}}n.closePath(),n.fill(),n.lineWidth=1,n.lineJoin=`round`,n.lineCap=`round`;let v=(e,t)=>{if(e.length!==0){n.strokeStyle=t,n.beginPath(),n.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++){let r=e[t];n.lineTo(r.x,r.y)}n.stroke()}};v(h,J.UPPER),v(g,J.MIDDLE),v(_,J.LOWER),n.restore()},getConfig(){let t=e?.getSharedState(ra);return t?{...t.params}:{}},setConfig(e){}}}var Ea=`"Trebuchet MS", Roboto, Ubuntu, sans-serif`;function Da(e,t){return`${t?.bold?`bold `:``}${e}px ${Ea}`}function Oa(e,t){e.font!==t&&(e.font=t)}var ka=new Map,Aa=512;function ja(e,t){let n=`${e.font}\n${t}`,r=ka.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return ka.size>=Aa&&ka.clear(),ka.set(n,i),i}function Ma(e){let t={yPaddingPx:e.yPaddingPx,indicators:{MA:{enabled:!0,params:{}},BOLL:{enabled:!1,params:{period:20,multiplier:2}},EXPMA:{enabled:!1,params:{fastPeriod:12,slowPeriod:50}},ENE:{enabled:!1,params:{period:10,deviation:11}}}},n=null;return{name:`mainIndicatorLegend`,version:`2.1.0`,description:`主图指标图例渲染器(MA 数据来自 StateStore)`,debugName:`主图指标图例`,paneId:`main`,priority:R.FOREGROUND,enabled:!0,onInstall(e){n=e},getDeclaredNamespaces(){return[ea,ta,na,ra]},draw(e){let{ctx:r,data:i,range:a,crosshairIndex:o}=e,s=i;if(!s.length)return;r.save(),Oa(r,Da(12)),r.textAlign=`left`;let c=o??Math.min(a.end-1,s.length-1),l=[];t.indicators.MA?.enabled&&l.push({draw:e=>{let i=[],a=n?.getSharedState(ea);if(a&&a.visibleMin<=a.visibleMax)for(let e of a.enabledPeriods){let t=`MA${e}`,n=a.series[e]?.[c];i.push({label:`MA${e}`,color:Ne[t]||Ne.MA5,value:n})}if(i.length>0){let n=12,a=t.yPaddingPx/2+12+e*18;r.fillStyle=U.NEUTRAL,r.fillText(`MA`,n,a),n+=ja(r,`MA`)+10;for(let e of i){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,i=`${e.label}${t}`;r.fillStyle=e.color,r.fillText(i,n,a),n+=ja(r,i)+10}}}}),t.indicators.BOLL?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(ta),a=i?.series[c],o=i?.params.period??20,s=i?.params.multiplier??2,l=12,u=t.yPaddingPx/2+12+e*18,d=`BOLL(${o},${s})`;if(r.fillStyle=U.NEUTRAL,r.fillText(d,l,u),l+=ja(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=G.UPPER,r.fillText(e,l,u),l+=ja(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=G.MIDDLE,r.fillText(t,l,u),l+=ja(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=G.LOWER,r.fillText(n,l,u)}}}),t.indicators.EXPMA?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(na),a=i?.series[c],o=i?.params.fastPeriod??12,s=i?.params.slowPeriod??50,l=12,u=t.yPaddingPx/2+12+e*18,d=`EXPMA(${o},${s})`;if(r.fillStyle=U.NEUTRAL,r.fillText(d,l,u),l+=ja(r,d)+10,a){let e=`快:${a.fast.toFixed(2)}`;r.fillStyle=Be.FAST,r.fillText(e,l,u),l+=ja(r,e)+10;let t=`慢:${a.slow.toFixed(2)}`;r.fillStyle=Be.SLOW,r.fillText(t,l,u)}}}),t.indicators.ENE?.enabled&&l.push({draw:e=>{let i=n?.getSharedState(ra),a=i?.series[c],o=i?.params.period??10,s=i?.params.deviation??11,l=12,u=t.yPaddingPx/2+12+e*18,d=`ENE(${o},${s})`;if(r.fillStyle=U.NEUTRAL,r.fillText(d,l,u),l+=ja(r,d)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=J.UPPER,r.fillText(e,l,u),l+=ja(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=J.MIDDLE,r.fillText(t,l,u),l+=ja(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=J.LOWER,r.fillText(n,l,u)}}}),l.forEach((e,t)=>e.draw(t)),r.restore()},getConfig(){return{yPaddingPx:t.yPaddingPx,indicators:{...t.indicators}}},setConfig(e){if(typeof e.yPaddingPx==`number`&&(t.yPaddingPx=e.yPaddingPx),e.indicators&&typeof e.indicators==`object`)for(let[n,r]of Object.entries(e.indicators))t.indicators[n]||(t.indicators[n]={enabled:!1,params:{}}),r.enabled!==void 0&&(t.indicators[n].enabled=r.enabled),r.params&&(t.indicators[n].params=r.params)}}}function Na(e={}){let{paneId:t=`sub`,config:n={}}=e,r=ui(t),i=null,a={fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0,...n},o=``,s=[],c=[];function l(){o=``,s=[],c=[]}function u(e,t,n,r,i){return n.yAxis.getDisplayRange(),[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.toFixed(6),r.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),a.showDIF,a.showDEA].join(`|`)}return{name:`macd_${t}`,version:`1.0.0`,description:`MACD 指标渲染器`,debugName:`MACD`,paneId:t,priority:R.INDICATOR,onInstall(e){i=e},getDeclaredNamespaces(){return[r]},draw(e){let{ctx:t,pane:n,data:l,range:d,scrollLeft:f,dpr:p,kLineCenters:m,lineWebGLSurface:h}=e,g=l,_=i?.getSharedState(r);if(!_||_.visibleMin>_.visibleMax||g.length<a.slowPeriod)return;let v=_.series;if(!v||v.length===0)return;let y=_.visibleMin,b=_.visibleMax,x=Math.max(.05,(b-y)*.1);y-=x,b+=x,b-y;let S=n.yAxis.getDisplayRange({minPrice:y,maxPrice:b}),C=S.minPrice,w=S.maxPrice,T=w-C||1,E=n.height-(0-C)/T*n.height,D=Math.max(d.start,a.slowPeriod-1),O=Math.min(d.end,g.length);if(a.showBAR){let r=Math.round(E*p)/p,i=Math.max(1,O-D),a=new Float32Array(i*4),o=new Float32Array(i*4),s=new Float32Array(i*4),c=new Float32Array(i*4),l=0,u=0,m=0,h=0;for(let t=D;t<O;t++){let i=v[t];if(!i)continue;let f=e.kBarRects[t-d.start];if(!f)continue;let g=n.height-(i.macd-C)/T*n.height,_=i.macd>=0,y=t>0?v[t-1]:null,b=y?i.macd>=y.macd:!0,x=Math.round(g*p)/p,S=1/p,w,E;if(_){let e=r-x,t=e<=0?S:Math.max(e,S),n=e<=0?r-S:r-t;b?(w=a,E=l++):(w=o,E=u++);let i=E*4;w[i]=f.x,w[i+1]=n,w[i+2]=f.width,w[i+3]=t}else{let e=x-r,t=e<=0?S:Math.max(e,S);b?(w=c,E=h++):(w=s,E=m++);let n=E*4;w[n]=f.x,w[n+1]=r,w[n+2]=f.width,w[n+3]=t}}Pa(e,a,l,o,u,s,m,c,h)?La(t,e):Fa(t,f,a,l,o,u,s,m,c,h)}let k=u(d,m,n,C,w);if(o!==k){if(o=k,s=[],c=[],a.showDIF)for(let e=D;e<O;e++){let t=v[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dif-C)/T*n.height;s.push({x:r,y:i})}if(a.showDEA)for(let e=D;e<O;e++){let t=v[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dea-C)/T*n.height;c.push({x:r,y:i})}}let A=e.settings?.enableWebGLRendering!==!1,j=!1;if(A&&h?.isAvailable()){let e=[];a.showDIF&&s.length>=2&&e.push({points:s,width:1,color:K.DIF}),a.showDEA&&c.length>=2&&e.push({points:c,width:1,color:K.DEA}),e.length>0&&h.drawLineStrips(e,f)&&(j=!0,h.compositeTo(t,{imageSmoothingEnabled:!1}))}j||Ia(t,f,s,c,a)},onDataUpdate(){l()},getConfig(){return{...a}},setConfig(e){let t=!1;`fastPeriod`in e&&e.fastPeriod!==a.fastPeriod&&l(),`slowPeriod`in e&&e.slowPeriod!==a.slowPeriod&&l(),`signalPeriod`in e&&e.signalPeriod!==a.signalPeriod&&l(),`showDIF`in e&&e.showDIF!==a.showDIF&&(t=!0),`showDEA`in e&&e.showDEA!==a.showDEA&&(t=!0),Object.assign(a,e),t&&l()}}}function Pa(e,t,n,r,i,a,o,s,c){if(e.settings?.enableWebGLRendering===!1)return!1;let l=e.candleWebGLSurface;if(!l||!l.isAvailable())return!1;l.clear();let u=n===0||l.drawRectBuffer(t.subarray(0,n*4),n,K.BAR_UP,e.scrollLeft),d=i===0||l.drawRectBuffer(r.subarray(0,i*4),i,K.BAR_UP_LIGHT,e.scrollLeft),f=o===0||l.drawRectBuffer(a.subarray(0,o*4),o,K.BAR_DOWN,e.scrollLeft),p=c===0||l.drawRectBuffer(s.subarray(0,c*4),c,K.BAR_DOWN_LIGHT,e.scrollLeft);return u&&d&&f&&p}function Fa(e,t,n,r,i,a,o,s,c,l){e.save(),e.translate(-t,0),e.fillStyle=K.BAR_UP;for(let t=0;t<r;t++){let r=t*4;e.fillRect(n[r],n[r+1],n[r+2],n[r+3])}e.fillStyle=K.BAR_UP_LIGHT;for(let t=0;t<a;t++){let n=t*4;e.fillRect(i[n],i[n+1],i[n+2],i[n+3])}e.fillStyle=K.BAR_DOWN;for(let t=0;t<s;t++){let n=t*4;e.fillRect(o[n],o[n+1],o[n+2],o[n+3])}e.fillStyle=K.BAR_DOWN_LIGHT;for(let t=0;t<l;t++){let n=t*4;e.fillRect(c[n],c[n+1],c[n+2],c[n+3])}e.restore()}function Ia(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showDIF&&n.length>=2){e.strokeStyle=K.DIF,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showDEA&&r.length>=2){e.strokeStyle=K.DEA,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function La(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function Ra(e,t,n,r,i,a=`sub_MACD`){let o=i.getSharedState(ui(a));if(!o)return null;let s=o.series[e];return s?{name:`MACD`,params:[t,n,r],values:[{label:`DIF`,value:s.dif,color:K.DIF},{label:`DEA`,value:s.dea,color:K.DEA},{label:`MACD`,value:s.macd,color:s.macd>=0?K.BAR_UP:K.BAR_DOWN}]}:null}function za(e={}){let{paneId:t=`sub`}=e,n=null,r=``,i=[],a=[],o=[],s=null,c=null,l=``;function u(){r=``,i=[],a=[],o=[]}function d(e,t){return(!s||s.width!==e||s.height!==t)&&(s=document.createElement(`canvas`),s.width=e,s.height=t,c=s.getContext(`2d`),l=``),{canvas:s,ctx:c}}function f(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function p(e,t,n,r,i,a){let o=i-r||1,s=X(n-(80-r)/o*n,a),c=X(n-(50-r)/o*n,a),l=X(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1.1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.moveTo(0,l),e.lineTo(t,l),e.stroke(),e.restore()}function m(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showRSI1,r.showRSI2,r.showRSI3].join(`|`)}return{name:`rsi_${t}`,version:`2.1.0`,description:`RSI 相对强弱指标渲染器(WebGL + Canvas2D 回退)`,debugName:`RSI`,paneId:t,priority:R.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){return[Yr(t)]},draw(e){let{ctx:c,pane:h,range:g,scrollLeft:_,dpr:v,kLineCenters:y,lineWebGLSurface:b}=e,x=Yr(t),S=n?.getSharedState(x);if(!S||S.visibleMin>S.visibleMax){u();return}let{valueMin:C,valueMax:w,params:T,series:E}=S,D=h.yAxis.getDisplayRange({minPrice:C,maxPrice:w}),O=D.minPrice,k=D.maxPrice,A=k-O||1,j=e.paneWidth,M=h.height,N=f(j,M,O,k,v);if(l!==N){l=N;let{ctx:e}=d(Math.ceil(j*v),Math.ceil(M*v));p(e,j,M,O,k,v)}s&&c.drawImage(s,0,0,j,M);let P=Math.max(g.start,T.period1),F=Math.min(g.end,y.length+g.start),I=m(g,y,h,T);if(r!==I){r=I;let e=M,t=e/A,n=g.start,s=r=>{let i=[];for(let a=P;a<F;a++){let o=r[a];if(o===void 0)continue;let s=y[a-n];s!==void 0&&i.push({x:s,y:e-(o-O)*t})}return i};i=T.showRSI1&&E[T.period1]?s(E[T.period1]):[],a=T.showRSI2&&E[T.period2]?s(E[T.period2]):[],o=T.showRSI3&&E[T.period3]?s(E[T.period3]):[]}let L=e.settings?.enableWebGLRendering!==!1,ee=!1;if(L&&b?.isAvailable()){let e=[];T.showRSI1&&i.length>=2&&e.push({points:i,width:1,color:q.RSI1}),T.showRSI2&&a.length>=2&&e.push({points:a,width:1,color:q.RSI2}),T.showRSI3&&o.length>=2&&e.push({points:o,width:1,color:q.RSI3}),e.length>0&&b.drawLineStrips(e,_)&&(ee=!0,b.compositeTo(c,{imageSmoothingEnabled:!1}))}ee||Ba(c,_,i,a,o,T)},getConfig(){let e=Yr(t),r=n?.getSharedState(e);return r?{...r.params}:{}},setConfig(e){}}}function Ba(e,t,n,r,i,a){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,a.showRSI1&&n.length>=2){e.strokeStyle=q.RSI1,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(a.showRSI2&&r.length>=2){e.strokeStyle=q.RSI2,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}if(a.showRSI3&&i.length>=2){e.strokeStyle=q.RSI3,e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let t=1;t<i.length;t++){let n=i[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function Va(e,t,n,r,i,a=`sub_RSI`){let o=Yr(a),s=i.getSharedState(o);if(!s)return null;let c=s.series[t]?.[e],l=s.series[n]?.[e],u=s.series[r]?.[e],d=[];return c!==void 0&&d.push({label:`RSI${t}`,value:c,color:q.RSI1}),l!==void 0&&d.push({label:`RSI${n}`,value:l,color:q.RSI2}),u!==void 0&&d.push({label:`RSI${r}`,value:u,color:q.RSI3}),d.length===0?null:{name:`RSI`,params:[t,n,r],values:d}}function Ha(e={}){let{paneId:t=`sub`}=e,n=Zr(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showCCI,r.period].join(`|`)}return{name:`cci_${t}`,version:`2.1.0`,description:`CCI 顺势指标渲染器(WebGL + Canvas2D 回退)`,debugName:`CCI`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=r?.getSharedState(n);if(!m||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1,S=c.height-(0-b)/x*c.height;t.save(),t.translate(-u,0);let C=c.height-(100-b)/x*c.height,w=c.height-(-100-b)/x*c.height,T=u,E=u+e.paneWidth;t.strokeStyle=Fe.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(T,C),t.lineTo(E,C),t.stroke(),t.strokeStyle=Fe.OVERSOLD,t.beginPath(),t.moveTo(T,w),t.lineTo(E,w),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(T,S),t.lineTo(E,S),t.stroke(),t.setLineDash([]),t.restore();let D=Math.max(l.start,_.period-1),O=Math.min(l.end,v.length),k=s(l,f,c,_);if(i!==k&&(i=k,a=[],_.showCCI))for(let e=D;e<O;e++){let t=v[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}let A=e.settings?.enableWebGLRendering!==!1,j=!1;A&&p?.isAvailable()&&_.showCCI&&a.length>=2&&p.drawLineStrips([{points:a,width:1,color:Fe.CCI}],u)&&(j=!0,p.compositeTo(t,{imageSmoothingEnabled:!1})),j||Ua(t,u,a,_)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Ua(e,t,n,r){if(!(!r.showCCI||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Fe.CCI,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function Wa(e,t,n,r=`sub_CCI`){let i=n.getSharedState(Zr(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`CCI`,params:[t],values:[{label:`CCI`,value:a,color:Fe.CCI}]}}function Ga(e={}){let{paneId:t=`sub`}=e,n=$r(t),r=null,i=``,a=[],o=[],s=null,c=null,l=``;function u(){i=``,a=[],o=[]}function d(e,t){return(!s||s.width!==e||s.height!==t)&&(s=document.createElement(`canvas`),s.width=e,s.height=t,c=s.getContext(`2d`),l=``),{canvas:s,ctx:c}}function f(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function p(e,t,n,r,i,a){let o=i-r||1,s=X(n-(80-r)/o*n,a),c=X(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.restore()}function m(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showK,r.showD,r.n,r.m].join(`|`)}return{name:`stoch_${t}`,version:`2.1.0`,description:`STOCH 随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`STOCH`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:h,scrollLeft:g,dpr:_,kLineCenters:v,lineWebGLSurface:y}=e,b=r?.getSharedState(n);if(!b||b.visibleMin>b.visibleMax){u();return}let{valueMin:x,valueMax:S,params:C,series:w}=b,T=c.yAxis.getDisplayRange({minPrice:x,maxPrice:S}),E=T.minPrice,D=T.maxPrice,O=D-E||1,k=e.paneWidth,A=c.height,j=f(k,A,E,D,_);if(l!==j){l=j;let{ctx:e}=d(Math.ceil(k*_),Math.ceil(A*_));p(e,k,A,E,D,_)}s&&t.drawImage(s,0,0,k,A);let M=Math.max(h.start,C.n+C.m-2),N=Math.min(h.end,w.length),P=m(h,v,c,C);if(i!==P){i=P;let e=A,t=e/O,n=h.start;if(C.showK){let r=[];for(let i=M;i<N;i++){let a=w[i];if(!a)continue;let o=v[i-n];o!==void 0&&r.push({x:o,y:e-(a.k-E)*t})}a=r}else a=[];if(C.showD){let r=[];for(let i=M;i<N;i++){let a=w[i];if(!a)continue;let o=v[i-n];o!==void 0&&r.push({x:o,y:e-(a.d-E)*t})}o=r}else o=[]}let F=e.settings?.enableWebGLRendering!==!1,I=!1;if(F&&y?.isAvailable()){let e=[];C.showK&&a.length>=2&&e.push({points:a,width:1,color:Ie.K}),C.showD&&o.length>=2&&e.push({points:o,width:1,color:Ie.D}),e.length>0&&y.drawLineStrips(e,g)&&(I=!0,y.compositeTo(t,{imageSmoothingEnabled:!1}))}I||Ka(t,g,a,o,C)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Ka(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showK&&n.length>=2){e.strokeStyle=Ie.K,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showD&&r.length>=2){e.strokeStyle=Ie.D,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function qa(e,t,n,r,i=`sub_STOCH`){let a=r.getSharedState($r(i));if(!a)return null;let o=a.series[e];if(!o||o.k===void 0)return null;let s=[];return a.params.showK&&s.push({label:`K`,value:o.k,color:Ie.K}),a.params.showD&&s.push({label:`D`,value:o.d,color:Ie.D}),s.length===0?null:{name:`STOCH`,params:[t,n],values:s}}function Ja(e={}){let{paneId:t=`sub`}=e,n=ti(t),r=null,i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a){let o=i-r||1,s=X(n-(0-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=Le.ZERO,e.lineWidth=1,e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.stroke(),e.restore()}function p(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showMOM,r.period].join(`|`)}return{name:`mom_${t}`,version:`2.1.0`,description:`MOM 动量指标渲染器(WebGL + Canvas2D 回退)`,debugName:`MOM`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=r?.getSharedState(n);if(!y||y.visibleMin>y.visibleMax){l();return}let{valueMin:b,valueMax:x,params:S,series:C}=y,w=s.yAxis.getDisplayRange({minPrice:b,maxPrice:x}),T=w.minPrice,E=w.maxPrice,D=E-T||1,O=e.paneWidth,k=s.height,A=d(O,k,T,E,g);if(c!==A){c=A;let{ctx:e}=u(Math.ceil(O*g),Math.ceil(k*g));f(e,O,k,T,E,g)}o&&t.drawImage(o,0,0,O,k);let j=Math.max(m.start,S.period),M=Math.min(m.end,C.length),N=p(m,_,s,S);if(i!==N){i=N;let e=k,t=e/D,n=m.start;if(S.showMOM){let r=[];for(let i=j;i<M;i++){let a=C[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-T)*t})}a=r}else a=[]}let P=e.settings?.enableWebGLRendering!==!1,F=!1;P&&v?.isAvailable()&&S.showMOM&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:Le.MOM}],h)&&(F=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),F||Ya(t,h,a,S)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Ya(e,t,n,r){if(!(!r.showMOM||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Le.MOM,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function Xa(e,t,n,r=`sub_MOM`){let i=n.getSharedState(ti(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`MOM`,params:[t],values:[{label:`MOM`,value:a,color:Le.MOM}]}}function Za(e={}){let{paneId:t=`sub`}=e,n=ri(t),r=null,i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a){let o=i-r||1,s=X(n-(-20-r)/o*n,a),c=X(n-(-80-r)/o*n,a),l=X(n-(-50-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.lineWidth=1,e.setLineDash([4,4]),e.strokeStyle=Re.OVERBOUGHT,e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.stroke(),e.strokeStyle=Re.OVERSOLD,e.beginPath(),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.beginPath(),e.moveTo(0,l),e.lineTo(t,l),e.stroke(),e.restore()}function p(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showWMSR,r.period].join(`|`)}return{name:`wmsr_${t}`,version:`2.1.0`,description:`WMSR 威廉指标渲染器(WebGL + Canvas2D 回退)`,debugName:`WMSR`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=r?.getSharedState(n);if(!y||y.visibleMin>y.visibleMax){l();return}let{valueMin:b,valueMax:x,params:S,series:C}=y,w=s.yAxis.getDisplayRange({minPrice:b,maxPrice:x}),T=w.minPrice,E=w.maxPrice,D=E-T||1,O=e.paneWidth,k=s.height,A=d(O,k,T,E,g);if(c!==A){c=A;let{ctx:e}=u(Math.ceil(O*g),Math.ceil(k*g));f(e,O,k,T,E,g)}o&&t.drawImage(o,0,0,O,k);let j=Math.max(m.start,S.period-1),M=Math.min(m.end,C.length),N=p(m,_,s,S);if(i!==N){i=N;let e=k,t=e/D,n=m.start;if(S.showWMSR){let r=[];for(let i=j;i<M;i++){let a=C[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-T)*t})}a=r}else a=[]}let P=e.settings?.enableWebGLRendering!==!1,F=!1;P&&v?.isAvailable()&&S.showWMSR&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:Re.WMSR}],h)&&(F=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),F||Qa(t,h,a,S)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function Qa(e,t,n,r){if(!(!r.showWMSR||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Re.WMSR,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function $a(e,t,n,r=`sub_WMSR`){let i=n.getSharedState(ri(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`WMSR`,params:[t],values:[{label:`WMSR`,value:a,color:Re.WMSR}]}}function eo(e={}){let{paneId:t=`sub`}=e,n=ai(t),r=null,i=``,a=[],o=[];function s(){i=``,a=[],o=[]}function c(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showKST,r.showSignal,r.roc1,r.roc2,r.roc3,r.roc4,r.signalPeriod].join(`|`)}return{name:`kst_${t}`,version:`2.1.0`,description:`KST 确知指标渲染器(WebGL + Canvas2D 回退)`,debugName:`KST`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:l,range:u,scrollLeft:d,dpr:f,kLineCenters:p,lineWebGLSurface:m}=e,h=r?.getSharedState(n);if(!h||h.visibleMin>h.visibleMax){s();return}let{valueMin:g,valueMax:_,params:v,series:y}=h;_-g;let b=l.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),x=b.minPrice,S=b.maxPrice-x||1,C=l.height-(0-x)/S*l.height;t.save(),t.translate(-d,0);let w=d,T=d+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.beginPath(),t.moveTo(w,C),t.lineTo(T,C),t.stroke(),t.restore();let E=Math.max(u.start,v.roc4+15+v.signalPeriod-1),D=Math.min(u.end,y.length),O=c(u,p,l,v);if(i!==O){if(i=O,a=[],o=[],v.showKST)for(let e=E;e<D;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.kst-x)/S*l.height;a.push({x:n,y:r})}if(v.showSignal)for(let e=E;e<D;e++){let t=y[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.signal-x)/S*l.height;o.push({x:n,y:r})}}let k=e.settings?.enableWebGLRendering!==!1,A=!1;if(k&&m?.isAvailable()){let e=[];v.showKST&&a.length>=2&&e.push({points:a,width:1,color:ze.KST}),v.showSignal&&o.length>=2&&e.push({points:o,width:1,color:ze.SIGNAL}),e.length>0&&m.drawLineStrips(e,d)&&(A=!0,m.compositeTo(t,{imageSmoothingEnabled:!1}))}A||to(t,d,a,o,v)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function to(e,t,n,r,i){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showKST&&n.length>=2){e.strokeStyle=ze.KST,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showSignal&&r.length>=2){e.strokeStyle=ze.SIGNAL,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function no(e,t,n,r,i,a,o,s=`sub_KST`){let c=o.getSharedState(ai(s));if(!c)return null;let l=c.series[e];if(!l)return null;let u=[];return c.params.showKST&&u.push({label:`KST`,value:l.kst,color:ze.KST}),c.params.showSignal&&u.push({label:`Signal`,value:l.signal,color:ze.SIGNAL}),u.length===0?null:{name:`KST`,params:[t,n,r,i,a],values:u}}function ro(e={}){let{paneId:t=`sub`}=e,n=si(t),r=null,i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a){let o=i-r||1,s=X(n-(80-r)/o*n,a),c=X(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.restore()}function p(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showFASTK,r.period].join(`|`)}return{name:`fastk_${t}`,version:`2.1.0`,description:`FASTK 快速随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`FASTK`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=r?.getSharedState(n);if(!y||y.visibleMin>y.visibleMax){l();return}let{valueMin:b,valueMax:x,params:S,series:C}=y,w=s.yAxis.getDisplayRange({minPrice:b,maxPrice:x}),T=w.minPrice,E=w.maxPrice,D=E-T||1,O=e.paneWidth,k=s.height,A=d(O,k,T,E,g);if(c!==A){c=A;let{ctx:e}=u(Math.ceil(O*g),Math.ceil(k*g));f(e,O,k,T,E,g)}o&&t.drawImage(o,0,0,O,k);let j=Math.max(m.start,S.period-1),M=Math.min(m.end,C.length),N=p(m,_,s,S);if(i!==N){i=N;let e=k,t=e/D,n=m.start;if(S.showFASTK){let r=[];for(let i=j;i<M;i++){let a=C[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-T)*t})}a=r}else a=[]}let P=e.settings?.enableWebGLRendering!==!1,F=!1;P&&v?.isAvailable()&&S.showFASTK&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:Ie.K}],h)&&(F=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),F||io(t,h,a,S)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function io(e,t,n,r){if(!(!r.showFASTK||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Ie.K,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function ao(e,t,n,r=`sub_FASTK`){let i=n.getSharedState(si(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`FASTK`,params:[t],values:[{label:`FASTK`,value:a,color:Ie.K}]}}var oo=`#d97706`;function so(e={}){let{paneId:t=`sub_ATR`}=e,n=fi(t),r=null,i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r){let i=n.yAxis.getDisplayRange();return[e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showATR,r.period].join(`|`)}return{name:`atr_${t}`,version:`1.0.0`,description:`ATR 平均真实波幅渲染器(Wilder 平滑)`,debugName:`ATR`,paneId:t,priority:R.MAIN,onInstall(e){r=e},getDeclaredNamespaces(){return[n]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,kLineCenters:d,lineWebGLSurface:f}=e,p=r?.getSharedState(n);if(!p||!p.params.showATR||p.visibleMin>p.visibleMax){o();return}let{valueMin:m,valueMax:h,params:g,series:_}=p;h-m;let v=c.yAxis.getDisplayRange({minPrice:m,maxPrice:h}),y=v.minPrice,b=v.maxPrice-y||1,x=c.height-(0-y)/b*c.height;t.save(),t.translate(-u,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(u,x),t.lineTo(u+e.paneWidth,x),t.stroke(),t.setLineDash([]),t.restore();let S=Math.max(l.start,g.period-1),C=Math.min(l.end,_.length),w=s(l,d,c,g);if(i!==w){i=w,a=[];for(let e=S;e<C;e++){let t=_[e];if(t===void 0)continue;let n=d[e-l.start];if(n===void 0)continue;let r=c.height-(t-y)/b*c.height;a.push({x:n,y:r})}}let T=e.settings?.enableWebGLRendering!==!1,E=!1;T&&f?.isAvailable()&&a.length>=2&&f.drawLineStrips([{points:a,width:1,color:oo}],u)&&(E=!0,f.compositeTo(t,{imageSmoothingEnabled:!1})),E||co(t,u,a)},getConfig(){return r?.getSharedState(n)?.params??{}},setConfig(){}}}function co(e,t,n){if(!(n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=oo,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function lo(e,t,n,r=`sub_ATR`){let i=n.getSharedState(fi(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`ATR`,params:[t],values:[{label:`ATR`,value:a,color:oo}]}}function uo(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return aa({paneId:n});case`MACD`:return Na({paneId:n});case`RSI`:return za({paneId:n});case`CCI`:return Ha({paneId:n});case`STOCH`:return Ga({paneId:n});case`MOM`:return Ja({paneId:n});case`WMSR`:return Za({paneId:n});case`KST`:return eo({paneId:n});case`FASTK`:return ro({paneId:n});case`ATR`:return so({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}function fo(e,t){return Math.max(3,Math.round(e/60)+1)}function po(e){let{height:t,paddingTop:n,paddingBottom:r,isMain:i,hideEdgeTicks:a}=e,o=n,s=Math.max(n,t-r),c=Math.max(0,s-o),l=fo(t,i),u=[];for(let e=0;e<l;e++){if(a&&(e===0||e===l-1))continue;let t=l<=1?0:e/(l-1),n=o+t*c;u.push({index:e,t,y:n})}return u}var mo=1e-10,ho=[1,1.2,1.5,2,2.5,3,4,5,6,7.5,8,10];function go(e){if(!Number.isFinite(e)||e<=0)return e;let t=10**Math.floor(Math.log10(e)),n=e/t,r=ho[0],i=1/0;for(let e of ho){let t=Math.abs(e-n);t<i&&(i=t,r=e)}return r*t}function _o(e){let{height:t,paddingTop:n,paddingBottom:r,valueMin:i,valueMax:a,targetCount:o}=e,s=Math.max(i,mo),c=Math.max(a,s*1.001),l=n,u=Math.max(n,t-r),d=Math.max(0,u-l);if(d<=0)return[];let f=Ce({minPrice:s,maxPrice:c}),p=V(s,f),m=V(c,f),h=m-p;if(!Number.isFinite(h)||Math.abs(h)<1e-10)return[];let g=Math.max(2,o),_=g<=1?d:d/(g-1),v=_*.6,y=_*.15,b=[],x=null;for(let e=0;e<g;e++){let t=g<=1?0:e/(g-1),n=l+t*d,r=Se(m-t*h,f),i=r,a=t,o=n,s=go(r);if(Number.isFinite(s)&&s>0){let e=(m-V(s,f))/h,t=l+e*d;Number.isFinite(t)&&Math.abs(t-n)<=y&&(i=s,a=e,o=t)}o<l-.5||o>u+.5||x!==null&&Math.abs(o-x)<v||(b.push({index:b.length,t:a,y:o,value:i}),x=o)}return b}var vo=``,yo=[];function bo(e){return`${e.valueMin}:${e.valueMax}:${e.height}:${e.paddingTop}:${e.paddingBottom}:${e.isMain}:${e.scaleType??`linear`}:${e.hideEdgeTicks??!1}`}function xo(e){let t=bo(e);if(t===vo)return yo;let{valueMin:n,valueMax:r,scaleType:i=`linear`}=e;if(i===`log`){if(n<=0)return xo({...e,scaleType:`linear`});let i=Math.max(n,mo),a=Math.max(r,i*1.001),{height:o,paddingTop:s,paddingBottom:c,isMain:l,hideEdgeTicks:u}=e,d=_o({height:o,paddingTop:s,paddingBottom:c,valueMin:i,valueMax:a,targetCount:Math.max(2,fo(o,l))});u&&d.length>2&&(d=d.slice(1,-1));let f=d.map((e,t)=>({...e,index:t}));return vo=t,yo=f,f}let a=po(e),o=fo(e.height,e.isMain),s=r-n||1,c=a.map(e=>{let t=r-s/Math.max(1,o-1)*e.index;return{...e,value:t}});return vo=t,yo=c,c}function So(e,t,n,r,i,a){let o=t-n||1,s=Math.max(1,r-i-a);return n+(1-(Math.min(Math.max(e,i),i+s)-i)/s)*o}var Co=new Map,wo=512;function To(e,t){let n=`${e.font}\n${t}`,r=Co.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Co.size>=wo&&Co.clear(),Co.set(n,i),i}function Eo(e,t){let{x:n,y:r,width:i,height:a,crosshairX:o,timestamp:s,dpr:c,fontSize:l=16,paddingX:u=8}=t,d=st(s);e.save(),Oa(e,Da(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(To(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=`rgba(0, 0, 0, 0.8)`,e.fillRect(Y(_,c),Y(v,c),Y(p,c),Y(m,c)),e.fillStyle=`#ffffff`,e.fillText(d,Y(h,c),X(g,c)),e.restore()}function Do(e,t){let{x:n,y:r,width:i,height:a,crosshairY:o,priceRange:s,yPaddingPx:c=0,dpr:l,bgColor:u=`rgba(0, 0, 0, 0.8)`,borderColor:d,textColor:f=`#ffffff`,fontSize:p=16,priceOffset:m=0,price:h,formatPrice:g}=t,_=Math.max(0,Math.min(c,Math.floor(a/2)-1)),{maxPrice:v,minPrice:y}=s,b=h??So(o-r,v,y,a,_,_)+m,x=g?g(b):b.toFixed(2);e.save(),Oa(e,Da(p)),e.textBaseline=`middle`,e.textAlign=`center`;let S=p+4,C=Math.min(Math.max(o,r+S/2),r+a-S/2),w=C-S/2,T=n,E=Y(w,l),D=i,O=Y(S,l);e.fillStyle=u,e.fillRect(T,E,D,O),d&&(e.strokeStyle=d,e.lineWidth=1,e.strokeRect(X(T,l),X(E,l),Math.max(0,D-1/l),Math.max(0,O-1/l)));let k=n+i/2;e.fillStyle=f,e.fillText(x,Y(k,l),X(C,l)),e.restore()}function Oo(e,t){let{x:n,y:r,width:i,height:a,data:o,scrollLeft:s,kWidth:c,kGap:l,startIndex:u,endIndex:d,dpr:f,bgColor:p=je.TRANSPARENT,textColor:m=Ae.SECONDARY,lineColor:h=Me.DARK,fontSize:g=12,paddingX:_=8,drawTopBorder:v=!0,drawBottomBorder:y=!0}=t,b=Math.round(c*f),x=b%2==0?b+1:b,S=Math.round(l*f),C=x+S,w=S,T=C/f,E=w/f,D=x/f;e.fillStyle=p,e.fillRect(n,r,i,a),v&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,X(r,f)),e.lineTo(n+i,X(r,f)),e.stroke()),y&&(e.strokeStyle=h,e.lineWidth=1,e.beginPath(),e.moveTo(n,X(r+a,f)),e.lineTo(n+i,X(r+a,f)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=m;let O=r+a/2,k=Da(g),A=Da(g,{bold:!0}),j=pt(o).filter(e=>e>=u&&e<d),M=null;for(let t of j){let n=o[t];if(!n)continue;let r=E+t*T+D/2-s,a=_,c=Math.max(_,i-_);if(r>=a&&r<=c){let t=Math.min(Math.max(r,a),c),{text:i,isYear:o}=it(n.timestamp);M!==o&&(Oa(e,o?A:k),M=o),e.fillText(i,Y(t,f),X(O,f))}}}function ko(e,t){let{x:n,y:r,width:i,height:a,priceY:o,price:s,dpr:c,bgColor:l=`rgba(0, 0, 0, 0.8)`,borderColor:u,textColor:d=`#ffffff`,fontSize:f=12}=t,p=s.toFixed(2);e.save(),Oa(e,Da(f)),e.textBaseline=`middle`,e.textAlign=`center`;let m=f+4,h=Math.min(Math.max(o,r+m/2),r+a-m/2),g=h-m/2,_=n,v=Y(g,c),y=i,b=Y(m,c);e.fillStyle=l,e.fillRect(_,v,y,b),u&&(e.strokeStyle=u,e.lineWidth=1,e.strokeRect(X(_,c),X(v,c),Math.max(0,y-1/c),Math.max(0,b-1/c)));let x=n+i/2;e.fillStyle=d,e.fillText(p,Y(x,c),X(h,c)),e.restore()}function Ao(e,t){let{x:n,y:r,width:i,height:a,labelX:o,timestamp:s,dpr:c,fontSize:l=12,paddingX:u=8}=t,d=st(s);e.save(),Oa(e,Da(l)),e.textBaseline=`middle`,e.textAlign=`center`;let f=Math.round(To(e,d)),p=Math.min(i,f+u*2),m=a,h=Math.min(Math.max(o,n+p/2),n+i-p/2),g=r+a/2,_=h-p/2,v=r;e.fillStyle=t.bgColor??`rgba(0, 0, 0, 0.8)`,e.fillRect(Y(_,c),Y(v,c),Y(p,c),Y(m,c)),e.fillStyle=t.textColor??`#ffffff`,e.fillText(d,Y(h,c),X(g,c)),e.restore()}var jo=`middle`,Mo=`center`;function No(e){let{ctx:t,dpr:n,axisWidth:r,height:i,paddingTop:a,paddingBottom:o,valueMin:s,valueMax:c,isMain:l,decimals:u=2,hideEdgeTicks:d=!0,scaleType:f=`linear`,formatLabel:p}=e;t.clearRect(0,0,r,i),Oa(t,Da(12)),t.textBaseline=jo,t.textAlign=Mo,t.fillStyle=Ae.SECONDARY;let m=Y(r/2,n),h=xo({height:i,paddingTop:a,paddingBottom:o,isMain:l,hideEdgeTicks:d,valueMin:s,valueMax:c,scaleType:f}),g=p??(e=>e.toFixed(u));for(let e=0;e<h.length;e++){let{y:r,value:i}=h[e];t.fillText(g(i),m,X(r,n))}}function Po(e){let{axisWidth:t,paneId:n,indicatorKey:r,label:i,decimals:a=2,yPaddingPx:o=0,scaleType:s=`linear`,getCrosshair:c,formatTickLabel:l,formatCrosshairLabel:u}=e,d=Z(r,n),f=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:R.INDICATOR_SCALE,layer:`overlay`,onInstall(e){f=e},draw(e){let{yAxisCtx:n,pane:r,dpr:i}=e;if(!n||!f)return;let p=f.getSharedState(d);if(!p)return;let m=r.yAxis.getScaleType()??s,h=n.canvas?n.canvas.width/i:t,g=r.yAxis.getDisplayRange({minPrice:p.valueMin,maxPrice:p.valueMax});No({ctx:n,dpr:i,axisWidth:h,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:g.minPrice,valueMax:g.maxPrice,isMain:!1,decimals:a,hideEdgeTicks:!1,scaleType:m,formatLabel:l});let _=c?.();if(!_||_.activePaneId!==r.id)return;let v=_.y-r.top,y=r.yAxis.getPaddingTop(),b=r.yAxis.getPaddingBottom(),x=y,S=Math.max(y,r.height-b),C=Math.max(1,S-x),w=(Math.min(Math.max(v,x),S)-x)/C,T=g.maxPrice-w*(g.maxPrice-g.minPrice);Do(n,{x:0,y:0,width:h,height:r.height,crosshairY:v,priceRange:g,yPaddingPx:o,dpr:i,fontSize:12,priceOffset:0,price:T,formatPrice:u})}}}var Fo=1e8;function Io(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>`${(e/Fo).toFixed(2)}B`,formatCrosshairLabel:e=>`${(e/Fo).toFixed(2)}B`})}function Lo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Ro(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function zo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Bo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Vo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Ho(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Uo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Wo(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Go(e){return Po({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`atr`,label:`ATR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var Ko=class{entries=new Map;create(e,t,n,r){if(this.entries.has(t))return!0;let i=`${n.toLowerCase()}_${t}`,a=`${n.toLowerCase()}_scale_${t}`;if(e.hasPane(t)||e.upsertPane({id:t,ratio:1,visible:!0,role:`indicator`}),!e.getRenderer(i)){let i=uo({indicatorId:n,paneId:t});e.useRenderer(i,r)}return this.mountScaleRenderer(e,t,n,a),this.entries.set(t,{paneId:t,indicatorId:n,params:r,rendererName:i,scaleRendererName:a}),this.syncSchedulerConfig(e,t,n,r),e.getIndicatorScheduler().onSubPaneChanged(),!0}remove(e,t){let n=this.entries.get(t);n&&(e.removeRenderer(n.rendererName),e.removeRenderer(n.scaleRendererName),this.entries.delete(t),e.hasPane(t)&&e.removePaneDefinition(t),e.getIndicatorScheduler().onSubPaneChanged())}replaceIndicator(e,t,n,r){let i=this.entries.get(t);if(!i)return;i.indicatorId,e.removeRenderer(i.rendererName),e.removeRenderer(i.scaleRendererName);let a=`${n.toLowerCase()}_${t}`,o=`${n.toLowerCase()}_scale_${t}`,s=uo({indicatorId:n,paneId:t});e.useRenderer(s,r),this.mountScaleRenderer(e,t,n,o),this.syncSchedulerConfig(e,t,n,r),this.entries.set(t,{paneId:t,indicatorId:n,params:r,rendererName:a,scaleRendererName:o}),e.getIndicatorScheduler().onSubPaneChanged()}updateParams(e,t,n){let r=this.entries.get(t);r&&(r.params={...n},e.updateRendererConfig(r.rendererName,n),this.syncSchedulerConfig(e,t,r.indicatorId,r.params))}getByPaneId(e){return this.entries.get(e)}getAll(){return Array.from(this.entries.values())}getPaneIds(){return Array.from(this.entries.keys())}clear(e){for(let t of this.entries.values())e.removeRenderer(t.rendererName),e.removeRenderer(t.scaleRendererName);this.entries.clear(),e.getIndicatorScheduler().onSubPaneChanged()}syncSchedulerConfig(e,t,n,r){let i=e.getIndicatorScheduler();switch(n){case`MACD`:i.updateMACDConfig(r,t);break;case`RSI`:i.updateRSIConfig(r,t);break;case`CCI`:i.updateCCIConfig(r,t);break;case`STOCH`:i.updateSTOCHConfig(r,t);break;case`MOM`:i.updateMOMConfig(r,t);break;case`WMSR`:i.updateWMSRConfig(r,t);break;case`KST`:i.updateKSTConfig(r,t);break;case`FASTK`:i.updateFASTKConfig(r,t);break;case`ATR`:console.log(`[ATR-SubPane] syncSchedulerConfig: paneId=${t} params=${JSON.stringify(r)}`),i.updateATRConfig(r,t);break;case`VOLUME`:break}}mountScaleRenderer(e,t,n,r){if(e.getRenderer(r))return;let i={axisWidth:e.getOption().rightAxisWidth+(e.getOption().priceLabelWidth??60),paneId:t,yPaddingPx:e.getOption().yPaddingPx,getCrosshair:()=>{let t=e.interaction.crosshairPos,n=e.interaction.crosshairPrice,r=e.interaction.activePaneId;return t&&n!==null?{y:t.y,price:n,activePaneId:r}:null}},a;switch(n){case`VOLUME`:a=Io(i);break;case`MACD`:a=Lo(i);break;case`RSI`:a=Ro(i);break;case`CCI`:a=zo(i);break;case`STOCH`:a=Bo(i);break;case`MOM`:a=Vo(i);break;case`WMSR`:a=Ho(i);break;case`KST`:a=Uo(i);break;case`FASTK`:a=Wo(i);break;case`ATR`:a=Go(i);break;default:return}e.useRenderer(a)}},qo=8,Jo=6,Yo=class e{chart;activeTool=`cursor`;pendingAnchors=[];drawings=[];callbacks={};previewDrawingId=`__preview__`;dragState=null;selectedDrawingId=null;static SINGLE_ANCHOR_TOOLS=[`h-line`,`h-ray`,`v-line`,`crosshair-line`];static DOUBLE_ANCHOR_TOOLS=[`trend-line`,`ray`,`info-line`,`regression-channel`];static TRIPLE_ANCHOR_TOOLS=[`parallel-channel`,`flat-line`,`disjoint-channel`];constructor(e){this.chart=e}setCallbacks(e){this.callbacks=e}getActiveTool(){return this.activeTool}setTool(e){this.activeTool=e,this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null),this.callbacks.onToolChange?.(e)}getDrawings(){return this.drawings}setDrawings(e){this.drawings=e,this.chart.setDrawings(e)}clear(){this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null)}getSelectedDrawing(){return this.selectedDrawingId?this.drawings.find(e=>e.id===this.selectedDrawingId)??null:null}updateDrawingStyle(e,t){this.drawings=this.drawings.map(n=>n.id===e?{...n,style:{...n.style,...t}}:n),this.chart.setDrawings(this.drawings)}removeDrawing(e){this.drawings=this.drawings.filter(t=>t.id!==e),this.selectedDrawingId===e&&this.setSelected(null),this.chart.setDrawings(this.drawings)}onPointerMove(e,t){return this.dragState?this.handleDragMove(e,t):this.activeTool===`cursor`?!1:this.handlePreviewMove(e,t)}onPointerDown(t,n){if(this.activeTool===`cursor`)return this.handleCursorDown(t,n);let r=this.resolveAnchorFromPointer(t,n);if(!r)return!1;if(e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool))return this.createSingleAnchorDrawing(r),!0;let i=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a)return!1;this.pendingAnchors.push(r);let o=i?2:3;return this.pendingAnchors.length>=o&&(this.createMultiAnchorDrawing(this.pendingAnchors),this.pendingAnchors=[]),!0}onPointerUp(e,t){return this.dragState?(this.dragState=null,!0):!1}handleCursorDown(e,t){let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,a=this.hitTest(r,i);return a?(this.setSelected(a.drawing),this.dragState={drawingId:a.drawing.id,anchorIndex:`anchorIndex`in a?a.anchorIndex:void 0,snapshot:a.drawing.anchors.map(e=>({...e})),startMouse:{x:r,y:i}},!0):(this.setSelected(null),!1)}handleDragMove(e,t){if(!this.dragState)return!1;let n=this.drawings.find(e=>e.id===this.dragState.drawingId);if(!n)return this.dragState=null,!1;let r=this.resolveAnchorFromPointer(e,t);if(this.dragState.anchorIndex!==void 0){if(r){let e=this.dragState.anchorIndex;n.anchors[e]={...n.anchors[e],index:r.index,time:r.time,price:r.price},n.kind===`flat-line`&&e===1&&n.anchors.length>=3&&(n.anchors[2]={...n.anchors[2],index:r.index,time:r.time})}}else{let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=i-this.dragState.startMouse.x,s=a-this.dragState.startMouse.y;for(let e=0;e<n.anchors.length;e++){let t=this.dragState.snapshot[e],r=this.anchorToScreen(t);if(!r)continue;let i=r.x+o,a=r.y+s,c=this.screenToAnchor(i,a);c&&(n.anchors[e]={...n.anchors[e],index:c.index,time:c.time,price:c.price})}}return this.chart.setDrawings([...this.drawings]),!0}handlePreviewMove(t,n){let r=this.resolveAnchorFromPointer(t,n);if(!r)return this.removePreview(),!1;let i=e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),o=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a&&!o)return!1;let s;if(i)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else if(a&&this.pendingAnchors.length>=1)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:this.activeTool===`regression-channel`?{sigma:2}:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,...this.activeTool===`regression-channel`?{fillOpacity:.1}:{}}};else if(o){if(this.pendingAnchors.length===0)return!1;if(this.pendingAnchors.length===1)s={id:this.previewDrawingId,kind:`trend-line`,paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else{let e=this.activeTool===`flat-line`?{id:`${this.previewDrawingId}-c`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:r.price}:{id:`${this.previewDrawingId}-c`,index:r.index,time:r.time,price:r.price};s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:this.pendingAnchors[1].price},e],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,fillOpacity:.1}}}}else return!1;return this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.drawings=[...this.drawings,s],this.chart.setDrawings(this.drawings),!0}hitTest(e,t){let n=this.drawings.filter(e=>e.id!==this.previewDrawingId&&e.visible),r=new Map;for(let i of n){if(i.kind===`regression-channel`&&i.anchors.length>=2){let n=this.hitTestRegressionEndpoints(i,e,t,r);if(n)return n}for(let n=0;n<i.anchors.length;n++){let r=this.anchorToScreen(i.anchors[n]);if(r&&Math.hypot(e-r.x,t-r.y)<=qo)return{drawing:i,anchorIndex:n}}}for(let i of n){let n=this.getDrawingLineSegments(i,r);for(let r of n)if(Xo(e,t,r.a,r.b)<=Jo)return{drawing:i}}return null}getDrawingLineSegments(e,t){let n=this.chart.getViewport();if(!n)return[];if(e.kind===`regression-channel`)return this.getRegressionChannelGeometry(e,t)?.segments??[];if(e.anchors.length===1){let t=this.anchorToScreen(e.anchors[0]);if(!t)return[];let r=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();if(!r)return[];let i=n.plotWidth,a=r.height;switch(e.kind){case`horizontal-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}}];case`horizontal-ray`:return[{a:t,b:{x:i,y:t.y}}];case`vertical-line`:return[{a:{x:t.x,y:0},b:{x:t.x,y:a}}];case`cross-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}},{a:{x:t.x,y:0},b:{x:t.x,y:a}}];default:return[]}}let r=e.anchors.map(e=>this.anchorToScreen(e)).filter(Boolean);if(r.length<2)return[];let i=[];if(r.length===2){let t=r[0],a=r[1],o=a.x-t.x,s=a.y-t.y,c=t,l=a,u=this.getExtendMode(e),d=Math.max(n.plotWidth,n.plotHeight)*4;(u===`right`||u===`both`)&&(l={x:a.x+o*d,y:a.y+s*d}),(u===`left`||u===`both`)&&(c={x:t.x-o*d,y:t.y-s*d}),i.push({a:c,b:l})}else if(r.length>=3)switch(e.kind){case`parallel-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y+o};i.push({a:e,b:t},{a:n,b:s});break}case`flat-line`:{let[e,t,n]=r,a={x:e.x,y:n.y},o={x:t.x,y:n.y};i.push({a:e,b:t}),i.push({a,b:o});break}case`disjoint-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y-o};i.push({a:e,b:t}),i.push({a:n,b:s});break}default:for(let e=0;e<r.length-1;e++)i.push({a:r[e],b:r[e+1]})}return i}hitTestRegressionEndpoints(e,t,n,r){let i=this.getRegressionChannelGeometry(e,r);if(!i)return null;for(let r of i.endpoints)if(Math.hypot(t-r.point.x,n-r.point.y)<=qo)return{drawing:e,anchorIndex:r.anchorIndex};return null}getRegressionChannelGeometry(e,t){let n=t?.get(e.id);if(n!==void 0)return n;let r=this.chart.getData();if(r.length===0||e.anchors.length<2)return t?.set(e.id,null),null;let i=Math.round(e.anchors[0].index),a=Math.round(e.anchors[1].index),o=Math.min(Math.max(i,0),r.length-1),s=Math.min(Math.max(a,0),r.length-1),c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=as(u.map(e=>e.close));if(!d)return t?.set(e.id,null),null;let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g=this.anchorToScreen({id:``,index:i,price:m}),_=this.anchorToScreen({id:``,index:a,price:h}),v=this.anchorToScreen({id:``,index:i,price:m+p}),y=this.anchorToScreen({id:``,index:a,price:h+p}),b=this.anchorToScreen({id:``,index:i,price:m-p}),x=this.anchorToScreen({id:``,index:a,price:h-p}),S=[];g&&_&&S.push({a:g,b:_}),v&&y&&S.push({a:v,b:y}),b&&x&&S.push({a:b,b:x});let C=[];g&&C.push({point:g,anchorIndex:0}),_&&C.push({point:_,anchorIndex:1}),v&&C.push({point:v,anchorIndex:0}),y&&C.push({point:y,anchorIndex:1}),b&&C.push({point:b,anchorIndex:0}),x&&C.push({point:x,anchorIndex:1});let w={segments:S,endpoints:C};return t?.set(e.id,w),w}getExtendMode(e){switch(e.kind){case`ray`:return`right`;case`extended-line`:return`both`;default:return`none`}}anchorToScreen(e){let t=this.chart.getViewport();if(!t)return null;let n=this.chart.getOption(),r=this.chart.getCurrentDpr(),{startXPx:i,unitPx:a}=B(n.kWidth,n.kGap,r);if(!Number.isFinite(e.index))return null;let o=(i+e.index*a+(a-1)/2)/r-t.scrollLeft,s=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return s?{x:o,y:s.yAxis.priceToY(e.price)}:null}screenToAnchor(e,t){let n=this.chart.getData();if(!this.chart.getViewport()||n.length===0)return null;let r=this.chart.getLogicalIndexAtX(e);if(r===null)return null;let i=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return i?{index:r,time:this.chart.getTimestampAtLogicalIndex(r)??void 0??void 0,price:i.yAxis.yToPrice(t-i.top)}:null}setSelected(e){let t=e?.id??null;this.selectedDrawingId!==t&&(this.selectedDrawingId=t,this.chart.setSelectedDrawingId(t),this.callbacks.onDrawingSelected?.(e))}removePreview(){this.drawings.some(e=>e.id===this.previewDrawingId)&&(this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.chart.setDrawings(this.drawings))}resolveAnchorFromPointer(e,t){let n=this.chart.getData(),r=this.chart.getViewport();if(!r||n.length===0)return null;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;if(a<0||o<0||a>r.plotWidth||o>r.plotHeight)return null;let s=this.chart.getPaneRenderers().find(e=>{let t=e.getPane();return t.id===`main`&&o>=t.top&&o<=t.top+t.height})?.getPane();if(!s)return null;let c=this.chart.getLogicalIndexAtX(a);return c===null?null:{index:c,time:this.chart.getTimestampAtLogicalIndex(c)??void 0??void 0,price:s.yAxis.yToPrice(o-s.top)}}createSingleAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t={id:`drawing-${Date.now()}`,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${Date.now()}-a`,index:e.index,time:e.time,price:e.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`}};this.drawings=[...this.drawings,t],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(t),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}createMultiAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t=this.getDrawingKind(this.activeTool),n=t===`regression-channel`?{sigma:2}:{},r=t===`flat-line`&&e.length>=3?[e[0],e[1],{index:e[1].index,time:e[1].time,price:e[2].price}]:e,i=[`parallel-channel`,`regression-channel`,`flat-line`,`disjoint-channel`].includes(t),a={id:`drawing-${Date.now()}`,kind:t,paneId:`main`,visible:!0,anchors:r.map((e,t)=>({id:`${Date.now()}-${String.fromCharCode(97+t)}`,index:e.index,time:e.time,price:e.price})),params:n,style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`,...i?{fillOpacity:.1}:{}}};this.drawings=[...this.drawings,a],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(a),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}getDrawingKind(e){switch(e){case`cursor`:throw Error(`cursor is not a drawing kind`);case`h-line`:return`horizontal-line`;case`h-ray`:return`horizontal-ray`;case`v-line`:return`vertical-line`;case`crosshair-line`:return`cross-line`;default:return e}}};function Xo(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=i*i+a*a;if(o===0)return Math.hypot(e-n.x,t-n.y);let s=((e-n.x)*i+(t-n.y)*a)/o;return s=Math.max(0,Math.min(1,s)),Math.hypot(e-(n.x+s*i),t-(n.y+s*a))}var Zo=class{drawings=[];selectedId=null;getSelectedId(){return this.selectedId}setSelectedId(e){this.selectedId=e}getAll(){return this.drawings}getVisibleByPane(e){return this.drawings.filter(t=>t.visible&&t.paneId===e).sort((e,t)=>(e.zIndex??0)-(t.zIndex??0))}setAll(e){this.drawings=[...e],this.selectedId&&!this.drawings.some(e=>e.id===this.selectedId)&&(this.selectedId=null)}upsert(e){let t=this.drawings.findIndex(t=>t.id===e.id);if(t>=0){this.drawings[t]=e;return}this.drawings.push(e)}remove(e){this.drawings=this.drawings.filter(t=>t.id!==e)}clear(){this.drawings=[],this.selectedId=null}},Qo=class{definitions=new Map;register(e){this.definitions.set(e.kind,e)}get(e){return this.definitions.get(e)}compute(e,t){let n=this.get(e.kind);return n?n.compute(e,t):null}};function $o(e,t){if(e.strokeStyle=t?.stroke??`#2962ff`,e.lineWidth=t?.strokeWidth??1,t?.strokeStyle===`dashed`){e.setLineDash([6,4]);return}if(t?.strokeStyle===`dotted`){e.setLineDash([2,3]);return}e.setLineDash([])}function es(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function ts(e,t,n,r,i){let a=(e,t)=>{let n=0;return e<i.left?n|=1:e>i.right&&(n|=2),t<i.top?n|=8:t>i.bottom&&(n|=4),n},o=e,s=t,c=n,l=r;for(;;){let e=a(o,s),t=a(c,l);if(!(e|t))return{a:{x:o,y:s},b:{x:c,y:l}};if(e&t)return null;let n=e||t,r=0,u=0;n&8?(r=o+(c-o)*(i.top-s)/(l-s),u=i.top):n&4?(r=o+(c-o)*(i.bottom-s)/(l-s),u=i.bottom):n&2?(u=s+(l-s)*(i.right-o)/(c-o),r=i.right):(u=s+(l-s)*(i.left-o)/(c-o),r=i.left),n===e?(o=r,s=u):(c=r,l=u)}}function ns(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return ts(n.x,n.y,r.x,r.y,t);let a=r.x-n.x,o=r.y-n.y;if(a===0&&o===0)return null;let s=Math.max(t.right-t.left,t.bottom-t.top)*4,c=n,l=r;return(i===`left`||i===`both`)&&(c={x:n.x-a*s,y:n.y-o*s}),(i===`right`||i===`both`)&&(l={x:r.x+a*s,y:r.y+o*s}),ts(c.x,c.y,l.x,l.y,t)}function rs(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function is(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function as(e){let t=e.length;if(t<2)return null;let n=0,r=0,i=0,a=0;for(let o=0;o<t;o++){let t=o,s=e[o];n+=t,r+=s,i+=t*s,a+=t*t}let o=t*a-n*n;if(o===0)return null;let s=(t*i-n*r)/o,c=(r-s*n)/t,l=0;for(let n=0;n<t;n++){let t=c+s*n,r=e[n]-t;l+=r*r}return{slope:s,intercept:c,stdDev:Math.sqrt(l/t)}}function os(){return{point(e,t,n){let r=t.style?.pointRadius??4;e.save(),e.fillStyle=t.style?.fill??t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.point.x,t.point.y,Math.max(r,1/n),0,Math.PI*2),e.fill(),e.restore()},line(e,t,n,r){let i=ns(t,n);if(!i)return;e.save(),$o(e,t.style);let a=(t.style?.strokeWidth??1)<=1?.5/r:0;if(e.beginPath(),e.moveTo(i.a.x+a,i.a.y+a),e.lineTo(i.b.x+a,i.b.y+a),e.stroke(),t.showEndpoints!==!1){let n=t.style?.pointRadius??4;e.fillStyle=t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.a.x,t.a.y,Math.max(n,1/r),0,Math.PI*2),e.fill(),e.beginPath(),e.arc(t.b.x,t.b.y,Math.max(n,1/r),0,Math.PI*2),e.fill()}e.restore()},area(e,t){if(t.points.length!==0){e.save(),es(e,t.style),e.beginPath(),e.moveTo(t.points[0].x,t.points[0].y);for(let n=1;n<t.points.length;n++){let r=t.points[n];e.lineTo(r.x,r.y)}t.closed&&e.closePath(),e.fill(),e.restore()}},text(e,t){e.save(),e.fillStyle=t.style?.textColor??t.style?.stroke??`#2962ff`,e.font=`${t.style?.fontSize??12}px sans-serif`,e.textAlign=t.align??`left`,e.textBaseline=t.baseline??`bottom`,e.fillText(t.text,t.point.x,t.point.y),e.restore()}}}function ss(e,t){return{kind:e,minAnchors:2,maxAnchors:2,compute(e,n){let[r,i]=e.anchors;return!r||!i?{primitives:[]}:{primitives:[{kind:`line`,a:n.toScreen(r),b:n.toScreen(i),extend:t,style:e.style}]}}}}function cs(e){return{kind:e,minAnchors:1,maxAnchors:1,compute(t,n){let[r]=t.anchors;if(!r)return{primitives:[]};let i=n.toScreen(r),a=n.pane.height,o=n.viewport.plotWidth;return e===`horizontal-line`?{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`horizontal-ray`?{primitives:[{kind:`line`,a:i,b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`vertical-line`?{primitives:[{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}}}}function ls(){return{kind:`info-line`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=t.toScreen(n),a=t.toScreen(r),o=Math.round(n.index),s=Math.round(r.index)-o,c=r.price-n.price,l=n.price===0?0:c/n.price*100,u=Math.atan2(a.y-i.y,a.x-i.x)*(180/Math.PI),d=`${is(c)} (${is(l)}%) ${s} bars ${is(u)}°`;return{primitives:[{kind:`line`,a:i,b:a,style:e.style},{kind:`text`,point:{x:(i.x+a.x)/2+8,y:Math.min(i.y,a.y)-8},text:d,align:`left`,baseline:`bottom`,style:e.style}],meta:{delta:c,percent:l,bars:s,angle:u}}}}}function us(){return{kind:`parallel-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y+l},d=e.params?.extend??`none`,f=i.index+(r.index-n.index),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)+((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,extend:d,style:e.style},{kind:`line`,a:s,b:u,extend:d,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:f,time:p,price:i.price+(r.price-n.price)}]}}}}function ds(){return{kind:`flat-line`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c={x:a.x,y:s.y},l={x:o.x,y:s.y};return{primitives:[{kind:`area`,points:[a,o,l,c],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:c,b:l,style:e.style},{kind:`point`,point:c,style:e.style},{kind:`point`,point:l,style:e.style}],computedAnchors:[{id:`${e.id}-h1`,index:n.index,time:n.time,price:i.price},{id:`${e.id}-h2`,index:r.index,time:r.time,price:i.price}]}}}}function fs(){return{kind:`disjoint-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y-l},d=i.index+(r.index-n.index),f=i.price-(r.price-n.price),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)-((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:s,b:u,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:d,time:p,price:f}]}}}}function ps(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=rs(n,t.seriesData),a=rs(r,t.seriesData);if(i<0&&a<0)return{primitives:[]};let o=Math.min(Math.max(Math.round(n.index),0),t.seriesData.length-1),s=Math.min(Math.max(Math.round(r.index),0),t.seriesData.length-1),c=Math.min(o,s),l=Math.max(o,s),u=t.seriesData.slice(c,l+1),d=as(u.map(e=>e.close));if(!d)return{primitives:[]};let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g={id:`${e.id}-reg-start`,index:Math.round(n.index),time:t.seriesData[c].timestamp,price:m},_={id:`${e.id}-reg-end`,index:Math.round(r.index),time:t.seriesData[l].timestamp,price:h},v={...g,id:`${e.id}-reg-upper-start`,price:m+p},y={..._,id:`${e.id}-reg-upper-end`,price:h+p},b={...g,id:`${e.id}-reg-lower-start`,price:m-p},x={..._,id:`${e.id}-reg-lower-end`,price:h-p},S=t.toScreen(g),C=t.toScreen(_),w=t.toScreen(v),T=t.toScreen(y),E=t.toScreen(b),D=t.toScreen(x);return{primitives:[{kind:`area`,points:[w,T,D,E],closed:!0,style:e.style},{kind:`line`,a:S,b:C,style:{...e.style,strokeStyle:`dashed`}},{kind:`line`,a:w,b:T,style:e.style},{kind:`line`,a:E,b:D,style:e.style}],computedAnchors:[g,_],meta:{sigma:f,stdDev:d.stdDev,slope:d.slope}}}}}function ms(e){e.register(ss(`trend-line`,`none`)),e.register(ss(`ray`,`right`)),e.register(ss(`extended-line`,`both`)),e.register(cs(`horizontal-line`)),e.register(cs(`horizontal-ray`)),e.register(cs(`vertical-line`)),e.register(cs(`cross-line`)),e.register(ls()),e.register(us()),e.register(ps()),e.register(ds()),e.register(fs())}function hs(e){let t=e.store,n=e.definitions??new Qo,r=e.renderers??os();return ms(n),{name:`drawingRenderer`,version:`0.1.0`,description:`绘图渲染器`,debugName:`绘图层`,paneId:e.paneId??`main`,priority:-25,draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c,paneWidth:l,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m}=e,h=e.viewport??{scrollLeft:e.scrollLeft,plotWidth:l,plotHeight:a.height},{startXPx:g,unitPx:_}=B(p,m,c),v=o,y=v.slice(s.start,s.end),b=t.getVisibleByPane(a.id);if(b.length===0)return;let x={left:0,top:0,right:h.plotWidth,bottom:a.height};i.save(),i.beginPath(),i.rect(0,0,h.plotWidth,a.height),i.clip();for(let o of b){let b=n.compute(o,{pane:a,visibleData:y,seriesData:v,range:s,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m,dpr:c,paneWidth:l,viewport:h,toScreen(e){return!Number.isFinite(e.index)||e.index<0?{x:-p,y:a.yAxis.priceToY(e.price)}:{x:(g+e.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(e.price)}}});if(!b)continue;let S=t.getSelectedId()===o.id,C=S?b.primitives.map(e=>gs(e,o.style)):b.primitives;if(S&&o.visible&&a.role===`price`){let t=[...o.anchors,...b.computedAnchors??[]];if(t.length===0)continue;if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)Number.isFinite(e.price)&&(e.price<n&&(n=e.price),e.price>r&&(r=e.price));Number.isFinite(n)&&Number.isFinite(r)&&n!==r&&(e.yAxisRanges||=[],e.yAxisRanges.push({topY:a.yAxis.priceToY(r),bottomY:a.yAxis.priceToY(n),color:o.style?.stroke??`#2962ff`,opacity:.15}))}if(t.length>=2){let n=1/0,r=-1/0;for(let e of t)!Number.isFinite(e.index)||e.index<0||(e.index<n&&(n=e.index),e.index>r&&(r=e.index));if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r){e.xAxisRanges||=[];let t=(g+n*_+(_-1)/2)/c,i=(g+r*_+(_-1)/2)/c;e.xAxisRanges.push({leftX:t,rightX:i,color:o.style?.stroke??`#2962ff`,opacity:.15})}}let n=e=>{if(e>=0&&e<v.length)return v[e]?.timestamp??null;if(v.length>=2&&e>=v.length){let t=v.length-1,n=v.length-2,r=v[t].timestamp,i=r-v[n].timestamp;return r+(e-t)*i}return null};for(let r of t){if(!Number.isFinite(r.index)||!Number.isFinite(r.price))continue;let t=r.index<0?{x:-p,y:a.yAxis.priceToY(r.price)}:{x:(g+r.index*_+(_-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(r.price)};if(t.y>=0&&t.y<=a.height&&(e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:Math.round(r.index),price:r.price,y:t.y,style:{bgColor:o.style?.stroke??`#2962ff`,borderColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})),t.x>=-p&&t.x<=h.plotWidth+p){let i=r.time?typeof r.time==`string`?new Date(r.time).getTime():r.time:n(Math.round(r.index));if(!i)continue;e.xAxisLabels||=[],e.xAxisLabels.push({dataIndex:Math.round(r.index),timestamp:i,x:t.x+h.scrollLeft,style:{bgColor:o.style?.stroke??`#2962ff`,textColor:`#ffffff`}})}}}for(let e of C){if(e.kind===`point`){r.point(i,e,c);continue}if(e.kind===`line`){r.line(i,e,x,c);continue}if(e.kind===`area`){r.area(i,e,c);continue}r.text(i,e,c)}}i.restore()}}}function gs(e,t){let n=t.stroke??`#2962ff`,r=(t.strokeWidth??1)+1,i=(t.pointRadius??4)+2;return e.kind===`point`?{...e,style:{...e.style,stroke:n,pointRadius:i}}:e.kind===`line`?{...e,style:{...e.style,stroke:n,strokeWidth:r}}:e.kind===`area`?{...e,style:{...e.style,stroke:n}}:{...e,style:{...e.style,textColor:n,fontSize:(e.style?.fontSize??12)+1}}}var _s=class{dom;opt;data=[];raf=null;pendingUpdateLevel=H.All;viewport=null;paneRenderers=[];markerManager;drawingStore=new Zo;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;onScroll;observedSize={width:0,height:0};cachedScrollLeft=0;overlayHadCrosshair=!1;settings={};paneRatios=new Map;onViewportChange;xAxisCtx=null;sharedWebGLSurface;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;indicatorScheduler;lastVisibleRange={start:0,end:0};cachedDrawFrame=null;subPaneManager;activeMainIndicators=new Set;mainIndicatorParams={MA:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},BOLL:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},EXPMA:{fastPeriod:12,slowPeriod:50},ENE:{period:10,deviation:11}};enableMainIndicator(e,t){let n=e.toUpperCase();return[`MA`,`BOLL`,`EXPMA`,`ENE`].includes(n)?this.activeMainIndicators.has(n)?(t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t},this.updateIndicatorSchedulerConfig(n)),!0):(this.activeMainIndicators.add(n),t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t}),this.enableMainIndicatorRenderer(n),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw(),!0):(console.warn(`[Chart] 未知的主图指标: ${e}`),!1)}disableMainIndicator(e){let t=e.toUpperCase();return this.activeMainIndicators.has(t)?(this.activeMainIndicators.delete(t),this.disableMainIndicatorRenderer(t),this.updateIndicatorSchedulerConfig(t),this.scheduleDraw(),!0):!1}toggleMainIndicator(e,t){t?this.enableMainIndicator(e):this.disableMainIndicator(e)}getActiveMainIndicators(){return Array.from(this.activeMainIndicators)}isMainIndicatorActive(e){return this.activeMainIndicators.has(e.toUpperCase())}updateMainIndicatorParams(e,t){let n=e.toUpperCase();this.mainIndicatorParams[n]||(this.mainIndicatorParams[n]={}),this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t};let r=n.toLowerCase(),i=this.getRenderer(r);i&&i.setConfig&&i.setConfig(this.mainIndicatorParams[n]),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw()}getMainIndicatorParams(e){return this.mainIndicatorParams[e.toUpperCase()]??null}clearMainIndicators(){for(let e of this.activeMainIndicators)this.disableMainIndicatorRenderer(e);this.activeMainIndicators.clear(),this.scheduleDraw()}enableMainIndicatorRenderer(e){let t={MA:()=>{this.getRenderer(`ma`)||this.useRenderer(fa()),this.setRendererEnabled(`ma`,!0)},BOLL:()=>{this.getRenderer(`boll`)||this.useRenderer(va()),this.setRendererEnabled(`boll`,!0)},EXPMA:()=>{this.getRenderer(`expma`)||this.useRenderer(ba()),this.setRendererEnabled(`expma`,!0)},ENE:()=>{this.getRenderer(`ene`)||this.useRenderer(Ta()),this.setRendererEnabled(`ene`,!0)}}[e];t&&t(),this.getRenderer(`mainIndicatorLegend`)||this.useRenderer(Ma({yPaddingPx:this.opt.yPaddingPx}))}disableMainIndicatorRenderer(e){let t={MA:`ma`,BOLL:`boll`,EXPMA:`expma`,ENE:`ene`}[e];t&&this.setRendererEnabled(t,!1)}updateIndicatorSchedulerConfig(e){let t=this.activeMainIndicators.has(e),n=this.mainIndicatorParams[e];switch(e){case`MA`:this.indicatorScheduler.updateMAConfig({ma5:t,ma10:t,ma20:t,ma30:t,ma60:t});break;case`BOLL`:t?this.indicatorScheduler.updateBOLLConfig(n):this.indicatorScheduler.updateBOLLConfig({...n,showUpper:!1,showMiddle:!1,showLower:!1,showBand:!1});break;case`EXPMA`:t&&this.indicatorScheduler.updateEXPMAConfig(n);break;case`ENE`:t&&this.indicatorScheduler.updateENEConfig(n);break}}setActiveMainIndicators(e){let t=new Set(e.map(e=>e.toUpperCase())),n=new Set(this.activeMainIndicators);for(let e of n)t.has(e)||this.disableMainIndicator(e);for(let e of t)n.has(e)||this.enableMainIndicator(e)}constructor(e,t){this.dom=e;let{kWidth:n,kGap:r,...i}=t;this.opt={...i,kWidth:n??0,kGap:r??0},this.interaction=new $n(this),this.markerManager=new Ht,this.pluginHost=ge(),this.rendererPluginManager=new ke,this.sharedWebGLSurface=new er,this.rendererPluginManager.setPluginHost(this.pluginHost),this.rendererPluginManager.setInvalidateCallback(()=>this.scheduleDraw()),this.syncPaneRatiosFromSpecs(this.opt.panes),this.zoomLevelCount=Math.max(2,Math.round(this.opt.zoomLevels??20)),this.currentZoomLevel=this.opt.initialZoomLevel??1,this.currentZoomLevel=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel)),this.indicatorScheduler=new ia,this.indicatorScheduler.setPluginHost(this.pluginHost),this.indicatorScheduler.setInvalidateCallback(()=>this.scheduleDraw()),this.subPaneManager=new Ko,this.indicatorScheduler.setActiveSubPaneProvider(()=>this.subPaneManager.getPaneIds()),this.initPanes(),this.useRenderer(hs({store:this.drawingStore})),this.initResizeObserver()}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){this.cachedScrollLeft=e.scrollLeft,this.onScroll=()=>{this.cachedScrollLeft=e.scrollLeft},e.addEventListener(`scroll`,this.onScroll,{passive:!0}),this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let n=this.observedSize.width,r=this.observedSize.height,i=this.preciseDpr;this.updateObservedMetrics(t);let a=this.observedSize.width!==n,o=this.observedSize.height!==r,s=this.preciseDpr!==i;(a||o||s)&&this.resize()});try{this.resizeObserver.observe(e,{box:`device-pixel-content-box`})}catch{this.resizeObserver.observe(e)}}}updateObservedMetrics(e){let t=Math.max(1,Math.round(e.contentRect.width)),n=Math.max(1,Math.round(e.contentRect.height));this.observedSize.width=t,this.observedSize.height=n;let r=e.devicePixelContentBoxSize?.[0],i=e.contentBoxSize?.[0];if(!r||!i||i.inlineSize<=0){this.preciseDpr=0;return}let a=r.inlineSize/i.inlineSize;this.preciseDpr=Math.round(a*64)/64}getEffectiveDpr(){let e=this.preciseDpr>0?this.preciseDpr:Math.round((window.devicePixelRatio||1)*64)/64;return e<1&&(e=1),e}getViewport(){return this.viewport}getCurrentDpr(){return this.getEffectiveDpr()}getCachedScrollLeft(){return this.cachedScrollLeft}get plugin(){return this.pluginHost}useRenderer(e,t){this.rendererPluginManager.register(e),t&&e.setConfig&&e.setConfig(t)}removeRenderer(e){this.rendererPluginManager.unregister(e)}getRenderer(e){return this.rendererPluginManager.getPlugin(e)}updateRendererConfig(e,t){this.rendererPluginManager.updateConfig(e,t)}setRendererEnabled(e,t){this.rendererPluginManager.setEnabled(e,t)}getAllRenderers(){return this.rendererPluginManager.getAllPlugins()}updateSettings(e){this.settings={...e},this.interaction.updateSettings(e);let t=e.logarithmicScale?`log`:`linear`;for(let e of this.paneRenderers)e.getPane().yAxis.setScaleType(t);this.scheduleDraw()}draw(e=H.All){this.markerManager.clear();let t=this.prepareFrameData(e);if(!t)return;let{vp:n,range:r,kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s,useCachedFrame:c}=t;this.interaction.setKLinePositions(i,r,s),this.indicatorScheduler.setActiveMainIndicators(Array.from(this.activeMainIndicators));let l=c?null:this.indicatorScheduler.getMainIndicatorPriceRange(),u=this.interaction.getCrosshairIndex()!==null,{sharedXAxisLabels:d,sharedXAxisRanges:f}=this.renderPanes(n,r,i,a,o,s,l,u,c,e);this.overlayHadCrosshair=u,this.renderXAxis(n,r,i,a,o,s,d,f)}prepareFrameData(e){let t=e===H.Overlay&&this.cachedDrawFrame!==null,n=t?this.cachedDrawFrame.viewport:this.computeViewport();if(!n||this.data.length===0)return null;let r=t?this.cachedDrawFrame.range:(()=>{let{start:e,end:t}=ve(n.scrollLeft,n.plotWidth,this.opt.kWidth,this.opt.kGap,this.data.length,n.dpr);return{start:e,end:t}})();!t&&(r.start!==this.lastVisibleRange.start||r.end!==this.lastVisibleRange.end)&&(this.indicatorScheduler.updateVisibleRange(r),this.lastVisibleRange=r);let i=t?this.cachedDrawFrame.kLinePositions:this.calcKLinePositions(r),a,o,s;if(t)a=this.cachedDrawFrame.kLineCenters,o=this.cachedDrawFrame.kBarRects,s=this.cachedDrawFrame.kWidthPx;else{let e=B(this.opt.kWidth,this.opt.kGap,n.dpr),t=Math.max(1,e.unitPx-1);t%2==0&&--t,a=Array(i.length),o=Array(i.length);for(let r=0;r<i.length;r++){let s=i[r],c=Math.round(s*n.dpr)+(e.kWidthPx-1)/2;a[r]=c/n.dpr;let l=c-(t-1)/2;o[r]={x:l/n.dpr,width:t/n.dpr}}s=B(this.opt.kWidth,this.opt.kGap,n.dpr).kWidthPx,this.cachedDrawFrame={viewport:{...n},range:{...r},kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s}}return{vp:n,range:r,kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s,useCachedFrame:t}}renderPanes(e,t,n,r,i,a,o,s,c,l){let u=[],d=[],f=[],p=[];for(let a of this.paneRenderers){let m=a.getPane(),{mainCtx:h,overlayCtx:g,yAxisCtx:_}=a.getContexts(),{candleSurface:v,lineSurface:y}=a.getWebGL();if(!c){let e=m.role===`price`?o:null;m.updateRange(this.data,t,e)}let b=l===H.Main||l===H.All,x=(l===H.Overlay||l===H.All)&&(s||this.overlayHadCrosshair);if(b&&h&&(h.setTransform(1,0,0,1,0,0),h.scale(e.dpr,e.dpr),h.clearRect(0,0,e.plotWidth+1,m.height+2/e.dpr),v?.clear(),y?.clear()),x&&g){let t=g.canvas.width/e.dpr;g.setTransform(1,0,0,1,0,0),g.scale(e.dpr,e.dpr),g.clearRect(0,0,t+1,m.height+2/e.dpr)}if(_&&!c){let t=_.canvas.width/e.dpr;_.setTransform(1,0,0,1,0,0),_.scale(e.dpr,e.dpr),_.clearRect(0,0,t,m.height+2/e.dpr)}let S={ctx:h,overlayCtx:g??void 0,pane:ue(m),data:this.data,range:t,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:n,kLineCenters:r,kBarRects:i,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:_??void 0,candleWebGLSurface:v??void 0,lineWebGLSurface:y??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},settings:this.settings,yAxisLabels:u,xAxisLabels:d,yAxisRanges:f,xAxisRanges:p},C=this.rendererPluginManager.render(m.id,S,l);C.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:C});let w=this.rendererPluginManager.renderPlugin(`yAxis`,S);w.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:w})}return{sharedXAxisLabels:d,sharedXAxisRanges:p}}renderXAxis(e,t,n,r,i,a,o,s){let c=this.xAxisCtx??this.dom.xAxisCanvas.getContext(`2d`);if(this.xAxisCtx||=c,c){let a={ctx:c,pane:{id:`xAxis`,role:`auxiliary`,capabilities:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1},top:0,height:this.opt.bottomAxisHeight,yAxis:{priceToY:()=>0,yToPrice:()=>0,getPaddingTop:()=>0,getPaddingBottom:()=>0,getPriceOffset:()=>0,getDisplayRange:e=>e??{maxPrice:0,minPrice:0},getScaleType:()=>`linear`},priceRange:{maxPrice:0,minPrice:0}},data:this.data,range:t,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:n,kLineCenters:r,kBarRects:i,xAxisCtx:c,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},yAxisLabels:[],xAxisLabels:o,xAxisRanges:s},l=this.rendererPluginManager.renderPlugin(`timeAxis`,a);l.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:l})}}applyRenderState(e,t,n){let r=n===void 0?this.currentZoomLevel:Math.max(1,Math.min(this.zoomLevelCount,n));(this.opt.kWidth!==e||this.opt.kGap!==t||this.currentZoomLevel!==r)&&(this.opt={...this.opt,kWidth:e,kGap:t},n!==void 0&&(this.currentZoomLevel=r),this.scheduleDraw())}getZoomLevelCount(){return this.zoomLevelCount}setOnViewportChange(e){this.onViewportChange=e}setOnPaneLayoutChange(e){this.onPaneLayoutChange=e}setOnDataChange(e){this.onDataChange=e}getPaneRenderers(){return this.paneRenderers}getMarkerManager(){return this.markerManager}updateCustomMarkers(e){this.markerManager.setCustomMarkers(e),this.scheduleDraw()}clearCustomMarkers(){this.markerManager.clearCustomMarkers(),this.scheduleDraw()}getDom(){return this.dom}getOption(){return this.opt}calcKLinePositions(e){let{start:t,end:n}=e,r=n-t;if(r<=0)return[];let i=this.getEffectiveDpr(),{unitPx:a,startXPx:o}=B(this.opt.kWidth,this.opt.kGap,i),s=Array(r);for(let e=0;e<r;e++)s[e]=(o+(t+e)*a)/i;return s}updateOptions(e){if(e.kWidth!==void 0&&(console.warn(`[Chart] kWidth cannot be set directly. Use applyRenderState() instead.`),delete e.kWidth),e.kGap!==void 0&&delete e.kGap,e.panes){let t=e.panes.map(e=>({...e}));this.opt={...this.opt,...e,panes:t},this.applyPaneLayoutSpecs(t);return}this.opt={...this.opt,...e},this.resize()}updatePaneLayout(e){this.applyPaneLayoutSpecs(e)}setPaneDefinitions(e){this.applyPaneLayoutSpecs(e)}upsertPane(e){let t=this.opt.panes.findIndex(t=>t.id===e.id);if(t===-1){this.applyPaneLayoutSpecs([...this.opt.panes,{...e}]);return}let n=[...this.opt.panes];n[t]={...n[t],...e},this.applyPaneLayoutSpecs(n)}removePaneDefinition(e){this.opt.panes.some(t=>t.id===e)&&(this.paneRatios.delete(e),this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>t.id!==e)))}bindIndicatorToPane(e,t,n){this.opt.panes.some(t=>t.id===e)||this.upsertPane({id:e,ratio:1,visible:!0,role:`indicator`});let r=`${t.toLowerCase()}_${e}`;if(this.getRenderer(r)){n&&this.updateRendererConfig(r,n);return}let i=uo({indicatorId:t,paneId:e});this.useRenderer(i,n)}setDrawings(e){this.drawingStore.setAll(e),this.scheduleDraw()}setSelectedDrawingId(e){this.drawingStore.getSelectedId()!==e&&(this.drawingStore.setSelectedId(e),this.scheduleDraw())}getPaneLayoutSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;return this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0,r=e.visible===!1?n:n/t,i=this.paneRenderers.find(t=>t.getPane().id===e.id)?.getPane();return{...e,ratio:r,role:i?.role??e.role,capabilities:i?{...i.capabilities}:e.capabilities}})}emitPaneLayoutChange(){this.onPaneLayoutChange?.(this.getPaneLayoutSpecs())}applyPaneLayoutSpecs(e){this.opt.panes=e.map(e=>({...e})),this.syncPaneRatiosFromSpecs(this.opt.panes),this.initPanes(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw()}resizePaneBoundary(e,t){if(!Number.isFinite(t)||t===0)return!1;let n=this.viewport;if(!n)return!1;let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.findIndex(t=>t.id===e);if(i<0||i>=r.length-1)return!1;let a=r[i],o=r[i+1];if(!a||!o)return!1;let s=new Map;for(let e of r){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);t&&s.set(e.id,t.getPane().height)}let c=t>0?i:i+1,l=t>0?i+1:i,u=t>0?1:-1,d=Math.abs(t),f=l;for(;d>0&&f>=0&&f<r.length;){let e=r[f];if(!e)break;let t=s.get(e.id)??0,i=this.getPaneMinHeight(e,n.plotHeight),a=Math.max(0,t-i);if(a>0){let n=Math.min(a,d);s.set(e.id,t-n),d-=n}d>0&&(f+=u)}if(d>0)return!1;let p=r[c];if(!p)return!1;let m=s.get(p.id)??0;s.set(p.id,m+Math.abs(t));let h=Math.max(0,this.opt.paneGap??0)*Math.max(0,r.length-1),g=Math.max(1,n.plotHeight-h);for(let e of r){let t=s.get(e.id)??0;this.paneRatios.set(e.id,t/g)}return this.normalizeVisiblePaneRatios(r),this.syncPaneRatiosToSpecs(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw(),!0}resolvePaneRole(e,t){return e.role?e.role:t===0?`price`:`indicator`}addPane(e){if(this.opt.panes.some(t=>t.id===e)){console.warn(`Pane "${e}" already exists`);return}let t=this.opt.panes.some((e,t)=>this.resolvePaneRole(e,t)===`price`)?`indicator`:`price`;this.applyPaneLayoutSpecs([...this.opt.panes,{id:e,ratio:1,visible:!0,role:t}])}removePane(e){if(!this.opt.panes.some(t=>t.id===e))return;let t=this.opt.panes.filter(t=>t.id!==e);this.paneRatios.delete(e),this.applyPaneLayoutSpecs(t)}hasPane(e){return this.opt.panes.some(t=>t.id===e)}createSubPane(e,t,n){let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.filter((e,t)=>this.resolvePaneRole(e,t)===`price`),a=r.filter((e,t)=>this.resolvePaneRole(e,t)===`indicator`);if(i.length===1){let t=i[0];t&&this.paneRatios.set(t.id,3);for(let e of a)this.paneRatios.set(e.id,1);this.paneRatios.set(e,1)}else this.paneRatios.set(e,1);return this.upsertPane({id:e,ratio:this.paneRatios.get(e)??1,visible:!0,role:`indicator`}),this.subPaneManager.create(this,e,t,n??this.getDefaultSubPaneParams(t))}removeSubPane(e){this.subPaneManager.remove(this,e),this.paneRatios.delete(e)}replaceSubPaneIndicator(e,t,n){this.subPaneManager.replaceIndicator(this,e,t,n??this.getDefaultSubPaneParams(t))}updateSubPaneParams(e,t){this.subPaneManager.updateParams(this,e,t)}clearSubPanes(){let e=this.subPaneManager.getPaneIds();if(e.length!==0){this.subPaneManager.clear(this);for(let t of e)this.paneRatios.delete(t);this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>!e.includes(t.id)))}}getSubPaneIndicators(){return this.subPaneManager.getAll().map(e=>e.indicatorId)}getSubPaneEntries(){return this.subPaneManager.getAll()}getSubPaneEntry(e){return this.subPaneManager.getByPaneId(e)}getDefaultSubPaneParams(e){return{...{VOLUME:{},MACD:{fastPeriod:12,slowPeriod:26,signalPeriod:9},RSI:{period1:6,period2:12,period3:24},CCI:{period:14,showCCI:!0},STOCH:{n:9,m:3,showK:!0,showD:!0},MOM:{period:10,showMOM:!0},WMSR:{period:14,showWMSR:!0},KST:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},FASTK:{period:9,showFASTK:!0},ATR:{period:14,showATR:!0}}[e]}}static SUB_PANE_PREFIX=`sub_`;translatePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();if(!r.capabilities.supportsPriceTranslate)return;let i=r.yAxis.deltaYToPriceOffset(t),a=r.yAxis.getPriceOffset();r.yAxis.setPriceOffset(a+i),this.scheduleDraw()}resetPriceOffset(e){let t=this.paneRenderers.find(t=>t.getPane().id===e);t&&(t.getPane().yAxis.resetPriceOffset(),this.scheduleDraw())}scalePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();r.capabilities.supportsPriceTranslate&&(r.yAxis.scaleByDelta(t),this.scheduleDraw())}updateData(e){this.data=e??[],this.onDataChange?.(this.data);let t=this.dom.container;if(t){let e=this.getContentWidth(),n=Math.max(0,e-t.clientWidth);this.cachedScrollLeft>n&&(t.scrollLeft=n,this.cachedScrollLeft=n)}this.interaction.reset(),this.indicatorScheduler.update(this.data,this.lastVisibleRange),this.scheduleDraw()}getData(){return this.data}getIndicatorScheduler(){return this.indicatorScheduler}getTrailingSlotCount(){return 24}getLogicalSlotCount(){return this.data.length+this.getTrailingSlotCount()}getTimestampAtLogicalIndex(e){return!Number.isInteger(e)||e<0||e>=this.data.length?null:this.data[e]?.timestamp??null}getLogicalIndexAtX(e){let t=this.viewport;if(!t||this.data.length===0)return null;let n=this.getEffectiveDpr(),{startXPx:r,unitPx:i}=B(this.opt.kWidth,this.opt.kGap,n),a=Math.round((t.scrollLeft+e)*n),o=Math.floor((a-r)/i);return o<0?null:o}getDataIndexAtX(e){let t=this.getLogicalIndexAtX(e);return t===null||t>=this.data.length?null:t}getContentWidth(){return mr({dataLength:this.data.length,kWidth:this.opt.kWidth,kGap:this.opt.kGap,viewWidth:this.viewport?.plotWidth??0,viewportDpr:this.getEffectiveDpr()})}resize(){let e=this.computeViewport();!e||e.viewWidth<10||e.viewHeight<10||(this.cachedDrawFrame=null,this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw())}scheduleDraw(e=H.All){if(this.raf!==null){if(this.pendingUpdateLevel===H.All)return;if(e===H.All){this.pendingUpdateLevel=H.All;return}if(this.pendingUpdateLevel===H.Main&&e===H.Overlay||this.pendingUpdateLevel===H.Overlay&&e===H.Main){this.pendingUpdateLevel=H.All;return}return}this.pendingUpdateLevel=e,this.raf=requestAnimationFrame(()=>{this.raf=null;let e=this.pendingUpdateLevel;this.pendingUpdateLevel=H.All,this.draw(e)})}async destroy(){this.raf!==null&&(cancelAnimationFrame(this.raf),this.raf=null),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.preciseDpr=0,this.observedSize={width:0,height:0},this.onScroll&&=(this.dom.container?.removeEventListener(`scroll`,this.onScroll),void 0),this.viewport=null,this.cachedDrawFrame=null,this.xAxisCtx=null,this.paneRenderers.forEach(e=>e.destroy()),this.paneRenderers=[],this.sharedWebGLSurface.destroy(),this.rendererPluginManager.clear(),this.onViewportChange=void 0,this.onPaneLayoutChange=void 0,this.indicatorScheduler.destroy(),await this.pluginHost.destroy()}initPanes(){this.paneRenderers=this.opt.panes.map((e,t)=>{let n=new De(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=document.createElement(`canvas`),o=n.role===`price`;return r.id=`${e.id}-main`,r.className=o?`main-canvas main`:`main-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-overlay`,i.className=`overlay-canvas`,i.style.position=`absolute`,i.style.left=`0`,i.style.top=`0`,i.style.pointerEvents=`none`,i.style.backgroundColor=`transparent`,a.id=`${e.id}-yAxis`,a.className=`right-axis`,a.style.position=`absolute`,a.style.left=`0`,new pr({mainCanvas:r,overlayCanvas:i,yAxisCanvas:a},n,{rightAxisWidth:this.opt.rightAxisWidth,yPaddingPx:this.opt.yPaddingPx,priceLabelWidth:this.opt.priceLabelWidth},this.sharedWebGLSurface)});let e=this.dom.canvasLayer,t=this.dom.rightAxisLayer;e&&e.querySelectorAll(`canvas:not(.x-axis-canvas)`).forEach(e=>e.remove()),t&&t.querySelectorAll(`canvas.right-axis`).forEach(e=>e.remove()),this.paneRenderers.forEach(n=>{let r=n.getDom();e.appendChild(r.mainCanvas),e.appendChild(r.overlayCanvas),t.appendChild(r.yAxisCanvas)}),this.rendererPluginManager.setKnownPaneIds(this.paneRenderers.map(e=>e.getPane().id))}syncPaneRatiosFromSpecs(e){let t=new Map;for(let n of e){let e=this.paneRatios.get(n.id),r=Number.isFinite(n.ratio)?n.ratio:0,i=e===void 0?r>0?r:1:e;t.set(n.id,i)}this.paneRatios=t,this.normalizeVisiblePaneRatios(e),this.syncPaneRatiosToSpecs()}syncPaneRatiosToSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this.paneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;this.opt.panes=this.opt.panes.map(e=>{let n=this.paneRatios.get(e.id)??e.ratio??0;return e.visible===!1?{...e,ratio:n}:{...e,ratio:n/t}})}normalizeVisiblePaneRatios(e){let t=e.filter(e=>e.visible!==!1);if(t.length===0)return;let n=0;for(let e of t){let t=this.paneRatios.get(e.id)??e.ratio??0,r=Number.isFinite(t)&&t>0?t:0;this.paneRatios.set(e.id,r),n+=r}if(n<=0){let e=1/t.length;for(let n of t)this.paneRatios.set(n.id,e);return}for(let e of t){let t=this.paneRatios.get(e.id)??0;this.paneRatios.set(e.id,t/n)}}getPaneMinHeight(e,t){let n=this.opt.defaultPaneMinHeightPx??120,r=e.minHeightPx??n;return Math.max(1,Math.min(Math.round(r),Math.max(1,t)))}computePaneHeightsByRatio(e,t){if(e.length===0)return[];let n=e.map(e=>this.paneRatios.get(e.id)??e.ratio??0),r=n.reduce((e,t)=>e+(t>0?t:0),0),i=(r>0?n.map(e=>(e>0?e:0)/r):e.map(()=>1/e.length)).map(e=>Math.max(1,Math.round(t*e))),a=e.map(e=>this.getPaneMinHeight(e,t));for(let e=0;e<i.length;e++)i[e]=Math.max(i[e],Math.min(a[e],t));let o=i.reduce((e,t)=>e+t,0);if(o>t){let e=o-t;for(;e>0;){let n=!1;for(let r=i.length-1;r>=0&&e>0;r--){let o=Math.max(1,Math.min(a[r],t)),s=i[r];s>o&&(i[r]=s-1,e--,n=!0)}if(!n)break}}else o<t&&(i[i.length-1]=(i[i.length-1]??1)+(t-o));return o=i.reduce((e,t)=>e+t,0),o!==t&&i.length>0&&(i[i.length-1]=Math.max(1,(i[i.length-1]??1)+(t-o))),i}layoutPanes(){let e=this.viewport;if(!e)return;let t=this.opt.panes.filter(e=>e.visible!==!1);if(t.length===0)return;let n=Math.max(0,this.opt.paneGap??0),r=0,i=n*Math.max(0,t.length-1),a=Math.max(1,e.plotHeight-i);this.normalizeVisiblePaneRatios(t);let o=this.computePaneHeightsByRatio(t,a);for(let i=0;i<t.length;i++){let a=t[i];if(!a)continue;let s=this.paneRenderers.find(e=>e.getPane().id===a.id);if(!s)continue;let c=s.getPane(),l=o[i]??1;c.setLayout(r,l),c.setPadding(this.opt.yPaddingPx,this.opt.yPaddingPx),s.resize(e.plotWidth,l,e.dpr),s.setWebGLRegion({x:0,y:r,width:e.plotWidth,height:l,dpr:e.dpr}),this.rendererPluginManager.notifyResize(c.id,ue(c));let u=s.getDom();u.mainCanvas.style.top=`${r}px`,u.overlayCanvas.style.top=`${r}px`,u.yAxisCanvas.style.top=`${r}px`,u.yAxisCanvas.style.left=`0px`,r+=l+n}let s=Math.max(1,a);for(let e of t){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);if(!t)continue;let n=t.getPane().height;this.paneRatios.set(e.id,n/s)}this.normalizeVisiblePaneRatios(t),this.syncPaneRatiosToSpecs()}computeViewport(){let e=this.dom.container;if(!e)return null;let t=this.observedSize.width,n=this.observedSize.height,r=t>0?t:Math.max(1,Math.round(e.clientWidth)),i=n>0?n:Math.max(1,Math.round(e.clientHeight)),a=Math.round(r),o=Math.round(i-this.opt.bottomAxisHeight),s=this.getEffectiveDpr(),c=16*1024*1024;r*s*(i*s)>c&&(s=Math.sqrt(c/(r*i)));let l=Math.round(this.cachedScrollLeft*s)/s,u=`${r}px`;this.dom.canvasLayer.style.width!==u&&(this.dom.canvasLayer.style.width=u);let d=`${i}px`;this.dom.canvasLayer.style.height!==d&&(this.dom.canvasLayer.style.height=d);let f=Math.round(a*s);this.dom.xAxisCanvas.width!==f&&(this.dom.xAxisCanvas.width=f);let p=Math.round(this.opt.bottomAxisHeight*s);this.dom.xAxisCanvas.height!==p&&(this.dom.xAxisCanvas.height=p);let m=`${f/s}px`;this.dom.xAxisCanvas.style.width!==m&&(this.dom.xAxisCanvas.style.width=m);let h=`${p/s}px`;this.dom.xAxisCanvas.style.height!==h&&(this.dom.xAxisCanvas.style.height=h),this.sharedWebGLSurface.resize(a,o,s);let g={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},_=this.viewport,v=!_||_.viewWidth!==g.viewWidth||_.viewHeight!==g.viewHeight||_.plotWidth!==g.plotWidth||_.plotHeight!==g.plotHeight||_.scrollLeft!==g.scrollLeft||_.dpr!==g.dpr;return this.viewport=g,v&&this.onViewportChange?.(g),g}},vs=3;function ys(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function bs(e,t){let n=Math.round(e*t);return Math.max(1,Math.min(vs,Math.round(n*.6)))/t}function xs(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,r+e));if(s===r)return null;let c=ys(s,o),l=bs(c,o.dpr),u=B(i,a,o.dpr),d=B(c,l,o.dpr),f=(Math.round((n+t)*o.dpr)-u.startXPx)/u.unitPx;return{targetLevel:s,newKWidth:c,newKGap:l,newScrollLeft:(d.startXPx+f*d.unitPx)/o.dpr-t}}function Ss(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,Math.round(e)))-r;return s===0?null:xs(s,t,n,r,i,a,o)}function Cs(e){return e.open>e.close?`down`:e.open<e.close?`up`:`flat`}var $=function(e){return e.RISE_WITH_VOLUME=`rise_with_volume`,e.RISE_WITHOUT_VOLUME=`rise_without_volume`,e.FALL_WITH_VOLUME=`fall_with_volume`,e.FALL_WITHOUT_VOLUME=`fall_without_volume`,e.OTHERS=`others`,e}({}),ws={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},Ts=class{prefixSum=[];dataLength=0;build(e){let t=e.length;if(t===0){this.prefixSum=[],this.dataLength=0;return}this.prefixSum=[0];for(let n=0;n<t;n++)this.prefixSum.push(this.prefixSum[n]+(e[n]?.volume??0));this.dataLength=t}query(e,t){return e<0||t>=this.dataLength||e>t?0:this.prefixSum[t+1]-this.prefixSum[e]}getVolumeMA(e,t){if(e<t-1)return 0;let n=e-t+1;return this.query(n,e)/t}get length(){return this.dataLength}};function Es(e,t,n,r=ws){let i=new Ts;i.build(e);let a=[],{volumeAmplifyThreshold:o,volumeShrinkThreshold:s,avgPeriod:c}=r;for(let r=t;r<n&&r<e.length;r++){let t=e[r]?.volume;if(r<1||!t){a.push($.OTHERS);continue}let n=i.getVolumeMA(r,c),l=e[r];if(!l){a.push($.OTHERS);continue}let u=l.close-l.open,d=u>0,f=u<0,p=t>n*o,m=t<n*s;d&&p?a.push($.RISE_WITH_VOLUME):d&&m?a.push($.RISE_WITHOUT_VOLUME):f&&p?a.push($.FALL_WITH_VOLUME):f&&m?a.push($.FALL_WITHOUT_VOLUME):a.push($.OTHERS)}return a}function Ds(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:R.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u,settings:d}=e,f=r;if(!f.length)return;let p=Os({pane:n,data:f,range:i,kWidth:o,kGap:s,dpr:c,kLinePositions:l,settings:d});As(e,p)?js(t,e):ks(t,a,p),Ms(e,p,u)}}}function Os(e){let{pane:t,data:n,range:r,kWidth:i,kGap:a,dpr:o,kLinePositions:s,settings:c}=e,{kWidthPx:l}=B(i,a,o),u=c?.showVolumePriceMarkers!==!1,d=u?Es(n,r.start,r.end,ws):null,f=[],p=[],m=Math.max(1,r.end-r.start),h=new Float32Array(m*4),g=new Float32Array(m*4),_=new Float32Array(m*2*4),v=new Float32Array(m*2*4),y=0,b=0,x=0,S=0,{maxPrice:C,minPrice:w}=t.yAxis.getDisplayRange(),T=t.yAxis.getPaddingTop(),E=t.yAxis.getPaddingBottom(),D=Math.max(1,t.height-T-E),O=t.yAxis.getScaleType()!==`log`,k;if(O){let e=D/(C-w||1),t=T+D;k=n=>t-(n-w)*e}else k=e=>t.yAxis.priceToY(e);for(let e=r.start;e<r.end&&e<n.length;e++){let t=n[e];if(!t)continue;let i=k(t.open),a=k(t.close),c=k(t.high),u=k(t.low),d=s[e-r.start];if(d===void 0)continue;let m=e=>Math.round(e*o)/o,C=m(i),w=m(a),T=m(c),E=m(u),D=Math.min(C,w),O=Math.max(Math.abs(C-w),1),A=We(Math.round(d*o),D,l,O,o),j=Cs(t),M={i:e,aligned:A,trend:j,openY:i,closeY:a,highY:c,lowY:u,alignedHighY:T,alignedLowY:E,e:t},N=A.bodyRect,P=j===`up`?f:p,F=j===`up`;if(P.push(M),F){let e=y++*4;h[e]=N.x,h[e+1]=N.y,h[e+2]=N.width,h[e+3]=N.height}else{let e=b++*4;g[e]=N.x,g[e+1]=N.y,g[e+2]=N.width,g[e+3]=N.height}let I=N.y,L=N.y+N.height,ee=Math.max(t.open,t.close),te=Math.min(t.open,t.close);if(t.high>ee){let e=He(A.wickRect.x,T,I,o);if(e){let t=F?_:v,n=(F?x++:S++)*4;t[n]=e.x,t[n+1]=e.y,t[n+2]=e.width,t[n+3]=e.height}}if(t.low<te){let e=He(A.wickRect.x,L,E,o);if(e){let t=F?_:v,n=(F?x++:S++)*4;t[n]=e.x,t[n+1]=e.y,t[n+2]=e.width,t[n+3]=e.height}}}let A=f[0]?.aligned.wickRect.width??p[0]?.aligned.wickRect.width??1;return{upKLines:f,downKLines:p,upBodyBuf:h,upBodyCount:y,downBodyBuf:g,downBodyCount:b,upWickBuf:_,upWickCount:x,downWickBuf:v,downWickCount:S,wickWidth:A,relations:d,showVolumePriceMarkers:u}}function ks(e,t,n){e.save(),e.translate(-t,0),e.fillStyle=U.UP;for(let t=0;t<n.upBodyCount;t++){let r=t*4;e.fillRect(n.upBodyBuf[r],n.upBodyBuf[r+1],n.upBodyBuf[r+2],n.upBodyBuf[r+3])}e.fillStyle=U.DOWN;for(let t=0;t<n.downBodyCount;t++){let r=t*4;e.fillRect(n.downBodyBuf[r],n.downBodyBuf[r+1],n.downBodyBuf[r+2],n.downBodyBuf[r+3])}e.fillStyle=U.UP;for(let t=0;t<n.upWickCount;t++){let r=t*4;e.fillRect(n.upWickBuf[r],n.upWickBuf[r+1],n.wickWidth,n.upWickBuf[r+3])}e.fillStyle=U.DOWN;for(let t=0;t<n.downWickCount;t++){let r=t*4;e.fillRect(n.downWickBuf[r],n.downWickBuf[r+1],n.wickWidth,n.downWickBuf[r+3])}e.restore()}function As(e,t){if(e.settings?.enableWebGLRendering===!1)return!1;let n=e.candleWebGLSurface;if(!n||!n.isAvailable())return!1;n.clear();let r=t.upBodyCount===0||n.drawRectBuffer(t.upBodyBuf.subarray(0,t.upBodyCount*4),t.upBodyCount,U.UP,e.scrollLeft),i=t.downBodyCount===0||n.drawRectBuffer(t.downBodyBuf.subarray(0,t.downBodyCount*4),t.downBodyCount,U.DOWN,e.scrollLeft),a=t.upWickCount===0||n.drawRectBuffer(t.upWickBuf.subarray(0,t.upWickCount*4),t.upWickCount,U.UP,e.scrollLeft),o=t.downWickCount===0||n.drawRectBuffer(t.downWickBuf.subarray(0,t.downWickCount*4),t.downWickCount,U.DOWN,e.scrollLeft);return r&&i&&a&&o}function js(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function Ms(e,t,n){let{ctx:r,range:i,kWidth:a,dpr:o}=e;if(!(!t.showVolumePriceMarkers||!n||(e.zoomLevel??1)<2)){r.save(),r.translate(-e.scrollLeft,0);for(let s of t.upKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];Ns(r,u,t,c,s.i,a,4,n,o)}}for(let s of t.downKLines){let c=t.relations?.[s.i-i.start];if(c!==void 0&&c!==$.OTHERS){let t=c===$.RISE_WITH_VOLUME||c===$.RISE_WITHOUT_VOLUME?s.alignedHighY-15:s.alignedLowY+15,l=s.i-i.start,u=e.kLineCenters[l];Ns(r,u,t,c,s.i,a,4,n,o)}}r.restore()}}function Ns(e,t,n,r,i,a,o=4,s,c){let l=e=>Math.round(e*c)/c;t=l(t),n=l(n);let u=Math.min(a,20),d=u*Math.sqrt(3)/2,f,p;switch(r){case $.RISE_WITH_VOLUME:f=`#FF4444`,p=!0;break;case $.RISE_WITHOUT_VOLUME:f=`#00C853`,p=!0;break;case $.FALL_WITH_VOLUME:f=`#FF4444`,p=!1;break;case $.FALL_WITHOUT_VOLUME:f=`#00C853`,p=!1;break;default:return}if(e.save(),e.beginPath(),p){let r=l(n-o),i=l(r-d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}else{let r=l(n+o),i=l(r+d);e.moveTo(t,i),e.lineTo(l(t-u/2),r),e.lineTo(l(t+u/2),r)}e.closePath(),e.fillStyle=f,e.fill(),e.restore();let m,h;if(p){let e=l(l(n-o)-d);m=l(t-u/2),h=e}else{let e=l(n+o);l(e+d),m=l(t-u/2),h=e}let g;switch(r){case $.RISE_WITH_VOLUME:g=`RISE_WITH_VOLUME`;break;case $.RISE_WITHOUT_VOLUME:g=`RISE_WITHOUT_VOLUME`;break;case $.FALL_WITH_VOLUME:g=`FALL_WITH_VOLUME`;break;case $.FALL_WITHOUT_VOLUME:g=`FALL_WITHOUT_VOLUME`;break;default:return}let _=`mk_price-volume_${i}`;s.register({id:_,type:`triangle`,markerType:g,x:m,y:h,width:u,height:d,dataIndex:i,metadata:{relation:r}})}function Ps(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:de,priority:R.GRID,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,dpr:s,kLinePositions:c}=e,l=r;if(!l.length)return;t.save(),t.fillStyle=W.HORIZONTAL,t.translate(-a,0);let u=t.canvas.width/s,d=a,f=a+u,p=n.yAxis.getPaddingTop(),m=n.yAxis.getPaddingBottom(),h=n.yAxis.getScaleType(),g;if(h===`log`&&n.role===`price`){let e=n.yAxis.getDisplayRange(n.priceRange);g=xo({height:n.height,paddingTop:p,paddingBottom:m,isMain:!0,valueMin:e.minPrice,valueMax:e.maxPrice,scaleType:`log`}).map(e=>e.y)}else g=po({height:n.height,paddingTop:p,paddingBottom:m,isMain:n.role===`price`}).map(e=>e.y);for(let e of g){let n=Ue(d,f,e,s);n&&t.fillRect(n.x,n.y,n.width,n.height)}let _=pt(l);for(let e of _){if(e<i.start||e>=i.end||e>=l.length)continue;let r=e-i.start;if(r<0||r>=c.length)continue;let a=He(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function Fs(e){let{pane:t,data:n}=e,r=n,i=r[r.length-1];if(!i)return null;let a=t.yAxis.getDisplayRange(t.priceRange);return i.close<a.minPrice||i.close>a.maxPrice?null:{price:i.close,y:Math.round(t.yAxis.priceToY(i.close)),dataIndex:r.length-1}}function Is(){return{name:`lastPriceLabelRegistrar`,version:`1.0.0`,description:`最新价 label 注册`,debugName:`最新价标签注册`,paneId:`main`,layer:`overlay`,priority:R.LAST_PRICE_LABEL,draw(e){let t=Fs(e);t&&(e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:t.dataIndex,price:t.price,y:t.y,type:`lastPrice`,style:{bgColor:`rgba(255, 247, 248, 0.98)`,borderColor:U.LAST_PRICE,textColor:U.LAST_PRICE}}))}}}function Ls(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:R.LAST_PRICE_LABEL,draw(e){let{ctx:t,scrollLeft:n,dpr:r,kLinePositions:i,paneWidth:a}=e,o=Fs(e);if(!o)return;let s=o.y;t.save(),t.translate(-n,0);let c=i[0]??0,l=a+n;t.strokeStyle=U.LAST_PRICE,t.lineWidth=1,t.setLineDash([4,3]),t.beginPath();let u=(Math.floor(s*r)+.5)/r;t.moveTo(Math.round(c*r)/r,u),t.lineTo(Math.round(l*r)/r,u),t.stroke(),t.setLineDash([]),t.restore()}}}var Rs={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n,r,i)=>t===null?null:Ra(t,n.fastPeriod??12,n.slowPeriod??26,n.signalPeriod??9,r,i)},RSI:{defaultParams:{period1:6,period2:12,period3:24},getTitleInfo:(e,t,n,r,i)=>t===null?null:Va(t,n.period1??6,n.period2??12,n.period3??24,r,i)},CCI:{defaultParams:{period:14,showCCI:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:Wa(t,n.period??14,r,i)},STOCH:{defaultParams:{n:9,m:3,showK:!0,showD:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:qa(t,n.n??9,n.m??3,r,i)},MOM:{defaultParams:{period:10,showMOM:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:Xa(t,n.period??10,r,i)},WMSR:{defaultParams:{period:14,showWMSR:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:$a(t,n.period??14,r,i)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:no(t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9,r,i)},FASTK:{defaultParams:{period:9,showFASTK:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:ao(t,n.period??9,r,i)},ATR:{defaultParams:{period:14,showATR:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:lo(t,n.period??14,r,i)}},zs=Object.keys(Rs);function Bs(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:de,priority:R.SYSTEM_YAXIS,draw(t){let{ctx:n,pane:r,dpr:i,yAxisCtx:a,data:o}=t,s=r.yAxis.getScaleType(),c=a||n,l=a?.canvas?a.canvas.width/i:e.axisWidth,u=r.yAxis.getDisplayRange(r.priceRange);if(r.capabilities.showPriceAxisTicks&&No({ctx:c,dpr:i,axisWidth:l,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:u.minPrice,valueMax:u.maxPrice,isMain:!0,decimals:2,hideEdgeTicks:!1,scaleType:s}),t.yAxisRanges&&r.role===`price`)for(let e of t.yAxisRanges){let t=e.topY+r.top,n=e.bottomY-e.topY;n<=0||(c.save(),c.globalAlpha=e.opacity,c.fillStyle=e.color,c.fillRect(0,t,l,n),c.restore())}if(t.yAxisLabels&&r.role===`price`)for(let e of t.yAxisLabels){let t=e.type===`lastPrice`;ko(c,{x:0,y:r.top,width:l,height:r.height,priceY:e.y+r.top,price:e.price,dpr:i,bgColor:e.style?.bgColor??`rgba(0, 0, 0, 0.8)`,borderColor:e.style?.borderColor,textColor:e.style?.textColor??`#ffffff`,fontSize:t?12:11})}let d=e.getCrosshair?.();d&&d.activePaneId===r.id&&d.price!==null&&Do(c,{x:0,y:r.top,width:l,height:r.height,crosshairY:d.y,priceRange:u,yPaddingPx:e.yPaddingPx,dpr:i,fontSize:12,priceOffset:0,price:d.price})}}}var Vs=Symbol(`time-axis`);function Hs(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:Vs,priority:R.SYSTEM_XAXIS,isSystem:!0,draw(t){let{ctx:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,paneWidth:l}=t,u=r,d=n,f=l,p=e.height;if(d.setTransform(1,0,0,1,0,0),d.scale(c,c),d.clearRect(0,0,f,p),Oo(d,{x:0,y:0,width:f,height:p,data:u,scrollLeft:a,kWidth:o,kGap:s,startIndex:i.start,endIndex:i.end,dpr:c,drawTopBorder:!1,drawBottomBorder:!1}),t.xAxisRanges)for(let e of t.xAxisRanges){let t=e.leftX-a,n=e.rightX-a-t;n<=0||(d.save(),d.globalAlpha=e.opacity,d.fillStyle=e.color,d.fillRect(t,0,n,p),d.restore())}let m=e.getCrosshair?.();if(m&&typeof m.index==`number`){let e=u[m.index];e&&Eo(d,{x:0,y:0,width:f,height:p,crosshairX:m.x,timestamp:e.timestamp,dpr:c,fontSize:12})}if(t.xAxisLabels)for(let e of t.xAxisLabels){let t=e.x-a;t>=0&&t<=f&&Ao(d,{x:0,y:0,width:f,height:p,labelX:t,timestamp:e.timestamp,dpr:c,fontSize:12,bgColor:e.style?.bgColor,textColor:e.style?.textColor})}}}}function Us(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:de,priority:R.SYSTEM_CROSSHAIR,layer:`overlay`,draw(t){let{pane:n,dpr:r,paneWidth:i,overlayCtx:a}=t,o=e.getCrosshairState();if(o.isDragging||!o.pos)return;let{x:s}=o.pos,c=n.id===o.activePaneId,l=-1;c&&o.price!==null&&(l=n.yAxis.priceToY(o.price));let u=a;if(!u)return;u.save(),u.beginPath(),u.rect(0,0,i,n.height),u.clip(),u.fillStyle=Ve.LINE;let d=He(s,0,n.height,r);if(d&&u.fillRect(d.x,d.y,d.width,d.height),c&&l>=0){let e=Ue(0,i,Math.min(l,n.height-1/r),r);e&&u.fillRect(e.x,e.y,e.width,e.height)}u.restore()}}}var Ws=new Map,Gs=256;function Ks(e,t){let n=`${e.font}\n${t}`,r=Ws.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Ws.size>=Gs&&Ws.clear(),Ws.set(n,i),i}function qs(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:R.FOREGROUND,draw(e){let{ctx:n,pane:r}=e;if(r.id!==t.paneId)return;let i=t.yOffset??12;n.save(),Oa(n,Da(12)),n.textAlign=`left`,n.textBaseline=`top`;let a=t.getTitleInfo?.();if(a){let e=12;if(n.fillStyle=Ae.PRIMARY,n.fillText(a.name,e,i),e+=Ks(n,a.name),a.params&&a.params.length>0){let t=`(${a.params.join(`,`)})`;n.fillStyle=Ae.TERTIARY,n.fillText(t,e,i),e+=Ks(n,t)+8}else e+=8;if(a.values&&a.values.length>0)for(let t of a.values){let r=`${t.label} ${t.value.toFixed(3)}`;n.fillStyle=t.color,n.fillText(r,e,i),e+=Ks(n,r)+8}}else if(n.fillStyle=Ae.PRIMARY,n.fillText(t.title,12,i),t.description){let e=Ks(n,t.title);n.fillStyle=Ae.WEAK,n.fillText(` - ${t.description}`,12+e,i)}n.restore()},setConfig(e){t={...t,...e}}}}var Js={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Ys(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Js,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7.904 17.563a1.2 1.2 0 0 0 2.228.308l2.09-3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047-1.047a1.067 1.067 0 0 0 0-1.509l-4.907-4.907l3.113-2.09a1.2 1.2 0 0 0-.309-2.228L4 4z`},null,-1)]])}var Xs=(0,e.markRaw)({name:`tabler-pointer`,render:Ys}),Zs={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Qs(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Zs,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 19h16M4 15l4-6l4 2l4-5l4 4`},null,-1)]])}var $s=(0,e.markRaw)({name:`tabler-chart-line`,render:Qs}),ec={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function tc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,ec,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 7L7 17M8 7h9v9`},null,-1)]])}var nc=(0,e.markRaw)({name:`tabler-arrow-up-right`,render:tc}),rc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ic(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,rc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14m-6 6l6-6m-6-6l6 6`},null,-1)]])}var ac=(0,e.markRaw)({name:`tabler-arrow-right`,render:ic}),oc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function sc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,oc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14`},null,-1)]])}var cc=(0,e.markRaw)({name:`tabler-minus`,render:sc}),lc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function uc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,lc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12v.01M7 12h10m4 0v.01`},null,-1)]])}var dc=(0,e.markRaw)({name:`tabler-separator`,render:uc}),fc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function pc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,fc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2M9 12h6m-3-3v6`},null,-1)]])}var mc=(0,e.markRaw)({name:`tabler-crosshair`,render:pc}),hc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function gc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,hc,[...n[0]||=[(0,e.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0m9-3h.01`}),(0,e.createElementVNode)(`path`,{d:`M11 12h1v4h1`})],-1)]])}var _c=(0,e.markRaw)({name:`tabler-info-circle`,render:gc}),vc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function yc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,vc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2`},null,-1)]])}var bc=(0,e.markRaw)({name:`tabler-maximize`,render:yc}),xc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Sc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,xc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5`},null,-1)]])}var Cc=(0,e.markRaw)({name:`tabler-minimize`,render:Sc}),wc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Tc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,wc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m-3-3v6m11 8l-6-6`},null,-1)]])}var Ec=(0,e.markRaw)({name:`tabler-zoom-in`,render:Tc}),Dc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Oc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Dc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m8 11l-6-6`},null,-1)]])}var kc=(0,e.markRaw)({name:`tabler-zoom-out`,render:Oc}),Ac={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function jc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Ac,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M5 7v10M7 5h10M7 19h10m2-12v10`},null,-1)]])}var Mc=(0,e.markRaw)({name:`tabler-shape`,render:jc}),Nc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Pc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Nc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 7a2 2 0 1 0 4 0a2 2 0 1 0-4 0m11 8a2 2 0 1 0 4 0a2 2 0 1 0-4 0m1-9a3 3 0 1 0 6 0a3 3 0 1 0-6 0M3 18a3 3 0 1 0 6 0a3 3 0 1 0-6 0m6-1l5-1.5m-7.5-7l7.81 5.37M7 7l8-1`},null,-1)]])}var Fc=(0,e.markRaw)({name:`tabler-chart-dots-3`,render:Pc}),Ic={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Lc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Ic,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m18 10l-6-6l-6 6zm0 4l-6 6l-6-6z`},null,-1)]])}var Rc=(0,e.markRaw)({name:`tabler-caret-up-down`,render:Lc}),zc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Bc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,zc,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var Vc=(0,e.markRaw)({name:`tabler-brackets`,render:Bc}),Hc={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Uc(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Hc,[...n[0]||=[(0,e.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065`}),(0,e.createElementVNode)(`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0`})],-1)]])}var Wc=(0,e.markRaw)({name:`tabler-settings`,render:Uc});function Gc(){if(typeof navigator>`u`)return`desktop`;let e=navigator.userAgentData;if(e?.formFactor){let t=e.formFactor;if(t===`phone`)return`mobile`;if(t===`tablet`)return`tablet`;if(t===`desktop`)return`desktop`}if(e?.mobile===!0)return`mobile`;e?.mobile;let t=navigator.userAgent.toLowerCase();if(/android.*mobile|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile/i.test(t))return`mobile`;let n=navigator.maxTouchPoints>1,r=window.screen.width>=768&&window.screen.width<=1366;return n&&r?`tablet`:`desktop`}var Kc=[{key:`showVolumePriceMarkers`,label:`显示量价关系标记`,type:`boolean`,default:!1,group:`main`},{key:`logarithmicScale`,label:`对数价格轴`,type:`boolean`,default:!1,group:`main`},{key:`disableMainPaneVerticalScroll`,label:`主图纵轴刻度自适应调整`,type:`boolean`,default:!0,group:`main`},{key:`enableWebGLRendering`,label:`启用 WebGL 硬件加速渲染`,type:`boolean`,default:Gc()===`desktop`,group:`main`},{key:`performanceTest10kKlines`,label:`万条K线性能测试`,type:`boolean`,default:!1,group:`experimental`},{key:`enableCanvasProfiler`,label:`Canvas 性能分析插桩`,type:`boolean`,default:!1,group:`experimental`}],qc=`kline-chart-settings`;function Jc(){return Object.create(null)}function Yc(){return{ctxMethods:Jc(),ctxProps:Jc(),canvasProps:Jc(),ctxMethodSources:Object.create(null)}}function Xc(e,t,n){let r=e[t]??={count:0,totalTime:0};r.count+=1,r.totalTime+=n}function Zc(e,t,n,r){Xc(e.ctxMethodSources[t]??=Jc(),n,r)}function Qc(e){return Object.entries(e).filter(([,e])=>e.count>0).map(([e,t])=>({name:e,count:t.count,totalTime:t.totalTime.toFixed(2),averageTime:(t.totalTime/t.count).toFixed(4)})).sort((e,t)=>Number(t.totalTime)-Number(e.totalTime))}var $c=!1,el=new Map,tl=new Map;function nl(e){$c=e,e?typeof window<`u`&&!window.__KMAP_CANVAS_PROFILER_INSTALLED__&&ol():sl()}function rl(){if(!$c)return`disabled`;let e=Error().stack;if(!e)return`unknown`;let t=e.split(`
|
|
49
|
-
`).map(e=>e.trim()).filter(Boolean);for(let e of t){if(e.includes(`canvasProfiler`)||e.includes(`CanvasRenderingContext2D`)||e===`Error`)continue;let t=e.replace(/^at\s+/,``),n=t.match(/((?:src|node_modules)[^\s)]+):(\d+):(\d+)/);if(n)return`${n[1]}:${n[2]}`;let r=t.match(/\(([^)]+):(\d+):(\d+)\)$/);return r?`${r[1]}:${r[2]}`:t}return`unknown`}function il(e,t,n,r){let i=`${e.constructor?.name??`proto`}:${t}`;if(el.has(i))return;let a=Reflect.get(e,t);typeof a==`function`&&(el.set(i,a),Reflect.set(e,t,function(...e){if(!$c)return a.apply(this,e);let i=r?.captureSource?rl():null,o=performance.now(),s=a.apply(this,e),c=performance.now()-o;return Xc(n.ctxMethods,t,c),i&&Zc(n,t,i,c),s}))}function al(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);if(!r?.set||!r.configurable)return;let i=`${e.constructor?.name??`proto`}:${t}`;tl.has(i)||(tl.set(i,r),Object.defineProperty(e,t,{configurable:!0,enumerable:r.enumerable??!1,get:r.get,set(e){if(!$c){r.set.call(this,e);return}let i=performance.now();r.set.call(this,e),Xc(n,t,performance.now()-i)}}))}function ol(){if(typeof window>`u`||window.__KMAP_CANVAS_PROFILER_INSTALLED__)return;let e=CanvasRenderingContext2D?.prototype,t=HTMLCanvasElement?.prototype;if(!e||!t)return;let n=Yc();il(e,`fillText`,n,{captureSource:!0}),il(e,`measureText`,n,{captureSource:!0}),il(e,`drawImage`,n),il(e,`save`,n),il(e,`restore`,n),il(e,`clip`,n),il(e,`setTransform`,n),il(e,`scale`,n),al(e,`font`,n.ctxProps),al(e,`filter`,n.ctxProps),al(e,`shadowBlur`,n.ctxProps),al(e,`lineWidth`,n.ctxProps),al(t,`width`,n.canvasProps),al(t,`height`,n.canvasProps),window.__KMAP_CANVAS_PROFILER_METRICS__=n,window.__KMAP_CANVAS_PROFILER_INSTALLED__=!0,window.showCanvasReport=()=>{let e=window.__KMAP_CANVAS_PROFILER_METRICS__;if(e){console.group(`[kmap] Canvas profiler report`),console.log(`ctx methods`),console.table(Qc(e.ctxMethods)),console.log(`ctx props`),console.table(Qc(e.ctxProps)),console.log(`canvas props`),console.table(Qc(e.canvasProps));for(let t of[`fillText`,`measureText`]){let n=e.ctxMethodSources[t];n&&(console.log(`${t} sources`),console.table(Qc(n).slice(0,20)))}console.groupEnd()}},window.resetCanvasReport=()=>{window.__KMAP_CANVAS_PROFILER_METRICS__=Yc()},console.info(`[kmap] Canvas profiler enabled. Use window.showCanvasReport() and window.resetCanvasReport().`)}function sl(){if(typeof window>`u`||!window.__KMAP_CANVAS_PROFILER_INSTALLED__)return;let e=CanvasRenderingContext2D?.prototype,t=HTMLCanvasElement?.prototype;el.forEach((n,r)=>{let i=r.match(/^(.+):(.+)$/);if(!i)return;let[,a,o]=i,s=null;a===`CanvasRenderingContext2D`?s=e:a===`HTMLCanvasElement`&&(s=t),s&&Reflect.set(s,o,n)}),el.clear(),tl.forEach((n,r)=>{let i=r.match(/^(.+):(.+)$/);if(!i)return;let[,a,o]=i,s=null;a===`CanvasRenderingContext2D`?s=e:a===`HTMLCanvasElement`&&(s=t),s&&n.configurable&&Object.defineProperty(s,o,n)}),tl.clear(),window.__KMAP_CANVAS_PROFILER_INSTALLED__=!1,window.__KMAP_CANVAS_PROFILER_METRICS__=void 0,window.showCanvasReport=void 0,window.resetCanvasReport=void 0,console.info(`[kmap] Canvas profiler disabled.`)}var cl={class:`left-toolbar`,"aria-label":`图表工具栏`},ll={class:`left-toolbar__group`},ul=[`title`,`aria-label`,`onClick`],dl=[`onClick`],fl=[`title`,`aria-label`,`onClick`],pl={class:`left-toolbar__group`},ml={class:`left-toolbar__group`},hl=[`title`,`aria-label`],gl={class:`left-toolbar__group`},_l={class:`settings-body`},vl={class:`settings-label`},yl=[`onUpdate:modelValue`],bl=[`onUpdate:modelValue`],xl=[`value`],Sl={class:`settings-label`},Cl=[`onUpdate:modelValue`],wl=[`onUpdate:modelValue`],Tl=[`value`],El=zt((0,e.defineComponent)({__name:`LeftToolbar`,props:{isFullscreen:{type:Boolean}},emits:[`selectTool`,`toggleFullscreen`,`zoomIn`,`zoomOut`,`settingsChange`],setup(t,{expose:n,emit:r}){let i=r,a=[{id:`cursor`,title:`光标`,icon:Xs},{id:`lines`,title:`线条`,icon:$s,children:[{id:`trend-line`,title:`线段`,icon:$s},{id:`ray`,title:`射线`,icon:nc},{id:`h-line`,title:`水平线`,icon:cc},{id:`h-ray`,title:`水平射线`,icon:ac},{id:`v-line`,title:`垂直线`,icon:dc},{id:`crosshair-line`,title:`十字线`,icon:mc},{id:`info-line`,title:`信息线`,icon:_c}]},{id:`channels`,title:`通道`,icon:Mc,children:[{id:`parallel-channel`,title:`平行通道`,icon:Mc},{id:`regression-channel`,title:`回归趋势`,icon:Fc},{id:`flat-line`,title:`平滑顶底`,icon:Rc},{id:`disjoint-channel`,title:`不相交通道`,icon:Vc}]}],o=(0,e.computed)(()=>Kc.filter(e=>e.group===`main`)),s=(0,e.computed)(()=>Kc.filter(e=>e.group===`experimental`)),c=(0,e.ref)(`cursor`),l=(0,e.ref)(null),u=(0,e.ref)(!1),d=qt();function f(){try{let e=localStorage.getItem(qc);if(e){let t=JSON.parse(e),n={};return Kc.forEach(e=>{n[e.key]=t[e.key]??e.default}),n}}catch{}let e={};return Kc.forEach(t=>{e[t.key]=t.default}),e}function p(e){try{localStorage.setItem(qc,JSON.stringify(e))}catch{}}let m=(0,e.ref)(f()),h=(0,e.ref)({...m.value});function g(e){return c.value===e.id?!0:e.children?e.children.some(e=>e.id===c.value):!1}function _(e){if(e.children?.length){if(!e.children.some(e=>e.id===c.value)){let t=e.children[0];c.value=t.id,i(`selectTool`,t.id)}y(e.id);return}c.value=e.id,i(`selectTool`,e.id),l.value=null}function v(e){c.value=e.id,i(`selectTool`,e.id),l.value=null}function y(e){l.value=l.value===e?null:e}function b(){h.value={...m.value},u.value=!0}function x(){u.value=!1}function S(){let e={};Kc.forEach(t=>{e[t.key]=t.default}),h.value=e}function C(){m.value={...h.value},p(m.value),nl(!!m.value.enableCanvasProfiler),i(`settingsChange`,{...m.value}),x()}function w(){return{...m.value}}n({getSettings:w});function T(e){e.target.closest(`.tool-item`)||(l.value=null)}return(0,e.onMounted)(()=>{document.addEventListener(`click`,T,!0),i(`settingsChange`,{...m.value}),nl(!!m.value.enableCanvasProfiler)}),(0,e.onUnmounted)(()=>{document.removeEventListener(`click`,T,!0)}),(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,[(0,e.createElementVNode)(`nav`,cl,[(0,e.createElementVNode)(`div`,ll,[((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(a,t=>(0,e.createElementVNode)(`div`,{key:t.id,class:`tool-item`},[(0,e.createElementVNode)(`button`,{type:`button`,class:(0,e.normalizeClass)([`left-toolbar__button`,{active:g(t)}]),title:t.title,"aria-label":t.title,onClick:e=>_(t),onPointerdown:r[0]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[1]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[2]||=(0,e.withModifiers)(()=>{},[`stop`])},[((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.icon),{class:`tool-icon`,"aria-hidden":`true`})),t.children&&t.children.length?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,class:(0,e.normalizeClass)([`corner-indicator`,{open:l.value===t.id}]),onClick:(0,e.withModifiers)(e=>y(t.id),[`stop`]),"aria-label":`展开子菜单`},null,10,dl)):(0,e.createCommentVNode)(``,!0)],42,ul),(0,e.createVNode)(e.Transition,{name:`dropdown`},{default:(0,e.withCtx)(()=>[l.value===t.id&&t.children&&t.children.length?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`tool-dropdown`,onPointerdown:r[3]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[4]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[5]||=(0,e.withModifiers)(()=>{},[`stop`])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.children,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,type:`button`,class:(0,e.normalizeClass)([`left-toolbar__button`,{active:c.value===t.id}]),title:t.title,"aria-label":t.title,onClick:e=>v(t)},[((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,fl))),128))],32)):(0,e.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),r[22]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,pl,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`放大`,"aria-label":`放大`,onClick:r[6]||=e=>n.$emit(`zoomIn`),onPointerdown:r[7]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[8]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[9]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(Ec),{class:`tool-icon`,"aria-hidden":`true`})],32),(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`缩小`,"aria-label":`缩小`,onClick:r[10]||=e=>n.$emit(`zoomOut`),onPointerdown:r[11]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[12]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[13]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(kc),{class:`tool-icon`,"aria-hidden":`true`})],32)]),r[23]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,ml,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:t.isFullscreen?`退出全屏`:`全屏显示`,"aria-label":t.isFullscreen?`退出全屏`:`全屏显示`,onClick:r[14]||=e=>n.$emit(`toggleFullscreen`),onPointerdown:r[15]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[16]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[17]||=(0,e.withModifiers)(()=>{},[`stop`])},[t.isFullscreen?((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(Cc),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(bc),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,hl)]),r[24]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,gl,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`设置`,"aria-label":`设置`,onClick:b,onPointerdown:r[18]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[19]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[20]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(Wc),{class:`tool-icon`,"aria-hidden":`true`})],32)])]),((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(d)},[(0,e.createVNode)(e.Transition,{name:`overlay`},{default:(0,e.withCtx)(()=>[u.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`settings-overlay`,onClick:x},[(0,e.createVNode)(e.Transition,{name:`modal`},{default:(0,e.withCtx)(()=>[(0,e.createElementVNode)(`div`,{class:`settings-modal`,onClick:r[21]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,{class:`settings-header`},[r[26]||=(0,e.createElementVNode)(`div`,{class:`header-left`},[(0,e.createElementVNode)(`span`,{class:`settings-title`},`图表设置`),(0,e.createElementVNode)(`span`,{class:`settings-subtitle`},`个性化配置`)],-1),(0,e.createElementVNode)(`div`,{class:`header-right`},[(0,e.createElementVNode)(`button`,{class:`settings-close`,onClick:x},[...r[25]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,e.createElementVNode)(`div`,_l,[o.value.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:0},[r[27]||=(0,e.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,e.createElementVNode)(`span`,{class:`settings-section-label`},`主图设置`)],-1),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(o.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:`settings-item`},[(0,e.createElementVNode)(`label`,vl,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.label),1),t.type===`boolean`?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":e=>h.value[t.key]=e},null,8,yl)),[[e.vModelCheckbox,h.value[t.key]]]):t.type===`select`&&t.options?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`select`,{key:1,class:`settings-select`,"onUpdate:modelValue":e=>h.value[t.key]=e},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.options,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`option`,{key:t.value,value:t.value},(0,e.toDisplayString)(t.label),9,xl))),128))],8,bl)),[[e.vModelSelect,h.value[t.key]]]):(0,e.createCommentVNode)(``,!0)])]))),128))],64)):(0,e.createCommentVNode)(``,!0),s.value.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:1},[r[28]||=(0,e.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,e.createElementVNode)(`span`,{class:`settings-section-label`},`实验性 / 调试设置`)],-1),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(s.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:`settings-item experimental`},[(0,e.createElementVNode)(`label`,Sl,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.label),1),t.type===`boolean`?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":e=>h.value[t.key]=e},null,8,Cl)),[[e.vModelCheckbox,h.value[t.key]]]):t.type===`select`&&t.options?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`select`,{key:1,class:`settings-select`,"onUpdate:modelValue":e=>h.value[t.key]=e},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.options,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`option`,{key:t.value,value:t.value},(0,e.toDisplayString)(t.label),9,Tl))),128))],8,wl)),[[e.vModelSelect,h.value[t.key]]]):(0,e.createCommentVNode)(``,!0)])]))),128))],64)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,{class:`settings-footer`},[(0,e.createElementVNode)(`button`,{class:`settings-btn reset`,onClick:S},[...r[29]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,e.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,e.createTextVNode)(` 重置 `,-1)]]),(0,e.createElementVNode)(`div`,{class:`footer-right`},[(0,e.createElementVNode)(`button`,{class:`settings-btn cancel`,onClick:x},`取消`),(0,e.createElementVNode)(`button`,{class:`settings-btn confirm`,onClick:C},[...r[30]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,e.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,e.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))],64))}}),[[`__scopeId`,`data-v-20a39cb3`]]),Dl={class:`chart-wrapper`},Ol={class:`pane-separator-layer`,"aria-hidden":`true`},kl=4,Al=zt((0,e.defineComponent)({__name:`KLineChart`,props:{semanticConfig:{},yPaddingPx:{default:0},minKWidth:{default:1},maxKWidth:{default:50},rightAxisWidth:{default:0},bottomAxisHeight:{default:24},priceLabelWidth:{default:60},zoomLevels:{default:20},initialZoomLevel:{default:3},isFullscreen:{type:Boolean,default:!1}},emits:[`zoomLevelChange`,`toggleFullscreen`],setup(t,{expose:n,emit:r}){let i=t,a=r,o=(0,e.ref)(null),s=(0,e.ref)(null),c=(0,e.ref)(null),l=(0,e.ref)(null),u=(0,e.ref)(null),d=(0,e.ref)(null),f=(0,e.ref)(null),p=(0,e.shallowRef)(null),m=(0,e.shallowRef)(null),h=hr({initialZoomLevel:i.initialZoomLevel??1,minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevels:i.zoomLevels,rightAxisWidth:i.rightAxisWidth,priceLabelWidth:i.priceLabelWidth});h.actions.setZoomState(h.state.zoomLevel,ys(h.state.zoomLevel,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:h.state.viewportDpr}),bs(ys(h.state.zoomLevel,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:h.state.viewportDpr}),h.state.viewportDpr)),(0,e.computed)(()=>h.state.dataLength),(0,e.computed)(()=>h.state.viewportDpr);let g=(0,e.computed)(()=>h.state.zoomLevel),_=(0,e.computed)(()=>h.state.kWidth),v=(0,e.computed)(()=>h.state.kGap),y=(0,e.computed)(()=>h.state.paneRatios),b=(0,e.computed)(()=>h.state.selectedDrawingId),x=(0,e.computed)(()=>h.state.dataVersion);function S(){p.value?.scheduleDraw()}function C(e){if(p.value?.updateSettings(e),e.performanceTest10kKlines){let e=w();console.time(`updateData-10k`),p.value?.updateData(e),console.timeEnd(`updateData-10k`),h.actions.setDataLength(e.length),h.actions.bumpDataVersion()}else m.value&&p.value?.getData()?.length===1e4&&m.value.applyConfig(i.semanticConfig)}function w(){let e=[],t=new Date(`2020-01-01`).getTime(),n=3e3;for(let r=0;r<1e4;r++){let i=t+r*864e5,a=(Math.random()-.5)*2*.02+1e-4,o=n,s=o*(1+a),c=Math.max(o,s)*(1+Math.random()*.01),l=Math.min(o,s)*(1-Math.random()*.01),u=Math.floor(1e6+Math.random()*5e6);e.push({timestamp:i,open:parseFloat(o.toFixed(2)),high:parseFloat(c.toFixed(2)),low:parseFloat(l.toFixed(2)),close:parseFloat(s.toFixed(2)),volume:u}),n=s}return e}function T(e,t,n){let r=e.getBoundingClientRect();return{width:Math.max(t,Math.round(r.width)),height:Math.max(n,Math.round(r.height))}}function E(t){t&&(0,e.nextTick)(()=>{if(!t.isConnected)return;let e=T(t,180,80);p.value?.interaction.setTooltipSize(e)})}function D(t){t&&(0,e.nextTick)(()=>{t.isConnected&&(ee.value=T(t,120,60))})}let O=(0,e.ref)({x:0,y:0}),k=(0,e.ref)(!1),A=null;function j(){A=null}function N(e){return A||=e.getBoundingClientRect(),A}let P=(0,e.shallowRef)({crosshairPos:null,crosshairIndex:null,crosshairPrice:null,hoveredIndex:null,activePaneId:null,tooltipPos:{x:0,y:0},tooltipAnchorPlacement:`right-bottom`,hoveredMarkerData:null,hoveredCustomMarker:null,isDragging:!1,isResizingPaneBoundary:!1,isHoveringPaneBoundary:!1,hoveredPaneBoundaryId:null,isHoveringRightAxis:!1}),F=(0,e.shallowRef)(null),I=(0,e.computed)(()=>{let e=b.value;return e?h.state.drawings.find(t=>t.id===e)??null:null}),L=(0,e.ref)([]),ee=(0,e.ref)({width:220,height:120}),te=(0,e.computed)(()=>{let e=l.value,t=u.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),ne=(0,e.computed)(()=>P.value.hoveredMarkerData),re=(0,e.computed)(()=>P.value.hoveredCustomMarker),ie=(0,e.computed)(()=>P.value.isDragging),ae=(0,e.computed)(()=>P.value.isResizingPaneBoundary),oe=(0,e.computed)(()=>P.value.isHoveringPaneBoundary),se=(0,e.computed)(()=>P.value.hoveredPaneBoundaryId),ce=(0,e.computed)(()=>P.value.isHoveringRightAxis),le=(0,e.computed)(()=>P.value.hoveredIndex),ue=(0,e.computed)(()=>P.value.crosshairIndex),de=(0,e.computed)(()=>ie.value?`grabbing`:ae.value||oe.value?`ns-resize`:le.value===null?`crosshair`:`pointer`),R=(0,e.computed)(()=>{let e=P.value.hoveredIndex;if(typeof e!=`number`)return null;x.value;let t=p.value?.getData();return t&&e>=0&&e<t.length?t[e]:null}),fe=(0,e.computed)(()=>P.value.hoveredIndex),pe=(0,e.computed)(()=>P.value.tooltipPos),z=(0,e.computed)(()=>({x:pe.value.x+te.value.x,y:pe.value.y+te.value.y})),me=(0,e.computed)(()=>({left:`${z.value.x}px`,top:`${z.value.y}px`})),he=(0,e.computed)(()=>({x:O.value.x+te.value.x,y:O.value.y+te.value.y})),ge=(0,e.computed)(()=>({left:`${he.value.x}px`,top:`${he.value.y}px`})),_e=(0,e.computed)(()=>P.value.tooltipAnchorPlacement),ve=(0,e.computed)(()=>{let e=p.value?.getViewport(),t=l.value,n=e?.plotWidth??(t?t.clientWidth:0);return O.value.x+12+ee.value.width+12>n?`left-bottom`:`right-bottom`}),ye=(0,e.computed)(()=>(x.value,p.value?.getData()??[]));function be(e){F.value?.setTool(e)}function xe(e){let t=I.value;!t||!F.value||(F.value.updateDrawingStyle(t.id,e),h.actions.bumpDrawingVersion())}function V(){let e=I.value;!e||!F.value||(F.value.removeDrawing(e.id),h.actions.setSelectedDrawingId(null),h.actions.bumpDrawingVersion(),h.actions.setDrawings(F.value.getDrawings()))}function Se(e){let t=l.value;if(t){if(F.value?.onPointerDown(e,t)){h.actions.setDrawings(F.value.getDrawings()),h.actions.bumpDrawingVersion();return}p.value?.interaction.onPointerDown(e)}}function Ce(e){let t=l.value;if(t){let n=N(t);if(O.value={x:e.clientX-n.left,y:e.clientY-n.top},F.value?.onPointerMove(e,t)){h.actions.setDrawings(F.value.getDrawings());return}}p.value?.interaction.onPointerMove(e)}function we(e){let t=l.value;if(t&&F.value?.onPointerUp(e,t)){h.actions.setDrawings(F.value.getDrawings());return}p.value?.interaction.onPointerUp(e)}function Te(e){p.value?.interaction.onPointerLeave(e)}function H(e){p.value?.interaction.onRightAxisPointerDown(e)}function Ee(e){p.value?.interaction.onRightAxisPointerMove(e)}function De(e){p.value?.interaction.onRightAxisPointerUp(e)}function Oe(e){p.value?.interaction.onRightAxisPointerLeave(e)}function ke(){p.value?.interaction.onScroll()}let Ae=(0,e.ref)([]),U=(0,e.computed)(()=>{let e=[],t=new Set;for(let n of W.value)t.has(n.indicatorId)||(t.add(n.indicatorId),e.push(n.indicatorId));return e}),je=(0,e.computed)(()=>[...Ae.value,...U.value]),Me=(0,e.ref)({}),W=(0,e.ref)([]);function Ne(){let e=y.value.main??3;return W.value.length===0?[{id:`main`,ratio:e,visible:!0,role:`price`}]:[{id:`main`,ratio:e,visible:!0,role:`price`},...W.value.map(e=>({id:e.id,ratio:y.value[e.id]??1,visible:!0,role:`indicator`}))]}function G(e){return{...Rs[e].defaultParams}}let K=new Map;function Pe(e){let t=K.get(e)??0;return K.set(e,t+1),`${e}_${t}`}let q=new Map;function Fe(e,t){let n=qs({paneId:e,title:t,getTitleInfo:()=>X(e)});p.value?.useRenderer(n),q.set(e,n.name)}function Ie(e){let t=q.get(e);t&&(p.value?.removeRenderer(t),q.delete(e))}function Le(e=`VOLUME`,t){if(W.value.length>=kl)return!1;let n=Pe(e),r=t??G(e);return p.value?.createSubPane(n,e,r)?(Fe(n,e),W.value.push({id:n,indicatorId:e,params:r}),S(),!0):!1}function Re(e){let t=W.value.findIndex(t=>t.id===e);t!==-1&&W.value[t]&&(Ie(e),p.value?.removeSubPane(e),W.value.splice(t,1))}function ze(){for(let e of W.value)Ie(e.id);p.value?.clearSubPanes(),W.value=[],K.clear(),q.clear()}function Be(){let e=i.semanticConfig,t=p.value;if(!t)return;let n=e.indicators?.main;if(n)for(let e of n)e.enabled&&(Ae.value.includes(e.type)||Ae.value.push(e.type),e.params&&(Me.value[e.type]=e.params),t.enableMainIndicator(e.type,e.params))}(0,e.watch)([je,Me],([e])=>{let t=p.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:Me.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:Me.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:Me.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:Me.value.ENE||{}}}}),S())},{deep:!0});function J(){let e=p.value?.getSubPaneEntries()??[];W.value=[],q.clear();for(let t of e){let{paneId:e,indicatorId:n,params:r}=t,i=e.match(/^(.+)_(\d+)$/);if(i){let[,e,t]=i,n=parseInt(t,10);n>=(K.get(e)??0)&&K.set(e,n+1)}Fe(e,n),W.value.push({id:e,indicatorId:n,params:{...r}})}S()}function Ve(e,t){if(!W.value.find(t=>t.id===e))return;let n=G(t);Ie(e),p.value?.replaceSubPaneIndicator(e,t,n),Fe(e,t);let r=W.value.findIndex(t=>t.id===e);r!==-1&&(W.value[r]={id:e,indicatorId:t,params:n})}let Y=new Map;function X(e){let t=W.value.find(t=>t.id===e);if(!t)return null;let n=p.value?.getData();if(!n||n.length===0)return null;let r=ue.value,i=n.length,a=Y.get(e);if(a&&a.idx===r&&a.dataLen===i)return a.result;let o=Rs[t.indicatorId],s=t.params,c=p.value?.plugin,l=c?o.getTitleInfo(n,r,s,c,e):null;return Y.set(e,{idx:r,dataLen:i,result:l}),l}function He(e,t){let n=p.value;if(n){if(e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){n.toggleMainIndicator(e,t),t?Ae.value.includes(e)||Ae.value.push(e):Ae.value=Ae.value.filter(t=>t!==e);return}if(zs.includes(e)){if(t){if(W.value.find(t=>t.indicatorId===e))return;if(!Le(e)){let t=W.value[W.value.length-1];t&&Ve(t.id,e)}}else W.value.filter(t=>t.indicatorId===e).forEach(e=>Re(e.id));S()}}}function Ue(e,t){if(Me.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){p.value?.updateMainIndicatorParams(e,t),S();return}if(zs.includes(e)){W.value.filter(t=>t.indicatorId===e).forEach(e=>{p.value?.updateSubPaneParams(e.id,t),e.params={...t}}),S();return}S()}function We(e){if(!e.length||W.value.length<=1)return;let t=e.filter(e=>zs.includes(e));if(!t.length)return;let n=new Map(W.value.map(e=>[e.indicatorId,e])),r=[];for(let e of t){let t=n.get(e);t&&(r.push(t),n.delete(e))}if(r.length===0)return;for(let e of W.value)n.has(e.indicatorId)&&(r.push(e),n.delete(e.indicatorId));let i=W.value.map(e=>e.id),a=r.map(e=>e.id);if(i.join(`|`)===a.join(`|`))return;W.value=r;let o=p.value;o&&o.updatePaneLayout(Ne())}let Ge=(0,e.computed)(()=>i.rightAxisWidth+i.priceLabelWidth),Ke=h.computed.totalWidth;function qe(){let e=l.value,t=p.value;if(!e||!t)return;let n=t.getData()?.length??0;if(n===0)return;let r=t.getCurrentDpr(),{unitPx:i,startXPx:a}=B(_.value,v.value,r),o=(a+n*i)/r,s=Math.max(0,e.scrollWidth-e.clientWidth),c=Math.min(s,Math.max(0,o-e.clientWidth));e.scrollLeft=Math.round(c*r)/r,S()}function Je(t,n){let r=p.value,o=l.value;if(!r||!o)return;let s=r.getCurrentDpr(),c=Ss(t,n??(r.getViewport()?.plotWidth??o.clientWidth)/2,o.scrollLeft,g.value,_.value,v.value,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:s});c&&(h.actions.setZoomState(c.targetLevel,c.newKWidth,c.newKGap),r.interaction.clearHover(),(0,e.nextTick)(()=>{let e=l.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),n=Math.min(Math.max(0,c.newScrollLeft),t);e.scrollLeft=Math.round(n*s)/s,r.applyRenderState(c.newKWidth,c.newKGap,c.targetLevel),a(`zoomLevelChange`,c.targetLevel,c.newKWidth)}))}n({scheduleRender:S,scrollToRight:qe,addSubPane:Le,removeSubPane:Re,switchSubIndicator:Ve,clearAllSubPanes:ze,get plugin(){return p.value?.plugin},zoomToLevel:Je,zoomIn:e=>Je(g.value+1,e),zoomOut:e=>Je(g.value-1,e),getZoomLevel:()=>g.value,getZoomLevelCount:()=>p.value?.getZoomLevelCount()??10});function Xe(t){let n=n=>{n.preventDefault();let r=p.value;if(!r)return;let o=t.getBoundingClientRect(),s=n.clientX-o.left,c=t.scrollLeft,u=r.getCurrentDpr(),d=xs(n.deltaY>0?-1:1,s,c,g.value,_.value,v.value,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:u});d&&(h.actions.setZoomState(d.targetLevel,d.newKWidth,d.newKGap),r.interaction.clearHover(),(0,e.nextTick)(()=>{let e=l.value;if(!e)return;let t=Math.max(0,e.scrollWidth-e.clientWidth),n=Math.min(Math.max(0,d.newScrollLeft),t);e.scrollLeft=Math.round(n*u)/u,r.applyRenderState(d.newKWidth,d.newKGap,d.targetLevel),a(`zoomLevelChange`,d.targetLevel,d.newKWidth)}))};return t.addEventListener(`wheel`,n,{passive:!1}),n}function Ze(e,t,n,r){let a=new _s({container:e,canvasLayer:t,rightAxisLayer:n,xAxisCanvas:r},{yPaddingPx:i.yPaddingPx,rightAxisWidth:i.rightAxisWidth,bottomAxisHeight:i.bottomAxisHeight,priceLabelWidth:i.priceLabelWidth,minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,panes:[{id:`main`,ratio:1}],paneGap:0,zoomLevels:i.zoomLevels,initialZoomLevel:i.initialZoomLevel});return Qe(a),a}function Qe(e){e.useRenderer(Ps()),e.useRenderer(fa()),e.setRendererEnabled(`ma`,!1),e.useRenderer(va()),e.setRendererEnabled(`boll`,!1),e.useRenderer(ba()),e.setRendererEnabled(`expma`,!1),e.useRenderer(Ta()),e.setRendererEnabled(`ene`,!1),e.useRenderer(Ds()),e.useRenderer(Ls()),e.useRenderer(Is()),e.useRenderer(Ye());let t=i.rightAxisWidth+i.priceLabelWidth;e.useRenderer(Bs({axisWidth:t,yPaddingPx:i.yPaddingPx,getCrosshair:()=>{let t=e.interaction.crosshairPos,n=e.interaction.crosshairPrice,r=e.interaction.activePaneId;return t&&n!==null?{y:t.y,price:n,activePaneId:r}:null}})),e.useRenderer(Ma({yPaddingPx:i.yPaddingPx})),e.useRenderer(Us({getCrosshairState:()=>({pos:e.interaction.crosshairPos,activePaneId:e.interaction.activePaneId,isDragging:e.interaction.isDraggingState(),price:e.interaction.crosshairPrice})})),e.useRenderer(Hs({height:i.bottomAxisHeight,getCrosshair:()=>{let t=e.interaction.crosshairPos,n=e.interaction.crosshairIndex;return t&&n!==null?{x:t.x,index:n}:null}}))}function $e(e){e.setOnViewportChange(t=>{j(),h.state.viewportDpr!==t.dpr&&h.actions.setViewportDpr(t.dpr),h.state.viewWidth!==t.plotWidth&&h.actions.setViewWidth(t.plotWidth);let n=bs(h.state.kWidth,t.dpr);h.state.kGap!==n&&h.actions.setZoomState(h.state.zoomLevel,h.state.kWidth,n);let r=e.getOption();(r.kWidth!==h.state.kWidth||r.kGap!==n)&&e.applyRenderState(h.state.kWidth,n,h.state.zoomLevel)}),e.setOnPaneLayoutChange(t=>{j();let n={};for(let e of t)n[e.id]=e.ratio;h.actions.setPaneRatios(n);let r=e.getPaneRenderers(),i=l.value&&parseInt(getComputedStyle(l.value).borderTopWidth)||0;L.value=r.slice(0,-1).map(e=>{let t=e.getPane();return{id:t.id,top:t.top+t.height+i}})}),e.setOnDataChange(e=>{h.actions.setDataLength(e.length),h.actions.bumpDataVersion()})}function et(e){let t=f.value?.getSettings()??{showVolumePriceMarkers:!0};if(e.updateSettings(t),t.performanceTest10kKlines){let t=w();console.time(`updateData-10k`),e.updateData(t),console.timeEnd(`updateData-10k`),h.actions.setDataLength(t.length),h.actions.bumpDataVersion()}}function tt(e){F.value=new Yo(e),F.value.setCallbacks({onDrawingCreated:e=>{h.actions.setDrawings([...h.state.drawings,e]),h.actions.setSelectedDrawingId(e.id)},onToolChange:()=>{},onDrawingSelected:e=>{h.actions.setSelectedDrawingId(e?.id??null)}})}function nt(t){t.interaction.setTooltipAnchorPositioning(k.value),t.interaction.setOnInteractionChange(e=>{P.value=e}),t.interaction.setOnPinchZoom((n,r)=>{let o=l.value;if(!o||!t)return;let s=r-o.getBoundingClientRect().left,c=o.scrollLeft,u=t.getCurrentDpr(),d=xs(n,s,c,g.value,_.value,v.value,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:u});d&&(h.actions.setZoomState(d.targetLevel,d.newKWidth,d.newKGap),t.interaction.clearHover(),(0,e.nextTick)(()=>{let e=l.value;if(!e)return;let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,d.newScrollLeft),n);e.scrollLeft=Math.round(r*u)/u,t.applyRenderState(d.newKWidth,d.newKGap,d.targetLevel),a(`zoomLevelChange`,d.targetLevel,d.newKWidth)}))}),P.value=t.interaction.getInteractionSnapshot(),h.actions.setViewportDpr(t.getCurrentDpr()),t.resize()}function rt(t){m.value=new M(t),m.value.on(`config:error`,e=>{console.error(`Semantic config error:`,e)}),m.value.on(`config:ready`,()=>{h.actions.setDataLength(t.getData()?.length??0),h.actions.bumpDataVersion(),Be(),J(),(0,e.nextTick)(()=>qe())}),m.value.applyConfig(i.semanticConfig).then(e=>{e&&!e.success&&console.error(`Semantic config apply failed:`,e.errors)})}return(0,e.onMounted)(()=>{k.value=!1;let e=l.value,t=s.value,n=c.value,r=o.value;if(!e||!t||!n||!r)return;let i=Xe(e),a=Ze(e,t,n,r);p.value=a,$e(a),a.applyRenderState(h.state.kWidth,h.state.kGap,h.state.zoomLevel),et(a),tt(a),nt(a),rt(a),a.__onWheel=i}),(0,e.onUnmounted)(()=>{let e=p.value;if(e){let t=e.__onWheel,n=l.value;t&&n&&n.removeEventListener(`wheel`,t),e.destroy()}p.value=null,F.value=null}),(0,e.watch)(()=>i.yPaddingPx,e=>{p.value?.updateOptions({yPaddingPx:e})}),(0,e.watch)(()=>i.semanticConfig,async(e,t)=>{if(e&&e!==t){let t=await m.value?.applyConfig(e);t&&!t.success&&console.error(`Semantic config apply failed:`,t.errors)}},{deep:!0}),(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,Dl,[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`chart-stage`,{"is-dragging":ie.value,"is-resizing-pane":ae.value,"is-hovering-pane-separator":oe.value,"is-hovering-right-axis":ce.value,"is-hovering-kline":le.value!==null}])},[(0,e.createVNode)(El,{ref_key:`toolbarRef`,ref:f,"is-fullscreen":t.isFullscreen,onSelectTool:be,onToggleFullscreen:r[0]||=e=>n.$emit(`toggleFullscreen`),onZoomIn:r[1]||=e=>Je(g.value+1),onZoomOut:r[2]||=e=>Je(g.value-1),onSettingsChange:C},null,8,[`is-fullscreen`]),(0,e.createElementVNode)(`div`,{class:`chart-main`,ref_key:`chartMainRef`,ref:u},[(0,e.createElementVNode)(`div`,Ol,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(L.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.id,class:(0,e.normalizeClass)([`pane-separator-line`,{"is-active":se.value===t.id}]),style:(0,e.normalizeStyle)({top:`${t.top}px`})},null,6))),128))]),(0,e.createElementVNode)(`div`,{ref_key:`tooltipLayerRef`,ref:d,class:`tooltip-layer`},null,512),(0,e.createElementVNode)(`div`,{class:`chart-container`,style:(0,e.normalizeStyle)({cursor:de.value}),ref_key:`containerRef`,ref:l,onScrollPassive:ke,onPointerdown:Se,onPointermove:Ce,onPointerup:we,onPointerleave:Te},[(0,e.createElementVNode)(`div`,{class:`scroll-content`,style:(0,e.normalizeStyle)({width:(0,e.unref)(Ke)+`px`})},[(0,e.createElementVNode)(`div`,{class:`canvas-layer`,ref_key:`canvasLayerRef`,ref:s},[(0,e.createElementVNode)(`canvas`,{class:`x-axis-canvas`,ref_key:`xAxisCanvasRef`,ref:o},null,512),I.value?((0,e.openBlock)(),(0,e.createBlock)(Yn,{key:0,drawing:I.value,onUpdateStyle:xe,onDelete:V},null,8,[`drawing`])):(0,e.createCommentVNode)(``,!0)],512)],4)],36),d.value?((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{key:0,to:d.value},[R.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:(0,e.normalizeClass)([`tooltip-anchor kline-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,e.normalizeStyle)(me.value)},null,6)):(0,e.createCommentVNode)(``,!0),ne.value||re.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,class:(0,e.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,e.normalizeStyle)(ge.value)},null,6)):(0,e.createCommentVNode)(``,!0),R.value?((0,e.openBlock)(),(0,e.createBlock)(Bt,{key:2,k:R.value,index:fe.value,data:ye.value,pos:z.value,"set-el":E,"use-anchor":k.value,"anchor-placement":_e.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,e.createCommentVNode)(``,!0),ne.value||re.value?((0,e.openBlock)(),(0,e.createBlock)(Gt,{key:3,marker:ne.value||re.value,pos:he.value,"use-anchor":k.value,"anchor-placement":ve.value,"set-el":D},null,8,[`marker`,`pos`,`use-anchor`,`anchor-placement`])):(0,e.createCommentVNode)(``,!0)],8,[`to`])):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{class:`right-axis-host`,ref_key:`rightAxisLayerRef`,ref:c,style:(0,e.normalizeStyle)({width:Ge.value+`px`}),onPointerdown:H,onPointermove:Ee,onPointerup:De,onPointerleave:Oe},null,36)],512)],2),(0,e.createVNode)(Vn,{"active-indicators":je.value,"indicator-params":Me.value,onToggle:He,onUpdateParams:Ue,onReorderSubIndicators:We},null,8,[`active-indicators`,`indicator-params`])]))}}),[[`__scopeId`,`data-v-2385e6a5`]]),jl={install(e){e.component(`KLineChart`,Al)}};exports.ConfigManager=z,exports.EventBus=t,exports.GLOBAL_PANE_ID=de,exports.HookSystem=pe,exports.KLineChart=Al,exports.KMapPlugin=jl,exports.PluginHostImpl=he,exports.PluginRegistry=fe,exports.PluginState=le,exports.RENDERER_PRIORITY=R,exports.RendererPluginManager=ke,exports.createPluginHost=ge,exports.wrapPaneInfo=ue;
|
|
48
|
+
}`,Rr=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),zr=class{shared;handles=null;logicalWidth=0;logicalHeight=0;available=!1;rectCapacity=0;rectScratch=new Float32Array;region=null;constructor(e){this.shared=e,this.handles=this.initRectHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.shared.getCanvas()}setRegion(e){this.region=e}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t}clear(){!this.region||this.logicalWidth<=0||this.logicalHeight<=0||this.shared.clearRegion(this.region)}compositeTo(e,t={}){this.region&&this.shared.compositeRegionTo(e,this.region,t)}drawRectBuffer(e,t,n,r){let i=this.handles;if(!i||t===0||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let a=Kr(n);if(!a)return!1;let o=t*4,s=this.shared.getGL();return!s||!this.region||!this.shared.bindRegion(this.region)?!1:(s.useProgram(i.program),s.bindVertexArray(i.vao),s.bindBuffer(s.ARRAY_BUFFER,i.rectBuffer),this.rectCapacity<o&&(this.rectCapacity=Vr(o),s.bufferData(s.ARRAY_BUFFER,this.rectCapacity*Float32Array.BYTES_PER_ELEMENT,s.DYNAMIC_DRAW)),s.bufferSubData(s.ARRAY_BUFFER,0,e),a[3]===1?s.disable(s.BLEND):s.enable(s.BLEND),s.uniform2f(i.resolutionLocation,this.logicalWidth,this.logicalHeight),s.uniform1f(i.scrollXLocation,r),s.uniform4f(i.colorLocation,a[0],a[1],a[2],a[3]),s.drawArraysInstanced(s.TRIANGLES,0,6,t),s.bindVertexArray(null),!0)}drawRects(e,t,n){if(!this.handles||!e.length||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let r=e.length*4;this.rectScratch.length<r&&(this.rectScratch=new Float32Array(Vr(r)));for(let t=0;t<e.length;t++){let n=e[t],r=t*4;this.rectScratch[r]=n.x,this.rectScratch[r+1]=n.y,this.rectScratch[r+2]=n.width,this.rectScratch[r+3]=n.height}return this.drawRectBuffer(this.rectScratch.subarray(0,r),e.length,t,n)}destroy(){let e=this.handles;if(!e)return;let t=this.shared.getGL();if(t){let{program:n,vao:r,unitBuffer:i,rectBuffer:a}=e;t.deleteBuffer(i),t.deleteBuffer(a),t.deleteVertexArray(r),t.deleteProgram(n)}this.handles=null,this.available=!1}initRectHandles(){let e=this.shared.getGL();if(!e)return null;let t=Ur(e,e.VERTEX_SHADER,Fr),n=Ur(e,e.FRAGMENT_SHADER,Lr);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=Wr(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer(),o=e.createBuffer();if(!i||!a||!o)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),o&&e.deleteBuffer(o),e.deleteProgram(r),null;let s=e.getUniformLocation(r,`u_resolution`),c=e.getUniformLocation(r,`u_scrollX`),l=e.getUniformLocation(r,`u_color`);if(!s||!c||!l)return e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null;let u=e.getAttribLocation(r,`a_unit`),d=e.getAttribLocation(r,`a_rect`);return u<0||d<0?(e.deleteBuffer(a),e.deleteBuffer(o),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,Rr,e.STATIC_DRAW),e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.vertexAttribDivisor(u,0),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,4,e.FLOAT,!1,16,0),e.vertexAttribDivisor(d,1),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{program:r,vao:i,unitBuffer:a,rectBuffer:o,resolutionLocation:s,scrollXLocation:c,colorLocation:l})}},Br=class{shared;handles=null;logicalWidth=0;logicalHeight=0;dpr=1;available=!1;vertexCapacity=0;fillScratch=new Float32Array;lineScratch=new Float32Array;region=null;msaaTargets=null;geoCache=new WeakMap;constructor(e){this.shared=e,this.handles=this.initLineHandles(),this.available=this.handles!==null}isAvailable(){return this.available}getCanvas(){return this.shared.getCanvas()}setRegion(e){this.region=e}resize(e,t,n){this.logicalWidth=e,this.logicalHeight=t,this.dpr=n}clear(){!this.region||this.logicalWidth<=0||this.logicalHeight<=0||this.shared.clearRegion(this.region)}compositeTo(e,t={}){this.region&&this.shared.compositeRegionTo(e,this.region,t)}drawLineStrips(e,t){let n=this.handles;if(!n||e.length===0||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let r=this.shared.getGL(),i=this.region;if(!r||!i)return!1;let a=[],o=0;for(let t of e){if(t.points.length<2)return!1;let e=Kr(t.color);if(!e)return!1;if(t.width===1){let{vertexCount:n,vertices:i}=this.getThinLineVertices(t.points);a.push({colorValue:e,mode:r.LINE_STRIP,firstVertex:o/2,pointCount:n}),o+=i.length}else{let n=this.getLineGeometry(t);if(!n)return!1;a.push({colorValue:e,mode:r.TRIANGLES,firstVertex:o/2,pointCount:n.vertexCount}),o+=n.vertices.length}}this.lineScratch.length<o&&(this.lineScratch=new Float32Array(Vr(o)));let s=0;for(let t of e){let e=t.width===1?this.getThinLineVertices(t.points).vertices:this.getLineGeometry(t).vertices;this.lineScratch.set(e,s),s+=e.length}let c=this.shared.getPhysicalRegion(i),l=c?this.ensureLineMsaaTargets(r,c):null,u=l!==null;if(u)r.bindFramebuffer(r.FRAMEBUFFER,l.msaaFramebuffer),r.viewport(0,0,l.widthPx,l.heightPx),r.disable(r.SCISSOR_TEST),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT);else if(!this.shared.bindRegion(i))return!1;r.useProgram(n.basic.program),r.bindVertexArray(n.basic.vao),r.bindBuffer(r.ARRAY_BUFFER,n.basic.vertexBuffer),this.vertexCapacity<o&&(this.vertexCapacity=Vr(o),r.bufferData(r.ARRAY_BUFFER,this.vertexCapacity*Float32Array.BYTES_PER_ELEMENT,r.DYNAMIC_DRAW)),r.bufferSubData(r.ARRAY_BUFFER,0,this.lineScratch.subarray(0,o)),r.uniform2f(n.basic.resolutionLocation,this.logicalWidth,this.logicalHeight),r.uniform1f(n.basic.scrollXLocation,t);for(let e of a)r.uniform4f(n.basic.colorLocation,e.colorValue[0],e.colorValue[1],e.colorValue[2],e.colorValue[3]),r.drawArrays(e.mode,e.firstVertex,e.pointCount);return r.bindVertexArray(null),u&&l&&c&&this.resolveLineMsaaToSharedRegion(r,l,c),r.bindFramebuffer(r.FRAMEBUFFER,null),!0}getThinLineVertices(e){let t=this.geoCache.get(e);if(t){let e=t.get(0);if(e)return e}else t=new Map,this.geoCache.set(e,t);let n=e.length,r=new Float32Array(n*2),i=0;for(let t of e)r[i++]=t.x,r[i++]=t.y;let a={vertices:r,vertexCount:n};return t.set(0,a),a}getLineGeometry(e){let t=e.width/2,n=this.geoCache.get(e.points);if(n){let e=n.get(t);if(e)return e}else n=new Map,this.geoCache.set(e.points,n);let r=Hr(e.points,t);return r&&n.set(t,r),r}drawFilledBand(e,t,n){let r=this.handles,i=Math.min(e.upperPoints.length,e.lowerPoints.length);if(!r||i<2||this.logicalWidth<=0||this.logicalHeight<=0)return!1;let a=Kr(t);if(!a)return!1;let o=i*2,s=o*2;this.fillScratch.length<s&&(this.fillScratch=new Float32Array(Vr(s)));let c=0;for(let t=0;t<i;t++){let n=e.upperPoints[t],r=e.lowerPoints[t];this.fillScratch[c++]=n.x,this.fillScratch[c++]=n.y,this.fillScratch[c++]=r.x,this.fillScratch[c++]=r.y}let l=this.shared.getGL();return!l||!this.region||!this.shared.bindRegion(this.region)?!1:(l.useProgram(r.basic.program),l.bindVertexArray(r.basic.vao),l.bindBuffer(l.ARRAY_BUFFER,r.basic.vertexBuffer),this.vertexCapacity<s&&(this.vertexCapacity=Vr(s),l.bufferData(l.ARRAY_BUFFER,this.vertexCapacity*Float32Array.BYTES_PER_ELEMENT,l.DYNAMIC_DRAW)),l.bufferSubData(l.ARRAY_BUFFER,0,this.fillScratch.subarray(0,s)),l.uniform2f(r.basic.resolutionLocation,this.logicalWidth,this.logicalHeight),l.uniform1f(r.basic.scrollXLocation,n),l.uniform4f(r.basic.colorLocation,a[0],a[1],a[2],a[3]),l.drawArrays(l.TRIANGLE_STRIP,0,o),l.bindVertexArray(null),!0)}destroy(){let e=this.handles,t=this.shared.getGL();if(t&&this.destroyLineMsaaTargets(t),!e){this.vertexCapacity=0;return}if(t){let{basic:n}=e;t.deleteBuffer(n.vertexBuffer),t.deleteVertexArray(n.vao),t.deleteProgram(n.program)}this.handles=null,this.available=!1,this.vertexCapacity=0}ensureLineMsaaTargets(e,t){let n=Number(e.getParameter(e.MAX_SAMPLES))||0,r=Math.max(1,Math.min(4,n));if(r<=1)return null;let i=this.msaaTargets;if(i&&i.widthPx===t.widthPx&&i.heightPx===t.heightPx&&i.samples===r)return i;this.destroyLineMsaaTargets(e);let a=e.createFramebuffer(),o=e.createRenderbuffer(),s=e.createFramebuffer(),c=e.createTexture();if(!a||!o||!s||!c)return a&&e.deleteFramebuffer(a),o&&e.deleteRenderbuffer(o),s&&e.deleteFramebuffer(s),c&&e.deleteTexture(c),null;if(e.bindFramebuffer(e.FRAMEBUFFER,a),e.bindRenderbuffer(e.RENDERBUFFER,o),e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.RGBA8,t.widthPx,t.heightPx),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,o),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.deleteFramebuffer(a),e.deleteRenderbuffer(o),e.deleteFramebuffer(s),e.deleteTexture(c),null;if(e.bindFramebuffer(e.FRAMEBUFFER,s),e.bindTexture(e.TEXTURE_2D,c),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.widthPx,t.heightPx,0,e.RGBA,e.UNSIGNED_BYTE,null),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,c,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE)return e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),e.bindRenderbuffer(e.RENDERBUFFER,null),e.deleteFramebuffer(a),e.deleteRenderbuffer(o),e.deleteFramebuffer(s),e.deleteTexture(c),null;e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),e.bindRenderbuffer(e.RENDERBUFFER,null);let l={samples:r,widthPx:t.widthPx,heightPx:t.heightPx,msaaFramebuffer:a,msaaColorRenderbuffer:o,resolveFramebuffer:s,resolveTexture:c};return this.msaaTargets=l,l}destroyLineMsaaTargets(e){let t=this.msaaTargets;t&&(e.deleteFramebuffer(t.msaaFramebuffer),e.deleteRenderbuffer(t.msaaColorRenderbuffer),e.deleteFramebuffer(t.resolveFramebuffer),e.deleteTexture(t.resolveTexture),this.msaaTargets=null)}resolveLineMsaaToSharedRegion(e,t,n){e.bindFramebuffer(e.READ_FRAMEBUFFER,t.msaaFramebuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,t.resolveFramebuffer),e.blitFramebuffer(0,0,t.widthPx,t.heightPx,0,0,t.widthPx,t.heightPx,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.resolveFramebuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null);let r=this.shared.getCanvas().height-n.sourceY-n.heightPx;e.disable(e.SCISSOR_TEST),e.blitFramebuffer(0,0,t.widthPx,t.heightPx,n.sourceX,r,n.sourceX+n.widthPx,r+n.heightPx,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null)}initLineHandles(){let e=this.shared.getGL();if(!e)return null;let t=Ur(e,e.VERTEX_SHADER,Ir),n=Ur(e,e.FRAGMENT_SHADER,Lr);if(!t||!n)return t&&e.deleteShader(t),n&&e.deleteShader(n),null;let r=Wr(e,t,n);if(e.deleteShader(t),e.deleteShader(n),!r)return null;let i=e.createVertexArray(),a=e.createBuffer();if(!i||!a)return i&&e.deleteVertexArray(i),a&&e.deleteBuffer(a),e.deleteProgram(r),null;let o=e.getUniformLocation(r,`u_resolution`),s=e.getUniformLocation(r,`u_scrollX`),c=e.getUniformLocation(r,`u_color`);if(!o||!s||!c)return e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null;let l=e.getAttribLocation(r,`a_position`);return l<0?(e.deleteBuffer(a),e.deleteVertexArray(i),e.deleteProgram(r),null):(e.bindVertexArray(i),e.bindBuffer(e.ARRAY_BUFFER,a),e.enableVertexAttribArray(l),e.vertexAttribPointer(l,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),{basic:{program:r,vao:i,vertexBuffer:a,resolutionLocation:o,scrollXLocation:s,colorLocation:c}})}};function Vr(e){let t=1;for(;t<e;)t<<=1;return t}function Hr(e,t){if(e.length<2)return null;let n=Array(e.length-1),r=0;for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1],o=a.x-i.x,s=a.y-i.y,c=o*o+s*s;if(c<=0){n[t]={nx:0,ny:0,valid:!1};continue}let l=1/Math.sqrt(c);n[t]={nx:-s*l,ny:o*l,valid:!0},r++}if(r===0)return null;let i=(e.length-1)*12,a=new Float32Array(i),o=0;for(let r=0;r<e.length-1;r++){let i=e[r],s=e[r+1],c=r>0?n[r-1]:null,l=n[r];if(!l.valid||!c&&!l.valid)continue;let u=0,d=0;if(c?.valid&&l.valid){u=c.nx+l.nx,d=c.ny+l.ny;let e=u*u+d*d;if(e>1e-12){let t=1/Math.sqrt(e);u*=t,d*=t;let n=u*l.nx+d*l.ny,r=1/Math.max(.2,Math.abs(n));u*=r,d*=r}else u=l.nx,d=l.ny}else if(l.valid)u=l.nx,d=l.ny;else if(c?.valid)u=c.nx,d=c.ny;else continue;let f=l.nx,p=l.ny,m=r<e.length-2?n[r+1]:null;if(m?.valid&&l.valid){f=l.nx+m.nx,p=l.ny+m.ny;let e=f*f+p*p;if(e>1e-12){let t=1/Math.sqrt(e);f*=t,p*=t;let n=f*m.nx+p*m.ny,r=1/Math.max(.2,Math.abs(n));f*=r,p*=r}else f=l.nx,p=l.ny}let h=i.x+u*t,g=i.y+d*t,_=i.x-u*t,v=i.y-d*t,y=s.x+f*t,b=s.y+p*t,x=s.x-f*t,S=s.y-p*t;a[o++]=h,a[o++]=g,a[o++]=_,a[o++]=v,a[o++]=y,a[o++]=b,a[o++]=y,a[o++]=b,a[o++]=_,a[o++]=v,a[o++]=x,a[o++]=S}return o===0?null:{vertices:o===i?a:a.subarray(0,o),vertexCount:o/2}}function Ur(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(e.deleteShader(r),null)):null}function Wr(e,t,n){let r=e.createProgram();return r?(e.attachShader(r,t),e.attachShader(r,n),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(e.deleteProgram(r),null)):null}var Gr=new Map;function Kr(e){let t=Gr.get(e);if(t)return t;let n=e.trim().toLowerCase(),r=null;if(n.startsWith(`rgba(`)){let e=n.slice(5,-1).split(`,`).map(e=>Number(e.trim()));e.length===4&&e.every(e=>Number.isFinite(e))&&(r=[e[0]/255,e[1]/255,e[2]/255,e[3]])}else if(n.startsWith(`rgb(`)){let e=n.slice(4,-1).split(`,`).map(e=>Number(e.trim()));e.length===3&&e.every(e=>Number.isFinite(e))&&(r=[e[0]/255,e[1]/255,e[2]/255,1])}else if(n.startsWith(`#`)){let e=n.slice(1);e.length===6?r=[Number.parseInt(e.slice(0,2),16)/255,Number.parseInt(e.slice(2,4),16)/255,Number.parseInt(e.slice(4,6),16)/255,1]:e.length===3&&(r=[Number.parseInt(e[0]+e[0],16)/255,Number.parseInt(e[1]+e[1],16)/255,Number.parseInt(e[2]+e[2],16)/255,1])}return r&&Gr.set(e,r),r}var qr=class{dom;pane;opt;contexts=null;webgl;constructor(e,t,n,r){this.dom=e,this.pane=t,this.opt={...n,priceLabelWidth:n.priceLabelWidth||60},this.webgl={candleSurface:new zr(r),lineSurface:new Br(r)}}getPane(){return this.pane}getDom(){return this.dom}getContexts(){return this.contexts||={mainCtx:this.dom.mainCanvas.getContext(`2d`),overlayCtx:this.dom.overlayCanvas.getContext(`2d`),yAxisCtx:this.dom.yAxisCanvas.getContext(`2d`)},this.contexts}getWebGL(){return this.webgl}setWebGLRegion(e){this.webgl.candleSurface?.setRegion(e),this.webgl.lineSurface?.setRegion(e)}resize(e,t,n){let r=this.dom.mainCanvas,i=this.dom.overlayCanvas,a=this.dom.yAxisCanvas,o=this.opt.rightAxisWidth+(this.opt.priceLabelWidth||60),s=a.parentElement?.clientWidth??0,c=s>0?s:o,l=Math.round(e*n);r.width!==l&&(r.width=l);let u=Math.round(t*n);r.height!==u&&(r.height=u);let d=`${l/n}px`;r.style.width!==d&&(r.style.width=d);let f=`${u/n}px`;r.style.height!==f&&(r.style.height=f),i.width!==l&&(i.width=l),i.height!==u&&(i.height=u),i.style.width!==d&&(i.style.width=d),i.style.height!==f&&(i.style.height=f);let p=Math.round(c*n);a.width!==p&&(a.width=p);let m=Math.round(t*n);a.height!==m&&(a.height=m);let h=`${p/n}px`;a.style.width!==h&&(a.style.width=h);let g=`${m/n}px`;a.style.height!==g&&(a.style.height=g),this.webgl.candleSurface?.resize(e,t,n),this.webgl.lineSurface?.resize(e,t,n)}destroy(){this.contexts=null,this.webgl.candleSurface?.destroy(),this.webgl.lineSurface?.destroy()}},Jr=class{canvas;gl=null;constructor(e){this.canvas=e??document.createElement(`canvas`),this.gl=this.initContext()}isAvailable(){return this.gl!==null}getGL(){return this.gl}getCanvas(){return this.canvas}resize(e,t,n){let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}getPhysicalRegion(e){return this.toPhysicalRegion(e)}bindRegion(e){let t=this.gl,n=this.toPhysicalRegion(e);if(!t||!n)return!1;let r=this.canvas.height-n.sourceY-n.heightPx;return t.enable(t.SCISSOR_TEST),t.viewport(n.sourceX,r,n.widthPx,n.heightPx),t.scissor(n.sourceX,r,n.widthPx,n.heightPx),!0}clearRegion(e){let t=this.gl;!t||!this.bindRegion(e)||(t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT))}compositeRegionTo(e,t,n={}){let r=this.toPhysicalRegion(t);if(!r||r.widthPx<=0||r.heightPx<=0)return;let i=e.imageSmoothingEnabled,a=e.globalAlpha,o=e.getTransform();n.imageSmoothingEnabled!==void 0&&(e.imageSmoothingEnabled=n.imageSmoothingEnabled),n.alpha!==void 0&&(e.globalAlpha=a*n.alpha),e.setTransform(1,0,0,1,0,0),e.drawImage(this.canvas,r.sourceX,r.sourceY,r.widthPx,r.heightPx,0,0,r.widthPx,r.heightPx),e.setTransform(o),e.globalAlpha=a,e.imageSmoothingEnabled=i}destroy(){this.canvas.width=1,this.canvas.height=1,this.gl=null}toPhysicalRegion(e){let t=Math.max(0,Math.round(e.width*e.dpr)),n=Math.max(0,Math.round(e.height*e.dpr));return t<=0||n<=0?null:{sourceX:Math.max(0,Math.round(e.x*e.dpr)),sourceY:Math.max(0,Math.round(e.y*e.dpr)),widthPx:t,heightPx:n}}initContext(){try{return this.canvas.getContext(`webgl2`,{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1})}catch{return null}}};function Yr(e){let{dataLength:t,kWidth:n,kGap:r,viewWidth:i,viewportDpr:a}=e;if(t===0)return 0;let{startXPx:o,unitPx:s}=br(n,r,a),c=(o+(t+24)*s)/a;return Math.max(c,i)}function Xr(t){let n=(0,e.reactive)({zoomLevel:t.initialZoomLevel,kWidth:0,kGap:1,viewportDpr:1,dataLength:0,dataVersion:0,paneRatios:{},drawings:[],selectedDrawingId:null,drawingVersion:0,viewWidth:0}),r=(0,e.computed)(()=>t.rightAxisWidth+t.priceLabelWidth),i=(0,e.computed)(()=>Yr({dataLength:n.dataLength,kWidth:n.kWidth,kGap:n.kGap,viewWidth:n.viewWidth,viewportDpr:n.viewportDpr}));function a(){n.dataVersion++}function o(){n.drawingVersion++}function s(e){n.dataLength=e}function c(e){n.viewportDpr=e}function l(e){n.viewWidth=e}function u(e,t,r){n.zoomLevel=e,n.kWidth=t,n.kGap=r}function d(e){n.paneRatios=e}function f(e){n.drawings=e,n.selectedDrawingId&&!e.some(e=>e.id===n.selectedDrawingId)&&(n.selectedDrawingId=null),n.drawingVersion++}function p(e){n.selectedDrawingId=e}return{state:n,computed:{axisHostWidth:r,totalWidth:i},actions:{bumpDataVersion:a,bumpDrawingVersion:o,setDataLength:s,setViewportDpr:c,setViewWidth:l,setZoomState:u,setPaneRatios:d,setDrawings:f,setSelectedDrawingId:p}}}var Zr=3;function Qr(e,t){let n=(e-1)/(t.zoomLevelCount-1);return t.minKWidth+n*(t.maxKWidth-t.minKWidth)}function $r(e,t){let n=Math.round(e*t);return Math.max(1,Math.min(Zr,Math.round(n*.6)))/t}function ei(e,t,n,r,i,a,o){let s=Math.max(1,Math.min(o.zoomLevelCount,r+e));if(s===r)return null;let c=Qr(s,o),l=$r(c,o.dpr),u=br(i,a,o.dpr),d=br(c,l,o.dpr),f=(Math.round((n+t)*o.dpr)-u.startXPx)/u.unitPx;return{targetLevel:s,newKWidth:c,newKGap:l,newScrollLeft:(d.startXPx+f*d.unitPx)/o.dpr-t}}var ti=[5,10,20,30,60];function ni(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0,a=[];for(let n=0;n<t;n++){let t=e[n];if(!t)return r;let o=t.close;a.push(o),i+=o}for(let o=t-1;o<e.length;o++){let s=e[o];if(!s)continue;if(o>=t){let e=a.shift();e!==void 0&&(i-=e);let t=s.close;a.push(t),i+=t}let c=i/t,l=0;for(let e=0;e<t;e++){let t=a[e];t!==void 0&&(l+=(t-c)**2)}let u=Math.sqrt(l/t);r[o]={upper:c+n*u,middle:c,lower:c-n*u}}return r}function ri(e,t,n){let r=Array(e.length);if(e.length===0)return r;let i=2/(t+1),a=2/(n+1),o=e[0].close,s=o,c=o;r[0]={fast:s,slow:c};for(let t=1;t<e.length;t++){let n=e[t].close;s=n*i+s*(1-i),c=n*a+c*(1-a),r[t]={fast:s,slow:c}}return r}function ii(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=0;for(let n=0;n<t;n++){let t=e[n];if(!t)return r;i+=t.close}let a=i/t,o=n/100;r[t-1]={upper:a*(1+o),middle:a,lower:a*(1-o)};for(let a=t;a<e.length;a++){let o=e[a-t],s=e[a];if(!o||!s)continue;i=i-o.close+s.close;let c=i/t,l=n/100;r[a]={upper:c*(1+l),middle:c,lower:c*(1-l)}}return r}function ai(e,t){let n=Array(e.length);if(e.length<t)return n;let r=0;for(let i=0;i<t;i++){let t=e[i];if(!t)return n;r+=t.close}n[t-1]=r/t;for(let i=t;i<e.length;i++){let a=e[i-t],o=e[i];!a||!o||(r=r-a.close+o.close,n[i]=r/t)}return n}function oi(e,t){let n=Array(e.length);if(e.length<t+1)return n;let r=[];for(let t=1;t<e.length;t++)r.push(e[t].close-e[t-1].close);let i=0,a=0;for(let e=0;e<t;e++){let t=r[e];t!==void 0&&(t>0?i+=t:a+=Math.abs(t))}let o=i/t,s=a/t;s===0?n[t]=100:n[t]=100-100/(1+o/s);for(let e=t;e<r.length;e++){let i=r[e];if(i!==void 0)if(i>0?(o=(o*(t-1)+i)/t,s=s*(t-1)/t):(o=o*(t-1)/t,s=(s*(t-1)+Math.abs(i))/t),s===0)n[e+1]=100;else{let t=o/s;n[e+1]=100-100/(1+t)}}return n}function si(e,t){let n=Array(e.length);if(e.length<t)return n;let r=[];for(let t of e)r.push((t.high+t.low+t.close)/3);let i=0;for(let e=0;e<t;e++)i+=r[e];for(let a=t-1;a<e.length;a++){a>=t&&(i=i-r[a-t]+r[a]);let e=i/t,o=0;for(let n=0;n<t;n++)o+=Math.abs(r[a-n]-e);o/=t,o===0?n[a]=0:n[a]=(r[a]-e)/(.015*o)}return n}function ci(e,t,n){let r=Array(e.length);if(e.length<t)return r;let i=Array(e.length);for(let n=t-1;n<e.length;n++){let r=-1/0,a=1/0;for(let i=0;i<t;i++){let t=e[n-i];t&&(r=Math.max(r,t.high),a=Math.min(a,t.low))}let o=e[n].close;r===a?i[n]=50:i[n]=(o-a)/(r-a)*100}for(let a=t-1+n-1;a<e.length;a++){let e=i[a];if(e===void 0)continue;let t=0,o=0;for(let e=0;e<n;e++){let n=i[a-e];n!==void 0&&(t+=n,o++)}o===n&&(r[a]={k:e,d:t/n})}return r}function li(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&(n[r]=i-a)}return n}function ui(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=-50:n[r]=(i-o)/(i-a)*-100}return n}function di(e,t){let n=Array(e.length);if(e.length<t+1)return n;for(let r=t;r<e.length;r++){let i=e[r]?.close,a=e[r-t]?.close;i!==void 0&&a!==void 0&&a!==0&&(n[r]=(i-a)/a*100)}return n}function fi(e,t){let n=Array(e.length),r=0,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(r+=o,i++,i>t){let n=e[a-t];n!==void 0&&(r-=n,i--)}i===t&&(n[a]=r/t)}}return n}function pi(e,t,n,r,i,a){let o=Array(e.length),s=di(e,t),c=di(e,n),l=di(e,r),u=di(e,i),d=fi(s,10),f=fi(c,10),p=fi(l,10),m=fi(u,15),h=Array(e.length);for(let t=0;t<e.length;t++){let e=d[t],n=f[t],r=p[t],i=m[t];e!==void 0&&n!==void 0&&r!==void 0&&i!==void 0&&(h[t]=e*1+n*2+r*3+i*4)}let g=fi(h,a);for(let t=0;t<e.length;t++){let e=h[t],n=g[t];e!==void 0&&n!==void 0&&(o[t]={kst:e,signal:n})}return o}function mi(e,t){let n=Array(e.length);if(e.length<t)return n;for(let r=t-1;r<e.length;r++){let i=-1/0,a=1/0;for(let n=0;n<t;n++){let t=e[r-n];t&&(i=Math.max(i,t.high),a=Math.min(a,t.low))}let o=e[r].close;i===a?n[r]=50:n[r]=(o-a)/(i-a)*100}return n}function hi(e,t){let n=Array(e.length),r=2/(t+1);if(e.length===0)return n;n[0]=e[0].close;for(let t=1;t<e.length;t++){let i=e[t];i&&(n[t]=i.close*r+n[t-1]*(1-r))}return n}function gi(e,t){let n=Array(e.length),r=2/(t+1),i=e.findIndex(e=>e!==void 0);if(i===-1)return n;n[i]=e[i];for(let t=i+1;t<e.length;t++){let i=e[t],a=n[t-1];i===void 0||a===void 0||(n[t]=i*r+a*(1-r))}return n}function _i(e,t,n,r){let i=Array(e.length);if(e.length<n)return i;let a=hi(e,t),o=hi(e,n),s=Array(e.length);for(let t=0;t<e.length;t++){let e=a[t],n=o[t];e!==void 0&&n!==void 0&&(s[t]=e-n)}let c=gi(s,r);for(let t=0;t<e.length;t++){let e=s[t],n=c[t];e!==void 0&&n!==void 0&&(i[t]={dif:e,dea:n,macd:(e-n)*2})}return i}function vi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;if(t===1){let t=e[0];r[0]=t.high-t.low;let i=t.close;for(let t=1;t<n;t++){let n=e[t];r[t]=Math.max(n.high-n.low,Math.abs(n.high-i),Math.abs(n.low-i)),i=n.close}return r}if(n<t)return r;let i=e[0],a=i.high-i.low,o=i.close;for(let n=1;n<t;n++){let t=e[n];a+=Math.max(t.high-t.low,Math.abs(t.high-o),Math.abs(t.low-o)),o=t.close}let s=a/t;r[t-1]=s;let c=t-1;for(let i=t;i<n;i++){let n=e[i],a=Math.max(n.high-n.low,Math.abs(n.high-o),Math.abs(n.low-o));s=(c*s+a)/t,r[i]=s,o=n.close}return r}function yi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;let i=t*(t+1)/2;for(let a=t-1;a<n;a++){let n=0,o=!0;for(let r=0;r<t;r++){let i=e[a-t+1+r];if(i===void 0){o=!1;break}n+=(r+1)*i}o&&(r[a]=n/i)}return r}function bi(e,t){if(e.length===0||t<=0)return Array(e.length).fill(void 0);let n=Array(e.length);for(let t=0;t<e.length;t++)n[t]=e[t].close;return yi(n,t)}function xi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=2/(t+1),a=0;for(;a<n&&e[a]===void 0;)a++;if(a>=n)return r;let o=e[a];r[a]=o;for(let t=a+1;t<n;t++){let n=e[t];n!==void 0&&(o=n*i+o*(1-i),r[t]=o)}return r}function Si(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=xi(i,t),o=xi(a,t);for(let e=0;e<n;e++){let t=a[e],n=o[e];t===void 0||n===void 0||(r[e]=2*t-n)}return r}function Ci(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=xi(i,t),o=xi(a,t),s=xi(o,t);for(let e=0;e<n;e++){let t=a[e],n=o[e],i=s[e];t===void 0||n===void 0||i===void 0||(r[e]=3*t-3*n+i)}return r}function wi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=e[t].close;let a=Math.max(1,Math.floor(t/2)),o=Math.max(1,Math.round(Math.sqrt(t))),s=yi(i,a),c=yi(i,t),l=Array(n).fill(void 0);for(let e=0;e<n;e++){let t=s[e],n=c[e];t===void 0||n===void 0||(l[e]=2*t-n)}return yi(l,o)}function Ti(e,t,n,r){let i=e.length,a=Array(i).fill(void 0);if(i===0||t<=0||n<=0||r<=0||i<=t)return a;let o=2/(n+1),s=2/(r+1),c=o-s,l=0;for(let n=1;n<=t;n++)l+=Math.abs(e[n].close-e[n-1].close);let u=e[t-1].close;a[t-1]=u;for(let n=t;n<i;n++){let r=e[n].close,o=e[n-t].close,d=Math.abs(r-o),f=((l>0?d/l:0)*c+s)**2;u+=f*(r-u),a[n]=u,n<i-1&&(l-=Math.abs(e[n-t+1].close-e[n-t].close),l+=Math.abs(e[n+1].close-e[n].close))}return a}var Ei=.02,Di=.2;function Oi(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r<2||t<=0||n<=0)return i;let a=e[1].close>=e[0].close?`up`:`down`,o=a===`up`?e[0].low:e[0].high,s=a===`up`?e[0].high:e[0].low,c=t;i[0]={value:o,trend:a};for(let l=1;l<r;l++){let r=e[l];if(o+=c*(s-o),a===`up`){let t=e[l-1].low,n=l>=2?e[l-2].low:t;o=Math.min(o,t,n)}else{let t=e[l-1].high,n=l>=2?e[l-2].high:t;o=Math.max(o,t,n)}a===`up`&&r.low<o?(a=`down`,o=s,s=r.low,c=t):a===`down`&&r.high>o?(a=`up`,o=s,s=r.high,c=t):a===`up`&&r.high>s?(s=r.high,c=Math.min(c+t,n)):a===`down`&&r.low<s&&(s=r.low,c=Math.min(c+t,n)),i[l]={value:o,trend:a}}return i}function ki(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r===0||t<=0||n<=0)return i;let a=vi(e,t),o=`up`,s=1/0,c=-1/0;for(let t=0;t<r;t++){let r=e[t],l=a[t];if(l===void 0)continue;let u=(r.high+r.low)/2,d=u+n*l,f=u-n*l,p=t>0?e[t-1].close:r.close,m=d<s||p>s?d:s,h=f>c||p<c?f:c;o===`up`&&r.close<h?o=`down`:o===`down`&&r.close>m&&(o=`up`),i[t]={value:o===`up`?h:m,trend:o},s=m,c=h}return i}function Ai(e,t,n,r){let i=e.length,a=Array(i).fill(void 0);if(i===0||t<=0||n<=0)return a;let o=Array(i);for(let t=0;t<i;t++)o[t]=e[t].close;let s=xi(o,t),c=vi(e,n);for(let e=0;e<i;e++){let t=s[e],n=c[e];t===void 0||n===void 0||(a[e]={upper:t+r*n,middle:t,lower:t-r*n})}return a}function ji(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;for(let i=t-1;i<n;i++){let n=-1/0,a=1/0;for(let r=0;r<t;r++){let t=e[i-r];t.high>n&&(n=t.high),t.low<a&&(a=t.low)}r[i]={upper:n,middle:(n+a)/2,lower:a}}return r}function Mi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n<t||t<=0)return r;for(let i=t-1;i<n;i++){let n=-1/0,a=1/0;for(let r=0;r<t;r++){let t=e[i-r];t.high>n&&(n=t.high),t.low<a&&(a=t.low)}r[i]=(n+a)/2}return r}function Ni(e,t,n,r,i){let a=e.length,o=Array(a).fill(void 0);if(a===0||t<=0||n<=0||r<=0)return o;let s=Mi(e,t),c=Mi(e,n),l=Mi(e,r);for(let t=0;t<a;t++){let n={};s[t]!==void 0&&(n.tenkan=s[t]),c[t]!==void 0&&(n.kijun=c[t]);let r=t-i;r>=0&&(s[r]!==void 0&&c[r]!==void 0&&(n.spanA=(s[r]+c[r])/2),l[r]!==void 0&&(n.spanB=l[r]));let u=t+i;u<a&&(n.chikou=e[u].close),o[t]=n}return o}function Pi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0)return r;for(let i=t;i<n;i++){let n=e[i-t].close;n!==0&&(r[i]=(e[i].close-n)/n*100)}return r}function Fi(e,t,n){let r=e.length,i=Array(r).fill(void 0),a=Array(r).fill(void 0);if(r===0||t<=0)return{series:i,signalSeries:a};let o=Array(r);for(let t=0;t<r;t++)o[t]=e[t].close;let s=xi(xi(xi(o,t),t),t);for(let e=1;e<r;e++){let t=s[e],n=s[e-1];t===void 0||n===void 0||n===0||(i[e]=(t-n)/n*100)}if(n>0){let e=xi(i,n);for(let t=0;t<r;t++)a[t]=e[t]}return{series:i,signalSeries:a}}function Ii(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r<2||t<=0||n<=0)return i;let a=Array(r);a[0]=0;for(let t=1;t<r;t++){let n=e[t-1].close,r=e[t].close;a[t]=n>0&&r>0?Math.log(r/n):0}let o=Math.sqrt(n);for(let e=t;e<r;e++){let n=0;for(let r=1;r<=t;r++)n+=a[e-t+r];let r=n/t,s=0;for(let n=1;n<=t;n++){let i=a[e-t+n]-r;s+=i*i}i[e]=Math.sqrt(s/(t-1>0?t-1:1))*o*100}return i}function Li(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r===0||t<=0||n<=0||r<t)return i;let a=1/(4*Math.log(2)),o=Math.sqrt(n),s=Array(r);for(let t=0;t<r;t++){let n=e[t];if(n.high>0&&n.low>0){let e=Math.log(n.high/n.low);s[t]=e*e}else s[t]=0}for(let e=t-1;e<r;e++){let n=0;for(let r=0;r<t;r++)n+=s[e-r];let r=n/t;i[e]=Math.sqrt(a*r)*o*100}return i}function Ri(e,t,n){let r=e.length,i=Array(r).fill(void 0);if(r===0||t<=0||n<=0)return i;let a=Array(r);for(let t=0;t<r;t++)a[t]=e[t].high-e[t].low;let o=xi(a,t);for(let e=n;e<r;e++){let t=o[e],r=o[e-n];t===void 0||r===void 0||r===0||(i[e]=(t-r)/r*100)}return i}function zi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;let i=0;for(let n=0;n<t;n++)i+=e[n].volume??0;r[t-1]=i/t;for(let a=t;a<n;a++)i+=(e[a].volume??0)-(e[a-t].volume??0),r[a]=i/t;return r}function Bi(e){let t=e.length,n=Array(t).fill(void 0);if(t===0)return n;let r=0;n[0]=0;for(let i=1;i<t;i++){let t=e[i],a=e[i-1];t.close>a.close?r+=t.volume??0:t.close<a.close&&(r-=t.volume??0),n[i]=r}return n}function Vi(e){let t=e.length,n=Array(t).fill(void 0);if(t===0)return n;let r=0;n[0]=0;for(let i=1;i<t;i++){let t=e[i-1].close;if(t===0){n[i]=r;continue}r+=(e[i].close-t)/t*(e[i].volume??0),n[i]=r}return n}function Hi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0)return r;let i=0,a=0,o=e[0].timestamp;for(let s=0;s<n;s++){let n=e[s];t>0&&s>0&&n.timestamp-o>t&&(i=0,a=0);let c=(n.high+n.low+n.close)/3;i+=c*(n.volume??0),a+=n.volume??0,r[s]=a>0?i/a:c,o=n.timestamp}return r}function Ui(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;let i=Array(n);for(let t=0;t<n;t++){let n=e[t],r=n.high-n.low;i[t]=(r>0?(n.close-n.low-(n.high-n.close))/r:0)*(n.volume??0)}let a=0,o=0;for(let n=0;n<t;n++)a+=i[n],o+=e[n].volume??0;r[t-1]=o>0?a/o:0;for(let s=t;s<n;s++)a+=i[s]-i[s-t],o+=(e[s].volume??0)-(e[s-t].volume??0),r[s]=o>0?a/o:0;return r}function Wi(e,t){let n=e.length,r=Array(n).fill(void 0);if(n<t+1||t<=0)return r;let i=Array(n);for(let t=0;t<n;t++)i[t]=(e[t].high+e[t].low+e[t].close)/3;let a=Array(n),o=Array(n);a[0]=0,o[0]=0;for(let t=1;t<n;t++){let n=i[t]*(e[t].volume??0);i[t]>i[t-1]?(a[t]=n,o[t]=0):i[t]<i[t-1]?(a[t]=0,o[t]=n):(a[t]=0,o[t]=0)}let s=0,c=0;for(let e=1;e<=t;e++)s+=a[e],c+=o[e];r[t]=c>0?100-100/(1+s/c):100;for(let e=t+1;e<n;e++)s+=a[e]-a[e-t],c+=o[e]-o[e-t],r[e]=c>0?100-100/(1+s/c):100;return r}function Gi(e){let t=e.length,n=Array(t).fill(void 0);if(t<2)return n;for(let r=1;r<t;r++){let t=e[r-1],i=(t.high+t.low+t.close)/3,a=t.high-t.low;n[r]={pp:i,r1:2*i-t.low,s1:2*i-t.high,r2:i+a,s2:i-a,r3:t.high+2*(i-t.low),s3:t.low-2*(t.high-i)}}return n}function Ki(e,t){let n=e.length,r=Array(n).fill(void 0);if(n===0||t<=0||n<t)return r;for(let i=t-1;i<n;i++){let n=-1/0,a=1/0,o=i,s=i;for(let r=0;r<t;r++){let t=e[i-r];t.high>n&&(n=t.high,o=i-r),t.low<a&&(a=t.low,s=i-r)}let c=o>=s?`up`:`down`,l=n-a,u=e=>c===`up`?n-l*e:a+l*e;r[i]={high:n,low:a,direction:c,level236:u(.236),level382:u(.382),level500:u(.5),level618:u(.618),level786:u(.786)}}return r}function qi(e,t,n,r){let i=e.length;if(i===0||t<0||n<0)return{swings:[],events:[],trend:`range`};let a=[];for(let r=0;r<i;r++){let o=e[r];Ji(e,r,t,n,`high`)&&a.push({index:r,price:o.high,kind:`high`,confirmed:r+n<i}),Ji(e,r,t,n,`low`)&&a.push({index:r,price:o.low,kind:`low`,confirmed:r+n<i})}a.sort((e,t)=>e.index-t.index);let o=[],s=null,c=null;for(let e of a){let t;e.kind===`high`?(t=s&&e.price>s.price?`HH`:`LH`,s={index:e.index,price:e.price}):(t=c&&e.price>c.price?`HL`:`LL`,c={index:e.index,price:e.price}),o.push({...e,label:t})}let l=[],u=`range`,d=null,f=null,p=o.filter(e=>e.confirmed),m=0;for(let t=0;t<i;t++){for(;m<p.length&&p[m].index+n<=t;){let e=p[m];e.kind===`high`?d={index:e.index,price:e.price}:f={index:e.index,price:e.price},m++}let i=e[t],a=r===`close`?i.close:i.high,o=r===`close`?i.close:i.low;if(d&&a>d.price){let e=u===`down`?`CHOCH`:`BOS`;l.push({kind:e,index:t,triggerPrice:a,brokenLevel:d.price,brokenSwingIndex:d.index,direction:`up`}),u=`up`,d=null}else if(f&&o<f.price){let e=u===`up`?`CHOCH`:`BOS`;l.push({kind:e,index:t,triggerPrice:o,brokenLevel:f.price,brokenSwingIndex:f.index,direction:`down`}),u=`down`,f=null}}return{swings:o,events:l,trend:u}}function Ji(e,t,n,r,i){let a=e.length;if(t<n||t+r>=a)return!1;let o=i===`high`?e[t].high:e[t].low;for(let r=1;r<=n;r++){let n=i===`high`?e[t-r].high:e[t-r].low;if(i===`high`?n>=o:n<=o)return!1}for(let n=1;n<=r;n++){let r=i===`high`?e[t+n].high:e[t+n].low;if(i===`high`?r>=o:r<=o)return!1}return!0}function Yi(e,t,n,r,i){let a=e.length;if(a<3)return[];let o=[];for(let t=2;t<a;t++){let n=e[t-2],r=e[t];n.high<r.low&&o.push({kind:`FVG_BULL`,startIndex:t-1,high:r.low,low:n.high}),n.low>r.high&&o.push({kind:`FVG_BEAR`,startIndex:t-1,high:n.low,low:r.high})}let s=qi(e,n,r,i);for(let n of s.events){if(n.kind!==`BOS`)continue;let r=Math.max(0,n.index-t);if(n.direction===`up`)for(let t=n.index-1;t>=r;t--){let n=e[t];if(n.close<n.open){o.push({kind:`OB_BULL`,startIndex:t,high:n.high,low:n.low});break}}else for(let t=n.index-1;t>=r;t--){let n=e[t];if(n.close>n.open){o.push({kind:`OB_BEAR`,startIndex:t,high:n.high,low:n.low});break}}}for(let t of o)for(let n=t.startIndex+1;n<a;n++){let r=e[n];if(r.low<=t.high&&r.high>=t.low){t.endIndex=n;break}}return o}var Xi=.7;function Zi(e,t,n,r){let i=e.length;if(i===0||t<=0)return{bins:[],poc:0,vah:0,val:0,totalVolume:0};let a=n>0?Math.max(0,i-n):0,o=1/0,s=-1/0;for(let t=a;t<i;t++){let n=e[t];n.low<o&&(o=n.low),n.high>s&&(s=n.high)}if(!Number.isFinite(o)||!Number.isFinite(s)||s<=o)return{bins:[],poc:o,vah:o,val:o,totalVolume:0};let c=(s-o)/t,l=Array(t).fill(0);for(let n=a;n<i;n++){let r=e[n],i=r.high-r.low;if(i<=0){let e=Math.min(t-1,Math.max(0,Math.floor((r.close-o)/c)));l[e]+=r.volume??0;continue}let a=(r.volume??0)/i,s=Math.max(0,Math.floor((r.low-o)/c)),u=Math.min(t-1,Math.floor((r.high-o)/c));for(let e=s;e<=u;e++){let t=o+e*c,n=t+c,i=Math.max(r.low,t),s=Math.min(r.high,n)-i;s>0&&(l[e]+=s*a)}}let u=l.map((e,t)=>({priceLow:o+t*c,priceHigh:o+(t+1)*c,volume:e})),d=0;for(let e=1;e<t;e++)l[e]>l[d]&&(d=e);let f=(u[d].priceLow+u[d].priceHigh)/2,p=l.reduce((e,t)=>e+t,0),m=p*r,h=l[d],g=d,_=d;for(;h<m&&(g>0||_<t-1);)if((g>0?l[g-1]:-1/0)>=(_<t-1?l[_+1]:-1/0)&&g>0)g--,h+=l[g];else if(_<t-1)_++,h+=l[_];else break;let v=u[g].priceLow;return{bins:u,poc:f,vah:u[_].priceHigh,val:v,totalVolume:p}}var Qi=class{currentData=[];dataVersion=0;config=this.getDefaultConfig();configVersion=0;cachedSeries={};cachedBollSeries=[];cachedExpmaSeries=[];cachedEneSeries=[];cachedRsiSeries={};cachedCciSeries=[];cachedStochSeries=[];cachedMomSeries=[];cachedWmsrSeries=[];cachedKstSeries=[];cachedFastkSeries=[];cachedMacdSeries=[];cachedAtrSeries=[];cachedWmaSeries=[];cachedDemaSeries=[];cachedTemaSeries=[];cachedHmaSeries=[];cachedKamaSeries=[];cachedSarSeries=[];cachedSupertrendSeries=[];cachedKeltnerSeries=[];cachedDonchianSeries=[];cachedIchimokuSeries=[];cachedRocSeries=[];cachedTrixSeries=[];cachedTrixSignalSeries=[];cachedHvSeries=[];cachedParkinsonSeries=[];cachedChaikinVolSeries=[];cachedVmaSeries=[];cachedObvSeries=[];cachedPvtSeries=[];cachedVwapSeries=[];cachedCmfSeries=[];cachedMfiSeries=[];cachedPivotSeries=[];cachedFibSeries=[];cachedStructureSeries={swings:[],events:[],trend:`range`};cachedZonesSeries=[];cachedVolumeProfileSeries={bins:[],poc:0,vah:0,val:0,totalVolume:0};dirtyData=!0;dirtyMAConfig=!0;dirtyBollConfig=!0;dirtyExpmaConfig=!0;dirtyEneConfig=!0;dirtyRsiConfig=!0;dirtyCciConfig=!0;dirtyStochConfig=!0;dirtyMomConfig=!0;dirtyWmsrConfig=!0;dirtyKstConfig=!0;dirtyFastkConfig=!0;dirtyMacdConfig=!0;dirtyAtrConfig=!0;dirtyWmaConfig=!0;dirtyDemaConfig=!0;dirtyTemaConfig=!0;dirtyHmaConfig=!0;dirtyKamaConfig=!0;dirtySarConfig=!0;dirtySupertrendConfig=!0;dirtyKeltnerConfig=!0;dirtyDonchianConfig=!0;dirtyIchimokuConfig=!0;dirtyRocConfig=!0;dirtyTrixConfig=!0;dirtyHvConfig=!0;dirtyParkinsonConfig=!0;dirtyChaikinVolConfig=!0;dirtyVmaConfig=!0;dirtyObvConfig=!0;dirtyPvtConfig=!0;dirtyVwapConfig=!0;dirtyCmfConfig=!0;dirtyMfiConfig=!0;dirtyPivotConfig=!0;dirtyFibConfig=!0;dirtyStructureConfig=!0;dirtyZonesConfig=!0;dirtyVolumeProfileConfig=!0;getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},atr:{period:14,showATR:!0},wma:{period:9,showWMA:!0},dema:{period:20,showDEMA:!0},tema:{period:20,showTEMA:!0},hma:{period:9,showHMA:!0},kama:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},sar:{step:Ei,maxStep:Di,showSAR:!0},supertrend:{atrPeriod:10,multiplier:3,showSuperTrend:!0},keltner:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},donchian:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},ichimoku:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showCloud:!0,showChikou:!0},roc:{period:12,showROC:!0},trix:{period:15,signalPeriod:9,showTRIX:!0,showSignal:!0},hv:{period:20,annualizationFactor:252,showHV:!0},parkinson:{period:20,annualizationFactor:252,showParkinson:!0},chaikinVol:{emaPeriod:10,rocPeriod:10,showChaikinVol:!0},vma:{period:5,showVMA:!0},obv:{showOBV:!0},pvt:{showPVT:!0},vwap:{sessionResetGapMs:0,showVWAP:!0},cmf:{period:20,showCMF:!0},mfi:{period:14,showMFI:!0},pivot:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},fib:{period:50,showLevels:!0},structure:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},zones:{showFVG:!0,showOB:!0,showFilledZones:!1,obLookback:5},volumeProfile:{bins:24,lookback:0,valueAreaPercent:Xi,showPOC:!0,showValueArea:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`,atrPaneId:`sub_ATR`,wmaPaneId:`sub_WMA`,demaPaneId:`sub_DEMA`,temaPaneId:`sub_TEMA`,hmaPaneId:`sub_HMA`,kamaPaneId:`sub_KAMA`,sarPaneId:`sub_SAR`,supertrendPaneId:`sub_SuperTrend`,keltnerPaneId:`sub_Keltner`,donchianPaneId:`sub_Donchian`,ichimokuPaneId:`sub_Ichimoku`,rocPaneId:`sub_ROC`,trixPaneId:`sub_TRIX`,hvPaneId:`sub_HV`,parkinsonPaneId:`sub_Parkinson`,chaikinVolPaneId:`sub_ChaikinVol`,vmaPaneId:`sub_VMA`,obvPaneId:`sub_OBV`,pvtPaneId:`sub_PVT`,vwapPaneId:`sub_VWAP`,cmfPaneId:`sub_CMF`,mfiPaneId:`sub_MFI`,pivotPaneId:`sub_Pivot`,fibPaneId:`sub_Fib`,structurePaneId:`sub_Structure`,zonesPaneId:`sub_Zones`,volumeProfilePaneId:`sub_VolumeProfile`}}setData(e,t){this.dataVersion===t&&!this.dirtyData||(this.currentData=e,this.dataVersion=t,this.dirtyData=!0)}shallowEqual(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}setConfig(e,t){e.ma!==void 0&&!this.shallowEqual(e.ma,this.config.ma)&&(this.config.ma={...this.config.ma,...e.ma},this.dirtyMAConfig=!0),e.boll!==void 0&&!this.shallowEqual(e.boll,this.config.boll)&&(this.config.boll={...this.config.boll,...e.boll},this.dirtyBollConfig=!0),e.expma!==void 0&&!this.shallowEqual(e.expma,this.config.expma)&&(this.config.expma={...this.config.expma,...e.expma},this.dirtyExpmaConfig=!0),e.ene!==void 0&&!this.shallowEqual(e.ene,this.config.ene)&&(this.config.ene={...this.config.ene,...e.ene},this.dirtyEneConfig=!0),e.rsi!==void 0&&!this.shallowEqual(e.rsi,this.config.rsi)&&(this.config.rsi={...this.config.rsi,...e.rsi},this.dirtyRsiConfig=!0),e.cci!==void 0&&!this.shallowEqual(e.cci,this.config.cci)&&(this.config.cci={...this.config.cci,...e.cci},this.dirtyCciConfig=!0),e.stoch!==void 0&&!this.shallowEqual(e.stoch,this.config.stoch)&&(this.config.stoch={...this.config.stoch,...e.stoch},this.dirtyStochConfig=!0),e.mom!==void 0&&!this.shallowEqual(e.mom,this.config.mom)&&(this.config.mom={...this.config.mom,...e.mom},this.dirtyMomConfig=!0),e.wmsr!==void 0&&!this.shallowEqual(e.wmsr,this.config.wmsr)&&(this.config.wmsr={...this.config.wmsr,...e.wmsr},this.dirtyWmsrConfig=!0),e.kst!==void 0&&!this.shallowEqual(e.kst,this.config.kst)&&(this.config.kst={...this.config.kst,...e.kst},this.dirtyKstConfig=!0),e.fastk!==void 0&&!this.shallowEqual(e.fastk,this.config.fastk)&&(this.config.fastk={...this.config.fastk,...e.fastk},this.dirtyFastkConfig=!0),e.macd!==void 0&&!this.shallowEqual(e.macd,this.config.macd)&&(this.config.macd={...this.config.macd,...e.macd},this.dirtyMacdConfig=!0),e.atr!==void 0&&!this.shallowEqual(e.atr,this.config.atr)&&(this.config.atr={...this.config.atr,...e.atr},this.dirtyAtrConfig=!0),e.wma!==void 0&&!this.shallowEqual(e.wma,this.config.wma)&&(this.config.wma={...this.config.wma,...e.wma},this.dirtyWmaConfig=!0),e.dema!==void 0&&!this.shallowEqual(e.dema,this.config.dema)&&(this.config.dema={...this.config.dema,...e.dema},this.dirtyDemaConfig=!0),e.tema!==void 0&&!this.shallowEqual(e.tema,this.config.tema)&&(this.config.tema={...this.config.tema,...e.tema},this.dirtyTemaConfig=!0),e.hma!==void 0&&!this.shallowEqual(e.hma,this.config.hma)&&(this.config.hma={...this.config.hma,...e.hma},this.dirtyHmaConfig=!0),e.kama!==void 0&&!this.shallowEqual(e.kama,this.config.kama)&&(this.config.kama={...this.config.kama,...e.kama},this.dirtyKamaConfig=!0),e.sar!==void 0&&!this.shallowEqual(e.sar,this.config.sar)&&(this.config.sar={...this.config.sar,...e.sar},this.dirtySarConfig=!0),e.supertrend!==void 0&&!this.shallowEqual(e.supertrend,this.config.supertrend)&&(this.config.supertrend={...this.config.supertrend,...e.supertrend},this.dirtySupertrendConfig=!0),e.keltner!==void 0&&!this.shallowEqual(e.keltner,this.config.keltner)&&(this.config.keltner={...this.config.keltner,...e.keltner},this.dirtyKeltnerConfig=!0),e.donchian!==void 0&&!this.shallowEqual(e.donchian,this.config.donchian)&&(this.config.donchian={...this.config.donchian,...e.donchian},this.dirtyDonchianConfig=!0),e.ichimoku!==void 0&&!this.shallowEqual(e.ichimoku,this.config.ichimoku)&&(this.config.ichimoku={...this.config.ichimoku,...e.ichimoku},this.dirtyIchimokuConfig=!0),e.roc!==void 0&&!this.shallowEqual(e.roc,this.config.roc)&&(this.config.roc={...this.config.roc,...e.roc},this.dirtyRocConfig=!0),e.trix!==void 0&&!this.shallowEqual(e.trix,this.config.trix)&&(this.config.trix={...this.config.trix,...e.trix},this.dirtyTrixConfig=!0),e.hv!==void 0&&!this.shallowEqual(e.hv,this.config.hv)&&(this.config.hv={...this.config.hv,...e.hv},this.dirtyHvConfig=!0),e.parkinson!==void 0&&!this.shallowEqual(e.parkinson,this.config.parkinson)&&(this.config.parkinson={...this.config.parkinson,...e.parkinson},this.dirtyParkinsonConfig=!0),e.chaikinVol!==void 0&&!this.shallowEqual(e.chaikinVol,this.config.chaikinVol)&&(this.config.chaikinVol={...this.config.chaikinVol,...e.chaikinVol},this.dirtyChaikinVolConfig=!0),e.vma!==void 0&&!this.shallowEqual(e.vma,this.config.vma)&&(this.config.vma={...this.config.vma,...e.vma},this.dirtyVmaConfig=!0),e.obv!==void 0&&!this.shallowEqual(e.obv,this.config.obv)&&(this.config.obv={...this.config.obv,...e.obv},this.dirtyObvConfig=!0),e.pvt!==void 0&&!this.shallowEqual(e.pvt,this.config.pvt)&&(this.config.pvt={...this.config.pvt,...e.pvt},this.dirtyPvtConfig=!0),e.vwap!==void 0&&!this.shallowEqual(e.vwap,this.config.vwap)&&(this.config.vwap={...this.config.vwap,...e.vwap},this.dirtyVwapConfig=!0),e.cmf!==void 0&&!this.shallowEqual(e.cmf,this.config.cmf)&&(this.config.cmf={...this.config.cmf,...e.cmf},this.dirtyCmfConfig=!0),e.mfi!==void 0&&!this.shallowEqual(e.mfi,this.config.mfi)&&(this.config.mfi={...this.config.mfi,...e.mfi},this.dirtyMfiConfig=!0),e.pivot!==void 0&&!this.shallowEqual(e.pivot,this.config.pivot)&&(this.config.pivot={...this.config.pivot,...e.pivot},this.dirtyPivotConfig=!0),e.fib!==void 0&&!this.shallowEqual(e.fib,this.config.fib)&&(this.config.fib={...this.config.fib,...e.fib},this.dirtyFibConfig=!0),e.structure!==void 0&&!this.shallowEqual(e.structure,this.config.structure)&&(this.config.structure={...this.config.structure,...e.structure},this.dirtyStructureConfig=!0),e.zones!==void 0&&!this.shallowEqual(e.zones,this.config.zones)&&(this.config.zones={...this.config.zones,...e.zones},this.dirtyZonesConfig=!0),e.volumeProfile!==void 0&&!this.shallowEqual(e.volumeProfile,this.config.volumeProfile)&&(this.config.volumeProfile={...this.config.volumeProfile,...e.volumeProfile},this.dirtyVolumeProfileConfig=!0),e.rsiPaneId!==void 0&&(this.config.rsiPaneId=e.rsiPaneId),e.cciPaneId!==void 0&&(this.config.cciPaneId=e.cciPaneId),e.stochPaneId!==void 0&&(this.config.stochPaneId=e.stochPaneId),e.momPaneId!==void 0&&(this.config.momPaneId=e.momPaneId),e.wmsrPaneId!==void 0&&(this.config.wmsrPaneId=e.wmsrPaneId),e.kstPaneId!==void 0&&(this.config.kstPaneId=e.kstPaneId),e.fastkPaneId!==void 0&&(this.config.fastkPaneId=e.fastkPaneId),e.macdPaneId!==void 0&&(this.config.macdPaneId=e.macdPaneId),e.atrPaneId!==void 0&&(this.config.atrPaneId=e.atrPaneId),e.wmaPaneId!==void 0&&(this.config.wmaPaneId=e.wmaPaneId),e.demaPaneId!==void 0&&(this.config.demaPaneId=e.demaPaneId),e.temaPaneId!==void 0&&(this.config.temaPaneId=e.temaPaneId),e.hmaPaneId!==void 0&&(this.config.hmaPaneId=e.hmaPaneId),e.kamaPaneId!==void 0&&(this.config.kamaPaneId=e.kamaPaneId),e.sarPaneId!==void 0&&(this.config.sarPaneId=e.sarPaneId),e.supertrendPaneId!==void 0&&(this.config.supertrendPaneId=e.supertrendPaneId),e.keltnerPaneId!==void 0&&(this.config.keltnerPaneId=e.keltnerPaneId),e.donchianPaneId!==void 0&&(this.config.donchianPaneId=e.donchianPaneId),e.ichimokuPaneId!==void 0&&(this.config.ichimokuPaneId=e.ichimokuPaneId),e.rocPaneId!==void 0&&(this.config.rocPaneId=e.rocPaneId),e.trixPaneId!==void 0&&(this.config.trixPaneId=e.trixPaneId),e.hvPaneId!==void 0&&(this.config.hvPaneId=e.hvPaneId),e.parkinsonPaneId!==void 0&&(this.config.parkinsonPaneId=e.parkinsonPaneId),e.chaikinVolPaneId!==void 0&&(this.config.chaikinVolPaneId=e.chaikinVolPaneId),e.vmaPaneId!==void 0&&(this.config.vmaPaneId=e.vmaPaneId),e.obvPaneId!==void 0&&(this.config.obvPaneId=e.obvPaneId),e.pvtPaneId!==void 0&&(this.config.pvtPaneId=e.pvtPaneId),e.vwapPaneId!==void 0&&(this.config.vwapPaneId=e.vwapPaneId),e.cmfPaneId!==void 0&&(this.config.cmfPaneId=e.cmfPaneId),e.mfiPaneId!==void 0&&(this.config.mfiPaneId=e.mfiPaneId),e.pivotPaneId!==void 0&&(this.config.pivotPaneId=e.pivotPaneId),e.fibPaneId!==void 0&&(this.config.fibPaneId=e.fibPaneId),e.structurePaneId!==void 0&&(this.config.structurePaneId=e.structurePaneId),e.zonesPaneId!==void 0&&(this.config.zonesPaneId=e.zonesPaneId),e.volumeProfilePaneId!==void 0&&(this.config.volumeProfilePaneId=e.volumeProfilePaneId),this.configVersion=t}forceDirty(){this.dirtyData=!0,this.dirtyMAConfig=!0,this.dirtyBollConfig=!0,this.dirtyExpmaConfig=!0,this.dirtyEneConfig=!0,this.dirtyRsiConfig=!0,this.dirtyCciConfig=!0,this.dirtyStochConfig=!0,this.dirtyMomConfig=!0,this.dirtyWmsrConfig=!0,this.dirtyKstConfig=!0,this.dirtyFastkConfig=!0,this.dirtyMacdConfig=!0,this.dirtyAtrConfig=!0,this.dirtyWmaConfig=!0,this.dirtyDemaConfig=!0,this.dirtyTemaConfig=!0,this.dirtyHmaConfig=!0,this.dirtyKamaConfig=!0,this.dirtySarConfig=!0,this.dirtySupertrendConfig=!0,this.dirtyKeltnerConfig=!0,this.dirtyDonchianConfig=!0,this.dirtyIchimokuConfig=!0,this.dirtyRocConfig=!0,this.dirtyTrixConfig=!0,this.dirtyHvConfig=!0,this.dirtyParkinsonConfig=!0,this.dirtyChaikinVolConfig=!0,this.dirtyVmaConfig=!0,this.dirtyObvConfig=!0,this.dirtyPvtConfig=!0,this.dirtyVwapConfig=!0,this.dirtyCmfConfig=!0,this.dirtyMfiConfig=!0,this.dirtyPivotConfig=!0,this.dirtyFibConfig=!0,this.dirtyStructureConfig=!0,this.dirtyZonesConfig=!0,this.dirtyVolumeProfileConfig=!0}getDataVersion(){return this.dataVersion}getConfigVersion(){return this.configVersion}computeSeries(){let e=this.currentData,t=[];if(this.dirtyData||this.dirtyMAConfig){this.cachedSeries={};for(let t of ti){let n=`ma${t}`;this.config.ma[n]&&(this.cachedSeries[t]=ai(e,t))}t.push(`ma`)}if((this.dirtyData||this.dirtyBollConfig)&&(this.cachedBollSeries=ni(e,this.config.boll.period,this.config.boll.multiplier),t.push(`boll`)),(this.dirtyData||this.dirtyExpmaConfig)&&(this.cachedExpmaSeries=ri(e,this.config.expma.fastPeriod,this.config.expma.slowPeriod),t.push(`expma`)),(this.dirtyData||this.dirtyEneConfig)&&(this.cachedEneSeries=ii(e,this.config.ene.period,this.config.ene.deviation),t.push(`ene`)),this.dirtyData||this.dirtyRsiConfig){this.cachedRsiSeries={};let n=[this.config.rsi.period1,this.config.rsi.period2,this.config.rsi.period3],r=[this.config.rsi.showRSI1,this.config.rsi.showRSI2,this.config.rsi.showRSI3];for(let t=0;t<n.length;t++)r[t]&&(this.cachedRsiSeries[n[t]]=oi(e,n[t]));t.push(`rsi`)}if((this.dirtyData||this.dirtyCciConfig)&&(this.config.cci.showCCI?this.cachedCciSeries=si(e,this.config.cci.period):this.cachedCciSeries=[],t.push(`cci`)),(this.dirtyData||this.dirtyStochConfig)&&(this.config.stoch.showK||this.config.stoch.showD?this.cachedStochSeries=ci(e,this.config.stoch.n,this.config.stoch.m):this.cachedStochSeries=[],t.push(`stoch`)),(this.dirtyData||this.dirtyMomConfig)&&(this.config.mom.showMOM?this.cachedMomSeries=li(e,this.config.mom.period):this.cachedMomSeries=[],t.push(`mom`)),(this.dirtyData||this.dirtyWmsrConfig)&&(this.config.wmsr.showWMSR?this.cachedWmsrSeries=ui(e,this.config.wmsr.period):this.cachedWmsrSeries=[],t.push(`wmsr`)),(this.dirtyData||this.dirtyKstConfig)&&(this.config.kst.showKST||this.config.kst.showSignal?this.cachedKstSeries=pi(e,this.config.kst.roc1,this.config.kst.roc2,this.config.kst.roc3,this.config.kst.roc4,this.config.kst.signalPeriod):this.cachedKstSeries=[],t.push(`kst`)),(this.dirtyData||this.dirtyFastkConfig)&&(this.config.fastk.showFASTK?this.cachedFastkSeries=mi(e,this.config.fastk.period):this.cachedFastkSeries=[],t.push(`fastk`)),(this.dirtyData||this.dirtyMacdConfig)&&(this.config.macd.showDIF||this.config.macd.showDEA||this.config.macd.showBAR?this.cachedMacdSeries=_i(e,this.config.macd.fastPeriod,this.config.macd.slowPeriod,this.config.macd.signalPeriod):this.cachedMacdSeries=[],t.push(`macd`)),(this.dirtyData||this.dirtyAtrConfig)&&(this.config.atr.showATR?this.cachedAtrSeries=vi(e,this.config.atr.period):this.cachedAtrSeries=[],t.push(`atr`)),(this.dirtyData||this.dirtyWmaConfig)&&(this.config.wma.showWMA?this.cachedWmaSeries=bi(e,this.config.wma.period):this.cachedWmaSeries=[],t.push(`wma`)),(this.dirtyData||this.dirtyDemaConfig)&&(this.config.dema.showDEMA?this.cachedDemaSeries=Si(e,this.config.dema.period):this.cachedDemaSeries=[],t.push(`dema`)),(this.dirtyData||this.dirtyTemaConfig)&&(this.config.tema.showTEMA?this.cachedTemaSeries=Ci(e,this.config.tema.period):this.cachedTemaSeries=[],t.push(`tema`)),(this.dirtyData||this.dirtyHmaConfig)&&(this.config.hma.showHMA?this.cachedHmaSeries=wi(e,this.config.hma.period):this.cachedHmaSeries=[],t.push(`hma`)),(this.dirtyData||this.dirtyKamaConfig)&&(this.config.kama.showKAMA?this.cachedKamaSeries=Ti(e,this.config.kama.period,this.config.kama.fastPeriod,this.config.kama.slowPeriod):this.cachedKamaSeries=[],t.push(`kama`)),(this.dirtyData||this.dirtySarConfig)&&(this.config.sar.showSAR?this.cachedSarSeries=Oi(e,this.config.sar.step,this.config.sar.maxStep):this.cachedSarSeries=[],t.push(`sar`)),(this.dirtyData||this.dirtySupertrendConfig)&&(this.config.supertrend.showSuperTrend?this.cachedSupertrendSeries=ki(e,this.config.supertrend.atrPeriod,this.config.supertrend.multiplier):this.cachedSupertrendSeries=[],t.push(`supertrend`)),(this.dirtyData||this.dirtyKeltnerConfig)&&(this.config.keltner.showUpper||this.config.keltner.showMiddle||this.config.keltner.showLower?this.cachedKeltnerSeries=Ai(e,this.config.keltner.emaPeriod,this.config.keltner.atrPeriod,this.config.keltner.multiplier):this.cachedKeltnerSeries=[],t.push(`keltner`)),(this.dirtyData||this.dirtyDonchianConfig)&&(this.config.donchian.showUpper||this.config.donchian.showMiddle||this.config.donchian.showLower?this.cachedDonchianSeries=ji(e,this.config.donchian.period):this.cachedDonchianSeries=[],t.push(`donchian`)),this.dirtyData||this.dirtyIchimokuConfig){let n=this.config.ichimoku;n.showTenkan||n.showKijun||n.showSpanA||n.showSpanB||n.showCloud||n.showChikou?this.cachedIchimokuSeries=Ni(e,n.tenkanPeriod,n.kijunPeriod,n.spanBPeriod,n.displacement):this.cachedIchimokuSeries=[],t.push(`ichimoku`)}if((this.dirtyData||this.dirtyRocConfig)&&(this.config.roc.showROC?this.cachedRocSeries=Pi(e,this.config.roc.period):this.cachedRocSeries=[],t.push(`roc`)),this.dirtyData||this.dirtyTrixConfig){if(this.config.trix.showTRIX||this.config.trix.showSignal){let t=Fi(e,this.config.trix.period,this.config.trix.signalPeriod);this.cachedTrixSeries=t.series,this.cachedTrixSignalSeries=t.signalSeries}else this.cachedTrixSeries=[],this.cachedTrixSignalSeries=[];t.push(`trix`)}if((this.dirtyData||this.dirtyHvConfig)&&(this.config.hv.showHV?this.cachedHvSeries=Ii(e,this.config.hv.period,this.config.hv.annualizationFactor):this.cachedHvSeries=[],t.push(`hv`)),(this.dirtyData||this.dirtyParkinsonConfig)&&(this.config.parkinson.showParkinson?this.cachedParkinsonSeries=Li(e,this.config.parkinson.period,this.config.parkinson.annualizationFactor):this.cachedParkinsonSeries=[],t.push(`parkinson`)),(this.dirtyData||this.dirtyChaikinVolConfig)&&(this.config.chaikinVol.showChaikinVol?this.cachedChaikinVolSeries=Ri(e,this.config.chaikinVol.emaPeriod,this.config.chaikinVol.rocPeriod):this.cachedChaikinVolSeries=[],t.push(`chaikinVol`)),(this.dirtyData||this.dirtyVmaConfig)&&(this.config.vma.showVMA?this.cachedVmaSeries=zi(e,this.config.vma.period):this.cachedVmaSeries=[],t.push(`vma`)),(this.dirtyData||this.dirtyObvConfig)&&(this.config.obv.showOBV?this.cachedObvSeries=Bi(e):this.cachedObvSeries=[],t.push(`obv`)),(this.dirtyData||this.dirtyPvtConfig)&&(this.config.pvt.showPVT?this.cachedPvtSeries=Vi(e):this.cachedPvtSeries=[],t.push(`pvt`)),(this.dirtyData||this.dirtyVwapConfig)&&(this.config.vwap.showVWAP?this.cachedVwapSeries=Hi(e,this.config.vwap.sessionResetGapMs):this.cachedVwapSeries=[],t.push(`vwap`)),(this.dirtyData||this.dirtyCmfConfig)&&(this.config.cmf.showCMF?this.cachedCmfSeries=Ui(e,this.config.cmf.period):this.cachedCmfSeries=[],t.push(`cmf`)),(this.dirtyData||this.dirtyMfiConfig)&&(this.config.mfi.showMFI?this.cachedMfiSeries=Wi(e,this.config.mfi.period):this.cachedMfiSeries=[],t.push(`mfi`)),this.dirtyData||this.dirtyPivotConfig){let n=this.config.pivot;n.showPP||n.showR1||n.showR2||n.showR3||n.showS1||n.showS2||n.showS3?this.cachedPivotSeries=Gi(e):this.cachedPivotSeries=[],t.push(`pivot`)}if((this.dirtyData||this.dirtyFibConfig)&&(this.config.fib.showLevels?this.cachedFibSeries=Ki(e,this.config.fib.period):this.cachedFibSeries=[],t.push(`fib`)),this.dirtyData||this.dirtyStructureConfig){let n=this.config.structure;n.showSwingLabels||n.showBOS||n.showCHOCH?this.cachedStructureSeries=qi(e,n.leftWindow,n.rightWindow,n.breakoutSource):this.cachedStructureSeries={swings:[],events:[],trend:`range`},t.push(`structure`)}if(this.dirtyData||this.dirtyZonesConfig){let n=this.config.zones;n.showFVG||n.showOB?this.cachedZonesSeries=Yi(e,n.obLookback,this.config.structure.leftWindow,this.config.structure.rightWindow,this.config.structure.breakoutSource):this.cachedZonesSeries=[],t.push(`zones`)}if(this.dirtyData||this.dirtyVolumeProfileConfig){let n=this.config.volumeProfile;n.showPOC||n.showValueArea?this.cachedVolumeProfileSeries=Zi(e,n.bins,n.lookback,n.valueAreaPercent):this.cachedVolumeProfileSeries={bins:[],poc:0,vah:0,val:0,totalVolume:0},t.push(`volumeProfile`)}return this.dirtyData=!1,this.dirtyMAConfig=!1,this.dirtyBollConfig=!1,this.dirtyExpmaConfig=!1,this.dirtyEneConfig=!1,this.dirtyRsiConfig=!1,this.dirtyCciConfig=!1,this.dirtyStochConfig=!1,this.dirtyMomConfig=!1,this.dirtyWmsrConfig=!1,this.dirtyKstConfig=!1,this.dirtyFastkConfig=!1,this.dirtyMacdConfig=!1,this.dirtyAtrConfig=!1,this.dirtyWmaConfig=!1,this.dirtyDemaConfig=!1,this.dirtyTemaConfig=!1,this.dirtyHmaConfig=!1,this.dirtyKamaConfig=!1,this.dirtySarConfig=!1,this.dirtySupertrendConfig=!1,this.dirtyKeltnerConfig=!1,this.dirtyDonchianConfig=!1,this.dirtyIchimokuConfig=!1,this.dirtyRocConfig=!1,this.dirtyTrixConfig=!1,this.dirtyHvConfig=!1,this.dirtyParkinsonConfig=!1,this.dirtyChaikinVolConfig=!1,this.dirtyVmaConfig=!1,this.dirtyObvConfig=!1,this.dirtyPvtConfig=!1,this.dirtyVwapConfig=!1,this.dirtyCmfConfig=!1,this.dirtyMfiConfig=!1,this.dirtyPivotConfig=!1,this.dirtyFibConfig=!1,this.dirtyStructureConfig=!1,this.dirtyZonesConfig=!1,this.dirtyVolumeProfileConfig=!1,{ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}},atr:{series:this.cachedAtrSeries,params:{...this.config.atr}},wma:{series:this.cachedWmaSeries,params:{...this.config.wma}},dema:{series:this.cachedDemaSeries,params:{...this.config.dema}},tema:{series:this.cachedTemaSeries,params:{...this.config.tema}},hma:{series:this.cachedHmaSeries,params:{...this.config.hma}},kama:{series:this.cachedKamaSeries,params:{...this.config.kama}},sar:{series:this.cachedSarSeries,params:{...this.config.sar}},supertrend:{series:this.cachedSupertrendSeries,params:{...this.config.supertrend}},keltner:{series:this.cachedKeltnerSeries,params:{...this.config.keltner}},donchian:{series:this.cachedDonchianSeries,params:{...this.config.donchian}},ichimoku:{series:this.cachedIchimokuSeries,params:{...this.config.ichimoku}},roc:{series:this.cachedRocSeries,params:{...this.config.roc}},trix:{series:this.cachedTrixSeries,signalSeries:this.cachedTrixSignalSeries,params:{...this.config.trix}},hv:{series:this.cachedHvSeries,params:{...this.config.hv}},parkinson:{series:this.cachedParkinsonSeries,params:{...this.config.parkinson}},chaikinVol:{series:this.cachedChaikinVolSeries,params:{...this.config.chaikinVol}},vma:{series:this.cachedVmaSeries,params:{...this.config.vma}},obv:{series:this.cachedObvSeries,params:{...this.config.obv}},pvt:{series:this.cachedPvtSeries,params:{...this.config.pvt}},vwap:{series:this.cachedVwapSeries,params:{...this.config.vwap}},cmf:{series:this.cachedCmfSeries,params:{...this.config.cmf}},mfi:{series:this.cachedMfiSeries,params:{...this.config.mfi}},pivot:{series:this.cachedPivotSeries,params:{...this.config.pivot}},fib:{series:this.cachedFibSeries,params:{...this.config.fib}},structure:{series:this.cachedStructureSeries,params:{...this.config.structure}},zones:{series:this.cachedZonesSeries,params:{...this.config.zones}},volumeProfile:{series:this.cachedVolumeProfileSeries,params:{...this.config.volumeProfile}},_changed:t}}getCachedSeries(){return{_changed:[],ma:{series:this.cachedSeries,enabledPeriods:Object.keys(this.cachedSeries).map(Number)},boll:{series:this.cachedBollSeries,params:{...this.config.boll}},expma:{series:this.cachedExpmaSeries,params:{...this.config.expma}},ene:{series:this.cachedEneSeries,params:{...this.config.ene}},rsi:{series:this.cachedRsiSeries,enabledPeriods:Object.keys(this.cachedRsiSeries).map(Number),params:{...this.config.rsi}},cci:{series:this.cachedCciSeries,params:{...this.config.cci}},stoch:{series:this.cachedStochSeries,params:{...this.config.stoch}},mom:{series:this.cachedMomSeries,params:{...this.config.mom}},wmsr:{series:this.cachedWmsrSeries,params:{...this.config.wmsr}},kst:{series:this.cachedKstSeries,params:{...this.config.kst}},fastk:{series:this.cachedFastkSeries,params:{...this.config.fastk}},macd:{series:this.cachedMacdSeries,params:{...this.config.macd}},atr:{series:this.cachedAtrSeries,params:{...this.config.atr}},wma:{series:this.cachedWmaSeries,params:{...this.config.wma}},dema:{series:this.cachedDemaSeries,params:{...this.config.dema}},tema:{series:this.cachedTemaSeries,params:{...this.config.tema}},hma:{series:this.cachedHmaSeries,params:{...this.config.hma}},kama:{series:this.cachedKamaSeries,params:{...this.config.kama}},sar:{series:this.cachedSarSeries,params:{...this.config.sar}},supertrend:{series:this.cachedSupertrendSeries,params:{...this.config.supertrend}},keltner:{series:this.cachedKeltnerSeries,params:{...this.config.keltner}},donchian:{series:this.cachedDonchianSeries,params:{...this.config.donchian}},ichimoku:{series:this.cachedIchimokuSeries,params:{...this.config.ichimoku}},roc:{series:this.cachedRocSeries,params:{...this.config.roc}},trix:{series:this.cachedTrixSeries,signalSeries:this.cachedTrixSignalSeries,params:{...this.config.trix}},hv:{series:this.cachedHvSeries,params:{...this.config.hv}},parkinson:{series:this.cachedParkinsonSeries,params:{...this.config.parkinson}},chaikinVol:{series:this.cachedChaikinVolSeries,params:{...this.config.chaikinVol}},vma:{series:this.cachedVmaSeries,params:{...this.config.vma}},obv:{series:this.cachedObvSeries,params:{...this.config.obv}},pvt:{series:this.cachedPvtSeries,params:{...this.config.pvt}},vwap:{series:this.cachedVwapSeries,params:{...this.config.vwap}},cmf:{series:this.cachedCmfSeries,params:{...this.config.cmf}},mfi:{series:this.cachedMfiSeries,params:{...this.config.mfi}},pivot:{series:this.cachedPivotSeries,params:{...this.config.pivot}},fib:{series:this.cachedFibSeries,params:{...this.config.fib}},structure:{series:this.cachedStructureSeries,params:{...this.config.structure}},zones:{series:this.cachedZonesSeries,params:{...this.config.zones}},volumeProfile:{series:this.cachedVolumeProfileSeries,params:{...this.config.volumeProfile}}}}};function $i(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.type==`string`?[`ready`,`seriesResult`,`error`].includes(t.type):!1}var W=(e,t)=>`indicator:${e}:${t}`,ea=e=>W(`rsi`,e),ta={timestamp:0,series:{},enabledPeriods:[],params:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},na=e=>W(`cci`,e),ra={timestamp:0,series:[],params:{period:14,showCCI:!0},valueMin:-150,valueMax:150,visibleMin:1/0,visibleMax:-1/0},ia=e=>W(`stoch`,e),aa={timestamp:0,series:[],params:{n:9,m:3,showK:!0,showD:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},oa=e=>W(`mom`,e),sa={timestamp:0,series:[],params:{period:10,showMOM:!0},valueMin:0,valueMax:0,visibleMin:1/0,visibleMax:-1/0},ca=e=>W(`wmsr`,e),la={timestamp:0,series:[],params:{period:14,showWMSR:!0},valueMin:-100,valueMax:0,visibleMin:1/0,visibleMax:-1/0},ua=e=>W(`kst`,e),da={timestamp:0,series:[],params:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},valueMin:0,valueMax:0,visibleMin:1/0,visibleMax:-1/0},fa=e=>W(`fastk`,e),pa={timestamp:0,series:[],params:{period:9,showFASTK:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},ma=`indicator:macd`;function ha(e){return`${ma}:${e}`}var ga={timestamp:0,series:[],params:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},visibleMin:1/0,visibleMax:-1/0,valueMin:-1/0,valueMax:1/0},_a=e=>W(`atr`,e),va={timestamp:0,series:[],params:{period:14,showATR:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},ya=e=>W(`wma`,e),ba={timestamp:0,series:[],params:{period:9,showWMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},xa=e=>W(`dema`,e),Sa={timestamp:0,series:[],params:{period:20,showDEMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Ca=e=>W(`tema`,e),wa={timestamp:0,series:[],params:{period:20,showTEMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Ta=e=>W(`hma`,e),Ea={timestamp:0,series:[],params:{period:9,showHMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Da=e=>W(`kama`,e),Oa={timestamp:0,series:[],params:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},ka=e=>W(`sar`,e),Aa=.02,ja=.2,Ma={timestamp:0,series:[],params:{step:Aa,maxStep:ja,showSAR:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Na=e=>W(`supertrend`,e),Pa={timestamp:0,series:[],params:{atrPeriod:10,multiplier:3,showSuperTrend:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Fa=e=>W(`keltner`,e),Ia={timestamp:0,series:[],params:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},La=e=>W(`donchian`,e),Ra={timestamp:0,series:[],params:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},za=e=>W(`ichimoku`,e),Ba={timestamp:0,series:[],params:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showCloud:!0,showChikou:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Va=e=>W(`roc`,e),Ha={timestamp:0,series:[],params:{period:12,showROC:!0},valueMin:-10,valueMax:10,visibleMin:1/0,visibleMax:-1/0},Ua=e=>W(`trix`,e),Wa={timestamp:0,series:[],signalSeries:[],params:{period:15,signalPeriod:9,showTRIX:!0,showSignal:!0},valueMin:-10,valueMax:10,visibleMin:1/0,visibleMax:-1/0},Ga=e=>W(`hv`,e),Ka={timestamp:0,series:[],params:{period:20,annualizationFactor:252,showHV:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},qa=e=>W(`parkinson`,e),Ja={timestamp:0,series:[],params:{period:20,annualizationFactor:252,showParkinson:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},Ya=e=>W(`chaikinVol`,e),Xa={timestamp:0,series:[],params:{emaPeriod:10,rocPeriod:10,showChaikinVol:!0},valueMin:-50,valueMax:50,visibleMin:1/0,visibleMax:-1/0},Za=e=>W(`vma`,e),Qa={timestamp:0,series:[],params:{period:5,showVMA:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},$a=e=>W(`obv`,e),eo={timestamp:0,series:[],params:{showOBV:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},to=e=>W(`pvt`,e),no={timestamp:0,series:[],params:{showPVT:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},ro=e=>W(`vwap`,e),io={timestamp:0,series:[],params:{sessionResetGapMs:0,showVWAP:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},ao=e=>W(`cmf`,e),oo={timestamp:0,series:[],params:{period:20,showCMF:!0},valueMin:-1,valueMax:1,visibleMin:1/0,visibleMax:-1/0},so=e=>W(`mfi`,e),co={timestamp:0,series:[],params:{period:14,showMFI:!0},valueMin:0,valueMax:100,visibleMin:1/0,visibleMax:-1/0},lo=e=>W(`pivot`,e),uo={timestamp:0,series:[],params:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},fo=e=>W(`fib`,e),po={timestamp:0,series:[],params:{period:50,showLevels:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},mo=e=>W(`structure`,e),ho={timestamp:0,series:{swings:[],events:[],trend:`range`},params:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},go=e=>W(`zones`,e),_o={timestamp:0,series:[],params:{showFVG:!0,showOB:!0,showFilledZones:!1,obLookback:5},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0},vo=e=>W(`volumeProfile`,e),yo=.7,bo={timestamp:0,series:{bins:[],poc:0,vah:0,val:0,totalVolume:0},params:{bins:24,lookback:0,valueAreaPercent:yo,showPOC:!0,showValueArea:!0},valueMin:0,valueMax:1,visibleMin:1/0,visibleMax:-1/0};function xo(e,t){let n=t.end-1;return n>=0&&n<e.macd.series.length?e.macd.series[n]:null}function G(e,t,n){return{...e,...n,timestamp:t}}function So(e,t,n,r={}){let i=r.rsi??!0,a=r.cci??!0,o=r.stoch??!0,s=r.mom??!0,c=r.wmsr??!0,l=r.kst??!0,u=r.fastk??!0,d=r.macd??!0,f=r.atr??!0,p=r.wma??!0,m=r.dema??!0,h=r.tema??!0,g=r.hma??!0,_=r.kama??!0,v=r.sar??!0,y=r.supertrend??!0,b=r.keltner??!0,x=r.donchian??!0,S=r.ichimoku??!0,C=r.roc??!0,w=r.trix??!0,T=r.hv??!0,E=r.parkinson??!0,D=r.chaikinVol??!0,O=r.vma??!0,k=r.obv??!0,A=r.pvt??!0,j=r.vwap??!0,M=r.cmf??!0,N=r.mfi??!0,P=r.pivot??!0,F=r.fib??!0,I=r.structure??!0,L=r.zones??!0,ee=r.volumeProfile??!0,R=i?Oo(e.rsi.series,t):null,te=a?ko(e.cci.series,t):null,ne=o?Ao(e.stoch.series,t):null,re=s?jo(e.mom.series,t):null,ie=c?Mo(e.wmsr.series,t):null,ae=l?No(e.kst.series,t):null,oe=u?Po(e.fastk.series,t):null,se=d?Fo(e.macd.series,t):null,ce=f?Io(e.atr.series,t):null,le=p?K(e.wma.series,t):null,ue=m?K(e.dema.series,t):null,de=h?K(e.tema.series,t):null,fe=g?K(e.hma.series,t):null,pe=_?K(e.kama.series,t):null,me=v?Vo(e.sar.series,t):null,he=y?Vo(e.supertrend.series,t):null,ge=b?Bo(e.keltner.series,t):null,_e=x?Bo(e.donchian.series,t):null,ve=S?zo(e.ichimoku.series,t):null,ye=C?K(e.roc.series,t):null,be=w?K(e.trix.series,t):null,xe=w?K(e.trix.signalSeries,t):null,Se=T?K(e.hv.series,t):null,Ce=E?K(e.parkinson.series,t):null,we=D?K(e.chaikinVol.series,t):null,Te=O?K(e.vma.series,t):null,Ee=k?K(e.obv.series,t):null,De=A?K(e.pvt.series,t):null,Oe=j?K(e.vwap.series,t):null,ke=M?K(e.cmf.series,t):null,Ae=N?K(e.mfi.series,t):null,je=P?Lo(e.pivot.series,t):null,Me=F?Ro(e.fib.series,t):null,Ne=d?xo(e,t):null,Pe=se?Math.max(Math.abs(se.max),Math.abs(se.min))*.1:0,Fe=se&&Number.isFinite(se.min)?se.min-Pe:ga.valueMin,Ie=se&&Number.isFinite(se.max)?se.max+Pe:ga.valueMax,z=te?Math.min(te.min,-150):ra.valueMin,Le=te?Math.max(te.max,150):ra.valueMax,Re=re?Math.max(Math.abs(re.max),Math.abs(re.min))*.1:0,ze=re?re.min-Re:sa.valueMin,Be=re?re.max+Re:sa.valueMax,Ve=(ae?ae.max-ae.min:0)*.1,He=ae?ae.min-Ve:da.valueMin,Ue=ae?ae.max+Ve:da.valueMax,We=ce&&Number.isFinite(ce.max)?ce.max*1.1:va.valueMax,B=(e,t)=>{if(!e||!Number.isFinite(e.min)||!Number.isFinite(e.max))return{valueMin:t.valueMin,valueMax:t.valueMax};let n=e.max-e.min,r=n>0?n*.05:Math.max(1,Math.abs(e.max)*.05);return{valueMin:e.min-r,valueMax:e.max+r}},Ge=B(le,ba),Ke=B(ue,Sa),qe=B(de,wa),Je=B(fe,Ea),Ye=B(pe,Oa),Xe=B(me,Ma),Ze=B(he,Pa),Qe=B(ge,Ia),$e=B(_e,Ra),et=B(ve,Ba),tt=B(ye,Ha),nt=Math.min(be?.min??1/0,xe?.min??1/0),rt=Math.max(be?.max??-1/0,xe?.max??-1/0),it=B(Number.isFinite(nt)&&Number.isFinite(rt)?{min:nt,max:rt}:null,Wa),at=Se&&Number.isFinite(Se.max)?Se.max*1.1:Ka.valueMax,ot=Ce&&Number.isFinite(Ce.max)?Ce.max*1.1:Ja.valueMax,st=B(we,Xa),ct=Te&&Number.isFinite(Te.max)?Te.max*1.1:Qa.valueMax,lt=B(Ee,eo),ut=B(De,no),dt=B(Oe,io);return{rsi:i?{timestamp:n,series:e.rsi.series,enabledPeriods:e.rsi.enabledPeriods,params:e.rsi.params,valueMin:0,valueMax:100,visibleMin:R.min,visibleMax:R.max}:G(ta,n,{series:e.rsi.series,enabledPeriods:e.rsi.enabledPeriods,params:e.rsi.params}),cci:a?{timestamp:n,series:e.cci.series,params:e.cci.params,valueMin:z,valueMax:Le,visibleMin:te.min,visibleMax:te.max}:G(ra,n,{series:e.cci.series,params:e.cci.params}),stoch:o?{timestamp:n,series:e.stoch.series,params:e.stoch.params,valueMin:0,valueMax:100,visibleMin:ne.min,visibleMax:ne.max}:G(aa,n,{series:e.stoch.series,params:e.stoch.params}),mom:s?{timestamp:n,series:e.mom.series,params:e.mom.params,valueMin:ze,valueMax:Be,visibleMin:re.min,visibleMax:re.max}:G(sa,n,{series:e.mom.series,params:e.mom.params}),wmsr:c?{timestamp:n,series:e.wmsr.series,params:e.wmsr.params,valueMin:-100,valueMax:0,visibleMin:ie.min,visibleMax:ie.max}:G(la,n,{series:e.wmsr.series,params:e.wmsr.params}),kst:l?{timestamp:n,series:e.kst.series,params:e.kst.params,valueMin:He,valueMax:Ue,visibleMin:ae.min,visibleMax:ae.max}:G(da,n,{series:e.kst.series,params:e.kst.params}),fastk:u?{timestamp:n,series:e.fastk.series,params:e.fastk.params,valueMin:0,valueMax:100,visibleMin:oe.min,visibleMax:oe.max}:G(pa,n,{series:e.fastk.series,params:e.fastk.params}),macd:d?{timestamp:n,series:e.macd.series,params:e.macd.params,valueMin:Fe,valueMax:Ie,visibleMin:se.min,visibleMax:se.max,latestValues:Ne?{dif:Ne.dif,dea:Ne.dea,macd:Ne.macd}:void 0}:G(ga,n,{series:e.macd.series,params:e.macd.params}),atr:f?{timestamp:n,series:e.atr.series,params:e.atr.params,valueMin:0,valueMax:We,visibleMin:ce.min,visibleMax:ce.max}:G(va,n,{series:e.atr.series,params:e.atr.params}),wma:p?{timestamp:n,series:e.wma.series,params:e.wma.params,valueMin:Ge.valueMin,valueMax:Ge.valueMax,visibleMin:le.min,visibleMax:le.max}:G(ba,n,{series:e.wma.series,params:e.wma.params}),dema:m?{timestamp:n,series:e.dema.series,params:e.dema.params,valueMin:Ke.valueMin,valueMax:Ke.valueMax,visibleMin:ue.min,visibleMax:ue.max}:G(Sa,n,{series:e.dema.series,params:e.dema.params}),tema:h?{timestamp:n,series:e.tema.series,params:e.tema.params,valueMin:qe.valueMin,valueMax:qe.valueMax,visibleMin:de.min,visibleMax:de.max}:G(wa,n,{series:e.tema.series,params:e.tema.params}),hma:g?{timestamp:n,series:e.hma.series,params:e.hma.params,valueMin:Je.valueMin,valueMax:Je.valueMax,visibleMin:fe.min,visibleMax:fe.max}:G(Ea,n,{series:e.hma.series,params:e.hma.params}),kama:_?{timestamp:n,series:e.kama.series,params:e.kama.params,valueMin:Ye.valueMin,valueMax:Ye.valueMax,visibleMin:pe.min,visibleMax:pe.max}:G(Oa,n,{series:e.kama.series,params:e.kama.params}),sar:v?{timestamp:n,series:e.sar.series,params:e.sar.params,valueMin:Xe.valueMin,valueMax:Xe.valueMax,visibleMin:me.min,visibleMax:me.max}:G(Ma,n,{series:e.sar.series,params:e.sar.params}),supertrend:y?{timestamp:n,series:e.supertrend.series,params:e.supertrend.params,valueMin:Ze.valueMin,valueMax:Ze.valueMax,visibleMin:he.min,visibleMax:he.max}:G(Pa,n,{series:e.supertrend.series,params:e.supertrend.params}),keltner:b?{timestamp:n,series:e.keltner.series,params:e.keltner.params,valueMin:Qe.valueMin,valueMax:Qe.valueMax,visibleMin:ge.min,visibleMax:ge.max}:G(Ia,n,{series:e.keltner.series,params:e.keltner.params}),donchian:x?{timestamp:n,series:e.donchian.series,params:e.donchian.params,valueMin:$e.valueMin,valueMax:$e.valueMax,visibleMin:_e.min,visibleMax:_e.max}:G(Ra,n,{series:e.donchian.series,params:e.donchian.params}),ichimoku:S?{timestamp:n,series:e.ichimoku.series,params:e.ichimoku.params,valueMin:et.valueMin,valueMax:et.valueMax,visibleMin:ve.min,visibleMax:ve.max}:G(Ba,n,{series:e.ichimoku.series,params:e.ichimoku.params}),roc:C?{timestamp:n,series:e.roc.series,params:e.roc.params,valueMin:tt.valueMin,valueMax:tt.valueMax,visibleMin:ye.min,visibleMax:ye.max}:G(Ha,n,{series:e.roc.series,params:e.roc.params}),trix:w?{timestamp:n,series:e.trix.series,signalSeries:e.trix.signalSeries,params:e.trix.params,valueMin:it.valueMin,valueMax:it.valueMax,visibleMin:Math.min(be?.min??1/0,xe?.min??1/0),visibleMax:Math.max(be?.max??-1/0,xe?.max??-1/0)}:G(Wa,n,{series:e.trix.series,signalSeries:e.trix.signalSeries,params:e.trix.params}),hv:T?{timestamp:n,series:e.hv.series,params:e.hv.params,valueMin:0,valueMax:at,visibleMin:Se.min,visibleMax:Se.max}:G(Ka,n,{series:e.hv.series,params:e.hv.params}),parkinson:E?{timestamp:n,series:e.parkinson.series,params:e.parkinson.params,valueMin:0,valueMax:ot,visibleMin:Ce.min,visibleMax:Ce.max}:G(Ja,n,{series:e.parkinson.series,params:e.parkinson.params}),chaikinVol:D?{timestamp:n,series:e.chaikinVol.series,params:e.chaikinVol.params,valueMin:st.valueMin,valueMax:st.valueMax,visibleMin:we.min,visibleMax:we.max}:G(Xa,n,{series:e.chaikinVol.series,params:e.chaikinVol.params}),vma:O?{timestamp:n,series:e.vma.series,params:e.vma.params,valueMin:0,valueMax:ct,visibleMin:Te.min,visibleMax:Te.max}:G(Qa,n,{series:e.vma.series,params:e.vma.params}),obv:k?{timestamp:n,series:e.obv.series,params:e.obv.params,valueMin:lt.valueMin,valueMax:lt.valueMax,visibleMin:Ee.min,visibleMax:Ee.max}:G(eo,n,{series:e.obv.series,params:e.obv.params}),pvt:A?{timestamp:n,series:e.pvt.series,params:e.pvt.params,valueMin:ut.valueMin,valueMax:ut.valueMax,visibleMin:De.min,visibleMax:De.max}:G(no,n,{series:e.pvt.series,params:e.pvt.params}),vwap:j?{timestamp:n,series:e.vwap.series,params:e.vwap.params,valueMin:dt.valueMin,valueMax:dt.valueMax,visibleMin:Oe.min,visibleMax:Oe.max}:G(io,n,{series:e.vwap.series,params:e.vwap.params}),cmf:M?{timestamp:n,series:e.cmf.series,params:e.cmf.params,valueMin:-1,valueMax:1,visibleMin:ke.min,visibleMax:ke.max}:G(oo,n,{series:e.cmf.series,params:e.cmf.params}),mfi:N?{timestamp:n,series:e.mfi.series,params:e.mfi.params,valueMin:0,valueMax:100,visibleMin:Ae.min,visibleMax:Ae.max}:G(co,n,{series:e.mfi.series,params:e.mfi.params}),pivot:P?{timestamp:n,series:e.pivot.series,params:e.pivot.params,valueMin:je.min,valueMax:je.max,visibleMin:je.min,visibleMax:je.max}:G(uo,n,{series:e.pivot.series,params:e.pivot.params}),fib:F?{timestamp:n,series:e.fib.series,params:e.fib.params,valueMin:Me.min,valueMax:Me.max,visibleMin:Me.min,visibleMax:Me.max}:G(po,n,{series:e.fib.series,params:e.fib.params}),structure:I?{timestamp:n,series:e.structure.series,params:e.structure.params,valueMin:0,valueMax:1,visibleMin:0,visibleMax:1}:G(ho,n,{series:e.structure.series,params:e.structure.params}),zones:L?{timestamp:n,series:e.zones.series,params:e.zones.params,valueMin:0,valueMax:1,visibleMin:0,visibleMax:1}:G(_o,n,{series:e.zones.series,params:e.zones.params}),volumeProfile:ee?{timestamp:n,series:e.volumeProfile.series,params:e.volumeProfile.params,valueMin:e.volumeProfile.series.bins[0]?.priceLow??0,valueMax:e.volumeProfile.series.bins[e.volumeProfile.series.bins.length-1]?.priceHigh??1,visibleMin:e.volumeProfile.series.val,visibleMax:e.volumeProfile.series.vah}:G(bo,n,{series:e.volumeProfile.series,params:e.volumeProfile.params})}}function Co(e,t,n){let r=wo(e.ma.series,t),i=To(e.boll.series,t),a=Eo(e.expma.series,t),o=Do(e.ene.series,t),s=So(e,t,n);return{ma:{timestamp:n,series:e.ma.series,enabledPeriods:e.ma.enabledPeriods,visibleMin:r.min,visibleMax:r.max},boll:{timestamp:n,series:e.boll.series,params:e.boll.params,visibleMin:i.min,visibleMax:i.max},expma:{timestamp:n,series:e.expma.series,params:e.expma.params,visibleMin:a.min,visibleMax:a.max},ene:{timestamp:n,series:e.ene.series,params:e.ene.params,visibleMin:o.min,visibleMax:o.max},...s}}function wo(e,t){let n=Object.values(e);if(n.length===0||t.start>=n[0].length)return{min:1/0,max:-1/0};let r=1/0,i=-1/0;for(let e of n){let n=Math.min(t.end,e.length);for(let a=t.start;a<n;a++){let t=e[a];t!==void 0&&(r=Math.min(r,t),i=Math.max(i,t))}}return{min:r,max:i}}function To(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function Eo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.fast,t.slow),r=Math.max(r,t.fast,t.slow))}return{min:n,max:r}}function Do(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.upper,t.middle,t.lower),r=Math.max(r,t.upper,t.middle,t.lower))}return{min:n,max:r}}function Oo(e,t){let n=Object.values(e);if(n.length===0||t.start>=n[0].length)return{min:1/0,max:-1/0};let r=1/0,i=-1/0;for(let e of n){let n=Math.min(t.end,e.length);for(let a=t.start;a<n;a++){let t=e[a];t!==void 0&&(r=Math.min(r,t),i=Math.max(i,t))}}return{min:r,max:i}}function ko(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Ao(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.k,t.d),r=Math.max(r,t.k,t.d))}return{min:n,max:r}}function jo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Mo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function No(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.kst,t.signal),r=Math.max(r,t.kst,t.signal))}return{min:n,max:r}}function Po(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Fo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.dif,t.dea,t.macd),r=Math.max(r,t.dif,t.dea,t.macd))}return{min:n,max:r}}function Io(e,t){return K(e,t)}function Lo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];if(t)for(let e of[t.pp,t.r1,t.r2,t.r3,t.s1,t.s2,t.s3])e<n&&(n=e),e>r&&(r=e)}return{min:n,max:r}}function Ro(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(t.low<n&&(n=t.low),t.high>r&&(r=t.high))}return{min:n,max:r}}function zo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];if(t)for(let e of[t.tenkan,t.kijun,t.spanA,t.spanB,t.chikou])e!==void 0&&(e<n&&(n=e),e>r&&(r=e))}return{min:n,max:r}}function Bo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.lower),r=Math.max(r,t.upper))}return{min:n,max:r}}function Vo(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t&&(n=Math.min(n,t.value),r=Math.max(r,t.value))}return{min:n,max:r}}function K(e,t){if(e.length===0||t.start>=e.length)return{min:1/0,max:-1/0};let n=1/0,r=-1/0,i=Math.min(t.end,e.length);for(let a=t.start;a<i;a++){let t=e[a];t!==void 0&&(n=Math.min(n,t),r=Math.max(r,t))}return{min:n,max:r}}function Ho(e,t,n){let r=1/0,i=-1/0,{start:a,end:o}=t;if(n.has(`ma`)&&Object.keys(e.ma.series).length>0)for(let t of Object.values(e.ma.series))for(let e=a;e<o&&e<t.length;e++){let n=t[e];n!==void 0&&(r=Math.min(r,n),i=Math.max(i,n))}if(n.has(`boll`)&&e.boll.series.length>0)for(let t=a;t<o&&t<e.boll.series.length;t++){let n=e.boll.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}if(n.has(`expma`)&&e.expma.series.length>0)for(let t=a;t<o&&t<e.expma.series.length;t++){let n=e.expma.series[t];n&&(r=Math.min(r,n.fast,n.slow),i=Math.max(i,n.fast,n.slow))}if(n.has(`ene`)&&e.ene.series.length>0)for(let t=a;t<o&&t<e.ene.series.length;t++){let n=e.ene.series[t];n&&(r=Math.min(r,n.upper,n.middle,n.lower),i=Math.max(i,n.upper,n.middle,n.lower))}return!Number.isFinite(r)||!Number.isFinite(i)?null:{min:r,max:i}}var Uo=class{indicators=new Map;register(e){if(!e.name||typeof e.name!=`string`)throw Error(`[IndicatorRegistry] Indicator name is required`);if(!e.displayName)throw Error(`[IndicatorRegistry] displayName is required for indicator '${e.name}'`);if(!e.rendererFactory||typeof e.rendererFactory!=`function`)throw Error(`[IndicatorRegistry] rendererFactory is required for indicator '${e.name}'`);this.indicators.has(e.name)&&console.warn(`[IndicatorRegistry] Indicator '${e.name}' already registered, overwriting`),this.indicators.set(e.name,e)}unregister(e){return this.indicators.delete(e)}get(e){return this.indicators.get(e)}has(e){return this.indicators.has(e)}getAll(){return Array.from(this.indicators.values())}getMainIndicators(){return this.getAll().filter(e=>e.category===`main`)}getSubIndicators(){return this.getAll().filter(e=>e.category===`sub`)}getNames(){return Array.from(this.indicators.keys())}clear(){this.indicators.clear()}get size(){return this.indicators.size}},Wo=class{pluginHost=null;visibleRange={start:0,end:0};activeMainIndicators=new Set;dataVersion=0;configVersion=0;requestId=0;lastAppliedRequestId=0;currentData=[];configSnapshot=this.getDefaultConfig();worker=null;workerReady=!1;useWorker=!1;pendingRequest=null;inlineRuntime=null;latestResult=null;invalidateCallback=null;getActiveSubPaneIds=null;registry;constructor(){this.registry=new Uo,this.initBackend()}registerIndicator(e){this.registry.has(e.name)&&console.warn(`[IndicatorScheduler] '${e.name}' already registered, overwriting`),this.registry.register(e),this.configVersion++,this.triggerRecompute(),console.log(`[IndicatorScheduler] Registered indicator '${e.name}' (${e.displayName})`)}unregisterIndicator(e){let t=this.registry.unregister(e);return t&&(this.configVersion++,this.triggerRecompute(),console.log(`[IndicatorScheduler] Unregistered indicator '${e}'`)),t}getIndicatorMetadata(e){return this.registry.get(e)}getAllIndicators(){return this.registry.getAll()}setPluginHost(e){this.pluginHost=e,e.registerService(`indicatorScheduler`,this)}setInvalidateCallback(e){this.invalidateCallback=e}onSubPaneChanged(){this.latestResult&&this.updateVisibleStatesOnly()}setActiveSubPaneProvider(e){this.getActiveSubPaneIds=e}destroy(){this.terminateWorker(),this.inlineRuntime=null,this.latestResult=null,this.invalidateCallback=null}getDefaultConfig(){return{ma:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},boll:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},expma:{fastPeriod:12,slowPeriod:50},ene:{period:10,deviation:11},rsi:{period1:6,period2:12,period3:24,showRSI1:!0,showRSI2:!0,showRSI3:!0},cci:{period:14,showCCI:!0},stoch:{n:9,m:3,showK:!0,showD:!0},mom:{period:10,showMOM:!0},wmsr:{period:14,showWMSR:!0},kst:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},fastk:{period:9,showFASTK:!0},macd:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0},atr:{period:14,showATR:!0},wma:{period:9,showWMA:!0},dema:{period:20,showDEMA:!0},tema:{period:20,showTEMA:!0},hma:{period:9,showHMA:!0},kama:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},sar:{step:Aa,maxStep:ja,showSAR:!0},supertrend:{atrPeriod:10,multiplier:3,showSuperTrend:!0},keltner:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},donchian:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},ichimoku:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showCloud:!0,showChikou:!0},roc:{period:12,showROC:!0},trix:{period:15,signalPeriod:9,showTRIX:!0,showSignal:!0},hv:{period:20,annualizationFactor:252,showHV:!0},parkinson:{period:20,annualizationFactor:252,showParkinson:!0},chaikinVol:{emaPeriod:10,rocPeriod:10,showChaikinVol:!0},vma:{period:5,showVMA:!0},obv:{showOBV:!0},pvt:{showPVT:!0},vwap:{sessionResetGapMs:0,showVWAP:!0},cmf:{period:20,showCMF:!0},mfi:{period:14,showMFI:!0},pivot:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},fib:{period:50,showLevels:!0},structure:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},zones:{showFVG:!0,showOB:!0,showFilledZones:!1,obLookback:5},volumeProfile:{bins:24,lookback:0,valueAreaPercent:yo,showPOC:!0,showValueArea:!0},rsiPaneId:`sub_RSI`,cciPaneId:`sub_CCI`,stochPaneId:`sub_STOCH`,momPaneId:`sub_MOM`,wmsrPaneId:`sub_WMSR`,kstPaneId:`sub_KST`,fastkPaneId:`sub_FASTK`,macdPaneId:`sub_MACD`,atrPaneId:`sub_ATR`,wmaPaneId:`sub_WMA`,demaPaneId:`sub_DEMA`,temaPaneId:`sub_TEMA`,hmaPaneId:`sub_HMA`,kamaPaneId:`sub_KAMA`,sarPaneId:`sub_SAR`,supertrendPaneId:`sub_SuperTrend`,keltnerPaneId:`sub_Keltner`,donchianPaneId:`sub_Donchian`,ichimokuPaneId:`sub_Ichimoku`,rocPaneId:`sub_ROC`,trixPaneId:`sub_TRIX`,hvPaneId:`sub_HV`,parkinsonPaneId:`sub_Parkinson`,chaikinVolPaneId:`sub_ChaikinVol`,vmaPaneId:`sub_VMA`,obvPaneId:`sub_OBV`,pvtPaneId:`sub_PVT`,vwapPaneId:`sub_VWAP`,cmfPaneId:`sub_CMF`,mfiPaneId:`sub_MFI`,pivotPaneId:`sub_Pivot`,fibPaneId:`sub_Fib`,structurePaneId:`sub_Structure`,zonesPaneId:`sub_Zones`,volumeProfilePaneId:`sub_VolumeProfile`}}initBackend(){this.tryInitWorker()||this.initInlineRuntime()}tryInitWorker(){if(console.log(`[IndicatorScheduler] tryInitWorker: Worker available?`,typeof Worker<`u`),typeof Worker>`u`)return!1;try{let e=new URL(`data:video/mp2t;base64,LyoqCiAqIEluZGljYXRvciBXb3JrZXIg5YWl5Y+jCiAqIOi/kOihjOWcqOeLrOeri+e6v+eoi++8jOi0n+i0o+aMh+agh+iuoeeulwogKi8KCmltcG9ydCB0eXBlIHsKICAgIEluZGljYXRvcldvcmtlclJlcXVlc3QsCiAgICBJbmRpY2F0b3JXb3JrZXJSZXNwb25zZSwKICAgIEluZGljYXRvckNvbmZpZ1NuYXBzaG90LAp9IGZyb20gJy4vd29ya2VyUHJvdG9jb2wnCmltcG9ydCB7IFBST1RPQ09MX1ZFUlNJT04gfSBmcm9tICcuL3dvcmtlclByb3RvY29sJwppbXBvcnQgdHlwZSB7IEtMaW5lRGF0YSB9IGZyb20gJ0AvdHlwZXMvcHJpY2UnCmltcG9ydCB7IEluZGljYXRvclJ1bnRpbWUgfSBmcm9tICcuL2luZGljYXRvclJ1bnRpbWUnCgovLyBXb3JrZXIg5YWo5bGA5L2c55So5Z+fCmNvbnN0IGN0eCA9IHNlbGYgYXMgdW5rbm93biBhcyBXb3JrZXIKCi8vIOi/kOihjOaXtuWunuS+iwpsZXQgcnVudGltZTogSW5kaWNhdG9yUnVudGltZSB8IG51bGwgPSBudWxsCgovKioKICog5Y+R6YCB5ZON5bqU5Yiw5Li757q/56iLCiAqLwpmdW5jdGlvbiBwb3N0UmVzcG9uc2UocmVzcG9uc2U6IEluZGljYXRvcldvcmtlclJlc3BvbnNlKTogdm9pZCB7CiAgICBjdHgucG9zdE1lc3NhZ2UocmVzcG9uc2UpCn0KCi8qKgogKiDlpITnkIbliJ3lp4vljJYKICovCmZ1bmN0aW9uIGhhbmRsZUluaXQoKTogdm9pZCB7CiAgICBydW50aW1lID0gbmV3IEluZGljYXRvclJ1bnRpbWUoKQogICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICB0eXBlOiAncmVhZHknLAogICAgICAgIHByb3RvY29sVmVyc2lvbjogUFJPVE9DT0xfVkVSU0lPTiwKICAgIH0pCn0KCi8qKgogKiDlpITnkIborr7nva7mlbDmja4KICovCmZ1bmN0aW9uIGhhbmRsZVNldERhdGEoZGF0YTogS0xpbmVEYXRhW10sIHZlcnNpb246IG51bWJlcik6IHZvaWQgewogICAgaWYgKCFydW50aW1lKSB7CiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgc3RhZ2U6ICdzZXREYXRhJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXREYXRhKGRhdGEsIHZlcnNpb24pCn0KCi8qKgogKiDlpITnkIborr7nva7phY3nva4KICovCmZ1bmN0aW9uIGhhbmRsZVNldENvbmZpZyhjb25maWc6IFBhcnRpYWw8SW5kaWNhdG9yQ29uZmlnU25hcHNob3Q+LCB2ZXJzaW9uOiBudW1iZXIpOiB2b2lkIHsKICAgIGlmICghcnVudGltZSkgewogICAgICAgIHBvc3RSZXNwb25zZSh7CiAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgIHN0YWdlOiAnc2V0Q29uZmlnJywKICAgICAgICAgICAgbWVzc2FnZTogJ1J1bnRpbWUgbm90IGluaXRpYWxpemVkJywKICAgICAgICB9KQogICAgICAgIHJldHVybgogICAgfQogICAgcnVudGltZS5zZXRDb25maWcoY29uZmlnLCB2ZXJzaW9uKQp9CgovKioKICog5aSE55CG6K6h566XIHNlcmllcwogKi8KZnVuY3Rpb24gaGFuZGxlQ29tcHV0ZVNlcmllcyhyZXF1ZXN0SWQ6IG51bWJlciwgZGF0YVZlcnNpb246IG51bWJlciwgY29uZmlnVmVyc2lvbjogbnVtYmVyKTogdm9pZCB7CiAgICBpZiAoIXJ1bnRpbWUpIHsKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnZXJyb3InLAogICAgICAgICAgICByZXF1ZXN0SWQsCiAgICAgICAgICAgIHN0YWdlOiAnY29tcHV0ZVNlcmllcycsCiAgICAgICAgICAgIG1lc3NhZ2U6ICdSdW50aW1lIG5vdCBpbml0aWFsaXplZCcsCiAgICAgICAgfSkKICAgICAgICByZXR1cm4KICAgIH0KCiAgICBjb25zdCBzdGFydFRpbWUgPSBwZXJmb3JtYW5jZS5ub3coKQoKICAgIHRyeSB7CiAgICAgICAgY29uc29sZS5sb2coYFtJbmRpY2F0b3JXb3JrZXJdIGNvbXB1dGVTZXJpZXMgU1RBUlQgcmVxSWQ9JHtyZXF1ZXN0SWR9YCkKICAgICAgICBjb25zdCByZXN1bHRzID0gcnVudGltZS5jb21wdXRlU2VyaWVzKCkKICAgICAgICBjb25zdCBjb21wdXRlTXMgPSBwZXJmb3JtYW5jZS5ub3coKSAtIHN0YXJ0VGltZQogICAgICAgIGNvbnNvbGUubG9nKGBbSW5kaWNhdG9yV29ya2VyXSBjb21wdXRlU2VyaWVzIERPTkUgaW4gJHtjb21wdXRlTXMudG9GaXhlZCgxKX1tcywgY2hhbmdlZD1bJHtyZXN1bHRzLl9jaGFuZ2VkLmpvaW4oJywnKX1dYCkKCiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ3Nlcmllc1Jlc3VsdCcsCiAgICAgICAgICAgIHJlcXVlc3RJZCwKICAgICAgICAgICAgZGF0YVZlcnNpb24sCiAgICAgICAgICAgIGNvbmZpZ1ZlcnNpb24sCiAgICAgICAgICAgIHJlc3VsdHMsCiAgICAgICAgICAgIG1ldHJpY3M6IHsKICAgICAgICAgICAgICAgIGNvbXB1dGVNcywKICAgICAgICAgICAgICAgIGRhdGFMZW5ndGg6IDAsIC8vIOeUseiwg+eUqOaWueWhq+WFhQogICAgICAgICAgICB9LAogICAgICAgIH0pCiAgICB9IGNhdGNoIChlcnIpIHsKICAgICAgICBjb25zdCBtZXNzYWdlID0gZXJyIGluc3RhbmNlb2YgRXJyb3IgPyBlcnIubWVzc2FnZSA6IFN0cmluZyhlcnIpCiAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgdHlwZTogJ2Vycm9yJywKICAgICAgICAgICAgcmVxdWVzdElkLAogICAgICAgICAgICBzdGFnZTogJ2NvbXB1dGVTZXJpZXMnLAogICAgICAgICAgICBtZXNzYWdlLAogICAgICAgIH0pCiAgICB9Cn0KCi8qKgogKiDlpITnkIbplIDmr4EKICovCmZ1bmN0aW9uIGhhbmRsZURpc3Bvc2UoKTogdm9pZCB7CiAgICBydW50aW1lID0gbnVsbAogICAgLy8gV29ya2VyIOS8muiiq+S4u+e6v+eoiyB0ZXJtaW5hdGXvvIzov5nph4zlgZrmuIXnkIbljbPlj68KfQoKLyoqCiAqIOa2iOaBr+WkhOeQhuWZqAogKi8KY3R4Lm9ubWVzc2FnZSA9IChldmVudDogTWVzc2FnZUV2ZW50PEluZGljYXRvcldvcmtlclJlcXVlc3Q+KSA9PiB7CiAgICBjb25zdCBtc2cgPSBldmVudC5kYXRhCgogICAgaWYgKCFtc2cgfHwgdHlwZW9mIG1zZyAhPT0gJ29iamVjdCcpIHsKICAgICAgICBwb3N0UmVzcG9uc2UoewogICAgICAgICAgICB0eXBlOiAnZXJyb3InLAogICAgICAgICAgICBzdGFnZTogJ2luaXQnLAogICAgICAgICAgICBtZXNzYWdlOiAnSW52YWxpZCBtZXNzYWdlIGZvcm1hdCcsCiAgICAgICAgfSkKICAgICAgICByZXR1cm4KICAgIH0KCiAgICBzd2l0Y2ggKG1zZy50eXBlKSB7CiAgICAgICAgY2FzZSAnaW5pdCc6CiAgICAgICAgICAgIGhhbmRsZUluaXQoKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdzZXREYXRhJzoKICAgICAgICAgICAgaGFuZGxlU2V0RGF0YShtc2cuZGF0YSwgbXNnLmRhdGFWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdzZXRDb25maWcnOgogICAgICAgICAgICBoYW5kbGVTZXRDb25maWcobXNnLmNvbmZpZ3MsIG1zZy5jb25maWdWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdjb21wdXRlU2VyaWVzJzoKICAgICAgICAgICAgaGFuZGxlQ29tcHV0ZVNlcmllcyhtc2cucmVxdWVzdElkLCBtc2cuZGF0YVZlcnNpb24sIG1zZy5jb25maWdWZXJzaW9uKQogICAgICAgICAgICBicmVhawoKICAgICAgICBjYXNlICdkaXNwb3NlJzoKICAgICAgICAgICAgaGFuZGxlRGlzcG9zZSgpCiAgICAgICAgICAgIGJyZWFrCgogICAgICAgIGRlZmF1bHQ6IHsKICAgICAgICAgICAgY29uc3QgX2V4aGF1c3RpdmVDaGVjazogbmV2ZXIgPSBtc2cKICAgICAgICAgICAgcG9zdFJlc3BvbnNlKHsKICAgICAgICAgICAgICAgIHR5cGU6ICdlcnJvcicsCiAgICAgICAgICAgICAgICBzdGFnZTogJ2luaXQnLAogICAgICAgICAgICAgICAgbWVzc2FnZTogYFVua25vd24gbWVzc2FnZSB0eXBlOiAkeyhfZXhoYXVzdGl2ZUNoZWNrIGFzIHVua25vd24gYXMgeyB0eXBlOiBzdHJpbmcgfSkudHlwZX1gLAogICAgICAgICAgICB9KQogICAgICAgIH0KICAgIH0KfQoKLy8g6YCa55+l5Li757q/56iLIHdvcmtlciDlt7LliqDovb3vvIjlj6/pgInvvIzkuLvopoHnlKjkuo7osIPor5XvvIkKLy8gY29uc29sZS5sb2coJ1tJbmRpY2F0b3JXb3JrZXJdIExvYWRlZCcpCg==`,``+{}.url);return console.log(`[IndicatorScheduler] Creating worker from:`,e.href),this.worker=new Worker(e,{type:`module`}),console.log(`[IndicatorScheduler] Worker created, waiting for ready...`),this.worker.onmessage=e=>this.handleWorkerMessage(e.data),this.worker.onerror=e=>{console.error(`[IndicatorScheduler] Worker error:`,e),this.fallbackToInline()},this.worker.postMessage({type:`init`,protocolVersion:1}),!0}catch(e){return console.warn(`[IndicatorScheduler] Failed to init worker:`,e),!1}}initInlineRuntime(){console.log(`[IndicatorScheduler] Using INLINE runtime (fallback)`),this.inlineRuntime=new Qi,this.useWorker=!1,this.workerReady=!0}fallbackToInline(){console.warn(`[IndicatorScheduler] Falling back to inline runtime`),this.terminateWorker(),this.initInlineRuntime(),this.pendingRequest&&this.computeWithInline()}terminateWorker(){this.worker&&=(this.worker.terminate(),null),this.workerReady=!1,this.useWorker=!1}handleWorkerMessage(e){if(!$i(e)){console.warn(`[IndicatorScheduler] Invalid worker response:`,e);return}switch(e.type){case`ready`:this.workerReady=!0,this.useWorker=!0,console.log(`[IndicatorScheduler] Worker READY - using Worker backend`),this.triggerRecompute();break;case`seriesResult`:this.handleSeriesResult(e);break;case`error`:console.error(`[IndicatorScheduler] Worker error:`,e.stage,e.message),this.pendingRequest&&e.requestId===this.pendingRequest.requestId&&this.fallbackToInline();break;default:console.warn(`[IndicatorScheduler] Unknown response type:`,e.type)}}handleSeriesResult(e){e.requestId<this.lastAppliedRequestId||e.dataVersion!==this.dataVersion||e.configVersion!==this.configVersion||(console.log(`[IndicatorScheduler] << Worker result: requestId=${e.requestId} metrics=`,e.metrics),this.lastAppliedRequestId=e.requestId,this.pendingRequest=null,this.latestResult=e.results,this.applyResults(e.results),this.invalidateCallback?.())}checkVisibleExtremes(e,t){(!Number.isFinite(e.visibleMin)||!Number.isFinite(e.visibleMax))&&console.warn(`[IndicatorScheduler] ${t} state has non-finite visibleMin/visibleMax:`,{visibleMin:e.visibleMin,visibleMax:e.visibleMax})}applyResults(e){if(!this.pluginHost)return;let t=new Set(e._changed),n=Date.now(),r=Co(e,this.visibleRange,n);for(let e of this.registry.getAll()){if(!t.has(e.name)||!e.applyResult)continue;let n=r[e.name];if(!n)continue;this.checkVisibleExtremes(n,e.displayName);let i=e.paneIdField?this.configSnapshot[e.paneIdField]:e.defaultPaneId;e.applyResult(this.pluginHost,n,i)}}updateVisibleStatesOnly(){if(!this.pluginHost||!this.latestResult)return;let e=Date.now(),t=this.buildActiveSubIndicatorMask(),n=So(this.latestResult,this.visibleRange,e,t);for(let e of this.registry.getAll()){if(!e.applyResult||!e.paneIdField&&e.category===`main`)continue;let t=n[e.name];if(t===void 0)continue;this.checkVisibleExtremes(t,e.displayName);let r=e.paneIdField?this.configSnapshot[e.paneIdField]:e.defaultPaneId;e.applyResult(this.pluginHost,t,r)}}buildActiveSubIndicatorMask(){let e=this.getActiveSubPaneIds?.()??[],t={};for(let n of this.registry.getAll()){if(!n.paneIdField)continue;let r=this.configSnapshot[n.paneIdField]??n.defaultPaneId;t[n.name]=e.includes(r)||!!(n.allowMainPane&&r===`main`)}return t}buildActiveConfig(){let e=this.getActiveSubPaneIds?.()??[];if(e.length===0)return{...this.configSnapshot};let t={...this.configSnapshot};for(let n of this.registry.getAll()){if(!n.paneIdField)continue;let r=t[n.paneIdField];if(!e.includes(r)&&r!==`main`){let e={...t[n.name]};for(let t of Object.keys(e))t.startsWith(`show`)&&(e[t]=!1);t[n.name]=e}}return t}update(e,t){this.currentData=e,this.visibleRange=t,this.dataVersion++,this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}updateVisibleRange(e){this.visibleRange=e,this.latestResult&&this.updateVisibleStatesOnly()}updateMAConfig(e){this.configSnapshot.ma={...e},this.configVersion++,this.triggerRecompute()}updateBOLLConfig(e){this.configSnapshot.boll={...this.configSnapshot.boll,...e},this.configVersion++,this.triggerRecompute()}updateEXPMAConfig(e){this.configSnapshot.expma={...this.configSnapshot.expma,...e},this.configVersion++,this.triggerRecompute()}updateENEConfig(e){this.configSnapshot.ene={...this.configSnapshot.ene,...e},this.configVersion++,this.triggerRecompute()}updateRSIConfig(e,t){t!==void 0&&(this.configSnapshot.rsiPaneId=t),this.configSnapshot.rsi={...this.configSnapshot.rsi,...e},this.configVersion++,this.triggerRecompute()}updateCCIConfig(e,t){t!==void 0&&(this.configSnapshot.cciPaneId=t),this.configSnapshot.cci={...this.configSnapshot.cci,...e},this.configVersion++,this.triggerRecompute()}updateSTOCHConfig(e,t){t!==void 0&&(this.configSnapshot.stochPaneId=t),this.configSnapshot.stoch={...this.configSnapshot.stoch,...e},this.configVersion++,this.triggerRecompute()}updateMOMConfig(e,t){t!==void 0&&(this.configSnapshot.momPaneId=t),this.configSnapshot.mom={...this.configSnapshot.mom,...e},this.configVersion++,this.triggerRecompute()}updateWMSRConfig(e,t){t!==void 0&&(this.configSnapshot.wmsrPaneId=t),this.configSnapshot.wmsr={...this.configSnapshot.wmsr,...e},this.configVersion++,this.triggerRecompute()}updateKSTConfig(e,t){t!==void 0&&(this.configSnapshot.kstPaneId=t),this.configSnapshot.kst={...this.configSnapshot.kst,...e},this.configVersion++,this.triggerRecompute()}updateFASTKConfig(e,t){t!==void 0&&(this.configSnapshot.fastkPaneId=t),this.configSnapshot.fastk={...this.configSnapshot.fastk,...e},this.configVersion++,this.triggerRecompute()}updateMACDConfig(e,t){t!==void 0&&(this.configSnapshot.macdPaneId=t),this.configSnapshot.macd={...this.configSnapshot.macd,...e},this.configVersion++,this.triggerRecompute()}updateATRConfig(e,t){t!==void 0&&(this.configSnapshot.atrPaneId=t),this.configSnapshot.atr={...this.configSnapshot.atr,...e},this.configVersion++,this.triggerRecompute()}updateWMAConfig(e,t){t!==void 0&&(this.configSnapshot.wmaPaneId=t),this.configSnapshot.wma={...this.configSnapshot.wma,...e},this.configVersion++,this.triggerRecompute()}updateDEMAConfig(e,t){t!==void 0&&(this.configSnapshot.demaPaneId=t),this.configSnapshot.dema={...this.configSnapshot.dema,...e},this.configVersion++,this.triggerRecompute()}updateTEMAConfig(e,t){t!==void 0&&(this.configSnapshot.temaPaneId=t),this.configSnapshot.tema={...this.configSnapshot.tema,...e},this.configVersion++,this.triggerRecompute()}updateHMAConfig(e,t){t!==void 0&&(this.configSnapshot.hmaPaneId=t),this.configSnapshot.hma={...this.configSnapshot.hma,...e},this.configVersion++,this.triggerRecompute()}updateKAMAConfig(e,t){t!==void 0&&(this.configSnapshot.kamaPaneId=t),this.configSnapshot.kama={...this.configSnapshot.kama,...e},this.configVersion++,this.triggerRecompute()}updateSARConfig(e,t){t!==void 0&&(this.configSnapshot.sarPaneId=t),this.configSnapshot.sar={...this.configSnapshot.sar,...e},this.configVersion++,this.triggerRecompute()}updateSuperTrendConfig(e,t){t!==void 0&&(this.configSnapshot.supertrendPaneId=t),this.configSnapshot.supertrend={...this.configSnapshot.supertrend,...e},this.configVersion++,this.triggerRecompute()}updateKeltnerConfig(e,t){t!==void 0&&(this.configSnapshot.keltnerPaneId=t),this.configSnapshot.keltner={...this.configSnapshot.keltner,...e},this.configVersion++,this.triggerRecompute()}updateDonchianConfig(e,t){t!==void 0&&(this.configSnapshot.donchianPaneId=t),this.configSnapshot.donchian={...this.configSnapshot.donchian,...e},this.configVersion++,this.triggerRecompute()}updateIchimokuConfig(e,t){t!==void 0&&(this.configSnapshot.ichimokuPaneId=t),this.configSnapshot.ichimoku={...this.configSnapshot.ichimoku,...e},this.configVersion++,this.triggerRecompute()}updateROCConfig(e,t){t!==void 0&&(this.configSnapshot.rocPaneId=t),this.configSnapshot.roc={...this.configSnapshot.roc,...e},this.configVersion++,this.triggerRecompute()}updateTRIXConfig(e,t){t!==void 0&&(this.configSnapshot.trixPaneId=t),this.configSnapshot.trix={...this.configSnapshot.trix,...e},this.configVersion++,this.triggerRecompute()}updateHVConfig(e,t){t!==void 0&&(this.configSnapshot.hvPaneId=t),this.configSnapshot.hv={...this.configSnapshot.hv,...e},this.configVersion++,this.triggerRecompute()}updateParkinsonConfig(e,t){t!==void 0&&(this.configSnapshot.parkinsonPaneId=t),this.configSnapshot.parkinson={...this.configSnapshot.parkinson,...e},this.configVersion++,this.triggerRecompute()}updateChaikinVolConfig(e,t){t!==void 0&&(this.configSnapshot.chaikinVolPaneId=t),this.configSnapshot.chaikinVol={...this.configSnapshot.chaikinVol,...e},this.configVersion++,this.triggerRecompute()}updateVMAConfig(e,t){t!==void 0&&(this.configSnapshot.vmaPaneId=t),this.configSnapshot.vma={...this.configSnapshot.vma,...e},this.configVersion++,this.triggerRecompute()}updateOBVConfig(e,t){t!==void 0&&(this.configSnapshot.obvPaneId=t),this.configSnapshot.obv={...this.configSnapshot.obv,...e},this.configVersion++,this.triggerRecompute()}updatePVTConfig(e,t){t!==void 0&&(this.configSnapshot.pvtPaneId=t),this.configSnapshot.pvt={...this.configSnapshot.pvt,...e},this.configVersion++,this.triggerRecompute()}updateVWAPConfig(e,t){t!==void 0&&(this.configSnapshot.vwapPaneId=t),this.configSnapshot.vwap={...this.configSnapshot.vwap,...e},this.configVersion++,this.triggerRecompute()}updateCMFConfig(e,t){t!==void 0&&(this.configSnapshot.cmfPaneId=t),this.configSnapshot.cmf={...this.configSnapshot.cmf,...e},this.configVersion++,this.triggerRecompute()}updateMFIConfig(e,t){t!==void 0&&(this.configSnapshot.mfiPaneId=t),this.configSnapshot.mfi={...this.configSnapshot.mfi,...e},this.configVersion++,this.triggerRecompute()}updatePivotConfig(e,t){t!==void 0&&(this.configSnapshot.pivotPaneId=t),this.configSnapshot.pivot={...this.configSnapshot.pivot,...e},this.configVersion++,this.triggerRecompute()}updateFibConfig(e,t){t!==void 0&&(this.configSnapshot.fibPaneId=t),this.configSnapshot.fib={...this.configSnapshot.fib,...e},this.configVersion++,this.triggerRecompute()}updateStructureConfig(e,t){t!==void 0&&(this.configSnapshot.structurePaneId=t),this.configSnapshot.structure={...this.configSnapshot.structure,...e},this.configVersion++,this.triggerRecompute()}updateZonesConfig(e,t){t!==void 0&&(this.configSnapshot.zonesPaneId=t),this.configSnapshot.zones={...this.configSnapshot.zones,...e},this.configVersion++,this.triggerRecompute()}updateVolumeProfileConfig(e,t){t!==void 0&&(this.configSnapshot.volumeProfilePaneId=t),this.configSnapshot.volumeProfile={...this.configSnapshot.volumeProfile,...e},this.configVersion++,this.triggerRecompute()}setActiveMainIndicators(e){this.activeMainIndicators=new Set(e.map(e=>e.toLowerCase()))}getMainIndicatorPriceRange(){return this.latestResult?Ho(this.latestResult,this.visibleRange,this.activeMainIndicators):null}recompute(){this.inlineRuntime&&this.inlineRuntime.forceDirty(),this.dataVersion++,this.triggerRecompute()}triggerRecompute(){this.useWorker&&this.worker&&this.workerReady?this.computeWithWorker():this.computeWithInline()}computeWithWorker(){!this.worker||!this.workerReady||(console.log(`[IndicatorScheduler] >> Worker compute: requestId=${this.requestId+1} dataV=${this.dataVersion} configV=${this.configVersion}`),this.requestId++,this.pendingRequest={requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion},this.worker.postMessage({type:`setData`,dataVersion:this.dataVersion,format:`aos`,data:this.currentData}),this.worker.postMessage({type:`setConfig`,configVersion:this.configVersion,configs:this.buildActiveConfig()}),this.worker.postMessage({type:`computeSeries`,requestId:this.requestId,dataVersion:this.dataVersion,configVersion:this.configVersion}))}computeWithInline(){this.inlineRuntime||=new Qi,console.log(`[IndicatorScheduler] >> INLINE compute: dataV=${this.dataVersion} configV=${this.configVersion}`),this.inlineRuntime.setData(this.currentData,this.dataVersion),this.inlineRuntime.setConfig(this.buildActiveConfig(),this.configVersion);let e=this.inlineRuntime.computeSeries();this.latestResult=e,this.applyResults(e),this.invalidateCallback?.()}},Go=new Map;function q(e){return function(t,n){return n.addInitializer(function(){let t=this.rendererFactory;if(typeof t!=`function`)throw Error(`[Indicator] '${e.name}' definition must expose static rendererFactory`);Go.set(e.name,{...e,rendererFactory:t,paneIdField:e.paneIdField,allowMainPane:e.allowMainPane,applyResult:e.applyResult})}),t}}function Ko(){return Array.from(Go.values())}var qo=function(e){return e.Registered=`registered`,e.Installed=`installed`,e.Error=`error`,e}({});function Jo(e){return{id:e.id,role:e.role,capabilities:{...e.capabilities},top:e.top,height:e.height,yAxis:{priceToY:t=>e.yAxis.priceToY(t),yToPrice:t=>e.yAxis.yToPrice(t),getPaddingTop:()=>e.yAxis.getPaddingTop(),getPaddingBottom:()=>e.yAxis.getPaddingBottom(),getPriceOffset:()=>e.yAxis.getPriceOffset(),getDisplayRange:t=>e.yAxis.getDisplayRange(t),getScaleType:()=>e.yAxis.getScaleType()},priceRange:e.priceRange}}var Yo=Symbol(`global-pane`),J={LAST_PRICE_LABEL:-25,SYSTEM_YAXIS:-20,SYSTEM_XAXIS:-20,BACKGROUND:0,GRID:10,INDICATOR:30,MAIN:50,INDICATOR_SCALE:55,OVERLAY:80,FOREGROUND:100,SYSTEM_BORDER:120,SYSTEM_CROSSHAIR:150},Xo=class{plugins=new Map;register(e,t){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);let n={plugin:e,config:{enabled:!0,priority:0,...t},state:`registered`};return this.plugins.set(e.name,n),n}unregister(e){return this.plugins.delete(e)}get(e){return this.plugins.get(e)}getPlugin(e){return this.plugins.get(e)?.plugin}getAll(){return Array.from(this.plugins.values())}getEnabled(){return this.getAll().filter(e=>e.config?.enabled!==!1)}updateState(e,t,n){let r=this.plugins.get(e);r&&(r.state=t,n&&(r.error=n))}has(e){return this.plugins.has(e)}clear(){this.plugins.clear()}},Zo=class{hooks=new Map;tap(e,t,n=0){this.hooks.has(e)||this.hooks.set(e,[]);let r=this.hooks.get(e);r.push({name:e,fn:t,priority:n}),r.sort((e,t)=>e.priority-t.priority)}untap(e,t){let n=this.hooks.get(e);if(n){let e=n.findIndex(e=>e.fn===t);e!==-1&&n.splice(e,1)}}async call(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=await a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}callSync(e,t,n){let r=this.hooks.get(e);if(!r||r.length===0)return[];let i=[];for(let{fn:a}of r)try{let e=a(t);i.push(e)}catch(t){if(console.error(`[HookSystem] Error in hook "${e}":`,t),n?.throwOnError)throw t}return i}clear(){this.hooks.clear()}hookCount(e){return this.hooks.get(e)?.length??0}},Qo=class{configs=new Map;defaults=new Map;registerDefaults(e,t){this.defaults.set(e,{...t}),this.configs.has(e)||this.configs.set(e,new Map);let n=this.configs.get(e);for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r)}get(e,t,n){let r=this.configs.get(e);if(r?.has(t))return r.get(t);let i=this.defaults.get(e);return i&&t in i?i[t]:n}set(e,t,n){this.configs.has(e)||this.configs.set(e,new Map),this.configs.get(e).set(t,n)}setAll(e,t){for(let[n,r]of Object.entries(t))this.set(e,n,r)}getAll(e){let t=this.configs.get(e);return{...this.defaults.get(e)||{},...t?Object.fromEntries(t):{}}}clear(e){e?(this.configs.delete(e),this.defaults.delete(e)):(this.configs.clear(),this.defaults.clear())}},$o=class{states=new Map;ownerNamespaces=new Map;setState(e,t,n){this.states.set(e,t)}getState(e){return this.states.get(e)}clearState(e){this.states.delete(e)}registerStateOwner(e,t){this.ownerNamespaces.set(e,new Set(t))}clearByOwner(e){let t=this.ownerNamespaces.get(e);t&&(t.forEach(e=>{this.states.delete(e)}),this.ownerNamespaces.delete(e))}clear(){this.states.clear(),this.ownerNamespaces.clear()}},es=class{registry;eventBus;hookSystem;configManager;stateStore;services=new Map;isDestroyed=!1;logger;constructor(e){this.registry=new Xo,this.eventBus=new t,this.hookSystem=new Zo,this.configManager=new Qo,this.stateStore=new $o,this.logger=e??console}events={on:(e,t)=>{this.eventBus.on(e,t)},off:(e,t)=>{this.eventBus.off(e,t)},emit:(e,t)=>{this.eventBus.emit(e,t)},once:(e,t)=>{this.eventBus.once(e,t)}};hooks={tap:(e,t,n=0)=>{this.hookSystem.tap(e,t,n)},untap:(e,t)=>{this.hookSystem.untap(e,t)},call:async(e,t,n)=>this.hookSystem.call(e,t,n),callSync:(e,t,n)=>this.hookSystem.callSync(e,t,n)};getConfig(e,t,n){return this.configManager.get(e,t,n)}setConfig(e,t,n){this.configManager.set(e,t,n)}getPlugin(e){return this.registry.getPlugin(e)}log(e,t,...n){let r=`[${new Date().toISOString()}] [${e.toUpperCase()}]`;this.logger[e](`${r} ${t}`,...n)}setSharedState(e,t,n){this.stateStore.setState(e,t,n)}getSharedState(e){return this.stateStore.getState(e)}clearSharedState(e){this.stateStore.clearState(e)}registerStateOwner(e,t){this.stateStore.registerStateOwner(e,t)}clearByOwner(e){this.stateStore.clearByOwner(e)}registerService(e,t){this.services.set(e,t)}getService(e){return this.services.get(e)}async use(e,t){if(this.ensureNotDestroyed(),this.registry.has(e.name))throw Error(`Plugin "${e.name}" is already installed`);try{let n=this.registry.register(e,t);t&&this.configManager.setAll(e.name,t),await this.hooks.call(`plugin:beforeInstall`,{plugin:e,config:t},{throwOnError:!0}),await e.install(this,n.config),this.registry.updateState(e.name,`installed`),await this.hooks.call(`plugin:afterInstall`,{plugin:e,config:t},{throwOnError:!0}),this.log(`info`,`Plugin "${e.name}" installed successfully`)}catch(t){throw this.registry.updateState(e.name,`error`,t instanceof Error?t:Error(String(t))),this.log(`error`,`Failed to install plugin "${e.name}":`,t),t}}async remove(e){this.ensureNotDestroyed();let t=this.registry.get(e);if(!t)throw Error(`Plugin "${e}" is not installed`);try{await this.hooks.call(`plugin:beforeUninstall`,{name:e},{throwOnError:!0}),t.plugin.uninstall&&await t.plugin.uninstall(),this.registry.unregister(e),this.configManager.clear(e),await this.hooks.call(`plugin:afterUninstall`,{name:e},{throwOnError:!0}),this.log(`info`,`Plugin "${e}" removed successfully`)}catch(t){throw this.log(`error`,`Failed to remove plugin "${e}":`,t),t}}getPlugins(){return this.registry.getAll()}getState(e){return this.registry.get(e)?.state}async destroy(){if(!this.isDestroyed){for(let e of this.registry.getAll())try{e.plugin.uninstall&&await e.plugin.uninstall()}catch(t){this.log(`error`,`Error uninstalling "${e.plugin.name}":`,t)}this.registry.clear(),this.eventBus.clear(),this.hookSystem.clear(),this.configManager.clear(),this.stateStore.clear(),this.services.clear(),this.isDestroyed=!0,this.log(`info`,`PluginHost destroyed`)}}ensureNotDestroyed(){if(this.isDestroyed)throw Error(`PluginHost has been destroyed`)}};function ts(e){return new es(e)}var ns=Symbol(`renderer:global-cache`),rs=class{plugins=new Map;pluginHost=null;enabledState=new Map;groupCache=new Map;mergedCache=new Map;knownPaneIds=new Set;cacheInvalid=!0;onInvalidate=null;setInvalidateCallback(e){this.onInvalidate=e}setPluginHost(e){this.pluginHost=e}addKnownPaneId(e){this.knownPaneIds.add(e),this.cacheInvalid=!0}removeKnownPaneId(e){this.knownPaneIds.delete(e),this.cacheInvalid=!0}setKnownPaneIds(e){this.knownPaneIds=new Set(e),this.cacheInvalid=!0}register(e){if(this.plugins.has(e.name)){console.warn(`Renderer plugin "${e.name}" already registered`);return}this.plugins.set(e.name,e),e.enabled!==void 0&&this.enabledState.set(e.name,e.enabled),this.cacheInvalid=!0;let t=e;if(t.onInstall&&this.pluginHost)try{t.onInstall(this.pluginHost)}catch(t){console.error(`[RendererPlugin] ${e.name} onInstall error:`,t)}let n=t.getDeclaredNamespaces?.();n&&this.pluginHost&&this.pluginHost.registerStateOwner(e.name,n),this.onInvalidate?.()}unregister(e){let t=this.plugins.get(e);if(t){if(t.getDeclaredNamespaces&&this.pluginHost?.clearByOwner(e),t.onUninstall)try{t.onUninstall()}catch(e){console.error(`[RendererPlugin] ${t.name} onUninstall error:`,e)}this.plugins.delete(e),this.enabledState.delete(e),this.cacheInvalid=!0,this.onInvalidate?.()}}clear(){for(let e of this.plugins.values())if(e.onUninstall)try{e.onUninstall()}catch(t){console.error(`[RendererPlugin] ${e.name} onUninstall error:`,t)}this.plugins.clear(),this.enabledState.clear(),this.groupCache.clear(),this.mergedCache.clear(),this.cacheInvalid=!1}mergeSorted(e,t){let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)e[r].priority<=t[i].priority?n.push(e[r++]):n.push(t[i++]);return[...n,...e.slice(r),...t.slice(i)]}rebuildCache(){if(!this.cacheInvalid)return;this.groupCache.clear(),this.mergedCache.clear();for(let e of this.plugins.values()){let t=typeof e.paneId==`symbol`?ns:e.paneId;this.groupCache.has(t)||this.groupCache.set(t,[]),this.groupCache.get(t).push(e)}for(let[,e]of this.groupCache)e.sort((e,t)=>e.priority-t.priority);let e=this.groupCache.get(ns)??[];for(let t of this.knownPaneIds){let n=this.groupCache.get(t)??[],r=this.mergeSorted(n,e);this.mergedCache.set(t,r)}this.mergedCache.set(ns,[...e]),this.cacheInvalid=!1}isRendererEnabled(e){let t=this.enabledState.get(e.name);return t===void 0?e.enabled!==!1:t}getMergedRenderers(e){this.rebuildCache();let t=this.mergedCache.get(e);if(!t){let n=this.groupCache.get(e)??[],r=this.groupCache.get(ns)??[];t=this.mergeSorted(n,r),this.mergedCache.set(e,t)}return t}getRenderers(e){return this.getMergedRenderers(e).filter(e=>e.isSystem?!1:this.isRendererEnabled(e))}render(e,t,n){let r=this.getRenderers(e),i=[];for(let e of r){if(n){let t=e.layer??`main`;if(n===U.Overlay&&t!==`overlay`||n===U.Main&&t===`overlay`)continue}try{e.draw(t)}catch(n){let r=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e.name} draw error:`,r),i.push({name:e.name,error:{message:r.message,stack:r.stack},paneId:t.pane.id,timestamp:Date.now()})}}return i}renderPlugin(e,t){let n=this.plugins.get(e);if(!n||!this.isRendererEnabled(n))return[];let r=[];try{n.draw(t)}catch(n){let i=n instanceof Error?n:Error(String(n));console.error(`[RendererPlugin] ${e} draw error:`,i),r.push({name:e,error:{message:i.message,stack:i.stack},paneId:t.pane.id,timestamp:Date.now()})}return r}setEnabled(e,t){this.plugins.has(e)&&(this.enabledState.set(e,t),this.onInvalidate?.())}updateConfig(e,t){let n=this.plugins.get(e);return n?.setConfig?(n.setConfig(t),this.onInvalidate?.(),!0):!1}getAllPlugins(){return Array.from(this.plugins.values())}getPlugin(e){return this.plugins.get(e)}notifyDataUpdate(e,t){for(let n of this.plugins.values())if(n.onDataUpdate&&this.isRendererEnabled(n))try{n.onDataUpdate(e,t)}catch(e){console.error(`[RendererPlugin] ${n.name} onDataUpdate error:`,e)}}notifyResize(e,t){let n=this.getMergedRenderers(e).filter(e=>this.isRendererEnabled(e));for(let e of n)if(e.onResize)try{e.onResize(t)}catch(t){console.error(`[RendererPlugin] ${e.name} onResize error:`,t)}}};function Y(e,t){if(typeof e==`function`){if(!t)throw Error(`[IndicatorMetadata] Pane ID required for dynamic state key`);return e(t)}return e}var is;function as(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:cs(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||cs(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:os(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return ls(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function os(e){var t=ss(e,`string`);return typeof t==`symbol`?t:t+``}function ss(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function cs(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function ls(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function us(e){return e}function ds(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[VolumeRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`volume`);return r?Y(r.stateKey,t):(console.warn(`[VolumeRenderer] Indicator metadata for 'volume' not found, skip rendering`),null)}function fs(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return ds(n,t)}return{name:`volume_${t}`,version:`1.0.0`,description:`成交量渲染器`,debugName:`成交量`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c}=e,l=V(e.theme),u=o;if(!u.length)return;let{start:d,end:f}=s,p=0,m=1/0;for(let e=d;e<f&&e<u.length;e++){let t=u[e];if(!t)continue;let n=t.volume;n!=null&&(p=Math.max(p,n),m=Math.min(m,n))}if(p===0||!Number.isFinite(m))return;let h=Math.max(.05,(p-m)*.1),g=Math.max(0,m-h),_=p+h,v=a.yAxis.getDisplayRange({minPrice:g,maxPrice:_}),y=v.minPrice,b=v.maxPrice-y||1,x=a.height-(0-y)/b*a.height,S=Math.round(x*c)/c,C=r();if(!C)return;n?.setSharedState(C,{valueMin:g,valueMax:_,timestamp:Date.now()},`volume_${t}`);let w=Math.max(1,f-d),T=new Float32Array(w*4),E=new Float32Array(w*4),D=new Float32Array(w*4),O=0,k=0,A=0;for(let t=d;t<f;t++){let n=u[t];if(!n)continue;let r=n.volume;if(!r)continue;let i=e.kBarRects[t-d];if(!i)continue;let o=a.height-(r-y)/b*a.height,s=Math.round(o*c)/c,f=1/c,p=S-s,m=p<=0?f:Math.max(p,f),h=p<=0?S-f:S-m,g=gs(n,l.VOLUME),_,v;g===l.VOLUME.UP?(_=T,v=O++):g===l.VOLUME.DOWN?(_=E,v=k++):(_=D,v=A++);let x=v*4;_[x]=i.x,_[x+1]=h,_[x+2]=i.width,_[x+3]=m}ps(e,T,O,E,k,D,A,l.VOLUME)?hs(i,e):ms(i,e.scrollLeft,T,O,E,k,D,A,l.VOLUME)}}}function ps(e,t,n,r,i,a,o,s){if(e.settings?.enableWebGLRendering===!1)return!1;let c=e.candleWebGLSurface;if(!c||!c.isAvailable())return!1;c.clear();let l=n===0||c.drawRectBuffer(t.subarray(0,n*4),n,s.UP,e.scrollLeft),u=i===0||c.drawRectBuffer(r.subarray(0,i*4),i,s.DOWN,e.scrollLeft),d=o===0||c.drawRectBuffer(a.subarray(0,o*4),o,s.NEUTRAL,e.scrollLeft);return l&&u&&d}function ms(e,t,n,r,i,a,o,s,c){e.save(),e.translate(-t,0),e.fillStyle=c.UP;for(let t=0;t<r;t++){let r=t*4;e.fillRect(n[r],n[r+1],n[r+2],n[r+3])}e.fillStyle=c.DOWN;for(let t=0;t<a;t++){let n=t*4;e.fillRect(i[n],i[n+1],i[n+2],i[n+3])}e.fillStyle=c.NEUTRAL;for(let t=0;t<s;t++){let n=t*4;e.fillRect(o[n],o[n+1],o[n+2],o[n+3])}e.restore()}function hs(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function gs(e,t){return e.close>e.open?t.UP:e.close<e.open?t.DOWN:t.NEUTRAL}var _s;new class extends us{static[class{static{[_s,is]=as(this,[q({name:`volume`,displayName:`VOL`,category:`volume`,stateKey:e=>W(`volume`,e),defaultPaneId:`sub`})],[]).c}}];rendererFactory=fs;constructor(){super(_s),is()}};var vs=W(`ma`,`main`),ys;function bs(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Cs(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Cs(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:xs(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return ws(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function xs(e){var t=Ss(e,`string`);return typeof t==`symbol`?t:t+``}function Ss(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Cs(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function ws(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Ts(e){return e}function Es(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),r.join(`,`),n.height.toFixed(2)].join(`|`)}function Ds(e){let t=e?.getService(`indicatorScheduler`);if(!t)return console.warn(`[MARenderer] Scheduler not available via service locator`),null;let n=t.getIndicatorMetadata(`ma`);return n?Y(n.stateKey):(console.warn(`[MARenderer] Indicator metadata for 'ma' not found, skip rendering`),null)}var Os;new class extends Ts{static[class{static{[Os,ys]=bs(this,[q({name:`ma`,displayName:`MA`,category:`main`,stateKey:vs,defaultPaneId:`main`,applyResult:(e,t,n)=>{e.setSharedState(vs,t,`ma_scheduler`)}})],[]).c}}];rendererFactory=ks;constructor(){super(Os),ys()}};function ks(){let e=null,t=``,n=new Map;function r(){t=``,n=new Map}function i(){return Ds(e)}return{name:`ma`,version:`2.1.0`,description:`MA均线渲染器`,debugName:`MA均线`,paneId:`main`,priority:J.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){let e=i();return e?[e]:[]},draw(a){let{ctx:o,pane:s,range:c,scrollLeft:l,dpr:u,kLineCenters:d,lineWebGLSurface:f}=a,p=V(a.theme),m={5:p.MA.MA5,10:p.MA.MA10,20:p.MA.MA20,30:p.MA.MA30,60:p.MA.MA60},h=i();if(!h)return;let g=e?.getSharedState(h);if(!g||g.visibleMin>g.visibleMax){r();return}if(g.enabledPeriods.length===0){r();return}let _=Es(c,d,s,g.enabledPeriods,g.timestamp);if(t!==_){t=_,n=new Map;for(let[e,t]of Object.entries(g.series)){let r=Number(e),i=[];for(let e=c.start;e<c.end&&e<t.length;e++){let n=t[e];if(n===void 0)continue;let r=d[e-c.start];r!==void 0&&i.push({x:r,y:s.yAxis.priceToY(n)})}i.length>=2&&n.set(r,i)}}let v=a.settings?.enableWebGLRendering!==!1,y=!1;if(v&&f?.isAvailable()){let e=[];for(let t of g.enabledPeriods){let r=n.get(t);r&&e.push({points:r,width:1,color:m[t]??p.MA.MA5})}e.length>0&&f.drawLineStrips(e,l)&&(y=!0,f.compositeTo(o,{imageSmoothingEnabled:!1}))}if(!y){o.save(),o.translate(-l,0),o.lineWidth=1,o.lineJoin=`round`,o.lineCap=`round`;for(let e of g.enabledPeriods){let t=n.get(e);if(!(!t||t.length<2)){o.strokeStyle=m[e]??p.MA.MA5,o.beginPath(),o.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){let n=t[e];o.lineTo(n.x,n.y)}o.stroke()}}o.restore()}},getConfig(){let t=i();if(!t)return{};let n=e?.getSharedState(t),r={};return n?.enabledPeriods.forEach(e=>{r[`ma${e}`]=!0}),r},setConfig(e){}}}function X(e,t,n){return Math.round(e*t)/t}function Z(e,t,n){return(Math.floor(e*t)+.5)/t}function As(e,t,n,r,i){if(t===n)return null;let a=Math.min(t,n),o=Math.max(t,n),s=Math.round(e*r),c=Math.round(a*r),l=Math.round(o*r);return{x:s/r,y:c/r,width:1/r,height:Math.max(1,l-c)/r}}function js(e,t,n,r,i){if(e===t)return null;let a=Math.min(e,t),o=Math.max(e,t),s=Math.round(a*r),c=Math.round(o*r),l=Math.round(n*r);return{x:s/r,y:l/r,width:Math.max(1,c-s)/r,height:1/r}}function Ms(e,t,n,r,i,a){let o=e+n,s=n,c=Math.round(t*i),l=Math.round((t+r)*i),u=Math.max(1,l-c),d=e+(n-1)/2,f=d,p=s%2==1;return{bodyRect:{x:e/i,y:c/i,width:n/i,height:u/i},physBodyLeft:e,physBodyRight:o,physBodyWidth:s,physBodyCenter:f,physWickX:d,wickRect:{x:d/i,width:1/i},isPerfectlyAligned:p}}var Ns=W(`boll`,`main`),Ps;function Fs(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Rs(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Rs(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Is(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return zs(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Is(e){var t=Ls(e,`string`);return typeof t==`symbol`?t:t+``}function Ls(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Rs(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function zs(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Bs(e){return e}var Vs=1;function Hs(e){let t=e.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([\d.]+)\)$/i);if(!t)return 1;let n=Number(t[1]);return Number.isFinite(n)?n:1}function Us(e){return e.replace(/,\s*[\d.]+\s*\)$/i,`, 1)`)}function Ws(e,t,n=1){t.compositeTo(e.ctx,{alpha:n,imageSmoothingEnabled:!1})}function Gs(e,t){let n=V(e.theme);if(e.settings?.enableWebGLRendering===!1)return!1;let r=e.lineWebGLSurface;if(!r||!r.isAvailable())return!1;r.clear();let i=!0;t.showBand&&t.bandUpperPoints.length>=2&&t.bandLowerPoints.length>=2&&(r.clear(),i=r.drawFilledBand({upperPoints:t.bandUpperPoints,lowerPoints:t.bandLowerPoints},Us(n.BOLL.BAND_FILL),e.scrollLeft),i&&Ws(e,r,Hs(n.BOLL.BAND_FILL))),r.clear();let a=[];return t.showUpper&&t.upperPoints.length>=2&&a.push({points:t.upperPoints,width:Vs,color:n.BOLL.UPPER}),t.showMiddle&&t.middlePoints.length>=2&&a.push({points:t.middlePoints,width:Vs,color:n.BOLL.MIDDLE}),t.showLower&&t.lowerPoints.length>=2&&a.push({points:t.lowerPoints,width:Vs,color:n.BOLL.LOWER}),a.length>0&&(i=r.drawLineStrips(a,e.scrollLeft)),i?(Ws(e,r),r.clear(),!0):(r.clear(),!1)}function Ks(e){let t=e?.getService(`indicatorScheduler`);if(!t)return console.warn(`[BOLLRenderer] Scheduler not available via service locator`),null;let n=t.getIndicatorMetadata(`boll`);return n?Y(n.stateKey):(console.warn(`[BOLLRenderer] Indicator metadata for 'boll' not found, skip rendering`),null)}var qs;new class extends Bs{static[class{static{[qs,Ps]=Fs(this,[q({name:`boll`,displayName:`BOLL`,category:`main`,stateKey:Ns,defaultPaneId:`main`,applyResult:(e,t,n)=>{e.setSharedState(Ns,t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Js;constructor(){super(qs),Ps()}};function Js(){let e=null,t=[],n=[],r=[],i=[],a=[],o=0;function s(e){if(!(e<=o)){for(let s=o;s<e;s++)t[s]={x:0,y:0},n[s]={x:0,y:0},r[s]={x:0,y:0},i[s]={x:0,y:0},a[s]={x:0,y:0};o=e}}function c(){return Ks(e)}return{name:`boll`,version:`2.2.0`,description:`布林带渲染器(无缓存优化)`,debugName:`BOLL布林带`,paneId:`main`,priority:J.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){let e=c();return e?[e]:[]},draw(o){let{ctx:l,pane:u,data:d,range:f,scrollLeft:p,dpr:m,kLineCenters:h}=o,g=d,_=V(o.theme),v=c();if(!v)return;let y=e?.getSharedState(v);if(!y||y.visibleMin>y.visibleMax||y.series.length===0)return;let{period:b,showUpper:x,showMiddle:S,showLower:C,showBand:w}=y.params,T=y.series;if(g.length<b)return;let E=Math.max(f.start,b-1),D=Math.min(f.end,g.length);if(D<=E)return;let O=f.start,k=u.yAxis.priceToY.bind(u.yAxis),A=D-E;s(A);let j=Array(A),M=Array(A),N=Array(A),P=w?Array(A):[],F=w?Array(A):[],I=0,L=0,ee=0,R=0;for(let e=E;e<D;e++){let o=T[e];if(!o)continue;let s=h[e-O];if(s===void 0)continue;let c=Z(k(o.upper),m),l=Z(k(o.middle),m),u=Z(k(o.lower),m),d=t[I];d.x=s,d.y=c,j[I++]=d,d=n[L],d.x=s,d.y=l,M[L++]=d,d=r[ee],d.x=s,d.y=u,N[ee++]=d,w&&(d=i[R],d.x=s,d.y=c,P[R]=d,d=a[R],d.x=s,d.y=u,F[R]=d,R++)}if(j.length=I,M.length=L,N.length=ee,w&&(P.length=R,F.length=R),Gs(o,{showUpper:x,showMiddle:S,showLower:C,showBand:w,upperPoints:j,middlePoints:M,lowerPoints:N,bandUpperPoints:P,bandLowerPoints:F}))return;if(l.save(),l.translate(-p,0),l.lineWidth=Vs,l.lineJoin=`round`,l.lineCap=`round`,w&&P.length>=2){let e=new Path2D;e.moveTo(P[0].x,P[0].y);for(let t=1;t<P.length;t++)e.lineTo(P[t].x,P[t].y);for(let t=F.length-1;t>=0;t--)e.lineTo(F[t].x,F[t].y);e.closePath(),l.fillStyle=_.BOLL.BAND_FILL,l.fill(e)}let te=(e,t)=>{if(!(e.length<2)){l.beginPath(),l.strokeStyle=t,l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.stroke()}};x&&te(j,_.BOLL.UPPER),S&&te(M,_.BOLL.MIDDLE),C&&te(N,_.BOLL.LOWER),l.restore()},getConfig(){let t=c();if(!t)return{};let n=e?.getSharedState(t);return n?{...n.params}:{}},setConfig(e){}}}var Ys=W(`expma`,`main`),Xs;function Zs(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ec(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ec(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Qs(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return tc(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Qs(e){var t=$s(e,`string`);return typeof t==`symbol`?t:t+``}function $s(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ec(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function tc(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function nc(e){return e}function rc(e,t,n,r){let i=n.yAxis.getDisplayRange();return[r,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.maxPrice.toFixed(6),i.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2)].join(`|`)}function ic(e){let t=e?.getService(`indicatorScheduler`);if(!t)return console.warn(`[EXPMARenderer] Scheduler not available via service locator`),null;let n=t.getIndicatorMetadata(`expma`);return n?Y(n.stateKey):(console.warn(`[EXPMARenderer] Indicator metadata for 'expma' not found, skip rendering`),null)}function ac(){let e=null,t=``,n=[],r=[];function i(){t=``,n=[],r=[]}function a(){return ic(e)}return{name:`expma`,version:`2.1.0`,description:`EXPMA 指数平滑移动平均线渲染器(带绘制缓存)`,debugName:`EXPMA`,paneId:`main`,priority:J.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){let e=a();return e?[e]:[]},draw(o){let{ctx:s,pane:c,data:l,range:u,scrollLeft:d,dpr:f,kLineCenters:p,lineWebGLSurface:m}=o,h=l,g=V(o.theme),_=a();if(!_)return;let v=e?.getSharedState(_);if(!v||v.visibleMin>v.visibleMax){i();return}if(v.series.length===0||h.length<2){i();return}let y=v.series,b=u.start,x=Math.min(u.end,h.length),S=rc(u,p,c,v.timestamp);if(t!==S){t=S,n=[],r=[];for(let e=b;e<x;e++){let t=y[e];if(!t)continue;let i=p[e-u.start];i!==void 0&&(n.push({x:i,y:c.yAxis.priceToY(t.fast)}),r.push({x:i,y:c.yAxis.priceToY(t.slow)}))}}let C=o.settings?.enableWebGLRendering!==!1,w=!1;if(C&&m?.isAvailable()){let e=[];n.length>=2&&e.push({points:n,width:1,color:g.EXPMA.FAST}),r.length>=2&&e.push({points:r,width:1,color:g.EXPMA.SLOW}),e.length>0&&m.drawLineStrips(e,d)&&(w=!0,m.compositeTo(s,{imageSmoothingEnabled:!1}))}if(!w){if(s.save(),s.translate(-d,0),s.lineWidth=1,s.lineJoin=`round`,s.lineCap=`round`,n.length>=2){s.strokeStyle=g.EXPMA.FAST,s.beginPath(),s.moveTo(n[0].x,n[0].y);for(let e=1;e<n.length;e++){let t=n[e];s.lineTo(t.x,t.y)}s.stroke()}if(r.length>=2){s.strokeStyle=g.EXPMA.SLOW,s.beginPath(),s.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++){let t=r[e];s.lineTo(t.x,t.y)}s.stroke()}s.restore()}},getConfig(){let t=a();if(!t)return{};let n=e?.getSharedState(t);return n?{...n.params}:{}},setConfig(e){}}}var oc;new class extends nc{static[class{static{[oc,Xs]=Zs(this,[q({name:`expma`,displayName:`EXPMA`,category:`main`,stateKey:Ys,defaultPaneId:`main`,applyResult:(e,t,n)=>{e.setSharedState(Ys,t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=ac;constructor(){super(oc),Xs()}};var sc=W(`ene`,`main`),cc;function lc(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:fc(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||fc(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:uc(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return pc(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function uc(e){var t=dc(e,`string`);return typeof t==`symbol`?t:t+``}function dc(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fc(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function pc(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function mc(e){return e}function hc(e){let t=e.match(/^rgba\([^,]+,[^,]+,[^,]+,\s*([\d.]+)\)$/i);if(!t)return 1;let n=Number(t[1]);return Number.isFinite(n)?n:1}function gc(e){return e.replace(/,\s*[\d.]+\s*\)$/i,`, 1)`)}function _c(e,t,n=1){t.compositeTo(e.ctx,{alpha:n,imageSmoothingEnabled:!1})}function vc(e,t){let n=V(e.theme);if(e.settings?.enableWebGLRendering===!1)return!1;let r=e.lineWebGLSurface;if(!r||!r.isAvailable())return!1;r.clear();let i=!0;t.upperPoints.length>=2&&t.lowerPoints.length>=2&&(r.clear(),i=r.drawFilledBand({upperPoints:t.upperPoints,lowerPoints:t.lowerPoints},gc(n.ENE.BAND_FILL),e.scrollLeft),i&&_c(e,r,hc(n.ENE.BAND_FILL))),r.clear();let a=[];return t.upperPoints.length>=2&&a.push({points:t.upperPoints,width:1,color:n.ENE.UPPER}),t.middlePoints.length>=2&&a.push({points:t.middlePoints,width:1,color:n.ENE.MIDDLE}),t.lowerPoints.length>=2&&a.push({points:t.lowerPoints,width:1,color:n.ENE.LOWER}),a.length>0&&(i=r.drawLineStrips(a,e.scrollLeft)),i?(_c(e,r),r.clear(),!0):(r.clear(),!1)}function yc(e){let t=e?.getService(`indicatorScheduler`);if(!t)return console.warn(`[ENERenderer] Scheduler not available via service locator`),null;let n=t.getIndicatorMetadata(`ene`);return n?Y(n.stateKey):(console.warn(`[ENERenderer] Indicator metadata for 'ene' not found, skip rendering`),null)}function bc(){let e=null;function t(){return yc(e)}return{name:`ene`,version:`2.1.0`,description:`ENE 轨道线渲染器(无状态)`,debugName:`ENE轨道线`,paneId:`main`,priority:J.INDICATOR,onInstall(t){e=t},getDeclaredNamespaces(){let e=t();return e?[e]:[]},draw(n){let{ctx:r,pane:i,data:a,range:o,scrollLeft:s,dpr:c,kLineCenters:l}=n,u=a,d=V(n.theme),f=t();if(!f)return;let p=e?.getSharedState(f);if(!p||p.visibleMin>p.visibleMax||p.series.length===0)return;let{period:m}=p.params,h=p.series;if(u.length<m)return;let g=Math.max(o.start,m-1),_=Math.min(o.end,u.length),v=[],y=[],b=[];for(let e=g;e<_;e++){let t=h[e];if(!t)continue;let n=l[e-o.start];n!==void 0&&(v.push({x:n,y:Z(i.yAxis.priceToY(t.upper),c)}),y.push({x:n,y:Z(i.yAxis.priceToY(t.middle),c)}),b.push({x:n,y:Z(i.yAxis.priceToY(t.lower),c)}))}if(vc(n,{upperPoints:v,middlePoints:y,lowerPoints:b}))return;if(r.save(),r.translate(-s,0),r.fillStyle=d.ENE.BAND_FILL,r.beginPath(),v.length>0){r.moveTo(v[0].x,v[0].y);for(let e=1;e<v.length;e++){let t=v[e];r.lineTo(t.x,t.y)}for(let e=b.length-1;e>=0;e--){let t=b[e];r.lineTo(t.x,t.y)}}r.closePath(),r.fill(),r.lineWidth=1,r.lineJoin=`round`,r.lineCap=`round`;let x=(e,t)=>{if(e.length!==0){r.strokeStyle=t,r.beginPath(),r.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++){let n=e[t];r.lineTo(n.x,n.y)}r.stroke()}};x(v,d.ENE.UPPER),x(y,d.ENE.MIDDLE),x(b,d.ENE.LOWER),r.restore()},getConfig(){let n=t();if(!n)return{};let r=e?.getSharedState(n);return r?{...r.params}:{}},setConfig(e){}}}var xc;new class extends mc{static[class{static{[xc,cc]=lc(this,[q({name:`ene`,displayName:`ENE`,category:`main`,stateKey:sc,defaultPaneId:`main`,applyResult:(e,t,n)=>{e.setSharedState(sc,t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=bc;constructor(){super(xc),cc()}};var Sc=`"Trebuchet MS", Roboto, Ubuntu, sans-serif`;function Cc(e,t){return`${t?.bold?`bold `:``}${e}px ${Sc}`}function wc(e,t){e.font!==t&&(e.font=t)}var Tc=new Map,Ec=512;function Dc(e,t){let n=`${e.font}\n${t}`,r=Tc.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Tc.size>=Ec&&Tc.clear(),Tc.set(n,i),i}function Oc(e){let t={yPaddingPx:e.yPaddingPx,indicators:{MA:{enabled:!0,params:{}},BOLL:{enabled:!1,params:{period:20,multiplier:2}},EXPMA:{enabled:!1,params:{fastPeriod:12,slowPeriod:50}},ENE:{enabled:!1,params:{period:10,deviation:11}}}},n=null;return{name:`mainIndicatorLegend`,version:`2.1.0`,description:`主图指标图例渲染器(MA 数据来自 StateStore)`,debugName:`主图指标图例`,paneId:`main`,priority:J.FOREGROUND,layer:`overlay`,enabled:!0,onInstall(e){n=e},getDeclaredNamespaces(){return[vs,Ns,Ys,sc]},draw(e){let{overlayCtx:r,data:i,range:a,crosshairIndex:o}=e,s=i,c=V(e.theme);if(!s.length||!r)return;r.save(),wc(r,Cc(12)),r.textAlign=`left`;let l=o??Math.min(a.end-1,s.length-1),u=[];t.indicators.MA?.enabled&&u.push({draw:e=>{let i=[],a=n?.getSharedState(vs);if(a&&a.visibleMin<=a.visibleMax)for(let e of a.enabledPeriods){let t=`MA${e}`,n=a.series[e]?.[l];i.push({label:`MA${e}`,color:c.MA[t]||c.MA.MA5,value:n})}if(i.length>0){let n=12,a=t.yPaddingPx/2+12+e*18;r.fillStyle=c.PRICE.NEUTRAL,r.fillText(`MA`,n,a),n+=Dc(r,`MA`)+10;for(let e of i){let t=typeof e.value==`number`?` ${e.value.toFixed(2)}`:``,i=`${e.label}${t}`;r.fillStyle=e.color,r.fillText(i,n,a),n+=Dc(r,i)+10}}}}),t.indicators.BOLL?.enabled&&u.push({draw:e=>{let i=n?.getSharedState(Ns),a=i?.series[l],o=i?.params.period??20,s=i?.params.multiplier??2,u=12,d=t.yPaddingPx/2+12+e*18,f=`BOLL(${o},${s})`;if(r.fillStyle=c.PRICE.NEUTRAL,r.fillText(f,u,d),u+=Dc(r,f)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=c.BOLL.UPPER,r.fillText(e,u,d),u+=Dc(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=c.BOLL.MIDDLE,r.fillText(t,u,d),u+=Dc(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=c.BOLL.LOWER,r.fillText(n,u,d)}}}),t.indicators.EXPMA?.enabled&&u.push({draw:e=>{let i=n?.getSharedState(Ys),a=i?.series[l],o=i?.params.fastPeriod??12,s=i?.params.slowPeriod??50,u=12,d=t.yPaddingPx/2+12+e*18,f=`EXPMA(${o},${s})`;if(r.fillStyle=c.PRICE.NEUTRAL,r.fillText(f,u,d),u+=Dc(r,f)+10,a){let e=`快:${a.fast.toFixed(2)}`;r.fillStyle=c.EXPMA.FAST,r.fillText(e,u,d),u+=Dc(r,e)+10;let t=`慢:${a.slow.toFixed(2)}`;r.fillStyle=c.EXPMA.SLOW,r.fillText(t,u,d)}}}),t.indicators.ENE?.enabled&&u.push({draw:e=>{let i=n?.getSharedState(sc),a=i?.series[l],o=i?.params.period??10,s=i?.params.deviation??11,u=12,d=t.yPaddingPx/2+12+e*18,f=`ENE(${o},${s})`;if(r.fillStyle=c.PRICE.NEUTRAL,r.fillText(f,u,d),u+=Dc(r,f)+10,a){let e=`上轨:${a.upper.toFixed(2)}`;r.fillStyle=c.ENE.UPPER,r.fillText(e,u,d),u+=Dc(r,e)+10;let t=`中轨:${a.middle.toFixed(2)}`;r.fillStyle=c.ENE.MIDDLE,r.fillText(t,u,d),u+=Dc(r,t)+10;let n=`下轨:${a.lower.toFixed(2)}`;r.fillStyle=c.ENE.LOWER,r.fillText(n,u,d)}}}),u.forEach((e,t)=>e.draw(t)),r.restore()},getConfig(){return{yPaddingPx:t.yPaddingPx,indicators:{...t.indicators}}},setConfig(e){if(typeof e.yPaddingPx==`number`&&(t.yPaddingPx=e.yPaddingPx),e.indicators&&typeof e.indicators==`object`)for(let[n,r]of Object.entries(e.indicators))t.indicators[n]||(t.indicators[n]={enabled:!1,params:{}}),r.enabled!==void 0&&(t.indicators[n].enabled=r.enabled),r.params&&(t.indicators[n].params=r.params)}}}var kc;function Ac(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Nc(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Nc(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:jc(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Pc(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function jc(e){var t=Mc(e,`string`);return typeof t==`symbol`?t:t+``}function Mc(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Nc(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Pc(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Fc(e){return e}function Ic(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[MACDRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`macd`);return r?Y(r.stateKey,t):(console.warn(`[MACDRenderer] Indicator metadata for 'macd' not found, skip rendering`),null)}function Lc(e={}){let{paneId:t=`sub`,config:n={}}=e,r=null;function i(){return Ic(r,t)}let a={fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:!0,showDEA:!0,showBAR:!0,...n},o=``,s=[],c=[];function l(){o=``,s=[],c=[]}function u(e,t,n,r,i,o){return n.yAxis.getDisplayRange(),[o,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,i.toFixed(6),r.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),a.showDIF,a.showDEA].join(`|`)}return{name:`macd_${t}`,version:`1.0.0`,description:`MACD 指标渲染器`,debugName:`MACD`,paneId:t,priority:J.INDICATOR,onInstall(e){r=e},getDeclaredNamespaces(){let e=i();return e?[e]:[]},draw(e){let{ctx:t,pane:n,data:l,range:d,scrollLeft:f,dpr:p,kLineCenters:m,lineWebGLSurface:h}=e,g=l,_=V(e.theme),v=i();if(!v)return;let y=r?.getSharedState(v);if(!y||y.visibleMin>y.visibleMax||g.length<a.slowPeriod)return;let b=y.series;if(!b||b.length===0)return;let x=y.visibleMin,S=y.visibleMax,C=Math.max(.05,(S-x)*.1);x-=C,S+=C,S-x;let w=n.yAxis.getDisplayRange({minPrice:x,maxPrice:S}),T=w.minPrice,E=w.maxPrice,D=E-T||1,O=n.height-(0-T)/D*n.height,k=Math.max(d.start,a.slowPeriod-1),A=Math.min(d.end,g.length);if(a.showBAR){let r=Math.round(O*p)/p,i=Math.max(1,A-k),a=new Float32Array(i*4),o=new Float32Array(i*4),s=new Float32Array(i*4),c=new Float32Array(i*4),l=0,u=0,m=0,h=0;for(let t=k;t<A;t++){let i=b[t];if(!i)continue;let f=e.kBarRects[t-d.start];if(!f)continue;let g=n.height-(i.macd-T)/D*n.height,_=i.macd>=0,v=t>0?b[t-1]:null,y=v?i.macd>=v.macd:!0,x=Math.round(g*p)/p,S=1/p,C,w;if(_){let e=r-x,t=e<=0?S:Math.max(e,S),n=e<=0?r-S:r-t;y?(C=a,w=l++):(C=o,w=u++);let i=w*4;C[i]=f.x,C[i+1]=n,C[i+2]=f.width,C[i+3]=t}else{let e=x-r,t=e<=0?S:Math.max(e,S);y?(C=c,w=h++):(C=s,w=m++);let n=w*4;C[n]=f.x,C[n+1]=r,C[n+2]=f.width,C[n+3]=t}}Rc(e,a,l,o,u,s,m,c,h)?Vc(t,e):zc(t,f,_,a,l,o,u,s,m,c,h)}let j=u(d,m,n,T,E,y.timestamp);if(o!==j){if(o=j,s=[],c=[],a.showDIF)for(let e=k;e<A;e++){let t=b[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dif-T)/D*n.height;s.push({x:r,y:i})}if(a.showDEA)for(let e=k;e<A;e++){let t=b[e];if(!t)continue;let r=m[e-d.start];if(r===void 0)continue;let i=n.height-(t.dea-T)/D*n.height;c.push({x:r,y:i})}}let M=e.settings?.enableWebGLRendering!==!1,N=!1;if(M&&h?.isAvailable()){let e=[];a.showDIF&&s.length>=2&&e.push({points:s,width:1,color:_.MACD.DIF}),a.showDEA&&c.length>=2&&e.push({points:c,width:1,color:_.MACD.DEA}),e.length>0&&h.drawLineStrips(e,f)&&(N=!0,h.compositeTo(t,{imageSmoothingEnabled:!1}))}N||Bc(t,f,_,s,c,a)},onDataUpdate(){l()},getConfig(){return{...a}},setConfig(e){let t=!1;`fastPeriod`in e&&e.fastPeriod!==a.fastPeriod&&l(),`slowPeriod`in e&&e.slowPeriod!==a.slowPeriod&&l(),`signalPeriod`in e&&e.signalPeriod!==a.signalPeriod&&l(),`showDIF`in e&&e.showDIF!==a.showDIF&&(t=!0),`showDEA`in e&&e.showDEA!==a.showDEA&&(t=!0),Object.assign(a,e),t&&l()}}}function Rc(e,t,n,r,i,a,o,s,c){let l=V(e.theme);if(e.settings?.enableWebGLRendering===!1)return!1;let u=e.candleWebGLSurface;if(!u||!u.isAvailable())return!1;u.clear();let d=n===0||u.drawRectBuffer(t.subarray(0,n*4),n,l.MACD.BAR_UP,e.scrollLeft),f=i===0||u.drawRectBuffer(r.subarray(0,i*4),i,l.MACD.BAR_UP_LIGHT,e.scrollLeft),p=o===0||u.drawRectBuffer(a.subarray(0,o*4),o,l.MACD.BAR_DOWN,e.scrollLeft),m=c===0||u.drawRectBuffer(s.subarray(0,c*4),c,l.MACD.BAR_DOWN_LIGHT,e.scrollLeft);return d&&f&&p&&m}function zc(e,t,n,r,i,a,o,s,c,l,u){e.save(),e.translate(-t,0),e.fillStyle=n.MACD.BAR_UP;for(let t=0;t<i;t++){let n=t*4;e.fillRect(r[n],r[n+1],r[n+2],r[n+3])}e.fillStyle=n.MACD.BAR_UP_LIGHT;for(let t=0;t<o;t++){let n=t*4;e.fillRect(a[n],a[n+1],a[n+2],a[n+3])}e.fillStyle=n.MACD.BAR_DOWN;for(let t=0;t<c;t++){let n=t*4;e.fillRect(s[n],s[n+1],s[n+2],s[n+3])}e.fillStyle=n.MACD.BAR_DOWN_LIGHT;for(let t=0;t<u;t++){let n=t*4;e.fillRect(l[n],l[n+1],l[n+2],l[n+3])}e.restore()}function Bc(e,t,n,r,i,a){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,a.showDIF&&r.length>=2){e.strokeStyle=n.MACD.DIF,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}if(a.showDEA&&i.length>=2){e.strokeStyle=n.MACD.DEA,e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let t=1;t<i.length;t++){let n=i[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function Vc(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function Hc(e,t,n,r,i,a=`sub_MACD`,o=`light`){let s=V(o),c=i.getSharedState(ha(a));if(!c)return null;let l=c.series[e];return l?{name:`MACD`,params:[t,n,r],values:[{label:`DIF`,value:l.dif,color:s.MACD.DIF},{label:`DEA`,value:l.dea,color:s.MACD.DEA},{label:`MACD`,value:l.macd,color:l.macd>=0?s.MACD.BAR_UP:s.MACD.BAR_DOWN}]}:null}var Uc;new class extends Fc{static[class{static{[Uc,kc]=Ac(this,[q({name:`macd`,displayName:`MACD`,category:`oscillator`,stateKey:ha,defaultPaneId:`sub_MACD`,paneIdField:`macdPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ha(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Lc;constructor(){super(Uc),kc()}};var Wc;function Gc(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Jc(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Jc(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Kc(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Yc(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Kc(e){var t=qc(e,`string`);return typeof t==`symbol`?t:t+``}function qc(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Jc(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Yc(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Xc(e){return e}function Zc(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[RSIRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`rsi`);return r?Y(r.stateKey,t):(console.warn(`[RSIRenderer] Indicator metadata for 'rsi' not found, skip rendering`),null)}function Qc(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return Zc(n,t)}let i=``,a=[],o=[],s=[],c=null,l=null,u=``;function d(){i=``,a=[],o=[],s=[]}function f(e,t){return(!c||c.width!==e||c.height!==t)&&(c=document.createElement(`canvas`),c.width=e,c.height=t,l=c.getContext(`2d`),u=``),{canvas:c,ctx:l}}function p(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function m(e,t,n,r,i,a){let o=i-r||1,s=Z(n-(80-r)/o*n,a),c=Z(n-(50-r)/o*n,a),l=Z(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.moveTo(0,l),e.lineTo(t,l),e.stroke(),e.restore()}function h(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showRSI1,r.showRSI2,r.showRSI3].join(`|`)}return{name:`rsi_${t}`,version:`2.1.0`,description:`RSI 相对强弱指标渲染器(WebGL + Canvas2D 回退)`,debugName:`RSI`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:l,range:g,scrollLeft:_,dpr:v,kLineCenters:y,lineWebGLSurface:b}=e,x=V(e.theme),S=r();if(!S)return;let C=n?.getSharedState(S);if(!C||C.visibleMin>C.visibleMax){d();return}let{valueMin:w,valueMax:T,params:E,series:D}=C,O=l.yAxis.getDisplayRange({minPrice:w,maxPrice:T}),k=O.minPrice,A=O.maxPrice,j=A-k||1,M=e.paneWidth,N=l.height,P=p(M,N,k,A,v);if(u!==P){u=P;let{ctx:e}=f(Math.ceil(M*v),Math.ceil(N*v));m(e,M,N,k,A,v)}c&&t.drawImage(c,0,0,M,N);let F=Math.max(g.start,E.period1),I=Math.min(g.end,y.length+g.start),L=h(g,y,l,E,C.timestamp);if(i!==L){i=L;let e=N,t=e/j,n=g.start,r=r=>{let i=[];for(let a=F;a<I;a++){let o=r[a];if(o===void 0)continue;let s=y[a-n];s!==void 0&&i.push({x:s,y:e-(o-k)*t})}return i};a=E.showRSI1&&D[E.period1]?r(D[E.period1]):[],o=E.showRSI2&&D[E.period2]?r(D[E.period2]):[],s=E.showRSI3&&D[E.period3]?r(D[E.period3]):[]}let ee=e.settings?.enableWebGLRendering!==!1,R=!1;if(ee&&b?.isAvailable()){let e=[];E.showRSI1&&a.length>=2&&e.push({points:a,width:1,color:x.RSI.RSI1}),E.showRSI2&&o.length>=2&&e.push({points:o,width:1,color:x.RSI.RSI2}),E.showRSI3&&s.length>=2&&e.push({points:s,width:1,color:x.RSI.RSI3}),e.length>0&&b.drawLineStrips(e,_)&&(R=!0,b.compositeTo(t,{imageSmoothingEnabled:!1}))}R||$c(t,_,a,o,s,E,x)},getConfig(){let e=r();if(!e)return{};let t=n?.getSharedState(e);return t?{...t.params}:{}},setConfig(e){}}}function $c(e,t,n,r,i,a,o){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,a.showRSI1&&n.length>=2){e.strokeStyle=o.RSI.RSI1,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(a.showRSI2&&r.length>=2){e.strokeStyle=o.RSI.RSI2,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}if(a.showRSI3&&i.length>=2){e.strokeStyle=o.RSI.RSI3,e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let t=1;t<i.length;t++){let n=i[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function el(e,t,n,r,i,a=`sub_RSI`,o=`light`){let s=V(o),c=ea(a),l=i.getSharedState(c);if(!l)return null;let u=l.series[t]?.[e],d=l.series[n]?.[e],f=l.series[r]?.[e],p=[];return u!==void 0&&p.push({label:`RSI${t}`,value:u,color:s.RSI.RSI1}),d!==void 0&&p.push({label:`RSI${n}`,value:d,color:s.RSI.RSI2}),f!==void 0&&p.push({label:`RSI${r}`,value:f,color:s.RSI.RSI3}),p.length===0?null:{name:`RSI`,params:[t,n,r],values:p}}var tl;new class extends Xc{static[class{static{[tl,Wc]=Gc(this,[q({name:`rsi`,displayName:`RSI`,category:`oscillator`,stateKey:ea,defaultPaneId:`sub_RSI`,paneIdField:`rsiPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ea(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Qc;constructor(){super(tl),Wc()}};var nl;function rl(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ol(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ol(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:il(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return sl(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function il(e){var t=al(e,`string`);return typeof t==`symbol`?t:t+``}function al(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ol(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function sl(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function cl(e){return e}function ll(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[CCIRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`cci`);return r?Y(r.stateKey,t):(console.warn(`[CCIRenderer] Indicator metadata for 'cci' not found, skip rendering`),null)}function ul(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return ll(n,t)}let i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showCCI,r.period].join(`|`)}return{name:`cci_${t}`,version:`2.1.0`,description:`CCI 顺势指标渲染器(WebGL + Canvas2D 回退)`,debugName:`CCI`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,dpr:d,kLineCenters:f,lineWebGLSurface:p}=e,m=V(e.theme),h=r();if(!h)return;let g=n?.getSharedState(h);if(!g||g.visibleMin>g.visibleMax){o();return}let{valueMin:_,valueMax:v,params:y,series:b}=g;v-_;let x=c.yAxis.getDisplayRange({minPrice:_,maxPrice:v}),S=x.minPrice,C=x.maxPrice-S||1,w=c.height-(0-S)/C*c.height;t.save(),t.translate(-u,0);let T=c.height-(100-S)/C*c.height,E=c.height-(-100-S)/C*c.height,D=u,O=u+e.paneWidth;t.strokeStyle=m.CCI.OVERBOUGHT,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(D,T),t.lineTo(O,T),t.stroke(),t.strokeStyle=m.CCI.OVERSOLD,t.beginPath(),t.moveTo(D,E),t.lineTo(O,E),t.stroke(),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.beginPath(),t.moveTo(D,w),t.lineTo(O,w),t.stroke(),t.setLineDash([]),t.restore();let k=Math.max(l.start,y.period-1),A=Math.min(l.end,b.length),j=s(l,f,c,y,g.timestamp);if(i!==j&&(i=j,a=[],y.showCCI))for(let e=k;e<A;e++){let t=b[e];if(t===void 0)continue;let n=f[e-l.start];if(n===void 0)continue;let r=c.height-(t-S)/C*c.height;a.push({x:n,y:r})}let M=e.settings?.enableWebGLRendering!==!1,N=!1;M&&p?.isAvailable()&&y.showCCI&&a.length>=2&&p.drawLineStrips([{points:a,width:1,color:m.CCI.CCI}],u)&&(N=!0,p.compositeTo(t,{imageSmoothingEnabled:!1})),N||dl(t,u,a,y,m)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function dl(e,t,n,r,i){if(!(!r.showCCI||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=i.CCI.CCI,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function fl(e,t,n,r=`sub_CCI`,i=`light`){let a=V(i),o=n.getSharedState(na(r));if(!o)return null;let s=o.series[e];return s===void 0?null:{name:`CCI`,params:[t],values:[{label:`CCI`,value:s,color:a.CCI.CCI}]}}var pl;new class extends cl{static[class{static{[pl,nl]=rl(this,[q({name:`cci`,displayName:`CCI`,category:`oscillator`,stateKey:na,defaultPaneId:`sub_CCI`,paneIdField:`cciPaneId`,applyResult:(e,t,n)=>{e.setSharedState(na(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=ul;constructor(){super(pl),nl()}};var ml;function hl(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:vl(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||vl(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:gl(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return yl(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function gl(e){var t=_l(e,`string`);return typeof t==`symbol`?t:t+``}function _l(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vl(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function yl(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function bl(e){return e}function xl(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[STOCHRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`stoch`);return r?Y(r.stateKey,t):(console.warn(`[STOCHRenderer] Indicator metadata for 'stoch' not found, skip rendering`),null)}function Sl(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return xl(n,t)}let i=``,a=[],o=[],s=null,c=null,l=``;function u(){i=``,a=[],o=[]}function d(e,t){return(!s||s.width!==e||s.height!==t)&&(s=document.createElement(`canvas`),s.width=e,s.height=t,c=s.getContext(`2d`),l=``),{canvas:s,ctx:c}}function f(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function p(e,t,n,r,i,a){let o=i-r||1,s=Z(n-(80-r)/o*n,a),c=Z(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.restore()}function m(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showK,r.showD,r.n,r.m].join(`|`)}return{name:`stoch_${t}`,version:`2.1.0`,description:`STOCH 随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`STOCH`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:c,range:h,scrollLeft:g,dpr:_,kLineCenters:v,lineWebGLSurface:y}=e,b=V(e.theme),x=r();if(!x)return;let S=n?.getSharedState(x);if(!S||S.visibleMin>S.visibleMax){u();return}let{valueMin:C,valueMax:w,params:T,series:E}=S,D=c.yAxis.getDisplayRange({minPrice:C,maxPrice:w}),O=D.minPrice,k=D.maxPrice,A=k-O||1,j=e.paneWidth,M=c.height,N=f(j,M,O,k,_);if(l!==N){l=N;let{ctx:e}=d(Math.ceil(j*_),Math.ceil(M*_));p(e,j,M,O,k,_)}s&&t.drawImage(s,0,0,j,M);let P=Math.max(h.start,T.n+T.m-2),F=Math.min(h.end,E.length),I=m(h,v,c,T,S.timestamp);if(i!==I){i=I;let e=M,t=e/A,n=h.start;if(T.showK){let r=[];for(let i=P;i<F;i++){let a=E[i];if(!a)continue;let o=v[i-n];o!==void 0&&r.push({x:o,y:e-(a.k-O)*t})}a=r}else a=[];if(T.showD){let r=[];for(let i=P;i<F;i++){let a=E[i];if(!a)continue;let o=v[i-n];o!==void 0&&r.push({x:o,y:e-(a.d-O)*t})}o=r}else o=[]}let L=e.settings?.enableWebGLRendering!==!1,ee=!1;if(L&&y?.isAvailable()){let e=[];T.showK&&a.length>=2&&e.push({points:a,width:1,color:b.KDJ.K}),T.showD&&o.length>=2&&e.push({points:o,width:1,color:b.KDJ.D}),e.length>0&&y.drawLineStrips(e,g)&&(ee=!0,y.compositeTo(t,{imageSmoothingEnabled:!1}))}ee||Cl(t,g,a,o,T,b)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Cl(e,t,n,r,i,a){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showK&&n.length>=2){e.strokeStyle=a.KDJ.K,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showD&&r.length>=2){e.strokeStyle=a.KDJ.D,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function wl(e,t,n,r,i=`sub_STOCH`,a=`light`){let o=V(a),s=r.getSharedState(ia(i));if(!s)return null;let c=s.series[e];if(!c||c.k===void 0)return null;let l=[];return s.params.showK&&l.push({label:`K`,value:c.k,color:o.KDJ.K}),s.params.showD&&l.push({label:`D`,value:c.d,color:o.KDJ.D}),l.length===0?null:{name:`STOCH`,params:[t,n],values:l}}var Tl;new class extends bl{static[class{static{[Tl,ml]=hl(this,[q({name:`stoch`,displayName:`STOCH`,category:`oscillator`,stateKey:ia,defaultPaneId:`sub_STOCH`,paneIdField:`stochPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ia(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Sl;constructor(){super(Tl),ml()}};var El;function Dl(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Al(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Al(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Ol(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return jl(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Ol(e){var t=kl(e,`string`);return typeof t==`symbol`?t:t+``}function kl(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Al(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function jl(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Ml(e){return e}function Nl(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[MOMRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`mom`);return r?Y(r.stateKey,t):(console.warn(`[MOMRenderer] Indicator metadata for 'mom' not found, skip rendering`),null)}function Pl(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return Nl(n,t)}let i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a,o){let s=i-r||1,c=Z(n-(0-r)/s*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=o.MOM.ZERO,e.lineWidth=1,e.beginPath(),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.restore()}function p(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showMOM,r.period].join(`|`)}return{name:`mom_${t}`,version:`2.1.0`,description:`MOM 动量指标渲染器(WebGL + Canvas2D 回退)`,debugName:`MOM`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=V(e.theme),b=r();if(!b)return;let x=n?.getSharedState(b);if(!x||x.visibleMin>x.visibleMax){l();return}let{valueMin:S,valueMax:C,params:w,series:T}=x,E=s.yAxis.getDisplayRange({minPrice:S,maxPrice:C}),D=E.minPrice,O=E.maxPrice,k=O-D||1,A=e.paneWidth,j=s.height,M=d(A,j,D,O,g);if(c!==M){c=M;let{ctx:e}=u(Math.ceil(A*g),Math.ceil(j*g));f(e,A,j,D,O,g,y)}o&&t.drawImage(o,0,0,A,j);let N=Math.max(m.start,w.period),P=Math.min(m.end,T.length),F=p(m,_,s,w,x.timestamp);if(i!==F){i=F;let e=j,t=e/k,n=m.start;if(w.showMOM){let r=[];for(let i=N;i<P;i++){let a=T[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-D)*t})}a=r}else a=[]}let I=e.settings?.enableWebGLRendering!==!1,L=!1;I&&v?.isAvailable()&&w.showMOM&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:y.MOM.MOM}],h)&&(L=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),L||Fl(t,h,a,w,y)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Fl(e,t,n,r,i){if(!(!r.showMOM||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=i.MOM.MOM,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function Il(e,t,n,r=`sub_MOM`,i=`light`){let a=V(i),o=n.getSharedState(oa(r));if(!o)return null;let s=o.series[e];return s===void 0?null:{name:`MOM`,params:[t],values:[{label:`MOM`,value:s,color:a.MOM.MOM}]}}var Ll;new class extends Ml{static[class{static{[Ll,El]=Dl(this,[q({name:`mom`,displayName:`MOM`,category:`oscillator`,stateKey:oa,defaultPaneId:`sub_MOM`,paneIdField:`momPaneId`,applyResult:(e,t,n)=>{e.setSharedState(oa(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Pl;constructor(){super(Ll),El()}};var Rl;function zl(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Hl(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Hl(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Bl(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Ul(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Bl(e){var t=Vl(e,`string`);return typeof t==`symbol`?t:t+``}function Vl(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Hl(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Ul(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Wl(e){return e}function Gl(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[WMSRRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`wmsr`);return r?Y(r.stateKey,t):(console.warn(`[WMSRRenderer] Indicator metadata for 'wmsr' not found, skip rendering`),null)}function Kl(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return Gl(n,t)}let i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a,o){let s=i-r||1,c=Z(n-(-20-r)/s*n,a),l=Z(n-(-80-r)/s*n,a),u=Z(n-(-50-r)/s*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.lineWidth=1,e.setLineDash([4,4]),e.strokeStyle=o.WMSR.OVERBOUGHT,e.beginPath(),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.strokeStyle=o.WMSR.OVERSOLD,e.beginPath(),e.moveTo(0,l),e.lineTo(t,l),e.stroke(),e.strokeStyle=o.WMSR_GRID,e.beginPath(),e.moveTo(0,u),e.lineTo(t,u),e.stroke(),e.restore()}function p(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showWMSR,r.period].join(`|`)}return{name:`wmsr_${t}`,version:`2.1.0`,description:`WMSR 威廉指标渲染器(WebGL + Canvas2D 回退)`,debugName:`WMSR`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=V(e.theme),b=r();if(!b)return;let x=n?.getSharedState(b);if(!x||x.visibleMin>x.visibleMax){l();return}let{valueMin:S,valueMax:C,params:w,series:T}=x,E=s.yAxis.getDisplayRange({minPrice:S,maxPrice:C}),D=E.minPrice,O=E.maxPrice,k=O-D||1,A=e.paneWidth,j=s.height,M=d(A,j,D,O,g);if(c!==M){c=M;let{ctx:e}=u(Math.ceil(A*g),Math.ceil(j*g));f(e,A,j,D,O,g,y)}o&&t.drawImage(o,0,0,A,j);let N=Math.max(m.start,w.period-1),P=Math.min(m.end,T.length),F=p(m,_,s,w,x.timestamp);if(i!==F){i=F;let e=j,t=e/k,n=m.start;if(w.showWMSR){let r=[];for(let i=N;i<P;i++){let a=T[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-D)*t})}a=r}else a=[]}let I=e.settings?.enableWebGLRendering!==!1,L=!1;I&&v?.isAvailable()&&w.showWMSR&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:y.WMSR.WMSR}],h)&&(L=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),L||ql(t,h,a,w,y)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function ql(e,t,n,r,i){if(!(!r.showWMSR||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=i.WMSR.WMSR,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function Jl(e,t,n,r=`sub_WMSR`,i=`light`){let a=V(i),o=n.getSharedState(ca(r));if(!o)return null;let s=o.series[e];return s===void 0?null:{name:`WMSR`,params:[t],values:[{label:`WMSR`,value:s,color:a.WMSR.WMSR}]}}var Yl;new class extends Wl{static[class{static{[Yl,Rl]=zl(this,[q({name:`wmsr`,displayName:`WMSR`,category:`oscillator`,stateKey:ca,defaultPaneId:`sub_WMSR`,paneIdField:`wmsrPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ca(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Kl;constructor(){super(Yl),Rl()}};var Xl;function Zl(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:eu(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||eu(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Ql(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return tu(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Ql(e){var t=$l(e,`string`);return typeof t==`symbol`?t:t+``}function $l(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function eu(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function tu(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function nu(e){return e}function ru(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[KSTRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`kst`);return r?Y(r.stateKey,t):(console.warn(`[KSTRenderer] Indicator metadata for 'kst' not found, skip rendering`),null)}function iu(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return ru(n,t)}let i=``,a=[],o=[];function s(){i=``,a=[],o=[]}function c(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showKST,r.showSignal,r.roc1,r.roc2,r.roc3,r.roc4,r.signalPeriod].join(`|`)}return{name:`kst_${t}`,version:`2.1.0`,description:`KST 确知指标渲染器(WebGL + Canvas2D 回退)`,debugName:`KST`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:l,range:u,scrollLeft:d,dpr:f,kLineCenters:p,lineWebGLSurface:m}=e,h=V(e.theme),g=r();if(!g)return;let _=n?.getSharedState(g);if(!_||_.visibleMin>_.visibleMax){s();return}let{valueMin:v,valueMax:y,params:b,series:x}=_;y-v;let S=l.yAxis.getDisplayRange({minPrice:v,maxPrice:y}),C=S.minPrice,w=S.maxPrice-C||1,T=l.height-(0-C)/w*l.height;t.save(),t.translate(-d,0);let E=d,D=d+e.paneWidth;t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.beginPath(),t.moveTo(E,T),t.lineTo(D,T),t.stroke(),t.restore();let O=Math.max(u.start,b.roc4+15+b.signalPeriod-1),k=Math.min(u.end,x.length),A=c(u,p,l,b,_.timestamp);if(i!==A){if(i=A,a=[],o=[],b.showKST)for(let e=O;e<k;e++){let t=x[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.kst-C)/w*l.height;a.push({x:n,y:r})}if(b.showSignal)for(let e=O;e<k;e++){let t=x[e];if(!t)continue;let n=p[e-u.start];if(n===void 0)continue;let r=l.height-(t.signal-C)/w*l.height;o.push({x:n,y:r})}}let j=e.settings?.enableWebGLRendering!==!1,M=!1;if(j&&m?.isAvailable()){let e=[];b.showKST&&a.length>=2&&e.push({points:a,width:1,color:h.KST.KST}),b.showSignal&&o.length>=2&&e.push({points:o,width:1,color:h.KST.SIGNAL}),e.length>0&&m.drawLineStrips(e,d)&&(M=!0,m.compositeTo(t,{imageSmoothingEnabled:!1}))}M||au(t,d,a,o,b,h)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function au(e,t,n,r,i,a){if(e.save(),e.translate(-t,0),e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,i.showKST&&n.length>=2){e.strokeStyle=a.KST.KST,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke()}if(i.showSignal&&r.length>=2){e.strokeStyle=a.KST.SIGNAL,e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t++){let n=r[t];e.lineTo(n.x,n.y)}e.stroke()}e.restore()}function ou(e,t,n,r,i,a,o,s=`sub_KST`,c=`light`){let l=V(c),u=o.getSharedState(ua(s));if(!u)return null;let d=u.series[e];if(!d)return null;let f=[];return u.params.showKST&&f.push({label:`KST`,value:d.kst,color:l.KST.KST}),u.params.showSignal&&f.push({label:`Signal`,value:d.signal,color:l.KST.SIGNAL}),f.length===0?null:{name:`KST`,params:[t,n,r,i,a],values:f}}var su;new class extends nu{static[class{static{[su,Xl]=Zl(this,[q({name:`kst`,displayName:`KST`,category:`oscillator`,stateKey:ua,defaultPaneId:`sub_KST`,paneIdField:`kstPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ua(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=iu;constructor(){super(su),Xl()}};var cu;function lu(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:fu(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||fu(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:uu(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return pu(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function uu(e){var t=du(e,`string`);return typeof t==`symbol`?t:t+``}function du(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fu(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function pu(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function mu(e){return e}function hu(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[FASTKRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`fastk`);return r?Y(r.stateKey,t):(console.warn(`[FASTKRenderer] Indicator metadata for 'fastk' not found, skip rendering`),null)}function gu(e={}){let{paneId:t=`sub`}=e,n=null;function r(){return hu(n,t)}let i=``,a=[],o=null,s=null,c=``;function l(){i=``,a=[]}function u(e,t){return(!o||o.width!==e||o.height!==t)&&(o=document.createElement(`canvas`),o.width=e,o.height=t,s=o.getContext(`2d`),c=``),{canvas:o,ctx:s}}function d(e,t,n,r,i){return`${e}|${t}|${n.toFixed(4)}|${r.toFixed(4)}|${i}`}function f(e,t,n,r,i,a){let o=i-r||1,s=Z(n-(80-r)/o*n,a),c=Z(n-(20-r)/o*n,a);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.save(),e.scale(a,a),e.strokeStyle=`rgba(0, 0, 0, 0.1)`,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(0,s),e.lineTo(t,s),e.moveTo(0,c),e.lineTo(t,c),e.stroke(),e.restore()}function p(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showFASTK,r.period].join(`|`)}return{name:`fastk_${t}`,version:`2.1.0`,description:`FASTK 快速随机指标渲染器(WebGL + Canvas2D 回退)`,debugName:`FASTK`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:s,range:m,scrollLeft:h,dpr:g,kLineCenters:_,lineWebGLSurface:v}=e,y=V(e.theme),b=r();if(!b)return;let x=n?.getSharedState(b);if(!x||x.visibleMin>x.visibleMax){l();return}let{valueMin:S,valueMax:C,params:w,series:T}=x,E=s.yAxis.getDisplayRange({minPrice:S,maxPrice:C}),D=E.minPrice,O=E.maxPrice,k=O-D||1,A=e.paneWidth,j=s.height,M=d(A,j,D,O,g);if(c!==M){c=M;let{ctx:e}=u(Math.ceil(A*g),Math.ceil(j*g));f(e,A,j,D,O,g)}o&&t.drawImage(o,0,0,A,j);let N=Math.max(m.start,w.period-1),P=Math.min(m.end,T.length),F=p(m,_,s,w,x.timestamp);if(i!==F){i=F;let e=j,t=e/k,n=m.start;if(w.showFASTK){let r=[];for(let i=N;i<P;i++){let a=T[i];if(a===void 0)continue;let o=_[i-n];o!==void 0&&r.push({x:o,y:e-(a-D)*t})}a=r}else a=[]}let I=e.settings?.enableWebGLRendering!==!1,L=!1;I&&v?.isAvailable()&&w.showFASTK&&a.length>=2&&v.drawLineStrips([{points:a,width:1,color:y.KDJ.K}],h)&&(L=!0,v.compositeTo(t,{imageSmoothingEnabled:!1})),L||_u(t,h,a,w,y)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function _u(e,t,n,r,i){if(!(!r.showFASTK||n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=i.KDJ.K,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function vu(e,t,n,r=`sub_FASTK`,i=`light`){let a=V(i),o=n.getSharedState(fa(r));if(!o)return null;let s=o.series[e];return s===void 0?null:{name:`FASTK`,params:[t],values:[{label:`FASTK`,value:s,color:a.KDJ.K}]}}var yu;new class extends mu{static[class{static{[yu,cu]=lu(this,[q({name:`fastk`,displayName:`FASTK`,category:`oscillator`,stateKey:fa,defaultPaneId:`sub_FASTK`,paneIdField:`fastkPaneId`,applyResult:(e,t,n)=>{e.setSharedState(fa(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=gu;constructor(){super(yu),cu()}};var bu;function xu(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:wu(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||wu(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Su(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Tu(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Su(e){var t=Cu(e,`string`);return typeof t==`symbol`?t:t+``}function Cu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function wu(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Tu(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Eu(e){return e}var Du=`#d97706`;function Ou(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[ATRRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`atr`);return r?Y(r.stateKey,t):(console.warn(`[ATRRenderer] Indicator metadata for 'atr' not found, skip rendering`),null)}function ku(e={}){let{paneId:t=`sub_ATR`}=e,n=null;function r(){return Ou(n,t)}let i=``,a=[];function o(){i=``,a=[]}function s(e,t,n,r,i){let a=n.yAxis.getDisplayRange();return[i,e.start,e.end,t.length,t[0]?.toFixed(2)??`n`,t[t.length-1]?.toFixed(2)??`n`,a.maxPrice.toFixed(6),a.minPrice.toFixed(6),n.yAxis.getPriceOffset().toFixed(6),n.yAxis.getScaleType(),n.height.toFixed(2),r.showATR,r.period].join(`|`)}return{name:`atr_${t}`,version:`1.0.0`,description:`ATR 平均真实波幅渲染器(Wilder 平滑)`,debugName:`ATR`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:c,range:l,scrollLeft:u,kLineCenters:d,lineWebGLSurface:f}=e,p=r();if(!p)return;let m=n?.getSharedState(p);if(!m||!m.params.showATR||m.visibleMin>m.visibleMax){o();return}let{valueMin:h,valueMax:g,params:_,series:v}=m;g-h;let y=c.yAxis.getDisplayRange({minPrice:h,maxPrice:g}),b=y.minPrice,x=y.maxPrice-b||1,S=c.height-(0-b)/x*c.height;t.save(),t.translate(-u,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(u,S),t.lineTo(u+e.paneWidth,S),t.stroke(),t.setLineDash([]),t.restore();let C=Math.max(l.start,_.period-1),w=Math.min(l.end,v.length),T=s(l,d,c,_,m.timestamp);if(i!==T){i=T,a=[];for(let e=C;e<w;e++){let t=v[e];if(t===void 0)continue;let n=d[e-l.start];if(n===void 0)continue;let r=c.height-(t-b)/x*c.height;a.push({x:n,y:r})}}let E=e.settings?.enableWebGLRendering!==!1,D=!1;E&&f?.isAvailable()&&a.length>=2&&f.drawLineStrips([{points:a,width:1,color:Du}],u)&&(D=!0,f.compositeTo(t,{imageSmoothingEnabled:!1})),D||Au(t,u,a)},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Au(e,t,n){if(!(n.length<2)){e.save(),e.translate(-t,0),e.strokeStyle=Du,e.lineWidth=1,e.lineJoin=`round`,e.lineCap=`round`,e.beginPath(),e.moveTo(n[0].x,n[0].y);for(let t=1;t<n.length;t++){let r=n[t];e.lineTo(r.x,r.y)}e.stroke(),e.restore()}}function ju(e,t,n,r=`sub_ATR`){let i=n.getSharedState(_a(r));if(!i)return null;let a=i.series[e];return a===void 0?null:{name:`ATR`,params:[t],values:[{label:`ATR`,value:a,color:Du}]}}var Mu;new class extends Eu{static[class{static{[Mu,bu]=xu(this,[q({name:`atr`,displayName:`ATR`,category:`oscillator`,stateKey:_a,defaultPaneId:`sub_ATR`,paneIdField:`atrPaneId`,applyResult:(e,t,n)=>{e.setSharedState(_a(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=ku;constructor(){super(Mu),bu()}};var Nu;function Pu(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Lu(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Lu(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Fu(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Ru(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Fu(e){var t=Iu(e,`string`);return typeof t==`symbol`?t:t+``}function Iu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Lu(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Ru(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function zu(e){return e}var Bu=`#10b981`;function Vu(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[WMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`wma`);return r?Y(r.stateKey,t):(console.warn(`[WMARenderer] Indicator metadata for 'wma' not found, skip rendering`),null)}function Hu(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Vu(n,t)}return{name:`wma_${t}`,version:`1.1.0`,description:`WMA 线性加权移动均线渲染器(WebGL + Canvas2D 回退)`,debugName:`WMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showWMA||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=Math.min(a.end,d.length),p=a.start,m=[];for(let e=a.start;e<f;e++){let t=d[e];if(t===void 0)continue;let n=s[e-p];n!==void 0&&m.push({x:n,y:i.yAxis.priceToY(t)})}if(m.length<2)return;let h=e.settings?.enableWebGLRendering!==!1,g=!1;if(h&&c?.isAvailable()&&c.drawLineStrips([{points:m,width:1,color:Bu}],o)&&(g=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!g){t.save(),t.translate(-o,0),t.strokeStyle=Bu,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(m[0].x,m[0].y);for(let e=1;e<m.length;e++)t.lineTo(m[e].x,m[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Uu;new class extends zu{static[class{static{[Uu,Nu]=Pu(this,[q({name:`wma`,displayName:`WMA`,category:`main`,stateKey:ya,defaultPaneId:`main`,paneIdField:`wmaPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(ya(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Hu;constructor(){super(Uu),Nu()}};var Wu;function Gu(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Ju(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Ju(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Ku(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Yu(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Ku(e){var t=qu(e,`string`);return typeof t==`symbol`?t:t+``}function qu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ju(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Yu(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Xu(e){return e}var Zu=`#6366f1`;function Qu(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[DEMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`dema`);return r?Y(r.stateKey,t):(console.warn(`[DEMARenderer] Indicator metadata for 'dema' not found, skip rendering`),null)}function $u(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Qu(n,t)}return{name:`dema_${t}`,version:`1.1.0`,description:`DEMA 双重指数移动均线渲染器(WebGL + Canvas2D 回退)`,debugName:`DEMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showDEMA||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=Math.min(a.end,d.length),p=a.start,m=[];for(let e=a.start;e<f;e++){let t=d[e];if(t===void 0)continue;let n=s[e-p];n!==void 0&&m.push({x:n,y:i.yAxis.priceToY(t)})}if(m.length<2)return;let h=e.settings?.enableWebGLRendering!==!1,g=!1;if(h&&c?.isAvailable()&&c.drawLineStrips([{points:m,width:1,color:Zu}],o)&&(g=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!g){t.save(),t.translate(-o,0),t.strokeStyle=Zu,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(m[0].x,m[0].y);for(let e=1;e<m.length;e++)t.lineTo(m[e].x,m[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var ed;new class extends Xu{static[class{static{[ed,Wu]=Gu(this,[q({name:`dema`,displayName:`DEMA`,category:`main`,stateKey:xa,defaultPaneId:`main`,paneIdField:`demaPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(xa(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=$u;constructor(){super(ed),Wu()}};var td;function nd(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ad(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ad(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:rd(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return od(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function rd(e){var t=id(e,`string`);return typeof t==`symbol`?t:t+``}function id(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ad(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function od(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function sd(e){return e}var cd=`#d946ef`;function ld(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[TEMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`tema`);return r?Y(r.stateKey,t):(console.warn(`[TEMARenderer] Indicator metadata for 'tema' not found, skip rendering`),null)}function ud(e={}){let{paneId:t=`main`}=e,n=null;function r(){return ld(n,t)}return{name:`tema_${t}`,version:`1.1.0`,description:`TEMA 三重指数移动均线渲染器(WebGL + Canvas2D 回退)`,debugName:`TEMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showTEMA||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=Math.min(a.end,d.length),p=a.start,m=[];for(let e=a.start;e<f;e++){let t=d[e];if(t===void 0)continue;let n=s[e-p];n!==void 0&&m.push({x:n,y:i.yAxis.priceToY(t)})}if(m.length<2)return;let h=e.settings?.enableWebGLRendering!==!1,g=!1;if(h&&c?.isAvailable()&&c.drawLineStrips([{points:m,width:1,color:cd}],o)&&(g=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!g){t.save(),t.translate(-o,0),t.strokeStyle=cd,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(m[0].x,m[0].y);for(let e=1;e<m.length;e++)t.lineTo(m[e].x,m[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var dd;new class extends sd{static[class{static{[dd,td]=nd(this,[q({name:`tema`,displayName:`TEMA`,category:`main`,stateKey:Ca,defaultPaneId:`main`,paneIdField:`temaPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(Ca(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=ud;constructor(){super(dd),td()}};var fd;function pd(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:gd(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||gd(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:md(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return _d(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function md(e){var t=hd(e,`string`);return typeof t==`symbol`?t:t+``}function hd(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function gd(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function _d(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function vd(e){return e}var yd=`#f43f5e`;function bd(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[HMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`hma`);return r?Y(r.stateKey,t):(console.warn(`[HMARenderer] Indicator metadata for 'hma' not found, skip rendering`),null)}function xd(e={}){let{paneId:t=`main`}=e,n=null;function r(){return bd(n,t)}return{name:`hma_${t}`,version:`1.1.0`,description:`HMA Hull 移动均线渲染器(WebGL + Canvas2D 回退)`,debugName:`HMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showHMA||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=Math.min(a.end,d.length),p=a.start,m=[];for(let e=a.start;e<f;e++){let t=d[e];if(t===void 0)continue;let n=s[e-p];n!==void 0&&m.push({x:n,y:i.yAxis.priceToY(t)})}if(m.length<2)return;let h=e.settings?.enableWebGLRendering!==!1,g=!1;if(h&&c?.isAvailable()&&c.drawLineStrips([{points:m,width:1,color:yd}],o)&&(g=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!g){t.save(),t.translate(-o,0),t.strokeStyle=yd,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(m[0].x,m[0].y);for(let e=1;e<m.length;e++)t.lineTo(m[e].x,m[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Sd;new class extends vd{static[class{static{[Sd,fd]=pd(this,[q({name:`hma`,displayName:`HMA`,category:`main`,stateKey:Ta,defaultPaneId:`main`,paneIdField:`hmaPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(Ta(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=xd;constructor(){super(Sd),fd()}};var Cd;function wd(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Dd(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Dd(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Td(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Od(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Td(e){var t=Ed(e,`string`);return typeof t==`symbol`?t:t+``}function Ed(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Dd(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Od(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function kd(e){return e}var Ad=`#0ea5e9`;function jd(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[KAMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`kama`);return r?Y(r.stateKey,t):(console.warn(`[KAMARenderer] Indicator metadata for 'kama' not found, skip rendering`),null)}function Md(e={}){let{paneId:t=`main`}=e,n=null;function r(){return jd(n,t)}return{name:`kama_${t}`,version:`1.1.0`,description:`KAMA Kaufman 自适应均线渲染器(WebGL + Canvas2D 回退)`,debugName:`KAMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showKAMA||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=Math.min(a.end,d.length),p=a.start,m=[];for(let e=a.start;e<f;e++){let t=d[e];if(t===void 0)continue;let n=s[e-p];n!==void 0&&m.push({x:n,y:i.yAxis.priceToY(t)})}if(m.length<2)return;let h=e.settings?.enableWebGLRendering!==!1,g=!1;if(h&&c?.isAvailable()&&c.drawLineStrips([{points:m,width:1,color:Ad}],o)&&(g=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!g){t.save(),t.translate(-o,0),t.strokeStyle=Ad,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(m[0].x,m[0].y);for(let e=1;e<m.length;e++)t.lineTo(m[e].x,m[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Nd;new class extends kd{static[class{static{[Nd,Cd]=wd(this,[q({name:`kama`,displayName:`KAMA`,category:`main`,stateKey:Da,defaultPaneId:`main`,paneIdField:`kamaPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(Da(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Md;constructor(){super(Nd),Cd()}};var Pd;function Fd(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Rd(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Rd(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Id(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return zd(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Id(e){var t=Ld(e,`string`);return typeof t==`symbol`?t:t+``}function Ld(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Rd(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function zd(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Bd(e){return e}var Vd=`#22c55e`,Hd=`#ef4444`,Ud=1.5,Wd=Math.PI*2;function Gd(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[SARRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`sar`);return r?Y(r.stateKey,t):(console.warn(`[SARRenderer] Indicator metadata for 'sar' not found, skip rendering`),null)}function Kd(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Gd(n,t)}return{name:`sar_${t}`,version:`1.0.0`,description:`Parabolic SAR 渲染器(绿色 = 多头止损 / 红色 = 空头止损)`,debugName:`SAR`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s}=e,c=r();if(!c)return;let l=n?.getSharedState(c);if(!l||!l.params.showSAR||l.visibleMin>l.visibleMax)return;let{series:u}=l;t.save(),t.translate(-o,0);let d=Math.min(a.end,u.length);for(let e=a.start;e<d;e++){let n=u[e];if(n===void 0)continue;let r=s[e-a.start];if(r===void 0)continue;let o=i.yAxis.priceToY(n.value);t.fillStyle=n.trend===`up`?Vd:Hd,t.beginPath(),t.arc(r,o,Ud,0,Wd),t.fill()}t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var qd;new class extends Bd{static[class{static{[qd,Pd]=Fd(this,[q({name:`sar`,displayName:`SAR`,category:`main`,stateKey:ka,defaultPaneId:`main`,paneIdField:`sarPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(ka(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Kd;constructor(){super(qd),Pd()}};var Jd;function Yd(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Qd(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Qd(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Xd(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return $d(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Xd(e){var t=Zd(e,`string`);return typeof t==`symbol`?t:t+``}function Zd(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qd(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function $d(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function ef(e){return e}var tf=`#22c55e`,nf=`#ef4444`;function rf(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[SuperTrendRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`supertrend`);return r?Y(r.stateKey,t):(console.warn(`[SuperTrendRenderer] Indicator metadata for 'supertrend' not found, skip rendering`),null)}function af(e={}){let{paneId:t=`sub_SuperTrend`}=e,n=null;function r(){return rf(n,t)}return{name:`supertrend_${t}`,version:`1.0.0`,description:`SuperTrend ATR 趋势带渲染器(趋势翻转处颜色切换)`,debugName:`SuperTrend`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s}=e,c=r();if(!c)return;let l=n?.getSharedState(c);if(!l||!l.params.showSuperTrend||l.visibleMin>l.visibleMax)return;let{series:u}=l;t.save(),t.translate(-o,0),t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`;let d=Math.min(a.end,u.length),f=null,p=null,m=null;for(let e=a.start;e<d;e++){let n=u[e];if(n===void 0)continue;let r=s[e-a.start];if(r===void 0)continue;let o=i.yAxis.priceToY(n.value);f!==null&&m===n.trend&&(t.strokeStyle=n.trend===`up`?tf:nf,t.beginPath(),t.moveTo(f,p),t.lineTo(r,o),t.stroke()),f=r,p=o,m=n.trend}t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var of;new class extends ef{static[class{static{[of,Jd]=Yd(this,[q({name:`supertrend`,displayName:`SuperTrend`,category:`oscillator`,stateKey:Na,defaultPaneId:`sub_SuperTrend`,paneIdField:`supertrendPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(Na(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=af;constructor(){super(of),Jd()}};var sf;function cf(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:df(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||df(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:lf(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return ff(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function lf(e){var t=uf(e,`string`);return typeof t==`symbol`?t:t+``}function uf(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function df(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function ff(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function pf(e){return e}var mf=`#7c3aed`,hf=`#f59e0b`,gf=`#7c3aed`;function _f(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[KeltnerRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`keltner`);return r?Y(r.stateKey,t):(console.warn(`[KeltnerRenderer] Indicator metadata for 'keltner' not found, skip rendering`),null)}function vf(e={}){let{paneId:t=`main`}=e,n=null;function r(){return _f(n,t)}return{name:`keltner_${t}`,version:`1.1.0`,description:`Keltner Channel 渲染器(WebGL + Canvas2D 回退)`,debugName:`Keltner`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||u.visibleMin>u.visibleMax)return;let{showUpper:d,showMiddle:f,showLower:p}=u.params;if(!d&&!f&&!p)return;let{series:m}=u,h=e=>i.yAxis.priceToY(e),g=a.start,_=[],v=[],y=[],b=Math.min(a.end,m.length);for(let e=a.start;e<b;e++){let t=m[e];if(!t)continue;let n=s[e-g];n!==void 0&&(d&&_.push({x:n,y:h(t.upper)}),f&&v.push({x:n,y:h(t.middle)}),p&&y.push({x:n,y:h(t.lower)}))}let x=[];_.length>=2&&x.push({points:_,width:1,color:mf}),v.length>=2&&x.push({points:v,width:1,color:hf}),y.length>=2&&x.push({points:y,width:1,color:gf});let S=e.settings?.enableWebGLRendering!==!1,C=!1;S&&c?.isAvailable()&&x.length>0&&c.drawLineStrips(x,o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C&&(t.save(),t.translate(-o,0),t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,yf(t,_,mf),yf(t,v,hf),yf(t,y,gf),t.restore())},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function yf(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}var bf;new class extends pf{static[class{static{[bf,sf]=cf(this,[q({name:`keltner`,displayName:`Keltner`,category:`main`,stateKey:Fa,defaultPaneId:`main`,paneIdField:`keltnerPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(Fa(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=vf;constructor(){super(bf),sf()}};var xf;function Sf(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Tf(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Tf(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Cf(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Ef(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Cf(e){var t=wf(e,`string`);return typeof t==`symbol`?t:t+``}function wf(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Tf(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Ef(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Df(e){return e}var Of=`#0891b2`,kf=`#94a3b8`,Af=`#0891b2`;function jf(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[DonchianRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`donchian`);return r?Y(r.stateKey,t):(console.warn(`[DonchianRenderer] Indicator metadata for 'donchian' not found, skip rendering`),null)}function Mf(e={}){let{paneId:t=`main`}=e,n=null;function r(){return jf(n,t)}return{name:`donchian_${t}`,version:`1.1.0`,description:`Donchian Channel 渲染器(WebGL + Canvas2D 回退)`,debugName:`Donchian`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||u.visibleMin>u.visibleMax)return;let{showUpper:d,showMiddle:f,showLower:p}=u.params;if(!d&&!f&&!p)return;let{series:m}=u,h=e=>i.yAxis.priceToY(e),g=a.start,_=[],v=[],y=[],b=Math.min(a.end,m.length);for(let e=a.start;e<b;e++){let t=m[e];if(!t)continue;let n=s[e-g];n!==void 0&&(d&&_.push({x:n,y:h(t.upper)}),f&&v.push({x:n,y:h(t.middle)}),p&&y.push({x:n,y:h(t.lower)}))}let x=[];_.length>=2&&x.push({points:_,width:1,color:Of}),v.length>=2&&x.push({points:v,width:1,color:kf}),y.length>=2&&x.push({points:y,width:1,color:Af});let S=e.settings?.enableWebGLRendering!==!1,C=!1;S&&c?.isAvailable()&&x.length>0&&c.drawLineStrips(x,o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C&&(t.save(),t.translate(-o,0),t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,Nf(t,_,Of),Nf(t,v,kf),Nf(t,y,Af),t.restore())},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Nf(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}var Pf;new class extends Df{static[class{static{[Pf,xf]=Sf(this,[q({name:`donchian`,displayName:`Donchian`,category:`main`,stateKey:La,defaultPaneId:`main`,paneIdField:`donchianPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(La(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Mf;constructor(){super(Pf),xf()}};var Ff;function If(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:zf(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||zf(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Lf(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Bf(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Lf(e){var t=Rf(e,`string`);return typeof t==`symbol`?t:t+``}function Rf(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zf(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Bf(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Vf(e){return e}var Hf=`#dc2626`,Uf=`#2563eb`,Wf=`#16a34a`,Gf=`#dc2626`,Kf=`#7c3aed`,qf=`rgba(34, 197, 94, 0.15)`,Jf=`rgba(239, 68, 68, 0.15)`;function Yf(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[IchimokuRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`ichimoku`);return r?Y(r.stateKey,t):(console.warn(`[IchimokuRenderer] Indicator metadata for 'ichimoku' not found, skip rendering`),null)}function Xf(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Yf(n,t)}return{name:`ichimoku_${t}`,version:`1.1.0`,description:`一目均衡表渲染器(WebGL 线 + Canvas2D 云图)`,debugName:`Ichimoku`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||u.visibleMin>u.visibleMax)return;let{params:d,series:f}=u,p=e=>i.yAxis.priceToY(e),m=a.start,h=[],g=[],_=[],v=[],y=[],b=[],x=Math.min(a.end,f.length);for(let e=a.start;e<x;e++){let t=f[e];if(!t)continue;let n=s[e-m];n!==void 0&&(d.showTenkan&&t.tenkan!==void 0&&h.push({x:n,y:p(t.tenkan)}),d.showKijun&&t.kijun!==void 0&&g.push({x:n,y:p(t.kijun)}),d.showSpanA&&t.spanA!==void 0&&_.push({x:n,y:p(t.spanA)}),d.showSpanB&&t.spanB!==void 0&&v.push({x:n,y:p(t.spanB)}),d.showChikou&&t.chikou!==void 0&&y.push({x:n,y:p(t.chikou)}),d.showCloud&&t.spanA!==void 0&&t.spanB!==void 0&&b.push({x:n,ya:p(t.spanA),yb:p(t.spanB),bull:t.spanA>t.spanB}))}d.showCloud&&b.length>=2&&(t.save(),t.translate(-o,0),Qf(t,b),t.restore());let S=[];h.length>=2&&S.push({points:h,width:1,color:Hf}),g.length>=2&&S.push({points:g,width:1,color:Uf}),_.length>=2&&S.push({points:_,width:1,color:Wf}),v.length>=2&&S.push({points:v,width:1,color:Gf}),y.length>=2&&S.push({points:y,width:1,color:Kf});let C=e.settings?.enableWebGLRendering!==!1,w=!1;C&&c?.isAvailable()&&S.length>0&&c.drawLineStrips(S,o)&&(w=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!w&&(t.save(),t.translate(-o,0),t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,Zf(t,h,Hf),Zf(t,g,Uf),Zf(t,_,Wf),Zf(t,v,Gf),Zf(t,y,Kf),t.restore())},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Zf(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}function Qf(e,t){for(let n=0;n<t.length-1;n++){let r=t[n],i=t[n+1];e.fillStyle=r.bull?qf:Jf,e.beginPath(),e.moveTo(r.x,r.ya),e.lineTo(i.x,i.ya),e.lineTo(i.x,i.yb),e.lineTo(r.x,r.yb),e.closePath(),e.fill()}}var $f;new class extends Vf{static[class{static{[$f,Ff]=If(this,[q({name:`ichimoku`,displayName:`Ichimoku`,category:`main`,stateKey:za,defaultPaneId:`main`,paneIdField:`ichimokuPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(za(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Xf;constructor(){super($f),Ff()}};var ep;function tp(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ip(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ip(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:np(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return ap(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function np(e){var t=rp(e,`string`);return typeof t==`symbol`?t:t+``}function rp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ip(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function ap(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function op(e){return e}var sp=`#0ea5e9`;function cp(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[ROCRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`roc`);return r?Y(r.stateKey,t):(console.warn(`[ROCRenderer] Indicator metadata for 'roc' not found, skip rendering`),null)}function lp(e={}){let{paneId:t=`sub_ROC`}=e,n=null;function r(){return cp(n,t)}return{name:`roc_${t}`,version:`1.1.0`,description:`ROC 变化率渲染器(WebGL + Canvas2D 回退)`,debugName:`ROC`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showROC||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=_-(0-h)*v;t.save(),t.translate(-o,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(o,b),t.lineTo(o+e.paneWidth,b),t.stroke(),t.setLineDash([]),t.restore();let x=Math.min(a.end,p.length),S=[];for(let e=a.start;e<x;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&S.push({x:n,y:_-(t-h)*v})}if(S.length<2)return;let C=e.settings?.enableWebGLRendering!==!1,w=!1;if(C&&c?.isAvailable()&&c.drawLineStrips([{points:S,width:1,color:sp}],o)&&(w=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!w){t.save(),t.translate(-o,0),t.strokeStyle=sp,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let e=1;e<S.length;e++)t.lineTo(S[e].x,S[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var up;new class extends op{static[class{static{[up,ep]=tp(this,[q({name:`roc`,displayName:`ROC`,category:`oscillator`,stateKey:Va,defaultPaneId:`sub_ROC`,paneIdField:`rocPaneId`,applyResult:(e,t,n)=>{e.setSharedState(Va(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=lp;constructor(){super(up),ep()}};var dp;function fp(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:hp(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||hp(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:pp(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return gp(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function pp(e){var t=mp(e,`string`);return typeof t==`symbol`?t:t+``}function mp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function hp(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function gp(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function _p(e){return e}var vp=`#e11d48`,yp=`#f59e0b`;function bp(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[TRIXRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`trix`);return r?Y(r.stateKey,t):(console.warn(`[TRIXRenderer] Indicator metadata for 'trix' not found, skip rendering`),null)}function xp(e={}){let{paneId:t=`sub_TRIX`}=e,n=null;function r(){return bp(n,t)}return{name:`trix_${t}`,version:`1.1.0`,description:`TRIX 三重指数平滑振荡器渲染器(WebGL + Canvas2D 回退)`,debugName:`TRIX`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||u.visibleMin>u.visibleMax)return;let{showTRIX:d,showSignal:f}=u.params;if(!d&&!f)return;let{valueMin:p,valueMax:m,series:h,signalSeries:g}=u,_=i.yAxis.getDisplayRange({minPrice:p,maxPrice:m}),v=_.minPrice,y=_.maxPrice-v||1,b=i.height,x=b/y,S=a.start,C=e=>b-(e-v)*x,w=C(0);t.save(),t.translate(-o,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(o,w),t.lineTo(o+e.paneWidth,w),t.stroke(),t.setLineDash([]),t.restore();let T=[],E=[],D=Math.min(a.end,h.length);for(let e=a.start;e<D;e++){let t=s[e-S];if(t!==void 0){if(d){let n=h[e];n!==void 0&&T.push({x:t,y:C(n)})}if(f){let n=g[e];n!==void 0&&E.push({x:t,y:C(n)})}}}if(T.length<2&&E.length<2)return;let O=[];T.length>=2&&O.push({points:T,width:1,color:vp}),E.length>=2&&O.push({points:E,width:1,color:yp});let k=e.settings?.enableWebGLRendering!==!1,A=!1;k&&c?.isAvailable()&&O.length>0&&c.drawLineStrips(O,o)&&(A=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!A&&(t.save(),t.translate(-o,0),t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,Sp(t,T,vp),Sp(t,E,yp),t.restore())},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Sp(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}var Cp;new class extends _p{static[class{static{[Cp,dp]=fp(this,[q({name:`trix`,displayName:`TRIX`,category:`oscillator`,stateKey:Ua,defaultPaneId:`sub_TRIX`,paneIdField:`trixPaneId`,applyResult:(e,t,n)=>{e.setSharedState(Ua(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=xp;constructor(){super(Cp),dp()}};var wp;function Tp(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Op(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Op(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Ep(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return kp(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Ep(e){var t=Dp(e,`string`);return typeof t==`symbol`?t:t+``}function Dp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Op(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function kp(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Ap(e){return e}var jp=`#7c3aed`;function Mp(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[HVRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`hv`);return r?Y(r.stateKey,t):(console.warn(`[HVRenderer] Indicator metadata for 'hv' not found, skip rendering`),null)}function Np(e={}){let{paneId:t=`sub_HV`}=e,n=null;function r(){return Mp(n,t)}return{name:`hv_${t}`,version:`1.1.0`,description:`HV 历史波动率渲染器(WebGL + Canvas2D 回退)`,debugName:`HV`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showHV||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:jp}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=jp,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Pp;new class extends Ap{static[class{static{[Pp,wp]=Tp(this,[q({name:`hv`,displayName:`HV`,category:`oscillator`,stateKey:Ga,defaultPaneId:`sub_HV`,paneIdField:`hvPaneId`,applyResult:(e,t,n)=>{e.setSharedState(Ga(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Np;constructor(){super(Pp),wp()}};var Fp;function Ip(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:zp(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||zp(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Lp(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Bp(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Lp(e){var t=Rp(e,`string`);return typeof t==`symbol`?t:t+``}function Rp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zp(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Bp(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Vp(e){return e}var Hp=`#0891b2`;function Up(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[ParkinsonRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`parkinson`);return r?Y(r.stateKey,t):(console.warn(`[ParkinsonRenderer] Indicator metadata for 'parkinson' not found, skip rendering`),null)}function Wp(e={}){let{paneId:t=`sub_Parkinson`}=e,n=null;function r(){return Up(n,t)}return{name:`parkinson_${t}`,version:`1.1.0`,description:`Parkinson 波动率渲染器(WebGL + Canvas2D 回退)`,debugName:`Parkinson`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showParkinson||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:Hp}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=Hp,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Gp;new class extends Vp{static[class{static{[Gp,Fp]=Ip(this,[q({name:`parkinson`,displayName:`Parkinson`,category:`oscillator`,stateKey:qa,defaultPaneId:`sub_Parkinson`,paneIdField:`parkinsonPaneId`,applyResult:(e,t,n)=>{e.setSharedState(qa(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Wp;constructor(){super(Gp),Fp()}};var Kp;function qp(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Xp(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Xp(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Jp(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Zp(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Jp(e){var t=Yp(e,`string`);return typeof t==`symbol`?t:t+``}function Yp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Xp(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Zp(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Qp(e){return e}var $p=`#f59e0b`;function em(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[ChaikinVolRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`chaikinVol`);return r?Y(r.stateKey,t):(console.warn(`[ChaikinVolRenderer] Indicator metadata for 'chaikinVol' not found, skip rendering`),null)}function tm(e={}){let{paneId:t=`sub_ChaikinVol`}=e,n=null;function r(){return em(n,t)}return{name:`chaikinVol_${t}`,version:`1.1.0`,description:`Chaikin Volatility 渲染器(WebGL + Canvas2D 回退)`,debugName:`ChaikinVol`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showChaikinVol||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=_-(0-h)*v;t.save(),t.translate(-o,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(o,b),t.lineTo(o+e.paneWidth,b),t.stroke(),t.setLineDash([]),t.restore();let x=Math.min(a.end,p.length),S=[];for(let e=a.start;e<x;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&S.push({x:n,y:_-(t-h)*v})}if(S.length<2)return;let C=e.settings?.enableWebGLRendering!==!1,w=!1;if(C&&c?.isAvailable()&&c.drawLineStrips([{points:S,width:1,color:$p}],o)&&(w=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!w){t.save(),t.translate(-o,0),t.strokeStyle=$p,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let e=1;e<S.length;e++)t.lineTo(S[e].x,S[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var nm;new class extends Qp{static[class{static{[nm,Kp]=qp(this,[q({name:`chaikinVol`,displayName:`ChaikinVol`,category:`oscillator`,stateKey:Ya,defaultPaneId:`sub_ChaikinVol`,paneIdField:`chaikinVolPaneId`,applyResult:(e,t,n)=>{e.setSharedState(Ya(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=tm;constructor(){super(nm),Kp()}};var rm;function im(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:sm(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||sm(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:am(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return cm(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function am(e){var t=om(e,`string`);return typeof t==`symbol`?t:t+``}function om(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function sm(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function cm(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function lm(e){return e}var um=`#0ea5e9`;function dm(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[VMARenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`vma`);return r?Y(r.stateKey,t):(console.warn(`[VMARenderer] Indicator metadata for 'vma' not found, skip rendering`),null)}function fm(e={}){let{paneId:t=`sub_VMA`}=e,n=null;function r(){return dm(n,t)}return{name:`vma_${t}`,version:`1.1.0`,description:`VMA 成交量均线渲染器(WebGL + Canvas2D 回退)`,debugName:`VMA`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showVMA||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:um}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=um,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var pm;new class extends lm{static[class{static{[pm,rm]=im(this,[q({name:`vma`,displayName:`VMA`,category:`volume`,stateKey:Za,defaultPaneId:`sub_VMA`,paneIdField:`vmaPaneId`,applyResult:(e,t,n)=>{e.setSharedState(Za(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=fm;constructor(){super(pm),rm()}};var mm;function hm(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:vm(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||vm(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:gm(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return ym(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function gm(e){var t=_m(e,`string`);return typeof t==`symbol`?t:t+``}function _m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vm(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function ym(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function bm(e){return e}var xm=`#16a34a`;function Sm(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[OBVRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`obv`);return r?Y(r.stateKey,t):(console.warn(`[OBVRenderer] Indicator metadata for 'obv' not found, skip rendering`),null)}function Cm(e={}){let{paneId:t=`sub_OBV`}=e,n=null;function r(){return Sm(n,t)}return{name:`obv_${t}`,version:`1.1.0`,description:`OBV 能量潮渲染器(WebGL + Canvas2D 回退)`,debugName:`OBV`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showOBV||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:xm}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=xm,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var wm;new class extends bm{static[class{static{[wm,mm]=hm(this,[q({name:`obv`,displayName:`OBV`,category:`volume`,stateKey:$a,defaultPaneId:`sub_OBV`,paneIdField:`obvPaneId`,applyResult:(e,t,n)=>{e.setSharedState($a(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Cm;constructor(){super(wm),mm()}};var Tm;function Em(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:km(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||km(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Dm(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Am(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Dm(e){var t=Om(e,`string`);return typeof t==`symbol`?t:t+``}function Om(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function km(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Am(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function jm(e){return e}var Mm=`#a855f7`;function Nm(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[PVTRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`pvt`);return r?Y(r.stateKey,t):(console.warn(`[PVTRenderer] Indicator metadata for 'pvt' not found, skip rendering`),null)}function Pm(e={}){let{paneId:t=`sub_PVT`}=e,n=null;function r(){return Nm(n,t)}return{name:`pvt_${t}`,version:`1.1.0`,description:`PVT 量价趋势渲染器(WebGL + Canvas2D 回退)`,debugName:`PVT`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showPVT||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:Mm}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=Mm,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Fm;new class extends jm{static[class{static{[Fm,Tm]=Em(this,[q({name:`pvt`,displayName:`PVT`,category:`volume`,stateKey:to,defaultPaneId:`sub_PVT`,paneIdField:`pvtPaneId`,applyResult:(e,t,n)=>{e.setSharedState(to(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Pm;constructor(){super(Fm),Tm()}};var Im;function Lm(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Bm(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Bm(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Rm(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Vm(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Rm(e){var t=zm(e,`string`);return typeof t==`symbol`?t:t+``}function zm(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Bm(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Vm(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Hm(e){return e}var Um=`#ec4899`;function Wm(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[VWAPRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`vwap`);return r?Y(r.stateKey,t):(console.warn(`[VWAPRenderer] Indicator metadata for 'vwap' not found, skip rendering`),null)}function Gm(e={}){let{paneId:t=`sub_VWAP`}=e,n=null;function r(){return Wm(n,t)}return{name:`vwap_${t}`,version:`1.1.0`,description:`VWAP 成交量加权均价渲染器(WebGL + Canvas2D 回退)`,debugName:`VWAP`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showVWAP||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=Math.min(a.end,p.length),x=[];for(let e=a.start;e<b;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&x.push({x:n,y:_-(t-h)*v})}if(x.length<2)return;let S=e.settings?.enableWebGLRendering!==!1,C=!1;if(S&&c?.isAvailable()&&c.drawLineStrips([{points:x,width:1,color:Um}],o)&&(C=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!C){t.save(),t.translate(-o,0),t.strokeStyle=Um,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(x[0].x,x[0].y);for(let e=1;e<x.length;e++)t.lineTo(x[e].x,x[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Km;new class extends Hm{static[class{static{[Km,Im]=Lm(this,[q({name:`vwap`,displayName:`VWAP`,category:`volume`,stateKey:ro,defaultPaneId:`sub_VWAP`,paneIdField:`vwapPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ro(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Gm;constructor(){super(Km),Im()}};var qm;function Jm(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Zm(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Zm(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Ym(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Qm(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Ym(e){var t=Xm(e,`string`);return typeof t==`symbol`?t:t+``}function Xm(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Zm(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Qm(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function $m(e){return e}var eh=`#06b6d4`;function th(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[CMFRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`cmf`);return r?Y(r.stateKey,t):(console.warn(`[CMFRenderer] Indicator metadata for 'cmf' not found, skip rendering`),null)}function nh(e={}){let{paneId:t=`sub_CMF`}=e,n=null;function r(){return th(n,t)}return{name:`cmf_${t}`,version:`1.1.0`,description:`CMF Chaikin 资金流渲染器(WebGL + Canvas2D 回退)`,debugName:`CMF`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showCMF||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=_-(0-h)*v;t.save(),t.translate(-o,0),t.strokeStyle=`rgba(0, 0, 0, 0.1)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(o,b),t.lineTo(o+e.paneWidth,b),t.stroke(),t.setLineDash([]),t.restore();let x=Math.min(a.end,p.length),S=[];for(let e=a.start;e<x;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&S.push({x:n,y:_-(t-h)*v})}if(S.length<2)return;let C=e.settings?.enableWebGLRendering!==!1,w=!1;if(C&&c?.isAvailable()&&c.drawLineStrips([{points:S,width:1,color:eh}],o)&&(w=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!w){t.save(),t.translate(-o,0),t.strokeStyle=eh,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let e=1;e<S.length;e++)t.lineTo(S[e].x,S[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var rh;new class extends $m{static[class{static{[rh,qm]=Jm(this,[q({name:`cmf`,displayName:`CMF`,category:`volume`,stateKey:ao,defaultPaneId:`sub_CMF`,paneIdField:`cmfPaneId`,applyResult:(e,t,n)=>{e.setSharedState(ao(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=nh;constructor(){super(rh),qm()}};var ih;function ah(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ch(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ch(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:oh(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return lh(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function oh(e){var t=sh(e,`string`);return typeof t==`symbol`?t:t+``}function sh(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ch(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function lh(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function uh(e){return e}var dh=`#fb923c`;function fh(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[MFIRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`mfi`);return r?Y(r.stateKey,t):(console.warn(`[MFIRenderer] Indicator metadata for 'mfi' not found, skip rendering`),null)}function ph(e={}){let{paneId:t=`sub_MFI`}=e,n=null;function r(){return fh(n,t)}return{name:`mfi_${t}`,version:`1.1.0`,description:`MFI 资金流强弱渲染器(WebGL + Canvas2D 回退,80/20 超买超卖线)`,debugName:`MFI`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showMFI||u.visibleMin>u.visibleMax)return;let{valueMin:d,valueMax:f,series:p}=u,m=i.yAxis.getDisplayRange({minPrice:d,maxPrice:f}),h=m.minPrice,g=m.maxPrice-h||1,_=i.height,v=_/g,y=a.start,b=e=>_-(e-h)*v;t.save(),t.translate(-o,0),t.strokeStyle=`rgba(239, 68, 68, 0.3)`,t.lineWidth=1,t.setLineDash([4,4]),t.beginPath(),t.moveTo(o,b(80)),t.lineTo(o+e.paneWidth,b(80)),t.stroke(),t.strokeStyle=`rgba(34, 197, 94, 0.3)`,t.beginPath(),t.moveTo(o,b(20)),t.lineTo(o+e.paneWidth,b(20)),t.stroke(),t.setLineDash([]),t.restore();let x=Math.min(a.end,p.length),S=[];for(let e=a.start;e<x;e++){let t=p[e];if(t===void 0)continue;let n=s[e-y];n!==void 0&&S.push({x:n,y:b(t)})}if(S.length<2)return;let C=e.settings?.enableWebGLRendering!==!1,w=!1;if(C&&c?.isAvailable()&&c.drawLineStrips([{points:S,width:1,color:dh}],o)&&(w=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!w){t.save(),t.translate(-o,0),t.strokeStyle=dh,t.lineWidth=1,t.lineJoin=`round`,t.lineCap=`round`,t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let e=1;e<S.length;e++)t.lineTo(S[e].x,S[e].y);t.stroke(),t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var mh;new class extends uh{static[class{static{[mh,ih]=ah(this,[q({name:`mfi`,displayName:`MFI`,category:`volume`,stateKey:so,defaultPaneId:`sub_MFI`,paneIdField:`mfiPaneId`,applyResult:(e,t,n)=>{e.setSharedState(so(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=ph;constructor(){super(mh),ih()}};var hh;function gh(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:yh(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||yh(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:_h(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return bh(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function _h(e){var t=vh(e,`string`);return typeof t==`symbol`?t:t+``}function vh(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function yh(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function bh(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function xh(e){return e}var Sh=`#94a3b8`,Ch=`#dc2626`,wh=`#16a34a`;function Th(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[PivotRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`pivot`);return r?Y(r.stateKey,t):(console.warn(`[PivotRenderer] Indicator metadata for 'pivot' not found, skip rendering`),null)}function Eh(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Th(n,t)}return{name:`pivot_${t}`,version:`1.0.0`,description:`Pivot Points 枢轴点渲染器(PP/R1-3/S1-3 阶梯线)`,debugName:`Pivot`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s}=e,c=r();if(!c)return;let l=n?.getSharedState(c);if(!l||l.visibleMin>l.visibleMax)return;let u=l.params;if(!(u.showPP||u.showR1||u.showR2||u.showR3||u.showS1||u.showS2||u.showS3))return;let{series:d}=l,f=e=>i.yAxis.priceToY(e),p=Math.min(a.end,d.length),m=[],h=[],g=[],_=[],v=[],y=[],b=[];for(let e=a.start;e<p;e++){let t=d[e];if(!t)continue;let n=s[e-a.start];n!==void 0&&(u.showPP&&m.push({x:n,y:f(t.pp)}),u.showR1&&h.push({x:n,y:f(t.r1)}),u.showR2&&g.push({x:n,y:f(t.r2)}),u.showR3&&_.push({x:n,y:f(t.r3)}),u.showS1&&v.push({x:n,y:f(t.s1)}),u.showS2&&y.push({x:n,y:f(t.s2)}),u.showS3&&b.push({x:n,y:f(t.s3)}))}t.save(),t.translate(-o,0),t.lineWidth=1,Dh(t,m,Sh),Dh(t,h,Ch),Dh(t,g,Ch),Dh(t,_,Ch),Dh(t,v,wh),Dh(t,y,wh),Dh(t,b,wh),t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function Dh(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n-1].y),e.lineTo(t[n].x,t[n].y);e.stroke()}}var Oh;new class extends xh{static[class{static{[Oh,hh]=gh(this,[q({name:`pivot`,displayName:`Pivot`,category:`main`,stateKey:lo,defaultPaneId:`main`,paneIdField:`pivotPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(lo(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Eh;constructor(){super(Oh),hh()}};var kh;function Ah(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Nh(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Nh(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:jh(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Ph(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function jh(e){var t=Mh(e,`string`);return typeof t==`symbol`?t:t+``}function Mh(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Nh(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Ph(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function Fh(e){return e}var Ih={high:`#94a3b8`,low:`#94a3b8`,l236:`#fbbf24`,l382:`#f59e0b`,l500:`#d97706`,l618:`#dc2626`,l786:`#7c2d12`};function Lh(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[FibRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`fib`);return r?Y(r.stateKey,t):(console.warn(`[FibRenderer] Indicator metadata for 'fib' not found, skip rendering`),null)}function Rh(e={}){let{paneId:t=`main`}=e,n=null;function r(){return Lh(n,t)}return{name:`fib_${t}`,version:`1.1.0`,description:`斐波那契回撤线渲染器(WebGL + Canvas2D 回退)`,debugName:`Fib`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s,lineWebGLSurface:c}=e,l=r();if(!l)return;let u=n?.getSharedState(l);if(!u||!u.params.showLevels||u.visibleMin>u.visibleMax)return;let{series:d}=u,f=e=>i.yAxis.priceToY(e),p=a.start,m={high:[],low:[],l236:[],l382:[],l500:[],l618:[],l786:[]},h=Math.min(a.end,d.length);for(let e=a.start;e<h;e++){let t=d[e];if(!t)continue;let n=s[e-p];n!==void 0&&(m.high.push({x:n,y:f(t.high)}),m.low.push({x:n,y:f(t.low)}),m.l236.push({x:n,y:f(t.level236)}),m.l382.push({x:n,y:f(t.level382)}),m.l500.push({x:n,y:f(t.level500)}),m.l618.push({x:n,y:f(t.level618)}),m.l786.push({x:n,y:f(t.level786)}))}let g=[];for(let[e,t]of Object.entries(m))t.length>=2&&g.push({points:t,width:1,color:Ih[e]});let _=e.settings?.enableWebGLRendering!==!1,v=!1;if(_&&c?.isAvailable()&&g.length>0&&c.drawLineStrips(g,o)&&(v=!0,c.compositeTo(t,{imageSmoothingEnabled:!1})),!v){t.save(),t.translate(-o,0),t.lineWidth=1;for(let[e,n]of Object.entries(m))zh(t,n,Ih[e]);t.restore()}},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}function zh(e,t,n){if(!(t.length<2)){e.strokeStyle=n,e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}var Bh;new class extends Fh{static[class{static{[Bh,kh]=Ah(this,[q({name:`fib`,displayName:`Fib`,category:`main`,stateKey:fo,defaultPaneId:`main`,paneIdField:`fibPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(fo(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Rh;constructor(){super(Bh),kh()}};var Vh;function Hh(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:Gh(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||Gh(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:Uh(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return Kh(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function Uh(e){var t=Wh(e,`string`);return typeof t==`symbol`?t:t+``}function Wh(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Gh(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function Kh(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function qh(e){return e}var Jh=`11px sans-serif`;function Yh(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[StructureRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`structure`);return r?Y(r.stateKey,t):(console.warn(`[StructureRenderer] Indicator metadata for 'structure' not found, skip rendering`),null)}function Xh(e={}){let{paneId:t=`sub_Structure`}=e,n=null;function r(){return Yh(n,t)}return{name:`structure_${t}`,version:`1.0.0`,description:`SMC 结构渲染器(swing 标签 + BOS/CHOCH 触发线)`,debugName:`Structure`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s}=e,c=V(e.theme),l=r();if(!l)return;let u=n?.getSharedState(l);if(!u)return;let d=u.params,{swings:f,events:p}=u.series;if(!d.showSwingLabels&&!d.showBOS&&!d.showCHOCH)return;let m=e=>i.yAxis.priceToY(e);if(t.save(),t.translate(-o,0),t.font=Jh,t.textAlign=`center`,d.showSwingLabels)for(let e of f){if(e.index<a.start||e.index>=a.end||!e.confirmed&&!d.showProvisional)continue;let n=s[e.index-a.start];if(n===void 0)continue;let r=m(e.price);t.fillStyle=e.label===`HH`?c.STRUCTURE.HH:e.label===`HL`?c.STRUCTURE.HL:e.label===`LH`?c.STRUCTURE.LH:c.STRUCTURE.LL;let i=e.kind===`high`?r-8:r+16;t.fillText(e.label,n,i),t.beginPath(),t.arc(n,r,2,0,Math.PI*2),t.fill()}if(d.showBOS||d.showCHOCH){t.lineWidth=1,t.setLineDash([4,4]);for(let e of p){if(e.kind===`BOS`&&!d.showBOS||e.kind===`CHOCH`&&!d.showCHOCH||e.index<a.start||e.index>=a.end||e.brokenSwingIndex<a.start)continue;let n=s[e.brokenSwingIndex-a.start],r=s[e.index-a.start];if(n===void 0||r===void 0)continue;let i=m(e.brokenLevel);t.strokeStyle=e.kind===`BOS`?c.STRUCTURE.BOS:c.STRUCTURE.CHOCH,t.beginPath(),t.moveTo(n,i),t.lineTo(r,i),t.stroke(),t.fillStyle=e.kind===`BOS`?c.STRUCTURE.BOS:c.STRUCTURE.CHOCH,t.fillText(e.kind,(n+r)/2,i-4)}t.setLineDash([])}t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var Zh;new class extends qh{static[class{static{[Zh,Vh]=Hh(this,[q({name:`structure`,displayName:`Structure`,category:`sub`,stateKey:mo,defaultPaneId:`sub_Structure`,paneIdField:`structurePaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(mo(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=Xh;constructor(){super(Zh),Vh()}};var Qh;function $h(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:ng(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||ng(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:eg(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return rg(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function eg(e){var t=tg(e,`string`);return typeof t==`symbol`?t:t+``}function tg(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ng(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function rg(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function ig(e){return e}function ag(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[ZonesRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`zones`);return r?Y(r.stateKey,t):(console.warn(`[ZonesRenderer] Indicator metadata for 'zones' not found, skip rendering`),null)}function og(e={}){let{paneId:t=`main`}=e,n=null;function r(){return ag(n,t)}return{name:`zones_${t}`,version:`1.0.0`,description:`SMC 区域渲染器(FVG 缺口 + Order Blocks 订单块)`,debugName:`Zones`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,range:a,scrollLeft:o,kLineCenters:s}=e,c=V(e.theme),l=r();if(!l)return;let u=n?.getSharedState(l);if(!u)return;let{showFVG:d,showOB:f,showFilledZones:p}=u.params;if(!d&&!f)return;let m=e=>i.yAxis.priceToY(e);t.save(),t.translate(-o,0);for(let e of u.series){let n=e.kind===`FVG_BULL`||e.kind===`FVG_BEAR`,r=e.kind===`OB_BULL`||e.kind===`OB_BEAR`;if(n&&!d||r&&!f||e.endIndex!==void 0&&!p)continue;let i=e.startIndex,o=e.endIndex??a.end-1;if(o<a.start||i>=a.end)continue;let l=s[Math.max(i,a.start)-a.start],u=s[Math.min(o,a.end-1)-a.start];if(l===void 0||u===void 0)continue;let h=m(e.high),g=m(e.low);t.fillStyle=e.kind===`FVG_BULL`?c.ZONES.FVG_BULL_FILL:e.kind===`FVG_BEAR`?c.ZONES.FVG_BEAR_FILL:e.kind===`OB_BULL`?c.ZONES.OB_BULL_FILL:c.ZONES.OB_BEAR_FILL,t.fillRect(l,h,u-l,g-h)}t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var sg;new class extends ig{static[class{static{[sg,Qh]=$h(this,[q({name:`zones`,displayName:`Zones`,category:`main`,stateKey:go,defaultPaneId:`main`,paneIdField:`zonesPaneId`,allowMainPane:!0,applyResult:(e,t,n)=>{e.setSharedState(go(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=og;constructor(){super(sg),Qh()}};var cg;function lg(e,t,n,r,i,a){var o,s,c,l,u,d,f,p=Symbol.metadata||Symbol.for(`Symbol.metadata`),m=Object.defineProperty,h=Object.create,g=[h(null),h(null)],_=t.length;function v(t,n,r){return function(i,a){n&&(a=i,i=e);for(var o=0;o<t.length;o++)a=t[o].apply(i,r?[a]:[]);return r?a:i}}function y(e,t,n,r){if(typeof e!=`function`&&(r||e!==void 0))throw TypeError(t+` must `+(n||`be`)+` a function`+(r?``:` or undefined`));return e}function b(e,t,n,r,i,a,c,l,u,d,f){function p(e){if(!f(e))throw TypeError(`Attempted to access private element on non-instance`)}var h=[].concat(t[0]),_=t[3],b=!c,x=i===1,S=i===3,C=i===4,w=i===2;function T(t,n,r){return function(i,a){return n&&(a=i,i=e),r&&r(i),E[t].call(i,a)}}if(!b){var E={},D=[],O=S?`get`:C||x?`set`:`value`;if(u?(d||x?E={get:fg(function(){return _(this)},r,`get`),set:function(e){t[4](this,e)}}:E[O]=_,d||fg(E[O],r,w?``:O)):d||(E=Object.getOwnPropertyDescriptor(e,r)),!d&&!u){if((s=g[+l][r])&&(s^i)!==7)throw Error(`Decorating two elements with the same name (`+E[O].name+`) is not supported yet`);g[+l][r]=i<3?1:i}}for(var k=e,A=h.length-1;A>=0;A-=n?2:1){var j=y(h[A],`A decorator`,`be`,!0),M=n?h[A-1]:void 0,N={},P={kind:[`field`,`accessor`,`method`,`getter`,`setter`,`class`][i],name:r,metadata:o,addInitializer:function(e,t){if(e.v)throw TypeError(`attempted to call addInitializer after decoration was finished`);y(t,`An initializer`,`be`,!0),a.push(t)}.bind(null,N)};if(b)s=j.call(M,k,P),N.v=1,y(s,`class decorators`,`return`)&&(k=s);else if(P.static=l,P.private=u,s=P.access={has:u?f.bind():function(e){return r in e}},C||(s.get=u?w?function(e){return p(e),E.value}:T(`get`,0,p):function(e){return e[r]}),w||S||(s.set=u?T(`set`,0,p):function(e,t){e[r]=t}),k=j.call(M,x?{get:E.get,set:E.set}:E[O],P),N.v=1,x){if(typeof k==`object`&&k)(s=y(k.get,`accessor.get`))&&(E.get=s),(s=y(k.set,`accessor.set`))&&(E.set=s),(s=y(k.init,`accessor.init`))&&D.unshift(s);else if(k!==void 0)throw TypeError(`accessor decorators must return an object with get, set, or init properties or undefined`)}else y(k,(d?`field`:`method`)+` decorators`,`return`)&&(d?D.unshift(k):E[O]=k)}return i<2&&c.push(v(D,l,1),v(a,l,0)),d||b||(u?x?c.splice(-1,0,T(`get`,l),T(`set`,l)):c.push(w?E[O]:y.call.bind(E[O])):m(e,r,E)),k}function x(e){return m(e,p,{configurable:!0,enumerable:!0,value:o})}return a!==void 0&&(o=a[p]),o=h(o??null),u=[],d=function(e){e&&u.push(v(e))},f=function(t,r){for(var a=0;a<n.length;a++){var o=n[a],s=o[1],d=7&s;if((8&s)==t&&!d==r){var f=o[2],p=!!o[3],m=16&s;b(t?e:e.prototype,o,m,p?`#`+f:ug(f),d,d<2?[]:t?l||=[]:c||=[],u,!!t,p,r,t&&p?function(t){return pg(t)===e}:i)}}},f(8,0),f(0,0),f(8,1),f(0,1),d(c),d(l),s=u,_||x(e),{e:s,get c(){var n=[];return _&&[x(e=b(e,[t],r,e.name,5,n)),v(n,1)]}}}function ug(e){var t=dg(e,`string`);return typeof t==`symbol`?t:t+``}function dg(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fg(e,t,n){typeof t==`symbol`&&(t=(t=t.description)?`[`+t+`]`:``);try{Object.defineProperty(e,`name`,{configurable:!0,value:n?n+` `+t:t})}catch{}return e}function pg(e){if(Object(e)!==e)throw TypeError(`right-hand side of 'in' should be an object, got `+(e===null?`null`:typeof e));return e}function mg(e){return e}var hg=`rgba(99, 102, 241, 0.35)`,gg=`#f59e0b`,_g=`rgba(99, 102, 241, 0.6)`,vg=80;function yg(e,t){let n=e?.getService(`indicatorScheduler`);if(!n)return console.warn(`[VolumeProfileRenderer] Scheduler not available via service locator`),null;let r=n.getIndicatorMetadata(`volumeProfile`);return r?Y(r.stateKey,t):(console.warn(`[VolumeProfileRenderer] Indicator metadata for 'volumeProfile' not found, skip rendering`),null)}function bg(e={}){let{paneId:t=`sub_VolumeProfile`}=e,n=null;function r(){return yg(n,t)}return{name:`volumeProfile_${t}`,version:`1.0.0`,description:`Volume Profile 渲染器(POC + Value Area + 价格-成交量直方图)`,debugName:`VolumeProfile`,paneId:t,priority:J.MAIN,onInstall(e){n=e},getDeclaredNamespaces(){let e=r();return e?[e]:[]},draw(e){let{ctx:t,pane:i,scrollLeft:a}=e,o=r();if(!o)return;let s=n?.getSharedState(o);if(!s)return;let{bins:c,poc:l,vah:u,val:d,totalVolume:f}=s.series;if(c.length===0||f<=0)return;let{showPOC:p,showValueArea:m}=s.params,h=i.yAxis.getDisplayRange(),g=h.minPrice,_=h.maxPrice-g||1,v=e=>i.height-(e-g)/_*i.height,y=Math.max(...c.map(e=>e.volume));if(y<=0)return;t.save(),t.translate(-a,0);let b=a+e.paneWidth-vg;t.fillStyle=hg;for(let e of c){let n=v(e.priceHigh),r=v(e.priceLow),i=e.volume/y*vg;t.fillRect(b,n,i,r-n)}if(m){t.strokeStyle=_g,t.lineWidth=1,t.setLineDash([4,4]);let n=v(u),r=v(d);t.beginPath(),t.moveTo(a,n),t.lineTo(a+e.paneWidth,n),t.moveTo(a,r),t.lineTo(a+e.paneWidth,r),t.stroke(),t.setLineDash([])}if(p){t.strokeStyle=gg,t.lineWidth=1;let n=v(l);t.beginPath(),t.moveTo(a,n),t.lineTo(a+e.paneWidth,n),t.stroke()}t.restore()},getConfig(){let e=r();return e?n?.getSharedState(e)?.params??{}:{}},setConfig(){}}}var xg;new class extends mg{static[class{static{[xg,cg]=lg(this,[q({name:`volumeProfile`,displayName:`VP`,category:`volume`,stateKey:vo,defaultPaneId:`sub_VolumeProfile`,paneIdField:`volumeProfilePaneId`,applyResult:(e,t,n)=>{e.setSharedState(vo(n),t,`indicator_scheduler`)}})],[]).c}}];rendererFactory=bg;constructor(){super(xg),cg()}};function Sg(e){let{indicatorId:t,paneId:n}=e;switch(t){case`VOLUME`:return fs({paneId:n});case`MACD`:return Lc({paneId:n});case`RSI`:return Qc({paneId:n});case`CCI`:return ul({paneId:n});case`STOCH`:return Sl({paneId:n});case`MOM`:return Pl({paneId:n});case`WMSR`:return Kl({paneId:n});case`KST`:return iu({paneId:n});case`FASTK`:return gu({paneId:n});case`ATR`:return ku({paneId:n});case`WMA`:return Hu({paneId:n});case`DEMA`:return $u({paneId:n});case`TEMA`:return ud({paneId:n});case`HMA`:return xd({paneId:n});case`KAMA`:return Md({paneId:n});case`SAR`:return Kd({paneId:n});case`SUPERTREND`:return af({paneId:n});case`KELTNER`:return vf({paneId:n});case`DONCHIAN`:return Mf({paneId:n});case`ICHIMOKU`:return Xf({paneId:n});case`ROC`:return lp({paneId:n});case`TRIX`:return xp({paneId:n});case`HV`:return Np({paneId:n});case`PARKINSON`:return Wp({paneId:n});case`CHAIKIN_VOL`:return tm({paneId:n});case`VMA`:return fm({paneId:n});case`OBV`:return Cm({paneId:n});case`PVT`:return Pm({paneId:n});case`VWAP`:return Gm({paneId:n});case`CMF`:return nh({paneId:n});case`MFI`:return ph({paneId:n});case`PIVOT`:return Eh({paneId:n});case`FIB`:return Rh({paneId:n});case`STRUCTURE`:return Xh({paneId:n});case`ZONES`:return og({paneId:n});case`VOLUME_PROFILE`:return bg({paneId:n});default:throw Error(`Unknown indicator: ${t}`)}}function Cg(e,t){return Math.max(3,Math.round(e/60)+1)}function wg(e){let{height:t,paddingTop:n,paddingBottom:r,isMain:i,hideEdgeTicks:a}=e,o=n,s=Math.max(n,t-r),c=Math.max(0,s-o),l=Cg(t,i),u=[];for(let e=0;e<l;e++){if(a&&(e===0||e===l-1))continue;let t=l<=1?0:e/(l-1),n=o+t*c;u.push({index:e,t,y:n})}return u}var Tg=1e-10,Eg=[1,1.2,1.5,2,2.5,3,4,5,6,7.5,8,10];function Dg(e){if(!Number.isFinite(e)||e<=0)return e;let t=10**Math.floor(Math.log10(e)),n=e/t,r=Eg[0],i=1/0;for(let e of Eg){let t=Math.abs(e-n);t<i&&(i=t,r=e)}return r*t}function Og(e){let{height:t,paddingTop:n,paddingBottom:r,valueMin:i,valueMax:a,targetCount:o}=e,s=Math.max(i,Tg),c=Math.max(a,s*1.001),l=n,u=Math.max(n,t-r),d=Math.max(0,u-l);if(d<=0)return[];let f=Er({minPrice:s,maxPrice:c}),p=H(s,f),m=H(c,f),h=m-p;if(!Number.isFinite(h)||Math.abs(h)<1e-10)return[];let g=Math.max(2,o),_=g<=1?d:d/(g-1),v=_*.6,y=_*.15,b=[],x=null;for(let e=0;e<g;e++){let t=g<=1?0:e/(g-1),n=l+t*d,r=Tr(m-t*h,f),i=r,a=t,o=n,s=Dg(r);if(Number.isFinite(s)&&s>0){let e=(m-H(s,f))/h,t=l+e*d;Number.isFinite(t)&&Math.abs(t-n)<=y&&(i=s,a=e,o=t)}o<l-.5||o>u+.5||x!==null&&Math.abs(o-x)<v||(b.push({index:b.length,t:a,y:o,value:i}),x=o)}return b}var kg=``,Ag=[];function jg(e){return`${e.valueMin}:${e.valueMax}:${e.height}:${e.paddingTop}:${e.paddingBottom}:${e.isMain}:${e.scaleType??`linear`}:${e.hideEdgeTicks??!1}`}function Mg(e){let t=jg(e);if(t===kg)return Ag;let{valueMin:n,valueMax:r,scaleType:i=`linear`}=e;if(i===`log`){if(n<=0)return Mg({...e,scaleType:`linear`});let i=Math.max(n,Tg),a=Math.max(r,i*1.001),{height:o,paddingTop:s,paddingBottom:c,isMain:l,hideEdgeTicks:u}=e,d=Og({height:o,paddingTop:s,paddingBottom:c,valueMin:i,valueMax:a,targetCount:Math.max(2,Cg(o,l))});u&&d.length>2&&(d=d.slice(1,-1));let f=d.map((e,t)=>({...e,index:t}));return kg=t,Ag=f,f}let a=wg(e),o=Cg(e.height,e.isMain),s=r-n||1,c=a.map(e=>{let t=r-s/Math.max(1,o-1)*e.index;return{...e,value:t}});return kg=t,Ag=c,c}function Ng(e,t,n,r,i,a){let o=t-n||1,s=Math.max(1,r-i-a);return n+(1-(Math.min(Math.max(e,i),i+s)-i)/s)*o}var Pg=new Map,Fg=512;function Ig(e,t){let n=`${e.font}\n${t}`,r=Pg.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return Pg.size>=Fg&&Pg.clear(),Pg.set(n,i),i}function Lg(e,t,n=`light`){let r=V(n),{x:i,y:a,width:o,height:s,crosshairX:c,timestamp:l,dpr:u,fontSize:d=16,paddingX:f=8}=t,p=_e(l);e.save(),wc(e,Cc(d)),e.textBaseline=`middle`,e.textAlign=`center`;let m=Math.round(Ig(e,p)),h=Math.min(o,m+f*2),g=s,_=Math.min(Math.max(c,i+h/2),i+o-h/2),v=a+s/2,y=_-h/2,b=a;e.fillStyle=r.LABEL.BG,e.fillRect(X(y,u),X(b,u),X(h,u),X(g,u)),e.fillStyle=r.LABEL.TEXT,e.fillText(p,X(_,u),Z(v,u)),e.restore()}function Rg(e,t,n=`light`){let r=V(n),{x:i,y:a,width:o,height:s,crosshairY:c,priceRange:l,yPaddingPx:u=0,dpr:d,bgColor:f=r.LABEL.BG,borderColor:p,textColor:m=r.LABEL.TEXT,fontSize:h=16,priceOffset:g=0,price:_,formatPrice:v}=t,y=Math.max(0,Math.min(u,Math.floor(s/2)-1)),{maxPrice:b,minPrice:x}=l,S=_??Ng(c-a,b,x,s,y,y)+g,C=v?v(S):S.toFixed(2);e.save(),wc(e,Cc(h)),e.textBaseline=`middle`,e.textAlign=`center`;let w=h+4,T=Math.min(Math.max(c,a+w/2),a+s-w/2),E=T-w/2,D=i,O=X(E,d),k=o,A=X(w,d);e.fillStyle=f,e.fillRect(D,O,k,A),p&&(e.strokeStyle=p,e.lineWidth=1,e.strokeRect(Z(D,d),Z(O,d),Math.max(0,k-1/d),Math.max(0,A-1/d)));let j=i+o/2;e.fillStyle=m,e.fillText(C,X(j,d),Z(T,d)),e.restore()}function zg(e,t,n=`light`){let r=V(n),{x:i,y:a,width:o,height:s,data:c,scrollLeft:l,kWidth:u,kGap:d,startIndex:f,endIndex:p,dpr:m,bgColor:h=r.TAG_BG.TRANSPARENT,textColor:g=r.TEXT.SECONDARY,lineColor:_=r.BORDER.DARK,fontSize:v=12,paddingX:y=8,drawTopBorder:b=!0,drawBottomBorder:x=!0}=t,S=Math.round(u*m),C=S%2==0?S+1:S,w=Math.round(d*m),T=C+w,E=w,D=T/m,O=E/m,k=C/m;e.fillStyle=h,e.fillRect(i,a,o,s),b&&(e.strokeStyle=_,e.lineWidth=1,e.beginPath(),e.moveTo(i,Z(a,m)),e.lineTo(i+o,Z(a,m)),e.stroke()),x&&(e.strokeStyle=_,e.lineWidth=1,e.beginPath(),e.moveTo(i,Z(a+s,m)),e.lineTo(i+o,Z(a+s,m)),e.stroke()),e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=g;let A=a+s/2,j=Cc(v),M=Cc(v,{bold:!0}),N=Ce(c).filter(e=>e>=f&&e<p),P=null;for(let t of N){let n=c[t];if(!n)continue;let r=O+t*D+k/2-l,i=y,a=Math.max(y,o-y);if(r>=i&&r<=a){let t=Math.min(Math.max(r,i),a),{text:o,isYear:s}=me(n.timestamp);P!==s&&(wc(e,s?M:j),P=s),e.fillText(o,X(t,m),Z(A,m))}}}function Bg(e,t,n=`light`){let r=V(n),{x:i,y:a,width:o,height:s,priceY:c,price:l,dpr:u,bgColor:d=r.LABEL.BG,borderColor:f,textColor:p=r.LABEL.TEXT,fontSize:m=12}=t,h=l.toFixed(2);e.save(),wc(e,Cc(m)),e.textBaseline=`middle`,e.textAlign=`center`;let g=m+4,_=Math.min(Math.max(c,a+g/2),a+s-g/2),v=_-g/2,y=i,b=X(v,u),x=o,S=X(g,u);e.fillStyle=d,e.fillRect(y,b,x,S),f&&(e.strokeStyle=f,e.lineWidth=1,e.strokeRect(Z(y,u),Z(b,u),Math.max(0,x-1/u),Math.max(0,S-1/u)));let C=i+o/2;e.fillStyle=p,e.fillText(h,X(C,u),Z(_,u)),e.restore()}function Vg(e,t,n=`light`){let r=V(n),{x:i,y:a,width:o,height:s,labelX:c,timestamp:l,dpr:u,fontSize:d=12,paddingX:f=8}=t,p=_e(l);e.save(),wc(e,Cc(d)),e.textBaseline=`middle`,e.textAlign=`center`;let m=Math.round(Ig(e,p)),h=Math.min(o,m+f*2),g=s,_=Math.min(Math.max(c,i+h/2),i+o-h/2),v=a+s/2,y=_-h/2,b=a;e.fillStyle=t.bgColor??r.LABEL.BG,e.fillRect(X(y,u),X(b,u),X(h,u),X(g,u)),e.fillStyle=t.textColor??r.LABEL.TEXT,e.fillText(p,X(_,u),Z(v,u)),e.restore()}var Hg=`middle`,Ug=`center`;function Wg(e){let{ctx:t,dpr:n,axisWidth:r,height:i,paddingTop:a,paddingBottom:o,valueMin:s,valueMax:c,isMain:l,decimals:u=2,hideEdgeTicks:d=!0,scaleType:f=`linear`,formatLabel:p}=e;t.clearRect(0,0,r,i),wc(t,Cc(12)),t.textBaseline=Hg,t.textAlign=Ug,t.fillStyle=e.colors.TEXT.SECONDARY;let m=X(r/2,n),h=Mg({height:i,paddingTop:a,paddingBottom:o,isMain:l,hideEdgeTicks:d,valueMin:s,valueMax:c,scaleType:f}),g=p??(e=>e.toFixed(u));for(let e=0;e<h.length;e++){let{y:r,value:i}=h[e];t.fillText(g(i),m,Z(r,n))}}function Q(e){let{axisWidth:t,paneId:n,indicatorKey:r,label:i,decimals:a=2,yPaddingPx:o=0,scaleType:s=`linear`,getCrosshair:c,formatTickLabel:l,formatCrosshairLabel:u}=e,d=W(r,n),f=null;return{name:`${r}Scale_${n}`,version:`1.0.0`,description:`${i} 刻度渲染器`,debugName:`${i}刻度`,paneId:n,priority:J.INDICATOR_SCALE,layer:`overlay`,onInstall(e){f=e},draw(e){let{yAxisCtx:n,pane:r,dpr:i}=e;if(!n||!f)return;let p=f.getSharedState(d);if(!p)return;let m=r.yAxis.getScaleType()??s,h=n.canvas?n.canvas.width/i:t,g=V(e.theme),_=r.yAxis.getDisplayRange({minPrice:p.valueMin,maxPrice:p.valueMax});Wg({colors:g,ctx:n,dpr:i,axisWidth:h,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:_.minPrice,valueMax:_.maxPrice,isMain:!1,decimals:a,hideEdgeTicks:!1,scaleType:m,formatLabel:l});let v=c?.();if(!v||v.activePaneId!==r.id)return;let y=v.y-r.top,b=r.yAxis.getPaddingTop(),x=r.yAxis.getPaddingBottom(),S=b,C=Math.max(b,r.height-x),w=Math.max(1,C-S),T=(Math.min(Math.max(y,S),C)-S)/w,E=_.maxPrice-T*(_.maxPrice-_.minPrice);Rg(n,{x:0,y:0,width:h,height:r.height,crosshairY:y,priceRange:_,yPaddingPx:o,dpr:i,fontSize:12,priceOffset:0,price:E,formatPrice:u})}}}var Gg=1e8;function Kg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`volume`,label:`VOL`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair,formatTickLabel:e=>`${(e/Gg).toFixed(2)}B`,formatCrosshairLabel:e=>`${(e/Gg).toFixed(2)}B`})}function qg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`macd`,label:`MACD`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Jg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`rsi`,label:`RSI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Yg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`cci`,label:`CCI`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Xg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`stoch`,label:`STOCH`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Zg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`mom`,label:`MOM`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function Qg(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`wmsr`,label:`WMSR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function $g(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`kst`,label:`KST`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function e_(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`fastk`,label:`FASTK`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}function t_(e){return Q({axisWidth:e.axisWidth,paneId:e.paneId,indicatorKey:`atr`,label:`ATR`,decimals:2,yPaddingPx:e.yPaddingPx,getCrosshair:e.getCrosshair})}var n_=class{entries=new Map;create(e,t,n,r){if(this.entries.has(t))return!0;let i=`${n.toLowerCase()}_${t}`,a=`${n.toLowerCase()}_scale_${t}`;if(e.hasPane(t)||e.upsertPane({id:t,ratio:1,visible:!0,role:`indicator`}),!e.getRenderer(i)){let i=Sg({indicatorId:n,paneId:t});e.useRenderer(i,r)}return this.mountScaleRenderer(e,t,n,a),this.entries.set(t,{paneId:t,indicatorId:n,params:r,rendererName:i,scaleRendererName:a}),this.syncSchedulerConfig(e,t,n,r),e.getIndicatorScheduler().onSubPaneChanged(),!0}remove(e,t){let n=this.entries.get(t);n&&(e.removeRenderer(n.rendererName),e.removeRenderer(n.scaleRendererName),this.entries.delete(t),e.hasPane(t)&&e.removePaneDefinition(t),e.getIndicatorScheduler().onSubPaneChanged())}replaceIndicator(e,t,n,r){let i=this.entries.get(t);if(!i)return;i.indicatorId,e.removeRenderer(i.rendererName),e.removeRenderer(i.scaleRendererName);let a=`${n.toLowerCase()}_${t}`,o=`${n.toLowerCase()}_scale_${t}`,s=Sg({indicatorId:n,paneId:t});e.useRenderer(s,r),this.mountScaleRenderer(e,t,n,o),this.syncSchedulerConfig(e,t,n,r),this.entries.set(t,{paneId:t,indicatorId:n,params:r,rendererName:a,scaleRendererName:o}),e.getIndicatorScheduler().onSubPaneChanged()}updateParams(e,t,n){let r=this.entries.get(t);r&&(r.params={...n},e.updateRendererConfig(r.rendererName,n),this.syncSchedulerConfig(e,t,r.indicatorId,r.params))}getByPaneId(e){return this.entries.get(e)}getAll(){return Array.from(this.entries.values())}getPaneIds(){return Array.from(this.entries.keys())}clear(e){for(let t of this.entries.values())e.removeRenderer(t.rendererName),e.removeRenderer(t.scaleRendererName);this.entries.clear(),e.getIndicatorScheduler().onSubPaneChanged()}syncSchedulerConfig(e,t,n,r){let i=e.getIndicatorScheduler();switch(n){case`MACD`:i.updateMACDConfig(r,t);break;case`RSI`:i.updateRSIConfig(r,t);break;case`CCI`:i.updateCCIConfig(r,t);break;case`STOCH`:i.updateSTOCHConfig(r,t);break;case`MOM`:i.updateMOMConfig(r,t);break;case`WMSR`:i.updateWMSRConfig(r,t);break;case`KST`:i.updateKSTConfig(r,t);break;case`FASTK`:i.updateFASTKConfig(r,t);break;case`ATR`:console.log(`[ATR-SubPane] syncSchedulerConfig: paneId=${t} params=${JSON.stringify(r)}`),i.updateATRConfig(r,t);break;case`WMA`:i.updateWMAConfig(r,t);break;case`DEMA`:i.updateDEMAConfig(r,t);break;case`TEMA`:i.updateTEMAConfig(r,t);break;case`HMA`:i.updateHMAConfig(r,t);break;case`KAMA`:i.updateKAMAConfig(r,t);break;case`SAR`:i.updateSARConfig(r,t);break;case`SUPERTREND`:i.updateSuperTrendConfig(r,t);break;case`KELTNER`:i.updateKeltnerConfig(r,t);break;case`DONCHIAN`:i.updateDonchianConfig(r,t);break;case`ICHIMOKU`:i.updateIchimokuConfig(r,t);break;case`ROC`:i.updateROCConfig(r,t);break;case`TRIX`:i.updateTRIXConfig(r,t);break;case`HV`:i.updateHVConfig(r,t);break;case`PARKINSON`:i.updateParkinsonConfig(r,t);break;case`CHAIKIN_VOL`:i.updateChaikinVolConfig(r,t);break;case`VMA`:i.updateVMAConfig(r,t);break;case`OBV`:i.updateOBVConfig(r,t);break;case`PVT`:i.updatePVTConfig(r,t);break;case`VWAP`:i.updateVWAPConfig(r,t);break;case`CMF`:i.updateCMFConfig(r,t);break;case`MFI`:i.updateMFIConfig(r,t);break;case`PIVOT`:i.updatePivotConfig(r,t);break;case`FIB`:i.updateFibConfig(r,t);break;case`STRUCTURE`:i.updateStructureConfig(r,t);break;case`ZONES`:i.updateZonesConfig(r,t);break;case`VOLUME_PROFILE`:i.updateVolumeProfileConfig(r,t);break;case`VOLUME`:break}}mountScaleRenderer(e,t,n,r){if(e.getRenderer(r))return;let i={axisWidth:e.getOption().rightAxisWidth+(e.getOption().priceLabelWidth??60),paneId:t,yPaddingPx:e.getOption().yPaddingPx,getCrosshair:()=>{let t=e.interaction.crosshairPos,n=e.interaction.crosshairPrice,r=e.interaction.activePaneId;return t&&n!==null?{y:t.y,price:n,activePaneId:r}:null}},a;switch(n){case`VOLUME`:a=Kg(i);break;case`MACD`:a=qg(i);break;case`RSI`:a=Jg(i);break;case`CCI`:a=Yg(i);break;case`STOCH`:a=Xg(i);break;case`MOM`:a=Zg(i);break;case`WMSR`:a=Qg(i);break;case`KST`:a=$g(i);break;case`FASTK`:a=e_(i);break;case`ATR`:a=t_(i);break;case`WMA`:a=Q({...i,indicatorKey:`wma`,label:`WMA`,decimals:2});break;case`DEMA`:a=Q({...i,indicatorKey:`dema`,label:`DEMA`,decimals:2});break;case`TEMA`:a=Q({...i,indicatorKey:`tema`,label:`TEMA`,decimals:2});break;case`HMA`:a=Q({...i,indicatorKey:`hma`,label:`HMA`,decimals:2});break;case`KAMA`:a=Q({...i,indicatorKey:`kama`,label:`KAMA`,decimals:2});break;case`SAR`:a=Q({...i,indicatorKey:`sar`,label:`SAR`,decimals:4});break;case`SUPERTREND`:a=Q({...i,indicatorKey:`supertrend`,label:`SuperTrend`,decimals:2});break;case`KELTNER`:a=Q({...i,indicatorKey:`keltner`,label:`Keltner`,decimals:2});break;case`DONCHIAN`:a=Q({...i,indicatorKey:`donchian`,label:`Donchian`,decimals:2});break;case`ICHIMOKU`:a=Q({...i,indicatorKey:`ichimoku`,label:`Ichimoku`,decimals:2});break;case`ROC`:a=Q({...i,indicatorKey:`roc`,label:`ROC`,decimals:2});break;case`TRIX`:a=Q({...i,indicatorKey:`trix`,label:`TRIX`,decimals:6});break;case`HV`:a=Q({...i,indicatorKey:`hv`,label:`HV`,decimals:2});break;case`PARKINSON`:a=Q({...i,indicatorKey:`parkinson`,label:`Parkinson`,decimals:2});break;case`CHAIKIN_VOL`:a=Q({...i,indicatorKey:`chaikinVol`,label:`ChaikinVol`,decimals:2});break;case`VMA`:a=Q({...i,indicatorKey:`vma`,label:`VMA`,decimals:0});break;case`OBV`:a=Q({...i,indicatorKey:`obv`,label:`OBV`,decimals:0});break;case`PVT`:a=Q({...i,indicatorKey:`pvt`,label:`PVT`,decimals:0});break;case`VWAP`:a=Q({...i,indicatorKey:`vwap`,label:`VWAP`,decimals:2});break;case`CMF`:a=Q({...i,indicatorKey:`cmf`,label:`CMF`,decimals:4});break;case`MFI`:a=Q({...i,indicatorKey:`mfi`,label:`MFI`,decimals:2});break;case`PIVOT`:a=Q({...i,indicatorKey:`pivot`,label:`Pivot`,decimals:2});break;case`FIB`:a=Q({...i,indicatorKey:`fib`,label:`Fib`,decimals:4});break;case`STRUCTURE`:a=Q({...i,indicatorKey:`structure`,label:`Structure`,decimals:2});break;case`ZONES`:a=Q({...i,indicatorKey:`zones`,label:`Zones`,decimals:2});break;case`VOLUME_PROFILE`:a=Q({...i,indicatorKey:`volumeProfile`,label:`VP`,decimals:0});break;default:return}e.useRenderer(a)}},r_=8,i_=6,a_=class e{chart;activeTool=`cursor`;pendingAnchors=[];drawings=[];callbacks={};previewDrawingId=`__preview__`;dragState=null;selectedDrawingId=null;static SINGLE_ANCHOR_TOOLS=[`h-line`,`h-ray`,`v-line`,`crosshair-line`];static DOUBLE_ANCHOR_TOOLS=[`trend-line`,`ray`,`info-line`,`regression-channel`];static TRIPLE_ANCHOR_TOOLS=[`parallel-channel`,`flat-line`,`disjoint-channel`];constructor(e){this.chart=e}setCallbacks(e){this.callbacks=e}getActiveTool(){return this.activeTool}setTool(e){this.activeTool=e,this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null),this.callbacks.onToolChange?.(e)}getDrawings(){return this.drawings}setDrawings(e){this.drawings=e,this.chart.setDrawings(e)}clear(){this.pendingAnchors=[],this.removePreview(),this.dragState=null,this.setSelected(null)}getSelectedDrawing(){return this.selectedDrawingId?this.drawings.find(e=>e.id===this.selectedDrawingId)??null:null}updateDrawingStyle(e,t){this.drawings=this.drawings.map(n=>n.id===e?{...n,style:{...n.style,...t}}:n),this.chart.setDrawings(this.drawings)}removeDrawing(e){this.drawings=this.drawings.filter(t=>t.id!==e),this.selectedDrawingId===e&&this.setSelected(null),this.chart.setDrawings(this.drawings)}onPointerMove(e,t){return this.dragState?this.handleDragMove(e,t):this.activeTool===`cursor`?!1:this.handlePreviewMove(e,t)}onPointerDown(t,n){if(this.activeTool===`cursor`)return this.handleCursorDown(t,n);let r=this.resolveAnchorFromPointer(t,n);if(!r)return!1;if(e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool))return this.createSingleAnchorDrawing(r),!0;let i=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a)return!1;this.pendingAnchors.push(r);let o=i?2:3;return this.pendingAnchors.length>=o&&(this.createMultiAnchorDrawing(this.pendingAnchors),this.pendingAnchors=[]),!0}onPointerUp(e,t){return this.dragState?(this.dragState=null,!0):!1}handleCursorDown(e,t){let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top,a=this.hitTest(r,i);return a?(this.setSelected(a.drawing),this.dragState={drawingId:a.drawing.id,anchorIndex:`anchorIndex`in a?a.anchorIndex:void 0,snapshot:a.drawing.anchors.map(e=>({...e})),startMouse:{x:r,y:i}},!0):(this.setSelected(null),!1)}handleDragMove(e,t){if(!this.dragState)return!1;let n=this.drawings.find(e=>e.id===this.dragState.drawingId);if(!n)return this.dragState=null,!1;let r=this.resolveAnchorFromPointer(e,t);if(this.dragState.anchorIndex!==void 0){if(r){let e=this.dragState.anchorIndex;n.anchors[e]={...n.anchors[e],index:r.index,time:r.time,price:r.price},n.kind===`flat-line`&&e===1&&n.anchors.length>=3&&(n.anchors[2]={...n.anchors[2],index:r.index,time:r.time})}}else{let r=t.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=i-this.dragState.startMouse.x,s=a-this.dragState.startMouse.y;for(let e=0;e<n.anchors.length;e++){let t=this.dragState.snapshot[e],r=this.anchorToScreen(t);if(!r)continue;let i=r.x+o,a=r.y+s,c=this.screenToAnchor(i,a);c&&(n.anchors[e]={...n.anchors[e],index:c.index,time:c.time,price:c.price})}}return this.chart.setDrawings([...this.drawings]),!0}handlePreviewMove(t,n){let r=this.resolveAnchorFromPointer(t,n);if(!r)return this.removePreview(),!1;let i=e.SINGLE_ANCHOR_TOOLS.includes(this.activeTool),a=e.DOUBLE_ANCHOR_TOOLS.includes(this.activeTool),o=e.TRIPLE_ANCHOR_TOOLS.includes(this.activeTool);if(!i&&!a&&!o)return!1;let s;if(i)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else if(a&&this.pendingAnchors.length>=1)s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:this.activeTool===`regression-channel`?{sigma:2}:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,...this.activeTool===`regression-channel`?{fillOpacity:.1}:{}}};else if(o){if(this.pendingAnchors.length===0)return!1;if(this.pendingAnchors.length===1)s={id:this.previewDrawingId,kind:`trend-line`,paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:r.index,time:r.time,price:r.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`}};else{let e=this.activeTool===`flat-line`?{id:`${this.previewDrawingId}-c`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:r.price}:{id:`${this.previewDrawingId}-c`,index:r.index,time:r.time,price:r.price};s={id:this.previewDrawingId,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${this.previewDrawingId}-a`,index:this.pendingAnchors[0].index,time:this.pendingAnchors[0].time,price:this.pendingAnchors[0].price},{id:`${this.previewDrawingId}-b`,index:this.pendingAnchors[1].index,time:this.pendingAnchors[1].time,price:this.pendingAnchors[1].price},e],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`dashed`,fillOpacity:.1}}}}else return!1;return this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.drawings=[...this.drawings,s],this.chart.setDrawings(this.drawings),!0}hitTest(e,t){let n=this.drawings.filter(e=>e.id!==this.previewDrawingId&&e.visible),r=new Map;for(let i of n){if(i.kind===`regression-channel`&&i.anchors.length>=2){let n=this.hitTestRegressionEndpoints(i,e,t,r);if(n)return n}for(let n=0;n<i.anchors.length;n++){let r=this.anchorToScreen(i.anchors[n]);if(r&&Math.hypot(e-r.x,t-r.y)<=r_)return{drawing:i,anchorIndex:n}}}for(let i of n){let n=this.getDrawingLineSegments(i,r);for(let r of n)if(o_(e,t,r.a,r.b)<=i_)return{drawing:i}}return null}getDrawingLineSegments(e,t){let n=this.chart.getViewport();if(!n)return[];if(e.kind===`regression-channel`)return this.getRegressionChannelGeometry(e,t)?.segments??[];if(e.anchors.length===1){let t=this.anchorToScreen(e.anchors[0]);if(!t)return[];let r=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();if(!r)return[];let i=n.plotWidth,a=r.height;switch(e.kind){case`horizontal-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}}];case`horizontal-ray`:return[{a:t,b:{x:i,y:t.y}}];case`vertical-line`:return[{a:{x:t.x,y:0},b:{x:t.x,y:a}}];case`cross-line`:return[{a:{x:0,y:t.y},b:{x:i,y:t.y}},{a:{x:t.x,y:0},b:{x:t.x,y:a}}];default:return[]}}let r=e.anchors.map(e=>this.anchorToScreen(e)).filter(Boolean);if(r.length<2)return[];let i=[];if(r.length===2){let t=r[0],a=r[1],o=a.x-t.x,s=a.y-t.y,c=t,l=a,u=this.getExtendMode(e),d=Math.max(n.plotWidth,n.plotHeight)*4;(u===`right`||u===`both`)&&(l={x:a.x+o*d,y:a.y+s*d}),(u===`left`||u===`both`)&&(c={x:t.x-o*d,y:t.y-s*d}),i.push({a:c,b:l})}else if(r.length>=3)switch(e.kind){case`parallel-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y+o};i.push({a:e,b:t},{a:n,b:s});break}case`flat-line`:{let[e,t,n]=r,a={x:e.x,y:n.y},o={x:t.x,y:n.y};i.push({a:e,b:t}),i.push({a,b:o});break}case`disjoint-channel`:{let[e,t,n]=r,a=t.x-e.x,o=t.y-e.y,s={x:n.x+a,y:n.y-o};i.push({a:e,b:t}),i.push({a:n,b:s});break}default:for(let e=0;e<r.length-1;e++)i.push({a:r[e],b:r[e+1]})}return i}hitTestRegressionEndpoints(e,t,n,r){let i=this.getRegressionChannelGeometry(e,r);if(!i)return null;for(let r of i.endpoints)if(Math.hypot(t-r.point.x,n-r.point.y)<=r_)return{drawing:e,anchorIndex:r.anchorIndex};return null}getRegressionChannelGeometry(e,t){let n=t?.get(e.id);if(n!==void 0)return n;let r=this.chart.getData();if(r.length===0||e.anchors.length<2)return t?.set(e.id,null),null;let i=Math.round(e.anchors[0].index),a=Math.round(e.anchors[1].index),o=Math.min(Math.max(i,0),r.length-1),s=Math.min(Math.max(a,0),r.length-1),c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=h_(u.map(e=>e.close));if(!d)return t?.set(e.id,null),null;let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g=this.anchorToScreen({id:``,index:i,price:m}),_=this.anchorToScreen({id:``,index:a,price:h}),v=this.anchorToScreen({id:``,index:i,price:m+p}),y=this.anchorToScreen({id:``,index:a,price:h+p}),b=this.anchorToScreen({id:``,index:i,price:m-p}),x=this.anchorToScreen({id:``,index:a,price:h-p}),S=[];g&&_&&S.push({a:g,b:_}),v&&y&&S.push({a:v,b:y}),b&&x&&S.push({a:b,b:x});let C=[];g&&C.push({point:g,anchorIndex:0}),_&&C.push({point:_,anchorIndex:1}),v&&C.push({point:v,anchorIndex:0}),y&&C.push({point:y,anchorIndex:1}),b&&C.push({point:b,anchorIndex:0}),x&&C.push({point:x,anchorIndex:1});let w={segments:S,endpoints:C};return t?.set(e.id,w),w}getExtendMode(e){switch(e.kind){case`ray`:return`right`;case`extended-line`:return`both`;default:return`none`}}anchorToScreen(e){let t=this.chart.getViewport();if(!t)return null;let n=this.chart.getOption(),r=this.chart.getCurrentDpr(),{startXPx:i,unitPx:a}=br(n.kWidth,n.kGap,r);if(!Number.isFinite(e.index))return null;let o=(i+e.index*a+(a-1)/2)/r-t.scrollLeft,s=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return s?{x:o,y:s.yAxis.priceToY(e.price)}:null}screenToAnchor(e,t){let n=this.chart.getData();if(!this.chart.getViewport()||n.length===0)return null;let r=this.chart.getLogicalIndexAtX(e);if(r===null)return null;let i=this.chart.getPaneRenderers().find(e=>e.getPane().id===`main`)?.getPane();return i?{index:r,time:this.chart.getTimestampAtLogicalIndex(r)??void 0??void 0,price:i.yAxis.yToPrice(t-i.top)}:null}setSelected(e){let t=e?.id??null;this.selectedDrawingId!==t&&(this.selectedDrawingId=t,this.chart.setSelectedDrawingId(t),this.callbacks.onDrawingSelected?.(e))}removePreview(){this.drawings.some(e=>e.id===this.previewDrawingId)&&(this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId),this.chart.setDrawings(this.drawings))}resolveAnchorFromPointer(e,t){let n=this.chart.getData(),r=this.chart.getViewport();if(!r||n.length===0)return null;let i=t.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top;if(a<0||o<0||a>r.plotWidth||o>r.plotHeight)return null;let s=this.chart.getPaneRenderers().find(e=>{let t=e.getPane();return t.id===`main`&&o>=t.top&&o<=t.top+t.height})?.getPane();if(!s)return null;let c=this.chart.getLogicalIndexAtX(a);return c===null?null:{index:c,time:this.chart.getTimestampAtLogicalIndex(c)??void 0??void 0,price:s.yAxis.yToPrice(o-s.top)}}createSingleAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t={id:`drawing-${Date.now()}`,kind:this.getDrawingKind(this.activeTool),paneId:`main`,visible:!0,anchors:[{id:`${Date.now()}-a`,index:e.index,time:e.time,price:e.price}],params:{},style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`}};this.drawings=[...this.drawings,t],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(t),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}createMultiAnchorDrawing(e){this.drawings=this.drawings.filter(e=>e.id!==this.previewDrawingId);let t=this.getDrawingKind(this.activeTool),n=t===`regression-channel`?{sigma:2}:{},r=t===`flat-line`&&e.length>=3?[e[0],e[1],{index:e[1].index,time:e[1].time,price:e[2].price}]:e,i=[`parallel-channel`,`regression-channel`,`flat-line`,`disjoint-channel`].includes(t),a={id:`drawing-${Date.now()}`,kind:t,paneId:`main`,visible:!0,anchors:r.map((e,t)=>({id:`${Date.now()}-${String.fromCharCode(97+t)}`,index:e.index,time:e.time,price:e.price})),params:n,style:{stroke:`#2962ff`,strokeWidth:1,strokeStyle:`solid`,...i?{fillOpacity:.1}:{}}};this.drawings=[...this.drawings,a],this.chart.setDrawings(this.drawings),this.callbacks.onDrawingCreated?.(a),this.activeTool=`cursor`,this.callbacks.onToolChange?.(`cursor`)}getDrawingKind(e){switch(e){case`cursor`:throw Error(`cursor is not a drawing kind`);case`h-line`:return`horizontal-line`;case`h-ray`:return`horizontal-ray`;case`v-line`:return`vertical-line`;case`crosshair-line`:return`cross-line`;default:return e}}};function o_(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=i*i+a*a;if(o===0)return Math.hypot(e-n.x,t-n.y);let s=((e-n.x)*i+(t-n.y)*a)/o;return s=Math.max(0,Math.min(1,s)),Math.hypot(e-(n.x+s*i),t-(n.y+s*a))}var s_=class{drawings=[];selectedId=null;getSelectedId(){return this.selectedId}setSelectedId(e){this.selectedId=e}getAll(){return this.drawings}getVisibleByPane(e){return this.drawings.filter(t=>t.visible&&t.paneId===e).sort((e,t)=>(e.zIndex??0)-(t.zIndex??0))}setAll(e){this.drawings=[...e],this.selectedId&&!this.drawings.some(e=>e.id===this.selectedId)&&(this.selectedId=null)}upsert(e){let t=this.drawings.findIndex(t=>t.id===e.id);if(t>=0){this.drawings[t]=e;return}this.drawings.push(e)}remove(e){this.drawings=this.drawings.filter(t=>t.id!==e)}clear(){this.drawings=[],this.selectedId=null}},c_=class{definitions=new Map;register(e){this.definitions.set(e.kind,e)}get(e){return this.definitions.get(e)}compute(e,t){let n=this.get(e.kind);return n?n.compute(e,t):null}};function l_(e,t){if(e.strokeStyle=t?.stroke??`#2962ff`,e.lineWidth=t?.strokeWidth??1,t?.strokeStyle===`dashed`){e.setLineDash([6,4]);return}if(t?.strokeStyle===`dotted`){e.setLineDash([2,3]);return}e.setLineDash([])}function u_(e,t){e.fillStyle=t?.fill??t?.stroke??`#2962ff`,e.globalAlpha=t?.fillOpacity??1}function d_(e,t,n,r,i){let a=(e,t)=>{let n=0;return e<i.left?n|=1:e>i.right&&(n|=2),t<i.top?n|=8:t>i.bottom&&(n|=4),n},o=e,s=t,c=n,l=r;for(;;){let e=a(o,s),t=a(c,l);if(!(e|t))return{a:{x:o,y:s},b:{x:c,y:l}};if(e&t)return null;let n=e||t,r=0,u=0;n&8?(r=o+(c-o)*(i.top-s)/(l-s),u=i.top):n&4?(r=o+(c-o)*(i.bottom-s)/(l-s),u=i.bottom):n&2?(u=s+(l-s)*(i.right-o)/(c-o),r=i.right):(u=s+(l-s)*(i.left-o)/(c-o),r=i.left),n===e?(o=r,s=u):(c=r,l=u)}}function f_(e,t){let{a:n,b:r,extend:i=`none`}=e;if(i===`none`)return d_(n.x,n.y,r.x,r.y,t);let a=r.x-n.x,o=r.y-n.y;if(a===0&&o===0)return null;let s=Math.max(t.right-t.left,t.bottom-t.top)*4,c=n,l=r;return(i===`left`||i===`both`)&&(c={x:n.x-a*s,y:n.y-o*s}),(i===`right`||i===`both`)&&(l={x:r.x+a*s,y:r.y+o*s}),d_(c.x,c.y,l.x,l.y,t)}function p_(e,t){if(!Number.isFinite(e.index))return-1;let n=Math.round(e.index);return n<0||n>=t.length?-1:n}function m_(e,t=2){if(!Number.isFinite(e))return`0`;let n=e.toFixed(t);return e>0?`+${n}`:n}function h_(e){let t=e.length;if(t<2)return null;let n=0,r=0,i=0,a=0;for(let o=0;o<t;o++){let t=o,s=e[o];n+=t,r+=s,i+=t*s,a+=t*t}let o=t*a-n*n;if(o===0)return null;let s=(t*i-n*r)/o,c=(r-s*n)/t,l=0;for(let n=0;n<t;n++){let t=c+s*n,r=e[n]-t;l+=r*r}return{slope:s,intercept:c,stdDev:Math.sqrt(l/t)}}function g_(){return{point(e,t,n){let r=t.style?.pointRadius??4;e.save(),e.fillStyle=t.style?.fill??t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.point.x,t.point.y,Math.max(r,1/n),0,Math.PI*2),e.fill(),e.restore()},line(e,t,n,r){let i=f_(t,n);if(!i)return;e.save(),l_(e,t.style);let a=(t.style?.strokeWidth??1)<=1?.5/r:0;if(e.beginPath(),e.moveTo(i.a.x+a,i.a.y+a),e.lineTo(i.b.x+a,i.b.y+a),e.stroke(),t.showEndpoints!==!1){let n=t.style?.pointRadius??4;e.fillStyle=t.style?.stroke??`#2962ff`,e.beginPath(),e.arc(t.a.x,t.a.y,Math.max(n,1/r),0,Math.PI*2),e.fill(),e.beginPath(),e.arc(t.b.x,t.b.y,Math.max(n,1/r),0,Math.PI*2),e.fill()}e.restore()},area(e,t){if(t.points.length!==0){e.save(),u_(e,t.style),e.beginPath(),e.moveTo(t.points[0].x,t.points[0].y);for(let n=1;n<t.points.length;n++){let r=t.points[n];e.lineTo(r.x,r.y)}t.closed&&e.closePath(),e.fill(),e.restore()}},text(e,t){e.save(),e.fillStyle=t.style?.textColor??t.style?.stroke??`#2962ff`,e.font=`${t.style?.fontSize??12}px sans-serif`,e.textAlign=t.align??`left`,e.textBaseline=t.baseline??`bottom`,e.fillText(t.text,t.point.x,t.point.y),e.restore()}}}function __(e,t){return{kind:e,minAnchors:2,maxAnchors:2,compute(e,n){let[r,i]=e.anchors;return!r||!i?{primitives:[]}:{primitives:[{kind:`line`,a:n.toScreen(r),b:n.toScreen(i),extend:t,style:e.style}]}}}}function v_(e){return{kind:e,minAnchors:1,maxAnchors:1,compute(t,n){let[r]=t.anchors;if(!r)return{primitives:[]};let i=n.toScreen(r),a=n.pane.height,o=n.viewport.plotWidth;return e===`horizontal-line`?{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`horizontal-ray`?{primitives:[{kind:`line`,a:i,b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:e===`vertical-line`?{primitives:[{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}:{primitives:[{kind:`line`,a:{x:0,y:i.y},b:{x:o,y:i.y},showEndpoints:!1,style:t.style},{kind:`line`,a:{x:i.x,y:0},b:{x:i.x,y:a},showEndpoints:!1,style:t.style},{kind:`point`,point:i,style:t.style}]}}}}function y_(){return{kind:`info-line`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=t.toScreen(n),a=t.toScreen(r),o=Math.round(n.index),s=Math.round(r.index)-o,c=r.price-n.price,l=n.price===0?0:c/n.price*100,u=Math.atan2(a.y-i.y,a.x-i.x)*(180/Math.PI),d=`${m_(c)} (${m_(l)}%) ${s} bars ${m_(u)}°`;return{primitives:[{kind:`line`,a:i,b:a,style:e.style},{kind:`text`,point:{x:(i.x+a.x)/2+8,y:Math.min(i.y,a.y)-8},text:d,align:`left`,baseline:`bottom`,style:e.style}],meta:{delta:c,percent:l,bars:s,angle:u}}}}}function b_(){return{kind:`parallel-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y+l},d=e.params?.extend??`none`,f=i.index+(r.index-n.index),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)+((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,extend:d,style:e.style},{kind:`line`,a:s,b:u,extend:d,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:f,time:p,price:i.price+(r.price-n.price)}]}}}}function x_(){return{kind:`flat-line`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c={x:a.x,y:s.y},l={x:o.x,y:s.y};return{primitives:[{kind:`area`,points:[a,o,l,c],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:c,b:l,style:e.style},{kind:`point`,point:c,style:e.style},{kind:`point`,point:l,style:e.style}],computedAnchors:[{id:`${e.id}-h1`,index:n.index,time:n.time,price:i.price},{id:`${e.id}-h2`,index:r.index,time:r.time,price:i.price}]}}}}function S_(){return{kind:`disjoint-channel`,minAnchors:3,maxAnchors:3,compute(e,t){let[n,r,i]=e.anchors;if(!n||!r||!i)return{primitives:[]};let a=t.toScreen(n),o=t.toScreen(r),s=t.toScreen(i),c=o.x-a.x,l=o.y-a.y,u={x:s.x+c,y:s.y-l},d=i.index+(r.index-n.index),f=i.price-(r.price-n.price),p=i.time?(typeof i.time==`string`?new Date(i.time).getTime():i.time)-((typeof r.time==`string`?new Date(r.time).getTime():r.time??0)-(typeof n.time==`string`?new Date(n.time).getTime():n.time??0)):void 0;return{primitives:[{kind:`area`,points:[a,o,u,s],closed:!0,style:e.style},{kind:`line`,a,b:o,style:e.style},{kind:`line`,a:s,b:u,style:e.style}],computedAnchors:[{id:`${e.id}-p4`,index:d,time:p,price:f}]}}}}function C_(){return{kind:`regression-channel`,minAnchors:2,maxAnchors:2,compute(e,t){let[n,r]=e.anchors;if(!n||!r)return{primitives:[]};let i=p_(n,t.seriesData),a=p_(r,t.seriesData);if(i<0&&a<0)return{primitives:[]};let o=Math.min(Math.max(Math.round(n.index),0),t.seriesData.length-1),s=Math.min(Math.max(Math.round(r.index),0),t.seriesData.length-1),c=Math.min(o,s),l=Math.max(o,s),u=t.seriesData.slice(c,l+1),d=h_(u.map(e=>e.close));if(!d)return{primitives:[]};let f=e.params?.sigma??2,p=d.stdDev*f,m=d.intercept,h=d.intercept+d.slope*(u.length-1),g={id:`${e.id}-reg-start`,index:Math.round(n.index),time:t.seriesData[c].timestamp,price:m},_={id:`${e.id}-reg-end`,index:Math.round(r.index),time:t.seriesData[l].timestamp,price:h},v={...g,id:`${e.id}-reg-upper-start`,price:m+p},y={..._,id:`${e.id}-reg-upper-end`,price:h+p},b={...g,id:`${e.id}-reg-lower-start`,price:m-p},x={..._,id:`${e.id}-reg-lower-end`,price:h-p},S=t.toScreen(g),C=t.toScreen(_),w=t.toScreen(v),T=t.toScreen(y),E=t.toScreen(b),D=t.toScreen(x);return{primitives:[{kind:`area`,points:[w,T,D,E],closed:!0,style:e.style},{kind:`line`,a:S,b:C,style:{...e.style,strokeStyle:`dashed`}},{kind:`line`,a:w,b:T,style:e.style},{kind:`line`,a:E,b:D,style:e.style}],computedAnchors:[g,_],meta:{sigma:f,stdDev:d.stdDev,slope:d.slope}}}}}function w_(e){e.register(__(`trend-line`,`none`)),e.register(__(`ray`,`right`)),e.register(__(`extended-line`,`both`)),e.register(v_(`horizontal-line`)),e.register(v_(`horizontal-ray`)),e.register(v_(`vertical-line`)),e.register(v_(`cross-line`)),e.register(y_()),e.register(b_()),e.register(C_()),e.register(x_()),e.register(S_())}function T_(e,t,n,r,i,a,o,s,c,l,u,d){let f=e.getSelectedId();if(!f)return;let p=e.getAll().find(e=>e.id===f);if(!p||!p.visible||p.paneId!==r.id)return;let m=t.compute(p,{pane:r,visibleData:i.slice(a.start,a.end),seriesData:i,range:a,kLinePositions:n.kLinePositions,kLineCenters:n.kLineCenters,kBarRects:n.kBarRects,kWidth:o,kGap:s,dpr:c,paneWidth:n.paneWidth,viewport:l,toScreen(e){return!Number.isFinite(e.index)||e.index<0?{x:-o,y:r.yAxis.priceToY(e.price)}:{x:(u+e.index*d+(d-1)/2)/c-l.scrollLeft,y:r.yAxis.priceToY(e.price)}}});if(!m||r.role!==`price`)return;let h=[...p.anchors,...m.computedAnchors??[]];if(h.length===0)return;if(h.length>=2){let e=1/0,t=-1/0;for(let n of h)Number.isFinite(n.price)&&(n.price<e&&(e=n.price),n.price>t&&(t=n.price));Number.isFinite(e)&&Number.isFinite(t)&&e!==t&&(n.yAxisRanges||=[],n.yAxisRanges.push({topY:r.yAxis.priceToY(t),bottomY:r.yAxis.priceToY(e),color:p.style?.stroke??`#2962ff`,opacity:.15}))}if(h.length>=2){let e=1/0,t=-1/0;for(let n of h)!Number.isFinite(n.index)||n.index<0||(n.index<e&&(e=n.index),n.index>t&&(t=n.index));if(Number.isFinite(e)&&Number.isFinite(t)&&e!==t){n.xAxisRanges||=[];let r=(u+e*d+(d-1)/2)/c,i=(u+t*d+(d-1)/2)/c;n.xAxisRanges.push({leftX:r,rightX:i,color:p.style?.stroke??`#2962ff`,opacity:.15})}}let g=e=>{if(e>=0&&e<i.length)return i[e]?.timestamp??null;if(i.length>=2&&e>=i.length){let t=i.length-1,n=i.length-2,r=i[t].timestamp,a=r-i[n].timestamp;return r+(e-t)*a}return null};for(let e of h){if(!Number.isFinite(e.index)||!Number.isFinite(e.price))continue;let t=e.index<0?{x:-o,y:r.yAxis.priceToY(e.price)}:{x:(u+e.index*d+(d-1)/2)/c-l.scrollLeft,y:r.yAxis.priceToY(e.price)};if(t.y>=0&&t.y<=r.height&&(n.yAxisLabels||=[],n.yAxisLabels.push({dataIndex:Math.round(e.index),price:e.price,y:t.y,style:{bgColor:p.style?.stroke??`#2962ff`,borderColor:p.style?.stroke??`#2962ff`,textColor:`#ffffff`}})),t.x>=-o&&t.x<=l.plotWidth+o){let r=e.time?typeof e.time==`string`?new Date(e.time).getTime():e.time:g(Math.round(e.index));if(!r)continue;n.xAxisLabels||=[],n.xAxisLabels.push({dataIndex:Math.round(e.index),timestamp:r,x:t.x+l.scrollLeft,style:{bgColor:p.style?.stroke??`#2962ff`,textColor:`#ffffff`}})}}}function E_(e){let t=e.store,n=e.definitions??new c_,r=e.renderers??g_();return w_(n),{name:`drawingRenderer`,version:`0.1.0`,description:`绘图渲染器(仅负责绘制形状)`,debugName:`绘图层`,paneId:e.paneId??`main`,priority:-25,draw(e){let{ctx:i,pane:a,data:o,range:s,dpr:c,paneWidth:l,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m}=e,h=e.viewport??{scrollLeft:e.scrollLeft,plotWidth:l,plotHeight:a.height},g=o,_=g.slice(s.start,s.end),v=t.getVisibleByPane(a.id);if(v.length===0)return;let y={left:0,top:0,right:h.plotWidth,bottom:a.height};i.save(),i.beginPath(),i.rect(0,0,h.plotWidth,a.height),i.clip();for(let e of v){let o=n.compute(e,{pane:a,visibleData:_,seriesData:g,range:s,kLinePositions:u,kLineCenters:d,kBarRects:f,kWidth:p,kGap:m,dpr:c,paneWidth:l,viewport:h,toScreen(e){let{startXPx:t,unitPx:n}=br(p,m,c);return!Number.isFinite(e.index)||e.index<0?{x:-p,y:a.yAxis.priceToY(e.price)}:{x:(t+e.index*n+(n-1)/2)/c-h.scrollLeft,y:a.yAxis.priceToY(e.price)}}});if(!o)continue;let v=t.getSelectedId()===e.id?o.primitives.map(t=>O_(t,e.style)):o.primitives;for(let e of v){if(e.kind===`point`){r.point(i,e,c);continue}if(e.kind===`line`){r.line(i,e,y,c);continue}if(e.kind===`area`){r.area(i,e,c);continue}r.text(i,e,c)}}i.restore()}}}function D_(e){let t=e.store,n=e.definitions??new c_;return w_(n),{name:`drawingLabelOverlay`,version:`0.1.0`,description:`绘图轴标签渲染器(overlay 层,负责推送选中绘图的轴标签)`,debugName:`绘图标签层`,paneId:e.paneId??`main`,layer:`overlay`,priority:-24,draw(e){let{pane:r,data:i,range:a,dpr:o,paneWidth:s,kWidth:c,kGap:l}=e,u=e.viewport??{scrollLeft:e.scrollLeft,plotWidth:s,plotHeight:r.height},d=i,{startXPx:f,unitPx:p}=br(c,l,o);T_(t,n,e,r,d,a,c,l,o,u,f,p)}}}function O_(e,t){let n=t.stroke??`#2962ff`,r=(t.strokeWidth??1)+1,i=(t.pointRadius??4)+2;return e.kind===`point`?{...e,style:{...e.style,stroke:n,pointRadius:i}}:e.kind===`line`?{...e,style:{...e.style,stroke:n,strokeWidth:r}}:e.kind===`area`?{...e,style:{...e.style,stroke:n}}:{...e,style:{...e.style,textColor:n,fontSize:(e.style?.fontSize??12)+1}}}function k_(){return{name:`gridLines`,version:`1.0.0`,description:`网格线渲染器`,debugName:`网格线`,paneId:Yo,priority:J.GRID,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,dpr:s,kLinePositions:c,settings:l}=e,u=V(e.theme),d=r;if(!d.length||l?.showGridLines===!1)return;t.save(),t.fillStyle=u.GRID.HORIZONTAL,t.translate(-a,0);let f=t.canvas.width/s,p=a,m=a+f,h=n.yAxis.getPaddingTop(),g=n.yAxis.getPaddingBottom(),_=n.yAxis.getScaleType(),v;if(_===`log`&&n.role===`price`){let e=n.yAxis.getDisplayRange(n.priceRange);v=Mg({height:n.height,paddingTop:h,paddingBottom:g,isMain:!0,valueMin:e.minPrice,valueMax:e.maxPrice,scaleType:`log`}).map(e=>e.y)}else v=wg({height:n.height,paddingTop:h,paddingBottom:g,isMain:n.role===`price`}).map(e=>e.y);for(let e of v){let n=js(p,m,e,s);n&&t.fillRect(n.x,n.y,n.width,n.height)}let y=Ce(d);for(let e of y){if(e<i.start||e>=i.end||e>=d.length)continue;let r=e-i.start;if(r<0||r>=c.length)continue;let a=As(c[r]+o/2,0,n.height,s);a&&t.fillRect(a.x,a.y,a.width,a.height)}t.restore()}}}function A_(e){return e.open>e.close?`down`:e.open<e.close?`up`:`flat`}var $=function(e){return e.RISE_WITH_VOLUME=`rise_with_volume`,e.RISE_WITHOUT_VOLUME=`rise_without_volume`,e.FALL_WITH_VOLUME=`fall_with_volume`,e.FALL_WITHOUT_VOLUME=`fall_without_volume`,e.OTHERS=`others`,e}({}),j_={volumeAmplifyThreshold:1.5,volumeShrinkThreshold:.8,avgPeriod:20},M_=class{prefixSum=[];dataLength=0;build(e){let t=e.length;if(t===0){this.prefixSum=[],this.dataLength=0;return}this.prefixSum=[0];for(let n=0;n<t;n++)this.prefixSum.push(this.prefixSum[n]+(e[n]?.volume??0));this.dataLength=t}query(e,t){return e<0||t>=this.dataLength||e>t?0:this.prefixSum[t+1]-this.prefixSum[e]}getVolumeMA(e,t){if(e<t-1)return 0;let n=e-t+1;return this.query(n,e)/t}get length(){return this.dataLength}};function N_(e,t,n,r=j_){let i=new M_;i.build(e);let a=[],{volumeAmplifyThreshold:o,volumeShrinkThreshold:s,avgPeriod:c}=r;for(let r=t;r<n&&r<e.length;r++){let t=e[r]?.volume;if(r<1||!t){a.push($.OTHERS);continue}let n=i.getVolumeMA(r,c),l=e[r];if(!l){a.push($.OTHERS);continue}let u=l.close-l.open,d=u>0,f=u<0,p=t>n*o,m=t<n*s;d&&p?a.push($.RISE_WITH_VOLUME):d&&m?a.push($.RISE_WITHOUT_VOLUME):f&&p?a.push($.FALL_WITH_VOLUME):f&&m?a.push($.FALL_WITHOUT_VOLUME):a.push($.OTHERS)}return a}function P_(){return{name:`candle`,version:`1.0.0`,description:`K线蜡烛图渲染器`,debugName:`K线`,paneId:`main`,priority:J.MAIN,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,kLinePositions:l,markerManager:u,settings:d}=e,f=V(e.theme),p=r;if(!p.length)return;let m=F_({pane:n,data:p,range:i,kWidth:o,kGap:s,dpr:c,kLinePositions:l,settings:d});L_(e,m,f.PRICE)?R_(t,e):I_(t,a,m,f.PRICE),z_(e,m,u)}}}function F_(e){let{pane:t,data:n,range:r,kWidth:i,kGap:a,dpr:o,kLinePositions:s,settings:c}=e,{kWidthPx:l}=br(i,a,o),u=c?.showVolumePriceMarkers!==!1,d=u?N_(n,r.start,r.end,j_):null,f=[],p=[],m=Math.max(1,r.end-r.start),h=new Float32Array(m*4),g=new Float32Array(m*4),_=new Float32Array(m*2*4),v=new Float32Array(m*2*4),y=0,b=0,x=0,S=0,{maxPrice:C,minPrice:w}=t.yAxis.getDisplayRange(),T=t.yAxis.getPaddingTop(),E=t.yAxis.getPaddingBottom(),D=Math.max(1,t.height-T-E),O=t.yAxis.getScaleType()!==`log`,k;if(O){let e=D/(C-w||1),t=T+D;k=n=>t-(n-w)*e}else k=e=>t.yAxis.priceToY(e);for(let e=r.start;e<r.end&&e<n.length;e++){let t=n[e];if(!t)continue;let i=k(t.open),a=k(t.close),c=k(t.high),u=k(t.low),d=s[e-r.start];if(d===void 0)continue;let m=e=>Math.round(e*o)/o,C=m(i),w=m(a),T=m(c),E=m(u),D=Math.min(C,w),O=Math.max(Math.abs(C-w),1),A=Ms(Math.round(d*o),D,l,O,o),j=A_(t),M={i:e,aligned:A,trend:j,openY:i,closeY:a,highY:c,lowY:u,alignedHighY:T,alignedLowY:E,e:t},N=A.bodyRect,P=j===`up`?f:p,F=j===`up`;if(P.push(M),F){let e=y++*4;h[e]=N.x,h[e+1]=N.y,h[e+2]=N.width,h[e+3]=N.height}else{let e=b++*4;g[e]=N.x,g[e+1]=N.y,g[e+2]=N.width,g[e+3]=N.height}let I=N.y,L=N.y+N.height,ee=Math.max(t.open,t.close),R=Math.min(t.open,t.close);if(t.high>ee){let e=As(A.wickRect.x,T,I,o);if(e){let t=F?_:v,n=(F?x++:S++)*4;t[n]=e.x,t[n+1]=e.y,t[n+2]=e.width,t[n+3]=e.height}}if(t.low<R){let e=As(A.wickRect.x,L,E,o);if(e){let t=F?_:v,n=(F?x++:S++)*4;t[n]=e.x,t[n+1]=e.y,t[n+2]=e.width,t[n+3]=e.height}}}let A=f[0]?.aligned.wickRect.width??p[0]?.aligned.wickRect.width??1;return{upKLines:f,downKLines:p,upBodyBuf:h,upBodyCount:y,downBodyBuf:g,downBodyCount:b,upWickBuf:_,upWickCount:x,downWickBuf:v,downWickCount:S,wickWidth:A,relations:d,showVolumePriceMarkers:u}}function I_(e,t,n,r){e.save(),e.translate(-t,0),e.fillStyle=r.UP;for(let t=0;t<n.upBodyCount;t++){let r=t*4;e.fillRect(n.upBodyBuf[r],n.upBodyBuf[r+1],n.upBodyBuf[r+2],n.upBodyBuf[r+3])}e.fillStyle=r.DOWN;for(let t=0;t<n.downBodyCount;t++){let r=t*4;e.fillRect(n.downBodyBuf[r],n.downBodyBuf[r+1],n.downBodyBuf[r+2],n.downBodyBuf[r+3])}e.fillStyle=r.UP;for(let t=0;t<n.upWickCount;t++){let r=t*4;e.fillRect(n.upWickBuf[r],n.upWickBuf[r+1],n.wickWidth,n.upWickBuf[r+3])}e.fillStyle=r.DOWN;for(let t=0;t<n.downWickCount;t++){let r=t*4;e.fillRect(n.downWickBuf[r],n.downWickBuf[r+1],n.wickWidth,n.downWickBuf[r+3])}e.restore()}function L_(e,t,n){if(e.settings?.enableWebGLRendering===!1)return!1;let r=e.candleWebGLSurface;if(!r||!r.isAvailable())return!1;r.clear();let i=t.upBodyCount===0||r.drawRectBuffer(t.upBodyBuf.subarray(0,t.upBodyCount*4),t.upBodyCount,n.UP,e.scrollLeft),a=t.downBodyCount===0||r.drawRectBuffer(t.downBodyBuf.subarray(0,t.downBodyCount*4),t.downBodyCount,n.DOWN,e.scrollLeft),o=t.upWickCount===0||r.drawRectBuffer(t.upWickBuf.subarray(0,t.upWickCount*4),t.upWickCount,n.UP,e.scrollLeft),s=t.downWickCount===0||r.drawRectBuffer(t.downWickBuf.subarray(0,t.downWickCount*4),t.downWickCount,n.DOWN,e.scrollLeft);return i&&a&&o&&s}function R_(e,t){let n=t.candleWebGLSurface;n&&n.compositeTo(e)}function z_(e,t,n){let{ctx:r,range:i,kWidth:a,dpr:o}=e,s=V(e.theme);if(!(!t.showVolumePriceMarkers||!n||(e.zoomLevel??1)<2)){r.save(),r.translate(-e.scrollLeft,0);for(let c of t.upKLines){let l=t.relations?.[c.i-i.start];if(l!==void 0&&l!==$.OTHERS){let t=l===$.RISE_WITH_VOLUME||l===$.RISE_WITHOUT_VOLUME?c.alignedHighY-15:c.alignedLowY+15,u=c.i-i.start,d=e.kLineCenters[u];B_(r,d,t,l,c.i,a,4,n,o,s.VOLUME_PRICE)}}for(let c of t.downKLines){let l=t.relations?.[c.i-i.start];if(l!==void 0&&l!==$.OTHERS){let t=l===$.RISE_WITH_VOLUME||l===$.RISE_WITHOUT_VOLUME?c.alignedHighY-15:c.alignedLowY+15,u=c.i-i.start,d=e.kLineCenters[u];B_(r,d,t,l,c.i,a,4,n,o,s.VOLUME_PRICE)}}r.restore()}}function B_(e,t,n,r,i,a,o=4,s,c,l){let u=e=>Math.round(e*c)/c;t=u(t),n=u(n);let d=Math.min(a,20),f=d*Math.sqrt(3)/2,p,m;switch(r){case $.RISE_WITH_VOLUME:p=l.RISE_WITH,m=!0;break;case $.RISE_WITHOUT_VOLUME:p=l.RISE_WITHOUT,m=!0;break;case $.FALL_WITH_VOLUME:p=l.FALL_WITH,m=!1;break;case $.FALL_WITHOUT_VOLUME:p=l.FALL_WITHOUT,m=!1;break;default:return}if(e.save(),e.beginPath(),m){let r=u(n-o),i=u(r-f);e.moveTo(t,i),e.lineTo(u(t-d/2),r),e.lineTo(u(t+d/2),r)}else{let r=u(n+o),i=u(r+f);e.moveTo(t,i),e.lineTo(u(t-d/2),r),e.lineTo(u(t+d/2),r)}e.closePath(),e.fillStyle=p,e.fill(),e.restore();let h,g;if(m){let e=u(u(n-o)-f);h=u(t-d/2),g=e}else{let e=u(n+o);u(e+f),h=u(t-d/2),g=e}let _;switch(r){case $.RISE_WITH_VOLUME:_=`RISE_WITH_VOLUME`;break;case $.RISE_WITHOUT_VOLUME:_=`RISE_WITHOUT_VOLUME`;break;case $.FALL_WITH_VOLUME:_=`FALL_WITH_VOLUME`;break;case $.FALL_WITHOUT_VOLUME:_=`FALL_WITHOUT_VOLUME`;break;default:return}let v=`mk_price-volume_${i}`;s.register({id:v,type:`triangle`,markerType:_,x:h,y:g,width:d,height:f,dataIndex:i,metadata:{relation:r}})}function V_(e){let{pane:t,data:n}=e,r=n,i=r[r.length-1];if(!i)return null;let a=t.yAxis.getDisplayRange(t.priceRange);return i.close<a.minPrice||i.close>a.maxPrice?null:{price:i.close,y:Math.round(t.yAxis.priceToY(i.close)),dataIndex:r.length-1}}function H_(){return{name:`lastPriceLabelRegistrar`,version:`1.0.0`,description:`最新价 label 注册`,debugName:`最新价标签注册`,paneId:`main`,layer:`overlay`,priority:J.LAST_PRICE_LABEL,draw(e){let t=V(e.theme),n=V_(e);n&&(e.yAxisLabels||=[],e.yAxisLabels.push({dataIndex:n.dataIndex,price:n.price,y:n.y,type:`lastPrice`,style:{bgColor:t.LAST_PRICE_LABEL.BG,borderColor:t.PRICE.LAST_PRICE,textColor:t.PRICE.LAST_PRICE}}))}}}function U_(){return{name:`lastPriceLine`,version:`1.0.0`,description:`最新价虚线渲染器`,debugName:`最新价线`,paneId:`main`,priority:J.LAST_PRICE_LABEL,draw(e){let{ctx:t,scrollLeft:n,dpr:r,kLinePositions:i,paneWidth:a}=e,o=V(e.theme),s=V_(e);if(!s)return;let c=s.y;t.save(),t.translate(-n,0);let l=i[0]??0,u=a+n;t.strokeStyle=o.PRICE.LAST_PRICE,t.lineWidth=1,t.setLineDash([4,3]),t.beginPath();let d=(Math.floor(c*r)+.5)/r;t.moveTo(Math.round(l*r)/r,d),t.lineTo(Math.round(u*r)/r,d),t.stroke(),t.setLineDash([]),t.restore()}}}var W_=1.2,G_=24,K_=6;function q_(e){switch(e){case`arrow_up`:case`flag`:return!0;default:return!1}}function J_(){return{name:`customMarkers`,version:`1.0.0`,description:`自定义标记渲染器`,debugName:`自定义标记`,paneId:Yo,priority:J.OVERLAY,draw(e){let{ctx:t,pane:n,data:r,range:i,scrollLeft:a,kWidth:o,kLineCenters:s,dpr:c,markerManager:l,zoomLevel:u}=e;if(!l||(u??1)<2)return;let d=l.getCustomMarkers();if(!d||d.length===0)return;let f=r;if(f.length&&n.role===`price`){t.save(),t.translate(-a,0);for(let e of d){let r=X_(f,e.timestamp);if(r===-1||r<i.start||r>=i.end)continue;let u=r-i.start;if(u<0||u>=s.length)continue;let d=s[u],p=f[r],m=e.style?.size,h=Y_(o,m),g=(e.offset?.y??0)<0?!0:(e.offset?.y??0)>0?!1:q_(e.shape),_;_=g?n.yAxis.priceToY(p.high)-h/2-4+(e.offset?.y??0):n.yAxis.priceToY(p.low)+h/2+4+(e.offset?.y??0);let v=d+(e.offset?.x??0),y=_,b=v,x=y,S=Math.round(h*c/2)*2/c;F(t,e.shape,b,x,S,e.style||{}),e.label&&ee(t,e.label,b,x,S,e.style||{},g),l.setCustomMarkerPosition(e.id,b-a,x,S,e.shape)}t.restore()}}}}function Y_(e,t){let n=e*W_;return Math.max(K_,Math.min(n,t??G_))}function X_(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=e[i]?.timestamp;if(a===void 0)break;if(a===t)return i;a<t?n=i+1:r=i-1}return-1}function Z_(e){return{name:`yAxis`,version:`1.0.0`,description:`Y轴价格刻度渲染器`,debugName:`Y轴`,paneId:Yo,priority:J.SYSTEM_YAXIS,draw(t){let{ctx:n,pane:r,dpr:i,yAxisCtx:a,data:o}=t,s=V(t.theme),c=r.yAxis.getScaleType(),l=a||n,u=a?.canvas?a.canvas.width/i:e.axisWidth,d=r.yAxis.getDisplayRange(r.priceRange);if(r.capabilities.showPriceAxisTicks&&Wg({colors:s,ctx:l,dpr:i,axisWidth:u,height:r.height,paddingTop:r.yAxis.getPaddingTop(),paddingBottom:r.yAxis.getPaddingBottom(),valueMin:d.minPrice,valueMax:d.maxPrice,isMain:!0,decimals:2,hideEdgeTicks:!1,scaleType:c}),t.yAxisRanges&&r.role===`price`)for(let e of t.yAxisRanges){let t=e.topY+r.top,n=e.bottomY-e.topY;n<=0||(l.save(),l.globalAlpha=e.opacity,l.fillStyle=e.color,l.fillRect(0,t,u,n),l.restore())}if(t.yAxisLabels&&r.role===`price`)for(let e of t.yAxisLabels){let t=e.type===`lastPrice`;Bg(l,{x:0,y:r.top,width:u,height:r.height,priceY:e.y+r.top,price:e.price,dpr:i,bgColor:e.style?.bgColor??`rgba(0, 0, 0, 0.8)`,borderColor:e.style?.borderColor,textColor:e.style?.textColor??`#ffffff`,fontSize:t?12:11})}let f=e.getCrosshair?.();f&&f.activePaneId===r.id&&f.price!==null&&Rg(l,{x:0,y:r.top,width:u,height:r.height,crosshairY:f.y,priceRange:d,yPaddingPx:e.yPaddingPx,dpr:i,fontSize:12,priceOffset:0,price:f.price})}}}function Q_(e){return{name:`crosshair`,version:`1.0.0`,description:`十字线渲染器`,debugName:`十字线`,paneId:Yo,priority:J.SYSTEM_CROSSHAIR,layer:`overlay`,draw(t){let{pane:n,dpr:r,paneWidth:i,overlayCtx:a}=t,o=V(t.theme),s=e.getCrosshairState();if(s.isDragging||!s.pos)return;let{x:c}=s.pos,l=n.id===s.activePaneId,u=-1;l&&s.price!==null&&(u=n.yAxis.priceToY(s.price));let d=a;if(!d)return;d.save(),d.beginPath(),d.rect(0,0,i,n.height),d.clip(),d.fillStyle=o.CROSSHAIR.LINE;let f=As(c,0,n.height,r);if(f&&d.fillRect(f.x,f.y,f.width,f.height),l&&u>=0){let e=js(0,i,Math.min(u,n.height-1/r),r);e&&d.fillRect(e.x,e.y,e.width,e.height)}d.restore()}}}var $_=Symbol(`time-axis`);function ev(e){return{name:`timeAxis`,version:`1.0.0`,description:`时间轴渲染器`,debugName:`时间轴`,paneId:$_,priority:J.SYSTEM_XAXIS,isSystem:!0,draw(t){let{ctx:n,data:r,range:i,scrollLeft:a,kWidth:o,kGap:s,dpr:c,paneWidth:l}=t,u=V(t.theme),d=r,f=n,p=l,m=e.height;if(f.setTransform(1,0,0,1,0,0),f.scale(c,c),f.clearRect(0,0,p,m),zg(f,{x:0,y:0,width:p,height:m,data:d,scrollLeft:a,kWidth:o,kGap:s,startIndex:i.start,endIndex:i.end,dpr:c,textColor:u.TEXT.SECONDARY,lineColor:u.BORDER.DARK,drawTopBorder:!1,drawBottomBorder:!1}),t.xAxisRanges)for(let e of t.xAxisRanges){let t=e.leftX-a,n=e.rightX-a-t;n<=0||(f.save(),f.globalAlpha=e.opacity,f.fillStyle=e.color,f.fillRect(t,0,n,m),f.restore())}let h=e.getCrosshair?.();if(h&&typeof h.index==`number`){let e=d[h.index];e&&Lg(f,{x:0,y:0,width:p,height:m,crosshairX:h.x,timestamp:e.timestamp,dpr:c,fontSize:12,bgColor:u.CROSSHAIR.LABEL_BG,textColor:u.CROSSHAIR.LABEL_TEXT})}if(t.xAxisLabels)for(let e of t.xAxisLabels){let t=e.x-a;t>=0&&t<=p&&Vg(f,{x:0,y:0,width:p,height:m,labelX:t,timestamp:e.timestamp,dpr:c,fontSize:12,bgColor:e.style?.bgColor,textColor:e.style?.textColor})}}}}var tv=class{dom;opt;_internalData=[];raf=null;pendingUpdateLevel=U.All;_internalViewport=null;paneRenderers=[];markerManager;drawingStore=new s_;interaction;pluginHost;rendererPluginManager;preciseDpr=0;resizeObserver;onScroll;observedSize={width:0,height:0};cachedScrollLeft=0;overlayHadCrosshair=!1;settings={};_internalPaneRatios=new Map;onViewportChange;xAxisCtx=null;sharedWebGLSurface;onPaneLayoutChange;onDataChange;currentZoomLevel=1;zoomLevelCount;indicatorScheduler;lastVisibleRange={start:0,end:0};cachedDrawFrame=null;subPaneManager;activeMainIndicators=new Set;mainIndicatorParams={MA:{ma5:!0,ma10:!0,ma20:!0,ma30:!0,ma60:!0},BOLL:{period:20,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0,showBand:!0},EXPMA:{fastPeriod:12,slowPeriod:50},ENE:{period:10,deviation:11},WMA:{period:10,showWMA:!0},DEMA:{period:14,showDEMA:!0},TEMA:{period:14,showTEMA:!0},HMA:{period:14,showHMA:!0},KAMA:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},SAR:{step:.02,maxStep:.2,showSAR:!0},SUPERTREND:{atrPeriod:10,multiplier:3,showSuperTrend:!0},KELTNER:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},DONCHIAN:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},ICHIMOKU:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showChikou:!0,showCloud:!0},PIVOT:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},FIB:{period:50,showLevels:!0},STRUCTURE:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},ZONES:{showFVG:!0,showOB:!0,showFilledZones:!1,obLookback:5}};enableMainIndicator(e,t){let n=e.toUpperCase();return[`MA`,`BOLL`,`EXPMA`,`ENE`,`WMA`,`DEMA`,`TEMA`,`HMA`,`KAMA`,`SAR`,`SUPERTREND`,`KELTNER`,`DONCHIAN`,`ICHIMOKU`,`PIVOT`,`FIB`,`STRUCTURE`,`ZONES`].includes(n)?this.activeMainIndicators.has(n)?(t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t},this.updateIndicatorSchedulerConfig(n),this.syncIndicatorsSignal()),!0):(this.activeMainIndicators.add(n),t&&(this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t}),this.enableMainIndicatorRenderer(n),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw(),this.syncIndicatorsSignal(),!0):(console.warn(`[Chart] 未知的主图指标: ${e}`),!1)}disableMainIndicator(e){let t=e.toUpperCase();return this.activeMainIndicators.has(t)?(this.activeMainIndicators.delete(t),this.disableMainIndicatorRenderer(t),this.updateIndicatorSchedulerConfig(t),this.scheduleDraw(),this.syncIndicatorsSignal(),!0):!1}toggleMainIndicator(e,t){t?this.enableMainIndicator(e):this.disableMainIndicator(e)}getActiveMainIndicators(){return Array.from(this.activeMainIndicators)}isMainIndicatorActive(e){return this.activeMainIndicators.has(e.toUpperCase())}updateMainIndicatorParams(e,t){let n=e.toUpperCase();this.mainIndicatorParams[n]||(this.mainIndicatorParams[n]={}),this.mainIndicatorParams[n]={...this.mainIndicatorParams[n],...t};let r=n.toLowerCase(),i=this.getRenderer(r);i&&i.setConfig&&i.setConfig(this.mainIndicatorParams[n]),this.updateIndicatorSchedulerConfig(n),this.scheduleDraw(),this.syncIndicatorsSignal()}getMainIndicatorParams(e){return this.mainIndicatorParams[e.toUpperCase()]??null}clearMainIndicators(){for(let e of this.activeMainIndicators)this.disableMainIndicatorRenderer(e);this.activeMainIndicators.clear(),this.scheduleDraw(),this.syncIndicatorsSignal()}enableMainIndicatorRenderer(e){let t={MA:()=>{this.getRenderer(`ma`)||this.useRenderer(ks()),this.setRendererEnabled(`ma`,!0)},BOLL:()=>{this.getRenderer(`boll`)||this.useRenderer(Js()),this.setRendererEnabled(`boll`,!0)},EXPMA:()=>{this.getRenderer(`expma`)||this.useRenderer(ac()),this.setRendererEnabled(`expma`,!0)},ENE:()=>{this.getRenderer(`ene`)||this.useRenderer(bc()),this.setRendererEnabled(`ene`,!0)},WMA:()=>{this.getRenderer(`wma_main`)||this.useRenderer(Hu({paneId:`main`})),this.setRendererEnabled(`wma_main`,!0)},DEMA:()=>{this.getRenderer(`dema_main`)||this.useRenderer($u({paneId:`main`})),this.setRendererEnabled(`dema_main`,!0)},TEMA:()=>{this.getRenderer(`tema_main`)||this.useRenderer(ud({paneId:`main`})),this.setRendererEnabled(`tema_main`,!0)},HMA:()=>{this.getRenderer(`hma_main`)||this.useRenderer(xd({paneId:`main`})),this.setRendererEnabled(`hma_main`,!0)},KAMA:()=>{this.getRenderer(`kama_main`)||this.useRenderer(Md({paneId:`main`})),this.setRendererEnabled(`kama_main`,!0)},SAR:()=>{this.getRenderer(`sar_main`)||this.useRenderer(Kd({paneId:`main`})),this.setRendererEnabled(`sar_main`,!0)},SUPERTREND:()=>{this.getRenderer(`supertrend_main`)||this.useRenderer(af({paneId:`main`})),this.setRendererEnabled(`supertrend_main`,!0)},KELTNER:()=>{this.getRenderer(`keltner_main`)||this.useRenderer(vf({paneId:`main`})),this.setRendererEnabled(`keltner_main`,!0)},DONCHIAN:()=>{this.getRenderer(`donchian_main`)||this.useRenderer(Mf({paneId:`main`})),this.setRendererEnabled(`donchian_main`,!0)},ICHIMOKU:()=>{this.getRenderer(`ichimoku_main`)||this.useRenderer(Xf({paneId:`main`})),this.setRendererEnabled(`ichimoku_main`,!0)},PIVOT:()=>{this.getRenderer(`pivot_main`)||this.useRenderer(Eh({paneId:`main`})),this.setRendererEnabled(`pivot_main`,!0)},FIB:()=>{this.getRenderer(`fib_main`)||this.useRenderer(Rh({paneId:`main`})),this.setRendererEnabled(`fib_main`,!0)},STRUCTURE:()=>{this.getRenderer(`structure_main`)||this.useRenderer(Xh({paneId:`main`})),this.setRendererEnabled(`structure_main`,!0)},ZONES:()=>{this.getRenderer(`zones_main`)||this.useRenderer(og({paneId:`main`})),this.setRendererEnabled(`zones_main`,!0)}}[e];t&&t(),this.getRenderer(`mainIndicatorLegend`)||this.useRenderer(Oc({yPaddingPx:this.opt.yPaddingPx}))}disableMainIndicatorRenderer(e){let t={MA:`ma`,BOLL:`boll`,EXPMA:`expma`,ENE:`ene`,WMA:`wma_main`,DEMA:`dema_main`,TEMA:`tema_main`,HMA:`hma_main`,KAMA:`kama_main`,SAR:`sar_main`,SUPERTREND:`supertrend_main`,KELTNER:`keltner_main`,DONCHIAN:`donchian_main`,ICHIMOKU:`ichimoku_main`,PIVOT:`pivot_main`,FIB:`fib_main`,STRUCTURE:`structure_main`,ZONES:`zones_main`}[e];t&&this.setRendererEnabled(t,!1)}updateIndicatorSchedulerConfig(e){let t=this.activeMainIndicators.has(e),n=this.mainIndicatorParams[e]||{};switch(e){case`MA`:this.indicatorScheduler.updateMAConfig({ma5:t,ma10:t,ma20:t,ma30:t,ma60:t});break;case`BOLL`:t?this.indicatorScheduler.updateBOLLConfig(n):this.indicatorScheduler.updateBOLLConfig({...n,showUpper:!1,showMiddle:!1,showLower:!1,showBand:!1});break;case`EXPMA`:t&&this.indicatorScheduler.updateEXPMAConfig(n);break;case`ENE`:t&&this.indicatorScheduler.updateENEConfig(n);break;case`WMA`:this.indicatorScheduler.updateWMAConfig({...n,showWMA:t},`main`);break;case`DEMA`:this.indicatorScheduler.updateDEMAConfig({...n,showDEMA:t},`main`);break;case`TEMA`:this.indicatorScheduler.updateTEMAConfig({...n,showTEMA:t},`main`);break;case`HMA`:this.indicatorScheduler.updateHMAConfig({...n,showHMA:t},`main`);break;case`KAMA`:this.indicatorScheduler.updateKAMAConfig({...n,showKAMA:t},`main`);break;case`SAR`:this.indicatorScheduler.updateSARConfig({...n,showSAR:t},`main`);break;case`SUPERTREND`:this.indicatorScheduler.updateSuperTrendConfig({...n,showSuperTrend:t},`main`);break;case`KELTNER`:this.indicatorScheduler.updateKeltnerConfig({...n,showUpper:t,showMiddle:t,showLower:t},`main`);break;case`DONCHIAN`:this.indicatorScheduler.updateDonchianConfig({...n,showUpper:t,showMiddle:t,showLower:t},`main`);break;case`ICHIMOKU`:this.indicatorScheduler.updateIchimokuConfig({...n,showTenkan:t,showKijun:t,showSpanA:t,showSpanB:t,showChikou:t,showCloud:t},`main`);break;case`PIVOT`:this.indicatorScheduler.updatePivotConfig({...n,showPP:t,showR1:t,showR2:t,showR3:t,showS1:t,showS2:t,showS3:t},`main`);break;case`FIB`:this.indicatorScheduler.updateFibConfig({...n,showLevels:t},`main`);break;case`STRUCTURE`:this.indicatorScheduler.updateStructureConfig({...n,showSwingLabels:t,showBOS:t,showCHOCH:t},`main`);break;case`ZONES`:this.indicatorScheduler.updateZonesConfig({...n,showFVG:t,showOB:t,showFilledZones:t},`main`);break}}setActiveMainIndicators(e){let t=new Set(e.map(e=>e.toUpperCase())),n=new Set(this.activeMainIndicators);for(let e of n)t.has(e)||this.disableMainIndicator(e);for(let e of t)n.has(e)||this.enableMainIndicator(e)}constructor(e,t){this.dom=e;let{kWidth:n,kGap:r,...i}=t;this.opt={...i,kWidth:n??0,kGap:r??0},this.interaction=new Pr(this),this.interaction.setOnInteractionChange(e=>{this._interactionSignal.set(e)}),this.markerManager=new Vt,this.pluginHost=ts(),this.rendererPluginManager=new rs,this.sharedWebGLSurface=new Jr,this.rendererPluginManager.setPluginHost(this.pluginHost),this.rendererPluginManager.setInvalidateCallback(()=>this.scheduleDraw()),this.syncPaneRatiosFromSpecs(this.opt.panes),this.zoomLevelCount=Math.max(2,Math.round(this.opt.zoomLevels??20)),this.currentZoomLevel=this.opt.initialZoomLevel??1,this.currentZoomLevel=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel)),this.indicatorScheduler=new Wo,this.indicatorScheduler.setPluginHost(this.pluginHost);for(let e of Ko())this.indicatorScheduler.registerIndicator(e);this.indicatorScheduler.setInvalidateCallback(()=>this.scheduleDraw()),this.subPaneManager=new n_,this.indicatorScheduler.setActiveSubPaneProvider(()=>this.subPaneManager.getPaneIds()),this.initPanes(),this.useRenderer(E_({store:this.drawingStore})),this.useRenderer(D_({store:this.drawingStore})),this.initCoreRenderers(),this.initResizeObserver()}initCoreRenderers(){let e=this.opt.rightAxisWidth+(this.opt.priceLabelWidth??0);this.useRenderer(k_()),this.useRenderer(P_()),this.useRenderer(U_()),this.useRenderer(H_()),this.useRenderer(J_()),this.useRenderer(Oc({yPaddingPx:this.opt.yPaddingPx})),this.useRenderer(Z_({axisWidth:e,yPaddingPx:this.opt.yPaddingPx,getCrosshair:()=>{let e=this.interaction.crosshairPos,t=this.interaction.crosshairPrice,n=this.interaction.activePaneId;return e&&t!==null?{y:e.y,price:t,activePaneId:n}:null}})),this.useRenderer(Q_({getCrosshairState:()=>({pos:this.interaction.crosshairPos,activePaneId:this.interaction.activePaneId,isDragging:this.interaction.isDraggingState(),price:this.interaction.crosshairPrice})})),this.useRenderer(ev({height:this.opt.bottomAxisHeight,getCrosshair:()=>{let e=this.interaction.crosshairPos,t=this.interaction.crosshairIndex;return e&&t!==null?{x:e.x,index:t}:null}}))}initResizeObserver(){if(typeof ResizeObserver>`u`)return;let e=this.dom.container;if(e){this.cachedScrollLeft=e.scrollLeft,this.onScroll=()=>{this.cachedScrollLeft=e.scrollLeft},e.addEventListener(`scroll`,this.onScroll,{passive:!0}),this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let n=this.observedSize.width,r=this.observedSize.height,i=this.preciseDpr;this.updateObservedMetrics(t);let a=this.observedSize.width!==n,o=this.observedSize.height!==r,s=this.preciseDpr!==i;(a||o||s)&&this.resize()});try{this.resizeObserver.observe(e,{box:`device-pixel-content-box`})}catch{this.resizeObserver.observe(e)}}}updateObservedMetrics(e){let t=Math.max(1,Math.round(e.contentRect.width)),n=Math.max(1,Math.round(e.contentRect.height));this.observedSize.width=t,this.observedSize.height=n;let r=e.devicePixelContentBoxSize?.[0],i=e.contentBoxSize?.[0];if(!r||!i||i.inlineSize<=0){this.preciseDpr=0;return}let a=r.inlineSize/i.inlineSize;this.preciseDpr=Math.round(a*64)/64}getEffectiveDpr(){let e=this.preciseDpr>0?this.preciseDpr:Math.round((window.devicePixelRatio||1)*64)/64;return e<1&&(e=1),e}getViewport(){return this._internalViewport}getCurrentDpr(){return this.getEffectiveDpr()}getCachedScrollLeft(){return this.cachedScrollLeft}get plugin(){return this.pluginHost}useRenderer(e,t){this.rendererPluginManager.register(e),t&&e.setConfig&&e.setConfig(t)}removeRenderer(e){this.rendererPluginManager.unregister(e)}getRenderer(e){return this.rendererPluginManager.getPlugin(e)}updateRendererConfig(e,t){this.rendererPluginManager.updateConfig(e,t)}setRendererEnabled(e,t){this.rendererPluginManager.setEnabled(e,t)}getAllRenderers(){return this.rendererPluginManager.getAllPlugins()}updateSettings(e){this.settings={...e},this.interaction.updateSettings(e);let t=e.logarithmicScale?`log`:`linear`;for(let e of this.paneRenderers)e.getPane().yAxis.setScaleType(t);this.scheduleDraw()}draw(e=U.All){this.markerManager.clear();let t=this.prepareFrameData(e);if(!t)return;let{vp:n,range:r,kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s,useCachedFrame:c}=t;this.interaction.setKLinePositions(i,r,s),this.indicatorScheduler.setActiveMainIndicators(Array.from(this.activeMainIndicators));let l=c?null:this.indicatorScheduler.getMainIndicatorPriceRange(),u=this.interaction.getCrosshairIndex()!==null,{sharedXAxisLabels:d,sharedXAxisRanges:f}=this.renderPanes(n,r,i,a,o,s,l,u,c,e);this.overlayHadCrosshair=u,this.renderXAxis(n,r,i,a,o,s,d,f)}prepareFrameData(e){let t=e===U.Overlay&&this.cachedDrawFrame!==null,n=t?this.cachedDrawFrame.viewport:this.computeViewport();if(!n||this._internalData.length===0)return null;let r=t?this.cachedDrawFrame.range:(()=>{let{start:e,end:t}=xr(n.scrollLeft,n.plotWidth,this.opt.kWidth,this.opt.kGap,this._internalData.length,n.dpr);return{start:e,end:t}})();!t&&(r.start!==this.lastVisibleRange.start||r.end!==this.lastVisibleRange.end)&&(this.indicatorScheduler.updateVisibleRange(r),this.lastVisibleRange=r);let i=t?this.cachedDrawFrame.kLinePositions:this.calcKLinePositions(r),a,o,s;if(t)a=this.cachedDrawFrame.kLineCenters,o=this.cachedDrawFrame.kBarRects,s=this.cachedDrawFrame.kWidthPx;else{let e=br(this.opt.kWidth,this.opt.kGap,n.dpr),t=Math.max(1,e.unitPx-1);t%2==0&&--t,a=Array(i.length),o=Array(i.length);for(let r=0;r<i.length;r++){let s=i[r],c=Math.round(s*n.dpr)+(e.kWidthPx-1)/2;a[r]=c/n.dpr;let l=c-(t-1)/2;o[r]={x:l/n.dpr,width:t/n.dpr}}s=br(this.opt.kWidth,this.opt.kGap,n.dpr).kWidthPx,this.cachedDrawFrame={viewport:{...n},range:{...r},kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s}}return{vp:n,range:r,kLinePositions:i,kLineCenters:a,kBarRects:o,kWidthPx:s,useCachedFrame:t}}renderPanes(e,t,n,r,i,a,o,s,c,l){let u=[],d=[],f=[],p=[];for(let a of this.paneRenderers){let m=a.getPane(),{mainCtx:h,overlayCtx:g,yAxisCtx:_}=a.getContexts(),{candleSurface:v,lineSurface:y}=a.getWebGL();if(!c){let e=m.role===`price`?o:null;m.updateRange(this._internalData,t,e)}let b=l===U.Main||l===U.All,x=l===U.All||l===U.Overlay&&(s||this.overlayHadCrosshair);if(b&&h&&(h.setTransform(1,0,0,1,0,0),h.scale(e.dpr,e.dpr),h.clearRect(0,0,e.plotWidth+1,m.height+2/e.dpr),v?.clear(),y?.clear()),x&&g){let t=g.canvas.width/e.dpr;g.setTransform(1,0,0,1,0,0),g.scale(e.dpr,e.dpr),g.clearRect(0,0,t+1,m.height+2/e.dpr)}if(_&&!c){let t=_.canvas.width/e.dpr;_.setTransform(1,0,0,1,0,0),_.scale(e.dpr,e.dpr),_.clearRect(0,0,t,m.height+2/e.dpr)}let S={ctx:h,overlayCtx:g??void 0,pane:Jo(m),data:this._internalData,range:t,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:n,kLineCenters:r,kBarRects:i,markerManager:this.markerManager,crosshairIndex:this.interaction.getCrosshairIndex(),yAxisCtx:_??void 0,candleWebGLSurface:v??void 0,lineWebGLSurface:y??void 0,zoomLevel:this.currentZoomLevel,zoomLevelCount:this.zoomLevelCount,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},settings:this.settings,yAxisLabels:u,xAxisLabels:d,yAxisRanges:f,xAxisRanges:p,theme:this._themeSignal.peek()};if(b||x){let e=this.rendererPluginManager.render(m.id,S,l);e.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:e});let t=this.rendererPluginManager.renderPlugin(`yAxis`,S);t.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:m.id,errors:t})}}return{sharedXAxisLabels:d,sharedXAxisRanges:p}}renderXAxis(e,t,n,r,i,a,o,s){let c=this.xAxisCtx??this.dom.xAxisCanvas.getContext(`2d`);if(this.xAxisCtx||=c,c){let a={ctx:c,pane:{id:`xAxis`,role:`auxiliary`,capabilities:{showPriceAxisTicks:!1,showCrosshairPriceLabel:!1,candleHitTest:!1,supportsPriceTranslate:!1},top:0,height:this.opt.bottomAxisHeight,yAxis:{priceToY:()=>0,yToPrice:()=>0,getPaddingTop:()=>0,getPaddingBottom:()=>0,getPriceOffset:()=>0,getDisplayRange:e=>e??{maxPrice:0,minPrice:0},getScaleType:()=>`linear`},priceRange:{maxPrice:0,minPrice:0}},data:this._internalData,range:t,scrollLeft:e.scrollLeft,kWidth:this.opt.kWidth,kGap:this.opt.kGap,dpr:e.dpr,paneWidth:e.plotWidth,kLinePositions:n,kLineCenters:r,kBarRects:i,xAxisCtx:c,viewport:{scrollLeft:e.scrollLeft,plotWidth:e.plotWidth,plotHeight:e.plotHeight},yAxisLabels:[],xAxisLabels:o,xAxisRanges:s,theme:this._themeSignal.peek()},l=this.rendererPluginManager.renderPlugin(`timeAxis`,a);l.length>0&&this.pluginHost.events.emit(`renderer:error`,{paneId:`timeAxis`,errors:l})}}applyRenderState(e,t,n){let r=n===void 0?this.currentZoomLevel:Math.max(1,Math.min(this.zoomLevelCount,n));(this.opt.kWidth!==e||this.opt.kGap!==t||this.currentZoomLevel!==r)&&(this.opt={...this.opt,kWidth:e,kGap:t},n!==void 0&&(this.currentZoomLevel=r),this.updateViewportSignal(),this.scheduleDraw())}getZoomLevelCount(){return this.zoomLevelCount}setOnViewportChange(e){this.onViewportChange=e}setOnPaneLayoutChange(e){this.onPaneLayoutChange=e}setOnDataChange(e){this.onDataChange=e}getPaneRenderers(){return this.paneRenderers}getMarkerManager(){return this.markerManager}updateCustomMarkers(e){this.markerManager.setCustomMarkers(e),this.scheduleDraw()}clearCustomMarkers(){this.markerManager.clearCustomMarkers(),this.scheduleDraw()}getDom(){return this.dom}getOption(){return this.opt}calcKLinePositions(e){let{start:t,end:n}=e,r=n-t;if(r<=0)return[];let i=this.getEffectiveDpr(),{unitPx:a,startXPx:o}=br(this.opt.kWidth,this.opt.kGap,i),s=Array(r);for(let e=0;e<r;e++)s[e]=(o+(t+e)*a)/i;return s}updateOptions(e){if(e.kWidth!==void 0&&(console.warn(`[Chart] kWidth cannot be set directly. Use applyRenderState() instead.`),delete e.kWidth),e.kGap!==void 0&&delete e.kGap,e.panes){let t=e.panes.map(e=>({...e}));this.opt={...this.opt,...e,panes:t},this.applyPaneLayoutSpecs(t);return}this.opt={...this.opt,...e},this.resize()}updatePaneLayout(e){this._internalPaneRatios.clear(),this.applyPaneLayoutSpecs(e)}setPaneDefinitions(e){this.applyPaneLayoutSpecs(e)}upsertPane(e){let t=this.opt.panes.findIndex(t=>t.id===e.id);if(t===-1){this.applyPaneLayoutSpecs([...this.opt.panes,{...e}]);return}let n=[...this.opt.panes];n[t]={...n[t],...e},this.applyPaneLayoutSpecs(n)}removePaneDefinition(e){this.opt.panes.some(t=>t.id===e)&&(this._internalPaneRatios.delete(e),this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>t.id!==e)))}bindIndicatorToPane(e,t,n){this.opt.panes.some(t=>t.id===e)||this.upsertPane({id:e,ratio:1,visible:!0,role:`indicator`});let r=`${t.toLowerCase()}_${e}`;if(this.getRenderer(r)){n&&this.updateRendererConfig(r,n);return}let i=Sg({indicatorId:t,paneId:e});this.useRenderer(i,n)}setDrawings(e){this.drawingStore.setAll(e),this._drawingsSignal.set(e),this.scheduleDraw()}setSelectedDrawingId(e){this.drawingStore.getSelectedId()!==e&&(this.drawingStore.setSelectedId(e),this.scheduleDraw())}getPaneLayoutSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this._internalPaneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;return this.opt.panes.map(e=>{let n=this._internalPaneRatios.get(e.id)??e.ratio??0,r=e.visible===!1?n:n/t,i=this.paneRenderers.find(t=>t.getPane().id===e.id)?.getPane();return{...e,ratio:r,role:i?.role??e.role,capabilities:i?{...i.capabilities}:e.capabilities}})}emitPaneLayoutChange(){let e={};this._internalPaneRatios.forEach((t,n)=>{e[n]=t}),this._paneRatiosSignal.set(e),this.syncSubPanesSignal(),this.onPaneLayoutChange?.(this.getPaneLayoutSpecs())}applyPaneLayoutSpecs(e){this.opt.panes=e.map(e=>({...e})),this.syncPaneRatiosFromSpecs(this.opt.panes),this.initPanes(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw()}resizePaneBoundary(e,t){if(!Number.isFinite(t)||t===0)return!1;let n=this._internalViewport;if(!n)return!1;let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.findIndex(t=>t.id===e);if(i<0||i>=r.length-1)return!1;let a=r[i],o=r[i+1];if(!a||!o)return!1;let s=new Map;for(let e of r){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);t&&s.set(e.id,t.getPane().height)}let c=t>0?i:i+1,l=t>0?i+1:i,u=t>0?1:-1,d=Math.abs(t),f=l;for(;d>0&&f>=0&&f<r.length;){let e=r[f];if(!e)break;let t=s.get(e.id)??0,i=this.getPaneMinHeight(e,n.plotHeight),a=Math.max(0,t-i);if(a>0){let n=Math.min(a,d);s.set(e.id,t-n),d-=n}d>0&&(f+=u)}if(d>0)return!1;let p=r[c];if(!p)return!1;let m=s.get(p.id)??0;s.set(p.id,m+Math.abs(t));let h=Math.max(0,this.opt.paneGap??0)*Math.max(0,r.length-1),g=Math.max(1,n.plotHeight-h);for(let e of r){let t=s.get(e.id)??0;this._internalPaneRatios.set(e.id,t/g)}return this.normalizeVisiblePaneRatios(r),this.syncPaneRatiosToSpecs(),this.layoutPanes(),this.emitPaneLayoutChange(),this.scheduleDraw(),!0}resolvePaneRole(e,t){return e.role?e.role:t===0?`price`:`indicator`}addPane(e){if(this.opt.panes.some(t=>t.id===e)){console.warn(`Pane "${e}" already exists`);return}let t=this.opt.panes.some((e,t)=>this.resolvePaneRole(e,t)===`price`)?`indicator`:`price`;this.applyPaneLayoutSpecs([...this.opt.panes,{id:e,ratio:1,visible:!0,role:t}])}removePane(e){if(!this.opt.panes.some(t=>t.id===e))return;let t=this.opt.panes.filter(t=>t.id!==e);this._internalPaneRatios.delete(e),this.applyPaneLayoutSpecs(t)}hasPane(e){return this.opt.panes.some(t=>t.id===e)}createSubPane(e,t,n){let r=this.opt.panes.filter(e=>e.visible!==!1),i=r.filter((e,t)=>this.resolvePaneRole(e,t)===`price`),a=r.filter((e,t)=>this.resolvePaneRole(e,t)===`indicator`);if(i.length===1){let t=i[0];t&&this._internalPaneRatios.set(t.id,3);for(let e of a)this._internalPaneRatios.set(e.id,1);this._internalPaneRatios.set(e,1)}else this._internalPaneRatios.set(e,1);this.upsertPane({id:e,ratio:this._internalPaneRatios.get(e)??1,visible:!0,role:`indicator`});let o=this.subPaneManager.create(this,e,t,n??this.getDefaultSubPaneParams(t));return this.syncIndicatorsSignal(),this.syncSubPanesSignal(),o}removeSubPane(e){this.subPaneManager.remove(this,e),this._internalPaneRatios.delete(e),this.syncIndicatorsSignal(),this.syncSubPanesSignal()}replaceSubPaneIndicator(e,t,n){this.subPaneManager.replaceIndicator(this,e,t,n??this.getDefaultSubPaneParams(t)),this.syncIndicatorsSignal(),this.syncSubPanesSignal()}updateSubPaneParams(e,t){this.subPaneManager.updateParams(this,e,t),this.syncIndicatorsSignal()}clearSubPanes(){let e=this.subPaneManager.getPaneIds();if(e.length!==0){this.subPaneManager.clear(this);for(let t of e)this._internalPaneRatios.delete(t);this.applyPaneLayoutSpecs(this.opt.panes.filter(t=>!e.includes(t.id))),this.syncIndicatorsSignal(),this.syncSubPanesSignal()}}getSubPaneIndicators(){return this.subPaneManager.getAll().map(e=>e.indicatorId)}getSubPaneEntries(){return this.subPaneManager.getAll()}getSubPaneEntry(e){return this.subPaneManager.getByPaneId(e)}getDefaultSubPaneParams(e){return{...{VOLUME:{},MACD:{fastPeriod:12,slowPeriod:26,signalPeriod:9},RSI:{period1:6,period2:12,period3:24},CCI:{period:14,showCCI:!0},STOCH:{n:9,m:3,showK:!0,showD:!0},MOM:{period:10,showMOM:!0},WMSR:{period:14,showWMSR:!0},KST:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},FASTK:{period:9,showFASTK:!0},ATR:{period:14,showATR:!0},WMA:{period:10,showWMA:!0},DEMA:{period:14,showDEMA:!0},TEMA:{period:14,showTEMA:!0},HMA:{period:14,showHMA:!0},KAMA:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},SAR:{step:.02,maxStep:.2,showSAR:!0},SUPERTREND:{atrPeriod:10,multiplier:3,showSuperTrend:!0},KELTNER:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},DONCHIAN:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},ICHIMOKU:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showChikou:!0,showCloud:!0},ROC:{period:12,showROC:!0},TRIX:{period:15,signalPeriod:9,showTRIX:!0,showSignal:!0},HV:{period:20,annualizationFactor:252,showHV:!0},PARKINSON:{period:20,annualizationFactor:252,showParkinson:!0},CHAIKIN_VOL:{emaPeriod:10,rocPeriod:10,showChaikinVol:!0},VMA:{period:5,showVMA:!0},OBV:{showOBV:!0},PVT:{showPVT:!0},VWAP:{sessionResetGapMs:0,showVWAP:!0},CMF:{period:20,showCMF:!0},MFI:{period:14,showMFI:!0},PIVOT:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},FIB:{period:50,showLevels:!0},STRUCTURE:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},ZONES:{showFVG:!0,showOB:!0,showFilledZones:!0,obLookback:5},VOLUME_PROFILE:{bins:24,lookback:0,valueAreaPercent:.7,showVolumeProfile:!0}}[e]}}static SUB_PANE_PREFIX=`sub_`;translatePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();if(!r.capabilities.supportsPriceTranslate)return;let i=r.yAxis.deltaYToPriceOffset(t),a=r.yAxis.getPriceOffset();r.yAxis.setPriceOffset(a+i),this.scheduleDraw()}resetPriceOffset(e){let t=this.paneRenderers.find(t=>t.getPane().id===e);t&&(t.getPane().yAxis.resetPriceOffset(),this.scheduleDraw())}scalePrice(e,t){let n=this.paneRenderers.find(t=>t.getPane().id===e);if(!n)return;let r=n.getPane();r.capabilities.supportsPriceTranslate&&(r.yAxis.scaleByDelta(t),this.scheduleDraw())}updateData(e){this._internalData=e??[],this._dataSignal.set([...this._internalData]),this.onDataChange?.(this._internalData);let t=this.dom.container;if(t){let e=this.getContentWidth(),n=Math.max(0,e-t.clientWidth);this.cachedScrollLeft>n&&(t.scrollLeft=n,this.cachedScrollLeft=n)}this.interaction.reset(),this.indicatorScheduler.update(this._internalData,this.lastVisibleRange),this.scheduleDraw()}getData(){return this._internalData}getIndicatorScheduler(){return this.indicatorScheduler}getTrailingSlotCount(){return 24}getLogicalSlotCount(){return this._internalData.length+this.getTrailingSlotCount()}getTimestampAtLogicalIndex(e){return!Number.isInteger(e)||e<0||e>=this._internalData.length?null:this._internalData[e]?.timestamp??null}getLogicalIndexAtX(e){let t=this._internalViewport;if(!t||this._internalData.length===0)return null;let n=this.getEffectiveDpr(),{startXPx:r,unitPx:i}=br(this.opt.kWidth,this.opt.kGap,n),a=Math.round((t.scrollLeft+e)*n),o=Math.floor((a-r)/i);return o<0?null:o}getDataIndexAtX(e){let t=this.getLogicalIndexAtX(e);return t===null||t>=this._internalData.length?null:t}getContentWidth(){return Yr({dataLength:this._internalData.length,kWidth:this.opt.kWidth,kGap:this.opt.kGap,viewWidth:this._internalViewport?.plotWidth??0,viewportDpr:this.getEffectiveDpr()})}resize(){let e=this.computeViewport();!e||e.viewWidth<10||e.viewHeight<10||(this.cachedDrawFrame=null,this.layoutPanes(),this.emitPaneLayoutChange(),this.updateViewportSignal(),this.scheduleDraw())}scheduleDraw(e=U.All){if(this.raf!==null){if(this.pendingUpdateLevel===U.All)return;if(e===U.All){this.pendingUpdateLevel=U.All;return}if(this.pendingUpdateLevel===U.Main&&e===U.Overlay||this.pendingUpdateLevel===U.Overlay&&e===U.Main){this.pendingUpdateLevel=U.All;return}return}this.pendingUpdateLevel=e,this.raf=requestAnimationFrame(()=>{this.raf=null;let e=this.pendingUpdateLevel;this.pendingUpdateLevel=U.All,this.draw(e)})}async destroy(){this.raf!==null&&(cancelAnimationFrame(this.raf),this.raf=null),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.preciseDpr=0,this.observedSize={width:0,height:0},this.onScroll&&=(this.dom.container?.removeEventListener(`scroll`,this.onScroll),void 0),this._internalViewport=null,this.cachedDrawFrame=null,this.xAxisCtx=null,this.paneRenderers.forEach(e=>e.destroy()),this.paneRenderers=[],this.sharedWebGLSurface.destroy(),this.rendererPluginManager.clear(),this.onViewportChange=void 0,this.onPaneLayoutChange=void 0,this.indicatorScheduler.destroy(),await this.pluginHost.destroy()}initPanes(){this.paneRenderers=this.opt.panes.map((e,t)=>{let n=new Ar(e.id,{role:this.resolvePaneRole(e,t),capabilities:e.capabilities}),r=document.createElement(`canvas`),i=document.createElement(`canvas`),a=document.createElement(`canvas`),o=n.role===`price`;return r.id=`${e.id}-main`,r.className=o?`main-canvas main`:`main-canvas sub`,r.style.position=`absolute`,r.style.left=`0`,r.style.top=`0`,i.id=`${e.id}-overlay`,i.className=`overlay-canvas`,i.style.position=`absolute`,i.style.left=`0`,i.style.top=`0`,i.style.pointerEvents=`none`,i.style.backgroundColor=`transparent`,a.id=`${e.id}-yAxis`,a.className=`right-axis`,a.style.position=`absolute`,a.style.left=`0`,new qr({mainCanvas:r,overlayCanvas:i,yAxisCanvas:a},n,{rightAxisWidth:this.opt.rightAxisWidth,yPaddingPx:this.opt.yPaddingPx,priceLabelWidth:this.opt.priceLabelWidth},this.sharedWebGLSurface)});let e=this.dom.canvasLayer,t=this.dom.rightAxisLayer;e&&e.querySelectorAll(`canvas:not(.x-axis-canvas)`).forEach(e=>e.remove()),t&&t.querySelectorAll(`canvas.right-axis`).forEach(e=>e.remove()),this.paneRenderers.forEach(n=>{let r=n.getDom();e.appendChild(r.mainCanvas),e.appendChild(r.overlayCanvas),t.appendChild(r.yAxisCanvas)}),this.rendererPluginManager.setKnownPaneIds(this.paneRenderers.map(e=>e.getPane().id))}syncPaneRatiosFromSpecs(e){let t=new Map;for(let n of e){let e=this._internalPaneRatios.get(n.id),r=Number.isFinite(n.ratio)?n.ratio:0,i=e===void 0?r>0?r:1:e;t.set(n.id,i)}this._internalPaneRatios=t,this.normalizeVisiblePaneRatios(e),this.syncPaneRatiosToSpecs()}syncPaneRatiosToSpecs(){let e=this.opt.panes.filter(e=>e.visible!==!1).reduce((e,t)=>e+(this._internalPaneRatios.get(t.id)??t.ratio??0),0),t=e>0?e:1;this.opt.panes=this.opt.panes.map(e=>{let n=this._internalPaneRatios.get(e.id)??e.ratio??0;return e.visible===!1?{...e,ratio:n}:{...e,ratio:n/t}})}normalizeVisiblePaneRatios(e){let t=e.filter(e=>e.visible!==!1);if(t.length===0)return;let n=0;for(let e of t){let t=this._internalPaneRatios.get(e.id)??e.ratio??0,r=Number.isFinite(t)&&t>0?t:0;this._internalPaneRatios.set(e.id,r),n+=r}if(n<=0){let e=1/t.length;for(let n of t)this._internalPaneRatios.set(n.id,e);return}for(let e of t){let t=this._internalPaneRatios.get(e.id)??0;this._internalPaneRatios.set(e.id,t/n)}}getPaneMinHeight(e,t){let n=this.opt.defaultPaneMinHeightPx??120,r=e.minHeightPx??n;return Math.max(1,Math.min(Math.round(r),Math.max(1,t)))}computePaneHeightsByRatio(e,t){if(e.length===0)return[];let n=e.map(e=>this._internalPaneRatios.get(e.id)??e.ratio??0),r=n.reduce((e,t)=>e+(t>0?t:0),0),i=(r>0?n.map(e=>(e>0?e:0)/r):e.map(()=>1/e.length)).map(e=>Math.max(1,Math.round(t*e))),a=e.map(e=>this.getPaneMinHeight(e,t));for(let e=0;e<i.length;e++)i[e]=Math.max(i[e],Math.min(a[e],t));let o=i.reduce((e,t)=>e+t,0);if(o>t){let e=o-t;for(;e>0;){let n=!1;for(let r=i.length-1;r>=0&&e>0;r--){let o=Math.max(1,Math.min(a[r],t)),s=i[r];s>o&&(i[r]=s-1,e--,n=!0)}if(!n)break}}else o<t&&(i[i.length-1]=(i[i.length-1]??1)+(t-o));return o=i.reduce((e,t)=>e+t,0),o!==t&&i.length>0&&(i[i.length-1]=Math.max(1,(i[i.length-1]??1)+(t-o))),i}layoutPanes(){let e=this._internalViewport;if(!e)return;let t=this.opt.panes.filter(e=>e.visible!==!1);if(t.length===0)return;let n=Math.max(0,this.opt.paneGap??0),r=0,i=n*Math.max(0,t.length-1),a=Math.max(1,e.plotHeight-i);this.normalizeVisiblePaneRatios(t);let o=this.computePaneHeightsByRatio(t,a);for(let i=0;i<t.length;i++){let a=t[i];if(!a)continue;let s=this.paneRenderers.find(e=>e.getPane().id===a.id);if(!s)continue;let c=s.getPane(),l=o[i]??1;c.setLayout(r,l),c.setPadding(this.opt.yPaddingPx,this.opt.yPaddingPx),s.resize(e.plotWidth,l,e.dpr),s.setWebGLRegion({x:0,y:r,width:e.plotWidth,height:l,dpr:e.dpr}),this.rendererPluginManager.notifyResize(c.id,Jo(c));let u=s.getDom();u.mainCanvas.style.top=`${r}px`,u.overlayCanvas.style.top=`${r}px`,u.yAxisCanvas.style.top=`${r}px`,u.yAxisCanvas.style.left=`0px`,r+=l+n}let s=Math.max(1,a);for(let e of t){let t=this.paneRenderers.find(t=>t.getPane().id===e.id);if(!t)continue;let n=t.getPane().height;this._internalPaneRatios.set(e.id,n/s)}this.normalizeVisiblePaneRatios(t),this.syncPaneRatiosToSpecs()}computeViewport(){let e=this.dom.container;if(!e)return null;let t=this.observedSize.width,n=this.observedSize.height,r=t>0?t:Math.max(1,Math.round(e.clientWidth)),i=n>0?n:Math.max(1,Math.round(e.clientHeight)),a=Math.round(r),o=Math.round(i-this.opt.bottomAxisHeight),s=this.getEffectiveDpr(),c=16*1024*1024;r*s*(i*s)>c&&(s=Math.sqrt(c/(r*i)));let l=Math.round(this.cachedScrollLeft*s)/s,u=`${r}px`;this.dom.canvasLayer.style.width!==u&&(this.dom.canvasLayer.style.width=u);let d=`${i}px`;this.dom.canvasLayer.style.height!==d&&(this.dom.canvasLayer.style.height=d);let f=Math.round(a*s);this.dom.xAxisCanvas.width!==f&&(this.dom.xAxisCanvas.width=f);let p=Math.round(this.opt.bottomAxisHeight*s);this.dom.xAxisCanvas.height!==p&&(this.dom.xAxisCanvas.height=p);let m=`${f/s}px`;this.dom.xAxisCanvas.style.width!==m&&(this.dom.xAxisCanvas.style.width=m);let h=`${p/s}px`;this.dom.xAxisCanvas.style.height!==h&&(this.dom.xAxisCanvas.style.height=h),this.sharedWebGLSurface.resize(a,o,s);let g={viewWidth:r,viewHeight:i,plotWidth:a,plotHeight:o,scrollLeft:l,dpr:s},_=this._internalViewport,v=!_||_.viewWidth!==g.viewWidth||_.viewHeight!==g.viewHeight||_.plotWidth!==g.plotWidth||_.plotHeight!==g.plotHeight||_.scrollLeft!==g.scrollLeft||_.dpr!==g.dpr;return this._internalViewport=g,v&&this.onViewportChange?.(g),g}_viewportSignal=vr({zoomLevel:1,plotWidth:0,plotHeight:0,dpr:1,visibleFrom:0,visibleTo:0,desiredScrollLeft:void 0,kWidth:0,kGap:1});_dataSignal=vr([]);_themeSignal=vr(`light`);_indicatorsSignal=vr([]);_subPanesSignal=vr([]);_drawingToolSignal=vr(null);_drawingsSignal=vr([]);_paneRatiosSignal=vr({});_interactionSignal=vr({crosshairPos:null,crosshairIndex:null,crosshairPrice:null,hoveredIndex:null,activePaneId:null,tooltipPos:{x:0,y:0},tooltipAnchorPlacement:`right-bottom`,hoveredMarkerData:null,hoveredCustomMarker:null,isDragging:!1,isResizingPaneBoundary:!1,isHoveringPaneBoundary:!1,hoveredPaneBoundaryId:null,isHoveringRightAxis:!1});get viewport(){return this._viewportSignal}get data(){return this._dataSignal}get theme(){return this._themeSignal}get indicators(){return this._indicatorsSignal}get subPanes(){return this._subPanesSignal}get drawingTool(){return this._drawingToolSignal}get drawings(){return this._drawingsSignal}get paneRatios(){return this._paneRatiosSignal}get interactionState(){return this._interactionSignal}setData(e){this.updateData(e)}appendData(e){let t=[...this._internalData,...e];this.setData(t)}setTheme(e){this._themeSignal.set(e),this.scheduleDraw()}zoomToLevel(e,t){let n=Math.max(1,Math.min(this.zoomLevelCount,Math.round(e)));this.applyZoom(n,t)}zoomIn(e){this.zoomToLevel(this.currentZoomLevel+1,e)}zoomOut(e){this.zoomToLevel(this.currentZoomLevel-1,e)}applyZoom(e,t){if(e===this.currentZoomLevel)return;let n=e-this.currentZoomLevel,r=this.getCachedScrollLeft(),i=this.getCurrentDpr(),a=ei(n,t??0,r,this.currentZoomLevel,this.opt.kWidth,this.opt.kGap,{minKWidth:this.opt.minKWidth,maxKWidth:this.opt.maxKWidth,zoomLevelCount:this.zoomLevelCount,dpr:i});a&&(this.currentZoomLevel=a.targetLevel,this.applyRenderState(a.newKWidth,a.newKGap,a.targetLevel),this._viewportSignal.set({zoomLevel:a.targetLevel,plotWidth:this._internalViewport?.plotWidth??0,plotHeight:this._internalViewport?.plotHeight??0,dpr:i,visibleFrom:this.lastVisibleRange.start,visibleTo:this.lastVisibleRange.end,desiredScrollLeft:a.newScrollLeft,kWidth:a.newKWidth,kGap:a.newKGap}))}handlePointerEvent(e,t){let n=this.dom.rightAxisLayer.contains(e.target);switch(e.type){case`pointerdown`:return t?.onPointerDown&&t.onPointerDown(e,this.dom.container)?!0:(n?this.interaction.onRightAxisPointerDown(e):this.interaction.onPointerDown(e),!1);case`pointermove`:return t?.onPointerMove&&t.onPointerMove(e,this.dom.container)?!0:(n?this.interaction.onRightAxisPointerMove(e):this.interaction.onPointerMove(e),!1);case`pointerup`:return t?.onPointerUp&&t.onPointerUp(e,this.dom.container)?!0:(n?this.interaction.onRightAxisPointerUp(e):this.interaction.onPointerUp(e),!1);case`pointerleave`:return n?this.interaction.onRightAxisPointerLeave(e):this.interaction.onPointerLeave(e),!1;default:return!1}}handleWheelEvent(e){let t=e.deltaY>0?-1:1,n=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel+t));if(n===this.currentZoomLevel)return;let r=this.dom.container.getBoundingClientRect(),i=e.clientX-r.left;this.applyZoom(n,i)}handleScrollEvent(){this.interaction.onScroll(),this.updateViewportSignal()}handlePinchZoom(e,t){let n=Math.max(1,Math.min(this.zoomLevelCount,this.currentZoomLevel+e));n!==this.currentZoomLevel&&this.applyZoom(n,t)}updateViewportSignal(){let e=this._internalViewport;e&&this._viewportSignal.set({zoomLevel:this.currentZoomLevel,plotWidth:e.plotWidth,plotHeight:e.plotHeight,dpr:e.dpr,visibleFrom:this.lastVisibleRange.start,visibleTo:this.lastVisibleRange.end,desiredScrollLeft:void 0,kWidth:this.opt.kWidth,kGap:this.opt.kGap})}addIndicator(e,t,n){if(t===`main`)return this.enableMainIndicator(e,n)?(this.syncIndicatorsSignal(),e.toUpperCase()):null;{let t=`${e.toUpperCase()}_${Date.now()}`;return this.createSubPane(t,e,n)?(this.syncIndicatorsSignal(),this.syncSubPanesSignal(),t):null}}removeIndicator(e){let t=e.toUpperCase();if(this.activeMainIndicators.has(t)){let t=this.disableMainIndicator(e);return t&&this.syncIndicatorsSignal(),t}return this.getSubPaneEntry(e)?(this.removeSubPane(e),this.syncIndicatorsSignal(),this.syncSubPanesSignal(),!0):!1}updateIndicatorParams(e,t){let n=e.toUpperCase();return this.activeMainIndicators.has(n)?(this.updateMainIndicatorParams(e,t),this.syncIndicatorsSignal(),!0):this.getSubPaneEntry(e)?(this.updateSubPaneParams(e,t),this.syncIndicatorsSignal(),!0):!1}reorderIndicators(e){return console.warn(`[Chart] reorderIndicators not fully implemented yet`),!1}syncIndicatorsSignal(){let e=this.getActiveMainIndicators().map(e=>({id:e,definitionId:e,label:e,name:e,role:`main`,params:this.getMainIndicatorParams(e)??{}})),t=this.getSubPaneEntries().map(e=>({id:e.paneId,definitionId:e.indicatorId,label:e.indicatorId,name:e.indicatorId,role:`sub`,paneId:e.paneId,params:e.params}));this._indicatorsSignal.set([...e,...t])}syncSubPanesSignal(){let e=this.getSubPaneEntries().map(e=>({paneId:e.paneId,indicatorId:e.indicatorId,params:e.params,ratio:this._internalPaneRatios.get(e.paneId)??1}));this._subPanesSignal.set(e)}resizeSubPane(e,t){return this.resizePaneBoundary(e,t)}setDrawingTool(e){this._drawingToolSignal.set(e)}removeDrawing(e){console.warn(`[Chart] removeDrawing not fully implemented yet`)}clearDrawings(){this.setDrawings([])}updateSettingsFacade(e){this.updateSettings(e)}updateOptionsFacade(e){this.updateOptions(e)}},nv={VOLUME:{defaultParams:{},getTitleInfo:()=>({name:`VOL`,params:[],values:[]})},MACD:{defaultParams:{fastPeriod:12,slowPeriod:26,signalPeriod:9},getTitleInfo:(e,t,n,r,i)=>t===null?null:Hc(t,n.fastPeriod??12,n.slowPeriod??26,n.signalPeriod??9,r,i)},RSI:{defaultParams:{period1:6,period2:12,period3:24},getTitleInfo:(e,t,n,r,i)=>t===null?null:el(t,n.period1??6,n.period2??12,n.period3??24,r,i)},CCI:{defaultParams:{period:14,showCCI:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:fl(t,n.period??14,r,i)},STOCH:{defaultParams:{n:9,m:3,showK:!0,showD:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:wl(t,n.n??9,n.m??3,r,i)},MOM:{defaultParams:{period:10,showMOM:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:Il(t,n.period??10,r,i)},WMSR:{defaultParams:{period:14,showWMSR:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:Jl(t,n.period??14,r,i)},KST:{defaultParams:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:!0,showSignal:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:ou(t,n.roc1??10,n.roc2??15,n.roc3??20,n.roc4??30,n.signalPeriod??9,r,i)},FASTK:{defaultParams:{period:9,showFASTK:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:vu(t,n.period??9,r,i)},ATR:{defaultParams:{period:14,showATR:!0},getTitleInfo:(e,t,n,r,i)=>t===null?null:ju(t,n.period??14,r,i)},WMA:{defaultParams:{period:10,showWMA:!0},getTitleInfo:()=>({name:`WMA`,params:[],values:[]})},DEMA:{defaultParams:{period:14,showDEMA:!0},getTitleInfo:()=>({name:`DEMA`,params:[],values:[]})},TEMA:{defaultParams:{period:14,showTEMA:!0},getTitleInfo:()=>({name:`TEMA`,params:[],values:[]})},HMA:{defaultParams:{period:14,showHMA:!0},getTitleInfo:()=>({name:`HMA`,params:[],values:[]})},KAMA:{defaultParams:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:!0},getTitleInfo:()=>({name:`KAMA`,params:[],values:[]})},SAR:{defaultParams:{step:.02,maxStep:.2,showSAR:!0},getTitleInfo:()=>({name:`SAR`,params:[],values:[]})},SUPERTREND:{defaultParams:{atrPeriod:10,multiplier:3,showSuperTrend:!0},getTitleInfo:()=>({name:`SuperTrend`,params:[],values:[]})},KELTNER:{defaultParams:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:!0,showMiddle:!0,showLower:!0},getTitleInfo:()=>({name:`Keltner`,params:[],values:[]})},DONCHIAN:{defaultParams:{period:20,showUpper:!0,showMiddle:!0,showLower:!0},getTitleInfo:()=>({name:`Donchian`,params:[],values:[]})},ICHIMOKU:{defaultParams:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:!0,showKijun:!0,showSpanA:!0,showSpanB:!0,showChikou:!0,showCloud:!0},getTitleInfo:()=>({name:`Ichimoku`,params:[],values:[]})},ROC:{defaultParams:{period:12,showROC:!0},getTitleInfo:()=>({name:`ROC`,params:[],values:[]})},TRIX:{defaultParams:{period:15,signalPeriod:9,showTRIX:!0,showSignal:!0},getTitleInfo:()=>({name:`TRIX`,params:[],values:[]})},HV:{defaultParams:{period:20,annualizationFactor:252,showHV:!0},getTitleInfo:()=>({name:`HV`,params:[],values:[]})},PARKINSON:{defaultParams:{period:20,annualizationFactor:252,showParkinson:!0},getTitleInfo:()=>({name:`Parkinson`,params:[],values:[]})},CHAIKIN_VOL:{defaultParams:{emaPeriod:10,rocPeriod:10,showChaikinVol:!0},getTitleInfo:()=>({name:`ChaikinVol`,params:[],values:[]})},VMA:{defaultParams:{period:5,showVMA:!0},getTitleInfo:()=>({name:`VMA`,params:[],values:[]})},OBV:{defaultParams:{showOBV:!0},getTitleInfo:()=>({name:`OBV`,params:[],values:[]})},PVT:{defaultParams:{showPVT:!0},getTitleInfo:()=>({name:`PVT`,params:[],values:[]})},VWAP:{defaultParams:{sessionResetGapMs:0,showVWAP:!0},getTitleInfo:()=>({name:`VWAP`,params:[],values:[]})},CMF:{defaultParams:{period:20,showCMF:!0},getTitleInfo:()=>({name:`CMF`,params:[],values:[]})},MFI:{defaultParams:{period:14,showMFI:!0},getTitleInfo:()=>({name:`MFI`,params:[],values:[]})},PIVOT:{defaultParams:{showPP:!0,showR1:!0,showR2:!0,showR3:!1,showS1:!0,showS2:!0,showS3:!1},getTitleInfo:()=>({name:`Pivot`,params:[],values:[]})},FIB:{defaultParams:{period:50,showLevels:!0},getTitleInfo:()=>({name:`Fib`,params:[],values:[]})},STRUCTURE:{defaultParams:{leftWindow:2,rightWindow:2,breakoutSource:`close`,showSwingLabels:!0,showBOS:!0,showCHOCH:!0,showProvisional:!1},getTitleInfo:()=>({name:`Structure`,params:[],values:[]})},ZONES:{defaultParams:{showFVG:!0,showOB:!0,showFilledZones:!1,obLookback:5},getTitleInfo:()=>({name:`Zones`,params:[],values:[]})},VOLUME_PROFILE:{defaultParams:{bins:24,lookback:0,valueAreaPercent:.7,showVolumeProfile:!0},getTitleInfo:()=>({name:`VP`,params:[],values:[]})}},rv=Object.keys(nv),iv=new Map,av=256;function ov(e,t){let n=`${e.font}\n${t}`,r=iv.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return iv.size>=av&&iv.clear(),iv.set(n,i),i}function sv(e){let t={...e};return{name:`paneTitle_${e.paneId}`,version:`1.0.0`,description:`面板标题渲染器`,debugName:`面板标题`,paneId:e.paneId,priority:J.FOREGROUND,layer:`overlay`,draw(e){let{overlayCtx:n,pane:r,paneWidth:i}=e,a=V(e.theme);if(r.id!==t.paneId||!n)return;let o=t.yOffset??12;n.save(),wc(n,Cc(12)),n.textAlign=`left`,n.textBaseline=`top`;let s=t.getTitleInfo?.();if(s){let e=12;if(n.fillStyle=a.TEXT.PRIMARY,n.fillText(s.name,e,o),e+=ov(n,s.name),s.params&&s.params.length>0){let t=`(${s.params.join(`,`)})`;n.fillStyle=a.TEXT.TERTIARY,n.fillText(t,e,o),e+=ov(n,t)+8}else e+=8;if(s.values&&s.values.length>0)for(let t of s.values){let r=`${t.label} ${t.value.toFixed(3)}`;n.fillStyle=t.color,n.fillText(r,e,o),e+=ov(n,r)+8}}else if(n.fillStyle=a.TEXT.PRIMARY,n.fillText(t.title,12,o),t.description){let e=ov(n,t.title);n.fillStyle=a.TEXT.WEAK,n.fillText(` - ${t.description}`,12+e,o)}n.restore()},setConfig(e){t={...t,...e}}}}var cv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function lv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,cv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7.904 17.563a1.2 1.2 0 0 0 2.228.308l2.09-3.093l4.907 4.907a1.067 1.067 0 0 0 1.509 0l1.047-1.047a1.067 1.067 0 0 0 0-1.509l-4.907-4.907l3.113-2.09a1.2 1.2 0 0 0-.309-2.228L4 4z`},null,-1)]])}var uv=(0,e.markRaw)({name:`tabler-pointer`,render:lv}),dv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function fv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,dv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 19h16M4 15l4-6l4 2l4-5l4 4`},null,-1)]])}var pv=(0,e.markRaw)({name:`tabler-chart-line`,render:fv}),mv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function hv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,mv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 7L7 17M8 7h9v9`},null,-1)]])}var gv=(0,e.markRaw)({name:`tabler-arrow-up-right`,render:hv}),_v={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function vv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,_v,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14m-6 6l6-6m-6-6l6 6`},null,-1)]])}var yv=(0,e.markRaw)({name:`tabler-arrow-right`,render:vv}),bv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function xv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,bv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14`},null,-1)]])}var Sv=(0,e.markRaw)({name:`tabler-minus`,render:xv}),Cv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function wv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Cv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12v.01M7 12h10m4 0v.01`},null,-1)]])}var Tv=(0,e.markRaw)({name:`tabler-separator`,render:wv}),Ev={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Dv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Ev,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2M9 12h6m-3-3v6`},null,-1)]])}var Ov=(0,e.markRaw)({name:`tabler-crosshair`,render:Dv}),kv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Av(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,kv,[...n[0]||=[(0,e.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0m9-3h.01`}),(0,e.createElementVNode)(`path`,{d:`M11 12h1v4h1`})],-1)]])}var jv=(0,e.markRaw)({name:`tabler-info-circle`,render:Av}),Mv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Nv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Mv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2`},null,-1)]])}var Pv=(0,e.markRaw)({name:`tabler-maximize`,render:Nv}),Fv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Iv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Fv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5`},null,-1)]])}var Lv=(0,e.markRaw)({name:`tabler-minimize`,render:Iv}),Rv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function zv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Rv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m-3-3v6m11 8l-6-6`},null,-1)]])}var Bv=(0,e.markRaw)({name:`tabler-zoom-in`,render:zv}),Vv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Hv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Vv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m4 0h6m8 11l-6-6`},null,-1)]])}var Uv=(0,e.markRaw)({name:`tabler-zoom-out`,render:Hv}),Wv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Gv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Wv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0m14 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0M5 7v10M7 5h10M7 19h10m2-12v10`},null,-1)]])}var Kv=(0,e.markRaw)({name:`tabler-shape`,render:Gv}),qv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Jv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,qv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 7a2 2 0 1 0 4 0a2 2 0 1 0-4 0m11 8a2 2 0 1 0 4 0a2 2 0 1 0-4 0m1-9a3 3 0 1 0 6 0a3 3 0 1 0-6 0M3 18a3 3 0 1 0 6 0a3 3 0 1 0-6 0m6-1l5-1.5m-7.5-7l7.81 5.37M7 7l8-1`},null,-1)]])}var Yv=(0,e.markRaw)({name:`tabler-chart-dots-3`,render:Jv}),Xv={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function Zv(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,Xv,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m18 10l-6-6l-6 6zm0 4l-6 6l-6-6z`},null,-1)]])}var Qv=(0,e.markRaw)({name:`tabler-caret-up-down`,render:Zv}),$v={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ey(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,$v,[...n[0]||=[(0,e.createElementVNode)(`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 4H5v16h3m8-16h3v16h-3`},null,-1)]])}var ty=(0,e.markRaw)({name:`tabler-brackets`,render:ey}),ny={viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`};function ry(t,n){return(0,e.openBlock)(),(0,e.createElementBlock)(`svg`,ny,[...n[0]||=[(0,e.createElementVNode)(`g`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065`}),(0,e.createElementVNode)(`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0`})],-1)]])}var iy=(0,e.markRaw)({name:`tabler-settings`,render:ry});function ay(){if(typeof navigator>`u`)return`desktop`;let e=navigator.userAgentData;if(e?.formFactor){let t=e.formFactor;if(t===`phone`)return`mobile`;if(t===`tablet`)return`tablet`;if(t===`desktop`)return`desktop`}if(e?.mobile===!0)return`mobile`;e?.mobile;let t=navigator.userAgent.toLowerCase();if(/android.*mobile|webos|iphone|ipod|blackberry|iemobile|opera mini|mobile/i.test(t))return`mobile`;let n=navigator.maxTouchPoints>1,r=window.screen.width>=768&&window.screen.width<=1366;return n&&r?`tablet`:`desktop`}var oy=[{key:`showGridLines`,label:`显示网格`,type:`boolean`,default:!0,group:`main`},{key:`showVolumePriceMarkers`,label:`显示量价关系标记`,type:`boolean`,default:!1,group:`main`},{key:`logarithmicScale`,label:`对数价格轴`,type:`boolean`,default:!1,group:`main`},{key:`disableMainPaneVerticalScroll`,label:`主图纵轴刻度自适应调整`,type:`boolean`,default:!0,group:`main`},{key:`enableWebGLRendering`,label:`启用 WebGL 硬件加速渲染`,type:`boolean`,default:ay()===`desktop`,group:`main`},{key:`performanceTest10kKlines`,label:`万条K线性能测试`,type:`boolean`,default:!1,group:`experimental`},{key:`enableCanvasProfiler`,label:`Canvas 性能分析插桩`,type:`boolean`,default:!1,group:`experimental`}],sy=`kline-chart-settings`;function cy(){return Object.create(null)}function ly(){return{ctxMethods:cy(),ctxProps:cy(),canvasProps:cy(),ctxMethodSources:Object.create(null)}}function uy(e,t,n){let r=e[t]??={count:0,totalTime:0};r.count+=1,r.totalTime+=n}function dy(e,t,n,r){uy(e.ctxMethodSources[t]??=cy(),n,r)}function fy(e){return Object.entries(e).filter(([,e])=>e.count>0).map(([e,t])=>({name:e,count:t.count,totalTime:t.totalTime.toFixed(2),averageTime:(t.totalTime/t.count).toFixed(4)})).sort((e,t)=>Number(t.totalTime)-Number(e.totalTime))}var py=!1,my=new Map,hy=new Map;function gy(e){py=e,e?typeof window<`u`&&!window.__KMAP_CANVAS_PROFILER_INSTALLED__&&by():xy()}function _y(){if(!py)return`disabled`;let e=Error().stack;if(!e)return`unknown`;let t=e.split(`
|
|
49
|
+
`).map(e=>e.trim()).filter(Boolean);for(let e of t){if(e.includes(`canvasProfiler`)||e.includes(`CanvasRenderingContext2D`)||e===`Error`)continue;let t=e.replace(/^at\s+/,``),n=t.match(/((?:src|node_modules)[^\s)]+):(\d+):(\d+)/);if(n)return`${n[1]}:${n[2]}`;let r=t.match(/\(([^)]+):(\d+):(\d+)\)$/);return r?`${r[1]}:${r[2]}`:t}return`unknown`}function vy(e,t,n,r){let i=`${e.constructor?.name??`proto`}:${t}`;if(my.has(i))return;let a=Reflect.get(e,t);typeof a==`function`&&(my.set(i,a),Reflect.set(e,t,function(...e){if(!py)return a.apply(this,e);let i=r?.captureSource?_y():null,o=performance.now(),s=a.apply(this,e),c=performance.now()-o;return uy(n.ctxMethods,t,c),i&&dy(n,t,i,c),s}))}function yy(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);if(!r?.set||!r.configurable)return;let i=`${e.constructor?.name??`proto`}:${t}`;hy.has(i)||(hy.set(i,r),Object.defineProperty(e,t,{configurable:!0,enumerable:r.enumerable??!1,get:r.get,set(e){if(!py){r.set.call(this,e);return}let i=performance.now();r.set.call(this,e),uy(n,t,performance.now()-i)}}))}function by(){if(typeof window>`u`||window.__KMAP_CANVAS_PROFILER_INSTALLED__)return;let e=CanvasRenderingContext2D?.prototype,t=HTMLCanvasElement?.prototype;if(!e||!t)return;let n=ly();vy(e,`fillText`,n,{captureSource:!0}),vy(e,`measureText`,n,{captureSource:!0}),vy(e,`drawImage`,n),vy(e,`save`,n),vy(e,`restore`,n),vy(e,`clip`,n),vy(e,`setTransform`,n),vy(e,`scale`,n),yy(e,`font`,n.ctxProps),yy(e,`filter`,n.ctxProps),yy(e,`shadowBlur`,n.ctxProps),yy(e,`lineWidth`,n.ctxProps),yy(t,`width`,n.canvasProps),yy(t,`height`,n.canvasProps),window.__KMAP_CANVAS_PROFILER_METRICS__=n,window.__KMAP_CANVAS_PROFILER_INSTALLED__=!0,window.showCanvasReport=()=>{let e=window.__KMAP_CANVAS_PROFILER_METRICS__;if(e){console.group(`[kmap] Canvas profiler report`),console.log(`ctx methods`),console.table(fy(e.ctxMethods)),console.log(`ctx props`),console.table(fy(e.ctxProps)),console.log(`canvas props`),console.table(fy(e.canvasProps));for(let t of[`fillText`,`measureText`]){let n=e.ctxMethodSources[t];n&&(console.log(`${t} sources`),console.table(fy(n).slice(0,20)))}console.groupEnd()}},window.resetCanvasReport=()=>{window.__KMAP_CANVAS_PROFILER_METRICS__=ly()},console.info(`[kmap] Canvas profiler enabled. Use window.showCanvasReport() and window.resetCanvasReport().`)}function xy(){if(typeof window>`u`||!window.__KMAP_CANVAS_PROFILER_INSTALLED__)return;let e=CanvasRenderingContext2D?.prototype,t=HTMLCanvasElement?.prototype;my.forEach((n,r)=>{let i=r.match(/^(.+):(.+)$/);if(!i)return;let[,a,o]=i,s=null;a===`CanvasRenderingContext2D`?s=e:a===`HTMLCanvasElement`&&(s=t),s&&Reflect.set(s,o,n)}),my.clear(),hy.forEach((n,r)=>{let i=r.match(/^(.+):(.+)$/);if(!i)return;let[,a,o]=i,s=null;a===`CanvasRenderingContext2D`?s=e:a===`HTMLCanvasElement`&&(s=t),s&&n.configurable&&Object.defineProperty(s,o,n)}),hy.clear(),window.__KMAP_CANVAS_PROFILER_INSTALLED__=!1,window.__KMAP_CANVAS_PROFILER_METRICS__=void 0,window.showCanvasReport=void 0,window.resetCanvasReport=void 0,console.info(`[kmap] Canvas profiler disabled.`)}var Sy={class:`left-toolbar`,"aria-label":`图表工具栏`},Cy={class:`left-toolbar__group`},wy=[`title`,`aria-label`,`onClick`],Ty=[`onClick`],Ey=[`title`,`aria-label`,`onClick`],Dy={class:`left-toolbar__group`},Oy={class:`left-toolbar__group`},ky=[`title`,`aria-label`],Ay={class:`left-toolbar__group`},jy={class:`settings-body`},My={class:`settings-label`},Ny=[`onUpdate:modelValue`],Py=[`onUpdate:modelValue`],Fy=[`value`],Iy={class:`settings-label`},Ly=[`onUpdate:modelValue`],Ry=[`onUpdate:modelValue`],zy=[`value`],By=Rt((0,e.defineComponent)({__name:`LeftToolbar`,props:{isFullscreen:{type:Boolean}},emits:[`selectTool`,`toggleFullscreen`,`zoomIn`,`zoomOut`,`settingsChange`],setup(t,{expose:n,emit:r}){let i=r,a=[{id:`cursor`,title:`光标`,icon:uv},{id:`lines`,title:`线条`,icon:pv,children:[{id:`trend-line`,title:`线段`,icon:pv},{id:`ray`,title:`射线`,icon:gv},{id:`h-line`,title:`水平线`,icon:Sv},{id:`h-ray`,title:`水平射线`,icon:yv},{id:`v-line`,title:`垂直线`,icon:Tv},{id:`crosshair-line`,title:`十字线`,icon:Ov},{id:`info-line`,title:`信息线`,icon:jv}]},{id:`channels`,title:`通道`,icon:Kv,children:[{id:`parallel-channel`,title:`平行通道`,icon:Kv},{id:`regression-channel`,title:`回归趋势`,icon:Yv},{id:`flat-line`,title:`平滑顶底`,icon:Qv},{id:`disjoint-channel`,title:`不相交通道`,icon:ty}]}],o=(0,e.computed)(()=>oy.filter(e=>e.group===`main`)),s=(0,e.computed)(()=>oy.filter(e=>e.group===`experimental`)),c=(0,e.ref)(`cursor`),l=(0,e.ref)(null),u=(0,e.ref)(!1),d=Kt();function f(){try{let e=localStorage.getItem(sy);if(e){let t=JSON.parse(e),n={};return oy.forEach(e=>{n[e.key]=t[e.key]??e.default}),n}}catch{}let e={};return oy.forEach(t=>{e[t.key]=t.default}),e}function p(e){try{localStorage.setItem(sy,JSON.stringify(e))}catch{}}let m=(0,e.ref)(f()),h=(0,e.ref)({...m.value});function g(e){return c.value===e.id?!0:e.children?e.children.some(e=>e.id===c.value):!1}function _(e){if(e.children?.length){if(!e.children.some(e=>e.id===c.value)){let t=e.children[0];c.value=t.id,i(`selectTool`,t.id)}y(e.id);return}c.value=e.id,i(`selectTool`,e.id),l.value=null}function v(e){c.value=e.id,i(`selectTool`,e.id),l.value=null}function y(e){l.value=l.value===e?null:e}function b(){h.value={...m.value},u.value=!0}function x(){u.value=!1}function S(){let e={};oy.forEach(t=>{e[t.key]=t.default}),h.value=e}function C(){m.value={...h.value},p(m.value),gy(!!m.value.enableCanvasProfiler),i(`settingsChange`,{...m.value}),x()}function w(){return{...m.value}}n({getSettings:w});function T(e){e.target.closest(`.tool-item`)||(l.value=null)}return(0,e.onMounted)(()=>{document.addEventListener(`click`,T,!0),i(`settingsChange`,{...m.value}),gy(!!m.value.enableCanvasProfiler)}),(0,e.onUnmounted)(()=>{document.removeEventListener(`click`,T,!0)}),(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,[(0,e.createElementVNode)(`nav`,Sy,[(0,e.createElementVNode)(`div`,Cy,[((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(a,t=>(0,e.createElementVNode)(`div`,{key:t.id,class:`tool-item`},[(0,e.createElementVNode)(`button`,{type:`button`,class:(0,e.normalizeClass)([`left-toolbar__button`,{active:g(t)}]),title:t.title,"aria-label":t.title,onClick:e=>_(t),onPointerdown:r[0]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[1]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[2]||=(0,e.withModifiers)(()=>{},[`stop`])},[((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.icon),{class:`tool-icon`,"aria-hidden":`true`})),t.children&&t.children.length?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,class:(0,e.normalizeClass)([`corner-indicator`,{open:l.value===t.id}]),onClick:(0,e.withModifiers)(e=>y(t.id),[`stop`]),"aria-label":`展开子菜单`},null,10,Ty)):(0,e.createCommentVNode)(``,!0)],42,wy),(0,e.createVNode)(e.Transition,{name:`dropdown`},{default:(0,e.withCtx)(()=>[l.value===t.id&&t.children&&t.children.length?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`tool-dropdown`,onPointerdown:r[3]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[4]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[5]||=(0,e.withModifiers)(()=>{},[`stop`])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.children,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:t.id,type:`button`,class:(0,e.normalizeClass)([`left-toolbar__button`,{active:c.value===t.id}]),title:t.title,"aria-label":t.title,onClick:e=>v(t)},[((0,e.openBlock)(),(0,e.createBlock)((0,e.resolveDynamicComponent)(t.icon),{class:`tool-icon`,"aria-hidden":`true`}))],10,Ey))),128))],32)):(0,e.createCommentVNode)(``,!0)]),_:2},1024)])),64))]),r[22]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,Dy,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`放大`,"aria-label":`放大`,onClick:r[6]||=e=>n.$emit(`zoomIn`),onPointerdown:r[7]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[8]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[9]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(Bv),{class:`tool-icon`,"aria-hidden":`true`})],32),(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`缩小`,"aria-label":`缩小`,onClick:r[10]||=e=>n.$emit(`zoomOut`),onPointerdown:r[11]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[12]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[13]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(Uv),{class:`tool-icon`,"aria-hidden":`true`})],32)]),r[23]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,Oy,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:t.isFullscreen?`退出全屏`:`全屏显示`,"aria-label":t.isFullscreen?`退出全屏`:`全屏显示`,onClick:r[14]||=e=>n.$emit(`toggleFullscreen`),onPointerdown:r[15]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[16]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[17]||=(0,e.withModifiers)(()=>{},[`stop`])},[t.isFullscreen?((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(Lv),{key:0,class:`tool-icon`,"aria-hidden":`true`})):((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(Pv),{key:1,class:`tool-icon`,"aria-hidden":`true`}))],40,ky)]),r[24]||=(0,e.createElementVNode)(`span`,{class:`left-toolbar__divider`},null,-1),(0,e.createElementVNode)(`div`,Ay,[(0,e.createElementVNode)(`button`,{type:`button`,class:`left-toolbar__button`,title:`设置`,"aria-label":`设置`,onClick:b,onPointerdown:r[18]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointermove:r[19]||=(0,e.withModifiers)(()=>{},[`stop`]),onPointerup:r[20]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createVNode)((0,e.unref)(iy),{class:`tool-icon`,"aria-hidden":`true`})],32)])]),((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:(0,e.unref)(d)},[(0,e.createVNode)(e.Transition,{name:`overlay`},{default:(0,e.withCtx)(()=>[u.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:`settings-overlay`,onClick:x},[(0,e.createVNode)(e.Transition,{name:`modal`},{default:(0,e.withCtx)(()=>[(0,e.createElementVNode)(`div`,{class:`settings-modal`,onClick:r[21]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,{class:`settings-header`},[r[26]||=(0,e.createElementVNode)(`div`,{class:`header-left`},[(0,e.createElementVNode)(`span`,{class:`settings-title`},`图表设置`),(0,e.createElementVNode)(`span`,{class:`settings-subtitle`},`个性化配置`)],-1),(0,e.createElementVNode)(`div`,{class:`header-right`},[(0,e.createElementVNode)(`button`,{class:`settings-close`,onClick:x},[...r[25]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M18 6L6 18M6 6l12 12`})],-1)]])])]),(0,e.createElementVNode)(`div`,jy,[o.value.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:0},[r[27]||=(0,e.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,e.createElementVNode)(`span`,{class:`settings-section-label`},`主图设置`)],-1),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(o.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:`settings-item`},[(0,e.createElementVNode)(`label`,My,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.label),1),t.type===`boolean`?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":e=>h.value[t.key]=e},null,8,Ny)),[[e.vModelCheckbox,h.value[t.key]]]):t.type===`select`&&t.options?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`select`,{key:1,class:`settings-select`,"onUpdate:modelValue":e=>h.value[t.key]=e},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.options,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`option`,{key:t.value,value:t.value},(0,e.toDisplayString)(t.label),9,Fy))),128))],8,Py)),[[e.vModelSelect,h.value[t.key]]]):(0,e.createCommentVNode)(``,!0)])]))),128))],64)):(0,e.createCommentVNode)(``,!0),s.value.length>0?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:1},[r[28]||=(0,e.createElementVNode)(`div`,{class:`settings-section-divider`},[(0,e.createElementVNode)(`span`,{class:`settings-section-label`},`实验性 / 调试设置`)],-1),((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(s.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.key,class:`settings-item experimental`},[(0,e.createElementVNode)(`label`,Iy,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.label),1),t.type===`boolean`?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`input`,{key:0,type:`checkbox`,class:`settings-checkbox`,"onUpdate:modelValue":e=>h.value[t.key]=e},null,8,Ly)),[[e.vModelCheckbox,h.value[t.key]]]):t.type===`select`&&t.options?(0,e.withDirectives)(((0,e.openBlock)(),(0,e.createElementBlock)(`select`,{key:1,class:`settings-select`,"onUpdate:modelValue":e=>h.value[t.key]=e},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.options,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`option`,{key:t.value,value:t.value},(0,e.toDisplayString)(t.label),9,zy))),128))],8,Ry)),[[e.vModelSelect,h.value[t.key]]]):(0,e.createCommentVNode)(``,!0)])]))),128))],64)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,{class:`settings-footer`},[(0,e.createElementVNode)(`button`,{class:`settings-btn reset`,onClick:S},[...r[29]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`},[(0,e.createElementVNode)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,e.createElementVNode)(`path`,{d:`M3 3v5h5`})],-1),(0,e.createTextVNode)(` 重置 `,-1)]]),(0,e.createElementVNode)(`div`,{class:`footer-right`},[(0,e.createElementVNode)(`button`,{class:`settings-btn cancel`,onClick:x},`取消`),(0,e.createElementVNode)(`button`,{class:`settings-btn confirm`,onClick:C},[...r[30]||=[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2.5`},[(0,e.createElementVNode)(`path`,{d:`M20 6L9 17l-5-5`})],-1),(0,e.createTextVNode)(` 确定 `,-1)]])])])])]),_:1})])):(0,e.createCommentVNode)(``,!0)]),_:1})],8,[`to`]))],64))}}),[[`__scopeId`,`data-v-20a39cb3`]]),Vy=[`data-theme`],Hy={class:`pane-separator-layer`,"aria-hidden":`true`},Uy=4,Wy=Rt((0,e.defineComponent)({__name:`KLineChart`,props:{semanticConfig:{},yPaddingPx:{default:0},minKWidth:{default:1},maxKWidth:{default:50},rightAxisWidth:{default:0},bottomAxisHeight:{default:24},priceLabelWidth:{default:60},zoomLevels:{default:20},initialZoomLevel:{default:3},isFullscreen:{type:Boolean,default:!1}},emits:[`zoomLevelChange`,`toggleFullscreen`],setup(t,{expose:n,emit:r}){let i=t,a=(0,e.ref)(null),o=(0,e.ref)(null),s=(0,e.ref)(null),c=(0,e.ref)(null),l=(0,e.ref)(null),u=(0,e.ref)(null),d=(0,e.ref)(null),f=(0,e.shallowRef)(null),p=(0,e.shallowRef)(null),m=Xr({initialZoomLevel:i.initialZoomLevel??1,minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevels:i.zoomLevels,rightAxisWidth:i.rightAxisWidth,priceLabelWidth:i.priceLabelWidth}),h=(0,e.ref)(`light`);m.actions.setZoomState(m.state.zoomLevel,Qr(m.state.zoomLevel,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:m.state.viewportDpr}),$r(Qr(m.state.zoomLevel,{minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,zoomLevelCount:i.zoomLevels,dpr:m.state.viewportDpr}),m.state.viewportDpr)),(0,e.computed)(()=>m.state.dataLength),(0,e.computed)(()=>m.state.viewportDpr);let g=(0,e.computed)(()=>m.state.zoomLevel),_=(0,e.computed)(()=>m.state.kWidth),v=(0,e.computed)(()=>m.state.kGap),y=(0,e.computed)(()=>m.state.paneRatios),b=(0,e.computed)(()=>m.state.selectedDrawingId),x=(0,e.computed)(()=>m.state.dataVersion);function S(){f.value?.scheduleDraw()}function C(e){if(f.value?.updateSettings(e),e.performanceTest10kKlines){let e=w();console.time(`updateData-10k`),f.value?.updateData(e),console.timeEnd(`updateData-10k`),m.actions.setDataLength(e.length),m.actions.bumpDataVersion()}else p.value&&f.value?.getData()?.length===1e4&&p.value.applyConfig(i.semanticConfig)}function w(){let e=[],t=new Date(`2020-01-01`).getTime(),n=3e3;for(let r=0;r<1e4;r++){let i=t+r*864e5,a=(Math.random()-.5)*2*.02+1e-4,o=n,s=o*(1+a),c=Math.max(o,s)*(1+Math.random()*.01),l=Math.min(o,s)*(1-Math.random()*.01),u=Math.floor(1e6+Math.random()*5e6);e.push({timestamp:i,open:parseFloat(o.toFixed(2)),high:parseFloat(c.toFixed(2)),low:parseFloat(l.toFixed(2)),close:parseFloat(s.toFixed(2)),volume:u}),n=s}return e}function T(e,t,n){let r=e.getBoundingClientRect();return{width:Math.max(t,Math.round(r.width)),height:Math.max(n,Math.round(r.height))}}function E(t){t&&(0,e.nextTick)(()=>{if(!t.isConnected)return;let e=T(t,180,80);f.value?.interaction.setTooltipSize(e)})}function D(t){t&&(0,e.nextTick)(()=>{t.isConnected&&(ee.value=T(t,120,60))})}let O=(0,e.ref)({x:0,y:0}),k=(0,e.ref)(!1),A=null;function j(){A=null}function N(e){return A||=e.getBoundingClientRect(),A}let P=(0,e.shallowRef)({crosshairPos:null,crosshairIndex:null,crosshairPrice:null,hoveredIndex:null,activePaneId:null,tooltipPos:{x:0,y:0},tooltipAnchorPlacement:`right-bottom`,hoveredMarkerData:null,hoveredCustomMarker:null,isDragging:!1,isResizingPaneBoundary:!1,isHoveringPaneBoundary:!1,hoveredPaneBoundaryId:null,isHoveringRightAxis:!1}),F=(0,e.shallowRef)(null),I=(0,e.computed)(()=>{let e=b.value;return e?m.state.drawings.find(t=>t.id===e)??null:null}),L=(0,e.ref)([]),ee=(0,e.ref)({width:220,height:120}),R=(0,e.computed)(()=>{let e=c.value,t=l.value;return!e||!t?{x:0,y:0}:{x:e.offsetLeft,y:e.offsetTop}}),te=(0,e.computed)(()=>P.value.hoveredMarkerData),ne=(0,e.computed)(()=>P.value.hoveredCustomMarker),re=(0,e.computed)(()=>P.value.isDragging),ie=(0,e.computed)(()=>P.value.isResizingPaneBoundary),ae=(0,e.computed)(()=>P.value.isHoveringPaneBoundary),oe=(0,e.computed)(()=>P.value.hoveredPaneBoundaryId),se=(0,e.computed)(()=>P.value.isHoveringRightAxis),ce=(0,e.computed)(()=>P.value.hoveredIndex),le=(0,e.computed)(()=>P.value.crosshairIndex),ue=(0,e.computed)(()=>re.value?`grabbing`:ie.value||ae.value?`ns-resize`:ce.value===null?`crosshair`:`pointer`),de=(0,e.computed)(()=>{let e=P.value.hoveredIndex;if(typeof e!=`number`)return null;x.value;let t=f.value?.getData();return t&&e>=0&&e<t.length?t[e]:null}),fe=(0,e.computed)(()=>P.value.hoveredIndex),pe=(0,e.computed)(()=>P.value.tooltipPos),me=(0,e.computed)(()=>({x:pe.value.x+R.value.x,y:pe.value.y+R.value.y})),he=(0,e.computed)(()=>({left:`${me.value.x}px`,top:`${me.value.y}px`})),ge=(0,e.computed)(()=>({x:O.value.x+R.value.x,y:O.value.y+R.value.y})),_e=(0,e.computed)(()=>({left:`${ge.value.x}px`,top:`${ge.value.y}px`})),ve=(0,e.computed)(()=>P.value.tooltipAnchorPlacement),ye=(0,e.computed)(()=>{let e=f.value?.getViewport(),t=c.value,n=e?.plotWidth??(t?t.clientWidth:0);return O.value.x+12+ee.value.width+12>n?`left-bottom`:`right-bottom`}),be=(0,e.computed)(()=>(x.value,f.value?.getData()??[]));function xe(e){F.value?.setTool(e)}function Se(e){let t=I.value;!t||!F.value||(F.value.updateDrawingStyle(t.id,e),m.actions.bumpDrawingVersion())}function Ce(){let e=I.value;!e||!F.value||(F.value.removeDrawing(e.id),m.actions.setSelectedDrawingId(null),m.actions.bumpDrawingVersion(),m.actions.setDrawings(F.value.getDrawings()))}function we(e){f.value?.handlePointerEvent(e,{onPointerDown:(e,t)=>F.value?.onPointerDown(e,t)?(m.actions.setDrawings(F.value.getDrawings()),m.actions.bumpDrawingVersion(),!0):!1})}function Te(e){let t=c.value;if(t){let n=N(t);O.value={x:e.clientX-n.left,y:e.clientY-n.top}}f.value?.handlePointerEvent(e,{onPointerMove:(e,t)=>F.value?.onPointerMove(e,t)?(m.actions.setDrawings(F.value.getDrawings()),!0):!1})}function Ee(e){f.value?.handlePointerEvent(e,{onPointerUp:(e,t)=>F.value?.onPointerUp(e,t)?(m.actions.setDrawings(F.value.getDrawings()),!0):!1})}function De(e){f.value?.handlePointerEvent(e)}function Oe(e){f.value?.handlePointerEvent(e)}function ke(e){f.value?.handlePointerEvent(e)}function Ae(e){f.value?.handlePointerEvent(e)}function je(e){f.value?.handlePointerEvent(e)}function Me(){f.value?.handleScrollEvent()}let Ne=(0,e.ref)([]),Pe=(0,e.computed)(()=>{let e=[],t=new Set;for(let n of z.value)t.has(n.indicatorId)||(t.add(n.indicatorId),e.push(n.indicatorId));return e}),Fe=(0,e.computed)(()=>[...Ne.value,...Pe.value]),Ie=(0,e.ref)({}),z=(0,e.ref)([]);function Le(){let e=y.value.main??3;return z.value.length===0?[{id:`main`,ratio:e,visible:!0,role:`price`}]:[{id:`main`,ratio:e,visible:!0,role:`price`},...z.value.map(e=>({id:e.id,ratio:y.value[e.id]??1,visible:!0,role:`indicator`}))]}function Re(e){return{...nv[e].defaultParams}}let ze=new Map,Be=new Map;function Ve(e,t){let n=sv({paneId:e,title:t,getTitleInfo:()=>Ye(e)});f.value?.useRenderer(n),Be.set(e,n.name)}function He(e){let t=Be.get(e);t&&(f.value?.removeRenderer(t),Be.delete(e))}function Ue(e=`VOLUME`,t){if(z.value.length>=Uy)return!1;let n=t??Re(e),r=f.value?.addIndicator(e,`sub`,n);return r?(Ve(r,e),z.value.push({id:r,indicatorId:e,params:n}),S(),!0):!1}function We(e){let t=z.value.findIndex(t=>t.id===e);t!==-1&&z.value[t]&&(He(e),f.value?.removeIndicator(e),z.value.splice(t,1))}function B(){for(let e of z.value)f.value?.removeIndicator(e.id),He(e.id);z.value=[],ze.clear(),Be.clear()}function Ge(){let e=i.semanticConfig,t=f.value;if(!t)return;let n=e.indicators?.main;if(n)for(let e of n)e.enabled&&(Ne.value.includes(e.type)||Ne.value.push(e.type),e.params&&(Ie.value[e.type]=e.params),t.enableMainIndicator(e.type,e.params))}(0,e.watch)([Fe,Ie],([e])=>{let t=f.value;t&&(t.updateRendererConfig(`mainIndicatorLegend`,{indicators:{MA:{enabled:e.includes(`MA`),params:Ie.value.MA||{}},BOLL:{enabled:e.includes(`BOLL`),params:Ie.value.BOLL||{}},EXPMA:{enabled:e.includes(`EXPMA`),params:Ie.value.EXPMA||{}},ENE:{enabled:e.includes(`ENE`),params:Ie.value.ENE||{}}}}),S())},{deep:!0});function Ke(){let e=f.value?.getSubPaneEntries()??[];z.value=[],Be.clear();for(let t of e){let{paneId:e,indicatorId:n,params:r}=t,i=e.match(/^(.+)_(\d+)$/);if(i){let[,e,t]=i,n=parseInt(t,10);n>=(ze.get(e)??0)&&ze.set(e,n+1)}Ve(e,n),z.value.push({id:e,indicatorId:n,params:{...r}})}S()}function qe(e,t){if(!z.value.find(t=>t.id===e))return;let n=Re(t);He(e),f.value?.replaceSubPaneIndicator(e,t,n),Ve(e,t);let r=z.value.findIndex(t=>t.id===e);r!==-1&&(z.value[r]={id:e,indicatorId:t,params:n})}let Je=new Map;function Ye(e){let t=z.value.find(t=>t.id===e);if(!t)return null;let n=f.value?.getData();if(!n||n.length===0)return null;let r=le.value,i=n.length,a=Je.get(e);if(a&&a.idx===r&&a.dataLen===i)return a.result;let o=nv[t.indicatorId],s=t.params,c=f.value?.plugin,l=c?o.getTitleInfo(n,r,s,c,e):null;return Je.set(e,{idx:r,dataLen:i,result:l}),l}function Xe(e,t){let n=f.value;if(n){if([`MA`,`BOLL`,`EXPMA`,`ENE`,`WMA`,`DEMA`,`TEMA`,`HMA`,`KAMA`,`SAR`,`SUPERTREND`,`KELTNER`,`DONCHIAN`,`ICHIMOKU`,`PIVOT`,`FIB`,`STRUCTURE`,`ZONES`].includes(e)){let r=Ne.value.find(t=>t===e);if(t&&!r)n.addIndicator(e,`main`,Ie.value[e]),Ne.value.push(e);else if(!t&&r){let t=e.toUpperCase();n.removeIndicator(t),Ne.value=Ne.value.filter(t=>t!==e)}return}if(rv.includes(e)){if(t){if(z.value.find(t=>t.indicatorId===e)||z.value.length>=Uy)return;let t=n.addIndicator(e,`sub`,Ie.value[e]);if(t)Ve(t,e),z.value.push({id:t,indicatorId:e,params:{...Ie.value[e]}});else if(z.value.length>0){let t=z.value[z.value.length-1];qe(t.id,e)}}else z.value.filter(t=>t.indicatorId===e).forEach(e=>{n.removeIndicator(e.id),He(e.id)}),z.value=z.value.filter(t=>t.indicatorId!==e);S()}}}function Ze(e,t){if(Ie.value[e]=t,e===`MA`||e===`BOLL`||e===`EXPMA`||e===`ENE`){f.value?.updateMainIndicatorParams(e,t),S();return}if(rv.includes(e)){z.value.filter(t=>t.indicatorId===e).forEach(e=>{f.value?.updateSubPaneParams(e.id,t),e.params={...t}}),S();return}S()}function Qe(e){if(!e.length||z.value.length<=1)return;let t=e.filter(e=>rv.includes(e));if(!t.length)return;let n=new Map(z.value.map(e=>[e.indicatorId,e])),r=[];for(let e of t){let t=n.get(e);t&&(r.push(t),n.delete(e))}if(r.length===0)return;for(let e of z.value)n.has(e.indicatorId)&&(r.push(e),n.delete(e.indicatorId));let i=z.value.map(e=>e.id),a=r.map(e=>e.id);if(i.join(`|`)===a.join(`|`))return;z.value=r;let o=f.value;o&&o.updatePaneLayout(Le())}let $e=(0,e.computed)(()=>i.rightAxisWidth+i.priceLabelWidth),et=m.computed.totalWidth;function tt(){let e=c.value,t=f.value;if(!e||!t)return;let n=t.getData()?.length??0;if(n===0)return;let r=t.getCurrentDpr(),{unitPx:i,startXPx:a}=br(_.value,v.value,r),o=(a+n*i)/r,s=Math.max(0,e.scrollWidth-e.clientWidth),l=Math.min(s,Math.max(0,o-e.clientWidth));e.scrollLeft=Math.round(l*r)/r,S()}function nt(e,t){let n=f.value;n&&n.zoomToLevel(e,t)}n({scheduleRender:S,scrollToRight:tt,addSubPane:Ue,removeSubPane:We,switchSubIndicator:qe,clearAllSubPanes:B,get plugin(){return f.value?.plugin},zoomToLevel:nt,zoomIn:e=>nt(g.value+1,e),zoomOut:e=>nt(g.value-1,e),getZoomLevel:()=>g.value,getZoomLevelCount:()=>f.value?.getZoomLevelCount()??10});function rt(e){let t=e=>{e.preventDefault();let t=f.value;t&&t.handleWheelEvent(e)};return e.addEventListener(`wheel`,t,{passive:!1}),t}function it(e,t,n,r){return new tv({container:e,canvasLayer:t,rightAxisLayer:n,xAxisCanvas:r},{yPaddingPx:i.yPaddingPx,rightAxisWidth:i.rightAxisWidth,bottomAxisHeight:i.bottomAxisHeight,priceLabelWidth:i.priceLabelWidth,minKWidth:i.minKWidth,maxKWidth:i.maxKWidth,panes:[{id:`main`,ratio:1}],paneGap:0,zoomLevels:i.zoomLevels,initialZoomLevel:i.initialZoomLevel})}function at(t){t.setOnPaneLayoutChange(()=>{j();let e=t.getPaneRenderers(),n=c.value&&parseInt(getComputedStyle(c.value).borderTopWidth)||0;L.value=e.slice(0,-1).map(e=>{let t=e.getPane();return{id:t.id,top:t.top+t.height+n}})});let n=t.paneRatios.subscribe(()=>{let e=t.paneRatios.peek();m.actions.setPaneRatios({...e})}),r=t.viewport.subscribe(()=>{let n=t.viewport.peek();m.state.viewportDpr!==n.dpr&&m.actions.setViewportDpr(n.dpr),m.state.viewWidth!==n.plotWidth&&m.actions.setViewWidth(n.plotWidth),(m.state.zoomLevel!==n.zoomLevel||m.state.kWidth!==n.kWidth||m.state.kGap!==n.kGap)&&m.actions.setZoomState(n.zoomLevel,n.kWidth,n.kGap);let r=n.desiredScrollLeft;r!==void 0&&r!==c.value?.scrollLeft&&(j(),(0,e.nextTick)(()=>{let e=c.value;if(!e)return;let n=Math.max(0,e.scrollWidth-e.clientWidth),i=Math.min(Math.max(0,r),n),a=t.getCurrentDpr();e.scrollLeft=Math.round(i*a)/a}))}),i=t.data.subscribe(()=>{let e=t.data.peek();m.actions.setDataLength(e.length),m.actions.bumpDataVersion()}),a=t.theme.subscribe(()=>{h.value=t.theme.peek()});(0,e.onUnmounted)(()=>{r(),i(),n(),a()})}function ot(e){let t=d.value?.getSettings()??{showVolumePriceMarkers:!0};if(e.updateSettings(t),t.performanceTest10kKlines){let t=w();console.time(`updateData-10k`),e.updateData(t),console.timeEnd(`updateData-10k`)}}function st(e){F.value=new a_(e),F.value.setCallbacks({onDrawingCreated:e=>{m.actions.setDrawings([...m.state.drawings,e]),m.actions.setSelectedDrawingId(e.id)},onToolChange:()=>{},onDrawingSelected:e=>{m.actions.setSelectedDrawingId(e?.id??null)}})}function ct(e){e.interaction.setTooltipAnchorPositioning(k.value),e.interaction.setOnInteractionChange(e=>{P.value=e}),e.interaction.setOnPinchZoom((t,n)=>{if(!e)return;let r=c.value;if(!r)return;let i=n-r.getBoundingClientRect().left;e.handlePinchZoom(t,i)}),P.value=e.interaction.getInteractionSnapshot(),m.actions.setViewportDpr(e.getCurrentDpr()),e.resize()}function lt(t){p.value=new M(t),p.value.on(`config:error`,e=>{console.error(`Semantic config error:`,e)}),p.value.on(`config:ready`,()=>{Ge(),Ke(),(0,e.nextTick)(()=>tt())}),p.value.applyConfig(i.semanticConfig).then(e=>{e&&!e.success&&console.error(`Semantic config apply failed:`,e.errors)})}return(0,e.onMounted)(()=>{k.value=!1;let e=c.value,t=o.value,n=s.value,r=a.value;if(!e||!t||!n||!r)return;let i=rt(e),l=it(e,t,n,r);f.value=l,at(l),l.applyRenderState(m.state.kWidth,m.state.kGap,m.state.zoomLevel),ot(l),st(l),ct(l),lt(l),l.__onWheel=i}),(0,e.onUnmounted)(()=>{let e=f.value;if(e){let t=e.__onWheel,n=c.value;t&&n&&n.removeEventListener(`wheel`,t),e.destroy()}f.value=null,F.value=null}),(0,e.watch)(()=>i.yPaddingPx,e=>{f.value?.updateOptions({yPaddingPx:e})}),(0,e.watch)(()=>i.semanticConfig,async(e,t)=>{if(e&&e!==t){let t=await p.value?.applyConfig(e);t&&!t.success&&console.error(`Semantic config apply failed:`,t.errors)}},{deep:!0}),(n,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:`chart-wrapper`,"data-theme":h.value},[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`chart-stage`,{"is-dragging":re.value,"is-resizing-pane":ie.value,"is-hovering-pane-separator":ae.value,"is-hovering-right-axis":se.value,"is-hovering-kline":ce.value!==null}])},[(0,e.createVNode)(By,{ref_key:`toolbarRef`,ref:d,"is-fullscreen":t.isFullscreen,onSelectTool:xe,onToggleFullscreen:r[0]||=e=>n.$emit(`toggleFullscreen`),onZoomIn:r[1]||=e=>nt(g.value+1),onZoomOut:r[2]||=e=>nt(g.value-1),onSettingsChange:C},null,8,[`is-fullscreen`]),(0,e.createElementVNode)(`div`,{class:`chart-main`,ref_key:`chartMainRef`,ref:l},[(0,e.createElementVNode)(`div`,Hy,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(L.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.id,class:(0,e.normalizeClass)([`pane-separator-line`,{"is-active":oe.value===t.id}]),style:(0,e.normalizeStyle)({top:`${t.top}px`})},null,6))),128))]),(0,e.createElementVNode)(`div`,{ref_key:`tooltipLayerRef`,ref:u,class:`tooltip-layer`},null,512),(0,e.createElementVNode)(`div`,{class:`chart-container`,style:(0,e.normalizeStyle)({cursor:ue.value}),ref_key:`containerRef`,ref:c,onScrollPassive:Me,onPointerdown:we,onPointermove:Te,onPointerup:Ee,onPointerleave:De},[(0,e.createElementVNode)(`div`,{class:`scroll-content`,style:(0,e.normalizeStyle)({width:(0,e.unref)(et)+`px`})},[(0,e.createElementVNode)(`div`,{class:`canvas-layer`,ref_key:`canvasLayerRef`,ref:o},[(0,e.createElementVNode)(`canvas`,{class:`x-axis-canvas`,ref_key:`xAxisCanvasRef`,ref:a},null,512),I.value?((0,e.openBlock)(),(0,e.createBlock)(gr,{key:0,drawing:I.value,onUpdateStyle:Se,onDelete:Ce},null,8,[`drawing`])):(0,e.createCommentVNode)(``,!0)],512)],4)],36),u.value?((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{key:0,to:u.value},[de.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:(0,e.normalizeClass)([`tooltip-anchor kline-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,e.normalizeStyle)(he.value)},null,6)):(0,e.createCommentVNode)(``,!0),te.value||ne.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:1,class:(0,e.normalizeClass)([`tooltip-anchor marker-tooltip-anchor`,{"use-anchor":k.value}]),style:(0,e.normalizeStyle)(_e.value)},null,6)):(0,e.createCommentVNode)(``,!0),de.value?((0,e.openBlock)(),(0,e.createBlock)(zt,{key:2,k:de.value,index:fe.value,data:be.value,pos:me.value,"set-el":E,"use-anchor":k.value,"anchor-placement":ve.value},null,8,[`k`,`index`,`data`,`pos`,`use-anchor`,`anchor-placement`])):(0,e.createCommentVNode)(``,!0),te.value||ne.value?((0,e.openBlock)(),(0,e.createBlock)(Wt,{key:3,marker:te.value||ne.value,pos:ge.value,"use-anchor":k.value,"anchor-placement":ye.value,"set-el":D},null,8,[`marker`,`pos`,`use-anchor`,`anchor-placement`])):(0,e.createCommentVNode)(``,!0)],8,[`to`])):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`div`,{class:`right-axis-host`,ref_key:`rightAxisLayerRef`,ref:s,style:(0,e.normalizeStyle)({width:$e.value+`px`}),onPointerdown:Oe,onPointermove:ke,onPointerup:Ae,onPointerleave:je},null,36)],512)],2),(0,e.createVNode)(cr,{"active-indicators":Fe.value,"indicator-params":Ie.value,onToggle:Xe,onUpdateParams:Ze,onReorderSubIndicators:Qe},null,8,[`active-indicators`,`indicator-params`])],8,Vy))}}),[[`__scopeId`,`data-v-9448d063`]]),Gy={install(e){e.component(`KLineChart`,Wy)}};exports.ConfigManager=Qo,exports.EventBus=t,exports.GLOBAL_PANE_ID=Yo,exports.HookSystem=Zo,exports.KLineChart=Wy,exports.KMapPlugin=Gy,exports.PluginHostImpl=es,exports.PluginRegistry=Xo,exports.PluginState=qo,exports.RENDERER_PRIORITY=J,exports.RendererPluginManager=rs,exports.createPluginHost=ts,exports.wrapPaneInfo=Jo;
|