@guihz/trading-vue-editor-tes 0.0.262 → 0.0.263

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,7 +82,7 @@ ${O.join(`
82
82
  `)}
83
83
  return ${p==null?void 0:p.code}`;d>1;)l=`${l}}`,d--;const f=[];for(const h of Object.keys(z))l.includes(`$_var.getCacheData("${h}"`)&&f.push(z[h]);return f.length&&(l=`${f.join(`
84
84
  `)}
85
- ${l}`),l}_getRequestLowerTfData(e,t,r,o){var L;let{symbol:n,timeframe:p,calc_bars_count:z,ignore_invalid_symbol:i,ignore_invalid_timeframe:s}=e;const{__period:a,time:O,_isRealTimeBar:u}=this._variables;p=hr(p);let l=y2(p,O)*1e3;const d=y2(a,O)*1e3;if(l>d)return!s&&this._errorListener.addError(r2(d1.requestLowerTfPeriodErr,{period:p}),t,Y0.Error,25),o;const f=`${n}--${p}`,h=self.workerStorage.get(`request_${this._scriptId}_data`),q=self.workerStorage.get(`request_${this._scriptId}_list`),m=self.workerStorage.get(`request_${this._scriptId}_tmp`),_={id:f,calc_bars_count:z,ignore_invalid_symbol:i,symbol:n,originTimeframe:p,timeframe:ii[p]||ic(p)};if(h!=null&&h.has(f)){m==null||m.delete(f);const{index:g=0,periodStamp:v=d}=this._cacheData.get(r)||{},y=h==null?void 0:h.get(f);if(!y.length||y.length-1<0)return o;const T=y.slice(g);let N=O,w=v+N;const C=[];for(const[P,H]of T.entries()){let{time:Y}=H;Y=Y*1e3;let k=g+P;if(Y>=w)return!u&&this._cacheData.set(r,{index:k,periodStamp:v}),C;if(N<=Y&&Y<w){const J=(L=H==null?void 0:H.result)==null?void 0:L[r];if(Array.isArray(J))for(const[e0,z0]of J.entries())C[e0]||(C[e0]=[]),C[e0].push(z0);else C.push(J)}}return!u&&this._cacheData.set(r,{index:y.length,periodStamp:v}),C}else(q==null?void 0:q.get(f))||m==null||m.set(f,_);q==null||q.set(f,_)}_getRequestData(e,t){var m,_,L,g,v;let{symbol:r,timeframe:o,calc_bars_count:n,gaps:p,lookahead:z,ignore_invalid_symbol:i}=e;const{__period:s,mintick:a,time:O,nextBarTime:u}=this._variables;o=hr(o),r=r;const l=`${r}--${o}`,d=self.workerStorage.get(`request_${this._scriptId}_data`),f=self.workerStorage.get(`request_${this._scriptId}_list`),h=self.workerStorage.get(`request_${this._scriptId}_tmp`),q={id:l,calc_bars_count:n,ignore_invalid_symbol:i,symbol:r,originTimeframe:o,timeframe:ii[o]||ic(o)};if(d!=null&&d.has(l)){let y=y2(o,O)*1e3;const X=y2(s,O)*1e3;h==null||h.delete(l);const{index:T=0,periodStamp:N=X}=this._cacheData.get(t)||{},w=d==null?void 0:d.get(l);if(!w.length)return;const C=w.slice(T);let P=O,H=N+P;const Y=w.length-1;if(Y<0)return;const k={lastBarIndex:w[Y].barindex||Y,lastBarTime:w[Y].time,interval:o,mintick:a};if(y>N){let J;if(z===Pe.lookaheadOn?J=this._lookaheadOnHandle(C,o,H,y,k,T,N,t,P,p):J=this._lookaheadOffHandle(C,o,H,y,k,T,N,t,P,u||H,p),J)return J;if(J===null)return}else if(z===Pe.lookaheadOn)for(const[J,e0]of C.entries()){let{time:z0,barindex:a0}=e0;z0=z0*1e3;const R0=((m=C[J+1])==null?void 0:m.time)*1e3||z0+y;let v0=T+J;if(z0>=H){this._cacheData.set(t,{index:v0,periodStamp:N});return}if(z0<=P&&R0>P){const u0=T+J;return this._cacheData.set(t,{index:u0,periodStamp:N}),{...e0,barIndex:a0||u0,nextBarTime:(_=C[J+1])==null?void 0:_.time,...k}}}else for(const[J,e0]of C.entries()){let{time:z0,barindex:a0}=e0;z0=z0*1e3;const R0=((L=C[J+1])==null?void 0:L.time)*1e3||z0+y;let v0=T+J;if(z0>H){this._cacheData.set(t,{index:v0,periodStamp:N});return}if(z0<H&&H<=R0)return this._cacheData.set(t,{index:v0,periodStamp:N}),{...e0,barIndex:a0||v0,nextBarTime:(g=C[J+1])==null?void 0:g.time,...k};if(z0>=P&&z0<=H&&(a0||v0)===k.lastBarIndex)return this._cacheData.set(t,{index:v0,periodStamp:N}),{...e0,barIndex:a0||v0,nextBarTime:(v=C[J+1])==null?void 0:v.time,...k}}this._cacheData.set(t,{index:w.length,periodStamp:N});return}else(f==null?void 0:f.get(l))||h==null||h.set(l,q);f==null||f.set(l,q)}_lookaheadOnHandle(e,t,r,o,n,p,z,i,s,a){var O;for(const[u,l]of e.entries()){let{time:d,barindex:f}=l;d=d*1e3,t.includes("M")&&(o=y2(t,d)*1e3-(D1(d).date()-1)*864e5);const h=d,q=o+h;let m=p+u;if(r<=h)return this._cacheData.set(i,{index:m,periodStamp:z}),null;let _={...l,barIndex:f||m,nextBarTime:(O=e[u+1])==null?void 0:O.time,...n};if(a===Pe.gapsOn){if(r>h&&s<=h)return this._cacheData.set(i,{index:m,periodStamp:z}),_}else{if(r>q)continue;if(r>h)return this._cacheData.set(i,{index:m,periodStamp:z}),_}}}_lookaheadOffHandle(e,t,r,o,n,p,z,i,s,a,O){var u,l;for(const[d,f]of e.entries()){let{time:h,barindex:q}=f;h=h*1e3,t.includes("M")&&(o=y2(t,h)*1e3-(D1(h).date()-1)*864e5);const m=h,_=o+m,L=p+d;if(r<m)return this._cacheData.set(i,{index:L,periodStamp:z}),null;const g={...f,barIndex:q||L,nextBarTime:(u=e[d+1])==null?void 0:u.time,...n};if(r>=_&&s<_||r<_&&a>=_)return O===Pe.gapsOn?(this._cacheData.set(i,{index:L,periodStamp:z}),g):(this._cacheData.set(i,{index:L,data:g,periodStamp:z}),g);if(!(s>_)&&s>=m){let v=(l=this._cacheData.get(i))==null?void 0:l.data;if(!v){const y=e[L-1];if(!y)return null;v={...y,barIndex:y.barindex||L-1,nextBarTime:g.time,...n},this._cacheData.set(i,{index:L,data:v,periodStamp:z})}return v}}}_getDependCodes(e,t,r,o,n,p){for(const z of e){if(!z.isArg){const i=t.filter(a=>{var O;return(O=a==null?void 0:a.depends)==null?void 0:O.some(u=>u.name===z.name&&u.scope===z.scope&&u.isAgainAssign!==!1)});for(const a of i){const{code:O,depends:u,scope:l,funcName:d}=a;r[l]=r[l]||[];const f=r[l];let h=l===0&&d;if(!f.includes(O)){if(h){if(o.includes(O))continue;o.unshift(O)}else f.unshift(O);if(u!=null&&u.length){for(const q of u)q.memberCode&&!h&&p.push(q.memberCode);this._getDependCodes(u,t,r,o,n,p)}}}const s=t.find(a=>{var O;return((O=a.varNames)==null?void 0:O.split(", ").includes(z.name))&&(!z.isPreArg||z.isPreArg&&a.methodName===z.functionName)||a.funcName===z.name});if(s){const{code:a,depends:O,scope:u}=s;r[u]=r[u]||[];const l=r[u],d=l.findIndex(f=>f===a);if(d!==-1){if(z.isFunc)continue;l.splice(d,1)}if(l.unshift(a),O!=null&&O.length){for(const f of O)f.memberCode&&p.push(f.memberCode);this._getDependCodes(O,t,r,o,n,p)}continue}}n.some(i=>i.name===z.name)||n.push(z)}}_getStmtFuncs(e,t,r,o,n){const p=t.filter(z=>z.isStmtFunc);for(const z of p){const{code:i,depends:s,scope:a=0}=z;e[a]=e[a]||[];const O=e[a];if(!O.includes(i)&&(O.push(i),s!=null&&s.length)){for(const u of s)u.memberCode&&r.push(u.memberCode);this._getDependCodes(s.filter(u=>!(u.isFunc&&i.startsWith(u.name))),t,e,o,n,r)}}}runScripts(e,t,r,o,n,p){var u;const z=`${this._scriptId}_${t}`;let{builtInGather:i,buildinConstants:s,buildInFunctions:a,tradingvueFunc:O}=self.workerStorage.get(z)||{};if(r&&(i=new qp(z),s=new Ap,a=new lp(this._variables.mintick||1e-5,i,this._scriptId),O=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",e),i.__requestName=t,self.workerStorage.set(z,{builtInGather:i,buildinConstants:s,buildInFunctions:a,tradingvueFunc:O})),o&&o.length){const l=o.length-1,{interval:d,symbol:f=""}=n,{mintick:h,syminfo:q}=this._variables,[m,_]=f.split(":");i.updateOptions({interval:d,mintick:h,syminfo:{...q.__syminfo,tickerid:f||q.tickerid,ticker:_||m||q.ticker}});for(const[v,y]of o.entries()){const{barindex:X}=y,T=Object.assign(y,{barIndex:X||v,lastBarIndex:o[l].barindex||l,lastBarTime:o[l].time,nextBarTime:(u=o[v+1])==null?void 0:u.time});if(i.updateData(T),a.update({barIndex:(T==null?void 0:T.barindex)||0}),y.result=Object.assign(y.result||{},{[t]:O(i,s,a,p||[],t)}),a.endExecution(),a.errors.length&&a.errors.some(N=>N.type===Y0.Error))return{logs:[],errors:a.errors}}const L=a.log.logs,g=a.errors;return a.log.clearLogs(),a.clearErrors(),{logs:L,errors:g}}}_runScripts(e,t,r,o,n){const p=`${this._scriptId}_${t}`;let{builtInGather:z,buildinConstants:i,buildInFunctions:s,tradingvueFunc:a}=self.workerStorage.get(p)||{};const{interval:O,...u}=n||{};if(r){z=new qp(p),i=new Ap,s=new lp(this._variables.mintick||1e-5,z,this._scriptId),a=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",e);const{mintick:h,syminfo:q}=this._variables;z.updateOptions({interval:O,mintick:h||1e-5,syminfo:{...q.__syminfo}}),z.__requestName=t,self.workerStorage.set(p,{builtInGather:z,buildinConstants:i,buildInFunctions:s,tradingvueFunc:a})}z.updateData(u),s.update({barIndex:(u==null?void 0:u.barindex)||0});const l=a(z,i,s,o||[],t),d=s.log.logs,f=s.errors;return s.log.clearLogs(),s.clearErrors(),s.endExecution(),{result:l,logs:d,errors:f}}},rm=class{constructor(){}prefix(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[0])||""}ticker(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[1])||""}};class Mm{constructor(e,t){E(this,"_logs");E(this,"_variables");E(this,"_str");E(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=e,this._logs=[],this._str=t}get logs(){return this._logs}clearLogForIndex(e){this._logs=this._logs.filter(t=>t.barIndex!==e)}clearLogs(){this._logs=[]}info(e,t,r){this._addLog(e,t,"info",r)}error(e,t,r){this._addLog(e,t,"error",r)}warning(e,t,r){this._addLog(e,t,"warning",r)}mergeLogs(e){this._logs=this._logs.concat(e)}_addLog(e,t,r,o){if(typeof t=="string"&&(o=t),o.startsWith("export"))return;const{message:n,formatString:p}=e,{time:z,bar_index:i,_isRealTimeBar:s}=this._variables;let a=n;p&&Array.isArray(t)&&t.length&&(t=t.map(l=>(typeof l=="object"&&(l.isArray?l=JSON.stringify(l._value):l=l.toString()),l!==void 0?l:"na")),a=this._str.strformat({formatString:p},t,!0));const{isrealtime:O}=this._preBar;this._preBar={barIndex:i,isrealtime:s};const u=Date.now();a!==void 0&&this._logs.push({message:`[${D1(O||s?u:z).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${a}`,time:z,id:Sl(6),barIndex:i,type:r})}}class om{constructor(e){E(this,"_errorListener");this._errorListener=e}error({message:e},t){t.startsWith("export")||this._errorListener.addError(e,t,Y0.Error)}}class nm{constructor(){E(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return L2.flatMap([...this._errors.values()])}setErrors(e,t){this._errors.set(t,e)}addError(e,t,r,o=0){const[n,p]=t.split("_").slice(-2),z=this._errors.get(t),i={message:e,endLineNumber:Number(n),startColumn:Number(p)+1,endColumn:Number(p)+o+1,startLineNumber:Number(n),type:r};z?z.push(i):this._errors.set(t,[i])}}class bm{constructor(){E(this,"_isMarketOpen");E(this,"_currentBarIndex");E(this,"_totalBarIndex");E(this,"_isRealTimeBar");E(this,"_preBarIndex");E(this,"_preIsRealTimeBar");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0,this._preIsRealTimeBar=!1}update(e,t,r,o){this._preBarIndex=this._currentBarIndex,this._preIsRealTimeBar=this._isRealTimeBar,this._currentBarIndex=e,this._totalBarIndex=t,this._isRealTimeBar=r,this._isMarketOpen=o}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1&&!this._preIsRealTimeBar||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class pm{constructor(e){E(this,"_variables");this._variables=e}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const{time:e,__period:t}=this._variables,r=y2(t,e);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const{time:e,__period:t}=this._variables,r=y2(t,e);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class zm{constructor(e){E(this,"_orders");E(this,"_historyOrders");E(this,"_options");E(this,"_max_contracts_held_all",0);E(this,"_max_contracts_held_long",0);E(this,"_max_contracts_held_short",0);E(this,"_max_drawdown",0);E(this,"_max_runup",0);E(this,"_max_runup_percent",0);E(this,"_max_drawdown_percent",0);E(this,"_variables");E(this,"_netprofit",0);E(this,"_eventrades",0);E(this,"_avg_trade_percent");E(this,"_avg_losing_trade_percent");E(this,"_avg_winning_trade_percent");E(this,"_closedtrades",0);E(this,"_losstrades",0);E(this,"_grossloss",0);E(this,"_grossprofit",0);E(this,"_wintrades",0);E(this,"_opentrades_capital_held",0);E(this,"_position_avg_price",0);E(this,"_position_size",0);E(this,"_openprofit",0);E(this,"_preMaxNetValue",0);E(this,"_preMinNetValue",0);E(this,"marginCallLong",0);E(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=e}update(e){this._calcMaxDrawdownAndMaxRunup(e)}_calcMaxDrawdownAndMaxRunup(e){if(!this._orders.length&&!this._historyOrders.length)return;let t=0,r=0;const{high:o,low:n,close:p}=e;let z=0;for(const[a,O]of this._orders.entries()){const{in_price:u,qty:l=0,direction:d,commission:f,original_qty:h=1}=O,q=d===i1.long?1:-1,m=(o-u)*l,_=(n-u)*l,L=q===1?m:-_,g=q===1?-_:m;z+=(p-u)*q*l,t+=g,a>0&&f&&(r-=f*l/h),r+=L}this._openprofit=z;const i=this.initial_capital,s=i+this._netprofit;this._preMinNetValue=this._preMinNetValue||i,this._preMaxNetValue=this._preMaxNetValue||i,t=this._preMaxNetValue-s+Math.max(t,0),r=s-this._preMinNetValue+r,this._max_drawdown<t&&(this._max_drawdown=t,this._max_drawdown_percent=t/this._preMaxNetValue*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(this._preMinNetValue+r)*100)}updateOrders(e){this._orders=e,this._calcMaxContracts()}_calcMaxContracts(){const e=this._orders.length;if(!e){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[t,r,o,n,p,z,i]=this._orders.reduce(([s,a,O,u,l,d,f],h)=>{const{direction:q,qty:m=0,in_price:_,commission:L=0}=h;return q===i1.long?(s+=m,a+=m,d+=m):(s+=m,O+=m,d-=m),u+=m*_,l+=_,f+=L,[s,a,O,u,l,d,f]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-i,this._grossloss=i),this._position_size=z,this._position_avg_price=p/e,this._opentrades_capital_held=n,this._max_contracts_held_all=Math.max(t,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(o,this._max_contracts_held_short)}updateHistoryOrders(e){this._historyOrders=e;const t=this._historyOrders.length;this._closedtrades=t;const[r,o,n,p,z,i,s,a]=this._historyOrders.reduce((l,d)=>{let[f,h,q,m,_,L,g,v]=l;const{profit:y=0,profit_percent:X=0}=d;return f+=y,h+=X,y<0?(q+=y,m+=X,g+=1):y>0&&(_+=y,L+=X,v+=1),[f,h,q,m,_,L,g,v]},[0,0,0,0,0,0,0,0]),O=this._orders.reduce((l,d)=>{const{commission:f=0,qty:h=0,original_qty:q=0}=d,m=f*h/q;return l+m},0);this._avg_trade_percent=t?o/t:void 0,this._avg_losing_trade_percent=t?Math.abs(p)/s:void 0,this._avg_winning_trade_percent=t?i/a:void 0,this._netprofit=r-O;const u=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,u),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,u),this._grossloss=Math.abs(n-O),this._grossprofit=z,this._eventrades=t-s-a,this._losstrades=s,this._wintrades=a}updateStrategyOptions(e){this._options=e}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const e=this._losstrades;return e?Math.abs(this._grossloss/e):void 0}get avg_losing_trade_percent(){return this._avg_losing_trade_percent}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const e=this._wintrades;return e?Math.abs(this._grossprofit/e):void 0}get avg_winning_trade_percent(){return this._avg_winning_trade_percent}get initial_capital(){var e;return((e=this._options)==null?void 0:e.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:e,margin_long:t=0,margin_short:r=0,commission_type:o,commission_value:n=0}=this._options,p=this._orders[0].direction===i1.long?1:-1,z=(p===1?t:r)/100;if(z<=0)return;const{close:i}=this._variables,[s,a]=this._orders.reduce((O,u)=>{let[l,d]=O;const{in_price:f,qty:h=0,original_qty:q=0}=u,m=f*h;if(l+=m,n){let _=0;switch(o){case O2.percent:_=(m+h*i)*n/100;break;case O2.cashPerContract:_=h*n*2;break;case O2.cashPerOrder:_=h/q*n+n;break}d+=_}return[l,d]},[0,0]);return(s-(e+this._netprofit-a))*p/this._position_size/(1-p*z)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(e,t){if(!this._options)return 0;const{commission_value:r=0,commission_type:o}=this._options,n=e*t;let p=0;switch(o){case O2.percent:p=n*r/100;break;case O2.cashPerContract:p=t*r;break;case O2.cashPerOrder:p=r;break}return p}}class im{constructor(e){E(this,"_preAccdist");E(this,"_preNvi");E(this,"_prePvi");E(this,"_preObv");E(this,"_prePvt");E(this,"_preWad");E(this,"_preVwap");E(this,"_preValue");E(this,"_currentData");E(this,"_preData");E(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=e}update(e){this._preValue={},e.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...e}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:e,low:t,high:r,volume:o}=this._currentData;if(r===t)return this._preAccdist;const n=(e-t-(r-e))/(r-t)*o+this._preAccdist;return!this.isRealTime&&(this._preAccdist=n),this._preValue.accdist=n,n}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:e,low:t,high:r,volume:o}=this._currentData,n=(2*e-r-t)/((r-t)*o);return this._preValue.iii=n,n}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:e,low:t,high:r,volume:o,open:n}=this._currentData,p=(e-n)/(r-t)*o;return this._preValue.wvad=p,p}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const o=Math.sign(e-r)*t+this._preObv;return!this.isRealTime&&(this._preObv=o),this._preValue.obv=o,o}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:e,high:t}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const o=Math.max(t-e,Math.abs(t-r),Math.abs(e-r));return this._preValue.tr=o,o}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const o=(e-r)/r*t+this._prePvt;return!this.isRealTime&&(this._prePvt=o),this._preValue.pvt=o,o}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:e,high:t,low:r}=this._currentData,{close:o}=this._preData;if(o===void 0)return this._preWad=0,0;const n=Math.max(t,o),p=Math.min(r,o),z=e-o,s=(z>0?e-p:z<0?e-n:0)+this._preWad;return!this.isRealTime&&(this._preWad=s),this._preValue.wad=s,s}get vwap(){var a,O;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:e,volume:t}=this._currentData;let{sum:r=0,sumV:o=0,isReset:n}=this._preVwap;if(((O=(a=self.workerStorage)==null?void 0:a.get(this._id))==null?void 0:O.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(n=!0,r=o=0),!n)return;const z=e*t+r,i=t+o;!this.isRealTime&&(this._preVwap={sum:z,sumV:i,isReset:n});const s=z/i;return this._preValue.vwap=s,s}_getNvi(){const e=this._preNvi||1,{close:t=0,volume:r=0}=this._preData,{close:o,volume:n}=this._currentData;let p=1;const z=e||1;return o&&t?p=n<r?z+(o-t)/t*z:z:p=z,!this.isRealTime&&(this._preNvi=p),this._preValue.nvi=p,p}_getPvi(){const e=this._prePvi||1,{close:t=0,volume:r=0}=this._preData,{close:o,volume:n}=this._currentData;let p=1;const z=e||1;return o&&t?p=n>r?z+(o-t)/t*z:z:p=z,!this.isRealTime&&(this._prePvi=p),this._preValue.pvi=p,p}}class cm{constructor(){E(this,"_period");E(this,"_multiplier");E(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(e){if(!e)return;this._period=e;const[t,r]=OM(e);this._multiplier=t,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class sm{constructor(){E(this,"_bgColor");E(this,"_fgColor");E(this,"isUseBgColor",!1)}updateOptions(e){e!=null&&e.bg_color&&(this._bgColor=e.bg_color,this._fgColor=this._contrastColor(e.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){}get right_visible_bar_time(){}_parseColor(e){let t,r,o,n;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);const p=e.substring(7);p?n=parseInt(p,16)/255:n=1}else{const p=this._parserRgbColor(e);t=p[0]||0,r=p[1]||0,o=p[2]||0,n=p[3]||1}return{r:t,g:r,b:o,a:n}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}_contrastColor(e){const{r:t,g:r,b:o}=this._parseColor(e);return(299*t+587*r+114*o)/1e3>128?"#000000":"#ffffff"}}class Om{constructor(){E(this,"_syminfo",{})}update(e){this._syminfo=e}get __syminfo(){return this._syminfo}get basecurrency(){return this._syminfo.basecurrency||""}get country(){return this._syminfo.country}get currency(){return this._syminfo.currency||"USD"}get description(){return this._syminfo.description||""}get employees(){return this._syminfo.employees||100}get expiration_date(){return this._syminfo.expiration_date}get industry(){return this._syminfo.industry}get minmove(){return this._syminfo.minmove&&Number(this._syminfo.minmove)}get mintick(){return this._syminfo.mintick}get pointvalue(){return this._syminfo.pointvalue&&Number(this._syminfo.pointvalue)}get prefix(){return this.tickerid.replace(`:${this.ticker}`,"")}get pricescale(){return this._syminfo.pricescale&&Number(this._syminfo.pricescale)}get recommendations_buy(){return this._syminfo.recommendations_buy}get recommendations_buy_strong(){return this._syminfo.recommendations_buy_strong}get recommendations_date(){return this._syminfo.recommendations_date}get recommendations_hold(){return this._syminfo.recommendations_hold}get recommendations_sell(){return this._syminfo.recommendations_sell}get recommendations_sell_strong(){return this._syminfo.recommendations_sell_strong}get recommendations_total(){return this._syminfo.recommendations_total}get root(){return this._syminfo.root||""}get sector(){return this._syminfo.sector}get session(){return this._syminfo.session||ut.regular}get shareholders(){return this._syminfo.shareholders}get shares_outstanding_float(){return this._syminfo.shares_outstanding_float}get shares_outstanding_total(){return this._syminfo.shares_outstanding_total}get target_price_average(){return this._syminfo.target_price_average}get target_price_date(){return this._syminfo.target_price_date}get target_price_estimates(){return this._syminfo.pricescale}get target_price_high(){return this._syminfo.target_price_high}get target_price_low(){return this._syminfo.target_price_low}get target_price_median(){return this._syminfo.target_price_median}get ticker(){return this._syminfo.ticker||""}get tickerid(){return this._syminfo.tickerid||""}get timezone(){return this._syminfo.timezone||"UTC+8"}get type(){return this._syminfo.type}get volumetype(){return this._syminfo.volumetype||"n/a"}}class am{constructor(e){E(this,"_variables");this._variables=e}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class um{constructor(e){E(this,"_variables");this._variables=e}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}class qp{constructor(e){E(this,"_cacheData");E(this,"_barIndex");E(this,"_isRealTimeBar");E(this,"_barstate");E(this,"_priceVariables");E(this,"_lastBarIndex");E(this,"_currentBarTime");E(this,"_lastBarTime");E(this,"_period");E(this,"_offsetTime");E(this,"_timeframe");E(this,"_ta");E(this,"_polyline");E(this,"_label");E(this,"_line");E(this,"_linefill");E(this,"_box");E(this,"_table");E(this,"_strategy");E(this,"_session");E(this,"syminfo");E(this,"chart");E(this,"earnings");E(this,"dividends");E(this,"_timeTradingday");E(this,"_mintick");E(this,"_cacheSpace");E(this,"_precision");E(this,"_nextBarTime");E(this,"_isRepeated");E(this,"_preCacheData");E(this,"__requestName","");E(this,"__isFirstRun",!1);this._cacheData={varData:{},varipData:{}},this._preCacheData={varData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new bm,this._timeframe=new cm,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new im(e),this._polyline=new Cr(this),this._label=new Cr(this),this._line=new Cr(this,Z0.LINE),this._linefill=new Cr(this,Z0.LINEFILL),this._box=new Cr(this),this._table=new Cr(this),this._strategy=new zm(this),this._session=new pm(this),this.syminfo=new Om,this.chart=new sm,this.earnings=new um(this),this.dividends=new am(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:e,open:t,high:r,low:o}=this._priceVariables;return(e+t+r+o)/4}get hl2(){const{high:e,low:t}=this._priceVariables;return(e+t)/2}get hlc3(){const{close:e,high:t,low:r}=this._priceVariables;return(e+t+r)/3}get hlcc4(){const{close:e,high:t,low:r}=this._priceVariables;return(e*2+t+r)/4}get hour(){return D1(this._currentBarTime).hour()}get minute(){return D1(this._currentBarTime).minute()}get second(){return D1(this._currentBarTime).second()}get month(){return D1(this._currentBarTime).month()+1}get year(){return D1(this._currentBarTime).year()}get dayofweek(){return D1(this._currentBarTime).day()}get dayofmonth(){return D1(this._currentBarTime).date()}get weekofyear(){return D1(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[e,t]=OM(this._period);return this._isRealTimeBar?void 0:D1(this._currentBarTime).add(e,t).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}get nextBarTime(){return this._nextBarTime}updateMaxLength(e){const{max_lines_count:t,max_labels_count:r,max_boxes_count:o,max_polylines_count:n}=e;o&&this._box.setMaxLen(o),r&&this._label.setMaxLen(r),t&&this._line.setMaxLen(t),n&&this._polyline.setMaxLen(n)}getTimeTradingday(e,t){const[r,o]=OM(t),n=D1(e);return["M","w","y","d"].includes(o)?n.valueOf():(n.subtract(this._offsetTime,"h"),n.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(e){var s;const{interval:t="1D",offsetTime:r=5,mintick:o,chart:n,syminfo:p}=e,z=((s=o.toString().split(".")[1])==null?void 0:s.length)||5;this._precision=z;const i=Ac(t);this._period=i,this._mintick=o,this._offsetTime=r,this._timeframe.update(i),this.chart.updateOptions(n),this.syminfo.update(p)}updateData(e,t){const{barIndex:r,c:o,o:n,h:p,l:z,volume:i,time:s,lastBarIndex:a,lastBarTime:O,isrealtime:u,time_tradingday:l,nextBarTime:d}=e;if(this._priceVariables={close:Number(o),open:Number(n),high:Number(p),low:Number(z),volume:Number(i)},this._isRealTimeBar=u,r>this._barIndex){const{varData:f,varipData:h}=this._cacheData;this._preCacheData={varData:{...f},varipData:{...h}}}this._isRepeated=t,this._timeTradingday=l,this._currentBarTime=s*1e3,this._lastBarIndex=a,this._barIndex=r,this._lastBarTime=O*1e3,this._nextBarTime=d*1e3,this._barstate.update(r,a,u,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(e,t,r){const o=this.setCacheData(e,r),n=this._cacheSpace.get(e)||0;return t=Math.floor(t),n<t&&this._cacheSpace.set(e,t),o[o.length-1-t]}setCacheData(e,t){let r=this._cacheData[e]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=t:r.data.push(t);const o=this._cacheSpace.get(e);return o&&r.data.length>o+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[e]=r,r.data}getTypeInstance(e,t){return new gu(e,t)}verifyVarAndVarip(e,t,r){const o=`${e}_${t}`,n=this._isRepeated?this._preCacheData:this._cacheData;return r==="var"&&n.varData.hasOwnProperty(o)?(this._upadteChartDraws(n.varData[o]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(o)?(this._upadteChartDraws(this._cacheData.varipData[o]),!0):!1}getVarValue(e,t,r){const o=`${e}_${t}`,n=this._isRepeated?this._preCacheData:this._cacheData;if(r==="var"){if(this._isRealTimeBar){const p=n.varData[o];return typeof p!="object"||p!=null&&p.type?p:p!=null&&p.copy?p.copy():Object.assign({},p)}return n.varData[o]}return this._cacheData.varipData[o]}setVarValue(e,t,r,o){var z;if(this._isRepeated&&o==="var")return this.getVarValue(e,t,o);const n=`${e}_${t}`;let p;switch(typeof r=="object"&&((z=r==null?void 0:r.varipKeys)!=null&&z.length)&&(o="var",p=r.varipKeys),o){case"var":if(this._isRealTimeBar){if(p&&p.length)for(const i of p)this._cacheData.varData[n][i]=r[i]}else this._chartDrawsHandle(r,this._cacheData.varData[n]),this._cacheData.varData[n]=r;break;case"varip":this._chartDrawsHandle(r,this._cacheData.varipData[n]),this._cacheData.varipData[n]=r;break}return r}_upadteChartDraws(e){const t=this._isRealTimeBar?e==null?void 0:e.preId:e==null?void 0:e.id;if(t)switch(e==null?void 0:e.type){case Z0.BOX:this._setChartDraw(t,this._box);break;case Z0.LINE:this._setChartDraw(t,this._line);break;case Z0.POLYLINE:this._setChartDraw(t,this._polyline);break;case Z0.LABEL:this._setChartDraw(t,this._label);break;case Z0.LINEFILL:this._setChartDraw(t,this._linefill);break;case Z0.TABLE:this._setChartDraw(t,this._table);break}}_setChartDraw(e,t){const r=t.getInstance(e),o=t.get(e);if(!o||!r)return;const n=r.updateId()||e;n===e&&!this._isRealTimeBar||(t.deleteHandle(e),t.set(n,o,r))}_chartDrawsHandle(e,t){const r=t==null?void 0:t.id;let o=e==null?void 0:e.id;o&&e.data&&(e.data.isVar=!0),r!==o&&r&&t.data&&(t.data.isVar=!1)}add(e,t){return Array.isArray(e)&&Array.isArray(t)?L2.uniq([...e,...t]):typeof e=="number"||typeof t=="number"?Number(e)+Number(t):(e||"")+(t||"")}sub(e,t){return Array.isArray(e)&&Array.isArray(t)?e.filter(r=>!t.includes(r)):Number(e)-Number(t)}div(e,t){if(t)return e/t}equal(e,t,r,o){if(e!==void 0&&t!==void 0)return e==t;if(!(r.endsWith(Z0.BOOL)&&e===void 0))return(r.endsWith(Z0.FLOAT)||r.endsWith(Z0.INT)||o.endsWith(Z0.FLOAT)||o.endsWith(Z0.INT))&&e===void 0&&t===void 0?!1:r.endsWith(Z0.STRING)&&e===""&&t===void 0||o.endsWith(Z0.STRING)&&t===""&&e===void 0?!0:r.endsWith(Z0.NA)&&o.endsWith(Z0.NA)?!1:e==t}compareDataHandle(e){if(typeof e!="number")return e;const t=String(e);if(!t.includes(".")&&!t.includes("-"))return e;const[r,o]=e.toFixed(20).split(".");return+`${r}.${o.slice(0,10)}`}againAssignParse(e,t){var o;if(t)return;const r=(o=e==null?void 0:e.constructor)==null?void 0:o.name;if(r)switch(r){case Ko.name:case Es.name:case Zo.name:case Ts.name:case Jo.name:case Qo.name:e==null||e.delete();break}}}class Cr{constructor(e,t,r=50){E(this,"_all");E(this,"_allInstance");E(this,"_pseudoArrayAll");E(this,"_maxLength");E(this,"_deleteIds");E(this,"_variables");E(this,"_preDeleteIds");E(this,"_againAddItems");E(this,"_tmpData");E(this,"_tmpInstance");E(this,"_type");E(this,"_tmpIds",[]);this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new n1,this._maxLength=r,this._deleteIds=new Map,this._variables=e,this._preDeleteIds=new Map,this._againAddItems=[],this._tmpData=new Map,this._tmpInstance=new Map,this._type=t}setMaxLen(e){this._maxLength=e}get size(){return this._all.size+this._tmpData.size}get data(){const e=[],t=L2.flatMap([...this._deleteIds.values()]),r=L2.uniq([...this._all.keys(),...this._tmpData.keys()]);for(const o of r)if(!t.some(n=>n.key===o)){const n=this._tmpData.get(o)||this._all.get(o);n&&e.push(n)}return this._variables._isRealTimeBar&&this._preDeleteIds.set(this._variables.last_bar_index,this._deleteIds.get(this._variables.last_bar_index)||[]),this._tmpDataHandle(),this._type===Z0.LINEFILL?e:e.slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values(),...this._tmpInstance.values()],this._pseudoArrayAll}add(e,t,r){if(this.set(e,t,r),!this._variables._isRealTimeBar&&this._type!==Z0.LINEFILL&&this._all.size>this._maxLength){const{bar_index:o}=t;for(const[n,p]of this._all){const{isVar:z,id:i,bar_index:s}=p;if(s===o)break;if(z)continue;this.deleteHandle(i);break}}}getValOfBarIndex(e){let t=[];const r=L2.uniq([...this._all.keys(),...this._tmpData.keys()]),o=L2.flatMap([...this._deleteIds.values()]);for(const n of e){const p=r.filter(z=>z.endsWith(`_${n}`));for(const z of p){if(o.some(s=>s.key===z))continue;const i=this._tmpData.get(z)||this._all.get(z);i&&t.push(i)}}return this._againAddItems.length&&(t=this._againAddItems.concat(t),this._againAddItems=[]),this._tmpDataHandle(),t.length?this._type===Z0.LINEFILL?t:t.slice(-this._maxLength):void 0}getDeleteIds(e){let t=[];const{bar_index:r,_isRealTimeBar:o}=this._variables,n=[];for(const p of e){let z=[...this._deleteIds.get(p)||[]];const i=this._preDeleteIds.get(p)||[];if(p===r&&o){let s=[];for(const a of i){const O=z.findIndex(u=>u.id===a.id);if(O===-1){const u=this._all.get(a.key);u&&n.push(u)}else s.push(a),z.splice(O,1)}this._preDeleteIds.set(r,L2.uniqBy([...z,...s],"id"))}else{const s=[];for(const a of this._tmpIds)!this._all.has(a.key)&&!this._tmpData.has(a.key)&&s.push(a);for(const a of z)i.some(O=>O.id===a.id)||s.push(a);z=s,this._preDeleteIds.delete(p)}t=t.concat(z)}return this._againAddItems=n,L2.uniq(t.map(p=>p.id))}set(e,t,r){this._variables._isRealTimeBar?(this._tmpData.set(e,t),this._tmpInstance.set(e,r)):(this._all.set(e,t),this._allInstance.set(e,r))}get(e){const t=this._all.get(e);let r=this._tmpData.get(e);return this._variables._isRealTimeBar?(r||(r=t?{...t}:void 0,r&&this._tmpData.set(e,r)),r):(this._tmpData.clear(),this._tmpInstance.clear(),t)}getInstance(e){return this._allInstance.get(e)}deleteHandle(e){var t;if(this._type===Z0.LINE){const r=(t=this._allInstance.get(e))==null?void 0:t.__fillKeys;if(r&&r.length)for(const o of r)this._variables.linefill.deleteHandle(o)}this._variables._isRealTimeBar?(this._tmpData.delete(e),this._tmpInstance.delete(e)):(this._all.delete(e),this._allInstance.delete(e))}delete(e,t){const r=this._all.get(e);if(this._variables._isRealTimeBar||this.deleteHandle(e),!(this._variables.__isFirstRun&&!this._variables._isRealTimeBar)&&typeof t=="number"){const o=this._deleteIds.get(t)||[];o.push({key:e,id:(r==null?void 0:r.id)||e}),this._deleteIds.set(t,o)}}_tmpDataHandle(){var e;this._tmpIds=[];for(const[t]of this._tmpInstance){const r=(e=this._tmpData.get(t))==null?void 0:e.id;r&&this._tmpIds.push({id:r,key:t})}this._tmpData.clear(),this._tmpInstance.clear(),this._deleteIds.clear()}}/**
85
+ ${l}`),l}_getRequestLowerTfData(e,t,r,o){var L;let{symbol:n,timeframe:p,calc_bars_count:z,ignore_invalid_symbol:i,ignore_invalid_timeframe:s}=e;const{__period:a,time:O,_isRealTimeBar:u}=this._variables;p=hr(p);let l=y2(p,O)*1e3;const d=y2(a,O)*1e3;if(l>d)return!s&&this._errorListener.addError(r2(d1.requestLowerTfPeriodErr,{period:p}),t,Y0.Error,25),o;const f=`${n}--${p}`,h=self.workerStorage.get(`request_${this._scriptId}_data`),q=self.workerStorage.get(`request_${this._scriptId}_list`),m=self.workerStorage.get(`request_${this._scriptId}_tmp`),_={id:f,calc_bars_count:z,ignore_invalid_symbol:i,symbol:n,originTimeframe:p,timeframe:ii[p]||ic(p)};if(h!=null&&h.has(f)){m==null||m.delete(f);const{index:g=0,periodStamp:v=d}=this._cacheData.get(r)||{},y=h==null?void 0:h.get(f);if(!y.length||y.length-1<0)return o;const T=y.slice(g);let N=O,w=v+N;const C=[];for(const[P,H]of T.entries()){let{time:Y}=H;Y=Y*1e3;let k=g+P;if(Y>=w)return!u&&this._cacheData.set(r,{index:k,periodStamp:v}),C;if(N<=Y&&Y<w){const J=(L=H==null?void 0:H.result)==null?void 0:L[r];if(Array.isArray(J))for(const[e0,z0]of J.entries())C[e0]||(C[e0]=[]),C[e0].push(z0);else C.push(J)}}return!u&&this._cacheData.set(r,{index:y.length,periodStamp:v}),C}else(q==null?void 0:q.get(f))||m==null||m.set(f,_);q==null||q.set(f,_)}_getRequestData(e,t){var m,_,L,g,v;let{symbol:r,timeframe:o,calc_bars_count:n,gaps:p,lookahead:z,ignore_invalid_symbol:i}=e;const{__period:s,mintick:a,time:O,nextBarTime:u}=this._variables;o=hr(o),r=r;const l=`${r}--${o}`,d=self.workerStorage.get(`request_${this._scriptId}_data`),f=self.workerStorage.get(`request_${this._scriptId}_list`),h=self.workerStorage.get(`request_${this._scriptId}_tmp`),q={id:l,calc_bars_count:n,ignore_invalid_symbol:i,symbol:r,originTimeframe:o,timeframe:ii[o]||ic(o)};if(d!=null&&d.has(l)){let y=y2(o,O)*1e3;const X=y2(s,O)*1e3;h==null||h.delete(l);const{index:T=0,periodStamp:N=X}=this._cacheData.get(t)||{},w=d==null?void 0:d.get(l);if(!w.length)return;const C=w.slice(T);let P=O,H=N+P;const Y=w.length-1;if(Y<0)return;const k={lastBarIndex:w[Y].barindex||Y,lastBarTime:w[Y].time,interval:o,mintick:a};if(y>N){let J;if(z===Pe.lookaheadOn?J=this._lookaheadOnHandle(C,o,H,y,k,T,N,t,P,p):J=this._lookaheadOffHandle(C,o,H,y,k,T,N,t,P,u||H,p),J)return J;if(J===null)return}else if(z===Pe.lookaheadOn)for(const[J,e0]of C.entries()){let{time:z0,barindex:a0}=e0;z0=z0*1e3;const R0=((m=C[J+1])==null?void 0:m.time)*1e3||z0+y;let v0=T+J;if(z0>=H){this._cacheData.set(t,{index:v0,periodStamp:N});return}if(z0<=P&&R0>P){const u0=T+J;return this._cacheData.set(t,{index:u0,periodStamp:N}),{...e0,barIndex:a0||u0,nextBarTime:(_=C[J+1])==null?void 0:_.time,...k}}}else for(const[J,e0]of C.entries()){let{time:z0,barindex:a0}=e0;z0=z0*1e3;const R0=((L=C[J+1])==null?void 0:L.time)*1e3||z0+y;let v0=T+J;if(z0>H){this._cacheData.set(t,{index:v0,periodStamp:N});return}if(z0<H&&H<=R0)return this._cacheData.set(t,{index:v0,periodStamp:N}),{...e0,barIndex:a0||v0,nextBarTime:(g=C[J+1])==null?void 0:g.time,...k};if(z0>=P&&z0<=H&&(a0||v0)===k.lastBarIndex)return this._cacheData.set(t,{index:v0,periodStamp:N}),{...e0,barIndex:a0||v0,nextBarTime:(v=C[J+1])==null?void 0:v.time,...k}}this._cacheData.set(t,{index:w.length,periodStamp:N});return}else(f==null?void 0:f.get(l))||h==null||h.set(l,q);f==null||f.set(l,q)}_lookaheadOnHandle(e,t,r,o,n,p,z,i,s,a){var O;for(const[u,l]of e.entries()){let{time:d,barindex:f}=l;d=d*1e3,t.includes("M")&&(o=y2(t,d)*1e3-(D1(d).date()-1)*864e5);const h=d,q=o+h;let m=p+u;if(r<=h)return this._cacheData.set(i,{index:m,periodStamp:z}),null;let _={...l,barIndex:f||m,nextBarTime:(O=e[u+1])==null?void 0:O.time,...n};if(a===Pe.gapsOn){if(r>h&&s<=h)return this._cacheData.set(i,{index:m,periodStamp:z}),_}else{if(r>q)continue;if(r>h)return this._cacheData.set(i,{index:m,periodStamp:z}),_}}}_lookaheadOffHandle(e,t,r,o,n,p,z,i,s,a,O){var u,l;for(const[d,f]of e.entries()){let{time:h,barindex:q}=f;h=h*1e3,t.includes("M")&&(o=y2(t,h)*1e3-(D1(h).date()-1)*864e5);const m=h,_=o+m,L=p+d;if(r<m)return this._cacheData.set(i,{index:L,periodStamp:z}),null;const g={...f,barIndex:q||L,nextBarTime:(u=e[d+1])==null?void 0:u.time,...n};if(r>=_&&s<_||r<_&&a>=_)return O===Pe.gapsOn?(this._cacheData.set(i,{index:L,periodStamp:z}),g):(this._cacheData.set(i,{index:L,data:g,periodStamp:z}),g);if(!(s>_)&&s>=m){let v=(l=this._cacheData.get(i))==null?void 0:l.data;if(!v){const y=e[L-1];if(!y)return null;v={...y,barIndex:y.barindex||L-1,nextBarTime:g.time,...n},this._cacheData.set(i,{index:L,data:v,periodStamp:z})}return v}}}_getDependCodes(e,t,r,o,n,p){for(const z of e){if(!z.isArg){const i=t.filter(a=>{var O;return(O=a==null?void 0:a.depends)==null?void 0:O.some(u=>u.name===z.name&&u.scope===z.scope&&u.isAgainAssign!==!1)});for(const a of i){const{code:O,depends:u,scope:l,funcName:d}=a;r[l]=r[l]||[];const f=r[l];let h=l===0&&d;if(!f.includes(O)){if(h){if(o.includes(O))continue;o.unshift(O)}else f.unshift(O);if(u!=null&&u.length){for(const q of u)q.memberCode&&!h&&p.push(q.memberCode);this._getDependCodes(u,t,r,o,n,p)}}}const s=t.find(a=>{var O;return((O=a.varNames)==null?void 0:O.split(", ").includes(z.name))&&(!z.isPreArg||z.isPreArg&&a.methodName===z.functionName)||a.funcName===z.name});if(s){const{code:a,depends:O,scope:u}=s;r[u]=r[u]||[];const l=r[u],d=l.findIndex(f=>f===a);if(d!==-1){if(z.isFunc)continue;l.splice(d,1)}if(l.unshift(a),O!=null&&O.length){for(const f of O)f.memberCode&&p.push(f.memberCode);this._getDependCodes(O,t,r,o,n,p)}continue}}n.some(i=>i.name===z.name)||n.push(z)}}_getStmtFuncs(e,t,r,o,n){const p=t.filter(z=>z.isStmtFunc);for(const z of p){const{code:i,depends:s,scope:a=0}=z;e[a]=e[a]||[];const O=e[a];if(!O.includes(i)&&(O.push(i),s!=null&&s.length)){for(const u of s)u.memberCode&&r.push(u.memberCode);this._getDependCodes(s.filter(u=>!(u.isFunc&&i.startsWith(u.name))),t,e,o,n,r)}}}runScripts(e,t,r,o,n,p){var u;const z=`${this._scriptId}_${t}`;let{builtInGather:i,buildinConstants:s,buildInFunctions:a,tradingvueFunc:O}=self.workerStorage.get(z)||{};if(r&&(i=new qp(z),s=new Ap,a=new lp(this._variables.mintick||1e-5,i,this._scriptId),O=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",e),i.__requestName=t,self.workerStorage.set(z,{builtInGather:i,buildinConstants:s,buildInFunctions:a,tradingvueFunc:O})),o&&o.length){const l=o.length-1,{interval:d,symbol:f=""}=n,{mintick:h,syminfo:q}=this._variables,[m,_]=f.split(":");i.updateOptions({interval:d,mintick:h,syminfo:{...q.__syminfo,tickerid:f||q.tickerid,ticker:_||m||q.ticker}});for(const[v,y]of o.entries()){const{barindex:X}=y,T=Object.assign(y,{barIndex:X||v,lastBarIndex:o[l].barindex||l,lastBarTime:o[l].time,nextBarTime:(u=o[v+1])==null?void 0:u.time});if(i.updateData(T),a.update({barIndex:(T==null?void 0:T.barindex)||0}),y.result=Object.assign(y.result||{},{[t]:O(i,s,a,p||[],t)}),a.endExecution(),a.errors.length&&a.errors.some(N=>N.type===Y0.Error))return{logs:[],errors:a.errors}}const L=a.log.logs,g=a.errors;return a.log.clearLogs(),a.clearErrors(),{logs:L,errors:g}}}_runScripts(e,t,r,o,n){const p=`${this._scriptId}_${t}`;let{builtInGather:z,buildinConstants:i,buildInFunctions:s,tradingvueFunc:a}=self.workerStorage.get(p)||{};const{interval:O,...u}=n||{};if(r){z=new qp(p),i=new Ap,s=new lp(this._variables.mintick||1e-5,z,this._scriptId),a=new Function("$_var","$_const","$_func","$paramsExpr","$posStr",e);const{mintick:h,syminfo:q}=this._variables;z.updateOptions({interval:O,mintick:h||1e-5,syminfo:{...q.__syminfo}}),z.__requestName=t,self.workerStorage.set(p,{builtInGather:z,buildinConstants:i,buildInFunctions:s,tradingvueFunc:a})}z.updateData(u),s.update({barIndex:(u==null?void 0:u.barindex)||0});const l=a(z,i,s,o||[],t),d=s.log.logs,f=s.errors;return s.log.clearLogs(),s.clearErrors(),s.endExecution(),{result:l,logs:d,errors:f}}},rm=class{constructor(){}prefix(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[0])||""}ticker(e){var r;const{symbol:t}=e;return((r=t==null?void 0:t.split("."))==null?void 0:r[1])||""}};class Mm{constructor(e,t){E(this,"_logs");E(this,"_variables");E(this,"_str");E(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=e,this._logs=[],this._str=t}get logs(){return this._logs}clearLogForIndex(e){this._logs=this._logs.filter(t=>t.barIndex!==e)}clearLogs(){this._logs=[]}info(e,t,r){this._addLog(e,t,"info",r)}error(e,t,r){this._addLog(e,t,"error",r)}warning(e,t,r){this._addLog(e,t,"warning",r)}mergeLogs(e){this._logs=this._logs.concat(e)}_addLog(e,t,r,o){if(typeof t=="string"&&(o=t),o.startsWith("export"))return;const{message:n,formatString:p}=e,{time:z,bar_index:i,_isRealTimeBar:s}=this._variables;let a=n;p&&Array.isArray(t)&&t.length&&(t=t.map(l=>(typeof l=="object"&&(l.isArray?l=JSON.stringify(l._value):l=l.toString()),l!==void 0?l:"na")),a=this._str.strformat({formatString:p},t,!0));const{isrealtime:O}=this._preBar;this._preBar={barIndex:i,isrealtime:s};const u=Date.now();a!==void 0&&this._logs.push({message:`[${D1(O||s?u:z).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${a}`,time:z,id:Sl(6),barIndex:i,type:r})}}class om{constructor(e){E(this,"_errorListener");this._errorListener=e}error({message:e},t){t.startsWith("export")||this._errorListener.addError(e,t,Y0.Error)}}class nm{constructor(){E(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return L2.flatMap([...this._errors.values()])}setErrors(e,t){this._errors.set(t,e)}addError(e,t,r,o=0){const[n,p]=t.split("_").slice(-2),z=this._errors.get(t),i={message:e,endLineNumber:Number(n),startColumn:Number(p)+1,endColumn:Number(p)+o+1,startLineNumber:Number(n),type:r};z?z.push(i):this._errors.set(t,[i])}}class bm{constructor(){E(this,"_isMarketOpen");E(this,"_currentBarIndex");E(this,"_totalBarIndex");E(this,"_isRealTimeBar");E(this,"_preBarIndex");E(this,"_preIsRealTimeBar");this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0,this._preIsRealTimeBar=!1}update(e,t,r,o){this._preBarIndex=this._currentBarIndex,this._preIsRealTimeBar=this._isRealTimeBar,this._currentBarIndex=e,this._totalBarIndex=t,this._isRealTimeBar=r,this._isMarketOpen=o}get isnew(){return!this._isRealTimeBar||this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar}get isrealtime(){return this._isRealTimeBar}get isconfirmed(){return!this._isRealTimeBar}get islastconfirmedhistory(){return this._isMarketOpen?this._currentBarIndex===this._totalBarIndex-1&&!this._preIsRealTimeBar||this._currentBarIndex===this._totalBarIndex&&!this._isRealTimeBar:this._currentBarIndex===this._totalBarIndex}}class pm{constructor(e){E(this,"_variables");this._variables=e}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get isfirstbar_regular(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday}get islastbar(){if(this._variables.timeframe.isdwm)return!0;const{time:e,__period:t}=this._variables,r=y2(t,e);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get islastbar_regular(){if(this._variables.timeframe.isdwm)return!0;const{time:e,__period:t}=this._variables,r=y2(t,e);return this._variables.time+r===this._variables.time_tradingday+24*60*60*1e3}get ismarket(){return!0}get ispostmarket(){return!1}get ispremarket(){return!1}}class zm{constructor(e){E(this,"_orders");E(this,"_historyOrders");E(this,"_options");E(this,"_max_contracts_held_all",0);E(this,"_max_contracts_held_long",0);E(this,"_max_contracts_held_short",0);E(this,"_max_drawdown",0);E(this,"_max_runup",0);E(this,"_max_runup_percent",0);E(this,"_max_drawdown_percent",0);E(this,"_variables");E(this,"_netprofit",0);E(this,"_eventrades",0);E(this,"_avg_trade_percent");E(this,"_avg_losing_trade_percent");E(this,"_avg_winning_trade_percent");E(this,"_closedtrades",0);E(this,"_losstrades",0);E(this,"_grossloss",0);E(this,"_grossprofit",0);E(this,"_wintrades",0);E(this,"_opentrades_capital_held",0);E(this,"_position_avg_price",0);E(this,"_position_size",0);E(this,"_openprofit",0);E(this,"_preMaxNetValue",0);E(this,"_preMinNetValue",0);E(this,"marginCallLong",0);E(this,"marginCallShort",0);this._orders=[],this._historyOrders=[],this._variables=e}update(e){this._calcMaxDrawdownAndMaxRunup(e)}_calcMaxDrawdownAndMaxRunup(e){if(!this._orders.length&&!this._historyOrders.length)return;let t=0,r=0;const{high:o,low:n,close:p}=e;let z=0;for(const[a,O]of this._orders.entries()){const{in_price:u,qty:l=0,direction:d,commission:f,original_qty:h=1}=O,q=d===i1.long?1:-1,m=(o-u)*l,_=(n-u)*l,L=q===1?m:-_,g=q===1?-_:m;z+=(p-u)*q*l,t+=g,a>0&&f&&(r-=f*l/h),r+=L}this._openprofit=z;const i=this.initial_capital,s=i+this._netprofit;this._preMinNetValue=this._preMinNetValue||i,this._preMaxNetValue=this._preMaxNetValue||i,t=this._preMaxNetValue-s+Math.max(t,0),r=s-this._preMinNetValue+r,this._max_drawdown<t&&(this._max_drawdown=t,this._max_drawdown_percent=t/this._preMaxNetValue*100),r>this._max_runup&&(this._max_runup=r,this._max_runup_percent=r/(this._preMinNetValue+r)*100)}updateOrders(e){this._orders=e,this._calcMaxContracts()}_calcMaxContracts(){const e=this._orders.length;if(!e){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[t,r,o,n,p,z,i]=this._orders.reduce(([s,a,O,u,l,d,f],h)=>{const{direction:q,qty:m=0,in_price:_,commission:L=0}=h;return q===i1.long?(s+=m,a+=m,d+=m):(s+=m,O+=m,d-=m),u+=m*_,l+=_,f+=L,[s,a,O,u,l,d,f]},[0,0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-i,this._grossloss=i),this._position_size=z,this._position_avg_price=p/e,this._opentrades_capital_held=n,this._max_contracts_held_all=Math.max(t,this._max_contracts_held_all),this._max_contracts_held_long=Math.max(r,this._max_contracts_held_long),this._max_contracts_held_short=Math.max(o,this._max_contracts_held_short)}updateHistoryOrders(e){this._historyOrders=e;const t=this._historyOrders.length;this._closedtrades=t;const[r,o,n,p,z,i,s,a]=this._historyOrders.reduce((l,d)=>{let[f,h,q,m,_,L,g,v]=l;const{profit:y=0,profit_percent:X=0}=d;return f+=y,h+=X,y<0?(q+=y,m+=X,g+=1):y>0&&(_+=y,L+=X,v+=1),[f,h,q,m,_,L,g,v]},[0,0,0,0,0,0,0,0]),O=this._orders.reduce((l,d)=>{const{commission:f=0,qty:h=0,original_qty:q=0}=d,m=f*h/q;return l+m},0);this._avg_trade_percent=t?o/t:void 0,this._avg_losing_trade_percent=t?Math.abs(p)/s:void 0,this._avg_winning_trade_percent=t?i/a:void 0,this._netprofit=r-O;const u=this.initial_capital+this._netprofit;this._preMaxNetValue=Math.max(this._preMaxNetValue||this.initial_capital,u),this._preMinNetValue=Math.min(this._preMinNetValue||this.initial_capital,u),this._grossloss=Math.abs(n-O),this._grossprofit=z,this._eventrades=t-s-a,this._losstrades=s,this._wintrades=a}updateStrategyOptions(e){this._options=e}get long(){return"long"}get short(){return"short"}get account_currency(){return"USD"}get closedtrades(){return this._closedtrades}get opentrades(){return{opentrades:this._orders.length,capital_held:this._opentrades_capital_held}}get avg_losing_trade(){const e=this._losstrades;return e?Math.abs(this._grossloss/e):void 0}get avg_losing_trade_percent(){return this._avg_losing_trade_percent}get avg_trade(){if(this._closedtrades)return this._netprofit/this._closedtrades}get equity(){return this.initial_capital+this._netprofit+this._openprofit}get netprofit(){return this._netprofit}get eventrades(){return this._eventrades}get openprofit(){return this._openprofit}get avg_trade_percent(){return this._avg_trade_percent}get avg_winning_trade(){const e=this._wintrades;return e?Math.abs(this._grossprofit/e):void 0}get avg_winning_trade_percent(){return this._avg_winning_trade_percent}get initial_capital(){var e;return((e=this._options)==null?void 0:e.initial_capital)||0}get losstrades(){return this._losstrades}get grossloss(){return this._grossloss}get grossloss_percent(){return this._grossloss/this.initial_capital*100}get grossprofit(){return this._grossprofit}get grossprofit_percent(){return this._grossprofit/this.initial_capital*100}get wintrades(){return this._wintrades}get margin_liquidation_price(){if(!this._options)return;const{initial_capital:e,margin_long:t=0,margin_short:r=0,commission_type:o,commission_value:n=0}=this._options,p=this._orders[0].direction===i1.long?1:-1,z=(p===1?t:r)/100;if(z<=0)return;const{close:i}=this._variables,[s,a]=this._orders.reduce((O,u)=>{let[l,d]=O;const{in_price:f,qty:h=0,original_qty:q=0}=u,m=f*h;if(l+=m,n){let _=0;switch(o){case O2.percent:_=(m+h*i)*n/100;break;case O2.cashPerContract:_=h*n*2;break;case O2.cashPerOrder:_=h/q*n+n;break}d+=_}return[l,d]},[0,0]);return(s-(e+this._netprofit-a))*p/this._position_size/(1-p*z)}get max_contracts_held_all(){return this._max_contracts_held_all}get max_contracts_held_long(){return this._max_contracts_held_long}get max_contracts_held_short(){return this._max_contracts_held_short}get max_drawdown(){return this._max_drawdown}get max_runup(){return this._max_runup}get max_runup_percent(){return this._max_runup_percent}get max_drawdown_percent(){return this._max_drawdown_percent}get netprofit_percent(){return this._netprofit/this.initial_capital*100}get openprofit_percent(){return this._openprofit/(this.initial_capital+this._netprofit)*100}get position_avg_price(){return this._position_avg_price}get position_entry_name(){if(this._orders.length)return this._orders[0].id}get position_size(){return this._position_size}get summaryData(){return{position_size:this.position_size,position_avg_price:this.position_avg_price,position_entry_name:this.position_entry_name,openprofit_percent:this.openprofit_percent,netprofit_percent:this.netprofit_percent,max_drawdown_percent:this.max_drawdown_percent,max_runup_percent:this.max_runup_percent,max_drawdown:this.max_drawdown,max_runup:this.max_runup,max_contracts_held_long:this.max_contracts_held_long,max_contracts_held_short:this.max_contracts_held_short,max_contracts_held_all:this.max_contracts_held_all,avg_winning_trade_percent:this.avg_winning_trade_percent,avg_winning_trade:this.avg_winning_trade,avg_trade_percent:this.avg_trade_percent,avg_trade:this.avg_trade,avg_losing_trade:this.avg_losing_trade,avg_losing_trade_percent:this.avg_losing_trade_percent,wintrades:this.wintrades,losstrades:this.losstrades,eventrades:this.eventrades,grossprofit:this.grossprofit,grossprofit_percent:this.grossprofit_percent,grossloss:this.grossloss,grossloss_percent:this.grossloss_percent,openprofit:this.openprofit,initial_capital:this.initial_capital,netprofit:this.netprofit,closedtrades:this.closedtrades,opentrades:this.opentrades,equity:this.equity,margin_call_long:this.marginCallLong,margin_call_short:this.marginCallShort}}_getCommission(e,t){if(!this._options)return 0;const{commission_value:r=0,commission_type:o}=this._options,n=e*t;let p=0;switch(o){case O2.percent:p=n*r/100;break;case O2.cashPerContract:p=t*r;break;case O2.cashPerOrder:p=r;break}return p}}class im{constructor(e){E(this,"_preAccdist");E(this,"_preNvi");E(this,"_prePvi");E(this,"_preObv");E(this,"_prePvt");E(this,"_preWad");E(this,"_preVwap");E(this,"_preValue");E(this,"_currentData");E(this,"_preData");E(this,"_id");this._preAccdist=0,this._preNvi=0,this._prePvi=0,this._preObv=0,this._prePvt=0,this._preWad=0,this._preVwap={},this._preValue={},this._currentData={},this._preData={},this._id=e}update(e){this._preValue={},e.barIndex!==this._currentData.barIndex&&(this._preData={...this._currentData}),this._currentData={...e}}get isRealTime(){return this._preData.barIndex===this._currentData.barIndex}get accdist(){if(this._preValue.accdist)return this._preValue.accdist;const{close:e,low:t,high:r,volume:o}=this._currentData;if(r===t)return this._preAccdist;const n=(e-t-(r-e))/(r-t)*o+this._preAccdist;return!this.isRealTime&&(this._preAccdist=n),this._preValue.accdist=n,n}get iii(){if(this._preValue.iii)return this._preValue.iii;const{close:e,low:t,high:r,volume:o}=this._currentData,n=(2*e-r-t)/((r-t)*o);return this._preValue.iii=n,n}get nvi(){return this._preValue.nvi?this._preValue.nvi:this._getNvi()}get wvad(){if(this._preValue.wvad)return this._preValue.wvad;const{close:e,low:t,high:r,volume:o,open:n}=this._currentData,p=(e-n)/(r-t)*o;return this._preValue.wvad=p,p}get obv(){if(this._preValue.obv)return this._preValue.obv;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._preObv=0;return}const o=Math.sign(e-r)*t+this._preObv;return!this.isRealTime&&(this._preObv=o),this._preValue.obv=o,o}get pvi(){return this._preValue.pvi?this._preValue.pvi:this._getPvi()}get tr(){if(this._preValue.tr)return this._preValue.tr;const{low:e,high:t}=this._currentData,{close:r}=this._preData;if(r===void 0)return;const o=Math.max(t-e,Math.abs(t-r),Math.abs(e-r));return this._preValue.tr=o,o}get pvt(){if(this._preValue.pvt)return this._preValue.pvt;const{close:e,volume:t}=this._currentData,{close:r}=this._preData;if(r===void 0){this._prePvt=0;return}const o=(e-r)/r*t+this._prePvt;return!this.isRealTime&&(this._prePvt=o),this._preValue.pvt=o,o}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:e,high:t,low:r}=this._currentData,{close:o}=this._preData;if(o===void 0)return this._preWad=0,0;const n=Math.max(t,o),p=Math.min(r,o),z=e-o,s=(z>0?e-p:z<0?e-n:0)+this._preWad;return!this.isRealTime&&(this._preWad=s),this._preValue.wad=s,s}get vwap(){var a,O;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:e,volume:t}=this._currentData;let{sum:r=0,sumV:o=0,isReset:n}=this._preVwap;if(((O=(a=self.workerStorage)==null?void 0:a.get(this._id))==null?void 0:O.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(n=!0,r=o=0),!n)return;const z=e*t+r,i=t+o;!this.isRealTime&&(this._preVwap={sum:z,sumV:i,isReset:n});const s=z/i;return this._preValue.vwap=s,s}_getNvi(){const e=this._preNvi||1,{close:t=0,volume:r=0}=this._preData,{close:o,volume:n}=this._currentData;let p=1;const z=e||1;return o&&t?p=n<r?z+(o-t)/t*z:z:p=z,!this.isRealTime&&(this._preNvi=p),this._preValue.nvi=p,p}_getPvi(){const e=this._prePvi||1,{close:t=0,volume:r=0}=this._preData,{close:o,volume:n}=this._currentData;let p=1;const z=e||1;return o&&t?p=n>r?z+(o-t)/t*z:z:p=z,!this.isRealTime&&(this._prePvi=p),this._preValue.pvi=p,p}}class cm{constructor(){E(this,"_period");E(this,"_multiplier");E(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(e){if(!e)return;this._period=e;const[t,r]=OM(e);this._multiplier=t,this._unit=r}get isdaily(){return this._unit==="d"}get isdwm(){return["d","w","M"].includes(this._unit)}get isintraday(){return["s","m","h"].includes(this._unit)}get isminutes(){return this._unit==="m"}get ismonthly(){return this._unit==="M"}get isseconds(){return this._unit==="s"}get isweekly(){return this._unit==="w"}get multiplier(){return this._multiplier}get period(){return this._period}}class sm{constructor(){E(this,"_bgColor");E(this,"_fgColor");E(this,"isUseBgColor",!1)}updateOptions(e){e!=null&&e.bg_color&&(this._bgColor=e.bg_color,this._fgColor=this._contrastColor(e.bg_color))}get bg_color(){return this.isUseBgColor=!0,this._bgColor}get fg_color(){return this.isUseBgColor=!0,this._fgColor}get is_heikinashi(){return!1}get is_kagi(){return!1}get is_linebreak(){return!1}get is_pnf(){return!1}get is_range(){return!1}get is_renko(){return!1}get is_standard(){return!0}get left_visible_bar_time(){}get right_visible_bar_time(){}_parseColor(e){let t,r,o,n;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);const p=e.substring(7);p?n=parseInt(p,16)/255:n=1}else{const p=this._parserRgbColor(e);t=p[0]||0,r=p[1]||0,o=p[2]||0,n=p[3]||1}return{r:t,g:r,b:o,a:n}}_parserRgbColor(e){var t;return((t=e.match(/\d+/g))==null?void 0:t.map(Number))||[]}_contrastColor(e){const{r:t,g:r,b:o}=this._parseColor(e);return(299*t+587*r+114*o)/1e3>128?"#000000":"#ffffff"}}class Om{constructor(){E(this,"_syminfo",{})}update(e){this._syminfo=e}get __syminfo(){return this._syminfo}get basecurrency(){return this._syminfo.basecurrency||""}get country(){return this._syminfo.country}get currency(){return this._syminfo.currency||"USD"}get description(){return this._syminfo.description||""}get employees(){return this._syminfo.employees||100}get expiration_date(){return this._syminfo.expiration_date}get industry(){return this._syminfo.industry}get minmove(){return this._syminfo.minmove&&Number(this._syminfo.minmove)}get mintick(){return this._syminfo.mintick}get pointvalue(){return this._syminfo.pointvalue&&Number(this._syminfo.pointvalue)}get prefix(){return this.tickerid.replace(`:${this.ticker}`,"")}get pricescale(){return this._syminfo.pricescale&&Number(this._syminfo.pricescale)}get recommendations_buy(){return this._syminfo.recommendations_buy}get recommendations_buy_strong(){return this._syminfo.recommendations_buy_strong}get recommendations_date(){return this._syminfo.recommendations_date}get recommendations_hold(){return this._syminfo.recommendations_hold}get recommendations_sell(){return this._syminfo.recommendations_sell}get recommendations_sell_strong(){return this._syminfo.recommendations_sell_strong}get recommendations_total(){return this._syminfo.recommendations_total}get root(){return this._syminfo.root||""}get sector(){return this._syminfo.sector}get session(){return this._syminfo.session||ut.regular}get shareholders(){return this._syminfo.shareholders}get shares_outstanding_float(){return this._syminfo.shares_outstanding_float}get shares_outstanding_total(){return this._syminfo.shares_outstanding_total}get target_price_average(){return this._syminfo.target_price_average}get target_price_date(){return this._syminfo.target_price_date}get target_price_estimates(){return this._syminfo.pricescale}get target_price_high(){return this._syminfo.target_price_high}get target_price_low(){return this._syminfo.target_price_low}get target_price_median(){return this._syminfo.target_price_median}get ticker(){return this._syminfo.ticker||""}get tickerid(){return this._syminfo.tickerid||""}get timezone(){return this._syminfo.timezone||"UTC+8"}get type(){return this._syminfo.type}get volumetype(){return this._syminfo.volumetype||"n/a"}}class am{constructor(e){E(this,"_variables");this._variables=e}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class um{constructor(e){E(this,"_variables");this._variables=e}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}class qp{constructor(e){E(this,"_cacheData");E(this,"_barIndex");E(this,"_isRealTimeBar");E(this,"_barstate");E(this,"_priceVariables");E(this,"_lastBarIndex");E(this,"_currentBarTime");E(this,"_lastBarTime");E(this,"_period");E(this,"_offsetTime");E(this,"_timeframe");E(this,"_ta");E(this,"_polyline");E(this,"_label");E(this,"_line");E(this,"_linefill");E(this,"_box");E(this,"_table");E(this,"_strategy");E(this,"_session");E(this,"syminfo");E(this,"chart");E(this,"earnings");E(this,"dividends");E(this,"_timeTradingday");E(this,"_mintick");E(this,"_cacheSpace");E(this,"_precision");E(this,"_nextBarTime");E(this,"_isRepeated");E(this,"_preCacheData");E(this,"__requestName","");E(this,"__isFirstRun",!1);this._cacheData={varData:{},varipData:{}},this._preCacheData={varData:{},varipData:{}},this._barIndex=0,this._lastBarIndex=0,this._currentBarTime=0,this._lastBarTime=0,this._offsetTime=0,this._period="",this._isRealTimeBar=!1,this._barstate=new bm,this._timeframe=new cm,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new im(e),this._polyline=new Cr(this),this._label=new Cr(this),this._line=new Cr(this,Z0.LINE),this._linefill=new Cr(this,Z0.LINEFILL),this._box=new Cr(this),this._table=new Cr(this),this._strategy=new zm(this),this._session=new pm(this),this.syminfo=new Om,this.chart=new sm,this.earnings=new um(this),this.dividends=new am(this),this._cacheSpace=new Map}get table(){return this._table}get box(){return this._box}get linefill(){return this._linefill}get line(){return this._line}get polyline(){return this._polyline}get label(){return this._label}get ta(){return this._ta}get strategy(){return this._strategy}get session(){return this._session}get na(){}get last_bar_index(){return this._lastBarIndex}get bar_index(){return this._barIndex}get barstate(){return this._barstate}get close(){return this._priceVariables.close}get low(){return this._priceVariables.low}get open(){return this._priceVariables.open}get high(){return this._priceVariables.high}get volume(){return this._priceVariables.volume}get ohlc4(){const{close:e,open:t,high:r,low:o}=this._priceVariables;return(e+t+r+o)/4}get hl2(){const{high:e,low:t}=this._priceVariables;return(e+t)/2}get hlc3(){const{close:e,high:t,low:r}=this._priceVariables;return(e+t+r)/3}get hlcc4(){const{close:e,high:t,low:r}=this._priceVariables;return(e*2+t+r)/4}get hour(){return D1(this._currentBarTime).hour()}get minute(){return D1(this._currentBarTime).minute()}get second(){return D1(this._currentBarTime).second()}get month(){return D1(this._currentBarTime).month()+1}get year(){return D1(this._currentBarTime).year()}get dayofweek(){return D1(this._currentBarTime).day()}get dayofmonth(){return D1(this._currentBarTime).date()}get weekofyear(){return D1(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[e,t]=OM(this._period);return this._isRealTimeBar?void 0:D1(this._currentBarTime).add(e,t).valueOf()}get timenow(){return Date.now()}get time_tradingday(){return this._timeTradingday||this.getTimeTradingday(this._currentBarTime,this._period)}get timeframe(){return this._timeframe}get mintick(){return this._mintick}get __period(){return this._period}get precision(){return this._precision}get nextBarTime(){return this._nextBarTime}updateMaxLength(e){const{max_lines_count:t,max_labels_count:r,max_boxes_count:o,max_polylines_count:n}=e;o&&this._box.setMaxLen(o),r&&this._label.setMaxLen(r),t&&this._line.setMaxLen(t),n&&this._polyline.setMaxLen(n)}getTimeTradingday(e,t){const[r,o]=OM(t),n=D1(e);return["M","w","y","d"].includes(o)?n.valueOf():(n.subtract(this._offsetTime,"h"),n.startOf("d").add(this._offsetTime,"h").valueOf())}updateOptions(e){var s;const{interval:t="1D",offsetTime:r=5,mintick:o,chart:n,syminfo:p}=e,z=((s=o.toString().split(".")[1])==null?void 0:s.length)||5;this._precision=z;const i=Ac(t);this._period=i,this._mintick=o,this._offsetTime=r,this._timeframe.update(i),this.chart.updateOptions(n),this.syminfo.update(p)}updateData(e,t){const{barIndex:r,c:o,o:n,h:p,l:z,volume:i,time:s,lastBarIndex:a,lastBarTime:O,isrealtime:u,time_tradingday:l,nextBarTime:d}=e;if(this._priceVariables={close:Number(o),open:Number(n),high:Number(p),low:Number(z),volume:Number(i)},this._isRealTimeBar=u,r>this._barIndex){const{varData:f,varipData:h}=this._cacheData;this._preCacheData={varData:{...f},varipData:{...h}}}this._isRepeated=t,this._timeTradingday=l,this._currentBarTime=s*1e3,this._lastBarIndex=a,this._barIndex=r,this._lastBarTime=O*1e3,this._nextBarTime=d*1e3,this._barstate.update(r,a,u,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(e,t,r){const o=this.setCacheData(e,r),n=this._cacheSpace.get(e)||0;return t=Math.floor(t),n<t&&this._cacheSpace.set(e,t),o[o.length-1-t]}setCacheData(e,t){let r=this._cacheData[e]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;r.barIndex===this._barIndex?r.data[r.data.length-1]=t:r.data.push(t);const o=this._cacheSpace.get(e);return o&&r.data.length>o+5&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[e]=r,r.data}getTypeInstance(e,t){return new gu(e,t)}verifyVarAndVarip(e,t,r){const o=`${e}_${t}`,n=this._isRepeated?this._preCacheData:this._cacheData;return r==="var"&&n.varData.hasOwnProperty(o)?(this._upadteChartDraws(n.varData[o]),!0):r==="varip"&&this._cacheData.varipData.hasOwnProperty(o)?(this._upadteChartDraws(this._cacheData.varipData[o]),!0):!1}getVarValue(e,t,r){const o=`${e}_${t}`,n=this._isRepeated?this._preCacheData:this._cacheData;if(r==="var"){if(this._isRealTimeBar){const p=n.varData[o];return typeof p!="object"||p!=null&&p.type?p:p!=null&&p.copy?p.copy():Object.assign({},p)}return n.varData[o]}return this._cacheData.varipData[o]}setVarValue(e,t,r,o){var z;if(this._isRepeated&&o==="var")return this.getVarValue(e,t,o);const n=`${e}_${t}`;let p;switch(typeof r=="object"&&((z=r==null?void 0:r.varipKeys)!=null&&z.length)&&(o="var",p=r.varipKeys),o){case"var":if(this._isRealTimeBar){if(p&&p.length)for(const i of p)this._cacheData.varData[n][i]=r[i]}else this._chartDrawsHandle(r,this._cacheData.varData[n]),this._cacheData.varData[n]=r;break;case"varip":this._chartDrawsHandle(r,this._cacheData.varipData[n]),this._cacheData.varipData[n]=r;break}return r}_upadteChartDraws(e){const t=this._isRealTimeBar?e==null?void 0:e.preId:e==null?void 0:e.id;if(t)switch(e==null?void 0:e.type){case Z0.BOX:this._setChartDraw(t,this._box);break;case Z0.LINE:this._setChartDraw(t,this._line);break;case Z0.POLYLINE:this._setChartDraw(t,this._polyline);break;case Z0.LABEL:this._setChartDraw(t,this._label);break;case Z0.LINEFILL:this._setChartDraw(t,this._linefill);break;case Z0.TABLE:this._setChartDraw(t,this._table);break}}_setChartDraw(e,t){const r=t.getInstance(e),o=t.get(e);if(!o||!r)return;const n=r.updateId()||e;n===e&&!this._isRealTimeBar||(t.deleteHandle(e),t.set(n,o,r))}_chartDrawsHandle(e,t){const r=t==null?void 0:t.id;let o=e==null?void 0:e.id;o&&e.data&&(e.data.isVar=!0),r!==o&&r&&t.data&&(t.data.isVar=!1)}add(e,t){return Array.isArray(e)&&Array.isArray(t)?L2.uniq([...e,...t]):typeof e=="number"||typeof t=="number"?Number(e)+Number(t):(e||"")+(t||"")}sub(e,t){return Array.isArray(e)&&Array.isArray(t)?e.filter(r=>!t.includes(r)):Number(e)-Number(t)}div(e,t){if(t)return e/t}equal(e,t,r,o){if(e!==void 0&&t!==void 0)return e==t;if(!(r.endsWith(Z0.BOOL)&&e===void 0))return(r.endsWith(Z0.FLOAT)||r.endsWith(Z0.INT)||o.endsWith(Z0.FLOAT)||o.endsWith(Z0.INT))&&e===void 0&&t===void 0?!1:r.endsWith(Z0.STRING)&&e===""&&t===void 0||o.endsWith(Z0.STRING)&&t===""&&e===void 0?!0:r.endsWith(Z0.NA)&&o.endsWith(Z0.NA)?!1:e==t}compareDataHandle(e){if(typeof e!="number")return e;const t=String(e);if(!t.includes(".")&&!t.includes("-"))return e;const[r,o]=e.toFixed(20).split(".");return+`${r}.${o.slice(0,10)}`}againAssignParse(e,t){var o;if(t)return;const r=(o=e==null?void 0:e.constructor)==null?void 0:o.name;if(r)switch(r){case Ko.name:case Es.name:case Zo.name:case Ts.name:case Jo.name:case Qo.name:e==null||e.delete();break}}}class Cr{constructor(e,t,r=50){E(this,"_all");E(this,"_allInstance");E(this,"_pseudoArrayAll");E(this,"_maxLength");E(this,"_deleteIds");E(this,"_variables");E(this,"_preDeleteIds");E(this,"_againAddItems");E(this,"_tmpData");E(this,"_tmpInstance");E(this,"_type");E(this,"_tmpIds",[]);this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=new n1,this._maxLength=r,this._deleteIds=new Map,this._variables=e,this._preDeleteIds=new Map,this._againAddItems=[],this._tmpData=new Map,this._tmpInstance=new Map,this._type=t}setMaxLen(e){this._maxLength=e}get size(){return this._all.size+this._tmpData.size}get data(){const e=[],t=L2.flatMap([...this._deleteIds.values()]),r=L2.uniq([...this._all.keys(),...this._tmpData.keys()]);for(const o of r)if(!t.some(n=>n.key===o)){const n=this._tmpData.get(o)||this._all.get(o);n&&e.push(n)}return this._variables._isRealTimeBar&&this._preDeleteIds.set(this._variables.last_bar_index,this._deleteIds.get(this._variables.last_bar_index)||[]),this._tmpDataHandle(),this._type===Z0.LINEFILL?e:e.slice(-this._maxLength)}get all(){return this._pseudoArrayAll._value=[...this._allInstance.values(),...this._tmpInstance.values()],this._pseudoArrayAll}add(e,t,r){if(this.set(e,t,r),!this._variables._isRealTimeBar&&this._type!==Z0.LINEFILL&&this._all.size>this._maxLength){const{bar_index:o}=t;for(const[n,p]of this._all){const{isVar:z,id:i,bar_index:s}=p;if(s===o)break;if(z)continue;this.deleteHandle(i);break}}}getValOfBarIndex(e){let t=[];const r=L2.uniq([...this._all.keys(),...this._tmpData.keys()]),o=L2.flatMap([...this._deleteIds.values()]);for(const n of e){const p=r.filter(z=>z.endsWith(`_${n}`));for(const z of p){if(o.some(s=>s.key===z))continue;const i=this._tmpData.get(z)||this._all.get(z);i&&t.push(i)}}return this._againAddItems.length&&(t=this._againAddItems.concat(t),this._againAddItems=[]),this._tmpDataHandle(),t.length?this._type===Z0.LINEFILL?t:t.slice(-this._maxLength):void 0}getDeleteIds(e){let t=[];const{bar_index:r,_isRealTimeBar:o}=this._variables,n=[];for(const p of e){let z=[...this._deleteIds.get(p)||[]];const i=this._preDeleteIds.get(p)||[];if(p===r&&o){let s=[];for(const a of i){const O=z.findIndex(u=>u.id===a.id);if(O===-1){const u=this._all.get(a.key);u&&n.push(u)}else s.push(a),z.splice(O,1)}this._preDeleteIds.set(r,L2.uniqBy([...z,...s],"id"))}else{const s=[],a=[...this._all.values(),...this._tmpData.values()];for(const O of this._tmpIds)a.some(u=>u.id===O.id)||s.push(O);for(const O of z)i.some(u=>u.id===O.id)||s.push(O);z=s,this._preDeleteIds.delete(p)}t=t.concat(z)}return this._againAddItems=n,L2.uniq(t.map(p=>p.id))}set(e,t,r){this._variables._isRealTimeBar?(this._tmpData.set(e,t),this._tmpInstance.set(e,r)):(this._all.set(e,t),this._allInstance.set(e,r))}get(e){const t=this._all.get(e);let r=this._tmpData.get(e);return this._variables._isRealTimeBar?(r||(r=t?{...t}:void 0,r&&this._tmpData.set(e,r)),r):(this._tmpData.clear(),this._tmpInstance.clear(),t)}getInstance(e){return this._allInstance.get(e)}deleteHandle(e){var t;if(this._type===Z0.LINE){const r=(t=this._allInstance.get(e))==null?void 0:t.__fillKeys;if(r&&r.length)for(const o of r)this._variables.linefill.deleteHandle(o)}this._variables._isRealTimeBar?(this._tmpData.delete(e),this._tmpInstance.delete(e)):(this._all.delete(e),this._allInstance.delete(e))}delete(e,t){const r=this._all.get(e);if(this._variables._isRealTimeBar||this.deleteHandle(e),!(this._variables.__isFirstRun&&!this._variables._isRealTimeBar)&&typeof t=="number"){const o=this._deleteIds.get(t)||[];o.push({key:e,id:(r==null?void 0:r.id)||e}),this._deleteIds.set(t,o)}}_tmpDataHandle(){var e;this._tmpIds=[];for(const[t]of this._tmpInstance){const r=(e=this._tmpData.get(t))==null?void 0:e.id;r&&this._tmpIds.push({id:r,key:t})}this._tmpData.clear(),this._tmpInstance.clear(),this._deleteIds.clear()}}/**
86
86
  * @license
87
87
  * Copyright 2019 Google LLC
88
88
  * SPDX-License-Identifier: Apache-2.0
@@ -69151,7 +69151,7 @@ function br(a, s, r) {
69151
69151
  function Nw() {
69152
69152
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
69153
69153
  }
69154
- const Cd = new Worker(new URL("" + new URL("assets/scriptsRunWorker-C37-bpBw.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
69154
+ const Cd = new Worker(new URL("" + new URL("assets/scriptsRunWorker-CDvmznKK.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
69155
69155
  Cd.onerror = (a) => {
69156
69156
  console.error(a);
69157
69157
  };
@@ -141,7 +141,7 @@ function print() { __p += __j.call(arguments, '') }
141
141
  * @license
142
142
  * Copyright 2019 Google LLC
143
143
  * SPDX-License-Identifier: Apache-2.0
144
- */const tl=Symbol("Comlink.proxy"),Dm=Symbol("Comlink.endpoint"),Im=Symbol("Comlink.releaseProxy"),Bn=Symbol("Comlink.finalizer"),ba=Symbol("Comlink.thrown"),sl=a=>typeof a=="object"&&a!==null||typeof a=="function",Am={canHandle:a=>sl(a)&&a[tl],serialize(a){const{port1:s,port2:r}=new MessageChannel;return al(a,s),[r,[r]]},deserialize(a){return a.start(),Un(a)}},qm={canHandle:a=>sl(a)&&ba in a,serialize({value:a}){let s;return a instanceof Error?s={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:s={isError:!1,value:a},[s,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},rl=new Map([["proxy",Am],["throw",qm]]);function Cm(a,s){for(const r of a)if(s===r||r==="*"||r instanceof RegExp&&r.test(s))return!0;return!1}function al(a,s=globalThis,r=["*"]){s.addEventListener("message",function n(o){if(!o||!o.data)return;if(!Cm(r,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}const{id:l,type:c,path:u}=Object.assign({path:[]},o.data),m=(o.data.argumentList||[]).map(Is);let _;try{const g=u.slice(0,-1).reduce((h,D)=>h[D],a),x=u.reduce((h,D)=>h[D],a);switch(c){case"GET":_=x;break;case"SET":g[u.slice(-1)[0]]=Is(o.data.value),_=!0;break;case"APPLY":_=x.apply(g,m);break;case"CONSTRUCT":{const h=new x(...m);_=Kn(h)}break;case"ENDPOINT":{const{port1:h,port2:D}=new MessageChannel;al(a,D),_=Lm(h,[h])}break;case"RELEASE":_=void 0;break;default:return}}catch(g){_={value:g,[ba]:0}}Promise.resolve(_).catch(g=>({value:g,[ba]:0})).then(g=>{const[x,h]=va(g);s.postMessage(Object.assign(Object.assign({},x),{id:l}),h),c==="RELEASE"&&(s.removeEventListener("message",n),nl(s),Bn in a&&typeof a[Bn]=="function"&&a[Bn]())}).catch(g=>{const[x,h]=va({value:new TypeError("Unserializable return value"),[ba]:0});s.postMessage(Object.assign(Object.assign({},x),{id:l}),h)})}),s.start&&s.start()}function Sm(a){return a.constructor.name==="MessagePort"}function nl(a){Sm(a)&&a.close()}function Un(a,s){return $n(a,[],s)}function xa(a){if(a)throw new Error("Proxy has been released and is not useable")}function il(a){return Hs(a,{type:"RELEASE"}).then(()=>{nl(a)})}const ha=new WeakMap,wa="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const s=(ha.get(a)||0)-1;ha.set(a,s),s===0&&il(a)});function zm(a,s){const r=(ha.get(s)||0)+1;ha.set(s,r),wa&&wa.register(a,s,a)}function Nm(a){wa&&wa.unregister(a)}function $n(a,s=[],r=function(){}){let n=!1;const o=new Proxy(r,{get(l,c){if(xa(n),c===Im)return()=>{Nm(o),il(a),n=!0};if(c==="then"){if(s.length===0)return{then:()=>o};const u=Hs(a,{type:"GET",path:s.map(m=>m.toString())}).then(Is);return u.then.bind(u)}return $n(a,[...s,c])},set(l,c,u){xa(n);const[m,_]=va(u);return Hs(a,{type:"SET",path:[...s,c].map(g=>g.toString()),value:m},_).then(Is)},apply(l,c,u){xa(n);const m=s[s.length-1];if(m===Dm)return Hs(a,{type:"ENDPOINT"}).then(Is);if(m==="bind")return $n(a,s.slice(0,-1));const[_,g]=ol(u);return Hs(a,{type:"APPLY",path:s.map(x=>x.toString()),argumentList:_},g).then(Is)},construct(l,c){xa(n);const[u,m]=ol(c);return Hs(a,{type:"CONSTRUCT",path:s.map(_=>_.toString()),argumentList:u},m).then(Is)}});return zm(o,a),o}function Em(a){return Array.prototype.concat.apply([],a)}function ol(a){const s=a.map(va);return[s.map(r=>r[0]),Em(s.map(r=>r[1]))]}const ll=new WeakMap;function Lm(a,s){return ll.set(a,s),a}function Kn(a){return Object.assign(a,{[tl]:!0})}function va(a){for(const[s,r]of rl)if(r.canHandle(a)){const[n,o]=r.serialize(a);return[{type:"HANDLER",name:s,value:n},o]}return[{type:"RAW",value:a},ll.get(a)||[]]}function Is(a){switch(a.type){case"HANDLER":return rl.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Hs(a,s,r){return new Promise(n=>{const o=Mm();a.addEventListener("message",function l(c){!c.data||!c.data.id||c.data.id!==o||(a.removeEventListener("message",l),n(c.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:o},s),r)})}function Mm(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const cl=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-C37-bpBw.js").href:new URL("assets/scriptsRunWorker-C37-bpBw.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ra&&ra.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});cl.onerror=a=>{console.error(a)};async function pl(a){return await _a.setInlayHints(a)}const dl=Un(cl),ul=Un(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-B7F1lNQc.js").href:new URL("assets/parserTccWorker-B7F1lNQc.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ra&&ra.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function ml(a,s=!1){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ul.parseTcc(a,s,Kn(pl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Om(a,s){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ul.parseLibraryCode(a,s,Kn(pl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Pm(a,s,r=!0){return await dl.runScript(a,s,r)}async function Rm(a){return await dl.removeScript(a)}function Fm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}const{slice:Bm,forEach:Um}=[];function $m(a){return Um.call(Bm.call(arguments,1),s=>{if(s)for(const r in s)a[r]===void 0&&(a[r]=s[r])}),a}const yl=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Km=(a,s,r)=>{const n=r||{};n.path=n.path||"/";const o=encodeURIComponent(s);let l=`${a}=${o}`;if(n.maxAge>0){const c=n.maxAge-0;if(Number.isNaN(c))throw new Error("maxAge should be a Number");l+=`; Max-Age=${Math.floor(c)}`}if(n.domain){if(!yl.test(n.domain))throw new TypeError("option domain is invalid");l+=`; Domain=${n.domain}`}if(n.path){if(!yl.test(n.path))throw new TypeError("option path is invalid");l+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");l+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(l+="; HttpOnly"),n.secure&&(l+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;case"none":l+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return l},_l={create(a,s,r,n){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),n&&(o.domain=n),document.cookie=Km(a,encodeURIComponent(s),o)},read(a){const s=`${a}=`,r=document.cookie.split(";");for(let n=0;n<r.length;n++){let o=r[n];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(s)===0)return o.substring(s.length,o.length)}return null},remove(a){this.create(a,"",-1)}};var jm={name:"cookie",lookup(a){let{lookupCookie:s}=a;if(s&&typeof document<"u")return _l.read(s)||void 0},cacheUserLanguage(a,s){let{lookupCookie:r,cookieMinutes:n,cookieDomain:o,cookieOptions:l}=s;r&&typeof document<"u"&&_l.create(r,a,n,o,l)}},Hm={name:"querystring",lookup(a){var n;let{lookupQuerystring:s}=a,r;if(typeof window<"u"){let{search:o}=window.location;!window.location.search&&((n=window.location.hash)==null?void 0:n.indexOf("?"))>-1&&(o=window.location.hash.substring(window.location.hash.indexOf("?")));const c=o.substring(1).split("&");for(let u=0;u<c.length;u++){const m=c[u].indexOf("=");m>0&&c[u].substring(0,m)===s&&(r=c[u].substring(m+1))}}return r}};let Cr=null;const fl=()=>{if(Cr!==null)return Cr;try{Cr=window!=="undefined"&&window.localStorage!==null;const a="i18next.translate.boo";window.localStorage.setItem(a,"foo"),window.localStorage.removeItem(a)}catch{Cr=!1}return Cr};var Wm={name:"localStorage",lookup(a){let{lookupLocalStorage:s}=a;if(s&&fl())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupLocalStorage:r}=s;r&&fl()&&window.localStorage.setItem(r,a)}};let Sr=null;const gl=()=>{if(Sr!==null)return Sr;try{Sr=window!=="undefined"&&window.sessionStorage!==null;const a="i18next.translate.boo";window.sessionStorage.setItem(a,"foo"),window.sessionStorage.removeItem(a)}catch{Sr=!1}return Sr};var Vm={name:"sessionStorage",lookup(a){let{lookupSessionStorage:s}=a;if(s&&gl())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupSessionStorage:r}=s;r&&gl()&&window.sessionStorage.setItem(r,a)}},Gm={name:"navigator",lookup(a){const s=[];if(typeof navigator<"u"){const{languages:r,userLanguage:n,language:o}=navigator;if(r)for(let l=0;l<r.length;l++)s.push(r[l]);n&&s.push(n),o&&s.push(o)}return s.length>0?s:void 0}},Xm={name:"htmlTag",lookup(a){let{htmlTag:s}=a,r;const n=s||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(r=n.getAttribute("lang")),r}},Ym={name:"path",lookup(a){var o;let{lookupFromPathIndex:s}=a;if(typeof window>"u")return;const r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?(o=r[typeof s=="number"?s:0])==null?void 0:o.replace("/",""):void 0}},Qm={name:"subdomain",lookup(a){var o,l;let{lookupFromSubdomainIndex:s}=a;const r=typeof s=="number"?s+1:1,n=typeof window<"u"&&((l=(o=window.location)==null?void 0:o.hostname)==null?void 0:l.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(n)return n[r]}};function Zm(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:a=>a}}class bl{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(s,r)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=s||{languageUtils:{}},this.options=$m(r,this.options||{},Zm()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=o=>o.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(jm),this.addDetector(Hm),this.addDetector(Wm),this.addDetector(Vm),this.addDetector(Gm),this.addDetector(Xm),this.addDetector(Ym),this.addDetector(Qm)}addDetector(s){return this.detectors[s.name]=s,this}detect(s){s||(s=this.options.order);let r=[];return s.forEach(n=>{if(this.detectors[n]){let o=this.detectors[n].lookup(this.options);o&&typeof o=="string"&&(o=[o]),o&&(r=r.concat(o))}}),r=r.map(n=>this.options.convertDetectedLanguage(n)),this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(s,r){r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(s)>-1||r.forEach(n=>{this.detectors[n]&&this.detectors[n].cacheUserLanguage(s,this.options)}))}}bl.type="languageDetector";const Jm=(...a)=>{console!=null&&console.warn&&(As(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),console.warn(...a))},xl={},jn=(...a)=>{As(a[0])&&xl[a[0]]||(As(a[0])&&(xl[a[0]]=new Date),Jm(...a))},hl=(a,s)=>()=>{if(a.isInitialized)s();else{const r=()=>{setTimeout(()=>{a.off("initialized",r)},0),s()};a.on("initialized",r)}},Hn=(a,s,r)=>{a.loadNamespaces(s,hl(a,r))},wl=(a,s,r,n)=>{if(As(r)&&(r=[r]),a.options.preload&&a.options.preload.indexOf(s)>-1)return Hn(a,r,n);r.forEach(o=>{a.options.ns.indexOf(o)<0&&a.options.ns.push(o)}),a.loadLanguages(s,hl(a,n))},ey=(a,s,r={})=>!s.languages||!s.languages.length?(jn("i18n.languages were undefined or empty",s.languages),!0):s.hasLoadedNamespace(a,{lng:r.lng,precheck:(n,o)=>{var l;if(((l=r.bindI18n)==null?void 0:l.indexOf("languageChanging"))>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,a))return!1}}),As=a=>typeof a=="string",ty=a=>typeof a=="object"&&a!==null,sy=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ry={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},ay=a=>ry[a];let Wn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:a=>a.replace(sy,ay)};const ny=(a={})=>{Wn={...Wn,...a}},iy=()=>Wn;let vl;const oy=a=>{vl=a},ly=()=>vl,cy={type:"3rdParty",init(a){ny(a.options.react),oy(a)}},py=N.createContext();class dy{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const uy=(a,s)=>{const r=N.useRef();return N.useEffect(()=>{r.current=s?r.current:a},[a,s]),r.current},Tl=(a,s,r,n)=>a.getFixedT(s,r,n),my=(a,s,r,n)=>N.useCallback(Tl(a,s,r,n),[a,s,r,n]),Ws=(a,s={})=>{var W,Q,C,z;const{i18n:r}=s,{i18n:n,defaultNS:o}=N.useContext(py)||{},l=r||n||ly();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new dy),!l){jn("You will need to pass in an i18next instance by using initReactI18next");const V=(A,L)=>As(L)?L:ty(L)&&As(L.defaultValue)?L.defaultValue:Array.isArray(A)?A[A.length-1]:A,q=[V,{},!1];return q.t=V,q.i18n={},q.ready=!1,q}(W=l.options.react)!=null&&W.wait&&jn("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const c={...iy(),...l.options.react,...s},{useSuspense:u,keyPrefix:m}=c;let _=a||o||((Q=l.options)==null?void 0:Q.defaultNS);_=As(_)?[_]:_||["translation"],(z=(C=l.reportNamespaces).addUsedNamespaces)==null||z.call(C,_);const g=(l.isInitialized||l.initializedStoreOnce)&&_.every(V=>ey(V,l,c)),x=my(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),h=()=>x,D=()=>Tl(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),[S,R]=N.useState(h);let U=_.join();s.lng&&(U=`${s.lng}${U}`);const K=uy(U),H=N.useRef(!0);N.useEffect(()=>{const{bindI18n:V,bindI18nStore:q}=c;H.current=!0,!g&&!u&&(s.lng?wl(l,s.lng,_,()=>{H.current&&R(D)}):Hn(l,_,()=>{H.current&&R(D)})),g&&K&&K!==U&&H.current&&R(D);const A=()=>{H.current&&R(D)};return V&&(l==null||l.on(V,A)),q&&(l==null||l.store.on(q,A)),()=>{H.current=!1,l&&(V==null||V.split(" ").forEach(L=>l.off(L,A))),q&&l&&q.split(" ").forEach(L=>l.store.off(L,A))}},[l,U]),N.useEffect(()=>{H.current&&g&&R(h)},[l,m,g]);const re=[S,l,g];if(re.t=S,re.i18n=l,re.ready=g,g||!g&&!u)return re;throw new Promise(V=>{s.lng?wl(l,s.lng,_,()=>V()):Hn(l,_,()=>V())})},yy={type:"type",syntax:"syntax",overloads:"overloads",arguments:"arguments",fields:"fields",example:"example",returns:"returns",remarks:"remarks","see also":"see also","Copy code":"Copy code","Copy link":"Copy link",Copied:"Copied","Link copied":"Link copied",variables:"Variables",constants:"Constants",functions:"Functions",keywords:"Keywords",types:"Types",operators:"Operators",annotations:"Annotations",search:"Search","Mine Script® v1 Reference Manual":"Mine Script® v1 Reference Manual","This script is read-only. It cannot be edited.":"This script is read-only. It cannot be edited.","save script":"Save script","open script":"Open script","find/replace":"Find/Replace","toggle console":"Toggle console","open editor in new tab":"Open editor in new tab","open editor in new window":"Open editor in new window",keyword:"keyword","built-in function":"built-in function","built-in variable":"built-in variable","built-in method":"built-in method","built-in type":"built-in type",annotation:"annotation","built-in constant":"built-in constant",namespace:"namespace","user-defined variable":"user-defined variable","user-defined type":"user-defined type",field:"field",enum:"enum","user-defined method":"user-defined method","user-defined function":"user-defined function",parameter:"parameter","**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.":"**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Mine functions, variables, and methods.","to trigger parameters hint":"to trigger parameters hint",library:"library","enum member":"enum member",Returns:"Returns",Syntax:"Syntax",Remarks:"Remarks",Fields:"Fields",Description:"Description",Example:"Example","Enum members":"Enum members",statement:"statement",loop:"loop","`click` on keyword for more help":"`click` on keyword for more help"},_y={type:"类型",syntax:"语法",overloads:"重载",arguments:"参数",fields:"字段",example:"例子",returns:"返回值",remarks:"备注","see also":"另见","Copy code":"复制代码","Copy link":"复制链接",Copied:"已复制","Link copied":"链接已复制",variables:"内置变量",constants:"常量",functions:"函数",keywords:"关键词",types:"类型",operators:"运算符",annotations:"注释",search:"搜索","Mine Script® v1 Reference Manual":"Mine Script™ v1参考手册","This script is read-only. It cannot be edited.":"该脚本是只读的。它无法被编辑。","save script":"保存脚本","open script":"打开脚本","find/replace":"寻找/替换","toggle console":"切换控制台","open editor in new tab":"在新标签页中打开","open editor in new window":"在新窗口中打开",keyword:"关键词","built-in function":"内置函数","built-in variable":"内置变量","built-in method":"内置方法","built-in type":"内置类型",annotation:"注释","built-in constant":"内置常量",namespace:"命名空间","user-defined variable":"用户自定义变量","user-defined type":"用户自定义类型",field:"字段",enum:"枚举","user-defined method":"用户自定义方法","user-defined function":"用户自定义函数",parameter:"参数","**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.":"命名空间是不可变的术语,充当标识符组的前缀。在命名Mine函数、变量和方法时,点和另一个术语始终遵循命名空间。","to trigger parameters hint":"触发参数提示",library:"脚本库","enum member":"枚举成员",Returns:"返回值",Syntax:"语法",Remarks:"备注",Fields:"字段",Description:"描述",Example:"例子","Enum members":"枚举成员",statement:"声明",loop:"循环","`click` on keyword for more help":"“点击”关键词以获得更多帮助"};Me.use(bl).use(cy).init({debug:!1,fallbackLng:"zh",interpolation:{escapeValue:!1},resources:{en:{translation:yy},zh:{translation:_y}}}),self.MonacoEnvironment={getWorker(){return new Fm({name:"Editor Worker"})}},In.config({paths:{vs:"https://my.tradingvue.com/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const fy=(a,s)=>{const{height:r,width:n,theme:o,options:l,hasDiff:c,readOnly:u,defaultValue:m,language:_,onChange:g,onLinkOpen:x,onCursorPositionChange:h,onActionTrigger:D,onEditorDidMount:S}=a,{t:R,i18n:U}=Ws(),K=N.useRef(null),H=N.useRef(null),re=N.useRef(!1),W=N.useRef(!1);N.useImperativeHandle(s,()=>({setOriginalScript(A){var L;(L=K.current)==null||L.setOriginalScript(A)},setScript(A){var L;(L=K.current)==null||L.setValue(A)},gotoLine(){var A;(A=K.current)==null||A.gotoLine()},getEditorLayout(){var A;return(A=K.current)==null?void 0:A.getEditorLayout()},setPosition(A,L){var Z;(Z=K.current)==null||Z.setPosition({column:A,lineNumber:L})},setModelMarkers(A){var L;W.current=!0,(L=K.current)==null||L.setModelMarkers(A),setTimeout(()=>{W.current=!1},2e3)},focus(){var A;(A=K.current)==null||A.focus()}})),N.useEffect(()=>{var A,L;c?(L=K.current)==null||L.addDiffDecorations():(A=K.current)==null||A.removeDiffDecorations()},[c]),N.useEffect(()=>{o&&Ne.editor.setTheme(o)},[o]),N.useEffect(()=>{_&&U.changeLanguage(_)},[_]),N.useEffect(()=>{var A;(A=K.current)==null||A.updateActionTrigger(D)},[D]),N.useEffect(()=>{var A;x&&((A=K.current)==null||A.addLinkOpenFunc(x))},[x]);function Q(A,L){var ee,ne;Pt.initBuiltinsTrees(),_a.setEditor(A),K.current=new km(A,L,D),x&&((ee=K.current)==null||ee.addLinkOpenFunc(x)),c&&((ne=K.current)==null||ne.addDiffDecorations()),Gu(A),requestAnimationFrame(q);const Z=A.getValue();K.current.onChangeCursorPosition(h),g&&g(Z),!u&&C(Z),S&&S()}const C=N.useCallback(async A=>{var Rt;re.current=!1;const{errors:L,functions:Z,methods:ee,types:ne,variables:Y,overloadsFuncs:le,imports:xe,enums:pe}=await ml(A),_e=new Map(Object.entries(Z)),Ee=new Map(Object.entries(ee)),te=new Map(Object.entries(ne)),de=new Map(Object.entries(Y)),Oe=new Map(Object.entries(xe)),Ge=new Map(Object.entries(pe));Ds.setUserDefined({functions:_e,methods:Ee,types:te,variables:de,imports:Oe,enums:Ge},le),Pt.setUserDefind(_e,te,de,Ee,Ge);const Qe=L.map(us=>({...us,severity:us.type||Ne.MarkerSeverity.Error}));u||!re.current&&!W.current&&Qe.length&&((Rt=K.current)==null||Rt.setModelMarkers(Qe))},[u]),z=N.useMemo(()=>Qu.debounce(C,1500),[C]);function V(A){var L;if(u){C(A||"");return}re.current=!0,_a.clearInlayHints(),(L=K.current)==null||L.setModelMarkers([]),A!==void 0&&(g&&g(A),z(A))}const q=N.useCallback(()=>{var L,Z;const A=(L=H.current)==null?void 0:L.getBoundingClientRect();(Z=K.current)==null||Z.setEditorLayout((A==null?void 0:A.height)||0,A==null?void 0:A.width)},[]);return N.useEffect(()=>{const A=()=>{window.requestAnimationFrame(q)},L=new ResizeObserver(A);return H.current&&L.observe(H.current),()=>{var Z;H.current&&L.unobserve(H.current),L.disconnect(),(Z=K.current)==null||Z.dispose()}},[]),T.jsx("div",{ref:H,children:T.jsx(mu,{height:r,width:n||"100%",defaultLanguage:Ke,defaultValue:m||`indicator("我的脚本")
144
+ */const tl=Symbol("Comlink.proxy"),Dm=Symbol("Comlink.endpoint"),Im=Symbol("Comlink.releaseProxy"),Bn=Symbol("Comlink.finalizer"),ba=Symbol("Comlink.thrown"),sl=a=>typeof a=="object"&&a!==null||typeof a=="function",Am={canHandle:a=>sl(a)&&a[tl],serialize(a){const{port1:s,port2:r}=new MessageChannel;return al(a,s),[r,[r]]},deserialize(a){return a.start(),Un(a)}},qm={canHandle:a=>sl(a)&&ba in a,serialize({value:a}){let s;return a instanceof Error?s={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:s={isError:!1,value:a},[s,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},rl=new Map([["proxy",Am],["throw",qm]]);function Cm(a,s){for(const r of a)if(s===r||r==="*"||r instanceof RegExp&&r.test(s))return!0;return!1}function al(a,s=globalThis,r=["*"]){s.addEventListener("message",function n(o){if(!o||!o.data)return;if(!Cm(r,o.origin)){console.warn(`Invalid origin '${o.origin}' for comlink proxy`);return}const{id:l,type:c,path:u}=Object.assign({path:[]},o.data),m=(o.data.argumentList||[]).map(Is);let _;try{const g=u.slice(0,-1).reduce((h,D)=>h[D],a),x=u.reduce((h,D)=>h[D],a);switch(c){case"GET":_=x;break;case"SET":g[u.slice(-1)[0]]=Is(o.data.value),_=!0;break;case"APPLY":_=x.apply(g,m);break;case"CONSTRUCT":{const h=new x(...m);_=Kn(h)}break;case"ENDPOINT":{const{port1:h,port2:D}=new MessageChannel;al(a,D),_=Lm(h,[h])}break;case"RELEASE":_=void 0;break;default:return}}catch(g){_={value:g,[ba]:0}}Promise.resolve(_).catch(g=>({value:g,[ba]:0})).then(g=>{const[x,h]=va(g);s.postMessage(Object.assign(Object.assign({},x),{id:l}),h),c==="RELEASE"&&(s.removeEventListener("message",n),nl(s),Bn in a&&typeof a[Bn]=="function"&&a[Bn]())}).catch(g=>{const[x,h]=va({value:new TypeError("Unserializable return value"),[ba]:0});s.postMessage(Object.assign(Object.assign({},x),{id:l}),h)})}),s.start&&s.start()}function Sm(a){return a.constructor.name==="MessagePort"}function nl(a){Sm(a)&&a.close()}function Un(a,s){return $n(a,[],s)}function xa(a){if(a)throw new Error("Proxy has been released and is not useable")}function il(a){return Hs(a,{type:"RELEASE"}).then(()=>{nl(a)})}const ha=new WeakMap,wa="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const s=(ha.get(a)||0)-1;ha.set(a,s),s===0&&il(a)});function zm(a,s){const r=(ha.get(s)||0)+1;ha.set(s,r),wa&&wa.register(a,s,a)}function Nm(a){wa&&wa.unregister(a)}function $n(a,s=[],r=function(){}){let n=!1;const o=new Proxy(r,{get(l,c){if(xa(n),c===Im)return()=>{Nm(o),il(a),n=!0};if(c==="then"){if(s.length===0)return{then:()=>o};const u=Hs(a,{type:"GET",path:s.map(m=>m.toString())}).then(Is);return u.then.bind(u)}return $n(a,[...s,c])},set(l,c,u){xa(n);const[m,_]=va(u);return Hs(a,{type:"SET",path:[...s,c].map(g=>g.toString()),value:m},_).then(Is)},apply(l,c,u){xa(n);const m=s[s.length-1];if(m===Dm)return Hs(a,{type:"ENDPOINT"}).then(Is);if(m==="bind")return $n(a,s.slice(0,-1));const[_,g]=ol(u);return Hs(a,{type:"APPLY",path:s.map(x=>x.toString()),argumentList:_},g).then(Is)},construct(l,c){xa(n);const[u,m]=ol(c);return Hs(a,{type:"CONSTRUCT",path:s.map(_=>_.toString()),argumentList:u},m).then(Is)}});return zm(o,a),o}function Em(a){return Array.prototype.concat.apply([],a)}function ol(a){const s=a.map(va);return[s.map(r=>r[0]),Em(s.map(r=>r[1]))]}const ll=new WeakMap;function Lm(a,s){return ll.set(a,s),a}function Kn(a){return Object.assign(a,{[tl]:!0})}function va(a){for(const[s,r]of rl)if(r.canHandle(a)){const[n,o]=r.serialize(a);return[{type:"HANDLER",name:s,value:n},o]}return[{type:"RAW",value:a},ll.get(a)||[]]}function Is(a){switch(a.type){case"HANDLER":return rl.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Hs(a,s,r){return new Promise(n=>{const o=Mm();a.addEventListener("message",function l(c){!c.data||!c.data.id||c.data.id!==o||(a.removeEventListener("message",l),n(c.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:o},s),r)})}function Mm(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const cl=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-CDvmznKK.js").href:new URL("assets/scriptsRunWorker-CDvmznKK.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ra&&ra.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});cl.onerror=a=>{console.error(a)};async function pl(a){return await _a.setInlayHints(a)}const dl=Un(cl),ul=Un(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-B7F1lNQc.js").href:new URL("assets/parserTccWorker-B7F1lNQc.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ra&&ra.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function ml(a,s=!1){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ul.parseTcc(a,s,Kn(pl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Om(a,s){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ul.parseLibraryCode(a,s,Kn(pl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Pm(a,s,r=!0){return await dl.runScript(a,s,r)}async function Rm(a){return await dl.removeScript(a)}function Fm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}const{slice:Bm,forEach:Um}=[];function $m(a){return Um.call(Bm.call(arguments,1),s=>{if(s)for(const r in s)a[r]===void 0&&(a[r]=s[r])}),a}const yl=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Km=(a,s,r)=>{const n=r||{};n.path=n.path||"/";const o=encodeURIComponent(s);let l=`${a}=${o}`;if(n.maxAge>0){const c=n.maxAge-0;if(Number.isNaN(c))throw new Error("maxAge should be a Number");l+=`; Max-Age=${Math.floor(c)}`}if(n.domain){if(!yl.test(n.domain))throw new TypeError("option domain is invalid");l+=`; Domain=${n.domain}`}if(n.path){if(!yl.test(n.path))throw new TypeError("option path is invalid");l+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");l+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(l+="; HttpOnly"),n.secure&&(l+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;case"none":l+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return l},_l={create(a,s,r,n){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),n&&(o.domain=n),document.cookie=Km(a,encodeURIComponent(s),o)},read(a){const s=`${a}=`,r=document.cookie.split(";");for(let n=0;n<r.length;n++){let o=r[n];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(s)===0)return o.substring(s.length,o.length)}return null},remove(a){this.create(a,"",-1)}};var jm={name:"cookie",lookup(a){let{lookupCookie:s}=a;if(s&&typeof document<"u")return _l.read(s)||void 0},cacheUserLanguage(a,s){let{lookupCookie:r,cookieMinutes:n,cookieDomain:o,cookieOptions:l}=s;r&&typeof document<"u"&&_l.create(r,a,n,o,l)}},Hm={name:"querystring",lookup(a){var n;let{lookupQuerystring:s}=a,r;if(typeof window<"u"){let{search:o}=window.location;!window.location.search&&((n=window.location.hash)==null?void 0:n.indexOf("?"))>-1&&(o=window.location.hash.substring(window.location.hash.indexOf("?")));const c=o.substring(1).split("&");for(let u=0;u<c.length;u++){const m=c[u].indexOf("=");m>0&&c[u].substring(0,m)===s&&(r=c[u].substring(m+1))}}return r}};let Cr=null;const fl=()=>{if(Cr!==null)return Cr;try{Cr=window!=="undefined"&&window.localStorage!==null;const a="i18next.translate.boo";window.localStorage.setItem(a,"foo"),window.localStorage.removeItem(a)}catch{Cr=!1}return Cr};var Wm={name:"localStorage",lookup(a){let{lookupLocalStorage:s}=a;if(s&&fl())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupLocalStorage:r}=s;r&&fl()&&window.localStorage.setItem(r,a)}};let Sr=null;const gl=()=>{if(Sr!==null)return Sr;try{Sr=window!=="undefined"&&window.sessionStorage!==null;const a="i18next.translate.boo";window.sessionStorage.setItem(a,"foo"),window.sessionStorage.removeItem(a)}catch{Sr=!1}return Sr};var Vm={name:"sessionStorage",lookup(a){let{lookupSessionStorage:s}=a;if(s&&gl())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupSessionStorage:r}=s;r&&gl()&&window.sessionStorage.setItem(r,a)}},Gm={name:"navigator",lookup(a){const s=[];if(typeof navigator<"u"){const{languages:r,userLanguage:n,language:o}=navigator;if(r)for(let l=0;l<r.length;l++)s.push(r[l]);n&&s.push(n),o&&s.push(o)}return s.length>0?s:void 0}},Xm={name:"htmlTag",lookup(a){let{htmlTag:s}=a,r;const n=s||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(r=n.getAttribute("lang")),r}},Ym={name:"path",lookup(a){var o;let{lookupFromPathIndex:s}=a;if(typeof window>"u")return;const r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?(o=r[typeof s=="number"?s:0])==null?void 0:o.replace("/",""):void 0}},Qm={name:"subdomain",lookup(a){var o,l;let{lookupFromSubdomainIndex:s}=a;const r=typeof s=="number"?s+1:1,n=typeof window<"u"&&((l=(o=window.location)==null?void 0:o.hostname)==null?void 0:l.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(n)return n[r]}};function Zm(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:a=>a}}class bl{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(s,r)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=s||{languageUtils:{}},this.options=$m(r,this.options||{},Zm()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=o=>o.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(jm),this.addDetector(Hm),this.addDetector(Wm),this.addDetector(Vm),this.addDetector(Gm),this.addDetector(Xm),this.addDetector(Ym),this.addDetector(Qm)}addDetector(s){return this.detectors[s.name]=s,this}detect(s){s||(s=this.options.order);let r=[];return s.forEach(n=>{if(this.detectors[n]){let o=this.detectors[n].lookup(this.options);o&&typeof o=="string"&&(o=[o]),o&&(r=r.concat(o))}}),r=r.map(n=>this.options.convertDetectedLanguage(n)),this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(s,r){r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(s)>-1||r.forEach(n=>{this.detectors[n]&&this.detectors[n].cacheUserLanguage(s,this.options)}))}}bl.type="languageDetector";const Jm=(...a)=>{console!=null&&console.warn&&(As(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),console.warn(...a))},xl={},jn=(...a)=>{As(a[0])&&xl[a[0]]||(As(a[0])&&(xl[a[0]]=new Date),Jm(...a))},hl=(a,s)=>()=>{if(a.isInitialized)s();else{const r=()=>{setTimeout(()=>{a.off("initialized",r)},0),s()};a.on("initialized",r)}},Hn=(a,s,r)=>{a.loadNamespaces(s,hl(a,r))},wl=(a,s,r,n)=>{if(As(r)&&(r=[r]),a.options.preload&&a.options.preload.indexOf(s)>-1)return Hn(a,r,n);r.forEach(o=>{a.options.ns.indexOf(o)<0&&a.options.ns.push(o)}),a.loadLanguages(s,hl(a,n))},ey=(a,s,r={})=>!s.languages||!s.languages.length?(jn("i18n.languages were undefined or empty",s.languages),!0):s.hasLoadedNamespace(a,{lng:r.lng,precheck:(n,o)=>{var l;if(((l=r.bindI18n)==null?void 0:l.indexOf("languageChanging"))>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!o(n.isLanguageChangingTo,a))return!1}}),As=a=>typeof a=="string",ty=a=>typeof a=="object"&&a!==null,sy=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ry={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},ay=a=>ry[a];let Wn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:a=>a.replace(sy,ay)};const ny=(a={})=>{Wn={...Wn,...a}},iy=()=>Wn;let vl;const oy=a=>{vl=a},ly=()=>vl,cy={type:"3rdParty",init(a){ny(a.options.react),oy(a)}},py=N.createContext();class dy{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const uy=(a,s)=>{const r=N.useRef();return N.useEffect(()=>{r.current=s?r.current:a},[a,s]),r.current},Tl=(a,s,r,n)=>a.getFixedT(s,r,n),my=(a,s,r,n)=>N.useCallback(Tl(a,s,r,n),[a,s,r,n]),Ws=(a,s={})=>{var W,Q,C,z;const{i18n:r}=s,{i18n:n,defaultNS:o}=N.useContext(py)||{},l=r||n||ly();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new dy),!l){jn("You will need to pass in an i18next instance by using initReactI18next");const V=(A,L)=>As(L)?L:ty(L)&&As(L.defaultValue)?L.defaultValue:Array.isArray(A)?A[A.length-1]:A,q=[V,{},!1];return q.t=V,q.i18n={},q.ready=!1,q}(W=l.options.react)!=null&&W.wait&&jn("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const c={...iy(),...l.options.react,...s},{useSuspense:u,keyPrefix:m}=c;let _=a||o||((Q=l.options)==null?void 0:Q.defaultNS);_=As(_)?[_]:_||["translation"],(z=(C=l.reportNamespaces).addUsedNamespaces)==null||z.call(C,_);const g=(l.isInitialized||l.initializedStoreOnce)&&_.every(V=>ey(V,l,c)),x=my(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),h=()=>x,D=()=>Tl(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),[S,R]=N.useState(h);let U=_.join();s.lng&&(U=`${s.lng}${U}`);const K=uy(U),H=N.useRef(!0);N.useEffect(()=>{const{bindI18n:V,bindI18nStore:q}=c;H.current=!0,!g&&!u&&(s.lng?wl(l,s.lng,_,()=>{H.current&&R(D)}):Hn(l,_,()=>{H.current&&R(D)})),g&&K&&K!==U&&H.current&&R(D);const A=()=>{H.current&&R(D)};return V&&(l==null||l.on(V,A)),q&&(l==null||l.store.on(q,A)),()=>{H.current=!1,l&&(V==null||V.split(" ").forEach(L=>l.off(L,A))),q&&l&&q.split(" ").forEach(L=>l.store.off(L,A))}},[l,U]),N.useEffect(()=>{H.current&&g&&R(h)},[l,m,g]);const re=[S,l,g];if(re.t=S,re.i18n=l,re.ready=g,g||!g&&!u)return re;throw new Promise(V=>{s.lng?wl(l,s.lng,_,()=>V()):Hn(l,_,()=>V())})},yy={type:"type",syntax:"syntax",overloads:"overloads",arguments:"arguments",fields:"fields",example:"example",returns:"returns",remarks:"remarks","see also":"see also","Copy code":"Copy code","Copy link":"Copy link",Copied:"Copied","Link copied":"Link copied",variables:"Variables",constants:"Constants",functions:"Functions",keywords:"Keywords",types:"Types",operators:"Operators",annotations:"Annotations",search:"Search","Mine Script® v1 Reference Manual":"Mine Script® v1 Reference Manual","This script is read-only. It cannot be edited.":"This script is read-only. It cannot be edited.","save script":"Save script","open script":"Open script","find/replace":"Find/Replace","toggle console":"Toggle console","open editor in new tab":"Open editor in new tab","open editor in new window":"Open editor in new window",keyword:"keyword","built-in function":"built-in function","built-in variable":"built-in variable","built-in method":"built-in method","built-in type":"built-in type",annotation:"annotation","built-in constant":"built-in constant",namespace:"namespace","user-defined variable":"user-defined variable","user-defined type":"user-defined type",field:"field",enum:"enum","user-defined method":"user-defined method","user-defined function":"user-defined function",parameter:"parameter","**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.":"**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Mine functions, variables, and methods.","to trigger parameters hint":"to trigger parameters hint",library:"library","enum member":"enum member",Returns:"Returns",Syntax:"Syntax",Remarks:"Remarks",Fields:"Fields",Description:"Description",Example:"Example","Enum members":"Enum members",statement:"statement",loop:"loop","`click` on keyword for more help":"`click` on keyword for more help"},_y={type:"类型",syntax:"语法",overloads:"重载",arguments:"参数",fields:"字段",example:"例子",returns:"返回值",remarks:"备注","see also":"另见","Copy code":"复制代码","Copy link":"复制链接",Copied:"已复制","Link copied":"链接已复制",variables:"内置变量",constants:"常量",functions:"函数",keywords:"关键词",types:"类型",operators:"运算符",annotations:"注释",search:"搜索","Mine Script® v1 Reference Manual":"Mine Script™ v1参考手册","This script is read-only. It cannot be edited.":"该脚本是只读的。它无法被编辑。","save script":"保存脚本","open script":"打开脚本","find/replace":"寻找/替换","toggle console":"切换控制台","open editor in new tab":"在新标签页中打开","open editor in new window":"在新窗口中打开",keyword:"关键词","built-in function":"内置函数","built-in variable":"内置变量","built-in method":"内置方法","built-in type":"内置类型",annotation:"注释","built-in constant":"内置常量",namespace:"命名空间","user-defined variable":"用户自定义变量","user-defined type":"用户自定义类型",field:"字段",enum:"枚举","user-defined method":"用户自定义方法","user-defined function":"用户自定义函数",parameter:"参数","**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.":"命名空间是不可变的术语,充当标识符组的前缀。在命名Mine函数、变量和方法时,点和另一个术语始终遵循命名空间。","to trigger parameters hint":"触发参数提示",library:"脚本库","enum member":"枚举成员",Returns:"返回值",Syntax:"语法",Remarks:"备注",Fields:"字段",Description:"描述",Example:"例子","Enum members":"枚举成员",statement:"声明",loop:"循环","`click` on keyword for more help":"“点击”关键词以获得更多帮助"};Me.use(bl).use(cy).init({debug:!1,fallbackLng:"zh",interpolation:{escapeValue:!1},resources:{en:{translation:yy},zh:{translation:_y}}}),self.MonacoEnvironment={getWorker(){return new Fm({name:"Editor Worker"})}},In.config({paths:{vs:"https://my.tradingvue.com/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const fy=(a,s)=>{const{height:r,width:n,theme:o,options:l,hasDiff:c,readOnly:u,defaultValue:m,language:_,onChange:g,onLinkOpen:x,onCursorPositionChange:h,onActionTrigger:D,onEditorDidMount:S}=a,{t:R,i18n:U}=Ws(),K=N.useRef(null),H=N.useRef(null),re=N.useRef(!1),W=N.useRef(!1);N.useImperativeHandle(s,()=>({setOriginalScript(A){var L;(L=K.current)==null||L.setOriginalScript(A)},setScript(A){var L;(L=K.current)==null||L.setValue(A)},gotoLine(){var A;(A=K.current)==null||A.gotoLine()},getEditorLayout(){var A;return(A=K.current)==null?void 0:A.getEditorLayout()},setPosition(A,L){var Z;(Z=K.current)==null||Z.setPosition({column:A,lineNumber:L})},setModelMarkers(A){var L;W.current=!0,(L=K.current)==null||L.setModelMarkers(A),setTimeout(()=>{W.current=!1},2e3)},focus(){var A;(A=K.current)==null||A.focus()}})),N.useEffect(()=>{var A,L;c?(L=K.current)==null||L.addDiffDecorations():(A=K.current)==null||A.removeDiffDecorations()},[c]),N.useEffect(()=>{o&&Ne.editor.setTheme(o)},[o]),N.useEffect(()=>{_&&U.changeLanguage(_)},[_]),N.useEffect(()=>{var A;(A=K.current)==null||A.updateActionTrigger(D)},[D]),N.useEffect(()=>{var A;x&&((A=K.current)==null||A.addLinkOpenFunc(x))},[x]);function Q(A,L){var ee,ne;Pt.initBuiltinsTrees(),_a.setEditor(A),K.current=new km(A,L,D),x&&((ee=K.current)==null||ee.addLinkOpenFunc(x)),c&&((ne=K.current)==null||ne.addDiffDecorations()),Gu(A),requestAnimationFrame(q);const Z=A.getValue();K.current.onChangeCursorPosition(h),g&&g(Z),!u&&C(Z),S&&S()}const C=N.useCallback(async A=>{var Rt;re.current=!1;const{errors:L,functions:Z,methods:ee,types:ne,variables:Y,overloadsFuncs:le,imports:xe,enums:pe}=await ml(A),_e=new Map(Object.entries(Z)),Ee=new Map(Object.entries(ee)),te=new Map(Object.entries(ne)),de=new Map(Object.entries(Y)),Oe=new Map(Object.entries(xe)),Ge=new Map(Object.entries(pe));Ds.setUserDefined({functions:_e,methods:Ee,types:te,variables:de,imports:Oe,enums:Ge},le),Pt.setUserDefind(_e,te,de,Ee,Ge);const Qe=L.map(us=>({...us,severity:us.type||Ne.MarkerSeverity.Error}));u||!re.current&&!W.current&&Qe.length&&((Rt=K.current)==null||Rt.setModelMarkers(Qe))},[u]),z=N.useMemo(()=>Qu.debounce(C,1500),[C]);function V(A){var L;if(u){C(A||"");return}re.current=!0,_a.clearInlayHints(),(L=K.current)==null||L.setModelMarkers([]),A!==void 0&&(g&&g(A),z(A))}const q=N.useCallback(()=>{var L,Z;const A=(L=H.current)==null?void 0:L.getBoundingClientRect();(Z=K.current)==null||Z.setEditorLayout((A==null?void 0:A.height)||0,A==null?void 0:A.width)},[]);return N.useEffect(()=>{const A=()=>{window.requestAnimationFrame(q)},L=new ResizeObserver(A);return H.current&&L.observe(H.current),()=>{var Z;H.current&&L.unobserve(H.current),L.disconnect(),(Z=K.current)==null||Z.dispose()}},[]),T.jsx("div",{ref:H,children:T.jsx(mu,{height:r,width:n||"100%",defaultLanguage:Ke,defaultValue:m||`indicator("我的脚本")
145
145
  plot(close)
146
146
  `,theme:o||"vs-dark",className:`tvue-script ${o||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,unicodeHighlight:{allowedCharacters:{" ":!0}},suggest:{filterGraceful:!0},fontSize:13,...u?am:{},readOnlyMessage:{value:R("This script is read-only. It cannot be edited.")},...l},onMount:Q,onChange:V})})},gy=N.forwardRef(fy),by=a=>{const{theme:s,modified:r,original:n,height:o,width:l,renderSideBySide:c=!0}=a,u=N.useCallback((m,_)=>{_.languages.register({id:Ke}),_.editor.defineTheme("vs-dark",Mn),_.editor.defineTheme("vs",Ln),_.languages.setMonarchTokensProvider(Ke,js),_.languages.setLanguageConfiguration(Ke,En)},[]);return T.jsx(lu,{height:o||"90vh",width:l||"100%",theme:s||"vs-dark",options:{readOnly:!0,renderSideBySide:c,scrollBeyondLastLine:!1},language:Ke,modified:r,original:n,onMount:u})};M.VMarkerSeverity=void 0,function(a){a[a.Hint=1]="Hint",a[a.Info=2]="Info",a[a.Warning=4]="Warning",a[a.Error=8]="Error"}(M.VMarkerSeverity||(M.VMarkerSeverity={}));var Ta={},xy=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var s=document.activeElement,r=[],n=0;n<a.rangeCount;n++)r.push(a.getRangeAt(n));switch(s.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":s.blur();break;default:s=null;break}return a.removeAllRanges(),function(){a.type==="Caret"&&a.removeAllRanges(),a.rangeCount||r.forEach(function(o){a.addRange(o)}),s&&s.focus()}},hy=xy,kl={"text/plain":"Text","text/html":"Url",default:"Text"},wy="Copy to clipboard: #{key}, Enter";function vy(a){var s=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,s)}function Ty(a,s){var r,n,o,l,c,u,m=!1;s||(s={}),r=s.debug||!1;try{o=hy(),l=document.createRange(),c=document.getSelection(),u=document.createElement("span"),u.textContent=a,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(g){if(g.stopPropagation(),s.format)if(g.preventDefault(),typeof g.clipboardData>"u"){r&&console.warn("unable to use e.clipboardData"),r&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var x=kl[s.format]||kl.default;window.clipboardData.setData(x,a)}else g.clipboardData.clearData(),g.clipboardData.setData(s.format,a);s.onCopy&&(g.preventDefault(),s.onCopy(g.clipboardData))}),document.body.appendChild(u),l.selectNodeContents(u),c.addRange(l);var _=document.execCommand("copy");if(!_)throw new Error("copy command was unsuccessful");m=!0}catch(g){r&&console.error("unable to copy using execCommand: ",g),r&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(s.format||"text",a),s.onCopy&&s.onCopy(window.clipboardData),m=!0}catch(x){r&&console.error("unable to copy using clipboardData: ",x),r&&console.error("falling back to prompt"),n=vy("message"in s?s.message:wy),window.prompt(n,a)}}finally{c&&(typeof c.removeRange=="function"?c.removeRange(l):c.removeAllRanges()),u&&document.body.removeChild(u),o()}return m}var ky=Ty;function Vn(a){"@babel/helpers - typeof";return Vn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Vn(a)}Object.defineProperty(Ta,"__esModule",{value:!0}),Ta.CopyToClipboard=void 0;var ka=Dl(N),Dy=Dl(ky),Iy=["text","onCopy","options","children"];function Dl(a){return a&&a.__esModule?a:{default:a}}function Il(a,s){var r=Object.keys(a);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(a);s&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(a,o).enumerable})),r.push.apply(r,n)}return r}function Al(a){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Il(Object(r),!0).forEach(function(n){Xn(a,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(r)):Il(Object(r)).forEach(function(n){Object.defineProperty(a,n,Object.getOwnPropertyDescriptor(r,n))})}return a}function Ay(a,s){if(a==null)return{};var r=qy(a,s),n,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);for(o=0;o<l.length;o++)n=l[o],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(a,n)&&(r[n]=a[n])}return r}function qy(a,s){if(a==null)return{};var r={},n=Object.keys(a),o,l;for(l=0;l<n.length;l++)o=n[l],!(s.indexOf(o)>=0)&&(r[o]=a[o]);return r}function Cy(a,s){if(!(a instanceof s))throw new TypeError("Cannot call a class as a function")}function ql(a,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(a,n.key,n)}}function Sy(a,s,r){return s&&ql(a.prototype,s),r&&ql(a,r),Object.defineProperty(a,"prototype",{writable:!1}),a}function zy(a,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(s&&s.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),s&&Gn(a,s)}function Gn(a,s){return Gn=Object.setPrototypeOf||function(n,o){return n.__proto__=o,n},Gn(a,s)}function Ny(a){var s=Ly();return function(){var n=Da(a),o;if(s){var l=Da(this).constructor;o=Reflect.construct(n,arguments,l)}else o=n.apply(this,arguments);return Ey(this,o)}}function Ey(a,s){if(s&&(Vn(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Cl(a)}function Cl(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Ly(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Da(a){return Da=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Da(a)}function Xn(a,s,r){return s in a?Object.defineProperty(a,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):a[s]=r,a}var Sl=function(a){zy(r,a);var s=Ny(r);function r(){var n;Cy(this,r);for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];return n=s.call.apply(s,[this].concat(l)),Xn(Cl(n),"onClick",function(u){var m=n.props,_=m.text,g=m.onCopy,x=m.children,h=m.options,D=ka.default.Children.only(x),S=(0,Dy.default)(_,h);g&&g(_,S),D&&D.props&&typeof D.props.onClick=="function"&&D.props.onClick(u)}),n}return Sy(r,[{key:"render",value:function(){var o=this.props;o.text,o.onCopy,o.options;var l=o.children,c=Ay(o,Iy),u=ka.default.Children.only(l);return ka.default.cloneElement(u,Al(Al({},c),{},{onClick:this.onClick}))}}]),r}(ka.default.PureComponent);Ta.CopyToClipboard=Sl,Xn(Sl,"defaultProps",{onCopy:void 0,options:void 0});var My=Ta,Yn=My.CopyToClipboard;Yn.CopyToClipboard=Yn;var Oy=Yn;const Vs=nd(Oy);Ne.languages.register({id:Ke}),Ne.editor.defineTheme("vs-dark",Mn),Ne.editor.defineTheme("vs",Ln),Ne.languages.setMonarchTokensProvider(Ke,js),Ne.languages.setLanguageConfiguration(Ke,En);async function zl(a,s){return s&&Ne.editor.setTheme(s.includes("dark")?"vs-dark":"light"),await Ne.editor.colorize(a,Ke,{tabSize:4})}async function Qn(a,s=0){const r=a[s];if(!r)return;const{name:n,args:o,type:l,desc:c,examples:u,remarks:m,seeAlso:_,syntax:g,detailedDesc:x,fields:h,returns:D}=r,S={name:n,orirginalName:n};if(a.length>1&&(S.overloads=`${a.length} ${Me.t("overloads")}`),l&&(S.type=l),o&&(S.name=`${n}()`,S.args=o.map(R=>{const{name:U,desc:K,displayType:H}=R;return{label:`${U} (${H})`,desc:K&&qs(K)}})),c&&(S.desc=c.map(R=>qs(R))),u&&(S.originalExample=u.join(`
147
147
  `),S.examples=await Ne.editor.colorize(S.originalExample,Ke,{tabSize:4})),x){S.detailedDesc=[];for(const R of x){const{desc:U,examples:K}=R;let H=U.map(Q=>qs(Q)),re,W;K&&(W=K.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guihz/trading-vue-editor-tes",
3
- "version": "0.0.262",
3
+ "version": "0.0.263",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"