@guihz/trading-vue-editor-tes 0.0.289 → 0.0.290
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-DpzZZ5qa.js → parserTccWorker-CG4IgAww.js} +3 -3
- package/lib/assets/{scriptsRunWorker-BalIXgQp.js → scriptsRunWorker-Bj5i72x4.js} +1 -1
- package/lib/trading-vue-editor.es.packages.js +2 -2
- package/lib/trading-vue-editor.umd.packages.mjs +1 -1
- package/package.json +1 -1
@@ -117,9 +117,9 @@ ${this._prefixNameVar}.setVarValue("${q}", ${A}, ${q}, "${b}")`}n==="-="?C=`${q}
|
|
117
117
|
${s}
|
118
118
|
}`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:z}),z}_parserArrowFunction(e){let n=`$_${e.name}`;this._nameMap.set(e.name,n);const r=[...e.params];n=`${n}${e.index?`$${e.index}`:""}`,this._currentFuncName=n,this._dependsObj[n]=new Map;const i=e.hasRequest?", $paramsExpr":"",s=`function ${n} (${this._parserParameters(r)}$posStr${i}) {
|
119
119
|
${this._parserBlock(e.block,!0,!0)}
|
120
|
-
}`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:s}),s}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:i}=n;let s=r;if(ge.includes(s)&&(s=`$${s}`),i){const b=this._parserSingleExpression(i);s=`${s} = ${b}`}return s}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){var r,i;const n=this._varlist[this._blockCount]||{};if(e.names){const s=e.posList;for(const[b,z]of e.names.entries()){const q=((r=s[b])==null?void 0:r.reName)||z;n[q]=s[b]}}else{const s=((i=e.pos)==null?void 0:i.reName)||e.name;n[s]=e.pos}this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var m;const{nameList:n,value:r}=e,i=this._parserDeclareAssignNames(n);this._addVarList(n);const s={code:"",varNames:i.replace(/[\[\]]/g,"").split(", "),depends:[]},b=`$${i}_${this._blockCount}`;this._dependsObj[b]=new Map;let z=this._parserSingleExpression(r);(n==null?void 0:n.ruleType)==="VarMultiple"&&(z=`(${z}) || []`);let q=`let ${i} = ${z}`;if(n.declare){const R=`${n.pos.column}_${n.pos.lineNumber}`,y=this._isInFunc?`$posStr + "_${R}"`:`"${R}"`;q=`let ${i} = ${this._prefixNameVar}.verifyVarAndVarip("${i}", ${y}, "${n.declare}") ? ${this._prefixNameVar}.getVarValue("${i}", ${y}, "${n.declare}") : ${this._prefixNameVar}.setVarValue("${i}", ${y}, ${z}, "${n.declare}")`}return s.code=q,s.depends=this._getDepends(b),(m=this._codesCol[this._blockCount])==null||m.push(s),q}_parserDeclareAssignNames(e){var n,r;switch(e==null?void 0:e.ruleType){case"VarMultiple":const i=e.posList;return`[${e.names.map((s,b)=>{var z,q;return s==="_"?(this.__count++,`_$$${this.__count}`):(z=i[b])!=null&&z.reName?(q=i[b])==null?void 0:q.reName:ge.includes(s)?`$${s}`:s}).join(", ")}]`;case"VarSingle":return e.name==="_"?(this.__count++,`_$$${this.__count}`):(n=e.pos)!=null&&n.reName?(r=e.pos)==null?void 0:r.reName:ge.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let i="";switch(e.ruleType){case i0.MemberIndexExpression:return this._parserMemberIndexExpression(e);case i0.MethodExpression:return this._parserMethodExpression(e);case i0.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case i0.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case i0.AdditiveExpression:return this._parserAdditiveExpression(e);case i0.MultiplicativeExpression:case i0.RelationalExpression:case i0.EqualityExpression:return this._parserEqualityExpression(e);case i0.LogicalAndExpression:return i=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,i;case i0.LogicalOrExpression:return i=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,i;case i0.TernaryExpression:return i=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,i;case i0.Name:return this._parserName(e);case i0.Literal:return this._parseLiteral(e);case i0.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.isBuiltInVar?`${this._prefixNameVar}.${e.name}`:e.isBuiltInConst?`${this._prefixNameConst}.${e.name}`:e.name||""}}_parserEqualityExpression(e){var q,m;const{exprs:n,operator:r}=e;let i=this._parserSingleExpression(n[0]),s=this._parserSingleExpression(n[1]);if(r==="/")return`${this._prefixNameVar}.div(${i}, ${s})`;if(!["*","%"].includes(r)&&!this._isInLoop&&(i=`${this._prefixNameVar}.compareDataHandle(${i})`,s=`${this._prefixNameVar}.compareDataHandle(${s})`),!["==","!="].includes(r))return`${i} ${r} ${s}`;const b=(q=n[0])==null?void 0:q.type,z=(m=n[1])==null?void 0:m.type;return`${this._prefixNameVar}.${r==="!="?"notEqual":"equal"}(${i}, ${s}, "${b}", "${z}")`}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,i=this._parserSingleExpression(n[0]),s=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${i}, ${s})`:`${this._prefixNameVar}.add(${i}, ${s})`}_parserMemberIndexExpression(e){var R,y;const{exprs:n,isInFunc:r,ctx:i}=e,s=n[0],b=this._parserSingleExpression(n[1]);let z=this._parserSingleExpression(s);const q=i.start.tokenIndex,m=r?"$posStr":q;if(s.ruleType===i0.Name&&!s.hasMethod){let E=this._blockCount;const C=((R=s.varPos)==null?void 0:R.reName)||s.name;if(!((y=s.arg)!=null&&y.isArg))for(;E>=0;){const k=this._varlist[E]||{},h=k[C];if(h)return this._getUserVarMemberIndexs(h,C,E,b,r);if(s.isBuiltIn){const A=this._memberIndexList[0]||{};return A[C]=`${this._prefixNameVar}.setCacheData("${C}", ${z})`,this._memberIndexList[0]=A,`${this._prefixNameVar}.getCacheData("${C}", ${b}, ${z})`}if(C.includes(".")){const A=C.split(".")[0],d=k[A];if(d)return this._getUserVarMemberIndexs(d,C,E,b,r)}E--}return this._getOtherVarMemberIndexs(`${C}_${s.varScope||s.scope}`,C,s.varScope||s.scope,b,r)}else{const E=this._preRunMembers[this._blockCount]||[],C=`$$m${q}_${m}`;E.push(`const ${C} = ${z};
|
120
|
+
}`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:s}),s}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:i}=n;let s=r;if(ge.includes(s)&&(s=`$${s}`),i){const b=this._parserSingleExpression(i);s=`${s} = ${b}`}return s}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){var r,i;const n=this._varlist[this._blockCount]||{};if(e.names){const s=e.posList;for(const[b,z]of e.names.entries()){const q=((r=s[b])==null?void 0:r.reName)||z;n[q]=s[b]}}else{const s=((i=e.pos)==null?void 0:i.reName)||e.name;n[s]=e.pos}this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var m;const{nameList:n,value:r}=e,i=this._parserDeclareAssignNames(n);this._addVarList(n);const s={code:"",varNames:i.replace(/[\[\]]/g,"").split(", "),depends:[]},b=`$${i}_${this._blockCount}`;this._dependsObj[b]=new Map;let z=this._parserSingleExpression(r);(n==null?void 0:n.ruleType)==="VarMultiple"&&(z=`(${z}) || []`);let q=`let ${i} = ${z}`;if(n.declare){const R=`${n.pos.column}_${n.pos.lineNumber}`,y=this._isInFunc?`$posStr + "_${R}"`:`"${R}"`;q=`let ${i} = ${this._prefixNameVar}.verifyVarAndVarip("${i}", ${y}, "${n.declare}") ? ${this._prefixNameVar}.getVarValue("${i}", ${y}, "${n.declare}") : ${this._prefixNameVar}.setVarValue("${i}", ${y}, ${z}, "${n.declare}")`}return s.code=q,s.depends=this._getDepends(b),(m=this._codesCol[this._blockCount])==null||m.push(s),q}_parserDeclareAssignNames(e){var n,r;switch(e==null?void 0:e.ruleType){case"VarMultiple":const i=e.posList;return`[${e.names.map((s,b)=>{var z,q;return s==="_"?(this.__count++,`_$$${this.__count}`):(z=i[b])!=null&&z.reName?(q=i[b])==null?void 0:q.reName:ge.includes(s)?`$${s}`:s}).join(", ")}]`;case"VarSingle":return e.name==="_"?(this.__count++,`_$$${this.__count}`):(n=e.pos)!=null&&n.reName?(r=e.pos)==null?void 0:r.reName:ge.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let i="";switch(e.ruleType){case i0.MemberIndexExpression:return this._parserMemberIndexExpression(e);case i0.MethodExpression:return this._parserMethodExpression(e);case i0.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case i0.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case i0.AdditiveExpression:return this._parserAdditiveExpression(e);case i0.MultiplicativeExpression:case i0.RelationalExpression:case i0.EqualityExpression:return this._parserEqualityExpression(e);case i0.LogicalAndExpression:return i=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,i;case i0.LogicalOrExpression:return i=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,i;case i0.TernaryExpression:return i=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,i;case i0.Name:return this._parserName(e);case i0.Literal:return this._parseLiteral(e);case i0.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.isBuiltInVar?`${this._prefixNameVar}.${e.name}`:e.isBuiltInConst?`${this._prefixNameConst}.${e.name}`:e.name||""}}_parserEqualityExpression(e){var q,m;const{exprs:n,operator:r}=e;let i=this._parserSingleExpression(n[0]),s=this._parserSingleExpression(n[1]);if(r==="/")return`${this._prefixNameVar}.div(${i}, ${s})`;if(!["*","%"].includes(r)&&!this._isInLoop&&(i=`${this._prefixNameVar}.compareDataHandle(${i})`,s=`${this._prefixNameVar}.compareDataHandle(${s})`),!["==","!="].includes(r))return`${i} ${r} ${s}`;const b=(q=n[0])==null?void 0:q.type,z=(m=n[1])==null?void 0:m.type;return`${this._prefixNameVar}.${r==="!="?"notEqual":"equal"}(${i}, ${s}, "${b}", "${z}")`}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,i=this._parserSingleExpression(n[0]),s=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${i}, ${s})`:`${this._prefixNameVar}.add(${i}, ${s})`}_parserMemberIndexExpression(e){var R,y;const{exprs:n,isInFunc:r,ctx:i}=e,s=n[0],b=this._parserSingleExpression(n[1]);let z=this._parserSingleExpression(s);const q=i.start.tokenIndex,m=r?"$posStr":q;if(s.ruleType===i0.Name&&!s.hasMethod){let E=this._blockCount;const C=((R=s.varPos)==null?void 0:R.reName)||s.name;if(!((y=s.arg)!=null&&y.isArg))for(;E>=0;){const k=this._varlist[E]||{},h=k[C];if(h)return this._getUserVarMemberIndexs(h,C,E,b,r);if(s.isBuiltIn){const A=this._memberIndexList[0]||{};return A[C]=`${this._prefixNameVar}.setCacheData("${C}", ${z})`,this._memberIndexList[0]=A,`${this._prefixNameVar}.getCacheData("${C}", ${b}, ${z})`}if(C.includes(".")){const A=C.split(".")[0],d=k[A];if(d)return this._getUserVarMemberIndexs(d,C,E,b,r)}E--}return this._getOtherVarMemberIndexs(`${C}_${s.varScope||s.scope}`,C,s.varScope||s.scope,b,r)}else{const E=this._preRunMembers[this._blockCount]||[],C=`$$m${q}_${m}`;return E.push(`const ${C} = ${z};
|
121
121
|
${this._prefixNameVar}.setCacheData("m${q}_" + ${m}, ${C})
|
122
|
-
`),this._preRunMembers[this._blockCount]=E
|
122
|
+
`),this._preRunMembers[this._blockCount]=E,`${this._prefixNameVar}.getCacheData("m${q}_" + ${m}, ${b}, ${C})`}}_getOtherVarMemberIndexs(e,n,r,i,s){const b=this._memberIndexList[r]||{};e=s&&r!==0?`"${e}_" + $posStr`:`"${e}"`;const z=`${this._prefixNameVar}.setCacheData(${e}, ${n})`;return b[e]=z,this._memberIndexList[r]=b,this._setDepend({name:n,scope:r,memberCode:z}),`${this._prefixNameVar}.getCacheData(${e}, ${i}, ${n})`}_getUserVarMemberIndexs(e,n,r,i,s){return this._getOtherVarMemberIndexs(`${n}_${e.lineNumber}_${e.column}`,n,r,i,s)}_parseLiteral(e){return e.type.endsWith(P.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16),b=e.substring(7);return b?n=parseInt(b,16)/255:n=1,`rgba(${Math.round(r)}, ${Math.round(i)}, ${Math.round(s)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){var m;const{exprs:r,varScope:i,hasMethod:s,arg:b,varPos:z}=e;let q=[];for(const R of r){if(typeof R=="string"){q.push((z==null?void 0:z.reName)||R);continue}let y="";const{column:E,line:C}=((m=R==null?void 0:R.ctx)==null?void 0:m.start)||{},k=`${C}_${E}`;let h=this._isInFunc?`$posStr + "__${k}"`:`"${k}"`;h=this._isInLoop?`"$" + $$count${this._count} + "_$" + ${h}`:h,R.selfArg?(y=this._parserMethodElement(R,h,q.join(".")),q=[]):y=this._parserMethodElement(R,h,""),q.push(y)}if(e.expr&&q.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn){const R=q.join(".");R==="strategy.opentrades"?q.push("opentrades"):R==="chart.left_visible_bar_time"?this._hasLeftVisibleBarTime=!0:R==="chart.right_visible_bar_time"&&(this._hasRightVisibleBarTime=!0),q.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar)}else if(ge.includes(q[0])&&(q[0]=`$${q[0]}`),!s){const R={name:q[0],scope:i||(b==null?void 0:b.varScope)||0,isAgainAssign:n,isArg:b==null?void 0:b.isArg,functionName:this._currentFuncName};this._setDepend(R)}return e.isBuiltIn||e.isAgainAssign||n?q.join("."):q.join("?.")}_setDepend(e){e.name.endsWith("?")&&(e.name=e.name.replace("?",""));const n=e.name;for(const r of Object.values(this._dependsObj)){const i=r.get(n)||{},s={...e,...i};r.set(n,s)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:i,line:s}=r.start,b=`${s}_${i}`;let z=this._isInFunc?`$posStr + "__${b}"`:`"${b}"`;z=this._isInLoop?`"$" + $$count${this._count} + "_$" + ${z}`:z,i===0&&(this._dependsObj[z]=new Map);let q=[];for(const R of n){let y="";R.selfArg?(y=this._parserMethodElement(R,z,q.join(".")),q=[]):y=this._parserMethodElement(R,z,""),q.push(y)}const m=q.join(".");return i===0&&this._codesCol[this._blockCount].push({code:m,isStmtFunc:!0,depends:this._getDepends(z)}),m}_parserMethodElement(e,n,r){var m,R,y;let i="",s="";const b={...e.args};e.expr&&(i=`(${this._parserSingleExpression(e.expr)})`),i=i?`${i}.${e.name}`:this._nameMap.get(e.name)||e.name;let z=!1;if(e.isBuiltIn){if(ju.includes(i))i=`${i}.${i}`;else if(i==="max_bars_back"){const{name:E,varPos:C}=b.var||b.params[0];s=`var_name: "${C?`${E}_${C.lineNumber}_${C.column}`:E}"`}else["array.new","matrix.new"].includes(i)?s=`type: "${e.type[0]}"`:i==="map.new"&&(s=`type: "${e.type}"`);i.startsWith(P.INPUT)?(s=`index: ${this._inputCount}`,this._inputCount++):i.startsWith("request.")&&(z=!0),i=`${this._prefixNameFunc}.${i}`}else{const E=i.split(".");let C=E[0];ge.includes(C.replace("?",""))&&(E[0]=`$${C}`,i=E.join("."))}if(e.selfArg){const E=i.split("."),C=E.length,k=E.slice(0,C-1);r&&k.unshift(r),!e.hasAddSelf&&Object.assign(b,{[e.selfArg.name]:{name:k.join("?."),isBuiltInConst:e.selfArg.isBuiltInConst,isBuiltInVar:e.selfArg.isBuiltInVar}}),i=(e.isBuiltInFunc?`${this._prefixNameFunc}.${e.funcName}`:e.funcName)||E[C-1],i=this._nameMap.get(i)||i,this._setDepend({name:E[0],scope:e.varScope||0})}i=`${i}${e.index&&!e.isBuiltIn&&!e.isBuiltInFunc?`$${e.index}`:""}`;const q=this._parserArguments(b,s,n,z,e.hasRequest,i);if(!e.isBuiltIn){const E=i.split(".");if(E.length>1?this._setDepend({name:E[0],scope:e.varScope||0}):this._setDepend({name:i,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const C=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:C,originName:i,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}if(e.targetVal){const E=e.targetVal,C=`${E.name}_${(m=E==null?void 0:E.range)==null?void 0:m.startLineNumber}_${(R=E==null?void 0:E.range)==null?void 0:R.endLineNumber}`;return i=`${this._prefixNameFunc}.getProxy(${E.name}, ${this._isInFunc&&E.scope!==0?`$posStr + "${C}"`:`"${C}"`}, { params: [${q.slice(1,q.length-1)}], funcName: "${E.funcName}" })`,i}else if((y=e.selfType)!=null&&y.length)return i=`${this._prefixNameFunc}.userFuncMiddleware(${e.selfArg.name}, "${e.selfType.join(",")}", ${i}, [${q.slice(1,q.length-1)}], ${n}, "${e.selfArg.name}", "${e.funcName}")`,i;return i+q}_parserArguments(e,n,r,i=!1,s=!1,b){const z=e.params||[];delete e.params;const q=[],m=[];let R=[],y;const E=(A,d)=>{b.startsWith(`${this._prefixNameFunc}.ta.`)&&d==="length"&&(A.type.startsWith(P.SERIES)||A.type===P.UNDETERMINED)&&q.push("isSeriesLen: true"),s&&(this._dependsObj[r]=new Map),i&&d==="expression"&&(this._dependsObj[`$arg_${d}${r}`]=new Map);let v=A.ruleType===i0.Brackethesized?this._parserBrackethesized(A):this._parserSingleExpression(A);if(d&&!["arg0, arg1, ...","number0, number1, ..."].includes(d)){A.isSourceType?q.push(`sourceTypeName: "${A.name}"`):d==="defval"&&b===`${this._prefixNameFunc}.input.enum`&&(y=this._enums.get(A.enumName));const L=this._requestParamsHandle(i,d,r,s,v,b);v=(L==null?void 0:L.code)||v,L!=null&&L.paramsExpr&&R.push(L==null?void 0:L.paramsExpr),ge.includes(d)&&(d=`$${d}`),ge.includes(v)&&(v=`$${v}`),q.push(`${d}: ${v}`)}else m.push(v)},C=[];for(const A of z)C.push(`'${A.originName}'`),E(A,A.originName);for(const A of Object.keys(e))E(e[A],A);i&&this._isInFunc&&q.push("paramsExpr: $paramsExpr"),n&&q.push(n),y&&q.unshift(`options: [${y.join(", ")}]`);const k=["label.new","line.new","box.new"].includes(b.replace(`${this._prefixNameFunc}.`,""))?`, [${C.join(",")}]`:"",h=R.length?`, [${this._isInFunc?"...$paramsExpr || [], ":""}${R.join(", ")}]`:"";return m.length?`({${q.join(", ")}}, [${m.join(", ")}], ${r}${h}${k})`:q.length?`({${q.join(", ")}}, ${r}${h}${k})`:`(${r}${h})`}_requestParamsHandle(e,n,r,i,s,b){const z=this._memberIndexList[0],q={};for(const m of Object.keys(z))m!=="_"&&(q[m]=z[m]);if(e&&n==="expression"){const m=this._getDepends(`$arg_${n}${r}`),R=this._getExpressionContext(m);return R.push({scope:this._blockCount,depends:m.map(y=>(y.isArg&&(y.functionName=this._currentFuncName),y)),code:s,memberCodes:q}),{code:`'${Ua(JSON.stringify(R))}'`}}else if(i){const m=this._getDepends(r),R=this._getExpressionContext(m);return R.push({scope:this._blockCount,type:2,varNames:n,methodName:b,depends:m,dependSelf:m.some(y=>y.name===n),code:`${n} = ${s}`,memberCodes:q}),{paramsExpr:`'${Ua(JSON.stringify(R))}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var b,z;const i=[];for(const q of e)if(!q.isArg){const m=this._codesCol[q.scope||0],R=m.find(E=>{var C;return((C=E.varNames)==null?void 0:C.includes(q.name))||E.funcName===q.name});R&&(r.includes(R)||(R.funcName&&i.push(R),r.push(R),R.depends.length&&this._getDependsCode(R.depends,n,r),n.push({scope:q.scope||0,code:R.code,depends:R.depends,funcName:R.funcName,varNames:(b=R.varNames)==null?void 0:b.join(", ")})));const y=m.filter(E=>E.depends.some(C=>C.name===q.name&&C.scope===q.scope&&C.isAgainAssign!==!1&&!C.isFunc));for(const E of y)r.includes(E)||(E.funcName&&i.push(E),r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:q.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(z=E.varNames)==null?void 0:z.join(", ")}))}const s=this._codesCol[0];for(const q of i){const m=s.filter(R=>R.isStmtFunc&&R.depends.some(y=>y.isFunc&&y.name===q.funcName));for(const R of m)if(!r.includes(R)){r.push(R);const y=R.depends;y.length&&this._getDependsCode(y,n,r),n.push({scope:0,code:R.code,depends:y,isStmtFunc:!0,funcName:R.funcName})}}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e,n){return`(function () {
|
123
123
|
let $$_result=${n&&typeof n=="string"&&n.endsWith("string")?'""':"undefined"};
|
124
124
|
${e}
|
125
125
|
return $$_result
|
@@ -282,6 +282,6 @@ Input files:
|
|
282
282
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,`+Sq(y)}else e.sourceMap.url&&(q.code+=`
|
283
283
|
//# sourceMappingURL=`+e.sourceMap.url)}return e.nameCache&&e.mangle&&(e.mangle.cache&&(e.nameCache.vars=FO(e.mangle.cache)),e.mangle.properties&&e.mangle.properties.cache&&(e.nameCache.props=FO(e.mangle.properties.cache))),m&&m.source_map&&m.source_map.destroy(),r&&(r.end=Date.now(),q.timings={parse:.001*(r.rename-r.parse),rename:.001*(r.compress-r.rename),compress:.001*(r.scope-r.compress),scope:.001*(r.mangle-r.scope),mangle:.001*(r.properties-r.mangle),properties:.001*(r.format-r.properties),format:.001*(r.end-r.format),total:.001*(r.end-r.start)}),q}async function UO(t,e,n){const r=Bq(t,e,n);let i,s;do s=r.next(await i),i=s.value;while(!s.done);return s.value}function VO(t){const e=new l3(t),n=new tp(e);n.removeErrorListeners();const r=new u3(n),i=new D(r);i._interp.predictionMode=m3.SLL,i.removeErrorListeners();const s=new Dq;n.addErrorListener(s),i.addErrorListener(s),i.buildParseTrees=!0;const b=i.program(),z=r.tokens.filter(q=>q.channel===2);return{errors:s.errors,ast:b,comments:z}}async function Cq(t,e,n,r){const{errors:i,ast:s,comments:b}=VO(t+`
|
284
284
|
|
285
|
-
`),z=new $z(r,b,n),q=await z.visit(s);let m=i.splice(0,1);m.length||(m=z.errors);let R="";const y=new r4("_$");let E=e?"":y.preParser(q);const C={};if(e&&!m.some(k=>k.type===xe.Error)){const{code:k="",hasLeftVisibleBarTime:h,hasRightVisibleBarTime:A}=y.parser(q)||{};Object.assign(C,{hasLeftVisibleBarTime:h,hasRightVisibleBarTime:A}),E=y.preParseCode;try{R=(await UO(k,{compress:!0,mangle:!0})).code||"";const v={message:O0.indiRunErr,type:xe.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(z.hasUseDrawFunc){if(z.scriptType===sr.library)z.exportPositions.length||(v.message=O0.libraryExportErr,m.push(v));else if(z.exportPositions.length){const L=z.exportPositions.map(T=>{const{type:I,...K}=T;return{message:l0(O0.exportUseErr,{type:I}),type:xe.Error,...K}});m.push(...L)}}else switch(z.scriptType){case sr.indicator:m.push(v);break;case sr.strategy:z.hasUseCreateOrderFunc||(v.message=O0.strategyRunErr,m.push(v));break}}catch(d){m.push({message:(d==null?void 0:d.message)||"minify error",type:xe.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0})}}return{errors:m,functions:Object.fromEntries(z.userFunctions),variables:Object.fromEntries(z.userVariables),types:Object.fromEntries(z.userTypes),methods:Object.fromEntries(z.userMethods),overloadsFuncs:z.overloadsFuncs,imports:Object.fromEntries(z.imports),enums:Object.fromEntries(z.userEnums),codeStr:R,preParserCode:E,config:C}}async function xq(t,e,n,r){const{ast:i,comments:s}=VO(t+`
|
285
|
+
`),z=new $z(r,b,n),q=await z.visit(s);let m=i.splice(0,1);m.length||(m=z.errors);let R="";const y=new r4("_$");let E=e?"":y.preParser(q);console.log(E);const C={};if(e&&!m.some(k=>k.type===xe.Error)){const{code:k="",hasLeftVisibleBarTime:h,hasRightVisibleBarTime:A}=y.parser(q)||{};Object.assign(C,{hasLeftVisibleBarTime:h,hasRightVisibleBarTime:A}),E=y.preParseCode;try{R=(await UO(k,{compress:!0,mangle:!0})).code||"";const v={message:O0.indiRunErr,type:xe.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(z.hasUseDrawFunc){if(z.scriptType===sr.library)z.exportPositions.length||(v.message=O0.libraryExportErr,m.push(v));else if(z.exportPositions.length){const L=z.exportPositions.map(T=>{const{type:I,...K}=T;return{message:l0(O0.exportUseErr,{type:I}),type:xe.Error,...K}});m.push(...L)}}else switch(z.scriptType){case sr.indicator:m.push(v);break;case sr.strategy:z.hasUseCreateOrderFunc||(v.message=O0.strategyRunErr,m.push(v));break}}catch(d){m.push({message:(d==null?void 0:d.message)||"minify error",type:xe.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0})}}return{errors:m,functions:Object.fromEntries(z.userFunctions),variables:Object.fromEntries(z.userVariables),types:Object.fromEntries(z.userTypes),methods:Object.fromEntries(z.userMethods),overloadsFuncs:z.overloadsFuncs,imports:Object.fromEntries(z.imports),enums:Object.fromEntries(z.userEnums),codeStr:R,preParserCode:E,config:C}}async function xq(t,e,n,r){const{ast:i,comments:s}=VO(t+`
|
286
286
|
|
287
287
|
`),b=new $z(r,s,n),z=await b.visit(i),{name:q,index:m}=b.endExport,R=z.findIndex(h=>h.name===q&&h.index===m),y=z.slice(0,R+1),C=new o4("$",e).parser(y)||"",k=await UO(C,{compress:!0,mangle:!0});return{...b.exportLibs,description:b.description,codeStr:k.code||""}}class Dq extends z3{constructor(){super(...arguments);S(this,"errors",[])}syntaxError(n,r,i,s,b){this.errors.push({message:`syntax error: ${b.replace(/expecting.+/,"")}`,type:xe.Error,startColumn:s,startLineNumber:i,endColumn:s,endLineNumber:i})}}wp({parseTcc:Cq,parseLibraryCode:xq})})();
|
@@ -82,7 +82,7 @@ ${s.join(`
|
|
82
82
|
`)}
|
83
83
|
return ${b==null?void 0:b.code}`;q>1;)l=`${l}}`,q--;const A=[];for(const h of Object.keys(z))l.includes(`$_var.getCacheData("${h}"`)&&A.push(z[h]);return A.length&&(l=`${A.join(`
|
84
84
|
`)}
|
85
|
-
${l}`),l}_getRequestLowerTfData(e,t,r,M){var R;let{symbol:n,timeframe:b,calc_bars_count:z,ignore_invalid_symbol:i,ignore_invalid_timeframe:c}=e;const{__period:O,time:s,_isRealTimeBar:u}=this._variables;b=uM(b);let l=y2(b,s)*1e3;const q=y2(O,s)*1e3;if(l>q)return!c&&this._errorListener.addError(l2(N1.requestLowerTfPeriodErr,{period:b}),t,K0.Error,25),[];const A=`${n}--${b}`,h=self.workerStorage.get(`request_${this._scriptId}_data`),d=self.workerStorage.get(`request_${this._scriptId}_list`),m=self.workerStorage.get(`request_${this._scriptId}_tmp`),_={id:A,calc_bars_count:z,ignore_invalid_symbol:i,symbol:n,originTimeframe:b,timeframe:Ai[b]||Ac(b)};if(h!=null&&h.has(A)){m==null||m.delete(A);const{index:g=0,periodStamp:L=q}=this._cacheData[r]||{},y=h==null?void 0:h.get(A);if(!y.length)return[];if(y.length-1<0)return[];const T=y.slice(g);let N=s,w=L+N;const E=[];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[r]={index:k,periodStamp:L}),E;if(N<=Y&&Y<w){const K=(R=H==null?void 0:H.result)==null?void 0:R[r];if(Array.isArray(K))for(const[e0,b0]of K.entries())E[e0]||(E[e0]=[]),E[e0].push(b0);else M||E.push(K)}}return!u&&(this._cacheData[r]={index:y.length,periodStamp:L}),E}else(d==null?void 0:d.get(A))||m==null||m.set(A,_);d==null||d.set(A,_)}_getRequestData(e,t){var m,_,R,g,L;let{symbol:r,timeframe:M,calc_bars_count:n,gaps:b,lookahead:z,ignore_invalid_symbol:i}=e;const{__period:c,mintick:O,time:s,nextBarTime:u}=this._variables;M=uM(M),r=r;const l=`${r}--${M}`,q=self.workerStorage.get(`request_${this._scriptId}_data`),A=self.workerStorage.get(`request_${this._scriptId}_list`),h=self.workerStorage.get(`request_${this._scriptId}_tmp`),d={id:l,calc_bars_count:n,ignore_invalid_symbol:i,symbol:r,originTimeframe:M,timeframe:Ai[M]||Ac(M)};if(q!=null&&q.has(l)){let y=y2(M,s)*1e3;const D=y2(c,s)*1e3;h==null||h.delete(l);const{index:T=0,periodStamp:N=D}=this._cacheData[t]||{},w=q==null?void 0:q.get(l);if(!w.length)return;const E=w.slice(T);let P=s,H=N+P;const Y=w.length-1;if(Y<0)return;const k={lastBarIndex:w[Y].barindex||Y,lastBarTime:w[Y].time,interval:M,mintick:O};if(y>N){let K;if(z===ke.lookaheadOn?K=this._lookaheadOnHandle(E,M,H,y,k,T,N,t,P,b):K=this._lookaheadOffHandle(E,M,H,y,k,T,N,t,P,u||H,b),K)return K;if(K===null)return}else if(z===ke.lookaheadOn)for(const[K,e0]of E.entries()){let{time:b0,barindex:O0}=e0;b0=b0*1e3;const v0=((m=E[K+1])==null?void 0:m.time)*1e3||b0+y;let B0=T+K;if(b0>=H){this._cacheData[t]={index:B0,periodStamp:N};return}if(b0<=P&&v0>P){const A0=T+K;return this._cacheData[t]={index:A0,periodStamp:N},{...e0,barIndex:O0||A0,nextBarTime:(_=E[K+1])==null?void 0:_.time,...k}}}else for(const[K,e0]of E.entries()){let{time:b0,barindex:O0}=e0;b0=b0*1e3;const v0=((R=E[K+1])==null?void 0:R.time)*1e3||b0+y;let B0=T+K;if(b0>H){this._cacheData[t]={index:B0,periodStamp:N};return}if(b0<H&&H<=v0)return this._cacheData[t]={index:B0,periodStamp:N},{...e0,barIndex:O0||B0,nextBarTime:(g=E[K+1])==null?void 0:g.time,...k};if(b0>=P&&b0<=H&&(O0||B0)===k.lastBarIndex)return this._cacheData[t]={index:B0,periodStamp:N},{...e0,barIndex:O0||B0,nextBarTime:(L=E[K+1])==null?void 0:L.time,...k}}this._cacheData[t]={index:w.length,periodStamp:N};return}else(A==null?void 0:A.get(l))||h==null||h.set(l,d);A==null||A.set(l,d)}_lookaheadOnHandle(e,t,r,M,n,b,z,i,c,O){var s;for(const[u,l]of e.entries()){let{time:q,barindex:A}=l;q=q*1e3,t.includes("M")&&(M=y2(t,q)*1e3-(O1(q).date()-1)*864e5);const h=q,d=M+h;let m=b+u;if(r<=h)return this._cacheData[i]={index:m,periodStamp:z},null;let _={...l,barIndex:A||m,nextBarTime:(s=e[u+1])==null?void 0:s.time,...n};if(O===ke.gapsOn){if(r>h&&c<=h)return this._cacheData[i]={index:m,periodStamp:z},_}else{if(r>d)continue;if(r>h)return this._cacheData[i]={index:m,periodStamp:z},_}}}_lookaheadOffHandle(e,t,r,M,n,b,z,i,c,O,s){var u,l;for(const[q,A]of e.entries()){let{time:h,barindex:d}=A;h=h*1e3,t.includes("M")&&(M=y2(t,h)*1e3-(O1(h).date()-1)*864e5);const m=h,_=M+m,R=b+q;if(r<m)return this._cacheData[i]={index:R,periodStamp:z},null;const g={...A,barIndex:d||R,nextBarTime:(u=e[q+1])==null?void 0:u.time,...n};if(r>=_&&c<_||r<_&&O>=_)return s===ke.gapsOn?(this._cacheData[i]={index:R,periodStamp:z},g):(this._cacheData[i]={index:R,data:g,periodStamp:z},g);if(!(c>_)&&c>=m){let L=(l=this._cacheData[i])==null?void 0:l.data;if(!L){const y=e[R-1];if(!y)return null;L={...y,barIndex:y.barindex||R-1,nextBarTime:g.time,...n},this._cacheData[i]={index:R,data:L,periodStamp:z}}return L}}}_getDependCodes(e,t,r,M,n,b){for(const z of e){if(!z.isArg){const i=t.filter(O=>{var s;return(s=O==null?void 0:O.depends)==null?void 0:s.some(u=>u.name===z.name&&u.scope===z.scope&&u.isAgainAssign!==!1)});for(const O of i){const{code:s,depends:u,scope:l,funcName:q}=O;r[l]=r[l]||[];const A=r[l];let h=l===0&&q;if(!A.includes(s)){if(h){if(M.includes(s))continue;M.unshift(s)}else A.unshift(s);if(u!=null&&u.length){for(const d of u)d.memberCode&&!h&&b.push(d.memberCode);this._getDependCodes(u,t,r,M,n,b)}}}const c=t.find(O=>{var s;return((s=O.varNames)==null?void 0:s.split(", ").includes(z.name))&&(!z.isPreArg||z.isPreArg&&O.methodName===z.functionName)||O.funcName===z.name});if(c){const{code:O,depends:s,scope:u}=c;r[u]=r[u]||[];const l=r[u],q=l.findIndex(A=>A===O);if(q!==-1){if(z.isFunc)continue;l.splice(q,1)}if(l.unshift(O),s!=null&&s.length){for(const A of s)A.memberCode&&b.push(A.memberCode);this._getDependCodes(s,t,r,M,n,b)}continue}}n.some(i=>i.name===z.name)||n.push(z)}}_getStmtFuncs(e,t,r,M,n){const b=t.filter(z=>z.isStmtFunc);for(const z of b){const{code:i,depends:c,scope:O=0}=z;e[O]=e[O]||[];const s=e[O];if(!s.includes(i)&&(s.push(i),c!=null&&c.length)){for(const u of c)u.memberCode&&r.push(u.memberCode);this._getDependCodes(c.filter(u=>!(u.isFunc&&i.startsWith(u.name))),t,e,M,n,r)}}}runScripts(e,t,r,M,n,b){var u,l;const z=`${this._scriptId}_${t}`,i=new _p(z),c=new hp,O=new Wp(this._variables.mintick||1e-5,i,this._scriptId),s=new Function("_$_var","_$_const","_$_func","$paramsExpr","$posStr",e);if(!r){const{varCacheData:q,funcCacheData:A}=n;i.setVarCacheData(q),O.setFuncCacheData(A)}if(i.__requestName=t,M&&M.length){const q=M.length-1,{interval:A,symbol:h=""}=n;let{mintick:d,syminfo:m}=this._variables;const[_,R]=h.split(":");d||(d=Math.pow(10,-(((u=String(M[0].o).split(".")[1])==null?void 0:u.length)||0))),i.updateOptions({interval:A,mintick:d,syminfo:{...m.__syminfo,mintick:d,tickerid:h||m.tickerid,ticker:R||_||m.ticker}});for(const[y,D]of M.entries()){const{barindex:T}=D,N=Object.assign(D,{barIndex:T||y,lastBarIndex:M[q].barindex||q,lastBarTime:M[q].time,nextBarTime:(l=M[y+1])==null?void 0:l.time});if(i.updateData(N),O.update({barIndex:(N==null?void 0:N.barindex)||0}),D.result=Object.assign(D.result||{},{[t]:s(i,c,O,b||[],t)}),O.endExecution(),O.errors.length&&O.errors.some(w=>w.type===K0.Error))return{logs:[],errors:O.errors}}const g=O.log.logs,L=O.errors;return O.log.clearLogs(),O.clearErrors(),{logs:g,errors:L,cacheData:{varCacheData:i.getVarCacheData(),funcCacheData:O.getFuncCacheData()}}}}_runScripts(e,t,r,M,n){const b=`${this._scriptId}_${t}`;let{builtInGather:z,buildinConstants:i,buildInFunctions:c,tradingvueFunc:O}=self.workerStorage.get(b)||{};const{interval:s,...u}=n||{};if(r){z=new _p(b),i=new hp,c=new Wp(this._variables.mintick||1e-5,z,this._scriptId),O=new Function("_$_var","_$_const","_$_func","$paramsExpr","$posStr",e);const{mintick:h,syminfo:d}=this._variables;z.updateOptions({interval:s,mintick:h||1e-5,syminfo:{...d.__syminfo}}),z.__requestName=t,self.workerStorage.set(b,{builtInGather:z,buildinConstants:i,buildInFunctions:c,tradingvueFunc:O})}z.updateData(u),c.update({barIndex:(u==null?void 0:u.barindex)||0});const l=O(z,i,c,M||[],t),q=c.log.logs,A=c.errors;return c.log.clearLogs(),c.clearErrors(),c.endExecution(),{result:l,logs:q,errors:A}}},Fm=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 Im{constructor(e,t){C(this,"_logs");C(this,"_variables");C(this,"_str");C(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=e,this._logs=[],this._str=t}get _logCacheData(){return this._preBar}set _logCacheData(e){this._preBar=e}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,M){if(typeof t=="string"&&(M=t),M.startsWith("export"))return;const{message:n,formatString:b}=e,{time:z,bar_index:i,_isRealTimeBar:c,__isReqRepeated:O}=this._variables;let s=n;b&&Array.isArray(t)&&t.length&&(t=t.map(A=>{if(typeof A=="object"){if(A===null)return"null";A!=null&&A.isArray?A=`[${A._value.toString()}]`:A=A.toString()}return A!==void 0?A:"na"}),s=this._str.strformat({formatString:b},t,!0));const{isrealtime:u,barIndex:l}=this._preBar;i!==l&&(this._preBar={barIndex:i,isrealtime:c});const q=Date.now();s!==void 0&&this._logs.push({message:`[${O1(u&&!O?q:z).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${s}`,time:z,id:K4(6),barIndex:i,type:r})}}class Pm{constructor(e){C(this,"_errorListener");this._errorListener=e}error({message:e},t){t.startsWith("export")||this._errorListener.addError(e,t,K0.Error)}}class km{constructor(){C(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return b2.flatMap([...this._errors.values()])}setErrors(e,t){this._errors.set(t,e)}addError(e,t,r,M=0){const[n,b]=t.split("_").slice(-2),z=this._errors.get(t),i={message:e,endLineNumber:Number(n),startColumn:Number(b)+1,endColumn:Number(b)+M+1,startLineNumber:Number(n),type:r};z?z.push(i):this._errors.set(t,[i])}}class $m{constructor(){C(this,"_isMarketOpen");C(this,"_currentBarIndex");C(this,"_totalBarIndex");C(this,"_isRealTimeBar");C(this,"_preBarIndex");C(this,"_preIsRealTimeBar");C(this,"_isFirstRun",!1);this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0,this._preIsRealTimeBar=!1}update(e,t,r,M){this._preBarIndex=this._currentBarIndex,this._preIsRealTimeBar=this._isRealTimeBar,this._currentBarIndex=e,this._totalBarIndex=t,this._isRealTimeBar=r,this._isMarketOpen=M}get _barstateCacheData(){return{currentBarIndex:this._currentBarIndex,isRealTimeBar:this._isRealTimeBar}}set _barstateCacheData(e){this._currentBarIndex=e.currentBarIndex,this._isRealTimeBar=e.isRealTimeBar}set isFirstRun(e){this._isFirstRun=e}get isnew(){return this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex||!this._isFirstRun}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar||this._isFirstRun}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 Um{constructor(e){C(this,"_variables");this._variables=e}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday||this._variables.bar_index===0}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 jm{constructor(e){C(this,"_orders");C(this,"_historyOrders");C(this,"_options");C(this,"_max_contracts_held_all",0);C(this,"_max_contracts_held_long",0);C(this,"_max_contracts_held_short",0);C(this,"_max_drawdown",0);C(this,"_max_runup",0);C(this,"_max_runup_percent",0);C(this,"_max_drawdown_percent",0);C(this,"_variables");C(this,"_netprofit",0);C(this,"_eventrades",0);C(this,"_avg_trade_percent");C(this,"_avg_losing_trade_percent");C(this,"_avg_winning_trade_percent");C(this,"_closedtrades",0);C(this,"_losstrades",0);C(this,"_grossloss",0);C(this,"_grossprofit",0);C(this,"_wintrades",0);C(this,"_opentrades_capital_held",0);C(this,"_position_avg_price",0);C(this,"_position_size",0);C(this,"_openprofit",0);C(this,"_preMaxNetValue",0);C(this,"_preMinNetValue",0);C(this,"marginCallLong",0);C(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:M,low:n,close:b}=e;let z=0;for(const[O,s]of this._orders.entries()){const{in_price:u,qty:l=0,direction:q,commission:A,original_qty:h=1}=s,d=q===a1.long?1:-1,m=(M-u)*l,_=(n-u)*l,R=d===1?m:-_,g=d===1?-_:m;z+=(b-u)*d*l,t+=g,O>0&&A&&(r-=A*l/h),r+=R}this._openprofit=z;const i=this.initial_capital,c=i+this._netprofit;this._preMinNetValue=this._preMinNetValue||i,this._preMaxNetValue=this._preMaxNetValue||i,t=this._preMaxNetValue-c+Math.max(t,0),r=c-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(){if(!this._orders.length){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[t,r,M,n,b,z]=this._orders.reduce(([i,c,O,s,u,l],q)=>{const{direction:A,qty:h=0,in_price:d,commission:m=0}=q;return A===a1.long?(i+=h,c+=h,u+=h):(i+=h,O+=h,u-=h),s+=h*d,l+=m,[i,c,O,s,u,l]},[0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-z,this._grossloss=z),this._position_size=b,this._position_avg_price=n/t,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(M,this._max_contracts_held_short)}updateHistoryOrders(e){this._historyOrders=e;const t=this._historyOrders.length;this._closedtrades=t;const[r,M,n,b,z,i,c,O]=this._historyOrders.reduce((l,q)=>{let[A,h,d,m,_,R,g,L]=l;const{profit:y=0,profit_percent:D=0}=q;return A+=y,h+=D,y<0?(d+=y,m+=D,g+=1):y>0&&(_+=y,R+=D,L+=1),[A,h,d,m,_,R,g,L]},[0,0,0,0,0,0,0,0]),s=this._orders.reduce((l,q)=>{const{commission:A=0,qty:h=0,original_qty:d=0}=q,m=A*h/d;return l+m},0);this._avg_trade_percent=t?M/t:void 0,this._avg_losing_trade_percent=t?Math.abs(b)/c:void 0,this._avg_winning_trade_percent=t?i/O:void 0,this._netprofit=r-s;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-s),this._grossprofit=z,this._eventrades=t-c-O,this._losstrades=c,this._wintrades=O}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:M,commission_value:n=0}=this._options,b=this._orders[0].direction===a1.long?1:-1,z=(b===1?t:r)/100;if(z<=0)return;const{close:i}=this._variables,[c,O]=this._orders.reduce((s,u)=>{let[l,q]=s;const{in_price:A,qty:h=0,original_qty:d=0}=u,m=A*h;if(l+=m,n){let _=0;switch(M){case O2.percent:_=(m+h*i)*n/100;break;case O2.cashPerContract:_=h*n*2;break;case O2.cashPerOrder:_=h/d*n+n;break}q+=_}return[l,q]},[0,0]);return(c-(e+this._netprofit-O))*b/this._position_size/(1-b*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:M}=this._options,n=e*t;let b=0;switch(M){case O2.percent:b=n*r/100;break;case O2.cashPerContract:b=t*r;break;case O2.cashPerOrder:b=r;break}return b}}class Hm{constructor(e){C(this,"_preAccdist");C(this,"_preNvi");C(this,"_prePvi");C(this,"_preObv");C(this,"_prePvt");C(this,"_preWad");C(this,"_preVwap");C(this,"_preValue");C(this,"_currentData");C(this,"_preData");C(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}get _varTaCacheData(){return{preAccdist:this._preAccdist,preNvi:this._preNvi,prePvi:this._prePvi,preObv:this._preObv,prePvt:this._prePvt,preWad:this._preWad,preVwap:this._preVwap,currentData:this._currentData,preData:this._preData}}set _varTaCacheData(e){const{preAccdist:t,preNvi:r,prePvi:M,preObv:n,prePvt:b,preWad:z,preVwap:i,currentData:c,preData:O}=e;this._preAccdist=t,this._preNvi=r,this._prePvi=M,this._preObv=n,this._prePvt=b,this._preWad=z,this._preVwap=i,this._currentData=c,this._preData=O}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:M}=this._currentData;if(r===t)return this._preAccdist;const n=(e-t-(r-e))/(r-t)*M+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:M}=this._currentData,n=(2*e-r-t)/((r-t)*M);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:M,open:n}=this._currentData,b=(e-n)/(r-t)*M;return this._preValue.wvad=b,b}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 M=Math.sign(e-r)*t+this._preObv;return!this.isRealTime&&(this._preObv=M),this._preValue.obv=M,M}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 M=Math.max(t-e,Math.abs(t-r),Math.abs(e-r));return this._preValue.tr=M,M}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 M=(e-r)/r*t+this._prePvt;return!this.isRealTime&&(this._prePvt=M),this._preValue.pvt=M,M}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:e,high:t,low:r}=this._currentData,{close:M}=this._preData;if(M===void 0)return this._preWad=0,0;const n=Math.max(t,M),b=Math.min(r,M),z=e-M,c=(z>0?e-b:z<0?e-n:0)+this._preWad;return!this.isRealTime&&(this._preWad=c),this._preValue.wad=c,c}get vwap(){var O,s;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:e,volume:t}=this._currentData;let{sum:r=0,sumV:M=0,isReset:n}=this._preVwap;if(((s=(O=self.workerStorage)==null?void 0:O.get(this._id))==null?void 0:s.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(n=!0,r=M=0),!n)return;const z=e*t+r,i=t+M;!this.isRealTime&&(this._preVwap={sum:z,sumV:i,isReset:n});const c=z/i;return this._preValue.vwap=c,c}_getNvi(){const e=this._preNvi||1,{close:t=0,volume:r=0}=this._preData,{close:M,volume:n}=this._currentData;let b=1;const z=e||1;return M&&t?b=n<r?z+(M-t)/t*z:z:b=z,!this.isRealTime&&(this._preNvi=b),this._preValue.nvi=b,b}_getPvi(){const e=this._prePvi||1,{close:t=0,volume:r=0}=this._preData,{close:M,volume:n}=this._currentData;let b=1;const z=e||1;return M&&t?b=n>r?z+(M-t)/t*z:z:b=z,!this.isRealTime&&(this._prePvi=b),this._preValue.pvi=b,b}}class Ym{constructor(){C(this,"_period");C(this,"_multiplier");C(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(e){if(!e)return;this._period=e;const[t,r]=ht(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 Gm{constructor(){C(this,"_bgColor");C(this,"_fgColor");C(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,M,n;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),M=parseInt(e.substring(5,7),16);const b=e.substring(7);b?n=parseInt(b,16)/255:n=1}else{const b=this._parserRgbColor(e);t=b[0]||0,r=b[1]||0,M=b[2]||0,n=b[3]||1}return{r:t,g:r,b:M,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:M}=this._parseColor(e);return(299*t+587*r+114*M)/1e3>128?"#000000":"#ffffff"}}class Vm{constructor(){C(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||ft.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||"forex"}get volumetype(){return this._syminfo.volumetype||"n/a"}}class Km{constructor(e){C(this,"_variables");this._variables=e}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class Jm{constructor(e){C(this,"_variables");this._variables=e}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}class _p{constructor(e){C(this,"_cacheData");C(this,"_barIndex");C(this,"_isRealTimeBar");C(this,"_barstate");C(this,"_priceVariables");C(this,"_lastBarIndex");C(this,"_currentBarTime");C(this,"_lastBarTime");C(this,"_period");C(this,"_offsetTime");C(this,"_timeframe");C(this,"_ta");C(this,"_polyline");C(this,"_label");C(this,"_line");C(this,"_linefill");C(this,"_box");C(this,"_table");C(this,"_strategy");C(this,"_session");C(this,"syminfo");C(this,"chart");C(this,"earnings");C(this,"dividends");C(this,"_timeTradingday");C(this,"_mintick");C(this,"_cacheSpace");C(this,"_precision");C(this,"_nextBarTime");C(this,"_isRepeated");C(this,"_preCacheData");C(this,"__requestName","");C(this,"__isFirstRun",!1);C(this,"_maxBarsBack",0);C(this,"_maxBarsBackOfKey");C(this,"__isReqRepeated");C(this,"_newCacheData",{});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 $m,this._timeframe=new Ym,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new Hm(e),this._polyline=new Sr(this,N0.POLYLINE),this._label=new Sr(this,N0.LABEL),this._line=new Sr(this,N0.LINE),this._linefill=new Sr(this,N0.LINEFILL),this._box=new Sr(this,N0.BOX),this._table=new Sr(this,N0.TABLE),this._strategy=new jm(this),this._session=new Um(this),this.syminfo=new Vm,this.chart=new Gm,this.earnings=new Jm(this),this.dividends=new Km(this),this._cacheSpace=Object.create(null),this._maxBarsBackOfKey=Object.create(null)}getVarCacheData(){return{cacheData:this._cacheData,preCacheData:this._preCacheData,cacheSpace:this._cacheSpace,taCacheData:this._ta._varTaCacheData,polylineCacheData:this._polyline._cacheData,labelCacheData:this._label._cacheData,lineCacheData:this._line._cacheData,linefillCacheData:this._linefill._cacheData,boxCacheData:this._box._cacheData,tableCacheData:this._table._cacheData,barstateCacheData:this.barstate._barstateCacheData}}setVarCacheData(e){if(!e)return;const{cacheData:t,preCacheData:r,cacheSpace:M,taCacheData:n,polylineCacheData:b,labelCacheData:z,lineCacheData:i,linefillCacheData:c,boxCacheData:O,tableCacheData:s,barstateCacheData:u}=e;this._cacheData=t,this._preCacheData=r,this._cacheSpace=M,this._ta._varTaCacheData=n,this._polyline._cacheData=b,this._label._cacheData=z,this._line._cacheData=i,this._linefill._cacheData=c,this._box._cacheData=O,this._table._cacheData=s,this.barstate._barstateCacheData=u}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:M}=this._priceVariables;return(e+t+r+M)/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 O1(this._currentBarTime).hour()}get minute(){return O1(this._currentBarTime).minute()}get second(){return O1(this._currentBarTime).second()}get month(){return O1(this._currentBarTime).month()+1}get year(){return O1(this._currentBarTime).year()}get dayofweek(){return O1(this.time_tradingday).weekday()}get dayofmonth(){return O1(this.time_tradingday).date()}get weekofyear(){return O1(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[e,t]=ht(this._period);return O1(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}set max_bars_back(e){this._maxBarsBack=e}updateMaxLength(e){const{max_lines_count:t,max_labels_count:r,max_boxes_count:M,max_polylines_count:n}=e;M&&this._box.setMaxLen(M),r&&this._label.setMaxLen(r),t&&this._line.setMaxLen(t),n&&this._polyline.setMaxLen(n)}getTimeTradingday(e,t){const[r,M]=ht(t),n=O1(e);return["M","w","y","d"].includes(M)?n.valueOf():(n.subtract(this._offsetTime,"h"),n.startOf("d").add(this._offsetTime,"h").valueOf())}_getTimeTradingday(e,t){const[r,M]=ht(t),n=O1(e).utc(!0);return["M","w","y","d"].includes(M)?n.valueOf():n.startOf("d").valueOf()}updateOptions(e){var c;const{interval:t="1D",offsetTime:r=5,mintick:M,chart:n,syminfo:b}=e,z=((c=M.toString().split(".")[1])==null?void 0:c.length)||5;this._precision=z;const i=Q4(t);this._period=i,this._mintick=M,this._offsetTime=r,this._timeframe.update(i),this.chart.updateOptions(n),this.syminfo.update(b),this._barstate.isFirstRun=this.__isFirstRun}updateData(e,t){const{barIndex:r,c:M,o:n,h:b,l:z,volume:i,time:c,lastBarIndex:O,lastBarTime:s,isrealtime:u,time_tradingday:l,nextBarTime:q}=e;if(this._priceVariables={close:rn(M,this._precision),open:rn(n,this._precision),high:rn(b,this._precision),low:rn(z,this._precision),volume:Number(i)},this._isRealTimeBar=u,this._newCacheData={},r>this._barIndex){const{varData:A,varipData:h}=this._cacheData;this._preCacheData={varData:{},varipData:{}},u?(this._preCacheData.varData=b2.cloneDeep(A),this._preCacheData.varipData=b2.cloneDeep(h)):this._preCacheData={varData:{...A},varipData:{...h}}}this._isRepeated=t,this._timeTradingday=l,this._currentBarTime=c*1e3,this._lastBarIndex=O,this._barIndex=r,this._lastBarTime=s*1e3,this._nextBarTime=q*1e3,this._barstate.update(r,O,u,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(e,t,r){const M=this.setCacheData(e,r),n=this._cacheSpace[e]||0;return t=Math.floor(t),n<t&&(this._cacheSpace[e]=t),M[M.length-1-t]}setCacheData(e,t){let r=this._cacheData[e]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;t=this._cacheCopy(t),r.barIndex===this._barIndex?r.data[r.data.length-1]=t:r.data.push(t);const M=this._cacheSpace[e]||0,n=ui.includes(e)?500:50;return M&&r.data.length>(this._maxBarsBackOfKey[e]||this._maxBarsBack||M+n)&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[e]=r,r.data}__setBarsBackOfKey(e,t){this._maxBarsBackOfKey[e]=t}__getBarsBackOfKey(e){return this._maxBarsBackOfKey[e]}getTypeInstance(e,t,r){return new Oi(e,t,r)}verifyVarAndVarip(e,t,r){const M=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`,n=this._isRepeated||this.__isReqRepeated?this._preCacheData:this._cacheData;if(r==="var"&&n.varData.hasOwnProperty(M))return this._upadteChartDraws(n.varData,M),!0;const b=this.__isReqRepeated?this._preCacheData.varipData:this._cacheData.varipData;return r==="varip"&&b.hasOwnProperty(M)?(this._upadteChartDraws(b,M),!0):!1}getVarValue(e,t,r){const M=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`;(this._isRepeated||this.__isReqRepeated)&&(this._cacheData.varData[M]=this._preCacheData.varData[M],this.__isReqRepeated&&(this._cacheData.varipData[M]=this._preCacheData.varipData[M]));const n=this._cacheData;if(r==="var"){const b=n.varData[M];return this._isRealTimeBar?this._newCacheData.hasOwnProperty(M)?this._newCacheData[M]:this._cacheCopy(b):b}return this._cacheData.varipData[M]}setVarValue(e,t,r,M){var z;const n=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`;let b;switch(typeof r=="object"&&((z=r==null?void 0:r.varipKeys)!=null&&z.length)&&M!=="varip"&&(M="var",b=r.varipKeys),M){case"var":if(this._isRealTimeBar){if(b&&b.length)for(const i of b)this._cacheData.varData[n][i]=r[i];this._newCacheData[n]=r}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,t){const r=e[t],M=this._isRealTimeBar?r==null?void 0:r.preId:r==null?void 0:r.id;if(!M)return;let n;switch(r==null?void 0:r.type){case N0.BOX:n=this._setChartDraw(M,this._box);break;case N0.LINE:n=this._setChartDraw(M,this._line);break;case N0.POLYLINE:n=this._setChartDraw(M,this._polyline);break;case N0.LABEL:n=this._setChartDraw(M,this._label);break;case N0.LINEFILL:n=this._setChartDraw(M,this._linefill);break;case N0.TABLE:n=this._setChartDraw(M,this._table);break}n&&(e[t]=n)}_cacheCopy(e){return typeof e!="object"||!e||e.isDraw?e:b2.cloneDeep(e)}_updateId(e){const{bar_index:t,_isRealTimeBar:r}=this,M=e.id;if(!e._suffix)e._suffix=`_${t}`,e.id=`${e.id}${e._suffix}`;else{const n=e.id.split("_");n.pop(),e.id=`${n.join("_")}_${t}`}return e.line1&&nt.__updateFillKeys(e.line1,M,e.id),e.line2&&nt.__updateFillKeys(e.line2,M,e.id),r||(e.preId=e.id),e.id}_setChartDraw(e,t){const r=t.getInstance(e);let M=t.get(e);if(!M||!r)return;const n=this._updateId(r)||e;return n===e&&!this._isRealTimeBar||(M=JSON.parse(JSON.stringify(M)),this._isRealTimeBar||(r.data=M),t.deleteHandle(e,!1),t.set(n,M,r)),r}_chartDrawsHandle(e,t){if(typeof e!="object")return;const r=t==null?void 0:t.id;let M=e==null?void 0:e.id;M&&e.data&&(e.data.isVar=!0),r!==M&&r&&t.data&&(t.data.isVar=!1)}add(e,t){return Array.isArray(e)&&Array.isArray(t)?b2.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}notEqual(e,t,r,M){return e===void 0&&typeof t=="number"||t===void 0&&typeof e=="number"?!1:!this.equal(e,t,r,M)}equal(e,t,r,M){if(typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t))return!0;if(e!==void 0&&t!==void 0)return e==t;if(e===void 0&&typeof t=="number"||t===void 0&&typeof e=="number")return!1;if(!(r.endsWith(N0.BOOL)&&e===void 0))return(r.endsWith(N0.FLOAT)||r.endsWith(N0.INT)||M.endsWith(N0.FLOAT)||M.endsWith(N0.INT))&&e===void 0&&t===void 0?!1:r.endsWith(N0.STRING)&&e===""&&t===void 0||M.endsWith(N0.STRING)&&t===""&&e===void 0?!0:r.endsWith(N0.NA)&&M.endsWith(N0.NA)?!1:e==t}compareDataHandle(e){if(typeof e!="number"||!e)return e;const t=String(e);if(!t.includes(".")&&!/[eE]/.test(t))return e;const[r,M]=e.toFixed(11).split(".");return+`${r}.${M.slice(0,10)}`}}class Sr{constructor(e,t,r=50){C(this,"_all");C(this,"_allInstance");C(this,"_pseudoArrayAll");C(this,"_maxLength");C(this,"_deleteIds");C(this,"_variables");C(this,"_preDeleteIds");C(this,"_againAddItems");C(this,"_tmpData");C(this,"_tmpInstance");C(this,"_type");C(this,"_tmpIds",[]);this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=p1(0,void 0,t),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}get _cacheData(){return{allInstance:Array.from(this._allInstance),tmpIds:this._tmpIds,preDeleteIds:Array.from(this._preDeleteIds)}}set _cacheData(e){this._allInstance=new Map(e.allInstance),this._all=new Map(e.allInstance.map(([t,r])=>[t,r.data])),this._tmpIds=e.tmpIds,this._preDeleteIds=new Map(e.preDeleteIds)}setMaxLen(e){this._maxLength=e}get size(){return this._all.size+this._tmpData.size}get __allInstance(){return this._allInstance}get data(){const e=[],t=b2.flatMap([...this._deleteIds.values()]),r=b2.uniq([...this._tmpData.keys(),...this._all.keys()]),M=[];for(const n of r)if(!t.some(b=>b.key===n)){const b=this._tmpData.get(n)||this._all.get(n),z=b==null?void 0:b.id;b&&!M.includes(z)&&(M.push(z),e.push(b))}return this._variables._isRealTimeBar&&this._preDeleteIds.set(this._variables.last_bar_index,this._deleteIds.get(this._variables.last_bar_index)||[]),this._tmpDataHandle(),this._type===N0.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!==N0.LINEFILL&&this._all.size>this._maxLength){const{bar_index:M}=t;for(const[n,b]of this._all){const{isVar:z,id:i,bar_index:c}=b;if(c===M)break;if(z)continue;this.deleteHandle(i);break}}}getValOfBarIndex(e){let t=[];const r=b2.uniq([...this._all.keys(),...this._tmpData.keys()]),M=b2.flatMap([...this._deleteIds.values()]);for(const n of e){const b=r.filter(z=>z.endsWith(`_${n}`));for(const z of b){if(M.some(c=>c.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===N0.LINEFILL?t:t.slice(-this._maxLength):void 0}getDeleteIds(e){let t=[];const{bar_index:r,_isRealTimeBar:M}=this._variables,n=[];for(const z of e){let i=[...this._deleteIds.get(z)||[]];const c=this._preDeleteIds.get(z)||[];if(z===r&&M){let O=[];for(const s of c){const u=i.findIndex(l=>l.id===s.id);if(u===-1){const l=this._all.get(s.key);l&&n.push(l)}else O.push(s),i.splice(u,1)}this._preDeleteIds.set(r,b2.uniqBy([...i,...O],"id"))}else{const O=[];for(const s of i)c.some(u=>u.id===s.id)||O.push(s);i=O,this._preDeleteIds.delete(z)}t=t.concat(i)}const b=[...this._all.values(),...this._tmpData.values()];for(const z of this._tmpIds)b.some(i=>i.id===z.id)||t.push(z);return this._againAddItems=n,b2.uniq(t.map(z=>z.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,t=!0,r=!1){var M;if(this._type===N0.LINE&&t){const n=(M=this._allInstance.get(e))==null?void 0:M.fillKeys;if(n&&n.length)for(const b of n)this._variables.linefill.deleteHandle(b)}if(this._variables._isRealTimeBar){if(r){const n=this._tmpInstance.get(e);n&&(n.data=void 0)}this._tmpData.delete(e),this._tmpInstance.delete(e)}else{if(r){const n=this._allInstance.get(e);n&&(n.data=void 0)}this._all.delete(e),this._allInstance.delete(e)}}delete(e,t,r){const M=this._all.get(e);if(this._variables._isRealTimeBar||this.deleteHandle(e,!1,!0),!(this._variables.__isFirstRun&&!this._variables._isRealTimeBar)&&typeof t=="number"){const n=this._deleteIds.get(t)||[];n.push({key:e,id:(M==null?void 0:M.id)||r}),this._deleteIds.set(t,n)}}_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,M){var R;let{symbol:n,timeframe:b,calc_bars_count:z,ignore_invalid_symbol:i,ignore_invalid_timeframe:c}=e;const{__period:O,time:s,_isRealTimeBar:u}=this._variables;b=uM(b);let l=y2(b,s)*1e3;const q=y2(O,s)*1e3;if(l>q)return!c&&this._errorListener.addError(l2(N1.requestLowerTfPeriodErr,{period:b}),t,K0.Error,25),[];const A=`${n}--${b}`,h=self.workerStorage.get(`request_${this._scriptId}_data`),d=self.workerStorage.get(`request_${this._scriptId}_list`),m=self.workerStorage.get(`request_${this._scriptId}_tmp`),_={id:A,calc_bars_count:z,ignore_invalid_symbol:i,symbol:n,originTimeframe:b,timeframe:Ai[b]||Ac(b)};if(h!=null&&h.has(A)){m==null||m.delete(A);const{index:g=0,periodStamp:L=q}=this._cacheData[r]||{},y=h==null?void 0:h.get(A);if(!y.length)return[];if(y.length-1<0)return[];const T=y.slice(g);let N=s,w=L+N;const E=[];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[r]={index:k,periodStamp:L}),E;if(N<=Y&&Y<w){const K=(R=H==null?void 0:H.result)==null?void 0:R[r];if(Array.isArray(K))for(const[e0,b0]of K.entries())E[e0]||(E[e0]=[]),E[e0].push(b0);else M||E.push(K)}}return!u&&(this._cacheData[r]={index:y.length,periodStamp:L}),E}else(d==null?void 0:d.get(A))||m==null||m.set(A,_);d==null||d.set(A,_)}_getRequestData(e,t){var m,_,R,g,L;let{symbol:r,timeframe:M,calc_bars_count:n,gaps:b,lookahead:z,ignore_invalid_symbol:i}=e;const{__period:c,mintick:O,time:s,nextBarTime:u}=this._variables;M=uM(M),r=r;const l=`${r}--${M}`,q=self.workerStorage.get(`request_${this._scriptId}_data`),A=self.workerStorage.get(`request_${this._scriptId}_list`),h=self.workerStorage.get(`request_${this._scriptId}_tmp`),d={id:l,calc_bars_count:n,ignore_invalid_symbol:i,symbol:r,originTimeframe:M,timeframe:Ai[M]||Ac(M)};if(q!=null&&q.has(l)){let y=y2(M,s)*1e3;const D=y2(c,s)*1e3;h==null||h.delete(l);const{index:T=0,periodStamp:N=D}=this._cacheData[t]||{},w=q==null?void 0:q.get(l);if(!w.length)return;const E=w.slice(T);let P=s,H=N+P;const Y=w.length-1;if(Y<0)return;const k={lastBarIndex:w[Y].barindex||Y,lastBarTime:w[Y].time,interval:M,mintick:O};if(y>N){let K;if(z===ke.lookaheadOn?K=this._lookaheadOnHandle(E,M,H,y,k,T,N,t,P,b):K=this._lookaheadOffHandle(E,M,H,y,k,T,N,t,P,u||H,b),K)return K;if(K===null)return}else if(z===ke.lookaheadOn)for(const[K,e0]of E.entries()){let{time:b0,barindex:O0}=e0;b0=b0*1e3;const v0=((m=E[K+1])==null?void 0:m.time)*1e3||b0+y;let B0=T+K;if(b0>=H){this._cacheData[t]={index:B0,periodStamp:N};return}if(b0<=P&&v0>P){const A0=T+K;return this._cacheData[t]={index:A0,periodStamp:N},{...e0,barIndex:O0||A0,nextBarTime:(_=E[K+1])==null?void 0:_.time,...k}}}else for(const[K,e0]of E.entries()){let{time:b0,barindex:O0}=e0;b0=b0*1e3;const v0=((R=E[K+1])==null?void 0:R.time)*1e3||b0+y;let B0=T+K;if(b0>H){this._cacheData[t]={index:B0,periodStamp:N};return}if(b0<H&&H<=v0)return this._cacheData[t]={index:B0,periodStamp:N},{...e0,barIndex:O0||B0,nextBarTime:(g=E[K+1])==null?void 0:g.time,...k};if(b0>=P&&b0<=H&&(O0||B0)===k.lastBarIndex)return this._cacheData[t]={index:B0,periodStamp:N},{...e0,barIndex:O0||B0,nextBarTime:(L=E[K+1])==null?void 0:L.time,...k}}this._cacheData[t]={index:w.length,periodStamp:N};return}else(A==null?void 0:A.get(l))||h==null||h.set(l,d);A==null||A.set(l,d)}_lookaheadOnHandle(e,t,r,M,n,b,z,i,c,O){var s;for(const[u,l]of e.entries()){let{time:q,barindex:A}=l;q=q*1e3,t.includes("M")&&(M=y2(t,q)*1e3-(O1(q).date()-1)*864e5);const h=q,d=M+h;let m=b+u;if(r<=h)return this._cacheData[i]={index:m,periodStamp:z},null;let _={...l,barIndex:A||m,nextBarTime:(s=e[u+1])==null?void 0:s.time,...n};if(O===ke.gapsOn){if(r>h&&c<=h)return this._cacheData[i]={index:m,periodStamp:z},_}else{if(r>d)continue;if(r>h)return this._cacheData[i]={index:m,periodStamp:z},_}}}_lookaheadOffHandle(e,t,r,M,n,b,z,i,c,O,s){var u,l;for(const[q,A]of e.entries()){let{time:h,barindex:d}=A;h=h*1e3,t.includes("M")&&(M=y2(t,h)*1e3-(O1(h).date()-1)*864e5);const m=h,_=M+m,R=b+q;if(r<m)return this._cacheData[i]={index:R,periodStamp:z},null;const g={...A,barIndex:d||R,nextBarTime:(u=e[q+1])==null?void 0:u.time,...n};if(r>=_&&c<_||r<_&&O>=_)return s===ke.gapsOn?(this._cacheData[i]={index:R,periodStamp:z},g):(this._cacheData[i]={index:R,data:g,periodStamp:z},g);if(!(c>_)&&c>=m){let L=(l=this._cacheData[i])==null?void 0:l.data;if(!L){const y=e[R-1];if(!y)return null;L={...y,barIndex:y.barindex||R-1,nextBarTime:g.time,...n},this._cacheData[i]={index:R,data:L,periodStamp:z}}return L}}}_getDependCodes(e,t,r,M,n,b){for(const z of e){if(!z.isArg){const i=t.filter(O=>{var s;return(s=O==null?void 0:O.depends)==null?void 0:s.some(u=>u.name===z.name&&u.scope===z.scope&&u.isAgainAssign!==!1)});for(const O of i){const{code:s,depends:u,scope:l,funcName:q}=O;r[l]=r[l]||[];const A=r[l];let h=l===0&&q;if(!A.includes(s)){if(h){if(M.includes(s))continue;M.unshift(s)}else A.unshift(s);if(u!=null&&u.length){for(const d of u)d.memberCode&&!h&&b.push(d.memberCode);this._getDependCodes(u,t,r,M,n,b)}}}const c=t.find(O=>{var s;return((s=O.varNames)==null?void 0:s.split(", ").includes(z.name))&&(!z.isPreArg||z.isPreArg&&O.methodName===z.functionName)||O.funcName===z.name});if(c){const{code:O,depends:s,scope:u}=c;r[u]=r[u]||[];const l=r[u],q=l.findIndex(A=>A===O);if(q!==-1){if(z.isFunc)continue;l.splice(q,1)}if(l.unshift(O),s!=null&&s.length){for(const A of s)A.memberCode&&b.push(A.memberCode);this._getDependCodes(s,t,r,M,n,b)}continue}}n.some(i=>i.name===z.name)||n.push(z)}}_getStmtFuncs(e,t,r,M,n){const b=t.filter(z=>z.isStmtFunc);for(const z of b){const{code:i,depends:c,scope:O=0}=z;e[O]=e[O]||[];const s=e[O];if(!s.includes(i)&&(s.push(i),c!=null&&c.length)){for(const u of c)u.memberCode&&r.push(u.memberCode);this._getDependCodes(c.filter(u=>!(u.isFunc&&i.startsWith(u.name))),t,e,M,n,r)}}}runScripts(e,t,r,M,n,b){var u,l;const z=`${this._scriptId}_${t}`,i=new _p(z),c=new hp,O=new Wp(this._variables.mintick||1e-5,i,this._scriptId),s=new Function("_$_var","_$_const","_$_func","$paramsExpr","$posStr",e);if(!r){const{varCacheData:q,funcCacheData:A}=n;i.setVarCacheData(q),O.setFuncCacheData(A)}if(i.__requestName=t,M&&M.length){const q=M.length-1,{interval:A,symbol:h=""}=n;let{mintick:d,syminfo:m}=this._variables;const[_,R]=h.split(":");d||(d=Math.pow(10,-(((u=String(M[0].o).split(".")[1])==null?void 0:u.length)||0))),i.updateOptions({interval:A,mintick:d,syminfo:{...m.__syminfo,mintick:d,tickerid:h||m.tickerid,ticker:R||_||m.ticker}});for(const[y,D]of M.entries()){const{barindex:T}=D,N=Object.assign(D,{barIndex:T||y,lastBarIndex:M[q].barindex||q,lastBarTime:M[q].time,nextBarTime:(l=M[y+1])==null?void 0:l.time});if(i.updateData(N),O.update({barIndex:(N==null?void 0:N.barindex)||0}),D.result=Object.assign(D.result||{},{[t]:s(i,c,O,b||[],t)}),O.endExecution(),O.errors.length&&O.errors.some(w=>w.type===K0.Error))return{logs:[],errors:O.errors}}const g=O.log.logs,L=O.errors;return O.log.clearLogs(),O.clearErrors(),{logs:g,errors:L,cacheData:{varCacheData:i.getVarCacheData(),funcCacheData:O.getFuncCacheData()}}}}_runScripts(e,t,r,M,n){const b=`${this._scriptId}_${t}`;let{builtInGather:z,buildinConstants:i,buildInFunctions:c,tradingvueFunc:O}=self.workerStorage.get(b)||{};const{interval:s,...u}=n||{};if(r){z=new _p(b),i=new hp,c=new Wp(this._variables.mintick||1e-5,z,this._scriptId),O=new Function("_$_var","_$_const","_$_func","$paramsExpr","$posStr",e);const{mintick:h,syminfo:d}=this._variables;z.updateOptions({interval:s,mintick:h||1e-5,syminfo:{...d.__syminfo}}),z.__requestName=t,self.workerStorage.set(b,{builtInGather:z,buildinConstants:i,buildInFunctions:c,tradingvueFunc:O})}z.updateData(u),c.update({barIndex:(u==null?void 0:u.barindex)||0});const l=O(z,i,c,M||[],t),q=c.log.logs,A=c.errors;return c.log.clearLogs(),c.clearErrors(),c.endExecution(),{result:l,logs:q,errors:A}}},Fm=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 Im{constructor(e,t){C(this,"_logs");C(this,"_variables");C(this,"_str");C(this,"_preBar",{barIndex:-1,isrealtime:!1});this._variables=e,this._logs=[],this._str=t}get _logCacheData(){return this._preBar}set _logCacheData(e){this._preBar=e}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,M){if(typeof t=="string"&&(M=t),M.startsWith("export"))return;const{message:n,formatString:b}=e,{time:z,bar_index:i,_isRealTimeBar:c,__isReqRepeated:O}=this._variables;let s=n;b&&Array.isArray(t)&&t.length&&(t=t.map(A=>{if(typeof A=="object"){if(A===null)return"null";A!=null&&A.isArray?A=`[${A._value.toString()}]`:A=A.toString()}return A!==void 0?A:"na"}),s=this._str.strformat({formatString:b},t,!0));const{isrealtime:u,barIndex:l}=this._preBar;i!==l&&(this._preBar={barIndex:i,isrealtime:c});const q=Date.now();s!==void 0&&this._logs.push({message:`[${O1(u&&!O?q:z).format("YYYY-MM-DDTHH:mm:ss.SSSZ")}]: ${s}`,time:z,id:K4(6),barIndex:i,type:r})}}class Pm{constructor(e){C(this,"_errorListener");this._errorListener=e}error({message:e},t){t.startsWith("export")||this._errorListener.addError(e,t,K0.Error)}}class km{constructor(){C(this,"_errors");this._errors=new Map}clear(){this._errors.clear()}get errors(){return b2.flatMap([...this._errors.values()])}setErrors(e,t){this._errors.set(t,e)}addError(e,t,r,M=0){const[n,b]=t.split("_").slice(-2),z=this._errors.get(t),i={message:e,endLineNumber:Number(n),startColumn:Number(b)+1,endColumn:Number(b)+M+1,startLineNumber:Number(n),type:r};z?z.push(i):this._errors.set(t,[i])}}class $m{constructor(){C(this,"_isMarketOpen");C(this,"_currentBarIndex");C(this,"_totalBarIndex");C(this,"_isRealTimeBar");C(this,"_preBarIndex");C(this,"_preIsRealTimeBar");C(this,"_isFirstRun",!1);this._currentBarIndex=0,this._totalBarIndex=0,this._isRealTimeBar=!1,this._preBarIndex=0,this._isMarketOpen=!0,this._preIsRealTimeBar=!1}update(e,t,r,M){this._preBarIndex=this._currentBarIndex,this._preIsRealTimeBar=this._isRealTimeBar,this._currentBarIndex=e,this._totalBarIndex=t,this._isRealTimeBar=r,this._isMarketOpen=M}get _barstateCacheData(){return{currentBarIndex:this._currentBarIndex,isRealTimeBar:this._isRealTimeBar}}set _barstateCacheData(e){this._currentBarIndex=e.currentBarIndex,this._isRealTimeBar=e.isRealTimeBar}set isFirstRun(e){this._isFirstRun=e}get isnew(){return this._preBarIndex!==this._currentBarIndex}get islast(){return this._currentBarIndex===this._totalBarIndex||!this._isFirstRun}get isfirst(){return this._currentBarIndex===0}get ishistory(){return!this._isRealTimeBar||this._isFirstRun}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 Um{constructor(e){C(this,"_variables");this._variables=e}get isfirstbar(){return this._variables.timeframe.isdwm?!0:this._variables.time===this._variables.time_tradingday||this._variables.bar_index===0}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 jm{constructor(e){C(this,"_orders");C(this,"_historyOrders");C(this,"_options");C(this,"_max_contracts_held_all",0);C(this,"_max_contracts_held_long",0);C(this,"_max_contracts_held_short",0);C(this,"_max_drawdown",0);C(this,"_max_runup",0);C(this,"_max_runup_percent",0);C(this,"_max_drawdown_percent",0);C(this,"_variables");C(this,"_netprofit",0);C(this,"_eventrades",0);C(this,"_avg_trade_percent");C(this,"_avg_losing_trade_percent");C(this,"_avg_winning_trade_percent");C(this,"_closedtrades",0);C(this,"_losstrades",0);C(this,"_grossloss",0);C(this,"_grossprofit",0);C(this,"_wintrades",0);C(this,"_opentrades_capital_held",0);C(this,"_position_avg_price",0);C(this,"_position_size",0);C(this,"_openprofit",0);C(this,"_preMaxNetValue",0);C(this,"_preMinNetValue",0);C(this,"marginCallLong",0);C(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:M,low:n,close:b}=e;let z=0;for(const[O,s]of this._orders.entries()){const{in_price:u,qty:l=0,direction:q,commission:A,original_qty:h=1}=s,d=q===a1.long?1:-1,m=(M-u)*l,_=(n-u)*l,R=d===1?m:-_,g=d===1?-_:m;z+=(b-u)*d*l,t+=g,O>0&&A&&(r-=A*l/h),r+=R}this._openprofit=z;const i=this.initial_capital,c=i+this._netprofit;this._preMinNetValue=this._preMinNetValue||i,this._preMaxNetValue=this._preMaxNetValue||i,t=this._preMaxNetValue-c+Math.max(t,0),r=c-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(){if(!this._orders.length){this._position_size=0,this._position_avg_price=void 0,this._opentrades_capital_held=0;return}const[t,r,M,n,b,z]=this._orders.reduce(([i,c,O,s,u,l],q)=>{const{direction:A,qty:h=0,in_price:d,commission:m=0}=q;return A===a1.long?(i+=h,c+=h,u+=h):(i+=h,O+=h,u-=h),s+=h*d,l+=m,[i,c,O,s,u,l]},[0,0,0,0,0,0]);this._historyOrders.length||(this._netprofit=-z,this._grossloss=z),this._position_size=b,this._position_avg_price=n/t,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(M,this._max_contracts_held_short)}updateHistoryOrders(e){this._historyOrders=e;const t=this._historyOrders.length;this._closedtrades=t;const[r,M,n,b,z,i,c,O]=this._historyOrders.reduce((l,q)=>{let[A,h,d,m,_,R,g,L]=l;const{profit:y=0,profit_percent:D=0}=q;return A+=y,h+=D,y<0?(d+=y,m+=D,g+=1):y>0&&(_+=y,R+=D,L+=1),[A,h,d,m,_,R,g,L]},[0,0,0,0,0,0,0,0]),s=this._orders.reduce((l,q)=>{const{commission:A=0,qty:h=0,original_qty:d=0}=q,m=A*h/d;return l+m},0);this._avg_trade_percent=t?M/t:void 0,this._avg_losing_trade_percent=t?Math.abs(b)/c:void 0,this._avg_winning_trade_percent=t?i/O:void 0,this._netprofit=r-s;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-s),this._grossprofit=z,this._eventrades=t-c-O,this._losstrades=c,this._wintrades=O}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:M,commission_value:n=0}=this._options,b=this._orders[0].direction===a1.long?1:-1,z=(b===1?t:r)/100;if(z<=0)return;const{close:i}=this._variables,[c,O]=this._orders.reduce((s,u)=>{let[l,q]=s;const{in_price:A,qty:h=0,original_qty:d=0}=u,m=A*h;if(l+=m,n){let _=0;switch(M){case O2.percent:_=(m+h*i)*n/100;break;case O2.cashPerContract:_=h*n*2;break;case O2.cashPerOrder:_=h/d*n+n;break}q+=_}return[l,q]},[0,0]);return(c-(e+this._netprofit-O))*b/this._position_size/(1-b*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:M}=this._options,n=e*t;let b=0;switch(M){case O2.percent:b=n*r/100;break;case O2.cashPerContract:b=t*r;break;case O2.cashPerOrder:b=r;break}return b}}class Hm{constructor(e){C(this,"_preAccdist");C(this,"_preNvi");C(this,"_prePvi");C(this,"_preObv");C(this,"_prePvt");C(this,"_preWad");C(this,"_preVwap");C(this,"_preValue");C(this,"_currentData");C(this,"_preData");C(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}get _varTaCacheData(){return{preAccdist:this._preAccdist,preNvi:this._preNvi,prePvi:this._prePvi,preObv:this._preObv,prePvt:this._prePvt,preWad:this._preWad,preVwap:this._preVwap,currentData:this._currentData,preData:this._preData}}set _varTaCacheData(e){const{preAccdist:t,preNvi:r,prePvi:M,preObv:n,prePvt:b,preWad:z,preVwap:i,currentData:c,preData:O}=e;this._preAccdist=t,this._preNvi=r,this._prePvi=M,this._preObv=n,this._prePvt=b,this._preWad=z,this._preVwap=i,this._currentData=c,this._preData=O}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:M}=this._currentData;if(r===t)return this._preAccdist;const n=(e-t-(r-e))/(r-t)*M+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:M}=this._currentData,n=(2*e-r-t)/((r-t)*M);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:M,open:n}=this._currentData,b=(e-n)/(r-t)*M;return this._preValue.wvad=b,b}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 M=Math.sign(e-r)*t+this._preObv;return!this.isRealTime&&(this._preObv=M),this._preValue.obv=M,M}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 M=Math.max(t-e,Math.abs(t-r),Math.abs(e-r));return this._preValue.tr=M,M}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 M=(e-r)/r*t+this._prePvt;return!this.isRealTime&&(this._prePvt=M),this._preValue.pvt=M,M}get wad(){if(this._preValue.wad)return this._preValue.wad;const{close:e,high:t,low:r}=this._currentData,{close:M}=this._preData;if(M===void 0)return this._preWad=0,0;const n=Math.max(t,M),b=Math.min(r,M),z=e-M,c=(z>0?e-b:z<0?e-n:0)+this._preWad;return!this.isRealTime&&(this._preWad=c),this._preValue.wad=c,c}get vwap(){var O,s;if(this._preValue.vwap)return this._preValue.vwap;const{hlc3:e,volume:t}=this._currentData;let{sum:r=0,sumV:M=0,isReset:n}=this._preVwap;if(((s=(O=self.workerStorage)==null?void 0:O.get(this._id))==null?void 0:s.buildInFunctions.timeframe.change({timeframe:"1D"},"vwap_buildin"))&&(n=!0,r=M=0),!n)return;const z=e*t+r,i=t+M;!this.isRealTime&&(this._preVwap={sum:z,sumV:i,isReset:n});const c=z/i;return this._preValue.vwap=c,c}_getNvi(){const e=this._preNvi||1,{close:t=0,volume:r=0}=this._preData,{close:M,volume:n}=this._currentData;let b=1;const z=e||1;return M&&t?b=n<r?z+(M-t)/t*z:z:b=z,!this.isRealTime&&(this._preNvi=b),this._preValue.nvi=b,b}_getPvi(){const e=this._prePvi||1,{close:t=0,volume:r=0}=this._preData,{close:M,volume:n}=this._currentData;let b=1;const z=e||1;return M&&t?b=n>r?z+(M-t)/t*z:z:b=z,!this.isRealTime&&(this._prePvi=b),this._preValue.pvi=b,b}}class Ym{constructor(){C(this,"_period");C(this,"_multiplier");C(this,"_unit");this._period="1",this._multiplier=1,this._unit="m"}update(e){if(!e)return;this._period=e;const[t,r]=ht(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 Gm{constructor(){C(this,"_bgColor");C(this,"_fgColor");C(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,M,n;if(e.startsWith("#")){t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),M=parseInt(e.substring(5,7),16);const b=e.substring(7);b?n=parseInt(b,16)/255:n=1}else{const b=this._parserRgbColor(e);t=b[0]||0,r=b[1]||0,M=b[2]||0,n=b[3]||1}return{r:t,g:r,b:M,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:M}=this._parseColor(e);return(299*t+587*r+114*M)/1e3>128?"#000000":"#ffffff"}}class Vm{constructor(){C(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||ft.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||"forex"}get volumetype(){return this._syminfo.volumetype||"n/a"}}class Km{constructor(e){C(this,"_variables");this._variables=e}get future_amount(){}get future_ex_date(){}get future_pay_date(){}}class Jm{constructor(e){C(this,"_variables");this._variables=e}get future_eps(){}get future_period_end_time(){}get future_revenue(){}get future_time(){}}class _p{constructor(e){C(this,"_cacheData");C(this,"_barIndex");C(this,"_isRealTimeBar");C(this,"_barstate");C(this,"_priceVariables");C(this,"_lastBarIndex");C(this,"_currentBarTime");C(this,"_lastBarTime");C(this,"_period");C(this,"_offsetTime");C(this,"_timeframe");C(this,"_ta");C(this,"_polyline");C(this,"_label");C(this,"_line");C(this,"_linefill");C(this,"_box");C(this,"_table");C(this,"_strategy");C(this,"_session");C(this,"syminfo");C(this,"chart");C(this,"earnings");C(this,"dividends");C(this,"_timeTradingday");C(this,"_mintick");C(this,"_cacheSpace");C(this,"_precision");C(this,"_nextBarTime");C(this,"_isRepeated");C(this,"_preCacheData");C(this,"__requestName","");C(this,"__isFirstRun",!1);C(this,"_maxBarsBack",0);C(this,"_maxBarsBackOfKey");C(this,"__isReqRepeated");C(this,"_newCacheData",{});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 $m,this._timeframe=new Ym,this._priceVariables={close:0,open:0,low:0,high:0,volume:0},this._ta=new Hm(e),this._polyline=new Sr(this,N0.POLYLINE),this._label=new Sr(this,N0.LABEL),this._line=new Sr(this,N0.LINE),this._linefill=new Sr(this,N0.LINEFILL),this._box=new Sr(this,N0.BOX),this._table=new Sr(this,N0.TABLE),this._strategy=new jm(this),this._session=new Um(this),this.syminfo=new Vm,this.chart=new Gm,this.earnings=new Jm(this),this.dividends=new Km(this),this._cacheSpace=Object.create(null),this._maxBarsBackOfKey=Object.create(null)}getVarCacheData(){return{cacheData:this._cacheData,preCacheData:this._preCacheData,cacheSpace:this._cacheSpace,taCacheData:this._ta._varTaCacheData,polylineCacheData:this._polyline._cacheData,labelCacheData:this._label._cacheData,lineCacheData:this._line._cacheData,linefillCacheData:this._linefill._cacheData,boxCacheData:this._box._cacheData,tableCacheData:this._table._cacheData,barstateCacheData:this.barstate._barstateCacheData}}setVarCacheData(e){if(!e)return;const{cacheData:t,preCacheData:r,cacheSpace:M,taCacheData:n,polylineCacheData:b,labelCacheData:z,lineCacheData:i,linefillCacheData:c,boxCacheData:O,tableCacheData:s,barstateCacheData:u}=e;this._cacheData=t,this._preCacheData=r,this._cacheSpace=M,this._ta._varTaCacheData=n,this._polyline._cacheData=b,this._label._cacheData=z,this._line._cacheData=i,this._linefill._cacheData=c,this._box._cacheData=O,this._table._cacheData=s,this.barstate._barstateCacheData=u}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:M}=this._priceVariables;return(e+t+r+M)/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 O1(this._currentBarTime).hour()}get minute(){return O1(this._currentBarTime).minute()}get second(){return O1(this._currentBarTime).second()}get month(){return O1(this._currentBarTime).month()+1}get year(){return O1(this._currentBarTime).year()}get dayofweek(){return O1(this.time_tradingday).weekday()}get dayofmonth(){return O1(this.time_tradingday).date()}get weekofyear(){return O1(this._currentBarTime).week()}get last_bar_time(){return this._lastBarTime}get time(){return this._currentBarTime}get time_close(){const[e,t]=ht(this._period);return O1(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}set max_bars_back(e){this._maxBarsBack=e}updateMaxLength(e){const{max_lines_count:t,max_labels_count:r,max_boxes_count:M,max_polylines_count:n}=e;M&&this._box.setMaxLen(M),r&&this._label.setMaxLen(r),t&&this._line.setMaxLen(t),n&&this._polyline.setMaxLen(n)}getTimeTradingday(e,t){const[r,M]=ht(t),n=O1(e);return["M","w","y","d"].includes(M)?n.valueOf():(n.subtract(this._offsetTime,"h"),n.startOf("d").add(this._offsetTime,"h").valueOf())}_getTimeTradingday(e,t){const[r,M]=ht(t),n=O1(e).utc(!0);return["M","w","y","d"].includes(M)?n.valueOf():n.startOf("d").valueOf()}updateOptions(e){var c;const{interval:t="1D",offsetTime:r=5,mintick:M,chart:n,syminfo:b}=e,z=((c=M.toString().split(".")[1])==null?void 0:c.length)||5;this._precision=z;const i=Q4(t);this._period=i,this._mintick=M,this._offsetTime=r,this._timeframe.update(i),this.chart.updateOptions(n),this.syminfo.update(b),this._barstate.isFirstRun=this.__isFirstRun}updateData(e,t){const{barIndex:r,c:M,o:n,h:b,l:z,volume:i,time:c,lastBarIndex:O,lastBarTime:s,isrealtime:u,time_tradingday:l,nextBarTime:q}=e;if(this._priceVariables={close:rn(M,this._precision),open:rn(n,this._precision),high:rn(b,this._precision),low:rn(z,this._precision),volume:Number(i)},this._isRealTimeBar=u,this._newCacheData={},r>this._barIndex){const{varData:A,varipData:h}=this._cacheData;this._preCacheData={varData:{},varipData:{}},u?(this._preCacheData.varData=b2.cloneDeep(A),this._preCacheData.varipData=b2.cloneDeep(h)):this._preCacheData={varData:{...A},varipData:{...h}}}this._isRepeated=t,this._timeTradingday=l,this._currentBarTime=c*1e3,this._lastBarIndex=O,this._barIndex=r,this._lastBarTime=s*1e3,this._nextBarTime=q*1e3,this._barstate.update(r,O,u,!0),this.ta.update({...this._priceVariables,hlc3:this.hlc3,barIndex:r})}getCacheData(e,t,r){var b;let M=(b=this._cacheData[e])==null?void 0:b.data;M||(M=this.setCacheData(e,r));const n=this._cacheSpace[e]||0;return t=Math.floor(t),n<t&&(this._cacheSpace[e]=t),M[M.length-1-t]}setCacheData(e,t){let r=this._cacheData[e]||{barIndex:-1,data:[]};if(r.barIndex>this._barIndex)return r.data;t=this._cacheCopy(t),r.barIndex===this._barIndex?r.data[r.data.length-1]=t:r.data.push(t);const M=this._cacheSpace[e]||0,n=ui.includes(e)?500:50;return M&&r.data.length>(this._maxBarsBackOfKey[e]||this._maxBarsBack||M+n)&&r.data.shift(),r.barIndex=this._barIndex,this._cacheData[e]=r,r.data}__setBarsBackOfKey(e,t){this._maxBarsBackOfKey[e]=t}__getBarsBackOfKey(e){return this._maxBarsBackOfKey[e]}getTypeInstance(e,t,r){return new Oi(e,t,r)}verifyVarAndVarip(e,t,r){const M=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`,n=this._isRepeated||this.__isReqRepeated?this._preCacheData:this._cacheData;if(r==="var"&&n.varData.hasOwnProperty(M))return this._upadteChartDraws(n.varData,M),!0;const b=this.__isReqRepeated?this._preCacheData.varipData:this._cacheData.varipData;return r==="varip"&&b.hasOwnProperty(M)?(this._upadteChartDraws(b,M),!0):!1}getVarValue(e,t,r){const M=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`;(this._isRepeated||this.__isReqRepeated)&&(this._cacheData.varData[M]=this._preCacheData.varData[M],this.__isReqRepeated&&(this._cacheData.varipData[M]=this._preCacheData.varipData[M]));const n=this._cacheData;if(r==="var"){const b=n.varData[M];return this._isRealTimeBar?this._newCacheData.hasOwnProperty(M)?this._newCacheData[M]:this._cacheCopy(b):b}return this._cacheData.varipData[M]}setVarValue(e,t,r,M){var z;const n=`${e}_${t.replace(/\$[\d]+_\$/g,"")}`;let b;switch(typeof r=="object"&&((z=r==null?void 0:r.varipKeys)!=null&&z.length)&&M!=="varip"&&(M="var",b=r.varipKeys),M){case"var":if(this._isRealTimeBar){if(b&&b.length)for(const i of b)this._cacheData.varData[n][i]=r[i];this._newCacheData[n]=r}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,t){const r=e[t],M=this._isRealTimeBar?r==null?void 0:r.preId:r==null?void 0:r.id;if(!M)return;let n;switch(r==null?void 0:r.type){case N0.BOX:n=this._setChartDraw(M,this._box);break;case N0.LINE:n=this._setChartDraw(M,this._line);break;case N0.POLYLINE:n=this._setChartDraw(M,this._polyline);break;case N0.LABEL:n=this._setChartDraw(M,this._label);break;case N0.LINEFILL:n=this._setChartDraw(M,this._linefill);break;case N0.TABLE:n=this._setChartDraw(M,this._table);break}n&&(e[t]=n)}_cacheCopy(e){return typeof e!="object"||!e||e.isDraw?e:b2.cloneDeep(e)}_updateId(e){const{bar_index:t,_isRealTimeBar:r}=this,M=e.id;if(!e._suffix)e._suffix=`_${t}`,e.id=`${e.id}${e._suffix}`;else{const n=e.id.split("_");n.pop(),e.id=`${n.join("_")}_${t}`}return e.line1&&nt.__updateFillKeys(e.line1,M,e.id),e.line2&&nt.__updateFillKeys(e.line2,M,e.id),r||(e.preId=e.id),e.id}_setChartDraw(e,t){const r=t.getInstance(e);let M=t.get(e);if(!M||!r)return;const n=this._updateId(r)||e;return n===e&&!this._isRealTimeBar||(M=JSON.parse(JSON.stringify(M)),this._isRealTimeBar||(r.data=M),t.deleteHandle(e,!1),t.set(n,M,r)),r}_chartDrawsHandle(e,t){if(typeof e!="object")return;const r=t==null?void 0:t.id;let M=e==null?void 0:e.id;M&&e.data&&(e.data.isVar=!0),r!==M&&r&&t.data&&(t.data.isVar=!1)}add(e,t){return Array.isArray(e)&&Array.isArray(t)?b2.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}notEqual(e,t,r,M){return e===void 0&&typeof t=="number"||t===void 0&&typeof e=="number"?!1:!this.equal(e,t,r,M)}equal(e,t,r,M){if(typeof e=="number"&&typeof t=="number"&&isNaN(e)&&isNaN(t))return!0;if(e!==void 0&&t!==void 0)return e==t;if(e===void 0&&typeof t=="number"||t===void 0&&typeof e=="number")return!1;if(!(r.endsWith(N0.BOOL)&&e===void 0))return(r.endsWith(N0.FLOAT)||r.endsWith(N0.INT)||M.endsWith(N0.FLOAT)||M.endsWith(N0.INT))&&e===void 0&&t===void 0?!1:r.endsWith(N0.STRING)&&e===""&&t===void 0||M.endsWith(N0.STRING)&&t===""&&e===void 0?!0:r.endsWith(N0.NA)&&M.endsWith(N0.NA)?!1:e==t}compareDataHandle(e){if(typeof e!="number"||!e)return e;const t=String(e);if(!t.includes(".")&&!/[eE]/.test(t))return e;const[r,M]=e.toFixed(11).split(".");return+`${r}.${M.slice(0,10)}`}}class Sr{constructor(e,t,r=50){C(this,"_all");C(this,"_allInstance");C(this,"_pseudoArrayAll");C(this,"_maxLength");C(this,"_deleteIds");C(this,"_variables");C(this,"_preDeleteIds");C(this,"_againAddItems");C(this,"_tmpData");C(this,"_tmpInstance");C(this,"_type");C(this,"_tmpIds",[]);this._all=new Map,this._allInstance=new Map,this._pseudoArrayAll=p1(0,void 0,t),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}get _cacheData(){return{allInstance:Array.from(this._allInstance),tmpIds:this._tmpIds,preDeleteIds:Array.from(this._preDeleteIds)}}set _cacheData(e){this._allInstance=new Map(e.allInstance),this._all=new Map(e.allInstance.map(([t,r])=>[t,r.data])),this._tmpIds=e.tmpIds,this._preDeleteIds=new Map(e.preDeleteIds)}setMaxLen(e){this._maxLength=e}get size(){return this._all.size+this._tmpData.size}get __allInstance(){return this._allInstance}get data(){const e=[],t=b2.flatMap([...this._deleteIds.values()]),r=b2.uniq([...this._tmpData.keys(),...this._all.keys()]),M=[];for(const n of r)if(!t.some(b=>b.key===n)){const b=this._tmpData.get(n)||this._all.get(n),z=b==null?void 0:b.id;b&&!M.includes(z)&&(M.push(z),e.push(b))}return this._variables._isRealTimeBar&&this._preDeleteIds.set(this._variables.last_bar_index,this._deleteIds.get(this._variables.last_bar_index)||[]),this._tmpDataHandle(),this._type===N0.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!==N0.LINEFILL&&this._all.size>this._maxLength){const{bar_index:M}=t;for(const[n,b]of this._all){const{isVar:z,id:i,bar_index:c}=b;if(c===M)break;if(z)continue;this.deleteHandle(i);break}}}getValOfBarIndex(e){let t=[];const r=b2.uniq([...this._all.keys(),...this._tmpData.keys()]),M=b2.flatMap([...this._deleteIds.values()]);for(const n of e){const b=r.filter(z=>z.endsWith(`_${n}`));for(const z of b){if(M.some(c=>c.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===N0.LINEFILL?t:t.slice(-this._maxLength):void 0}getDeleteIds(e){let t=[];const{bar_index:r,_isRealTimeBar:M}=this._variables,n=[];for(const z of e){let i=[...this._deleteIds.get(z)||[]];const c=this._preDeleteIds.get(z)||[];if(z===r&&M){let O=[];for(const s of c){const u=i.findIndex(l=>l.id===s.id);if(u===-1){const l=this._all.get(s.key);l&&n.push(l)}else O.push(s),i.splice(u,1)}this._preDeleteIds.set(r,b2.uniqBy([...i,...O],"id"))}else{const O=[];for(const s of i)c.some(u=>u.id===s.id)||O.push(s);i=O,this._preDeleteIds.delete(z)}t=t.concat(i)}const b=[...this._all.values(),...this._tmpData.values()];for(const z of this._tmpIds)b.some(i=>i.id===z.id)||t.push(z);return this._againAddItems=n,b2.uniq(t.map(z=>z.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,t=!0,r=!1){var M;if(this._type===N0.LINE&&t){const n=(M=this._allInstance.get(e))==null?void 0:M.fillKeys;if(n&&n.length)for(const b of n)this._variables.linefill.deleteHandle(b)}if(this._variables._isRealTimeBar){if(r){const n=this._tmpInstance.get(e);n&&(n.data=void 0)}this._tmpData.delete(e),this._tmpInstance.delete(e)}else{if(r){const n=this._allInstance.get(e);n&&(n.data=void 0)}this._all.delete(e),this._allInstance.delete(e)}}delete(e,t,r){const M=this._all.get(e);if(this._variables._isRealTimeBar||this.deleteHandle(e,!1,!0),!(this._variables.__isFirstRun&&!this._variables._isRealTimeBar)&&typeof t=="number"){const n=this._deleteIds.get(t)||[];n.push({key:e,id:(M==null?void 0:M.id)||r}),this._deleteIds.set(t,n)}}_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
|
@@ -69153,14 +69153,14 @@ function br(a, s, r) {
|
|
69153
69153
|
function zw() {
|
69154
69154
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
69155
69155
|
}
|
69156
|
-
const Sd = new Worker(new URL("" + new URL("assets/scriptsRunWorker-
|
69156
|
+
const Sd = new Worker(new URL("" + new URL("assets/scriptsRunWorker-Bj5i72x4.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
|
69157
69157
|
Sd.onerror = (a) => {
|
69158
69158
|
console.error(a);
|
69159
69159
|
};
|
69160
69160
|
async function Nd(a) {
|
69161
69161
|
return await wn.setInlayHints(a);
|
69162
69162
|
}
|
69163
|
-
const zd = xo(Sd), Ed = xo(new Worker(new URL("" + new URL("assets/parserTccWorker-
|
69163
|
+
const zd = xo(Sd), Ed = xo(new Worker(new URL("" + new URL("assets/parserTccWorker-CG4IgAww.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
|
69164
69164
|
async function Ew(a, s = !1) {
|
69165
69165
|
const { functions: r, types: n, constants: o, variables: l, methods: c } = dt;
|
69166
69166
|
return await Ed.parseTcc(a, s, ho(Nd), { functions: Object.fromEntries(r), methods: Object.fromEntries(c), types: Object.fromEntries(n), constants: Object.fromEntries(o), variables: Object.fromEntries(l) });
|
@@ -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 sl=Symbol("Comlink.proxy"),Im=Symbol("Comlink.endpoint"),Am=Symbol("Comlink.releaseProxy"),Bn=Symbol("Comlink.finalizer"),ba=Symbol("Comlink.thrown"),rl=a=>typeof a=="object"&&a!==null||typeof a=="function",qm={canHandle:a=>rl(a)&&a[sl],serialize(a){const{port1:s,port2:r}=new MessageChannel;return nl(a,s),[r,[r]]},deserialize(a){return a.start(),Un(a)}},Cm={canHandle:a=>rl(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}},al=new Map([["proxy",qm],["throw",Cm]]);function Sm(a,s){for(const r of a)if(s===r||r==="*"||r instanceof RegExp&&r.test(s))return!0;return!1}function nl(a,s=globalThis,r=["*"]){s.addEventListener("message",function n(o){if(!o||!o.data)return;if(!Sm(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;nl(a,D),_=Mm(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),il(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 zm(a){return a.constructor.name==="MessagePort"}function il(a){zm(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 ol(a){return Hs(a,{type:"RELEASE"}).then(()=>{il(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&&ol(a)});function Nm(a,s){const r=(ha.get(s)||0)+1;ha.set(s,r),wa&&wa.register(a,s,a)}function Em(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===Am)return()=>{Em(o),ol(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===Im)return Hs(a,{type:"ENDPOINT"}).then(Is);if(m==="bind")return $n(a,s.slice(0,-1));const[_,g]=ll(u);return Hs(a,{type:"APPLY",path:s.map(x=>x.toString()),argumentList:_},g).then(Is)},construct(l,c){xa(n);const[u,m]=ll(c);return Hs(a,{type:"CONSTRUCT",path:s.map(_=>_.toString()),argumentList:u},m).then(Is)}});return Nm(o,a),o}function Lm(a){return Array.prototype.concat.apply([],a)}function ll(a){const s=a.map(va);return[s.map(r=>r[0]),Lm(s.map(r=>r[1]))]}const cl=new WeakMap;function Mm(a,s){return cl.set(a,s),a}function Kn(a){return Object.assign(a,{[sl]:!0})}function va(a){for(const[s,r]of al)if(r.canHandle(a)){const[n,o]=r.serialize(a);return[{type:"HANDLER",name:s,value:n},o]}return[{type:"RAW",value:a},cl.get(a)||[]]}function Is(a){switch(a.type){case"HANDLER":return al.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Hs(a,s,r){return new Promise(n=>{const o=Om();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 Om(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const pl=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-BalIXgQp.js").href:new URL("assets/scriptsRunWorker-BalIXgQp.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.packages.mjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});pl.onerror=a=>{console.error(a)};async function dl(a){return await _a.setInlayHints(a)}const ul=Un(pl),ml=Un(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-DpzZZ5qa.js").href:new URL("assets/parserTccWorker-DpzZZ5qa.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.packages.mjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function yl(a,s=!1){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ml.parseTcc(a,s,Kn(dl),{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){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ml.parseLibraryCode(a,s,Kn(dl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Rm(a,s,r=!0){return await ul.runScript(a,s,r)}async function Fm(a){return await ul.removeScript(a)}function Bm(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:Um,forEach:$m}=[];function Km(a){return $m.call(Um.call(arguments,1),s=>{if(s)for(const r in s)a[r]===void 0&&(a[r]=s[r])}),a}const _l=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,jm=(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(!_l.test(n.domain))throw new TypeError("option domain is invalid");l+=`; Domain=${n.domain}`}if(n.path){if(!_l.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},fl={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=jm(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 Hm={name:"cookie",lookup(a){let{lookupCookie:s}=a;if(s&&typeof document<"u")return fl.read(s)||void 0},cacheUserLanguage(a,s){let{lookupCookie:r,cookieMinutes:n,cookieDomain:o,cookieOptions:l}=s;r&&typeof document<"u"&&fl.create(r,a,n,o,l)}},Wm={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 gl=()=>{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 Vm={name:"localStorage",lookup(a){let{lookupLocalStorage:s}=a;if(s&&gl())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupLocalStorage:r}=s;r&&gl()&&window.localStorage.setItem(r,a)}};let Sr=null;const bl=()=>{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 Gm={name:"sessionStorage",lookup(a){let{lookupSessionStorage:s}=a;if(s&&bl())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupSessionStorage:r}=s;r&&bl()&&window.sessionStorage.setItem(r,a)}},Xm={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}},Ym={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}},Qm={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}},Zm={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 Jm(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:a=>a}}class xl{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=Km(r,this.options||{},Jm()),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(Hm),this.addDetector(Wm),this.addDetector(Vm),this.addDetector(Gm),this.addDetector(Xm),this.addDetector(Ym),this.addDetector(Qm),this.addDetector(Zm)}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)}))}}xl.type="languageDetector";const ey=(...a)=>{console!=null&&console.warn&&(As(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),console.warn(...a))},hl={},jn=(...a)=>{As(a[0])&&hl[a[0]]||(As(a[0])&&(hl[a[0]]=new Date),ey(...a))},wl=(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,wl(a,r))},vl=(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,wl(a,n))},ty=(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",sy=a=>typeof a=="object"&&a!==null,ry=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ay={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ny=a=>ay[a];let Wn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:a=>a.replace(ry,ny)};const iy=(a={})=>{Wn={...Wn,...a}},oy=()=>Wn;let Tl;const ly=a=>{Tl=a},cy=()=>Tl,py={type:"3rdParty",init(a){iy(a.options.react),ly(a)}},dy=N.createContext();class uy{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const my=(a,s)=>{const r=N.useRef();return N.useEffect(()=>{r.current=s?r.current:a},[a,s]),r.current},kl=(a,s,r,n)=>a.getFixedT(s,r,n),yy=(a,s,r,n)=>N.useCallback(kl(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(dy)||{},l=r||n||cy();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new uy),!l){jn("You will need to pass in an i18next instance by using initReactI18next");const V=(A,L)=>As(L)?L:sy(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={...oy(),...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=>ty(V,l,c)),x=yy(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),h=()=>x,D=()=>kl(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=my(U),H=N.useRef(!0);N.useEffect(()=>{const{bindI18n:V,bindI18nStore:q}=c;H.current=!0,!g&&!u&&(s.lng?vl(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?vl(l,s.lng,_,()=>V()):Hn(l,_,()=>V())})},_y={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"},fy={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(xl).use(py).init({debug:!1,fallbackLng:"zh",interpolation:{escapeValue:!1},resources:{en:{translation:_y},zh:{translation:fy}}}),self.MonacoEnvironment={getWorker(){return new Bm({name:"Editor Worker"})}},In.config({paths:{vs:"https://my.tradingvue.com/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const gy=(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 Dm(A,L,D),x&&((ee=K.current)==null||ee.addLinkOpenFunc(x)),c&&((ne=K.current)==null||ne.addDiffDecorations()),Xu(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 yl(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(()=>Zu.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(yu,{height:r,width:n||"100%",defaultLanguage:Ke,defaultValue:m||`indicator("我的脚本")
|
144
|
+
*/const sl=Symbol("Comlink.proxy"),Im=Symbol("Comlink.endpoint"),Am=Symbol("Comlink.releaseProxy"),Bn=Symbol("Comlink.finalizer"),ba=Symbol("Comlink.thrown"),rl=a=>typeof a=="object"&&a!==null||typeof a=="function",qm={canHandle:a=>rl(a)&&a[sl],serialize(a){const{port1:s,port2:r}=new MessageChannel;return nl(a,s),[r,[r]]},deserialize(a){return a.start(),Un(a)}},Cm={canHandle:a=>rl(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}},al=new Map([["proxy",qm],["throw",Cm]]);function Sm(a,s){for(const r of a)if(s===r||r==="*"||r instanceof RegExp&&r.test(s))return!0;return!1}function nl(a,s=globalThis,r=["*"]){s.addEventListener("message",function n(o){if(!o||!o.data)return;if(!Sm(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;nl(a,D),_=Mm(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),il(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 zm(a){return a.constructor.name==="MessagePort"}function il(a){zm(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 ol(a){return Hs(a,{type:"RELEASE"}).then(()=>{il(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&&ol(a)});function Nm(a,s){const r=(ha.get(s)||0)+1;ha.set(s,r),wa&&wa.register(a,s,a)}function Em(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===Am)return()=>{Em(o),ol(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===Im)return Hs(a,{type:"ENDPOINT"}).then(Is);if(m==="bind")return $n(a,s.slice(0,-1));const[_,g]=ll(u);return Hs(a,{type:"APPLY",path:s.map(x=>x.toString()),argumentList:_},g).then(Is)},construct(l,c){xa(n);const[u,m]=ll(c);return Hs(a,{type:"CONSTRUCT",path:s.map(_=>_.toString()),argumentList:u},m).then(Is)}});return Nm(o,a),o}function Lm(a){return Array.prototype.concat.apply([],a)}function ll(a){const s=a.map(va);return[s.map(r=>r[0]),Lm(s.map(r=>r[1]))]}const cl=new WeakMap;function Mm(a,s){return cl.set(a,s),a}function Kn(a){return Object.assign(a,{[sl]:!0})}function va(a){for(const[s,r]of al)if(r.canHandle(a)){const[n,o]=r.serialize(a);return[{type:"HANDLER",name:s,value:n},o]}return[{type:"RAW",value:a},cl.get(a)||[]]}function Is(a){switch(a.type){case"HANDLER":return al.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Hs(a,s,r){return new Promise(n=>{const o=Om();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 Om(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const pl=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-Bj5i72x4.js").href:new URL("assets/scriptsRunWorker-Bj5i72x4.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.packages.mjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});pl.onerror=a=>{console.error(a)};async function dl(a){return await _a.setInlayHints(a)}const ul=Un(pl),ml=Un(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-CG4IgAww.js").href:new URL("assets/parserTccWorker-CG4IgAww.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.packages.mjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function yl(a,s=!1){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ml.parseTcc(a,s,Kn(dl),{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){const{functions:r,types:n,constants:o,variables:l,methods:c}=nt;return await ml.parseLibraryCode(a,s,Kn(dl),{functions:Object.fromEntries(r),methods:Object.fromEntries(c),types:Object.fromEntries(n),constants:Object.fromEntries(o),variables:Object.fromEntries(l)})}async function Rm(a,s,r=!0){return await ul.runScript(a,s,r)}async function Fm(a){return await ul.removeScript(a)}function Bm(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:Um,forEach:$m}=[];function Km(a){return $m.call(Um.call(arguments,1),s=>{if(s)for(const r in s)a[r]===void 0&&(a[r]=s[r])}),a}const _l=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,jm=(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(!_l.test(n.domain))throw new TypeError("option domain is invalid");l+=`; Domain=${n.domain}`}if(n.path){if(!_l.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},fl={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=jm(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 Hm={name:"cookie",lookup(a){let{lookupCookie:s}=a;if(s&&typeof document<"u")return fl.read(s)||void 0},cacheUserLanguage(a,s){let{lookupCookie:r,cookieMinutes:n,cookieDomain:o,cookieOptions:l}=s;r&&typeof document<"u"&&fl.create(r,a,n,o,l)}},Wm={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 gl=()=>{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 Vm={name:"localStorage",lookup(a){let{lookupLocalStorage:s}=a;if(s&&gl())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupLocalStorage:r}=s;r&&gl()&&window.localStorage.setItem(r,a)}};let Sr=null;const bl=()=>{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 Gm={name:"sessionStorage",lookup(a){let{lookupSessionStorage:s}=a;if(s&&bl())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(a,s){let{lookupSessionStorage:r}=s;r&&bl()&&window.sessionStorage.setItem(r,a)}},Xm={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}},Ym={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}},Qm={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}},Zm={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 Jm(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:a=>a}}class xl{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=Km(r,this.options||{},Jm()),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(Hm),this.addDetector(Wm),this.addDetector(Vm),this.addDetector(Gm),this.addDetector(Xm),this.addDetector(Ym),this.addDetector(Qm),this.addDetector(Zm)}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)}))}}xl.type="languageDetector";const ey=(...a)=>{console!=null&&console.warn&&(As(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),console.warn(...a))},hl={},jn=(...a)=>{As(a[0])&&hl[a[0]]||(As(a[0])&&(hl[a[0]]=new Date),ey(...a))},wl=(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,wl(a,r))},vl=(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,wl(a,n))},ty=(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",sy=a=>typeof a=="object"&&a!==null,ry=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ay={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ny=a=>ay[a];let Wn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:a=>a.replace(ry,ny)};const iy=(a={})=>{Wn={...Wn,...a}},oy=()=>Wn;let Tl;const ly=a=>{Tl=a},cy=()=>Tl,py={type:"3rdParty",init(a){iy(a.options.react),ly(a)}},dy=N.createContext();class uy{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const my=(a,s)=>{const r=N.useRef();return N.useEffect(()=>{r.current=s?r.current:a},[a,s]),r.current},kl=(a,s,r,n)=>a.getFixedT(s,r,n),yy=(a,s,r,n)=>N.useCallback(kl(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(dy)||{},l=r||n||cy();if(l&&!l.reportNamespaces&&(l.reportNamespaces=new uy),!l){jn("You will need to pass in an i18next instance by using initReactI18next");const V=(A,L)=>As(L)?L:sy(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={...oy(),...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=>ty(V,l,c)),x=yy(l,s.lng||null,c.nsMode==="fallback"?_:_[0],m),h=()=>x,D=()=>kl(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=my(U),H=N.useRef(!0);N.useEffect(()=>{const{bindI18n:V,bindI18nStore:q}=c;H.current=!0,!g&&!u&&(s.lng?vl(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?vl(l,s.lng,_,()=>V()):Hn(l,_,()=>V())})},_y={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"},fy={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(xl).use(py).init({debug:!1,fallbackLng:"zh",interpolation:{escapeValue:!1},resources:{en:{translation:_y},zh:{translation:fy}}}),self.MonacoEnvironment={getWorker(){return new Bm({name:"Editor Worker"})}},In.config({paths:{vs:"https://my.tradingvue.com/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const gy=(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 Dm(A,L,D),x&&((ee=K.current)==null||ee.addLinkOpenFunc(x)),c&&((ne=K.current)==null||ne.addDiffDecorations()),Xu(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 yl(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(()=>Zu.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(yu,{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?nm:{},readOnlyMessage:{value:R("This script is read-only. It cannot be edited.")},...l},onMount:Q,onChange:V})})},by=N.forwardRef(gy),xy=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(cu,{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={},hy=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()}},wy=hy,Dl={"text/plain":"Text","text/html":"Url",default:"Text"},vy="Copy to clipboard: #{key}, Enter";function Ty(a){var s=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,s)}function ky(a,s){var r,n,o,l,c,u,m=!1;s||(s={}),r=s.debug||!1;try{o=wy(),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=Dl[s.format]||Dl.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=Ty("message"in s?s.message:vy),window.prompt(n,a)}}finally{c&&(typeof c.removeRange=="function"?c.removeRange(l):c.removeAllRanges()),u&&document.body.removeChild(u),o()}return m}var Dy=ky;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=Il(N),Iy=Il(Dy),Ay=["text","onCopy","options","children"];function Il(a){return a&&a.__esModule?a:{default:a}}function Al(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 ql(a){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Al(Object(r),!0).forEach(function(n){Xn(a,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(r)):Al(Object(r)).forEach(function(n){Object.defineProperty(a,n,Object.getOwnPropertyDescriptor(r,n))})}return a}function qy(a,s){if(a==null)return{};var r=Cy(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 Cy(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 Sy(a,s){if(!(a instanceof s))throw new TypeError("Cannot call a class as a function")}function Cl(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 zy(a,s,r){return s&&Cl(a.prototype,s),r&&Cl(a,r),Object.defineProperty(a,"prototype",{writable:!1}),a}function Ny(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 Ey(a){var s=My();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 Ly(this,o)}}function Ly(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 Sl(a)}function Sl(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function My(){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 zl=function(a){Ny(r,a);var s=Ey(r);function r(){var n;Sy(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(Sl(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,Iy.default)(_,h);g&&g(_,S),D&&D.props&&typeof D.props.onClick=="function"&&D.props.onClick(u)}),n}return zy(r,[{key:"render",value:function(){var o=this.props;o.text,o.onCopy,o.options;var l=o.children,c=qy(o,Ay),u=ka.default.Children.only(l);return ka.default.cloneElement(u,ql(ql({},c),{},{onClick:this.onClick}))}}]),r}(ka.default.PureComponent);Ta.CopyToClipboard=zl,Xn(zl,"defaultProps",{onCopy:void 0,options:void 0});var Oy=Ta,Yn=Oy.CopyToClipboard;Yn.CopyToClipboard=Yn;var Py=Yn;const Vs=id(Py);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 Nl(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(`
|